Do not recompile identical OFG in same graph#2209
Merged
ricardoV94 merged 5 commits intoJun 15, 2026
Merged
Conversation
5bd4f4a to
d464497
Compare
c80bda8 to
9c40d08
Compare
jessegrabowski
approved these changes
Jun 13, 2026
9c40d08 to
1f83063
Compare
… graphs clone_v_get_shared_updates recursed once per graph node, overflowing Python's call stack on graphs deeper than the recursion limit. Rewrite it as an explicit-stack depth-first traversal with identical semantics.
1f83063 to
f9f8def
Compare
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.
Draft: as it includes commits from #2056
Repeated OpFromGraph make a lot of sense for deep machine learning graphs. This PR makes more use of this functionality.
In the JIT backends: don't redefine / rewrite the same fgraph.
Numba compile is usually slower than our rewrites, and our caching mechanism already "deduplicates" the functions numba sees. So this is only a %speedup never much absolute. (Big speedup with cache=False, but we are not optimizing for that if it was our goal)
Also when dprint don't show identical copies:
Before:
After: