-
Notifications
You must be signed in to change notification settings - Fork 447
Fixing the Python bridge's loop and scope emission #5251
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
Open
sacpis
wants to merge
24
commits into
NVIDIA:main
Choose a base branch
from
sacpis:fix_python_bridge_issues
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8390ca2
freeing qubits allocated in an if branch
sacpis 12dfd60
freeing qubits allocated in a loop body
sacpis 6478123
freeing qubits allocated in a loop else block
sacpis 9a89901
fixing memtoreg dropping a copy of the loop counter
sacpis d789931
emitting for-range loops in memory form
sacpis 5e31634
dropping loop-carried values that nothing reads
sacpis de7fd8e
fixing spelling
sacpis e5c1d4c
Merge branch 'main' into fix_python_bridge_issues
sacpis fe158c0
freeing qubits on the break path out of nested scopes
sacpis b877171
Merge branch 'main' into fix_python_bridge_issues
sacpis 1f4fdae
Merge branch 'main' into fix_python_bridge_issues
sacpis 9172c7e
* making cc.continue and cc.break region-branch terminators
sacpis b14aa1c
running a loop's else block when the loop is unrolled or fused
sacpis 0ae8b28
Merge branch 'main' into fix_python_bridge_issues
sacpis 9f0b9f1
Merge branch 'main' into fix_python_bridge_issues
sacpis 04e3fa4
Merge branch 'main' into fix_python_bridge_issues
sacpis e0a9f31
Merge branch 'main' into fix_python_bridge_issues
sacpis a6d3100
Merge branch 'main' into fix_python_bridge_issues
sacpis f46c960
reverting the block argument elimination attempt
sacpis ea82c73
dropping the for/else fixes now in #5282
sacpis 07324e6
binding only the copy's target when a promoted def becomes a block ar…
sacpis 22ba27b
Merge branch 'main' into fix_python_bridge_issues
sacpis 7795ca5
Merge branch 'main' into fix_python_bridge_issues
sacpis 1cdc065
Merge branch 'main' into fix_python_bridge_issues
sacpis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was going to be removed, eh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pass is what lets two workarounds on main go away. Both are from #5233.
allocasinking invisit_For/__analyzeLoopLocalTargets(the bare cc.alloca in the loop body)isNestedInLoopguard inVariableCoalesce.cpp, which refuses to raise anyallocanested in a cc.loopThis branch deletes both and prunes the dead loop-carried values in the optimizer instead. #5223 needs one of the three. With the pass disabled and nothing else changed,
test_5223.pyfails with the original 'arith.addi' op control-flow def-use not reversible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
So the isNestedInLoop stuff to move cc.alloca around is misplaced and possibly redundant with what stack-frame-prealloc does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agreed on the front end, and that's what this PR does. The bridge emits
cc.scopeforif/elseand loop bodies now, and the sinking that produced the barecc.allocais gone.The
isNestedInLoopguard was a consequence of that same front end bug.variable-coalescesays itrelies on the correct and proper construction and use of cc.scope ops,and the bridge emitted none, so #5233 guarded the pass instead of fixing the IR. With scopes emitted the guard is not needed, andcoalesce.qke's f2 goes back to 2 slots from 4.stack-frame-preallocis downstream of this (it runs inaddLowerToCFGAndCleanupafter lowering to CFG, whereasapply-op-specializationruns on the high-level IR, so it cannot cover this case).