Skip to content

[Fix] Fix Qwen3.5 MTP startup with HiCache - #34560

Merged
YAMY1234 merged 8 commits into
sgl-project:mainfrom
DarkraiHL:fix/qwen35-hicache-mtp-draft-depth
Aug 14, 2026
Merged

[Fix] Fix Qwen3.5 MTP startup with HiCache#34560
YAMY1234 merged 8 commits into
sgl-project:mainfrom
DarkraiHL:fix/qwen35-hicache-mtp-draft-depth

Conversation

@DarkraiHL

@DarkraiHL DarkraiHL commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

Qwen3.5 conditional-generation checkpoints store language-model attributes in
the nested text_config. During MTP draft remapping, SGLang sets
num_nextn_predict_layers = 1 only on the parent Hugging Face config. However,
ModelConfig.num_nextn_predict_layers is derived from hf_text_config, so the
draft depth remains None.

With NEXTN and HiCache enabled, the draft cache is therefore classified as a
sidecar instead of a packed MTP cache, and scheduler initialization fails with:

File "sglang/srt/mem_cache/hybrid_cache/hybrid_pool_assembler.py", line 936, in build_full_draft_pools
  if pool.layer_num == 0:
AttributeError: 'HybridLinearKVPool' object has no attribute 'layer_num'

This regression was exposed by
#30393, which introduced
packed-versus-sidecar HiCache draft routing. The original Qwen3.5 support in
#18489 normalized the MTP
depth only on the parent config. This PR completes that normalization without
changing the HiCache routing behavior.

Minimal reproduction

Tested with Qwen/Qwen3.5-397B-A17B-FP8, TP=8, on one node with 8 NVIDIA H20
96 GB GPUs (Python 3.12.3, PyTorch 2.13.0+cu130, CUDA 13.0,
sglang-kernel 0.4.6.post1+cu130):

python3 -m sglang.launch_server \
  --model-path Qwen/Qwen3.5-397B-A17B-FP8 \
  --trust-remote-code \
  --tp-size 8 \
  --mem-fraction-static 0.8 \
  --speculative-algo NEXTN \
  --enable-hierarchical-cache \
  --hicache-size 8

No L3 storage backend (including Mooncake) or custom HiCache I/O option is
required to reproduce the failure.

Modifications

  • Synchronize the normalized Qwen3.5 MTP draft depth to hf_text_config.
  • Add a focused regression test for Qwen3.5 MoE draft remapping.
 self.hf_config.num_nextn_predict_layers = 1
+self.hf_text_config.num_nextn_predict_layers = 1

Accuracy Tests

  • Focused unit tests: 4 tests and 4 subtests passed.
  • Minimal 8-H20 startup A/B with the same model and launch command:
    • Unpatched: target and MTP weights load, then scheduler initialization fails
      with the exception above; the server never becomes healthy.
    • Patched: /health returns HTTP 200, all 8 TP schedulers remain alive, and a
      completion request succeeds.
  • Mooncake smoke test on the patched source: 3/3 usage, 4/4 text, and 4/4
    uncached multimodal requests returned HTTP 200.
  • Independent AMD MI355X/ROCm reproduction: #34611
    reports the same stack trace, and
    SemiAnalysisAI/InferenceX#2582
    applies this exact fix to its Qwen3.5 NEXTN + HiCache benchmark.

Speed Tests and Profiling

Not applicable. This change only synchronizes a configuration attribute during
startup and does not modify the inference hot path.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci.
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #31775596976
Latest PR Test (Extra): ✅ Run #31775596847

@1e4ves

1e4ves commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

thanks!But sidecar should not fail as a fallback path, so there are also bugs here. let me fix it.

@DarkraiHL

Copy link
Copy Markdown
Contributor Author

@hnyls2002 Could you take a look when convenient? This is a small, focused fix for the Qwen3.5 NEXTN + HiCache startup failure, with a regression test. Thanks!

functionstackx added a commit to SemiAnalysisAI/InferenceX that referenced this pull request Aug 12, 2026
Comment out the merged resident arms and the remaining HiCache concurrency
points, leaving TP4/EP1 conc 16 with kv-offloading dram + hicache. This proves
whether the sgl-project/sglang#34560 container patch clears the
HybridLinearKVPool draft-sidecar crash on gfx950 without spending MI355X node
time on already-measured resident points.

注释掉已合入的常驻分支与其余 HiCache 并发点,仅保留 TP4/EP1 并发 16 的
kv-offloading dram + hicache 配置,用于验证 sgl-project/sglang#34560 容器补丁
能否在 gfx950 上消除 HybridLinearKVPool draft sidecar 崩溃,同时避免在已测的
常驻点上占用 MI355X 节点时间。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@huangtingwei9988 huangtingwei9988 self-assigned this Aug 13, 2026
@huangtingwei9988

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

Unwrap HybridLinearKVPool before building a draft sidecar and exercise Qwen3.5 NEXTN in the HiCache E2E test.

Co-authored-by: hjzhang <76768149+1e4ves@users.noreply.github.com>
@DarkraiHL
DarkraiHL force-pushed the fix/qwen35-hicache-mtp-draft-depth branch from 1292f82 to ca20e1f Compare August 13, 2026 11:43
@DarkraiHL

Copy link
Copy Markdown
Contributor Author

@1e4ves Thanks for catching the fallback-path issue. I’ve incorporated your HybridLinearKVPool unwrapping fix, added focused regression coverage.

@YAMY1234

Copy link
Copy Markdown
Collaborator

/rerun-failed-ci

@YAMY1234
YAMY1234 enabled auto-merge (squash) August 14, 2026 02:01
@huangtingwei9988
huangtingwei9988 enabled auto-merge (squash) August 14, 2026 02:09
@YAMY1234 YAMY1234 self-assigned this Aug 14, 2026
@YAMY1234
YAMY1234 merged commit 41cd5a7 into sgl-project:main Aug 14, 2026
254 of 266 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
Co-authored-by: hjzhang <76768149+1e4ves@users.noreply.github.com>
Co-authored-by: YAMY <74099316+YAMY1234@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants