Closed
Description
Describe the issue:
When a variable is defined with a coord, it's considered volatile. Then sample_posterior_predictive
does not transfer the node over.
I believe the volatility condition that's met is
Lines 208 to 212 in 9eaf92a
The coord is intended to be immutable, but after #7047, coords always mutable
Somewhat related:
- Make
sample_posterior_predictive
API less surprising #7069 sample_posterior_predictive
does not consider changes in "ConstantData" and "Constant coords" #6876- sample_posterior_predictive wrongly considers Deterministic variables as source of volatility #7183
(lmk if this issue is considered a duplicate of anything)
Reproduceable code example:
import pymc as pm
y_obs = [0] * 3
with pm.Model() as m:
m.add_coord("coord0", length=1)
x = pm.Data("x", [0] * 3)
b = pm.Normal("b", dims="coord0") # Causes `b` to be volatile
# b = pm.Normal("b", shape=1) # Works as expected (`b` is transferred)
y = pm.Normal("y", b[0] * x, observed=y_obs)
idata = pm.sample()
pm.sample_posterior_predictive(trace=idata, var_names='y')
Error message:
Sampling: [b, y]
PyMC version information:
5.15.1
Context for the issue:
Cannot use sample_posterior_predictive
as intended