Hitting a weird error to do with RNGs in Scan in a custom function inside a Potential

Unfortunately, those are completely different, because the grad can’t see the graph outside of scan when defined like that. That’s stated explicitly in the docs (second box):

https://pytensor.readthedocs.io/en/latest/tutorial/gradients.html#computing-the-jacobian

I fixed that in my WIP refactor of Scan because it’s extremely unintuitive.

Anyway there is a known bug when you try to get a gradient of a Scan wrt to something that used to have RVs but no explicit updates. I never managed to narrow down that but here is where it was last discussed:

Anyway I’ll try to actual check it locally

1 Like