Repository navigation
[ROCm][DSA] Enable AITER fused FP8 indexer writer - #40710
Conversation
|
Hi @kkHuang-amd @HaiShaw @yuan-luo — could you take a look at this ROCm DSA fused FP8 indexer writer (AITER CI failed at Thanks! |
|
Hi, @fanxingran |
Hi @1am9trash, thanks for tagging CI and catching the lint. I ran pre-commit locally (ruff format). It only reformatted wrapping in Thanks! |
|
Hi @1am9trash — we pushed a gfx950 arch gate ( Our own push is rate-limited: |
| return False | ||
| if not torch.cuda.is_available(): | ||
| return False | ||
| return "gfx95" in str(torch.cuda.get_device_properties(0).gcnArchName) |
There was a problem hiding this comment.
Hi, @fanxingran
Can _is_gfx95() reuse sglang.srt.utils.is_gfx95_supported() utility?
There was a problem hiding this comment.
Reused sglang.srt.utils.is_gfx95_supported() and dropped the local helper.
|
|
||
| from aiter.ops.cache import indexer_qk_rope_quant_and_cache | ||
|
|
||
| indexer_qk_rope_quant_and_cache( |
There was a problem hiding this comment.
Hi, @fanxingran
This path calls indexer_qk_rope_quant_and_cache, which sglang indexer did not use before.
Do we need to bump the sglang aiter version?
There was a problem hiding this comment.
No sglang AITER pin in this PR. Images clone ROCm/aiter; if indexer_qk_rope_quant_and_cache is missing we fall back via ImportError/AttributeError.
| SGLANG_DISABLE_DSA_INDEXER_FUSION = EnvBool(False) | ||
| # HIP analog of CUDA DSA indexer fusion (default on). Set 0 for the | ||
| # legacy split writer. Omits Hadamard; pre-quant logits match. | ||
| SGLANG_AITER_FUSED_FP8_DSA_INDEXER = EnvBool(True) |
There was a problem hiding this comment.
Hi, @fanxingran
CUDA uses SGLANG_DISABLE_DSA_INDEXER_FUSION (default on). Should we use the same disable-style flag?
There was a problem hiding this comment.
Added SGLANG_DISABLE_AITER_FUSED_FP8_DSA_INDEXER (default False). Kept it separate from SGLANG_DISABLE_DSA_INDEXER_FUSION because that CUDA flag also packs wk/weights_proj.
There was a problem hiding this comment.
Hi, @fanxingran
On some fallbacks (_get_q_k_bf16), Hadamard is gated only by _maybe_rotate(), which does not include the HIP fused flag.
May that crash our code path, or are those paths unreachable on HIP?
There was a problem hiding this comment.
_maybe_rotate now skips Hadamard when the HIP fused writer is on as well, so fallback K matches the fused cache. It would mismatch, not crash.
Reuse is_gfx95_supported, switch to a disable-style HIP env flag, and skip Hadamard on the HIP fused fallback path.
|
Hi @1am9trash, thanks for the review. All four are addressed in
Could you please take another look at those replies? If anything still needs a change, I will follow up right away; if it looks good, an approve would be very helpful. CI on |
1am9trash
left a comment
There was a problem hiding this comment.
Thanks for the update.
All comments are resolved.
LGTM.
|
Hi @1am9trash, the AMD mi35x failure is in test_triton_mla_kv_cache.py, which is unrelated to this PR — we did not change Triton MLA / KV cache. That test should be fine; this looks like a flake. Could you please /rerun-failed-ci? Thanks! |
| aiter_fused_fp8_writer_available, | ||
| fused_fp8_writer_geometry_supported, | ||
| prepare_aiter_rope_caches, | ||
| ) |
There was a problem hiding this comment.
@fanxingran let's put this hip specific import under _is_hip, in follow-up PR
There was a problem hiding this comment.
Thanks @HaiShaw,I will move the HIP-only import under _is_hip in a follow-up.
|
/rerun-failed-ci |
|
AITER specific |
|
Previous |
Motivation
On HIP, the DSA FP8 indexer writer currently issues a chain of small kernels (K LayerNorm, joint Q/K RoPE, optional Hadamard, Q/K FP8 quant, and the paged index-K cache store). That launch overhead shows up on decode ITL, especially the tail.
CUDA already fuses the analogous indexer writer (
SGLANG_DISABLE_DSA_INDEXER_FUSION, default on). This PR adds the ROCm counterpart via AITERindexer_qk_rope_quant_and_cache, so HIP can fuse RoPE + K LayerNorm + FP8 quant + cache write into one kernel. Hadamard is omitted, matching the CUDA fused writer (pre-quant logits stay aligned).The path is default-on when AITER is available and indexer geometry matches (
head_dim=128,rope_dim=64,quant_block=128, index-K LayerNorm). Models that do not match (including RMSNorm index-K) keep the legacy split writer. SetSGLANG_AITER_FUSED_FP8_DSA_INDEXER=0to force the split path.Validated on GLM-5.2-MXFP4 (gfx950). Any DSA indexer with the same geometry can take this path; it is not hardcoded to a model name.
Modifications
python/sglang/kernels/ops/attention/dsa/fp8_fused_writer_hip.py: AITER adapter (geometry checks, RoPE table reshape, fused Q/K write).python/sglang/srt/layers/attention/dsa/dsa_indexer.py: enable fused writer when HIP + AITER + geometry match; LayerNorm in fp32 only on the fused path; warn only if the env is explicitly set and unsupported.python/sglang/srt/environ.py:SGLANG_AITER_FUSED_FP8_DSA_INDEXER = EnvBool(True).test/registered/unit/layers/attention/test_fp8_fused_writer_hip.pytest/registered/amd/test_fp8_fused_dsa_writer_gfx950.pyAccuracy Tests
GSM8K via local
sglang.test.run_eval(1314 questions), GLM-5.2-MXFP4, baseline = fused off (SGLANG_AITER_FUSED_FP8_DSA_INDEXER=0).No accuracy regression. Server log contains
Enabled AITER fused FP8 DSA indexer writer.Speed Tests and Profiling
Hardware: gfx950. Workload: InferenceX AgentX, 1200s (not the 3600s publication window). Toggle only
SGLANG_AITER_FUSED_FP8_DSA_INDEXER. Interactivity = output token throughput per user; TPOT = ITL.TP4 / EP4 / concurrency 8, HiCache DRAM
Request mix is aligned (510 vs 518 completed; ISL/OSL mean 103925/568 vs 104042/563).
Gain is mainly decode tail latency (p99 ITL), not prefill.
TP8 / EP1 / concurrency 1, no HiCache
Request count 155 vs 157; ISL aligned. OSL mean 646 vs 582, so E2E and output throughput are not causal. Use interactivity / ITL.
Checklist
environ.py; no cookbook change.)Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ⏳ Run #35808442739
Latest PR Test (Extra): ❌ Run #35808442600
Latest PR Test (AMD ROCm 10): ⏳ Run #35808442791