Skip to content

Fix Step3.5 MTP local argmax draft step - #8

Closed
voipmonitor wants to merge 3 commits into
dev/black-benedictionfrom
codex/ds4-step35-mtp-local-argmax-spec-step-20260608
Closed

Fix Step3.5 MTP local argmax draft step#8
voipmonitor wants to merge 3 commits into
dev/black-benedictionfrom
codex/ds4-step35-mtp-local-argmax-spec-step-20260608

Conversation

@voipmonitor

@voipmonitor voipmonitor commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Fix Step3.5 MTP greedy local-argmax draft selection so each speculative step calls the model through _model_get_top_tokens(hidden_states, spec_step_idx) instead of directly calling model.get_top_tokens(hidden_states).

The direct call dropped spec_step_idx, which made multi-step MTP models such as DeepSeek V4 / GLM use the default MTP head for every draft position. With use_local_argmax_reduction=true, later draft positions had near-zero acceptance and could crash under CUDA graphs. The helper preserves compatibility with models whose get_top_tokens does not accept spec_step_idx.

Validation

  • Reproduced the broken clean local-argmax path on DS4 Flash TP2/MTP2 greedy: acceptance was 4 / 158, per-position 0.051, 0.000, followed by a CUDA illegal memory access on a subsequent smoke request.
  • Verified the fix via file bind mount first: 4/4 smoke prompts coherent; acceptance 113 / 146, per-position 0.890, 0.658.
  • Rebuilt a clean image with the fix baked in and no source bind mounts: health 200; 4/4 smoke prompts coherent with cjk=0; acceptance 163 / 206 = 79.1%, per-position 0.961, 0.621.

No production B12X binding/workspace behavior is changed.

lukealonso and others added 2 commits June 7, 2026 10:34
Automatically apply B12X virtual TP padding when supported B12X attention/MoE paths need compatible TP shapes. Remove the public virtual TP sharding and alignment CLI/config knobs, use fixed B12X capability alignments, and warn when automatic padding is enabled.

Co-authored-by: OpenAI Codex <codex@openai.com>
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors vLLM's virtual tensor parallelism (TP) configuration and sparse attention indexer handling. It removes explicit virtual-TP sharding CLI parameters and configuration fields, transitioning to a plan-based B12X padding approach. It migrates sparse attention and MLA indexers from compressed/integration APIs to paged-indexer APIs, and adds distributed context parallelism (DCP) support for global sequence length handling in decode tensor preparation.

Changes

Virtual TP + Sparse/MLA Indexer Refactoring

