Open
Description
#4463 raises several points related to this.
Our step methods are built around the assumption that model variables dimensions are fixed during sampling, which we might want to relax. Such refactoring would probably be quite painful, so perhaps we could explore adding some variants of the step methods that allow for this, incrementally. Users would have to manually assign variables they know don't have a fixed shape to them, or we would need some extra logic in the step assignment to check if a variable has non-fixed size.
with pm.Model() as m:
x = pm.DiscreteUniform('x', 1, 10)
y = pm.Normal('y', 0, 1, size=x)
y_step = pm.FANCY_NUTS([y])
pm.sample(step=y_step)
Some aspects of this might prove trickier. @brandonwillard noted:
pymc3.parallel_sampling._Process
- The whole parallel sampling approach relies on a single set of fixed-shape shared memory arrays for each random variable, and the processes all appear to write to that set of memory. Unfortunately, that approach doesn't work when the random variables change shape during sampling. This doesn't need to be fixed immediately, but it is an unnecessary restriction caused by this specific approach to multi-processing.