Skip to content

[eldritch] Fix B12X DCP global-topk MTP path - #37

Merged
lukealonso merged 2 commits into
dev/eldritch-enlightenmentfrom
codex/eldritch-dcp-globaltopk-mtp-20260623
Jun 28, 2026
Merged

[eldritch] Fix B12X DCP global-topk MTP path#37
lukealonso merged 2 commits into
dev/eldritch-enlightenmentfrom
codex/eldritch-dcp-globaltopk-mtp-20260623

Conversation

@voipmonitor

@voipmonitor voipmonitor commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Port the validated GLM-5.2 B12X DCP global-topk/MTP fix onto dev/eldritch-enlightenment.

This is the eldritch-targeted equivalent of the already validated dark-devotion PR #31. It keeps the B12X DCP global-topk path rank-consistent during warmup and makes the MTP draft path provide the same top-k score buffer that the target path expects.

Changes

  • Preserve empty DCP prefill chunks for B12X global-topk collectives.
  • Prewarm the real B12X DCP global-topk merge path.
  • Keep no-local-KV chunks in the global merge path with -inf scores and mask invalid results back to -1.
  • Prewarm B12X sparse MLA extend kernels using caller-owned scratch via plan.bind(scratch=...).
  • Allocate and pass topk_scores_buffer from the MTP draft layer under DCP + B12X sparse indexer.

Notes

This keeps the vLLM B12X binding rule: no cached vLLM workspace/arena ownership; plans bind caller scratch per call.

Validation

  • git diff --check lil/dev/eldritch-enlightenment..HEAD
  • python3 -m py_compile on changed Python files

Runtime validation will be done in the composed eldritch Docker stack.

Summary by CodeRabbit

  • Refactor / Performance
    • Improved sparse attention indexing and distributed top-k handling, including converting rank-local results into global form for B12X.
    • Added smarter DCP-aware synchronization and initialization prewarming to stabilize sparse attention backend startup.
    • Reworked warmup to reuse the real merge path for representative candidate sizes and ensure correct cross-rank behavior.
  • Bug Fixes
    • Fixed prefill metadata handling for empty sequence ranges so DCP global top-k can still be preserved when enabled.
  • New Features
    • Enabled conditional top-k score buffering for DeepSeek multi-token predictor when using the v32 path with multi-context decoding parallelism.

Keep the B12X DCP global top-k path rank-consistent through graph warmup and MTP draft execution.

The target GLM path already allocated score buffers for B12X DCP top-k, but the MTP draft layer only allocated indices. With B12X sparse indexer global-topk enabled, the draft capture either failed or fell back to non-comparable slow paths. Allocate and pass top-k score buffers for MTP when DCP and B12X sparse indexer are active.

Also keep empty DCP prefill chunks participating in the global-topk merge and prewarm the actual B12X merge/extend paths so rank-sensitive graph warmup enters the same collectives on every rank.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds DCP warmup synchronization and prewarm paths, a local-to-global top-k conversion path, B12X prefill/decode routing changes based on dcp_global_topk, topk_scores_buffer wiring in DeepSeek MTP, and empty DCP chunk preservation in the indexer.

Changes

B12X DCP Top-K Routing, Warmup, and Buffer Wiring

Layer / File(s) Summary
DCP warmup sync and extend-kernel prewarm
vllm/model_executor/layers/sparse_attn_indexer.py, vllm/v1/attention/backends/mla/b12x_mla_sparse.py
Adds _sync_dcp_warmup() in both files. Reworks _prewarm_b12x_dcp_topk_merge() to run _merge_b12x_dcp_topk() over candidate row sizes and synchronize after each run. Adds _EXTEND_PREWARM_DONE and _prewarm_extend_kernels_once() in the MLA backend, called during init before supports_quant_query_input.
Local-to-global DCP top-k conversion and routing
vllm/model_executor/layers/sparse_attn_indexer.py
Adds _convert_b12x_dcp_local_topk_to_global() and updates B12X prefill/decode post-processing to choose between _merge_b12x_dcp_topk() and the new local-to-global conversion based on dcp_global_topk.
topk_scores_buffer wiring and empty DCP chunk preservation
vllm/v1/attention/backends/mla/indexer.py, vllm/model_executor/layers/sparse_attn_indexer.py, vllm/model_executor/models/deepseek_mtp.py
Changes total_seq_lens == 0 handling to preserve empty DCP chunks when sparse indexing and global top-k are enabled. Updates the zero-length prefill branch to split B12X and non-B12X handling. Allocates and passes topk_scores_buffer through DeepSeek MTP when decode-context parallelism and B12X sparse indexing are enabled.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • local-inference-lab/vllm#31: Directly overlaps with the same B12X/DCP top-k routing, warmup, empty-chunk handling, and buffer wiring changes across the same files.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main fix to the B12X DCP global-topk MTP path.
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.
✨ 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/eldritch-dcp-globaltopk-mtp-20260623

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.

@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: 3

🤖 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 `@vllm/model_executor/layers/sparse_attn_indexer.py`:
- Around line 430-448: The _sync_dcp_warmup function currently catches all
exceptions and silently returns, which masks barrier failures and prevents
proper error surfacing. Replace the broad except Exception clause with a more
specific exception handler that only catches the expected uninitialized DCP
group case (when get_dcp_group() is unavailable or raises an initialization
error), and allow barrier() failures and other runtime exceptions to propagate
up so they surface as real errors instead of being silently ignored.

In `@vllm/v1/attention/backends/mla/b12x_mla_sparse.py`:
- Around line 699-714: The memoization key in the _prewarm_extend_kernels_once
method is being added to _EXTEND_PREWARM_DONE before any kernel warmup succeeds,
and the key tuple does not include the max_batched parameter even though this
parameter controls the largest warmed row shape. Include max_batched as an
additional element in the key tuple construction alongside the other parameters
like q_head_dim, kv_lora_rank, and topk_tokens, and move the
_EXTEND_PREWARM_DONE.add(key) statement to execute only after the kernel warmup
has completed successfully to prevent skipping required prewarm work for failed
attempts or larger scheduler batches.
- Around line 683-697: The current exception handling in the _sync_dcp_warmup
method catches all exceptions including failures from the
get_dcp_group().barrier() call, which hides critical synchronization failures
when dcp_world_size > 1. Restructure the error handling to only catch exceptions
from the import statement itself (the get_dcp_group import), but allow any
exceptions raised by the barrier() call to propagate so that rank-consistency
contract failures are not silently swallowed. This ensures that synchronization
failures are properly surfaced rather than hidden.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3670bc94-24c2-4aa9-9c9e-36e3b023ea0a

📥 Commits

Reviewing files that changed from the base of the PR and between 2d040b9 and dcad5d0.

📒 Files selected for processing (4)
  • vllm/model_executor/layers/sparse_attn_indexer.py
  • vllm/model_executor/models/deepseek_mtp.py
  • vllm/v1/attention/backends/mla/b12x_mla_sparse.py
  • vllm/v1/attention/backends/mla/indexer.py

Comment thread vllm/model_executor/layers/sparse_attn_indexer.py
Comment thread vllm/v1/attention/backends/mla/b12x_mla_sparse.py
Comment thread vllm/v1/attention/backends/mla/b12x_mla_sparse.py
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 2 file(s) based on 3 unresolved review comments.

Files modified:

  • vllm/model_executor/layers/sparse_attn_indexer.py
  • vllm/v1/attention/backends/mla/b12x_mla_sparse.py

Commit: 3e424016dd6c41063642f822db7cc4be2b5c5bc2

The changes have been pushed to the codex/eldritch-dcp-globaltopk-mtp-20260623 branch.

Time taken: 2m 19s

Fixed 2 file(s) based on 3 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@lukealonso
lukealonso merged commit ae300a9 into dev/eldritch-enlightenment Jun 28, 2026
1 of 3 checks passed
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