Skip to content

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 5, 2025

First commit is just small refactor, second fixes the issue.

Reported by @jessegrabowski, where pymc model would hang before sampling. We need to update the ancestors_bitset when we implicitly "claim" a subgraph.

@ricardoV94 ricardoV94 added bug Something isn't working graph rewriting labels Oct 5, 2025
@ricardoV94 ricardoV94 force-pushed the fix_fusion_bug branch 4 times, most recently from 92595ba to 7c6eeb4 Compare October 6, 2025 12:53
Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

I approved too fast, it looks like you broke scan :D

@ricardoV94
Copy link
Member Author

I approved too fast, it looks like you broke scan :D

Oh well we don't lose much anyway

Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.67%. Comparing base (b05acfd) to head (ca797da).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/tensor/rewriting/elemwise.py 94.11% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (94.11%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1630      +/-   ##
==========================================
- Coverage   81.67%   81.67%   -0.01%     
==========================================
  Files         232      232              
  Lines       53132    53132              
  Branches     9410     9407       -3     
==========================================
- Hits        43396    43395       -1     
- Misses       7283     7284       +1     
  Partials     2453     2453              
Files with missing lines Coverage Δ
pytensor/tensor/rewriting/elemwise.py 93.46% <94.11%> (-0.17%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94
Copy link
Member Author

good news: it works now. bad news: mypy ...

continue

# Finished exploring this subgraph
all_subgraphs_bitset |= subgraph_bitset
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 was what was causing the scan tests to fail. If we add the subgraph_bitset of failed nodes to all_subgraphs_bitset it then causes a failure in the sorting of the subgraphs below, because it was trying to sort wrt to these ones that don't matter.

Copy link
Member

Choose a reason for hiding this comment

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

What was the original logic of including it? Or was it just a mistake

Copy link
Member Author

@ricardoV94 ricardoV94 Oct 7, 2025

Choose a reason for hiding this comment

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

original this variable was meant more as a collection of "variable that were claimed or known to not be fuseable", so it would fulfill the second goal. But that info was not used anywhere in the latest iteration. Instead we only use this for the sorting bit at the end.

):
break # bingo
else: # no-break
raise RuntimeError(
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 would have raised in the failing scan test, showing our sorting failed

When a subgraph with multiple outputs is "implicitly" claimed, it can change the dependencies of remaining nodes. A node that depended only on a subset of the subgraph outputs now depends on all of them. Not taking this into account could lead to circular dependent Composites
@ricardoV94 ricardoV94 marked this pull request as ready for review October 7, 2025 19:55
@ricardoV94 ricardoV94 merged commit b6a9b68 into pymc-devs:main Oct 7, 2025
63 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working graph rewriting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants