VI fitting of custom pdf sporadically producing 'nan' parameter values which terminate fit

I think you are using CDF normly. The problem is that it still underflows easily.

Any chances you can work in log scale all the time? Here was a recent post where working on the log scale helped avoid similar type of issues: Replacing nested for loops from JAGS code for cognitive model of temporal discounting - #3 by ricardoV94