Repository navigation
[Triton/Gluon] [gfx1250] fp8_mqa_logits: fix epilogue store masks for cu_start != 0 - #4687
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
99c2e68 to
f8a88f6
Compare
f8a88f6 to
26a34e7
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The updated/new tests re-quantize kv after dequantization, overwriting kv_fp8/scales and making the kernel inputs inconsistent with the KV used by the reference computation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes a gfx1250 Gluon fp8_mqa_logits masking bug when the per-row KV window starts at a non-zero column (cu_start != 0), and extends the test suite to cover this regression scenario.
Changes:
- Correct epilogue mask KV-position computation in the gfx1250 Gluon kernel so
start_indis not incorrectly scaled byBLOCK_KV. - Tighten the main fp8_mqa_logits correctness threshold and align the reference
qwith the fp8-quantized input. - Add a regression test covering non-zero
cu_startwindows (vLLM-style packed prefill).
File summaries
| File | Description |
|---|---|
| op_tests/triton_tests/attention/test_fp8_mqa_logits.py | Adds non-zero cu_start regression coverage and ref/input alignment for tighter correctness checks. |
| aiter/ops/triton/_gluon_kernels/gfx1250/attention/fp8_mqa_logits.py | Fixes epilogue store mask KV index computation for non-zero start offsets. |
Review details
Suppressed comments (1)
op_tests/triton_tests/attention/test_fp8_mqa_logits.py:248
- This re-quantizes kv after it was already quantized/dequantized above, overwriting kv_fp8/scales and making the kernel inputs inconsistent with the kv used in ref_fp8_mqa_logits. The regression test should use the same kv_fp8/scales pair that kv was derived from to avoid comparing against a different effective KV.
kv_fp8, scales = per_custom_dims_cast_to_fp8(kv, (0,), False)
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
26a34e7 to
f7f8f87
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The kernel fix is straightforward and the added/updated tests cover the reported regression, with only minor test-reference precision/doc nits noted.
Review details
Suppressed comments (2)
op_tests/triton_tests/attention/test_fp8_mqa_logits.py:250
- This comment says kv is an "exact dequantization" of (kv_fp8, scales), but the code currently casts kv to bfloat16, which is not exact. Please update the comment to match the intended dtype/behavior (or keep kv in fp32 as above).
# kv_fp8/scales above are the kernel inputs and kv is their exact
# dequantization; re-quantizing kv here would hand the kernel a slightly
# different KV than the reference sees.
op_tests/triton_tests/attention/test_fp8_mqa_logits.py:246
- Same as kv: converting Q from fp8 -> fp32 -> bf16 adds an avoidable rounding step before the reference. Keeping q in fp32 makes the reference use the exact dequantized fp8 values.
q = q_fp8.to(torch.float32).to(torch.bfloat16)
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
f7f8f87 to
b050c38
Compare
b050c38 to
1bdaa25
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The kernel fix is narrowly scoped, logically consistent with surrounding indexing, and is backed by a targeted regression test that exercises the previously failing non-zero cu_start cases.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟢 Approval recommended
The kernel fix is a targeted correctness change and is backed by a new regression test that exercises the previously failing nonzero-cu_start scenario.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
1bdaa25 to
7662453
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The kernel fix is localized and consistent with how start_ind/end_ind are used elsewhere, and the added regression test directly covers the reported nonzero-cu_start failure mode.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
@lijinpei-amd Could you resolve conflicts? |
|
@lijinpei-amd pinging again so we can get this merged. |
|
No activity for 15 days, so this is now labelled |
…rt != 0 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… tolerance The reference was fed the pre-quantization q while the kernel got q_fp8, so the comparison carried an e4m3 rounding error that the tolerance had to absorb. Round-trip q through e4m3 for the reference instead. kv had the mirror problem from the other side: it was quantized, dequantized into the reference input, then quantized a second time into the kernel input. That second cast is not exactly idempotent -- the reciprocal scale and the bf16 dequant move elements sitting near an e4m3 rounding boundary -- so the kernel saw a slightly different KV than the reference. Drop it and reuse the pair kv was dequantized from. Dequantize both to fp32 rather than back to bf16 as well. bf16 holds every e4m3 value exactly, so it costs q nothing, but kv is a product of an e4m3 value and an fp32 scale and bf16 rounds it away from what the kernel sees. With both inputs matched, tighten the tolerance to 1e-4. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
7662453 to
8e61164
Compare
No description provided.