Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when freezing model with partially observed RVs #7388

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jun 24, 2024

Description

The problem was that the constant_fold call in create_partially_observed_rv was cloning the shared variable that defined the dim_length, and therefore it could no longer be replaced by it in freeze_data_and_dims

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

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

@ricardoV94 ricardoV94 added the bug label Jun 24, 2024
@ricardoV94 ricardoV94 requested a review from aseyboldt June 24, 2024 20:31
@@ -1045,7 +1045,7 @@ def constant_fold(
attempting constant folding, and any old non-shared inputs will not work with
the returned outputs
"""
fg = FunctionGraph(outputs=xs, features=[ShapeFeature()], clone=True)
fg = FunctionGraph(outputs=xs, features=[ShapeFeature()], copy_inputs=False, clone=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be safe, as we can never mutate inputs accidentally (there is no such operation)

Copy link
Member

@aseyboldt aseyboldt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the fast fix :-)

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.19%. Comparing base (7af0a87) to head (e2f86cb).
Report is 84 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7388   +/-   ##
=======================================
  Coverage   92.19%   92.19%           
=======================================
  Files         103      103           
  Lines       17214    17214           
=======================================
  Hits        15870    15870           
  Misses       1344     1344           
Files with missing lines Coverage Δ
pymc/pytensorf.py 90.44% <100.00%> (ø)

@ricardoV94 ricardoV94 merged commit b496127 into pymc-devs:main Jun 25, 2024
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants