Skip to content

[Fix] deepseek_v4: Fix mHC prewarm when chunked prefill is disabled - #43448

Merged
Qiaolin-Yu merged 5 commits into
sgl-project:mainfrom
maocheng23:fix/dsv4-mhc-prewarm-chunked-prefill-disabled
Oct 21, 2026
Merged

Qiaolin-Yu merged 5 commits into
sgl-project:mainfrom
maocheng23:fix/dsv4-mhc-prewarm-chunked-prefill-disabled

Conversation

@maocheng23

@maocheng23 maocheng23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

prewarm_mhc_pre sizes its token buckets from chunked_prefill_size. With --chunked-prefill-size -1 (chunked prefill disabled) that produces a single bucket of -1 tokens, so residual.new_zeros(-1, ...) raises while weights load. DeepSeek V4 cannot start with chunked prefill disabled.

Servers that capture prefill hidden states turn chunked prefill off, so a request's states arrive in one forward. They hit this on DeepSeek V4.

Modifications

When chunked prefill is disabled or unset, size the prewarm buckets from max_prefill_tokens, which bounds a prefill batch in that case. This is the same rule pre_capture_activation_reserve_mb uses.

Accuracy Tests

Not applicable: startup-only change. No kernel or forward code changed.

Speed Tests and Profiling

Not applicable: startup-only change.

Tests

No unit test: removed per review. The fallback cases (-1 / 0 / None chunked prefill) were exercised by a since-removed CPU test that failed without the fix and passed with it.

Checklist

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #39315285282
Latest PR Test (Extra): ❌ Run #39315285323
Latest PR Test (AMD ROCm 10): ❌ Run #39315285257

`prewarm_mhc_pre` sized its token buckets from `chunked_prefill_size`.
With `--chunked-prefill-size -1` that produced a single bucket of -1
tokens and `residual.new_zeros(-1, ...)` raised during weight loading, so
DeepSeek V4 could not start with chunked prefill disabled.

Fall back to `max_prefill_tokens`, the bound on a prefill batch when
prefill is not chunked (same rule as the pre-capture activation reserve).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Oasis-Git Oasis-Git left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We do not need the new added ut test. pls remove it. Also pls trim the comments

@maocheng23

Copy link
Copy Markdown
Collaborator Author

Comment addressed

@bvolpato bvolpato mentioned this pull request Oct 13, 2026
4 of 5 tasks
@Oasis-Git Oasis-Git added the run-ci CI: run the baseline test suite on this PR label Oct 14, 2026
@github-actions

This comment has been minimized.

@maocheng23 maocheng23 changed the title [Bugfix] DeepSeek V4: fix mHC prewarm when chunked prefill is disabled [Fix] deepseek_v4: Fix mHC prewarm when chunked prefill is disabled Oct 19, 2026
@Qiaolin-Yu
Qiaolin-Yu merged commit 4b9936b into sgl-project:main Oct 21, 2026
337 of 358 checks passed
bvolpato added a commit to bvolpato/sglang that referenced this pull request Nov 1, 2026
The load hook returned early when chunked prefill was disabled. Since sgl-project#43448, prewarm_mhc_pre uses --max-prefill-tokens as the limit in that case, so the check only removed coverage. With --chunked-prefill-size -1, the first eager prefills then compiled the kernels on the serving path.

Remove the check, its comment, and the get_schedule import. On a cold B200 cache the hook now warms all buckets at load, and later hc_attn_pre calls up to 16384 tokens compile nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants