Repository navigation
[HIP] [CI] [JIT] Add aiter.mqa_logits with a tuned Triton/FlyDSL table - #11
Closed
amd-sriram wants to merge 2 commits into
Closed
amd-sriram wants to merge 2 commits into
amd-sriram wants to merge 2 commits into
Conversation
Picks the FP8 MQA logits backend and FlyDSL variant per shape from tuned_mqa_logits.csv. Adds the tuner, op test and gfx950 GLM-5 rows.
|
Caution CodeRabbit couldn't post its review summary. Error details |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Motivation
vLLM's sparse indexer prefill calls the Triton/Gluon
fp8_mqa_logitsdirectly on gfx950. Moving it to the FlyDSL kernel from ROCm#4538 took a vLLM PR (vllm-project/vllm#59280), and so would every later switch. Likeaiter.paged_mqa_logitsfor decode (ROCm#6140), this addsaiter.mqa_logits: the framework asks for MQA logits, and AITER picks the backend and FlyDSL variant from a tuned table, the wayfused_moedoes.What it adds
mqa_logits(Q, KV, kv_scales, weights, cu_starts, cu_ends, clean_logits=True): takes the same tensors asfp8_mqa_logitsand returns the same[seq_len, seq_len_kv]logits.(gfx, cu_num, heads, head_dim, seq_len, seq_len_kv). Both lengths are tensor sizes, so the lookup never reads device memory. A call uses the row with the largest tunedseq_len_kvnot above its own, then the largest tunedseq_lennot above its own; a length below every tuned one uses the smallest. Rows are looked up with the live GPU arch (get_gfx_runtime()).triton(the existingfp8_mqa_logits, Gluon on gfx950) orflydslwith avariantfromKERNEL_VARIANTS.seq_len256 to 8192 andseq_len_kv4096 to 60000, limited to what vLLM produces (seq_len <= seq_len_kv, logits within the default 512 MBVLLM_SPARSE_INDEXER_MAX_LOGITS_MB).Without a matching row it runs
fp8_mqa_logits, so an empty table changes nothing. A FlyDSL row is only used where the kernel can run (gfx942/gfx950, the variant exists, native e4m3fn on gfx950); otherwise the call runsfp8_mqa_logits.The CSVs are named like fused MoE's (
tuned_mqa_logits.csv,model_configs/glm5_tuned_mqa_logits.csv). Amqa_logits_tunedname would also matchpaged_mqa_logits_tuned_*.csvin themodel_configsglob.Test Result
MI355X (gfx950), AITER
1a37aa008with this change applied, Triton 3.8.0, FlyDSL 0.3.4.1.mfma32x32x64_bkv128_r2_w4_lds3(13 of 24).-infmask,calc_diff < 1e-3); none was rejected.op_tests/test_mqa_logits.pypasses, including the live-GPU lookup check (child process started with the other arch inGPU_ARCHS), the dispatched-config check and the FlyDSL fallback.--run_config: 24/24 within 10% on one pass, 22/24 on a second (the two smallest kernels, about 20 and 40 us, at +12%). Collision guard: OK.GPU_ARCHSnaming another arch, the FlyDSL module builds its variant list for that arch at import, so a gfx950 FlyDSL row falls back tofp8_mqa_logitsinstead of failing.python3 csrc/mqa_logits/mqa_logits_tune.py \ -i aiter/configs/model_configs/glm5_untuned_mqa_logits.csv \ -o aiter/configs/model_configs/glm5_tuned_mqa_logits.csv python3 csrc/mqa_logits/mqa_logits_tune.py --run_config aiter/configs/model_configs/glm5_tuned_mqa_logits.csv python3 op_tests/test_mqa_logits.py python3 -m unittest op_tests.tuning_tests.test_config_shape_collision.TestConfigShapeCollision.test_mqa_logitsAll 24 shapes (us, single sweep timings; FlyDSL auto = the variant
flydsl_fp8_mqa_logitspicks by itself)mfma32x32x64_bkv64_r1_w2_lds2mfma32x32x64_bkv64_r2_w2_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv64_r2_w2_lds2mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv64_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv64_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv64_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds2mfma32x32x64_bkv64_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds2mfma32x32x64_bkv64_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds3mfma32x32x64_bkv128_r2_w4_lds2