Layer / File(s) Summary
Virtual TP sharding configuration removal
vllm/engine/arg_utils.py, vllm/config/parallel.py, vllm/config/__init__.py, vllm/config/speculative.py
Removes VirtualTPSharding type and VIRTUAL_TP_SHARDING_* constants from public exports; deletes virtual_tp_sharding and b12x_virtual_tp_*_alignment fields from EngineArgs and ParallelConfig; removes corresponding CLI argument definitions and parameter passing into ParallelConfig.
B12X virtual TP padding logic refactoring
vllm/config/virtual_tp.py
Transitions from mode-based gate (checking virtual_tp_sharding value) to capability-driven plan-based approach; builds in-memory plan dictionary from attention/MoE/vocab axes; detects whether padding is needed and applies padded dimensions to config objects; changes logging from info to warning with updated compatibility wording; removes explicit positive-alignment validation checks.
Virtual TP padding enabled detection
vllm/model_executor/virtual_tp.py
Updates is_virtual_tp_padded_enabled() to return true for any non-None virtual TP plan instead of checking for specific sharding mode value.
Sparse attention indexer paged migration
vllm/model_executor/layers/sparse_attn_indexer.py
Replaces compressed-indexer constants with paged-indexer constants for page sizing/layout; updates KV cache shape validation to expect paged dimensions; rewrites _run_b12x_paged_topk and _reserve_b12x_paged_indexer_scratch to use b12x.attention.indexer APIs (plan_indexer_scratch, index_topk_fp8) instead of compressed integration; adds shared_page_table parameter handling; updates error message references.
MLA indexer DCP support
vllm/v1/attention/backends/mla/indexer.py
Adds optional global_seq_lens parameter to _prepare_decode_tensors; computes DCP-local sequence lengths in uniform, variable, and next-n decode expansion paths when DCP enabled and compress_ratio==1; extends compressed slot mapping computation to DCP scenarios; updates B12X supertile-K helper from compressed to paged variant; changes schedule metadata builder import from b12x.integration.indexer to b12x.attention.indexer.
DeepSeek attention indexer documentation
vllm/models/deepseek_v4/attention.py
Clarifies V3.2 and DeepseekV4 indexer cache layout consistency in comments; corrects FP8 layout documentation wording.
Virtual TP padding test coverage
tests/config/test_virtual_tp.py
Adds FakeAlignedGlmDsaModelConfig for aligned config scenarios; introduces logging assertion test for B12X padding warnings; updates padding expectation tests for new plan format; adds shared-expert intermediate alignment constraint; introduces aligned-config skipping test; changes unsupported-model test from expecting ValueError to asserting plan attribute absence.
Sparse indexer test coverage
tests/model_executor/layers/test_sparse_attn_indexer_b12x.py
Rewires fake b12x module to provide paged indexer namespace; updates fake scratch planner and paged bind/top-k implementations to record new call signatures; rewrites tests to validate paged decode/prefill behavior with shared_page_table variants; adds tests for paged profile budgeting and schedule metadata construction.
CLI argument test coverage
tests/engine/test_arg_utils.py
Removes test for b12x-padded virtual TP CLI alias; adds test validating that virtual TP CLI arguments now cause SystemExit.
Serving scripts updates
festr.sh, serve-ds4-flash.sh, serve-ds4-pro-tp10.sh, serve-glm51-tp6.sh, serve-glm51.sh
Adds new festr.sh Docker container serving script with comprehensive GPU/NCCL environment setup; removes virtual-TP sharding/alignment CLI arguments from existing serve scripts; updates environment variable defaults; hard-sets NCCL and runtime tuning variables in serve-glm51.sh.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • local-inference-lab/vllm#4: Modifies vllm/v1/attention/backends/mla/indexer.py to add DCP decode metadata handling with global sequence lengths and DCP-local sequence length computation when compress_ratio == 1.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'Fix Step3.5 MTP local argmax draft step' directly addresses the main fix, but the PR includes numerous unrelated changes to B12X virtual TP padding, indexer planning, and DCP metadata that are not reflected in the title. Either focus the PR to only the Step3.5 MTP fix, or revise the title to reflect the broader scope of changes (e.g., 'B12X virtual TP refactor and Step3.5 MTP local argmax fix').
Docstring Coverage ⚠️ Warning Docstring coverage is 8.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/ds4-step35-mtp-local-argmax-spec-step-20260608

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
serve-glm51.sh (1)

20-24: ⚡ Quick win

Redundant environment variable assignments.

Several variables are being set twice with conflicting patterns:

  • OMP_NUM_THREADS is set with a default on line 14, then hard-set on line 23
  • NCCL_IB_DISABLE is set with a default on line 19, then hard-set on line 20

The hard-set assignments on lines 20-23 make the conditional defaults on lines 14 and 19 ineffective. Consider removing either the conditional defaults or the hard-set assignments to avoid confusion.

♻️ Proposed fix to remove redundant conditional defaults
 export PYTHONPATH="${SCRIPT_DIR}${PYTHONPATH:+:${PYTHONPATH}}"
-export OMP_NUM_THREADS="${OMP_NUM_THREADS:-16}"
 export SAFETENSORS_FAST_GPU="${SAFETENSORS_FAST_GPU:-1}"
 export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-2,3,4,5,6,7,8,9}"
 export CUTE_DSL_ARCH="${CUTE_DSL_ARCH:-sm_120a}"
 export CUDA_DEVICE_MAX_CONNECTIONS="${CUDA_DEVICE_MAX_CONNECTIONS:-32}"
-export NCCL_IB_DISABLE="${NCCL_IB_DISABLE:-1}"
 export NCCL_IB_DISABLE=1
 export NCCL_P2P_LEVEL=SYS
 export NCCL_PROTO=LL,LL128,Simple
 export OMP_NUM_THREADS=16
 export LLM_WORKER_MULTIPROC_METHOD=spawn
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@serve-glm51.sh` around lines 20 - 24, The script currently sets
NCCL_IB_DISABLE and OMP_NUM_THREADS twice (conditional defaults earlier and
hard-set later), causing the defaults to be ineffective; remove the duplicate
hard-set exports for NCCL_IB_DISABLE and OMP_NUM_THREADS (or alternatively
convert the hard-set lines for NCCL_IB_DISABLE, NCCL_P2P_LEVEL, NCCL_PROTO,
OMP_NUM_THREADS, LLM_WORKER_MULTIPROC_METHOD into conditional/parameterized
exports) so each environment variable is defined only once and the intended
conditional defaults take effect; target the export statements for
NCCL_IB_DISABLE and OMP_NUM_THREADS (and optionally NCCL_P2P_LEVEL, NCCL_PROTO,
LLM_WORKER_MULTIPROC_METHOD) in the snippet and either delete the redundant
hard-set lines or make them conditional (preserving the original default
behavior).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@festr.sh`:
- Line 1: This script lacks a shebang which can cause it to run under an
unexpected shell; edit festr.sh to add a POSIX shebang as the very first line
(use env to locate bash or a plain /bin/sh shebang) so the script executes with
the intended shell, and ensure the file is marked executable (chmod +x) after
updating; leave the existing docker run -d \ command unchanged.

