[Bugfix] Index Mamba align state copies by request slot in MRV2 by ZJY0516 · Pull Request #60210 · vllm-project/vllm · GitHub
Skip to content

[Bugfix] Index Mamba align state copies by request slot in MRV2 - #60210

Merged
ZJY0516 merged 1 commit into
vllm-project:mainfrom
ZJY0516:fix/mamba-align-req-slot-block-tables
Oct 7, 2026
Merged

ZJY0516 merged 1 commit into
vllm-project:mainfrom
ZJY0516:fix/mamba-align-req-slot-block-tables

Conversation

@ZJY0516

@ZJY0516 ZJY0516 commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Overview

Fix Mamba "align" state copies reading another request's block ids under MRV2 + PP + MTP, which poisons recurrent state (all-NaN logits, constant-token output, acceptance collapse). Consolidates #55506 and #57807 into a smaller change; both authors are co-authors. Refs #54173.

Claims

Validation

  • pytest tests/kernels/mamba/test_precopy_mamba_align.py tests/v1/worker/test_mamba_utils.py tests/v1/worker/test_mamba_hybrid_model_state.py tests/v1/worker/test_gpu_model_runner_v2_cudagraph_profiling.py: 146 passed (GB200).
  • With the kernels reverted to batch-row indexing, the new/updated kernel tests fail (26 failures), so they cover the bug.
  • E2E on GB200, Qwen3.6-27B, MRV2, MTP 4, --async-scheduling --enable-prefix-caching --mamba-cache-mode align (reproduction from @tomasruizt on [Bugfix] Index mamba spec-decode block tables by request slot, not batch row #55506). main = upstream 31e2443.
GSM8K 5-shot (mqa, chat, no think) Mean acceptance length (completions GSM8K / bench) Output tok/s (random 2k/1k, c=8) Mean TPOT
main, PP=2 did not finish: 8 requests stuck at AL 1.00 (no draft accepted) for 15 min at 772/1319, cancelled 2.95 / 3.56 1177 5.50 ms
this PR, PP=2 0.9727 strict / 0.9719 flexible 4.13 / 4.42 1506 4.76 ms
this PR, PP=1 (reference) 0.9727 strict / 0.9719 flexible 4.13 / 4.35 1589 4.46 ms

The stuck requests on main are the constant-token loop from poisoned recurrent state; with a 4096 max-token cap, main PP=2 averaged 235 output tokens per GSM8K question vs 82 for this PR at PP=2 and PP=1. The fix does not change kernel work; the throughput gain comes from the recovered acceptance length.

Reproduction commands
VLLM_USE_V2_MODEL_RUNNER=1 vllm serve Qwen/Qwen3.6-27B --language-model-only \
  --pipeline-parallel-size 2 --async-scheduling --enable-prefix-caching \
  --mamba-cache-mode align \
  --speculative-config '{"method": "mtp", "num_speculative_tokens": 4}'
# PP=1 reference: drop --pipeline-parallel-size 2

vllm bench serve --backend vllm --model Qwen/Qwen3.6-27B --dataset-name random \
  --random-input-len 2048 --random-output-len 1024 --random-range-ratio 0.75 \
  --random-prefix-len 1024 --ignore-eos --temperature 0 --seed 42 \
  --num-prompts 64 --max-concurrency 8

python tests/evals/gsm8k/gsm8k_eval.py --num-shots 5 --num-questions 1319 \
  --max-concurrency 64   # acceptance length column; accuracy from mqa gsm8k (5-shot, chat, no thinking)

Acceptance length is 1 + spec_decode_num_accepted_tokens / spec_decode_num_drafts from /metrics.

Details

Root cause: MambaSpecDecodeGPUContext captures block-table pointers once. MRV2 bound it to input_block_tables, a single buffer re-gathered in batch order every step, and the copy kernels indexed it by batch row. On a non-last PP rank the postprocess for step N runs after step N+k has re-gathered that buffer, so batch rows point at other requests' blocks. With the unified hybrid cache layout those copies land in live state.

Why not just #55506 or #57807: both keep lazy binding and add machinery around it (temporary bindings / bind flag, or two lazily bound contexts plus profiling teardown), and #55506 remaps the aligned-index kernel through idx_mapping, which changes padded-row behavior. Binding both table sets eagerly avoids all of that. The source tables are safe to read late because a request is not rescheduled (so its row is not rewritten or its slot reused) until its in-flight step's output is processed.

MRV1 is unaffected: it launches both kernels without idx_mapping, where req_idx == batch_idx, and passes a single table set, which stays the default for the aligned-index tables.

Credit: root cause first identified by @zebgop-ops; fix direction and kernel tests from @Karl0007 (#55506); separate metadata/copy tables and the profiling lifetime issue from @yongqinwang-cmd (#57807).


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (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.

Co-authored-by: Karl0007 <44745209+Karl0007@users.noreply.github.com>
Co-authored-by: Yongqin Wang <yongqinwang@roblox.com>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
@mergify mergify Bot added mrv2 Model Runner V2 specific bug Something isn't working labels Oct 6, 2026
@ZJY0516
ZJY0516 marked this pull request as ready for review October 6, 2026 11:01

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@njhill njhill left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @ZJY0516, looks great

@ZJY0516 ZJY0516 added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 7, 2026
@ZJY0516

ZJY0516 commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

/ci run --allow-stale

@ZJY0516
ZJY0516 enabled auto-merge (squash) October 7, 2026 01:17
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #93220 for commit feb2b73d89da.

⚠️ This PR is 43 commits behind upstream main. Running CI at your own risk because --allow-stale was requested; outdated CI configuration may cause failures. Before merging, merge or rebase onto the latest main, then rerun /ci run on the latest PR commit.

@vllm-agent

Copy link
Copy Markdown
Collaborator

CI selector (shadow): 132 test steps (173 jobs) instead of 70 (86 jobs)

Shadow mode: this changes nothing about what CI runs. It shows what the evidence-based selector would pick for this PR, next to today's rules. How it works.

Feedback welcome: reply here if it would skip a step this change needs, or runs something unrelated.

steps (jobs) Today's rules Selector Would skip Would add
NVIDIA, CPU and others 70 (86) 132 (173) 14 (20) 76 (107)
AMD mirrors 63 (76) 117 (149) 9 (12) 63 (85)
Selector would run (132)
  • amd-kernels-mi355
  • amd-lm-eval-small-models-harness
  • amd-qwen3-next-mtp-async-eplb-accuracy
  • arm-cpu-test ×3
  • async-engine-inputs-utils-worker
  • basic-correctness ×2
  • basic-correctness-cpu-offload
  • basic-correctness-cumem
  • basic-correctness-prefetch-offload
  • basic-correctness-sleep-mode
  • basic-models-tests-extra-initialization ×14
  • basic-models-tests-other
  • batch-invariance-b200
  • batch-invariance-h100
  • benchmarks-cli-test
  • cpu-kernel-tests ×2
  • cpu-language-generation-and-pooling-model-tests ×3
  • cpu-multimodal-config
  • cpu-spec-decode-tests
  • crosslayer-kv-layout-distributed-nixlconnector-pd-accuracy-tests-4-gpus
  • cudagraph
  • distributed-compile-comm-4-gpus
  • distributed-compile-rpc-tests-2-gpus
  • distributed-dp-tests-2-gpus
  • distributed-dp-tests-4-gpus
  • distributed-flashinfer-nixlconnector-pd-accuracy-4-gpus
  • distributed-model-tests-2-gpus ×3
  • distributed-mooncakeconnector-pd-accuracy-4-gpus
  • distributed-nixlconnector-pd-accuracy-4-gpus
  • distributed-tests-8xh100
  • distributed-torchrun-examples-4-gpus
  • distributed-torchrun-shutdown-tests-2-gpus
  • dp-ep-distributed-nixlconnector-pd-accuracy-tests-4-gpus
  • e2e-core-1-gpu
  • e2e-core-large-memory
  • e2e-scheduling-1-gpu
  • e2e-scheduling-accuracy-1-gpu
  • elastic-ep-scaling-test
  • engine
  • engine-1-gpu
  • entrypoints-integration-api-server ×4
  • entrypoints-integration-api-server-generate
  • entrypoints-integration-api-server-openai-chat_completion
  • entrypoints-integration-api-server-openai-completion
  • entrypoints-integration-llm
  • entrypoints-integration-multimodal
  • entrypoints-integration-pooling
  • entrypoints-integration-responses-api
  • entrypoints-integration-speech_to_text
  • entrypoints-unit-tests
  • examples
  • extract-hidden-states-integration
  • extract-hidden-states-integration-2-gpus
  • fault-tolerance-e2e-2xh100
  • fusion-e2e-config-sweep-h100
  • fusion-e2e-quick-h100
  • fusion-e2e-tp2-ar-rms-config-sweep-h100
  • fusion-e2e-tp2-ar-rms-dynamo-partition-amd
  • fusion-e2e-tp2-ar-rms-inductor-partition-amd
  • fusion-e2e-tp2-b200
  • fusion-e2e-tp2-quick-h100
  • hybrid-ssm-nixlconnector-pd-accuracy-tests-4-gpus
  • hybrid-ssm-nixlconnector-pd-prefix-cache-2-gpus
  • kernels-b200 ×3
  • kernels-deepgemm-test-h100
  • kernels-mamba-test
  • kernels-root-misc-test-b200
  • kimi-k3-prefix-cache-4xb200 ×2
  • kimi-k3-unit-tests-b200
  • kv-offload-large
  • kv-offload-medium
  • kv-offload-small
  • language-models-tests-extra-standard ×2
  • language-models-tests-granite-l4-compatibility
  • language-models-tests-hybrid ×2
  • language-models-tests-standard
  • lm-eval-dspark-watermark-2xh100
  • lm-eval-small-models
  • lm-eval-turboquant-k3v4nc
  • lm-eval-turboquant-k8v4
  • lm-eval-turboquant-t3nc
  • lm-eval-turboquant-t4nc
  • lm-eval-watermarking
  • lora ×4
  • lora-tp-distributed ×4
  • metrics-tracing-2-gpus
  • model-executor
  • mooncake-ec-tcp-e2e-2-gpus
  • mrcr-eval-small-models
  • multi-modal-accuracy-eval-small-models
  • multi-modal-models-standard-1-qwen2
  • multi-modal-models-standard-2-qwen3-gemma
  • multi-modal-models-standard-3-llava-qwen2-vl
  • multi-modal-models-standard-4-other-whisper
  • multiconnector-nixl-offloading-pd-accuracy-2-gpus
  • multiconnector-nixl-offloading-pd-edge-cases-2-gpus
  • nixlconnector-pd-edge-cases-2-gpus
  • openai-api-correctness
  • pipeline-context-parallelism-4-gpus
  • plugin-tests-2-gpus
  • push-nixlconnector-pp-prefill-pd-accuracy-4-gpus
  • pytorch-compilation-dynamic-shapes
  • pytorch-compilation-unit-tests
  • pytorch-compilation-unit-tests-h100
  • pytorch-fullgraph-cudagraph-l4-compatibility
  • pytorch-fullgraph-test
  • quantized-moe-test-b200
  • rayexecutorv2-4-gpus
  • regression
  • replayssm-e2e
  • rust-frontend-core-correctness
  • rust-frontend-distributed
  • rust-frontend-openai-coverage
  • rust-frontend-serve-admin-coverage
  • rust-frontend-tool-use
  • samplers-multimodal-beam-search
  • samplers-test
  • scale-out-ec-e2e-2-gpus
  • sharded-rdt-weight-transfer
  • spec-decode-draft-model ×4
  • spec-decode-eagle-1-deepseek-qwen
  • spec-decode-eagle-2-llama3-qwen-vl-other
  • spec-decode-mtp-deepseek-mimo
  • spec-decode-mtp-gemma4
  • spec-decode-mtp-qwen3-5
  • spec-decode-speculators
  • v1-core
  • v1-executor-worker
  • v1-kv-connectors ×4
  • v1-metrics-lmeval
  • v1-sample
  • v1-spec-decode
Would skip (today's rules run them) (14)
  • ascend-npu-test
  • basic-models-test-other-cpu
  • basic-models-tests-initialization
  • cpu-params-env-tokenizers-parser
  • cpu-reasoning-renderers
  • cpu-tool-parsers
  • kernels-fla-ops-test-b200
  • kernels-mhc-test-b200
  • multi-modal-processor ×4
  • multi-modal-processor-cpu ×4
  • pytorch-compilation-passes-unit-tests
  • v1-kv-offload
  • v1-logits-oracle
  • v1-others-cpu
Would add (today's rules do not run them) (76)
  • amd-kernels-mi355 (Python record)
  • amd-lm-eval-small-models-harness (Python record)
  • amd-qwen3-next-mtp-async-eplb-accuracy (Python record)
  • arm-cpu-test ×3 (code map)
  • basic-models-tests-extra-initialization ×14 (Python record)
  • batch-invariance-b200 (Python record)
  • batch-invariance-h100 (Python record)
  • cpu-kernel-tests ×2 (code map)
  • crosslayer-kv-layout-distributed-nixlconnector-pd-accuracy-tests-4-gpus (Python record)
  • cudagraph (Python record)
  • distributed-compile-comm-4-gpus (Python record)
  • distributed-dp-tests-4-gpus (Python record)
  • distributed-flashinfer-nixlconnector-pd-accuracy-4-gpus (Python record)
  • distributed-model-tests-2-gpus ×3 (code map)
  • distributed-mooncakeconnector-pd-accuracy-4-gpus (Python record)
  • distributed-nixlconnector-pd-accuracy-4-gpus (Python record)
  • distributed-tests-8xh100 (Python record)
  • distributed-torchrun-examples-4-gpus (Python record)
  • dp-ep-distributed-nixlconnector-pd-accuracy-tests-4-gpus (Python record)
  • elastic-ep-scaling-test (Python record)
  • engine (Python record)
  • engine-1-gpu (Python record)
  • entrypoints-unit-tests (Python record)
  • examples (Python record)
  • extract-hidden-states-integration (Python record)
  • extract-hidden-states-integration-2-gpus (Python record)
  • fusion-e2e-config-sweep-h100 (Python record)
  • fusion-e2e-quick-h100 (Python record)
  • fusion-e2e-tp2-ar-rms-config-sweep-h100 (Python record)
  • fusion-e2e-tp2-ar-rms-dynamo-partition-amd (Python record)
  • fusion-e2e-tp2-ar-rms-inductor-partition-amd (Python record)
  • fusion-e2e-tp2-b200 (Python record)
  • fusion-e2e-tp2-quick-h100 (Python record)
  • hybrid-ssm-nixlconnector-pd-accuracy-tests-4-gpus (Python record)
  • hybrid-ssm-nixlconnector-pd-prefix-cache-2-gpus (Python record)
  • kernels-b200 ×3 (Python record)
  • kernels-deepgemm-test-h100 (Python record)
  • kimi-k3-prefix-cache-4xb200 ×2 (Python record)
  • kimi-k3-unit-tests-b200 (code map)
  • kv-offload-large (Python record)
  • kv-offload-medium (Python record)
  • kv-offload-small (Python record)
  • language-models-tests-extra-standard ×2 (code map)
  • lm-eval-small-models (Python record)
  • lm-eval-turboquant-k3v4nc (Python record)
  • lm-eval-turboquant-k8v4 (Python record)
  • lm-eval-turboquant-t3nc (Python record)
  • lm-eval-turboquant-t4nc (Python record)
  • lora ×4 (Python record)
  • lora-tp-distributed ×4 (Python record)
  • model-executor (code map)
  • mrcr-eval-small-models (Python record)
  • multi-modal-accuracy-eval-small-models (Python record)
  • multiconnector-nixl-offloading-pd-accuracy-2-gpus (Python record)
  • multiconnector-nixl-offloading-pd-edge-cases-2-gpus (Python record)
  • nixlconnector-pd-edge-cases-2-gpus (Python record)
  • openai-api-correctness (Python record)
  • plugin-tests-2-gpus (Python record)
  • push-nixlconnector-pp-prefill-pd-accuracy-4-gpus (Python record)
  • quantized-moe-test-b200 (Python record)
  • rayexecutorv2-4-gpus (Python record)
  • rust-frontend-core-correctness (Python record)
  • rust-frontend-openai-coverage (Python record)
  • rust-frontend-serve-admin-coverage (Python record)
  • rust-frontend-tool-use (Python record)
  • samplers-multimodal-beam-search (Python record)
  • samplers-test (Python record)
  • scale-out-ec-e2e-2-gpus (Python record)
  • sharded-rdt-weight-transfer (Python record)
  • spec-decode-draft-model ×4 (Python record)
  • spec-decode-eagle-1-deepseek-qwen (Python record)
  • spec-decode-eagle-2-llama3-qwen-vl-other (Python record)
  • spec-decode-mtp-deepseek-mimo (Python record)
  • spec-decode-mtp-gemma4 (Python record)
  • spec-decode-mtp-qwen3-5 (Python record)
  • spec-decode-speculators (Python record)
AMD mirrors: would skip (9)
  • basic-models-tests-initialization
  • fault-tolerance-e2e-2xh100
  • kernels-fla-ops-test-b200
  • kernels-mhc-test-b200
  • multi-modal-processor ×4
  • platform-tests
  • pytorch-compilation-passes-unit-tests
  • v1-kv-offload
  • v1-logits-oracle
AMD mirrors: would add (63)
  • crosslayer-kv-layout-distributed-nixlconnector-pd-accuracy-tests-4-gpus (Python record)
  • cudagraph (Python record)
  • distributed-dp-tests-4-gpus (Python record)
  • distributed-flashinfer-nixlconnector-pd-accuracy-4-gpus (Python record)
  • distributed-mooncakeconnector-pd-accuracy-4-gpus (Python record)
  • distributed-nixlconnector-pd-accuracy-4-gpus (Python record)
  • distributed-tests-8xh100 (Python record)
  • distributed-torchrun-examples-4-gpus (Python record)
  • dp-ep-distributed-nixlconnector-pd-accuracy-tests-4-gpus (Python record)
  • engine (Python record)
  • engine-1-gpu (Python record)
  • entrypoints-unit-tests (Python record)
  • examples (Python record)
  • extract-hidden-states-integration (Python record)
  • extract-hidden-states-integration-2-gpus (Python record)
  • fusion-e2e-config-sweep-h100 (Python record)
  • fusion-e2e-quick-h100 (Python record)
  • fusion-e2e-tp2-ar-rms-config-sweep-h100 (Python record)
  • fusion-e2e-tp2-b200 (Python record)
  • fusion-e2e-tp2-quick-h100 (Python record)
  • hybrid-ssm-nixlconnector-pd-accuracy-tests-4-gpus (Python record)
  • hybrid-ssm-nixlconnector-pd-prefix-cache-2-gpus (Python record)
  • kernels-moe-test ×5 (Python record)
  • kernels-quantization-test ×6 (Python record)
  • kimi-k3-unit-tests-b200 (code map)
  • kv-offload-medium (Python record)
  • kv-offload-small (Python record)
  • language-models-tests-extra-standard ×2 (code map)
  • lm-eval-small-models (Python record)
  • lm-eval-turboquant-k3v4nc (Python record)
  • lm-eval-turboquant-k8v4 (Python record)
  • lm-eval-turboquant-t3nc (Python record)
  • lm-eval-turboquant-t4nc (Python record)
  • lora ×4 (Python record)
  • lora-tp-distributed ×4 (Python record)
  • model-executor (code map)
  • mrcr-eval-small-models (Python record)
  • multi-modal-accuracy-eval-small-models (Python record)
  • multiconnector-nixl-offloading-pd-accuracy-2-gpus (Python record)
  • multiconnector-nixl-offloading-pd-edge-cases-2-gpus (Python record)
  • nixlconnector-pd-edge-cases-2-gpus (Python record)
  • nixlconnector-pd-spec-decode-acceptance-2-gpus (Python record)
  • openai-api-correctness (Python record)
  • plugin-tests-2-gpus (Python record)
  • push-nixlconnector-pp-prefill-pd-accuracy-4-gpus (Python record)
  • quantization ×4 (Python record)
  • quantized-models-test (Python record)
  • rayexecutorv2-4-gpus (Python record)
  • rust-frontend-core-correctness (Python record)
  • rust-frontend-openai-coverage (Python record)
  • rust-frontend-serve-admin-coverage (Python record)
  • rust-frontend-tool-use (Python record)
  • samplers-multimodal-beam-search (Python record)
  • samplers-test (Python record)
  • scale-out-ec-e2e-2-gpus (Python record)
  • sharded-rdt-weight-transfer (Python record)
  • spec-decode-draft-model ×4 (Python record)
  • spec-decode-eagle-1-deepseek-qwen (Python record)
  • spec-decode-eagle-2-llama3-qwen-vl-other (Python record)
  • spec-decode-mtp-deepseek-mimo (Python record)
  • spec-decode-mtp-gemma4 (Python record)
  • spec-decode-mtp-qwen3-5 (Python record)
  • spec-decode-speculators (Python record)

6 changed files · base 31e2443c90 · head feb2b73d89 · Python record: build 93039 at 1e5d0ea888 · kernel record: table 1e5d0ea (build 93039), map 1e5d0ea · not counted: 10 build steps, 5 A100 steps the generator no longer emits, 116 optional steps the selector would also run

@ZJY0516
ZJY0516 merged commit 8a26869 into vllm-project:main Oct 7, 2026
180 checks passed
@ZJY0516
ZJY0516 deleted the fix/mamba-align-req-slot-block-tables branch October 7, 2026 06:39
dllehr-amd added a commit to dllehr-amd/vllm that referenced this pull request Oct 16, 2026
…-project#60210)

The hook upstream main added in vllm-project#60210 (2026-10-07, after this branch's base
74c5cbc): ModelState.initialize_kv_cache(kv_cache_config, block_tables), run after
the KV cache tensors are allocated and bound (the CUDA-graph memory-profiling cache,
then the real one). Identical to upstream's; drops out on rebase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FezMZ1ejD2hGmG6kJYzp9g
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…-project#60210)

Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Co-authored-by: Karl0007 <44745209+Karl0007@users.noreply.github.com>
Co-authored-by: Yongqin Wang <yongqinwang@roblox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mrv2 Model Runner V2 specific ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants