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

Do not reject PatternNodeRewriter due unrelated multiple clients #789

Merged
merged 1 commit into from
May 30, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented May 30, 2024

Description

The existing check was to restrictive, because it would reject a rewrite due to completely unrelated multiple clients above the replaced subgraph, as well as multiple uses of the output being replaced, neither of which make sense.

Checklist

Type of change

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

@ricardoV94 ricardoV94 force-pushed the pattern_node_rewriter_clients branch from 1e9b9c5 to 5a246b7 Compare May 30, 2024 10:56
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.

Looks fine to me. Do we know the original logic behind not allowing multiple clients? On first blush, it seems like it shouldn't have ever mattered.

tests/graph/rewriting/test_basic.py Show resolved Hide resolved
@ricardoV94
Copy link
Member Author

ricardoV94 commented May 30, 2024

Looks fine to me. Do we know the original logic behind not allowing multiple clients? On first blush, it seems like it shouldn't have ever mattered.

That's the default and the point is to avoid rewrites that accidentally split the work and end up with a graph that recomputes the same thing in different ways. This happens when a separate variable in the graph depends on one of the intermediate computations of the pattern being substituted. Those intermediate computations would remain in the graph anyway.

The way they did it was way too crude though. Also not sure if this should be the default, but that can be a discussion for another time.

@ricardoV94
Copy link
Member Author

Actually @jessegrabowski I think the issue wan introduced when the old unification code was scrapped in favor o the external library: 459c570

@ricardoV94 ricardoV94 force-pushed the pattern_node_rewriter_clients branch from 98e88e1 to 5a246b7 Compare May 30, 2024 12:10
@jessegrabowski jessegrabowski self-requested a review May 30, 2024 12:54
@ricardoV94 ricardoV94 merged commit ec45e25 into pymc-devs:main May 30, 2024
96 of 106 checks passed
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.

2 participants