Repository navigation
Conversation
model_from_fgraph wrapped a Deterministic in a view only when its variable was a basic RV. A Deterministic that only renames another Deterministic or a data variable became the same object as that variable, so clone_model, pm.do and freeze_dims_and_data lost one of the names. Pick one owner per underlying variable before replacing the dummies, the non-Deterministic model variable or else the first Deterministic in model order, and register every other Deterministic on it as a view. Closes pymc-devs#8608
A Deterministic that only renames a Potential also shared its variable, so cloning renamed the Potential. The owner rule already covers it; test it, type the owners map and say in the comment that the stable sort keeps the model order.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8656 +/- ##
=======================================
Coverage 92.24% 92.24%
=======================================
Files 130 130
Lines 21751 21754 +3
=======================================
+ Hits 20064 20067 +3
Misses 1687 1687
🚀 New features to boost your workflow:
|
anevolbap
marked this pull request as ready for review
November 20, 2026 18:40
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
model_from_fgraphwrapped a Deterministic in a view only when its variable was a basic RV. A Deterministic that only renames another Deterministic, a data variable or a Potential became the same object as that variable, so one of the names was lost in every transform built onmodel_from_fgraph:clone_model,pm.do,freeze_dims_and_data. Withy = pm.Deterministic("y", x + 1)andz = pm.Deterministic("z", y),clone_model(m).deterministicswas['y', 'y'], and samplingfreeze_dims_and_data(m)droppedzfrom the posterior. A Deterministic over apm.Datavariable or apm.Potentialrenamed that variable itself.Before the dummies are replaced,
model_from_fgraphnow picks one owner for each underlying variable: the RV, data variable or other non-Deterministic model variable, otherwise the first Deterministic in model order. Every other Deterministic on that variable is registered as a view of it, so each keeps its name and the renamed variable stays the base of the chain. An alias of an RV is a view, as before. A model in which no two model variables share an underlying variable is unchanged.This came up while reviewing pymc-labs/pymc-marketing#3396, where an alias of a cumulative-sum Deterministic was missing from a fitted MMM posterior; details in #8608.
Related Issue
Checklist
Type of change