Repository navigation
[Triton/Gluon] fp8_mqa_logits: Do not recompile per batch size on gfx950 - #7022
Conversation
seq_len, seq_len_kv and num_kv_splits change with the batch, and Triton specialized _gluon_fp8_mqa_logits_kernel on each (divisible by 16, and a separate key for 1), so a serving prefill compiled a new variant whenever the query row count changed class. The gl.int32 annotations do not stop this. Their divisibility does not change the generated gfx950 code. Mark them do_not_specialize, and add a test that query row counts 16, 17, 1 and 33 reuse one compiled variant, with logits checked against the reference. Signed-off-by: Rony Leppänen <[email protected]> Co-authored-by: Claude <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 Changes recommended
The FP8 MQA logits tests duplicate input setup, which should be extracted into a shared helper to avoid keeping changes synchronized manually.
1 open issue
What changed in this PR
This PR prevents batch-dependent recompilation of the gfx950 Gluon fp8_mqa_logits kernel while preserving specialization for launch configurations.
Changes:
- Disables integer specialization for query rows, KV rows, and KV splits.
- Adds a gfx950 regression test that checks output accuracy and requires one compiled variant across four query-row counts.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_fp8_mqa_logits.py |
Adds accuracy and compilation-cache checks for varying query-row counts. |
aiter/ops/triton/_gluon_kernels/gfx950/attention/fp8_mqa_logits.py |
Marks three runtime arguments as non-specializing. |
Review effort: Balanced
…alization test The specialization test repeated the input setup and the reference check of test_fp8_mqa_logits. Call that test for each query row count instead, with the same 64 heads, 1024 KV rows and checks. Signed-off-by: Rony Leppänen <[email protected]> Co-authored-by: Claude <[email protected]>
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
|
@eppaneamd Could you take a look at the review I added? |
No conflicts: main has not changed either of this branch's two files since the previous merge. Signed-off-by: Rony Leppänen <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Review on #7022: the compiled-variant count is a minor thing to test for. test_fp8_mqa_logits_query_rows_do_not_add_specializations is removed; the kernel change stands alone. Signed-off-by: Rony Leppänen <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
LGTM! I think any kind of warmup should capture these recompilations as there are very few modes and these args are not constexpr but still an improvement! |
…h size on gfx950 PR head 5a90ed9, applied as its diff against merge base 1eab5ae. Co-authored-by: Cursor <[email protected]>
…h size on gfx950 PR head 5a90ed9, applied as its diff against merge base 1eab5ae. Co-authored-by: Cursor <[email protected]>
This branch carries #7022 unchanged, so the file matches the -base branch again. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The JIT specialization change requires gfx950 runtime testing to confirm compile-cache reuse and performance across supported Triton versions, which source-only review cannot establish.
No open issues 🎉
Review effort: Balanced

Summary
On gfx950,
fp8_mqa_logitsno longer compiles a new Gluon kernel variant when the number of query rows, KV rows or KV splits changes, so serving prefills no longer stall on recompiling this kernel.Motivation
The gfx950 Gluon kernel of
fp8_mqa_logitscompiles a new variant when the number of query rows, KV rows or KV splits changes Triton's integer specialization class (equal to 1, divisible by 16, or other). In a serving prefill these values change with every batch, so the kernel compiles again while the server is already serving requests. Each compile stalls the batch for about 0.6 s on MI355X.The
gl.int32annotations on these arguments do not stop the specialization. The comment onnum_kv_splits("runtime value to remove unexpected compilations") shows that this was the intent.Changes
aiter/ops/triton/_gluon_kernels/gfx950/attention/fp8_mqa_logits.py:_gluon_fp8_mqa_logits_kerneladdsdo_not_specialize=["seq_len", "seq_len_kv", "num_kv_splits"].seq_lenis used once, in the row clamp of theBLOCK_M == 2path (:962).seq_len_kvclamps each row's KV range (:999,:1004,:1024).num_kv_splitsdivides the KV tiles among the splits (:1013).BLOCK_M,BLOCK_KV,HAS_KV_SPLIT, ...) are not changed, so each launch configuration still compiles once.fp8_mqa_logitscall on gfx950 with Triton 3.6 or later, which selects the Gluon kernel. The gfx1250 Gluon kernel and the Triton kernel (other architectures, and Triton before 3.6) are not changed.Performance (if applicable)
MI355X, image and runs as in "Validation and unverified scope"; mean of two runs per side.
Compile cost, one process, query rows 16 → 17 → 1 → 33 (64 heads, 1024 KV rows), wall time of the first call at each size:
The first call compiles on both sides. Without this PR, 17 and 1 query rows compile again.
Kernel time (KV splits as the launcher picks them):
Testing
Documentation
Only the arguments that Triton specializes on change; the API and the outputs do not.
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
5a90ed984c38dc41337e5ff0e606fea70a2a936aBehavior and intent
Each launch configuration now compiles one variant, whatever the number of query rows, KV rows and KV splits; before, every change of class of these values compiled a new variant while serving (see Motivation). Logits and kernel time do not change: the generated gfx950 code is the same with these values plain or divisible by 16.
Validation and unverified scope
Setup:
lmsysorg/sglang-rocm:v0.5.22-rocm724-mi35x-20261021(AITER285579b621, whose kernel file equals this PR's base; Triton 3.7.0). The kernel file is replaced by this PR's file for "with this PR"; both sides run this PR's test file.1034524fa0; Performance at4a655057e1, which has the same kernel file.Results, the same in both runs of each side:
pytest op_tests/triton_tests/attention/test_fp8_mqa_logits.pyat1034524fa0: 159 passed with this PR; 158 passed and 1 failed without it (test_fp8_mqa_logits_query_rows_do_not_add_specializations,assert 3 == 1). That test was removed from this PR in review (5a90ed984), so the PR no longer adds a test; the logits tests are unchanged.bench_fp8_mqa_logits.py --metric time: −0.1 % to +0.3 % (Performance).Unverified: the gfx1250 Gluon kernel (same arguments, not changed here, no gfx1250 hardware) and Triton versions other than 3.7.0. Not run on MI250X or MI300X: this PR changes only the gfx950 Gluon kernel. The merge of main (
6867e39f2) and the test removal change neither the kernel file nor its behavior and have not run on a GPU; CI runs on the push. Nothing in the repository now checks that the kernel compiles once per launch configuration.PR-specific question
What is the most important boundary or failure mode introduced by this change, and what evidence covers it?
do_not_specializemakesseq_len,seq_len_kvandnum_kv_splitsplain runtime values, so Triton can no longer assume that they are divisible by 16 (or equal to 1). If the kernel's code relied on that, results or speed would differ for the sizes that were divisible. Evidence: the generated gfx950 code is identical with these values plain or divisible by 16, for 5 launch configurations (compiled on CPU and compared; see Changes);test_fp8_mqa_logitspasses (159 passed at1034524fa0); kernel time is within -0.1 % to +0.3 % for 7 shapes (Performance).Changed op tests
None. This PR changes no file under
op_tests/: the specialization test it added was removed in review.This change was developed with AI assistance (Claude); I reviewed every line and ran the tests listed.