Skip to content

glm5_next: do not require a residual in the PP proxy tensors - #5

Closed
Thireus wants to merge 1 commit into
mainfrom
fix/glm5-next-pp-residual
Closed

Thireus wants to merge 1 commit into
mainfrom
fix/glm5-next-pp-residual

Conversation

@Thireus

@Thireus Thireus commented Sep 8, 2026

Copy link
Copy Markdown
Owner

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.


CI States

Latest PR Test (Base): ❌ Run #34175714435
Latest PR Test (Extra): ❌ Run #34175714299
Latest PR Test (AMD ROCm 7.2): ❌ Run #34175714453

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.
@Thireus

Thireus commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #11, rebuilt on the current main.

@Thireus Thireus closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant