-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[dynamic shapes] stop writing Max(*, 1) for strides #150376
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/150376
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit 3d7ac71 with merge base 9810488 ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…torch into pianpwk/max_1_strides
@@ -885,7 +885,7 @@ def test_non_overlapping_and_dense_unbacked(self): | |||
cf( | |||
torch.empty_strided( | |||
(2, 3, 1, u0), | |||
(3 * Max(1, u0), Max(1, u0), Max(1, u0), 1), | |||
(3 * u0, u0, u0, 1), |
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 test case is no longer relevant
sym_shape_meta.strides_[last_idx] = c10::SymInt(1); | ||
for (auto i = last_idx - 1; i >= 0; --i) { | ||
sym_shape_meta.strides_[i] = sym_shape_meta.strides_[i + 1] * | ||
sym_shape_meta.sizes_[i + 1].max(1); | ||
if (TORCH_GUARD_OR_TRUE(sym_shape_meta.sizes_[i + 1].sym_gt(1))) { |
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.
we used to generate max(u0, 1)
and now we generate just u0 unconditionally?
can you explain why this is safe?
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.
Back to your queue to address @laithsakka's comments around safety
@laithsakka @pianpwk I wonder for these guard_or_true cases if we should by default always add a comment about safety just like how rust does this with unsafe blocks: https://std-dev-guide.rust-lang.org/policy/safety-comments.html
When handling strides, avoiding generating Max(u0, 1) expressions if we can, since it'll be hard to deal with these once we move away from guard_size_oblivious.
Looking at what the code was before sym_max was introduced (#94400 in
_prims_common/__init__.py
), this change seems appropriate.