Skip to content

[HIP] [Tune] GLM-5 MQA logits: retune with clean_logits=False, add GLM-5.3-Flash rows - #7580

Open
amd-sriram wants to merge 14 commits into
ROCm:mainfrom
amd-sriram:tune/mqa-logits-no-clean
Open

amd-sriram wants to merge 14 commits into
ROCm:mainfrom
amd-sriram:tune/mqa-logits-no-clean

Conversation

@amd-sriram

@amd-sriram amd-sriram commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add tuned rows for the GLM-5.3-Flash MQA logits shapes, with and without MTP, and fill the GLM-5 decode batches between main's rows that MTP3/MTP5 hit (block 64). These shapes had no rows and fell back to the table's smallest row or to the default config. The prefill tuner now times candidates with clean_logits=False by default, which is how vLLM calls the op; --clean_logits 1 keeps the old timing. Main's rows are unchanged, except six kv_block_size=64, next_n 4/6 rows at batch 8 or below. Those rows sit inside the new native-MTP ranges; this PR replaces or drops them.

Motivation

  • GLM-5.3-Flash's index cache uses kv_block_size=32 (pooled KV). The decode table had no block-32 rows, so every Flash decode call used the default config (AITER_LOG_TUNED_CONFIG=1: from default (no tuned row)).
  • Flash prefill runs with seq_len_kv 2-1977 (pooled KV). That is below the table's smallest KV (4096), so every Flash prefill call took the 4096 rows.
  • vLLM calls mqa_logits with clean_logits=False ([ROCm][Perf] Skip cleaning sparse prefill MQA logits vllm-project/vllm#51314). The tuner timed with True, which adds the -inf fill to every candidate and biased picks toward FlyDSL.
  • MTP decode shapes that had no tuned rows:
    • Flash MTP1 is block 32, next_n=2; every call took the default config.
    • Flash and GLM-5.3 MTP3/MTP5 flatten to block 64, next_n=1, at batch = requests × 4 (MTP3, up to 1024) or × 6 (MTP5, up to 1536). Main has rows at 1/2/4/…/256 only: batch 65-127 took the batch-64 row and batches above 256 the batch-256 row.
  • With [ROCm][Perf] Allow DSA indexer native decode above next_n=2 vllm-project/vllm#59421, Flash and GLM-5.3 MTP3/MTP5 decode run natively at block 64, next_n 4/6, batch 1-256 (one per decode request). There, main's rows (tuned at GLM-5 contexts, batches 1/2/4/…/128) are up to 2x slower than the best config.

Changes

  • csrc/mqa_logits/mqa_logits_tune.py: --clean_logits {0,1} (default 0). With 0, the grade compares the causal window only.
  • op_tests/test_mqa_logits.py: when seq_len > seq_len_kv, build_inputs gives each query a pooled key window (end = (row + 1) * seq_len_kv // seq_len), as vLLM's indexer does for compressed KV. Before, those queries had empty windows, so the tuner timed and graded little work.
  • glm5_tuned_mqa_logits.csv: 22 rows for seq_len_kv 2-2048 (24 -> 46 rows). The rows at seq_len_kv 2 and 11 keep main's pick, where the new pick measured slower. 0036642 retunes the seq_len > seq_len_kv rows on the pooled windows; 6 rows change.
  • paged_mqa_logits_tuned_glm5.csv (72 -> 286 rows):
    • kv_block_size=32, next_n=1 (Flash, no MTP): batch 2 / 4 / 8 / 16 / 48 / 64. The batch-48 row holds the default config, so batch 48-63 run as on main.
    • kv_block_size=32, next_n=2 (Flash MTP1): batch 1 / 32 / 224 / 256. The batch-256 row holds the default config.
    • kv_block_size=64, next_n=1, above batch 256 (flattened MTP3/MTP5; Flash and GLM-5.3 share this key): batch 258 / 272 / 384 / 388 / 400 / 512 / 572 / 772 / 784. Batch 384-387 and 572-771 keep main's pick, because the new pick measured slower on GLM-5.3.
    • kv_block_size=64, next_n=1, batch 65 / 96 / 97 (flattened MTP3/MTP5 at 11-31 requests; also GLM-5.3 decode without MTP at batch 65-127). Batch 96 keeps main's pick.
    • kv_block_size=64, next_n 4 and 6 (native MTP3/MTP5, vllm#59421): rows for batch 1-127, plus next_n=4 batch 154 / 178 / 181 / 184 / 187 / 190 / 193 / 205 and next_n=6 batch 129 / 147 / 154 / 248.
      • Gluon ChunkK=256 WavePerEU=4 is fastest at batch % 4 == 0; FlyDSL is fastest between those batches.
      • Main's rows at batch 128 and 256 are unchanged. Rows that hold main's batch-128 pick (next_n=4 178 / 184 / 190, next_n=6 248) end the new row before them where it would be slower.
      • Main's rows at next_n=4 batch 2/4/8 and next_n=6 batch 1/2/8 are replaced or dropped, because they sit inside the new ranges.
      • Picked so that no shape is more than 1% slower than main at either context: Flash 2048;15000 and GLM-5.3 8192;60000.
    • 153d154: every measured batch where the new rows were slower than main now has its own row, with main's pick or a pick that is no slower than main at any measured context. A row at the next batch restores the earlier pick (71 rows). FlyDSL is 25-45% faster at context 8k-60k but 5-25% slower at 2048 for some next_n 4/6 batches, and the lookup has no context key.
  • The untuned CSVs list every tuned key, with its contexts (flat: +8 rows at KV 2/6/11; paged: +92 keys and the missing contexts of 8 keys).

The block-64 gap rows (next_n=1 batch 65-127 and above 256, next_n 4/6 above 128) come from a full batch grid: next_n 4/6 at batch 1-256, and next_n=1 at batch 1-256 plus every MTP3/MTP5 flattened batch up to 1536, each at both contexts. A row is added only if it is at least 2% faster over the batches it covers at both contexts, and no covered batch is more than 1% slower than the earlier table. Existing rows are unchanged.

Other shapes come from AITER_LOG_TUNED_CONFIG=1 dumps of vLLM serving GLM-5.3-Flash on MI355X, TP4, with no MTP and with MTP1/3/5, flattened and native. The indexer is replicated (heads=32 on every rank), so TP does not change the shapes.

Performance (if applicable)

Kernel A/B against main's tables, MI355X (gfx950, 256 CU). Every shape whose config differs from main, at each context listed in its row, interleaved reps per shape. Decode at 153d154 (5 reps, 16 GPUs); prefill at 0036642 on the pooled windows (7 reps, 4 GPUs):

Hardware Workload Points Main (us) This PR (us) Change Worst point
MI355X Prefill, KV 6-1977 71 13.83 11.64 -15.8% -2.8%
MI355X Decode, block 32, next_n 1, batch 2-256 148 12.57 11.85 -5.7% +1.0%
MI355X Decode, block 32, next_n 2, batch 1-232 136 14.87 13.96 -6.1% +0.7%
MI355X Decode, block 64, next_n 1, batch 65-1024 365 62.04 48.12 -22.5% +0.2%
MI355X Decode, block 64, next_n 4, batch 2-255 576 96.98 78.63 -18.8% +1.5%
MI355X Decode, block 64, next_n 6, batch 23-243 680 126.34 100.82 -20.1% +1.4%
  • Points are (shape, context) pairs; Main / This PR are geomeans. Decode contexts: 2048;15000 for block 32, 2048 / 8192 / 15000 / 60000 for block 64.
  • 8 of 1905 decode points are more than 1% slower, all at most +1.5%: next_n 4/6 batch 171-243 at context 2048, and next_n=1 block 32 batch 240 at 15000. The same batches are faster at their other contexts (by up to 7.7%).
  • 51 points at context 60000 and batch ~250 and up fail in both arms: FlyDSL's compile path packs sizes as int32 and a first call with a KV cache over 2^31 bytes raises struct.error. They fail with main's table too.

The tables below compare each earlier revision with the one after it.

Kernel level on MI355X (gfx950, 256 CU), on every real shape from the dumps, comparing the table before each change with the table after it:

Hardware Workload Shapes Config changed Before (us) After (us) Change Worst shape
MI355X Flash decode, block 32, next_n 1, batch 2-256 90 74 12.99 12.45 -4.1% +2.5%
MI355X Flash MTP1 decode, block 32, next_n 2, batch 1-256 75 75 15.98 15.04 -5.9% +0.8%
MI355X Flash MTP3 flattened, block 64, next_n 1, batch 256-512 17 15 81.02 66.92 -17.4% -6.7%
MI355X GLM-5.3 MTP3 flattened, block 64, next_n 1, batch 256-1024 51 43 416.30 379.57 -8.8% -0.3%
MI355X Flash MTP3 native, block 64, next_n 4, batch 1-128 58 28 16.65 14.92 -10.4% 0.0%
MI355X Flash MTP5 native, block 64, next_n 6, batch 1-83 51 27 24.37 20.27 -16.8% -0.2%
MI355X GLM-5.3 context, block 64, next_n 4, batch 1-127 127 98 97.96 70.37 -28.2% +0.3%
MI355X GLM-5.3 context, block 64, next_n 6, batch 1-127 127 94 152.96 99.95 -34.7% +0.6%
MI355X Flash context, block 64, next_n 1, batch 65-127 63 62 23.84 18.48 -22.5% -14.8%
MI355X GLM-5.3 context, block 64, next_n 1, batch 65-127 63 62 79.86 59.58 -25.4% -18.2%
MI355X Flash context, block 64, next_n 1, batch 258-780 175 13 93.05 72.31 -22.3% -15.1%
MI355X GLM-5.3 context, block 64, next_n 1, batch 258-780 175 13 308.73 253.75 -17.8% -6.9%
MI355X Flash context, block 64, next_n 4, batch 154-255 102 93 68.63 62.85 -8.4% -1.7%
MI355X GLM-5.3 context, block 64, next_n 4, batch 154-255 102 93 232.57 208.87 -10.2% -4.3%
MI355X Flash context, block 64, next_n 6, batch 129-247 119 119 82.45 76.96 -6.7% +0.5%
MI355X GLM-5.3 context, block 64, next_n 6, batch 129-247 119 119 285.29 258.42 -9.4% -1.4%

How to read the table:

  • Before is the config the earlier table picks for the shape. Before / After are geomeans over the shapes whose config changed; shapes with the same config in both tables are left out of the geomean.
  • Flash decode times are the geomean over contexts 2048 and 15000. GLM-5.3 times use contexts 8192 and 60000.
  • The "context" rows use a batch grid, not dumped shapes: Flash context 2048;15000, GLM-5.3 context 8192;60000. They check that the shared block-64 keys regress neither model. The last eight rows compare 85aafb0 with 9e999dd.

Method:

  • Same image and node for both arms. The tables are chosen through AITER_CONFIG_MQA_LOGITS / AITER_CONFIG_PAGED_MQA_LOGITS, and prefill runs with clean_logits=False.
  • 4 rounds, one per GPU, with the two tables in alternating order. Each shape uses the median of the 4 rounds.

Checks on the worst shapes and the noise floor:

  • The worst decode shape, batch 16, was re-run for 8 rounds: +4.6% (the PR was faster in 3 of 8).
  • Prefill on the pooled windows: every one of the 71 shapes is faster than main (worst (2900, 725), -2.8%). The 6 changed rows, each timed at its own grid shape against the previous pick: -7.5% geomean, none slower.
  • Noise floor, on shapes that run the same config in both tables:
    • Decode batch 48-63: +1.1% (worst +2.9%).
    • Native next_n 4/6: -0.4% / -0.9% (worst +1.3%).
  • MTP1 worst shape is batch 256, which runs the default config in both tables.
  • The flattened rows were first measured with batch 384 at +1.2% and batch 752 at +1.5% on GLM-5.3. Those batches now keep main's pick. Their numbers above use the measured time of whichever config each table now picks.
  • Prefill (11, 11) took triton in an earlier revision and measured +7%. It now has main's pick (+1.0% over 8 rounds, same kernel).

The rows only apply where vLLM's decode path runs:

  • Without vllm#59421 (native cap at its default of 2), MTP3/MTP5 decode flattens to next_n=1. The next_n 4/6 rows are then unused, and the next_n=1 rows (batch 65-127 and above 256) apply.
  • With the cap raised (VLLM_ROCM_INDEXER_NATIVE_DECODE_MAX_NEXT_N=8), the next_n 4/6 rows apply, and the next_n=1 rows above batch 256 are unused.

End to end, vLLM serving on MI355X TP4:

  • GLM-5.3-Flash measured on revision 7f0289a. Later commits add no rows Flash looks up without MTP: d258464 and 85aafb0 add rows at next_n ≥ 2 or batch > 256, and 9e999dd adds block-64 rows while Flash uses block 32.
  • GLM-5.3 measured on revision 9e999dd, which adds block-64 next_n=1 rows at batch 65-127 that GLM-5.3 without MTP looks up.
  • Setup: nightly a2bcb565 + AITER 20455aa. The base and PR images differ only by this PR's tables. ISL 8k / 60k / 128k, no MTP.
  • Concurrency: GLM-5.3-Flash 4-256 at 8k and 4-32 at 60k / 128k. GLM-5.3 1-256 at 8k and 1-32 at 60k / 128k.
  • Placement: Flash base and PR ran on the two halves of one node. GLM-5.3 base and PR ran one after the other on the same half.
Model Metric Base This PR Change
GLM-5.3-Flash Geomean output throughput (tok/s/GPU) 7058.04 7043.65 -0.2%
GLM-5.3-Flash Geomean TPOT (ms) 19.35 19.40 +0.3%
GLM-5.3-Flash Geomean TTFT (ms) 1784.77 1789.90 +0.3%
GLM-5.3 Geomean output throughput (tok/s/GPU) 2538.92 2530.72 -0.3%
GLM-5.3 Geomean TPOT (ms) 32.55 32.58 +0.1%
GLM-5.3 Geomean TTFT (ms) 4085.82 4077.39 -0.2%

Both models are within noise. For Flash, the kernel gains at batch 2-64 are a small share of the decode step.

Accuracy:

Model NIAH base NIAH PR GPQA (n=198) base GPQA (n=198) PR
GLM-5.3-Flash 1 1 0.914 0.904
GLM-5.3 1 1 0.899 0.914

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Tested on MI355X only (the rows are gfx950-keyed).

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Tuner flag is documented in its --help and module docstring.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. Lookup and table format are unchanged.

PR Self-Review

Reviewed revision

0036642

Behavior and intent

Only table rows and the tuner's default timing mode change; the op's dispatch code is untouched.

  • GLM-5 prefill shapes at KV 4096 and above pick exactly as on main.
  • GLM-5 decode shapes pick as on main, except:
    • block 64, next_n=1 at batch 65-127 and above 256;
    • block 64, next_n 4/6 between main's rows (batch 1-255).
  • Both exceptions were checked at the GLM-5.3 context.

Validation and unverified scope

Kernel A/B against main's tables on every changed shape (first table under Performance). Earlier: kernel A/B with bench.py (earlier table vs new table) on one MI355X node, on every dumped shape plus a batch grid at both contexts for the shared block-64 keys. The worst shapes are listed above.

Row selection was checked two ways:

  • AITER_LOG_TUNED_CONFIG=1 in the bench confirms the rows taken.
  • For the native next_n 4/6 rows, an offline lookup over the new table matches the picked config at every batch 1-127.

End-to-end serving was measured on 7f0289a, without MTP. GLM-5.3 was re-measured on 9e999dd.

Unverified:

  • gfx942.
  • End-to-end serving with the prefill rows retuned in 0036642 (kernel A/B only). These rows apply at seq_len_kv ≤ 2048.
  • End-to-end MTP serving with these rows.
  • Block-32 next_n ≥ 3: Flash native MTP decode uses block 64, so no dump hit that key.

PR-specific question

The native next_n 4/6 rows add about 120 rows, because gluon and FlyDSL alternate every few batches. Is that table size fine, or should the alternation be a rule in the dispatcher instead (gluon at batch % 4 == 0, FlyDSL otherwise)?

Changed op tests

  • op_tests/test_mqa_logits.py: build_inputs now gives pooled key windows when seq_len > seq_len_kv, matching vLLM's compressed-KV indexer. The tuner and --run_config share this function, so before the change, rows with more queries than keys were tuned on mostly empty windows. The test's own runs keep seq_len <= seq_len_kv, so their inputs are unchanged; python op_tests/test_mqa_logits.py passed on MI355X (err 0 for all four default shapes).

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7580 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@amd-sriram
amd-sriram marked this pull request as ready for review November 27, 2026 08:08
@amd-sriram
amd-sriram requested review from a team and a balanced review from Copilot November 27, 2026 08:08
@github-actions github-actions Bot changed the title [Tune] GLM-5 MQA logits: retune with clean_logits=False, add GLM-5.3-Flash rows [HIP] [Tune] GLM-5 MQA logits: retune with clean_logits=False, add GLM-5.3-Flash rows Nov 27, 2026
@github-actions github-actions Bot added the HIP label Nov 27, 2026
@aiter-bot

aiter-bot commented Nov 27, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 0036642e144e · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

Only table rows and the tuner's default timing mode change; the op's dispatch code is untouched.

- GLM-5 prefill shapes at KV 4096 and above pick exactly as on main.
- GLM-5 decode shapes pick as on main, except:
  - block 64, `next_n=1` at batch 65-127 and above 256;
  - block 64, `next_n` 4/6 between main's rows (batch 1-255).
- Both exceptions were checked at the GLM-5.3 context.

Validation and unverified scope

Kernel A/B against main's tables on every changed shape (first table under Performance). Earlier: kernel A/B with `bench.py` (earlier table vs new table) on one MI355X node, on every dumped shape plus a batch grid at both contexts for the shared block-64 keys. The worst shapes are listed above.

Row selection was checked two ways:

- `AITER_LOG_TUNED_CONFIG=1` in the bench confirms the rows taken.
- For the native `next_n` 4/6 rows, an offline lookup over the new table matches the picked config at every batch 1-127.

End-to-end serving was measured on 7f0289aecd, without MTP. GLM-5.3 was re-measured on 9e999dd0eb.

Unverified:

- gfx942.
- End-to-end serving with the prefill rows retuned in 0036642e14 (kernel A/B only). These rows apply at `seq_len_kv` ≤ 2048.
- End-to-end MTP serving with these rows.
- Block-32 `next_n` ≥ 3: Flash native MTP decode uses block 64, so no dump hit that key.

PR-specific question

The native `next_n` 4/6 rows add about 120 rows, because gluon and FlyDSL alternate every few batches. Is that table size fine, or should the alternation be a rule in the dispatcher instead (gluon at batch % 4 == 0, FlyDSL otherwise)?

Changed op tests

- `op_tests/test_mqa_logits.py`: `build_inputs` now gives pooled key windows when `seq_len > seq_len_kv`, matching vLLM's compressed-KV indexer. The tuner and `--run_config` share this function, so before the change, rows with more queries than keys were tuned on mostly empty windows. The test's own runs keep `seq_len <= seq_len_kv`, so their inputs are unchanged; `python op_tests/test_mqa_logits.py` passed on MI355X (err 0 for all four default shapes).

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • ADVISORY — an author-replied Copilot finding is still unresolved; confirm the disposition during human review

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Affected Q>KV configurations give queries empty windows, making tuning and grading unrepresentative of pooled prefill and requiring corrected per-query bounds and retuning.

1 open issue
What changed in this PR

This PR extends AITER’s MQA logits tuning tables for GLM-5.3-Flash and missing GLM-5 decode ranges, while aligning prefill tuning with vLLM’s clean_logits=False usage.

Changes:

  • Adds --clean_logits {0,1}, defaulting to 0, with window-only grading when cleanup is disabled.
  • Adds short-KV prefill configurations and block-32/block-64 decode configurations for standard and multi-token prediction workloads.
  • Expands tuning input CSVs without changing production dispatch logic or table formats.
File Description
csrc/​mqa_logits/​mqa_logits_tune.py Adds the cleanup flag and threads it through grading and timing.
aiter/​configs/​model_configs/​paged_mqa_logits_untuned_glm5.csv Expands decode tuning shapes and contexts.
aiter/​configs/​model_configs/​paged_mqa_logits_tuned_glm5.csv Adds gfx950 decode configurations and updates selected native-MTP rows.
aiter/​configs/​model_configs/​glm5_untuned_mqa_logits.csv Adds short-KV prefill tuning shapes.
aiter/​configs/​model_configs/​glm5_tuned_mqa_logits.csv Adds 22 short-KV prefill configurations.

Review effort: Balanced

32,128,2048,512
32,128,1024,1024
32,128,2048,1024
32,128,4096,1024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supply representative per-query bounds for both tuning and --run_config, then retune the affected rows where Q exceeds KV

Fixed in 115714e: build_inputs now gives pooled windows when seq_len > seq_len_kv, end = (row + 1) * seq_len_kv // seq_len, as in vLLM's indexer. The Q > KV rows were retuned on these inputs in 0036642 (6 rows changed). A/B against main on the 71 dumped prefill shapes: -15.8% geomean, none slower.

…default

vLLM calls aiter.mqa_logits with clean_logits=False (vllm#51314). The tuner
timed every candidate with the default clean_logits=True, which adds the
-inf fill to the Triton path, so the GLM-5 table picks FlyDSL variants that
are 2-7% slower than Triton without the fill. Add --clean_logits (default 0)
and grade only inside each row's window when the fill is off.

Signed-off-by: Sriram Kumar <[email protected]>
…GLM-5.3-Flash rows

Prefill: retime the 24 rows with clean_logits=False (vLLM's call) and add
long-context (KV 128k-262k) and Flash pooled-KV (KV 512-2048) rows.
Decode: add kv_block_size=32 rows (GLM-5.3-Flash index cache, next_n 1-2)
and batch 512/1024 rows for MTP.

Signed-off-by: Sriram Kumar <[email protected]>
Five rows did not beat main's pick on the median of five interleaved
runs (prefill 4096x8192, 256x16384, 256x32768, 256x131072; decode
block 32 batch 16 next_n 2). They now hold exactly the config main
picks for those shapes.

Signed-off-by: Sriram Kumar <[email protected]>
Main's GLM-5 rows are unchanged. Added rows were picked on real vLLM
shapes (GLM-5.3 and GLM-5.3-Flash, TP4, AITER_LOG_TUNED_CONFIG dumps)
and kept only if no real shape they serve is more than 1% slower than
main, then checked on held-out shapes:

- prefill KV 512 / 1024 rows (GLM-5.3-Flash pooled KV) and 256x131072
- prefill KV 2048 rows that copy main's KV 4096 configs, so shapes with
  KV 2048-4095 keep main's picks
- decode kv_block_size 32, next_n 1 rows (GLM-5.3-Flash); batch 48
  holds the default config

Signed-off-by: Sriram Kumar <[email protected]>
… real shapes

Held-out real shapes showed the KV 1024 rows for seq >= 4096 and the
KV 1984-2047 band lose to main's pick; those rows now carry main's
config. Dropped 256x131072 (no gain) and the decode block-32 batch
128 / 256 rows (same config as batch 64).

Signed-off-by: Sriram Kumar <[email protected]>
(2,2) measured +3.2% with triton in the A/B on the shapes where this table differs from main; the new seq_len_kv=2 row keeps main's flydsl pick there, and the seq_len_kv=6 rows repeat the 512 band so every other shape picks as before.

Signed-off-by: Sriram Kumar <[email protected]>
(11,11) measured +7% with triton in the 8-round A/B; the new seq_len_kv=11 rows give it main's flydsl pick and repeat the 512 band so every other shape picks as before.

Signed-off-by: Sriram Kumar <[email protected]>
- kv_block_size=32, next_n=2 (Flash MTP1): batch 1/32/224/256.
- kv_block_size=64, next_n=1 above batch 256 (MTP3 flattened; GLM-5.3 and
  Flash share the key): 272/384/400/512/572/784. Batch 384 and 572-783
  keep main's pick, where the new one measured slower on GLM-5.3.
With vllm#59421 raising the native-decode next_n cap, Flash MTP3/MTP5
decode runs the paged kernel natively at kv_block_size=64, next_n=4/6,
batch 1-127. That key is shared with GLM-5.3 native MTP.

- New rows for batch 1-127 at next_n 4 and 6. Gluon ChunkK=256
  WavePerEU=4 stays fastest at batch % 4 == 0; FlyDSL wins in between.
- Main's batch-128+ rows are unchanged.
- Picked so no shape is >1% slower than main at either context
  (Flash 2048;15000, GLM-5.3 8192;60000).
…lock 64)

Rows for next_n 4/6 at batch 129-255 and next_n 1 at batch 65-127 and
above 256, from a full batch grid at both GLM-5 contexts. Existing rows
are unchanged.

Signed-off-by: Sriram Kumar <[email protected]>
The retuned decode rows lost up to 19% at ctx 2048 for some next_n 4/6 batches
(FlyDSL wins at 8k-60k, loses at 2k; context is not in the lookup key). Every
measured batch that was slower than main now has its own row with main's pick
or a pick that is no slower than main at any measured context, plus a row at
the next batch that restores the previous pick.
@amd-sriram
amd-sriram force-pushed the tune/mqa-logits-no-clean branch from 539599c to 153d154 Compare November 27, 2026 14:21
Copilot AI balanced review requested due to automatic review settings November 27, 2026 14:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Pooled-KV tuning uses unpooled bounds that leave thousands of queries ungraded, while the untuned CSVs omit shipped configurations and contexts needed for complete retuning.

3 open issues

Review effort: Balanced

build_inputs gave every query a causal window ending at
row + seq_len_kv - seq_len + 1, so with seq_len > seq_len_kv the first
seq_len - seq_len_kv queries had empty windows. Pooled prefill (GLM-5.3-Flash)
grows each query's bound in pooled units instead: row i sees
(i + 1) * seq_len_kv // seq_len keys. The tuner and --run_config use the
same inputs.
glm5_untuned_mqa_logits.csv lacked the 8 shapes at seq_len_kv 2, 6 and 11.
paged_mqa_logits_untuned_glm5.csv lacked 92 tuned keys and some contexts of
8 others (310 rows). The tuners only visit input rows, so --all could not
retune them.
Rows where seq_len > seq_len_kv were tuned with empty query windows.
Retuned on the pooled-KV inputs from the previous commit: 6 rows change.
On 71 prefill shapes dumped from GLM-5.x serving (KV 6-1977), geomean
13.83 -> 11.64 us (-15.8%); every shape faster than main.
Copilot AI balanced review requested due to automatic review settings November 27, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The pooled-window branch is still skipped by the test driver, and the shared reference bounds can mask formula errors, so explicit boundary assertions and numerical checks are needed.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment on lines +46 to +50
if seq_len > seq_len_kv:
# Pooled KV (one key per seq_len // seq_len_kv tokens, as in GLM-5.3-Flash):
# vLLM's indexer grows each query's bound in pooled units, so row i sees
# (i + 1) * seq_len_kv // seq_len keys and the last row sees all of them.
cu_ends = (rows + 1) * seq_len_kv // seq_len

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on testing the pooled windows

Agree with Copilot here. main() still skips every seq_len > seq_len_kv pair, and the tuner grades against run_torch with the same cu_ends, so nothing would catch a wrong window formula. I ran every pooled row in the tables against the reference on MI355X and the kernels are fine; it's only the formula that has no check. A small check of the bounds would cover it, something like this (a sketch, I haven't run it):

def check_pooled_windows():
    """Pooled KV: row i ends at (i + 1) * seq_len_kv // seq_len."""
    for seq_len, seq_len_kv in ((4096, 1024), (1000, 251)):
        ends = build_inputs(seq_len, seq_len_kv)["cu_ends"].tolist()
        assert ends[0] == 0, ends[:4]  # leading rows see no key
        assert ends[-1] == seq_len_kv, ends[-4:]  # last row sees every key
        assert all(a <= b for a, b in zip(ends, ends[1:]))
    test_mqa_logits(4096, 1024)

called from main() next to the other checks. (1000, 251) covers a ratio that isn't a whole number. It might also be worth a line in the docstring that this matches vLLM only for a fresh prefill: vLLM's end is (start_pos + 1 + i) // COMPRESS_RATIO (indexer.py#L513-L516), so chunked prefill windows look different.

@zufayu

zufayu commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@ROCm ROCm deleted a comment from aiter-bot Dec 1, 2026
@aiter-bot

Copy link
Copy Markdown

⚠️ aiter-bot — this review could not complete: a problem with the review pipeline itself (bot logic / prompts), not with this PR.

the worker did not finish within AITER_AGENT_TIMEOUT=2400s; the backend answered normally -- raise it in the runner .env

@zufayu — please take a look.

Re-comment @aiter-bot review once it is resolved.

@msaffari-amd

Copy link
Copy Markdown
Contributor

Which vLLM change makes vLLM read these tables?

I checked vLLM main (8e7295e, Dec 2), and the GLM-5 indexer doesn't go through aiter.mqa_logits or aiter.paged_mqa_logits yet. Prefill calls the Triton fp8_mqa_logits(..., clean_logits=False) directly (L1070-L1073), and decode calls deepgemm_fp8_paged_mqa_logits with a fixed ChunkK=256, WavePerEU=2 (L905-L922). So these rows only take effect in vLLM once your vllm-project/vllm#60294 (prefill) and vllm-project/vllm#60042 (decode) land. vllm-project/vllm#51314 only set clean_logits=False on the raw Triton call.

Could you name #60294 and #60042 in the description, next to #59421? Both are approved already, so this is mostly so readers know what turns the rows on, and which vLLM the end-to-end numbers came from.

@msaffari-amd

Copy link
Copy Markdown
Contributor

Merge order with #7412

#7412 (draft, @vpietila-amd) rewrites main's 24 rows in glm5_tuned_mqa_logits.csv right next to the 22 rows this PR inserts, so the two conflict in that file. It also changes the FlyDSL prefill kernel. Its tag parser still builds the variant names used here, so nothing breaks either way. But in either order, the 22 short-KV rows from this PR end up tuned against the kernel from before #7412. Could you two agree on an order? Once both are in, it would be good to retune those 22 rows with --clean_logits 0.

@msaffari-amd

Copy link
Copy Markdown
Contributor

On your question about the native next_n 4/6 rows

I'd keep them as rows. I checked the table against the rule you suggested (gluon when batch % 4 == 0, FlyDSL otherwise) for block 64, batch 1-127. next_n=4 follows it on 54 of 60 rows, but next_n=6 only on 74 of 90: gluon also wins at even batches 14-74 there. The FlyDSL rows also use three different wg_per_cu values, which a single rule wouldn't pick. So a dispatcher rule would need per-next_n cases and would still lose some rows. It would also hard-code what this GPU (256 CUs) and today's kernels do, while rows just get retuned when a kernel changes (#8327 touches the FlyDSL decode kernel, for example). The lookup cost doesn't grow with the table, so I don't see a downside to ~120 rows. As the description says, they only matter once vllm-project/vllm#59421 lands.

gfx950,256,32,128,256,11,triton,,,,
gfx950,256,32,128,1024,11,triton,,,,
gfx950,256,32,128,2048,11,flydsl,mfma32x32x64_bkv64_r2_w4_lds3,,,
gfx950,256,32,128,256,512,triton,,,,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the new rows get their timings?

22 of the new rows here (lines 2-23) and 7 in paged_mqa_logits_tuned_glm5.csv (lines 6, 15, 17, 19, 22, 24, 156) have an empty us, and the per-backend columns are empty too. Main's tables have a time on every row. The description explains why several of them exist (keeping main's pick, or holding the default config), so it's mostly the numbers that are missing. Without them, --run_config reports these rows as ok no matter what: run_config only computes drift when csv_us > 0. There's also nothing stored to compare a later retune against.

Could you fill us and triton_us / flydsl_us (or gluon_us) from your A/B runs? If some rows were placed by hand, a line in the description saying which ones would help too.

This row is a good example of why it helps. On MI355X I timed it against main's pick (FlyDSL mfma32x32x64_bkv64_r1_w2_lds2), same GPU, interleaved, clean_logits=False. Triton is about 5% slower at the row's own shape, (256, 512): 4.94-5.04 vs 4.71-4.81 us over two runs of 11 and 15 rounds. It's 10% slower at (256, 1000). But it's 7-25% faster at the other shapes in its range: (300, 700), (512, 512), (700, 900), (900, 600) and (1000, 1000). So the pick is a reasonable trade-off overall, but the table doesn't show that.

Comment on lines +15 to +17
Candidates are timed with ``--clean_logits`` (default 0, as vLLM calls the op):
the -inf fill outside each row's window is a separate cost on the Triton path,
so a table tuned with it on can pick a kernel that is slower without it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small doc note: the table is tuned for clean_logits=False

The flip side of tuning at clean_logits=False is that aiter.mqa_logits still defaults to clean_logits=True, and the lookup has no clean_logits key. On MI355X, with clean_logits=True, the Triton picks here were 29-36% slower than main's FlyDSL picks at (256, 6), (256, 11), (1024, 11) and (256, 512). They stayed 9-16% faster at (1024, 512) and (1024, 1024). Nothing in aiter calls it that way, and vllm-project/vllm#60294 passes False, so this is just worth a sentence:

Suggested change
Candidates are timed with ``--clean_logits`` (default 0, as vLLM calls the op):
the -inf fill outside each row's window is a separate cost on the Triton path,
so a table tuned with it on can pick a kernel that is slower without it.
Candidates are timed with ``--clean_logits`` (default 0, as vLLM calls the op):
the -inf fill outside each row's window is a separate cost on the Triton path,
so a table tuned with it on can pick a kernel that is slower without it. The
lookup has no clean_logits key, so callers that keep ``mqa_logits``'s default
``clean_logits=True`` can get a slower pick on rows that chose Triton.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants