-
Notifications
You must be signed in to change notification settings - Fork 108
Fix KeyError 'i23' with symbolic shapes and reshape bsyms
#2764
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: beverlylytle <[email protected]>
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.
Pull Request Overview
This PR fixes a KeyError 'i23' that occurs when using symbolic shapes with reshape bsyms in the alias update mechanism. The fix ensures that when reshaping aliased inputs with different shapes, the symbolic shape is properly acquired using prims.shape before performing the reshape operation.
Key Changes:
- Modified
replace_args_with_alias_mapto insertprims.shapebsym beforereshapewhen using symbolic values - Added test coverage for aliasing with viewed inputs of different shapes
- Updated existing tests to parameterize cache mode ("constant values" vs "symbolic values")
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| thunder/core/update_aliases.py | Updated reshape handling to include shape acquisition for symbolic values and changed from single bsym to tuple of bsyms |
| thunder/tests/test_update_aliases.py | Added cache parameterization to existing tests and new test for viewed inputs with different shapes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return y | ||
|
|
||
| a = make_tensor((2, 3), dtype=torch.float32, device=device) | ||
| jfn = executor.make_callable(fn, skip_inplace_alias_updates=True) |
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.
I removed skip_inplace_alias_updates=True assuming it was meant to be deleted in 3df3d26. Maybe this test didn't work back then without this option.
|
While this PR makes sense for what I imagine to be most cases, I think we are still not gracefully handling the following situation: In the second application of |
|
Hmm, that's a good point. I will wait until seeing how #2760 (comment) will end up. |
Partial fix for #2677.
update_aliases.pymanually insertsreshapebsyms for aliases with different shapes. In this PR, we additionally insertprims.shapeto acquire the new symbolic shape in the trace.The tests will fail due to this line.
lightning-thunder/thunder/core/update_aliases.py
Line 75 in 1a2c7d9
It will disappear once #2760 is merged.