Skip to content

fix(model): align GLM5 mHC pipeline proxy contract - #37375

Closed
ActiveSky wants to merge 1 commit into
sgl-project:xinyuan/glm-5.3-flash-supportfrom
ActiveSky:codex/fix-glm5-pp-residual
Closed

ActiveSky wants to merge 1 commit into
sgl-project:xinyuan/glm-5.3-flash-supportfrom
ActiveSky:codex/fix-glm5-pp-residual

Conversation

@ActiveSky

@ActiveSky ActiveSky commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix the GLM-5.3-Flash mHC pipeline-parallel proxy contract so the mHC path forwards only hidden_states.
  • Preserve the existing residual forwarding behavior for the non-mHC path.
  • Add regression coverage for both mHC and non-mHC pipeline-parallel proxy paths.

Fixes #36906

Relationship to existing work

Testing

  • Focused GLM-5 regression tests: 7 passed.
  • pre-commit: passed.
  • compileall: passed.
  • git diff --check: passed.
  • No GPU end-to-end or model evaluation was run in this environment.

AI assistance

AI assistance was used during implementation and validation. The human submitter should review every changed line and verify the behavior before merging.


CI States

Latest PR Test (Base): ❌ Run #33482846710
Latest PR Test (Extra): ❌ Run #33482846546
Latest PR Test (AMD ROCm 7.2): ❌ Run #33482846626

Use the flattened hidden state as the pipeline-parallel handoff for mHC
GLM5 stages, which do not allocate a separate residual buffer. Preserve the
existing residual handoff for non-mHC configurations.

Fixes sgl-project#36906

Co-authored-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: jikuixie <jikuixie@gmail.com>
@Thireus

Thireus commented Sep 6, 2026

Copy link
Copy Markdown

@Fridge003 - why has this been closed? Is the code somewhere else? Thanks

Thireus added a commit to Thireus/sglang that referenced this pull request Sep 6, 2026
Any --pp-size > 1 worker dies at the first forward with KeyError: 'residual' on every non-first pipeline stage. Glm5NextModel.forward reads pp_proxy_tensors["residual"] unconditionally (glm5_next.py:1094) and returns both keys at :1183.

mHC folds the residual into the widened hidden state, so the previous stage never sends one. configs/model_config.py sets hc_mult = 4 and mhc = true for this checkpoint, so hc_hidden_size is 16384 rather than None; runner_utils/buffers.py and runner/base_runner.py both test is_mhc = hc_hidden_size is not None, allocate only hidden_states at the widened size, and guard the residual buffer behind `if not is_mhc:`. The reference mHC model deepseek_v4.py:3188 returns only {"hidden_states": hidden_states.flatten(1)}, so glm5_next is the odd one out.

Read the proxy with .tensors.get("residual") so an absent key means None, and send the key on only when it exists, because a None cannot travel over PP IPC.

Verified on 3 x RTX PRO 6000 Blackwell serving a GLM-5.3-Flash NVFP4 build as pp=3 x tp=1: without it there is no launchable three-GPU shape at all, since tp=3 is impossible at 64 heads and tp2 x pp2 inherits the same defect; with it the worker starts and the log carries no residual KeyError.

sgl-project#37375 proposed the same fix first, on 2026-09-01. It was stacked on xinyuan/glm-5.3-flash-support and GitHub auto-closed it unmerged on 2026-09-06 when that branch merged as sgl-project#36507. The bug survived the merge: main still reads the key unconditionally at models/glm5_next.py:983. Credit for the diagnosis belongs to that author.
@ActiveSky

Copy link
Copy Markdown
Contributor Author

Hi @Fridge003, thanks for reviewing #36507. We noticed that #37375 was closed at the same time that its base branch xinyuan/glm-5.3-flash-support was deleted after #36507 was merged.

Could you please clarify whether #37375 was closed because its model-side pipeline-parallel proxy fix is already included elsewhere, or because dependent PRs should be recreated against main? The change addresses #36906 and is separate from the other GLM-5.3-Flash hardware/backend reports.

If the fix is still needed, we would be happy to rebase or adjust it and submit a new PR against main, following whatever scope or merge order the maintainers prefer. Thank you!

Thireus added a commit to Thireus/sglang that referenced this pull request Sep 8, 2026
Any --pp-size > 1 worker dies at the first forward with KeyError: 'residual' on every non-first pipeline stage. Glm5NextModel.forward reads pp_proxy_tensors["residual"] unconditionally (glm5_next.py:1094) and returns both keys at :1183.

mHC folds the residual into the widened hidden state, so the previous stage never sends one. configs/model_config.py sets hc_mult = 4 and mhc = true for this checkpoint, so hc_hidden_size is 16384 rather than None; runner_utils/buffers.py and runner/base_runner.py both test is_mhc = hc_hidden_size is not None, allocate only hidden_states at the widened size, and guard the residual buffer behind `if not is_mhc:`. The reference mHC model deepseek_v4.py:3188 returns only {"hidden_states": hidden_states.flatten(1)}, so glm5_next is the odd one out.

Read the proxy with .tensors.get("residual") so an absent key means None, and send the key on only when it exists, because a None cannot travel over PP IPC.

Verified on 3 x RTX PRO 6000 Blackwell serving a GLM-5.3-Flash NVFP4 build as pp=3 x tp=1: without it there is no launchable three-GPU shape at all, since tp=3 is impossible at 64 heads and tp2 x pp2 inherits the same defect; with it the worker starts and the log carries no residual KeyError.

sgl-project#37375 proposed the same fix first, on 2026-09-01. It was stacked on xinyuan/glm-5.3-flash-support and GitHub auto-closed it unmerged on 2026-09-06 when that branch merged as sgl-project#36507. The bug survived the merge: main still reads the key unconditionally at models/glm5_next.py:983. Credit for the diagnosis belongs to that author.
yilin-void added a commit to yilin-void/sglang that referenced this pull request Sep 14, 2026
mHC folds residual state into the widened hidden state, so pipeline stages may receive and forward PP proxy tensors without a residual entry. Treat a missing residual as None and omit it from outgoing proxies unless it exists.

Add a CPU-only contract regression test for both missing and present residual paths.

Rebased from sgl-project#38367 (d36b37c), with credit to sgl-project#37375 for the original fix.
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.

3 participants