Repository navigation
[AMD][DSV4] fp8 unified_kv decode/verify via aiter FlyDSL v4 nm decode - #41383
AMD-yanfeiwang wants to merge 2 commits into
Conversation
Route the fp8 two-pool unified_kv decode and target verify to aiter's FlyDSL v4 nm decode (aiter.ops.flydsl) on gfx950 when the installed aiter ships it, instead of the asm mla_a8w8_qh64_qseqlen1_gqaratio64_nm kernel + stage-2 merge: * decode_fp8_2buff: drop-in kernel swap, one launch with the split merge, split plan picked per batch size and stream kind (CSA / HCA / SWA-only), H in 16 / 32 / 64 / 128. * fp8 wo_a: the same launch also does the inverse RoPE and the wo_a mxfp8 quant; MQALayer only runs the a8w8 mxscale GEMM on its output. * DSpark target verify: where aiter's measured policy says it pays (flydsl_mla_v4_grouped_pays for the layer kind and the model's output mode), HCA and SWA-only layers read one stream per request with per-draft key ranges (q_kv_bounds), exact w.r.t. the per-token streams. CSA stays per token. SGLANG_DSV4_FLYDSL_DECODE=0 keeps the asm path; an aiter without the FlyDSL v4 decode falls back the same way. Signed-off-by: Yanfei Wang <[email protected]>
…flicts with sgl-project#41308 sgl-project#41308 added an `inv_rope` argument next to this PR's `wo_a_quant_freqs`. Conflict resolution only, no functional change: - deepseek_v4_backend_hip_radix.py `_forward_attention`: keep both `inv_rope` (main) and `wo_a_quant_freqs` (this PR); keep main's docstring and this PR's `Union[Tensor, Tuple[Tensor, Tensor]]` return type. - deepseek_v4.py `MQALayer.forward`: keep main's `inv_rope = _hip.attention_inv_rope(...)` followed by this PR's `wo_a_quant_freqs = None`; in the unified branch forward both `inv_rope` and `wo_a_quant_freqs` through rope_kwargs. `attention_inv_rope` returns None whenever `unified` is set, so the two never apply together.
… until aiter ships it The official aiter pin (ROCm/aiter main 02575f1c3a) has no FlyDSL v4 nm decode, so sgl-project#41383's fp8 unified_kv decode/verify fell back to the asm kernel. Carry ROCm/aiter#5882 at its sgl-project#6377-adapted head 03359c43df in-tree: - python/sglang/kernels/ops/attention/dsv4/flydsl_v4nm/: mla_v4_decode.py, mla_v4_grouped.py, kernels/mla_v4_decode_{common,gfx950}.py copied from the PR (license header kept, source PR / commit / file noted); only the import paths changed (helpers come from aiter's public FlyDSL utils: communication_ops_utils, buffer_ops, kernels_common, tensor_shim) plus isort / ruff format. Importing it on an aiter before sgl-project#6377 raises ImportError. - runtime._flydsl_v4_decode(): aiter.ops.flydsl when the installed aiter has the API, else the in-tree copy; logs which one once per process. SGLANG_DSV4_FLYDSL_DECODE_SOURCE=auto|aiter|intree (default auto) forces one copy; SGLANG_DSV4_FLYDSL_DECODE=0 still turns FlyDSL off (asm). SGLANG_DSV4_FLYDSL_DECODE_H128 gating is unchanged. - test/registered/kernels/ops/attention/dsv4/test_flydsl_v4nm_decode.py: the PR's op_test ported to pytest, trimmed to the DSv4 shapes (H16/32/64/128 msq1, H16 msq4, fused wo_a epilogue, grouped verify at 4/7 drafts), plus the source-selection contract. - Kernel inventory entries for the two entry points; codespell skips the vendored directory (helper name `padd`). Every piece carries TODO(aiter#5882): remove once ROCm/aiter#5882 is in the aiter pin.
|
Required checks failed on 266d7e8; this PR cannot be merged until they pass. PR title (run)
|
|
Superseded by #44016 . |
Motivation
On gfx950, DSv4 fp8 unified_kv decode and target verify run the asm
mla_a8w8_qh64_qseqlen1_gqaratio64_nmkernel, then a stage-2 split merge, then a separate inverse-RoPE + wo_a mxfp8 quant. This PR moves all three into one launch of aiter's FlyDSL v4 nm decode (ROCm/aiter#5882). On the current image it cuts the 8K/1K step time by 1.1–3.9%.Modifications
decode_fp8_2buffcallsaiter.ops.flydsl.flydsl_mla_decode_fwd_v4_nmwhen the installed aiter has it. The kernel picks its own split plan from the stream kind (CSA / HCA / SWA-only).MQALayerruns only the a8w8 GEMM.q_kv_bounds) where aiter'sflydsl_mla_v4_grouped_payssays it pays. CSA stays per-token. The output matches per-token verify.SGLANG_DSV4_FLYDSL_DECODE=0keeps the asm path.aiter.ops.flydslhas noflydsl_mla_v4_decode_supported, so_flydsl_v4_decode()catches theAttributeError(orImportErrorif FlyDSL is missing) and returns None. Then decode/verify call the asmmla_decode_fwd_v4_nmwith the same split policy as today, wo_a keeps its current path, and no grouped-verify metadata is built. Behaviour is the same as main; there is just no speedup. The FlyDSL cases in the test skip.test/registered/e2e/dsv4/test_dsv4_unified_fp8_decode.pychecks decode, fused wo_a (incl. H128) and grouped verify against asm and a reference.Accuracy Tests
gsm8k (1319 q), DSv4-Pro TP8 + DSpark 6, one run per boot, same setup as the E2E below:
Speed Tests and Profiling
DSv4-Pro, 8x MI355X,
lmsysorg/sglang-rocm:v0.5.20-rocm724-mi35x-20260927, 8K in / 1K out, TP8, fp8 KV (SGLANG_DSV4_UNIFIED_KV_FP8=1 SGLANG_OPT_FP8_WO_A_FUSED_INVROPE=1), CUDA graphs..co([AMD] Add .co for deepseek v4 fp8 decode kernel and add group decode opt #41120) per-token + stage-2 merge + inverse-RoPE quant. This is the production path..codeleted. No other change.All 30 paired differences are negative. The DSpark rows are the total gain vs the production asm path. In the earlier 20260922-image numbers, about 0.18 ms/step of the DSpark gain came from that asm baseline (ROCm/aiter#5195
.co+ ROCm/aiter#5776 merge) buildingsplit_indptrin every layer; the stock asm wrapper here caches it, so none of the gain above comes from that.Attention per step, in-graph kineto (µs), stock asm read + merge + inv-RoPE quant → one FlyDSL launch:
The rest of the step is unchanged within 1–2%.
Kernel microbench (details in ROCm/aiter#5882), FlyDSL / best asm split + merge: 179 decode cells (H 16–128, msq 1–4, B 1–1024, L 128–16K) median 0.86, max 0.997; DSpark verify, 80 cells, median 0.86; 61-layer decode step 0.77–0.93x.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #38235907942
Latest PR Test (Extra): ❌ Run #38235907289
Latest PR Test (AMD ROCm 10): ❌ Run #38235907761