Skip to content

fix(image): patch sglang for GLM-5.2 MTP nextn quark-exclude (backport #30265) - #32

Merged
jiejingzhangamd merged 1 commit into
mainfrom
feat/sglang-glm-nextn-patch
Jul 28, 2026
Merged

jiejingzhangamd merged 1 commit into
mainfrom
feat/sglang-glm-nextn-patch

Conversation

@jiejingzhangamd

Copy link
Copy Markdown
Collaborator

Problem

GLM-5.2 EAGLE/MTP crashes at draft weight-load on our sglang v0.5.15.post1 base:

AssertionError: param.shape=[6144,6144] uint8 vs loaded_weight.shape=[6144,12288] bf16
  at linear.py weight_loader (via models/deepseek_nextn.py)

GLM-5.2's MTP layer (index = num_hidden_layers) is entirely bf16/unquantized — the quark quantization_config lists model.layers.<N>.eh_proj (and the layer's other submodules) in exclude. sglang's DeepseekV3ForCausalLMNextN disables nextn quant only when the bare layer prefix model.layers.<N> is in exclude_layers, but the exclude entries are submodule-level (...<N>.eh_proj), so should_ignore_layer() returns False, eh_proj is built as an MXFP4 (uint8) param, and the bf16 checkpoint weight won't load.

Fix

Upstream fixed this in sgl-project/sglang#30265 (merged 2026-07-08, a dedicated GlmMoeDsaForCausalLMNextN class), but our pinned base v0.5.15.post1 predates it. This adds a temporary, self-locating, idempotent Python patch that probes the eh_proj submodule (an exact exclude entry) instead of the bare layer → nextn_quant_config=None → the whole bf16 MTP layer builds bf16.

  • deploy/docker/patches/sglang/patch_glm52_nextn_quark_exclude.py — the patch (no-op if the anchor is absent, i.e. once sglang carries #30265).
  • Dockerfile.sglang — a patch loop after pip install (mirrors the vLLM patch loop).

Verification

Coherent GLM-5.2 MTP output on the v0.5.15.post1 base (single-stream accept len ~1.85–2.6, ~1.3–2× decode speedup), and the fix holds across single-node + 1P1D PD.

Removal

Temporary — drop deploy/docker/patches/sglang/ and the loop when we bump the base sglang to a build that includes #30265 (the patch already no-ops then). Tracking the broader GLM-5.x ROCm EAGLE enablement upstream in #32175 (still open).

🤖 Generated with Claude Code

…t #30265)

The sglang v0.5.15.post1 base predates sgl-project/sglang#30265, so GLM-5.2
EAGLE/MTP crashes at draft weight-load: the MTP layer (index=num_hidden_layers)
is entirely bf16, and its eh_proj is listed in the quark `exclude`, but sglang's
DeepseekV3ForCausalLMNextN checks the BARE layer prefix `model.layers.<N>` (not
the submodule-level `...<N>.eh_proj` exclude entry), so should_ignore_layer()
returns False, eh_proj is built as an MXFP4 uint8 param, and load asserts
(param [6144,6144] uint8 vs bf16 [6144,12288]).

Add a self-locating, idempotent Python patch (deploy/docker/patches/sglang/) that
probes the eh_proj submodule instead of the bare layer -> nextn_quant_config=None
-> whole bf16 MTP layer. Wire a patch loop into Dockerfile.sglang (mirrors the
vLLM one). Verified: coherent GLM-5.2 MTP output on the v0.5.15.post1 base.

Temporary: no-ops once the base sglang carries #30265 (merged upstream 2026-07-08);
drop deploy/docker/patches/sglang/ + the loop when we bump the base sglang.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pw7JSvdQb796xh5pEcctLz
Signed-off-by: Zhang, Jiejing <jiejing.zhang@amd.com>
@jiejingzhangamd
jiejingzhangamd force-pushed the feat/sglang-glm-nextn-patch branch from b9b838b to 0d8d0ff Compare July 28, 2026 03:36
@jiejingzhangamd
jiejingzhangamd merged commit fd2202d into main Jul 28, 2026
16 of 20 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.

1 participant