The problem is likely that when you are parameterizing with mu and sd, some times the value fall out of support. For example, you can see here for a similar problem and discussion: Beta Regression in pyMC3 - #6 by bdyetton
Here you can find more information and potential solution to NaN occurred in optimization
and Bad initial energy
problem.