Repository navigation
fix(lowering): order if/else phi and yield names by first definition - #777
Merged
Merged
Conversation
Contributor
|
Contributor
☂️ Code Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
weinbe58
approved these changes
Oct 10, 2026
Contributor
Backport results for 9be49b5Succeeded:
|
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.
Fixes #775.
lower_Ifin both thecfandscflowerings collected the names that need a join argument (cf) or a yield (scf) in aset[str], then built the IR by iterating it. String hashes are randomized per process, so the same kernel lowered to IR with a different argument/yield order in each process. Each lowering was still correct, because every loop iterates the same set, but the IR text and any hash of it changed between runs.This causes misses in the on-disk compile cache (#769). The key is computed from the lowered IR, so a new process often computes a new key for an unchanged kernel, then recompiles it and saves another copy. Callers are affected too, because a kernel's key includes its callees' keys.
Changes
dialects/lowering/cf.py:phiis adict[str, None]instead of aset[str].dialects/scf/lowering.py:all_names = dict.fromkeys([*body_frame.defs, *else_frame.defs]).Names now come out in the order they are first defined: the condition, then the then-branch's names, then names assigned only in the else branch.
Tests
test_ifelse_order_independent_of_hash_seed(test/lowering/test_ifelse.py) lowers oneif/elsewithbasic_no_optandstructural_no_optin fresh processes under 4 hash seeds, and checks that every run gives['flag', 'x', 'y']. Onmainit fails: 4 seeds give 4 different orders.