Skip to content

[Fix] Load HunyuanV3 NextN final_layernorm into the draft head's output norm - #30331

Merged
BBuf merged 1 commit into
sgl-project:mainfrom
auroter:fix/hyv3-nextn-final-layernorm
Jul 13, 2026
Merged

BBuf merged 1 commit into
sgl-project:mainfrom
auroter:fix/hyv3-nextn-final-layernorm

Conversation

@auroter

@auroter auroter commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On released tencent/Hy3 checkpoints, MTP speculative decoding is slower than plain decode. Root cause: the checkpoint stores the draft layer's output norm as model.layers.80.final_layernorm.weight, but HYV3ForCausalLMNextN.load_weights remaps every non-spec key under the NextN prefix to model.decoder.<subname>. model.decoder.final_layernorm.weight exists on no module, so the key is silently dropped by the name not in params_dict guard — and shared_head.norm, the RMSNorm applied immediately before the draft lm_head, only loads from a literal model.shared_head.norm.weight key that the released checkpoint does not contain. The draft head therefore runs a default-initialized output norm. The real tensor is materially non-identity (mean 1.16, range 0.81–1.23), so every draft logit is skewed and acceptance collapses.

Modifications

  • One elif in the NextN key remap routes final_layernorm.* to model.shared_head.norm.weight. The existing bare-key branch is kept for preview-era checkpoints.
  • New unit test test/registered/unit/models/test_hunyuan_v3_nextn_weight_loading.py (CPU-only, mirrors the Nemotron-H exemplar) asserting the four mapping classes: final_layernorm → shared_head.norm, spec weights → model.*, decoder-layer keys → model.decoder.*, embed/lm_head skipped. The regression test fails against the unfixed source.

Accuracy Tests

Output distribution is unchanged by construction — the fix touches only the draft model, and speculative verification is lossless. Unit tests: 4/4 pass.

Speed Tests and Profiling

tencent/Hy3-FP8, TP4 on 4× RTX PRO 6000 Blackwell (SM120), SGLang 0.5.14, fp8 KV.

Configuration accept decode tok/s (bs=1)
Plain decode (no speculation) — 81–86
MTP before fix (EAGLE 2-1-3) rate 0.575 54–56 (slower than plain)
MTP after fix (EAGLE 3-1-4) length 2.3–2.6 87–89 (332 tok/s aggregate @ 8 streams)

The dropped-tensor mechanism is configuration-independent.

Checklist

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ⏳ Run #29249862209
Latest PR Test (Extra): ⏳ Run #29249862255

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@BBuf

BBuf commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@BBuf
BBuf requested a review from JustinTong0323 July 13, 2026 07:54
… norm

The released tencent/Hy3 checkpoint stores the MTP draft layer's output
norm as model.layers.<num_hidden_layers>.final_layernorm.weight. The
nextn key remap sent it to model.decoder.final_layernorm.weight, which
does not exist in params_dict, so it was silently dropped and
model.shared_head.norm ran with default-initialized weights.

Map final_layernorm under the nextn prefix to
model.shared_head.norm.weight, keeping the existing literal
model.shared_head.norm.weight branch for preview-era checkpoints.

Co-Authored-By: Claude Fable 5 <[email protected]>
@BBuf
BBuf force-pushed the fix/hyv3-nextn-final-layernorm branch from 42e4268 to d37c0bb Compare July 13, 2026 12:26
@BBuf
BBuf merged commit 9fec359 into sgl-project:main Jul 13, 2026
62 of 94 checks passed
dougyster added a commit to dougyster/sglang that referenced this pull request Jul 17, 2026
…ped in v0.5.15

Ancestry-checked each rolling-:dev model against v0.5.15.post1. Support that
landed in the release moves to the stable tag:
- Baidu Unlimited-OCR (sgl-project#29186), LFM2.5 (sgl-project#29659) -> :latest
- MiniCPM-V-4.6 (sgl-project#24855): :dev -> :latest, :dev-cu12 -> :latest-cu129

Kept on :dev (support NOT in the release cut):
- LongCat-2.0 (FP8 support sgl-project#30275 not in v0.5.15.post1)
- Hy3 (HunyuanV3 NextN/MTP fix sgl-project#30331 not in release; MTP is a headline feature)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants