Test_grad: No Output

I’m trying to compare autodiff and finite differencing results to make sure everything is working okay, but when I run sampling in rstan with test_grad = TRUE and file ‘reparam.stan’, all it says is:

“TESTING GRADIENT FOR MODEL ‘reparam’ NOW (CHAIN 1).”, with nothing after it. I’m a fairly new Stan user, is this a common problem? I’m new to the forum as well, but did my best to search around and couldn’t find anything. I’ve tried running on a Linux cluster and on Windows, so I don’t think it’s an OS issue. I also made sure I have the latest version of rstan. If it’s helpful, here’s my model block:

model {
// Likelihood
Z ~ normal(theta , t);

// Priors
x_tilde ~ normal(0,1);
y_tilde ~ normal(0,1);
mu_tilde ~ normal(0,1);
tau ~ inv_gamma(0.1, 0.1);

for (n in 1:J){
w_tilde[n] ~ normal(0,1);
lat ~ gamma(nu/2, nu/2);

// Hyperpriors
v ~ lognormal(-2, 3);
nu ~ lognormal(-2, 1);
sigma ~ inv_gamma(0.1, 0.1);


That seems to be all it prints in rstan (just checked for my own model).

Cmdstan gives more verbose output. What was it you were looking for?

Oh you already told me I guess. Hmm, I guess if you want to check gradients make sense in different places, you can do grad_log_prob and check against finite differences of log_prob.

I guess that’s what you were hoping test grad would do for you? I agree, seems a little cludgy to do it yourself but usually we just assume the autodiff is correct unless we have a reason to believe otherwise. Which I guess sounds dangerous. Is there something particularly finicky about your model that isn’t shown there? All the stuff there I think it’s fair to assume it works (knock on wood).

Yeah, based on the documentation I thought I’d get a table printout with autodiff and finite difference calculations and the difference beteween them. They probably are the same, but I thought it would be a quick check to see. My tree depth needs to be set to 14 and adapt_delta to 0.99, and while I think it’s probably because of other issues in the model, I wanted to check this first.

Thanks for the grad_log_prob/log_prob and the cmdstan suggestions. I’ll check those out.