---

Nitpick comments:
In `@serve-glm51.sh`:
- Around line 20-24: The script currently sets NCCL_IB_DISABLE and
OMP_NUM_THREADS twice (conditional defaults earlier and hard-set later), causing
the defaults to be ineffective; remove the duplicate hard-set exports for
NCCL_IB_DISABLE and OMP_NUM_THREADS (or alternatively convert the hard-set lines
for NCCL_IB_DISABLE, NCCL_P2P_LEVEL, NCCL_PROTO, OMP_NUM_THREADS,
LLM_WORKER_MULTIPROC_METHOD into conditional/parameterized exports) so each
environment variable is defined only once and the intended conditional defaults
take effect; target the export statements for NCCL_IB_DISABLE and
OMP_NUM_THREADS (and optionally NCCL_P2P_LEVEL, NCCL_PROTO,
LLM_WORKER_MULTIPROC_METHOD) in the snippet and either delete the redundant
hard-set lines or make them conditional (preserving the original default
behavior).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 40c48c03-fd07-4e35-9385-99a9fe1d0d83

📥 Commits

Reviewing files that changed from the base of the PR and between 589045f and 00e862f2b2d844d9aafceac2469436cd6d5abd18.

📒 Files selected for processing (18)
  • festr.sh
  • serve-ds4-flash.sh
  • serve-ds4-pro-tp10.sh
  • serve-glm51-tp6.sh
  • serve-glm51.sh
  • tests/config/test_virtual_tp.py
  • tests/engine/test_arg_utils.py
  • tests/model_executor/layers/test_sparse_attn_indexer_b12x.py
  • vllm/config/__init__.py
  • vllm/config/parallel.py
  • vllm/config/speculative.py
  • vllm/config/virtual_tp.py
  • vllm/engine/arg_utils.py
  • vllm/model_executor/layers/sparse_attn_indexer.py
  • vllm/model_executor/virtual_tp.py
  • vllm/models/deepseek_v4/attention.py
  • vllm/v1/attention/backends/mla/indexer.py
  • vllm/v1/spec_decode/step3p5.py
💤 Files with no reviewable changes (6)
  • serve-glm51-tp6.sh
  • vllm/config/init.py
  • serve-ds4-flash.sh
  • vllm/config/speculative.py
  • vllm/config/parallel.py
  • vllm/engine/arg_utils.py

Comment thread festr.sh
@@ -0,0 +1,67 @@
docker run -d \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add shebang to make script executable.

The script is missing a shebang line, which means it may not execute correctly or may execute with an unexpected shell. This can lead to portability and compatibility issues.

🔧 Proposed fix to add shebang
+#!/usr/bin/env bash
 docker run -d \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker run -d \
#!/usr/bin/env bash
docker run -d \
🧰 Tools
🪛 Shellcheck (0.11.0)

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@festr.sh` at line 1, This script lacks a shebang which can cause it to run
under an unexpected shell; edit festr.sh to add a POSIX shebang as the very
first line (use env to locate bash or a plain /bin/sh shebang) so the script
executes with the intended shell, and ensure the file is marked executable
(chmod +x) after updating; leave the existing docker run -d \ command unchanged.

Source: Linters/SAST tools

@voipmonitor
voipmonitor changed the base branch from main to dev/black-benediction June 8, 2026 06:37
Pass spec_step_idx through the local-argmax draft token path instead of calling get_top_tokens() with its default step 0. DeepSeek V4/DS4 MTP has one head per speculative step; using step 0 for later draft positions produced near-zero acceptance and could crash the worker under CUDA graphs. Reuse the existing _model_get_top_tokens helper so models that do not accept spec_step_idx keep the previous call shape.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants