fix undefined values for tail elements in act quant kernels#4186
Merged
iamzainhuda merged 1 commit intomainfrom Mar 27, 2026
Merged
fix undefined values for tail elements in act quant kernels#4186iamzainhuda merged 1 commit intomainfrom
iamzainhuda merged 1 commit intomainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4186
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 1d57301 with merge base 96a9cdf ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
danielvegamyhre
approved these changes
Mar 26, 2026
Contributor
danielvegamyhre
left a comment
There was a problem hiding this comment.
Lgtm, thanks for fixing this!
Contributor
|
(this fix is indeed needed, just note that the triton fp8 blockwise gemms were experimental and not performant, not actually used. we use torch._scaled_mm which dispatches to cublas) |
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.
Summary
Fixed a tail-handling bug in the blockwise FP8 activation quantization kernels that was corrupting reciprocal scale tensors and causing
test_triton_fp8_gemm_1x128_128x128to fail on ragged shapes.The GEMM consumes a_s / b_s scale tensors produced by the quantization kernels, and those scale tensors could be corrupted at the tensor edges. In the LHS activation quant kernel, masked tail lanes were still storing scales into a compact column-major as_strided buffer. Because that buffer has no padding, logically invalid row writes could alias valid scale entries from the next column. The GEMM then used those corrupted scales and SQNR collapsed on small or ragged M.
Updated RHS and LHS blockwise quant kernels with
tl.load(..., other=0.0)for masked tail loads. And masked reciprocral scaletl.storecalls so invalid lanes don't write to scale buffers.Failures before fix:

Testing
pytest -q test/prototype/blockwise_fp8_training/test_blockwise_kernels.py -k test_triton_fp8_gemm_1x128_128x128pytest -q test/prototype/blockwise_fp8_training/test_blockwise_kernels.py