Skip to content

fix(glm5_next cuda): both ranks stop a reply when its caller asks - #320

Closed
pulseandthread wants to merge 1 commit into
ashhart:mainfrom
pulseandthread:glm-stop-vote
Closed

pulseandthread wants to merge 1 commit into
ashhart:mainfrom
pulseandthread:glm-stop-vote

Conversation

@pulseandthread

Copy link
Copy Markdown

GLM-5.3-Flash on two GPUs: both ranks stop a reply when its caller asks

Split out of #194 at review's request, so that PR is only the image input. This is the GLM twin of #231 (Flash Next), which ports the same vote.

The bug

Rank 1 cannot see the client, so the two-rank GLM engine decoded every reply to max_tokens after its caller asked to stop (client gone, stop string, thinking-budget cut), sending nothing. From outside this looks like a hang: requests_running: 1, completion_tokens_total frozen, GPUs at their decode power, no error on either rank, later requests queued. 0.6.0's decode loops are the same, so a text reply whose client left did this too; it surfaced with images because an image prompt never resumes, and a long conversation plus a camera photo is the 12k-token fresh prefill a person gives up on and resends.

The fix

StopVote all-gathers rank 0's "stop" (one int, sticky) after every round through the engine's existing comm.all_gather, and the decode loops end on it, so both ranks stop after the same round. Rank 1's follower passes a vote that never asks. One GPU is unchanged. #219 keeps comm.all_gather, so either merge order works.

Tested

Two DGX Sparks (GB10), EXL3 checkpoint, --tp 2, --drafter none:

Tests: tests/test_glm_stop_vote.py (both ranks stop after the round rank 0 asks, and a vote stays asked) and tests/cuda/test_glm_stop.py (drafted, at the default and a fixed MTP depth, and serial replies stop after the asked round, greedy and sampled, and the next request equals a fresh one). The GLM engine tests pass on both GB10s.

Only rank 0 sees the client, so the two-rank engine ignored on_tokens' True (the client left, a stop string
matched, a gate cut the reply) and decoded on to max_tokens on both ranks, sending nothing. From outside it looked
like a hang: requests_running 1, completion_tokens_total frozen, no error on either rank, later requests queued.
On two DGX Sparks a left 8,192-token reply held the pair for 343 s.

- StopVote all-gathers rank 0's stop (one int, sticky) after each round; both ranks end after the same round
- serial, MTP, DFlash2 and auto decoding break on True after the round's bookkeeping
- a client gone during prefill skips decoding

With it the pair is free within a second of the client leaving, for a text reply and a 7k-token image prompt, and
the next requests reply correctly. Decode on a 384-token reply: 23.1-25.3 tok/s, 24.3-25.4 on 0.6.0. Text
replies byte-identical to 0.6.0 for six prompts of 13 to 3,332 tokens, thinking on and off.

Tests: tests/test_glm_stop_vote.py (two ranks in lockstep stop after the round rank 0 asks);
tests/cuda/test_glm_stop.py (drafted and serial replies stop after the asked round, greedy and sampled; the next
request equals a fresh one).

(cherry picked from commit afb0835)
@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @pulseandthread. Splitting this out of #194 helped, and a pair busy for 343 s after its client left, against free within a second with the vote, shows why it matters.

The Python engine is frozen (#286) and GLM isn't on the Zig engine yet, so this PR won't merge, but the bug has no Zig counterpart to fix. The Zig engine's cluster is leader-driven. Rank 0 plans every round and broadcasts it, and followers only apply what it sends, with no decode loop of their own. When a client leaves, rank 0 cancels the reply, which drops out of the next round on every rank, and one release frees its slot everywhere. #231 and #301 found the same bug on other paths, and they close the same way.

@ashhart ashhart closed this Oct 6, 2026
grearjake-star added a commit to grearjake-star/TensorFold that referenced this pull request Oct 8, 2026
The GLM serial, MTP and DFlash2 decode loops (and auto_decode) called on_tokens but never read its
result, and rank 1 followed with a callback that could not stop. So when a client left, a stop string
matched or a grammar cut the reply, both ranks decoded on to max_tokens and every later request
waited behind it (a 343 s busy pair in the report). A sticky stop vote (stop.StopVote) now rides one
extra word on the round's existing sample all-gather, so both ranks end after the same round with no
added exchange. Replies up to the stop are unchanged.

Upstream: ashhart#301 (the same bug as ashhart#320 and ashhart#194, found on the GLM-5.3-Flash DGX Spark
recipe), closed unmerged with the Python engine frozen. Host tests in tests/test_glm_serial_stop.py;
the CUDA test needs a GLM checkpoint on two ranks, which this fork's gate does not run.

Co-authored-by: MiaAI-Lab <[email protected]>
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