Repository navigation
[Triton/Gluon] batched_gemm_a16wfp4: ragged-K regression test and operand shape validation - #4685
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
b496a0a to
15d7ce8
Compare
|
fix merged in #4181, rebase to only contain test and host side assert. |
There was a problem hiding this comment.
🟡 Changes recommended
The wrapper’s new K alignment assert is implemented on an implicitly overwritten K value without enforcing x.K == 2*w.K, and the new test imports internal _triton_kernels config helpers instead of using the public config loader.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
op_tests/triton_tests/gemm/batched/test_batched_gemm_a16wfp4.py:214
- After switching to
get_gemm_config, update the config fetch here to avoid calling the internal_get_config. The wrapper ultimately resolves configs by name with the unpacked K (2*packed K), so passKdirectly (this test'sKis already unpacked).
config, _ = _get_config(M, N, K // 2)
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
15d7ce8 to
117df53
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Input validation is still incomplete for w_scales shape (remaining OOB risk), and the new regression test is brittle against future tuning changes without pinning/sanitizing split-K behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
117df53 to
60614a7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new regression test currently relies on overriding tuning parameters via config=, which is brittle and should be adjusted to exercise the desired path without hardcoding tuning behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
60614a7 to
c8f6fec
Compare
c8f6fec to
6bad281
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Safety-critical validations use assertions that disappear under optimized Python, allowing out-of-bounds accesses.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
aiter/ops/triton/gemm/batched/batched_gemm_a16wfp4.py:120
- This is the safety check intended to prevent the scale-buffer OOB read, but optimized Python removes it. An undersized
w_scalestensor would then still be launched. Make this an unconditional runtime check rather than an assertion.
assert w_scales.shape == (
Bw,
N,
K_unpacked // 32,
), f"w_scales must have shape {(Bw, N, K_unpacked // 32)}, got {tuple(w_scales.shape)}"
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
612aa8a to
0850418
Compare
c3e584c to
4006823
Compare
|
@lijinpei-amd do we need the additional test cases? can't we merge it into existing unit tests? |
The kernel-side fixes for the EVEN_K == False path landed separately in ROCm#4181, so only the guards and the regression coverage remain here. The coverage goes into the existing test rather than a test of its own. ROCm#4181 fixed two bugs, which were not the same kind. A's mask compared unpacked offsets against the packed K, so it was too tight and silently dropped valid activations. The w_scales load was unmasked and genuinely read off the end of the scale tensor. The existing K=192 shape only caught the second one by luck, whenever the bytes past the allocation happened to be 0xFF. generate_batched_gemm_a16wfp4_inputs now places w_scales at the head of a 0xFF-filled buffer, which is NaN in e8m0 and which dot_scaled propagates even where the masked-off data is zero, so every shape in the file fails loudly on an out-of-bounds scale read. K=192 also hits the tail in the first and only K iteration. Add two K=1120 shapes, which tuned configs run as four full iterations and a ragged fifth. 1120 is 35 * 32, so it leaves a tail under any BLOCK_SIZE_K >= 64, and no config override is needed to keep a re-tune from moving these shapes onto EVEN_K == True. Re-injecting either ROCm#4181 bug fails all 24 ragged-K cases. In the wrapper, x's K was read and then immediately shadowed by w's, so nothing checked that the two operands agreed on K. Name them apart and assert x.K == 2 * w.K explicitly. Hang the mxfp4 multiple-of-32 check off the unpacked K rather than off an implicit contract, and check the w_scales shape too: the kernel bounds those loads from K rather than from the tensor, so an undersized scale tensor reads out of bounds instead of failing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
4006823 to
e421f4c
Compare
Merged into test_batched_gemm_a16wfp4 |


No description provided.