Skip to content

feat(glm5next): support pipeline parallelism via mHC multi-stream hand-off - #51

Merged
wtdcode merged 1 commit into
wtdcode:masterfrom
Karl0007:pr/glm-pp-mhc-handoff
Sep 1, 2026
Merged

wtdcode merged 1 commit into
wtdcode:masterfrom
Karl0007:pr/glm-pp-mhc-handoff

Conversation

@Karl0007

Copy link
Copy Markdown

Problem

GLM-5.3-Flash (Glm5Next) gates PP off: make_empty_intermediate_tensors is deliberately not implemented, and the non-last-rank branch of Glm5NextModel.forward returns [hidden_states, residual] while dropping the deferred mHC hc_post state (post/comb) — the receiving rank cannot reconstruct the multi-stream state, so a naive PP boot is numerically broken anyway.

On 4×64 GB sm_80 (PCIe, no P2P) this means GLM-5.3-Flash cannot run at all: TP4 prefill is ~6.6× slower than PP4 on this topology.

Fix — the DSV4 hc_mult hand-off pattern

  • Sending rank: materialise the last mHC layer's deferred hc_post at the boundary (exactly the post the next rank's first layer would have folded into its fused_post_pre — math unchanged, one extra post kernel per boundary). The full multi-stream state (tokens, n, hidden) crosses in a single hidden_states key.
  • Receiving rank: make_empty_intermediate_tensors allocates the (B, n, hidden) stream state; the stage's first mHC layer runs standalone hc_pre on it and re-derives residual, so no extra key is transported.
  • Both Glm5NextForCausalLM and the conditional-generation wrapper alias it; the "PP gated off" comments are replaced accordingly.

Verification (4× CMP 170HX, sm_80, 64 GB, PCIe no-P2P)

GLM-5.3-Flash AWQ W4A16, PP4 14,12,12,7 + MTP×5 (needs the draft-embedding fix from #50):

  • boots and serves; correctness battery 9/9 at temperature 0
  • single-stream decode 50–93 tok/s; KV pool 1,437,333 tokens @ max_model_len=524288
  • MTP draft acceptance 46–56% (mean length 3.3–3.8)

Without this patch the same box cannot host the model; with it, PP4 is the only viable parallelism on this hardware class.

…d-off

GLM-5.3-Flash (Glm5Next) gated PP off: no make_empty_intermediate_tensors,
and the non-last-rank branch carried [hidden_states, residual] while
dropping the deferred mHC hc_post state (post/comb), which the receiving
rank had no way to reconstruct.

This implements the boundary the way DeepSeek-V4 does it with hc_mult:
the sending rank materializes its last mHC layer's deferred hc_post (one
mhc_post kernel per boundary; the math is unchanged, since that is exactly
the post the next rank's first layer would have folded into its
fused_post_pre), so the FULL multi-stream state (tokens, n, hidden) crosses
in a single "hidden_states" key. The receiving rank's first mHC layer runs
standalone hc_pre on the materialized stream state; residual is re-derived
there, so no extra key is transported.

Verified on 4x sm80 64GB (PCIe, no P2P) with GLM-5.3-Flash AWQ W4A16:
PP4 14,12,12,7 + MTP x5 boots and serves; correctness battery 9/9 at
temperature 0; decode 50-93 tok/s single-stream; KV pool 1,437,333 tokens.
Without PP this model cannot run on 4x64GB at all (TP4 prefill is ~6.6x
slower on this PCIe topology).

Signed-off-by: kk <kk@cmp170hx>
@wtdcode
wtdcode merged commit 2dfd892 into wtdcode:master Sep 1, 2026
@Karl0007
Karl0007 deleted the pr/glm-pp-mhc-handoff branch September 12, 2026 11:03
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.

2 participants