pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.47k stars 1.97k forks source link

Fix bug in Truncated with Deterministic inputs #7315

Closed ricardoV94 closed 1 month ago

ricardoV94 commented 1 month ago

When using Deterministic, variables get wrapped in an identity operation. When attempting to define an icdf, the logp graph rewrites would remove this useless operation from the graph of the underlying RV and cause a mismatch between explict and implicit inputs of the inner graph of TruncatedRV

Description

Related Issue

Checklist

Type of change


📚 Documentation preview 📚: https://pymc--7315.org.readthedocs.build/en/7315/

ricardoV94 commented 1 month ago

CC @tomicapretto

jessegrabowski commented 1 month ago

What's the point of wrapping Deterministics with a useless identity Op?

ricardoV94 commented 1 month ago

What's the point of wrapping Deterministics with a useless identity Op?

So they are different PyTensor variables, when you do pm.Deterministic("y", pm.Normal("x")) or repeated Deterministic on the same variables

ricardoV94 commented 1 month ago

The copy was added in https://github.com/pymc-devs/pymc/pull/3170

ricardoV94 commented 1 month ago

Looks like a PyTensor rewrite bug, it thinks it has a variable but it has a list, and it's trying to call .dtype on it

ricardoV94 commented 1 month ago

@tomicapretto the issue you reported is independent of these changes, and should be fixed by https://github.com/pymc-devs/pytensor/pull/773

I'm going to go ahead and merge this