Repository navigation
[ROCm][Perf][DSv4.1] Mono decode on every backbone layer - #61082
Conversation
The first layer and the Engram layers take K1 without the fold; the index sources run vLLM's compressor and indexer between K1 and K2, which builds the key table itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
|
/ci run |
|
✅ Triggered Buildkite CI #94092 for commit |
| ) | ||
| return out | ||
|
|
||
| def ffn( |
There was a problem hiding this comment.
Question: Would we be able to get rid of the "just ffn" part now? Not necessarily in this PR but in a future one
There was a problem hiding this comment.
Great catch! yes that's my next plan, but before getting rid of that part. I would like to evaluate if it can be reused by dsv4 pro or not.
There was a problem hiding this comment.
Excellent, yes makes sense!
I think this also relates to a broader design choice mentioned in the RFC that we might have to think about:
There are two layer modes:
- Whole layer: the kernel runs everything.
- FFN layer: vLLM runs attention with its output all-reduce turned off. The kernel sums the partials and runs the rest, as [ROCm][Perf][DSv4.1] Mono decode layer for DeepSeek-V4.1-Flash on MI355X #60397 does for 10 of its 40 layers.
i.e. when developing the abstractions for mono, should we simply allow only "whole layer" mode or should we also allow more fine grained ops to be treated as monokernels. I'm planning on drafting a first suggestion on what this might look like based on the RFC + some of the other PRs
Replace the VLLM_ROCM_MONO_DECODE environment variable with a KernelConfig field, set by --monokernel / --no-monokernel (RFC vllm-project#60904). It also works from --kernel-config and the Python API, and stays in the compile hash. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
|
LGTM. With |
…the diff / 按 diff 重写 DSv4.1-Flash MI355X vLLM 重测的 changelog 条目 - Update the image from nightly-rocm100-7d0b4e57aac4c4323225b0eee9ae960ce75ffffe to nightly-rocm100-5555a2d8f7116b2b4877f66516f4128176cf722a, the 2026-10-13 ROCm 10.0 nightly, which contains vllm-project/vllm#59039 and #61082. Update model.container to match. - No point changes: concurrency 1, 2, 4, 8, 16, 32 and 64 on TP2 and TP4 (14 points), all re-measured on the new image. - Remove --no-swa-bounded-replay, which turns on decoder SWA bounded replay from vllm-project/vllm#59039: in eager prefill steps, layer 20 (the last KV source layer) writes its KV for every token, and the rest of layer 20 and layers 21-39 run on each request's last 128 tokens only. Prefix-cache SWA replay stays off, since vLLM still forces it off on ROCm (the window clamp it needs lives only in the FlashInfer and FlashMLA prefill kernels). - Replace VLLM_ROCM_MONO_DECODE=1 with --monokernel. vllm-project/vllm#61082 moves the switch to KernelConfig.monokernel and removes the environment variable, so the old setting would leave the mono decode kernels off. - vllm-project/vllm#61082 also runs all 40 backbone layers whole as two persistent launches. Before, 30 ran whole and the other 10 (layers 0 and 1 and the compressor / indexer layers 2, 8, 14, 20, 24, 28, 32 and 36) kept vLLM's attention plus the FFN launch. The step limit is unchanged at 48 rows, i.e. concurrency 1-8 with five DSpark drafts; larger steps take the regular path. - No data-type or precision change to the DSpark draft. The checkpoint's bundled mtp.0-2 stages are stored like the target's layers: FP8 E4M3 weights with 32x32 UE8M0 block scales for the attention projections, shared experts and main_proj; MXFP4 routed experts; BF16 norms, router gate, Markov head and confidence head; F32 attention sinks and hc mixers. vLLM builds the draft with the checkpoint's own quantization config (get_draft_quant_config) and, with no kv_cache_dtype in speculative-config, the target's fp8_ds_mla KV cache, so it runs as shipped. The mono decode kernels skip the draft layers, and the draft load path is the same in 7d0b4e57 and 5555a2d8. - 镜像从 nightly-rocm100-7d0b4e57aac4c4323225b0eee9ae960ce75ffffe 更新为 nightly-rocm100-5555a2d8f7116b2b4877f66516f4128176cf722a,即 2026-10-13 的 ROCm 10.0 nightly,包含 vllm-project/vllm#59039 与 #61082。model.container 同步更新。 - 测试点不变:TP2 与 TP4 上并发 1、2、4、8、16、32、64(共 14 个点),全部在新镜像上重测。 - 移除 --no-swa-bounded-replay,从而启用 vllm-project/vllm#59039 的 decoder SWA bounded replay:在 eager prefill 步中,第 20 层(最后一个 KV 源层)为每个 token 写入 KV,第 20 层其余部分及第 21-39 层只在每个请求的最后 128 个 token 上运行。前缀缓存 SWA replay 仍然关闭,因为 vLLM 在 ROCm 上仍强制关闭它(所需的窗口钳制只存在于 FlashInfer 与 FlashMLA 的 prefill 内核中)。 - 将 VLLM_ROCM_MONO_DECODE=1 替换为 --monokernel。vllm-project/vllm#61082 把开关改为 KernelConfig.monokernel 并移除了该环境变量,保留旧设置会让 mono decode 内核处于关闭状态。 - vllm-project/vllm#61082 还让全部 40 个主干层整层以两次持久化内核启动运行。此前 30 层整层运行,其余 10 层(第 0、1 层以及 compressor / indexer 层 2、8、14、20、24、28、32、36)保留 vLLM 的 attention 并只走 FFN 启动。步长上限仍为 48 行,即 5 个 DSpark 草稿 token 下的并发 1-8;更大的步走常规路径。 - DSpark 草稿模型的数据类型与精度不变。checkpoint 自带的 mtp.0-2 阶段与目标模型各层的存储方式相同:attention 投影、shared experts 与 main_proj 为带 32x32 UE8M0 块缩放的 FP8 E4M3 权重;routed experts 为 MXFP4;norm、router gate、Markov head 与 confidence head 为 BF16;attention sink 与 hc mixer 为 F32。vLLM 用 checkpoint 自身的量化配置(get_draft_quant_config)构建草稿模型;speculative-config 未设置 kv_cache_dtype,因此沿用目标模型的 fp8_ds_mla KV cache,按原样运行。mono decode 内核跳过草稿层,草稿加载路径在 7d0b4e57 与 5555a2d8 中相同。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the diff - Update the image from nightly-rocm100-7d0b4e57aac4c4323225b0eee9ae960ce75ffffe to nightly-rocm100-5555a2d8f7116b2b4877f66516f4128176cf722a, the 2026-10-13 ROCm 10.0 nightly, which contains vllm-project/vllm#59039 and #61082. Update model.container to match. - No point changes: concurrency 1, 2, 4, 8, 16, 32 and 64 on TP2 and TP4 (14 points), all re-measured on the new image. - Remove --no-swa-bounded-replay, which turns on decoder SWA bounded replay from vllm-project/vllm#59039: in eager prefill steps, layer 20 (the last KV source layer) writes its KV for every token, and the rest of layer 20 and layers 21-39 run on each request's last 128 tokens only. Prefix-cache SWA replay stays off, since vLLM still forces it off on ROCm (the window clamp it needs lives only in the FlashInfer and FlashMLA prefill kernels). - Replace VLLM_ROCM_MONO_DECODE=1 with --monokernel. vllm-project/vllm#61082 moves the switch to KernelConfig.monokernel and removes the environment variable, so the old setting would leave the mono decode kernels off. - vllm-project/vllm#61082 also runs all 40 backbone layers whole as two persistent launches. Before, 30 ran whole and the other 10 (layers 0 and 1 and the compressor / indexer layers 2, 8, 14, 20, 24, 28, 32 and 36) kept vLLM's attention plus the FFN launch. The step limit is unchanged at 48 rows, i.e. concurrency 1-8 with five DSpark drafts; larger steps take the regular path. - No data-type or precision change to the DSpark draft. The checkpoint's bundled mtp.0-2 stages are stored like the target's layers: FP8 E4M3 weights with 32x32 UE8M0 block scales for the attention projections, shared experts and main_proj; MXFP4 routed experts; BF16 norms, router gate, Markov head and confidence head; F32 attention sinks and hc mixers. vLLM builds the draft with the checkpoint's own quantization config (get_draft_quant_config) and, with no kv_cache_dtype in speculative-config, the target's fp8_ds_mla KV cache, so it runs as shipped. The mono decode kernels skip the draft layers, and the draft load path is the same in 7d0b4e57 and 5555a2d8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… --monokernel on the latest ROCm 10.0 nightly / [AMD][MI355X] DSv4.1 Flash vLLM:在最新 ROCm 10.0 nightly 上启用 SWA bounded replay 与 --monokernel 并重测 (#3959) * perf(amd): re-sweep DSv4.1-Flash MI355X vLLM AgentX with SWA bounded replay and --monokernel / DSv4.1-Flash MI355X vLLM AgentX 启用 SWA bounded replay 与 --monokernel 并重测 Bump the image to nightly-rocm100-5555a2d8f7116b2b4877f66516f4128176cf722a, which contains vllm-project/vllm#59039 and #61082. Drop --no-swa-bounded-replay and replace VLLM_ROCM_MONO_DECODE=1 with --monokernel. 镜像更新至 nightly-rocm100-5555a2d8f7116b2b4877f66516f4128176cf722a,包含 vllm-project/vllm#59039 与 #61082。移除 --no-swa-bounded-replay,并用 --monokernel 取代 VLLM_ROCM_MONO_DECODE=1。 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(changelog): point the perf-changelog entry at PR 3959 / 将 perf-changelog 条目指向 PR 3959 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs(changelog): describe the DSv4.1-Flash MI355X vLLM re-sweep from the diff - Update the image from nightly-rocm100-7d0b4e57aac4c4323225b0eee9ae960ce75ffffe to nightly-rocm100-5555a2d8f7116b2b4877f66516f4128176cf722a, the 2026-10-13 ROCm 10.0 nightly, which contains vllm-project/vllm#59039 and #61082. Update model.container to match. - No point changes: concurrency 1, 2, 4, 8, 16, 32 and 64 on TP2 and TP4 (14 points), all re-measured on the new image. - Remove --no-swa-bounded-replay, which turns on decoder SWA bounded replay from vllm-project/vllm#59039: in eager prefill steps, layer 20 (the last KV source layer) writes its KV for every token, and the rest of layer 20 and layers 21-39 run on each request's last 128 tokens only. Prefix-cache SWA replay stays off, since vLLM still forces it off on ROCm (the window clamp it needs lives only in the FlashInfer and FlashMLA prefill kernels). - Replace VLLM_ROCM_MONO_DECODE=1 with --monokernel. vllm-project/vllm#61082 moves the switch to KernelConfig.monokernel and removes the environment variable, so the old setting would leave the mono decode kernels off. - vllm-project/vllm#61082 also runs all 40 backbone layers whole as two persistent launches. Before, 30 ran whole and the other 10 (layers 0 and 1 and the compressor / indexer layers 2, 8, 14, 20, 24, 28, 32 and 36) kept vLLM's attention plus the FFN launch. The step limit is unchanged at 48 rows, i.e. concurrency 1-8 with five DSpark drafts; larger steps take the regular path. - No data-type or precision change to the DSpark draft. The checkpoint's bundled mtp.0-2 stages are stored like the target's layers: FP8 E4M3 weights with 32x32 UE8M0 block scales for the attention projections, shared experts and main_proj; MXFP4 routed experts; BF16 norms, router gate, Markov head and confidence head; F32 attention sinks and hc mixers. vLLM builds the draft with the checkpoint's own quantization config (get_draft_quant_config) and, with no kv_cache_dtype in speculative-config, the target's fp8_ds_mla KV cache, so it runs as shipped. The mono decode kernels skip the draft layers, and the draft load path is the same in 7d0b4e57 and 5555a2d8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: seungrokj <seungrok.jung@amd.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
With --monokernel on gfx942, DeepSeek-V4.1-Flash decode steps run the mono decode kernels of vllm-project#60397. gfx942 has no scaled FP4 or FP8 MFMA and uses FNUZ FP8, so the kernels compute the same layer with FNUZ FP8 MFMAs on their own copies of the dense weights (mono/weights942.py) and dequantize the FP4 experts in VALU. The copies are made when vLLM processes the weights at load, so they count as model memory when vLLM sizes the KV cache, and a reload writes into them in place. A gfx942 workgroup has 64 KB of LDS, so a GEMV pass takes 6 tokens instead of 16 and the kernels take decode steps of up to 42 rows at TP 4, which is 7 requests with 5 DSpark drafts. A larger step, prefill and a mixed step run vLLM's path. Every backbone layer runs whole, as on gfx950 since vllm-project#61082. The index layers use vLLM's FP8 indexer, because the MXFP4 indexer cache needs CDNA4. On gfx942 mono/keylist.py writes an index layer's keys between vLLM's indexer and K2, and K2 is the build without the key table. The 3 DSpark draft layers also take the FFN launch, built for the draft's 128 experts and top 3. The gfx942 helper ops are in vllm/models/deepseek_v41/amd/ops/: the sparse indexer's decode top-512 (topk512_gfx942.cu, built with hipcc when the model is created) and its candidate logits, the SWA decode metadata and the top-k packing as one launch each, and DSpark's Markov sampling as one launch a draft step. Each helper leaves a call it cannot take to vLLM's own op. They run only with --monokernel on gfx942. The helpers run in forward passes, so the model records the flag when it is created. Two changes apply without the flag. On gfx942 the wvSplitK skinny GEMM takes at most 4 rows, because at 5 rows it read the DSpark draft's lm_head shard at 1.1 TB/s. The padding loops of _prepare_dflash_inputs_kernel step 1024 entries at a time instead of the step's block size. The kernel tests in tests/kernels/test_dsv41_gfx942_*.py and tests/kernels/test_dsv41_mono_gfx942.py run in a new MI300 job in .buildkite/test_areas/kernels.yaml. tests/models/test_dsv41_mono_decode.py covers gfx942 too. Signed-off-by: Markus Hartikainen <markus.hartikainen@amd.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
…t#61082) Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Andreas Karatzas <AndreasKaratzas@users.noreply.github.com>
…t#61082) The generic MonoKernel switch from upstream cc2a6ee: the KernelConfig.monokernel field, the --monokernel kernel-group flag and its transfer in create_engine_config. Models that cannot run their MonoKernel refuse at startup with ValueError("--monokernel <reason>."). Co-authored-by: Fangzhou Ai <fangzhou.ai@amd.com>
…e RDNA2 parts Restructure the gfx1030 MonoKernel to match AMD's upstream MonoKernels (RFC vllm-project#60904, vllm-project#61082, vllm-project#61325). No kernel behaviour change. Switch * --monokernel (KernelConfig.monokernel, backported) turns on every validated part with the validated defaults: k1 (<= 24 rows), k2 (<= 8 rows), gdn (<= 64 rows), qsa. VLLM_ROCM_MONO_DECODE=1 is an alias, read in the API server by the ROCm platform and carried to the workers by the config. * Per-part knobs move to --additional-config '{"rocm_mono_decode": {...}}', read only with the flag; unknown keys are an error. The rdna_mono_* keys are gone. * Unsupported deployments refuse at startup with ValueError("--monokernel <reason>."): not gfx10x, not Qwen4Exp, MoE not symmetric W4A16 on the RDNA2 method, not Model Runner V2, PP > 1, missing _rocm_C ops. One startup line per rank lists the active parts. * The scoped HW-queue budget from monokernel/fg1-skew: with the flag the engine raises GPU_MAX_HW_QUEUES to 4 for the workers if the launcher set less (hw_queues knob). Layout * vllm/models/qwen4_exp/amd/mono_decode_rdna2.py: entry point (switch, refusals, hook installation). * vllm/models/qwen4_exp/amd/mono/rdna2/{k1,k2,gdn,qsa,layout,debug}.py from mono_ffn.py and the GDN / QSA hunks; shared files keep short hooks (qwen_gdn_linear_attn.MONO_GDN_HOOK, ops.qsa.MONO_QSA). * Torch ops vllm::qwen4_exp_mono_{k1,k2,gdn,mark}_rdna2 (one GDN op; the splitting-op list follows). HIP ops _rocm_C::mono_k1_rdna2 (was mono_hc_rdna2), mono_k2_rdna2* (was mono_ffn_rdna2*), mono_k2_rdna2_e1a (was the compiled-out E1a mono_gdn_rdna2), mono_gdn_rdna2* (was gdn_fused_rdna2*), mono_qsa_decode_rdna2* (was qsa_decode_rdna2*), in csrc/rocm/mono_{k2,gdn,qsa_decode}_rdna2.cu. Tests: tests/models/qwen4_exp/test_amd_mono_rdna2{,_kernels}.py (switch, refusals, parameters; K1/K2, GDN, QSA vs today's ops). Tools move to tools/rdna/mono/ (serve_2a.sh uses --monokernel); docs/rdna2/tuning.md gains the switch, docs/rdna/monokernel/ stays as history.
…t#61082) Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
Main replaced VLLM_ROCM_MONO_DECODE with KernelConfig.monokernel (vllm-project#61082), so the shared runtime reads the switch from the config. The spec also refuses a bf16 KDA recurrent state (--mamba-ssm-cache-dtype, vllm-project#59147): the kernel keeps it in fp32. Signed-off-by: Sriram Kumar <skishore@amd.com>
Overview
Follow-up to #60397. The DeepSeek-V4.1-Flash mono decode kernels (MI355X,
--monokernel) now run all 40 backbone layers whole as K1 + K2. Before, 30 layers ran whole and the other 10 kept vLLM's attention plus the FFN launch: layer 0, the Engram layer 1, and the index sources 2, 8, 14, 20, 24, 28, 32, 36. The switch is now--monokernel(KernelConfig.monokernel, per RFC #60904), replacing theVLLM_ROCM_MONO_DECODEenvironment variable from #60397.Claims
mainwith mono on: P90 interactivity goes from 541.6 to 562.6 tokens/s/user (+3.9%), P50 from 569.8 to 595.5 (+4.5%), and ITL p50 from 1.760 to 1.680 ms.Validation
Performance. MI355X, TP4, DSpark with 5 drafts and synthetic acceptance 3.51 (InferenceX#3690's TP4 recipe), AgentX at concurrency 1. Each arm is one 3,600 s run, and both arms ran at the same time on GPUs 0–3 and 4–7.
main(7d0b4e5), mono onThe
mainarm reproduces InferenceX's sweep point for this config (543). A 900 s run of each arm on the Python frontend gave +6.2% on P90 (503.5 to 534.5).Accuracy. TP2, this branch, mono on against off, 4 seeds each, thinking on, DSpark with block rejection. Each mono-on server logged every backbone layer running whole.
Long context. RULER NIAH, TP2, this branch, mono on against off: single-1, multikey-2 and multikey-3 at 32K, 128K and 256K, 40 samples each, greedy. All 9 points score 1.00 on both arms (360 samples per arm).
Tests, all run locally on MI355X:
tests/models/test_dsv41_mono_layers.pyat TP2 and TP4: passed. Its 5-layer model now covers every variant: the first layer, a ratio-2 KV and index source, a ratio-2 consumer with an Engram, a ratio-1 KV, index and candidate source, and a ratio-1 index source over layer 3's candidates. Every layer has to take the whole-layer path on every rank at every decode step.tests/models/test_dsv41_mono_numerics.pyat TP2 and TP4, including the 300-replay CUDA-graph stress: passed.tests/models/test_dsv41_mono_decode.py: 37 passed.VLLM_GPU_SYNC_CHECK=erroron the 5-layer model with CUDA graphs: no sync in steady-state decode. The runner's one-time setup on the first decode step syncs, as onmain.Reproduce
Details
foldbuild flag. Without it, the seam slice takes the residual as it arrives instead of folding the previous layer's output in. Layer 0's residual is the embedding broadcast to the 4 streams, with an identity incoming pre-mix. The mix projection useshc_attn_fnover the broadcast, which equals vLLM's foldedhc_attn_fn_broadcastup to summation order. On an Engram layer,mhc_postand the Engram write run in torch before K1, as on vLLM's path.indexbuild flag._selectruns vLLM's own modules: the compressor and its cache insert, the indexer K write,weights_proj,forward_qandindexer_op.wq_bquantizes the bf16 qr itself, where vLLM's fused q-norm hands it fp8 qr. The model-level test bounds the difference._selectrestates the module call sequence of_forward_csa2_fulland_forward_csa2_reindexwithout their stream forks.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
AI assistance (Claude Code) was used to write this change, its tests and this description. The submitter reviews every changed line and has run the tests and benchmarks above. No other open PR runs these layers on the mono kernels; #60731 is the gfx942 port.
🤖 Generated with Claude Code