-
Notifications
You must be signed in to change notification settings - Fork 293
Fix potential out-of-bound access in int8_mm.py #1751
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1751
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 62f7334 with merge base 1c76736 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
cc @Jokeren |
@mark14wu A clearer fix can be done using |
Thank you for the interest! Didn't know there are people looking at this code 😄. I copied this code from PyTorch Inductor though. Does that mean Inductor is susceptible to this bug too? (or inductor allocates padded tensors so it's not an issue?) Like @Jokeren said, Another question. It seems like we might do out-of-bound reads for M and N dims too? |
Yes indeed, but our tool, a triton sanitizer, cannot work for pytorch inductor at this moment. Hao may want to explore this direction when he starts intern at meta this summer.
M and N dims are safe because we have protections with @mark14wu please go ahead refactor the code with triton.heuristic |
There are ways to turn inductor code into triton only repos |
Now refactored with |
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.
@mark14wu You can run ruff formatting then we can merge. Thank you!
Done. Please merge, thanks! |
This PR fixes a bug in
_scaled_int8_mm_kernel
allowing unmaskedtl.load()
calls whenK
was even, but not necessarily a multiple ofBLOCK_K
, causing out-of-bounds reads. The fix changes the check toK % BLOCK_K == 0
, ensuring unmasked loads occur only when the last block is fully valid.