From 4b9936b5e35f2f6ff03afe4f50f8fd2471e3f276 Mon Sep 17 00:00:00 2001 From: maocheng23 <35615230+maocheng23@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:21:31 -0700 Subject: [PATCH] [Fix] deepseek_v4: Fix mHC prewarm when chunked prefill is disabled (#43448) --- python/sglang/kernels/ops/layernorm/mhc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/sglang/kernels/ops/layernorm/mhc.py b/python/sglang/kernels/ops/layernorm/mhc.py index d65725f165..d7f69f4068 100644 --- a/python/sglang/kernels/ops/layernorm/mhc.py +++ b/python/sglang/kernels/ops/layernorm/mhc.py @@ -858,7 +858,11 @@ def prewarm_mhc_pre( from sglang.srt.runtime_context import get_schedule hc_mult, hidden_size = residual.shape[-2], residual.shape[-1] - max_num_tokens = get_schedule().chunked_prefill_size + schedule = get_schedule() + max_num_tokens = schedule.chunked_prefill_size + if max_num_tokens is None or max_num_tokens <= 0: + # Chunked prefill disabled: bound by the prefill token budget. + max_num_tokens = schedule.max_prefill_tokens buckets = get_mhc_pre_token_count_representatives( max_num_tokens, hc_mult * hidden_size )