Wrong gradient in updated stan -- unsure if rstan or stan problem

Nice, looks like that did something:

> g_mat4[1]
[1] -0.13125
> gnum_mat4
[1] -0.13125
> g_mat40[1]
[1] -0.1003125
> gnum_mat40
[1] -0.1003125
1 Like

@Charles_Driver @andrjohns there was definitely a problem. Patch in the pipeline: Fix `cholesky_decompose` not updating adjoints correct (2.26) by bbbales2 · Pull Request #2365 · stan-dev/math · GitHub

The way the code was written it would work as long as the input to the decomposition was used nowhere else and each scalar in the input was its own autodiff variable. Something like that.

There’s a test now to fix this. This is probably something we should add to out automatic tests. There was another one like this recently: Fix dirichlet_lpdf and multi_normal_cholesky_lpdf adjoints by t4c1 · Pull Request #2331 · stan-dev/math · GitHub

4 Likes

Thanks Ben, what a turnaround!

EDIT: @Charles_Driver I just ran your test code with the patched cholesky_decompose and everything lines up now. Thanks for picking up on this!

5 Likes