Skip to content

Conversation

lucianopaz
Copy link
Member

@lucianopaz lucianopaz commented Aug 6, 2025

Description

This PR fixes the determination of independent_rvs RVs in vectorize_over_posterior. I think that the fixed check is much clearer now. It says that an rv is independent if it doesn't depend on an output, a needed_rv (a model freeRV that is replaced by its posterior samples), or another independent_rv. To make sure the check works correctly, the candidate rv nodes are searched in the order given by their topological sort.

Related Issue

Checklist

Type of change

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

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

Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (0960323) to head (dcb68e6).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7890   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files         116      116           
  Lines       18851    18851           
=======================================
+ Hits        17521    17522    +1     
+ Misses       1330     1329    -1     
Files with missing lines Coverage Δ
pymc/sampling/forward.py 96.73% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lucianopaz lucianopaz requested a review from ricardoV94 August 6, 2025 09:49
Copy link
Member

@ricardoV94 ricardoV94 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, some small comments

and not ({*outputs, *independent_rvs} & set(rv_ancestors))
and {var for var in rv_ancestors if var in all_rvs} <= {rv, *needed_rvs}
if rv not in needed_rvs and not (
{*outputs, *needed_rvs, *independent_rvs} & set(rv_ancestors)
Copy link
Member

Choose a reason for hiding this comment

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

outputs / needed_rvs / independent_rvs are also the blockers store than in an intermediate variable?

Copy link
Member

Choose a reason for hiding this comment

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

filter rv not in needed_rvs already in the list comp that starts this loop?

Comment on lines +1985 to +1986
a_ancestor1 = get_var_by_name([vectorized_no_intermediate], "a")[0]
a_ancestor2 = get_var_by_name([vectorized_intermediate_rvs], "a")[0]
Copy link
Member

Choose a reason for hiding this comment

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

Assuming there should only be one match:

Suggested change
a_ancestor1 = get_var_by_name([vectorized_no_intermediate], "a")[0]
a_ancestor2 = get_var_by_name([vectorized_intermediate_rvs], "a")[0]
[a_ancestor1] = get_var_by_name([vectorized_no_intermediate], "a")
[a_ancestor2] = get_var_by_name([vectorized_intermediate_rvs], "a")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vectorize_over_posterior fails to determine independent_rvs
2 participants