Repository navigation
Conversation
The GLM decode loops (serial, MTP, DFlash2, auto) call on_tokens but never read its result, and rank 1 runs with a no-op callback, so rank 1 cannot know that rank 0 wants to stop. After a client left, a stop string matched or a grammar cut, both ranks decoded on to max_tokens or an end token, and every later request waited behind it. stop.StopVote wraps on_tokens. Rank 0's wish to stop rides as one extra float32 word on the next verify sample's all-gather (the exchange each round already makes; the nucleus rule's first gather likewise) and is removed before sampling, so every rank ends the run after the same round. Sampled tokens are unchanged; only when a stopped run ends changes. Every rank adds the word to the same gathers, so gather sizes stay equal across ranks. GlmEngine._run_once sets the vote on every rank after prefill, _run clears it, and the stats of a stopped run say "stopped". One rank stops the same way. Tests: tests/test_glm_serial_stop.py (two CPU ranks as threads over a real all-gather: every loop and sampling rule, replies unchanged, equal gather sizes; GlmEngine._run on two ranks) and a GPU case in tests/cuda/test_glm_engine.py.
|
@ashhart @pulseandthread: #320 and this PR fix the same bug. GLM's two-rank decode loops never read
Either is fine with us. If you prefer #320, I'll close this one. If you take this one, please credit @pulseandthread as well, who found and fixed the same bug in #194 and #320. The GLM recipe ships this version as patch 0070 (v1.5). |
|
Still needed on 0.6.5: in Related#320 (@pulseandthread) fixes the same bug with a one-int all-gather of its own each round, and #231 (@plotarmordev) ReceiptRerun on TensorFold 0.6.5. The commit applies to Environment. TensorFold 0.6.5 ( What it fixes, on the two Sparks (two runs each, both nearly identical):
On 0.6.5 the stopped reply's text was complete after 96 tokens, but the response came only after both ranks had Exactness (
Decode (
The vote is one float32 word more on a gather each round already makes; the medians are within 0.4% of 0.6.5's Prompt speed (
Tests.
Not run. Metal: this is the CUDA GLM family only, and nothing outside |
|
Thank you, @MiaAI-Lab. The Python engine is frozen (#286) and GLM isn't on the Zig engine yet, so this won't land as written, 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 the follower loop in Thanks for chasing the recipe report down to the callback result nobody read, and for testing it on two ranks over a real all-gather. |
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]>
What this changes
A stopped GLM-5.3-Flash request on CUDA now ends on every rank within a round. Today it keeps both ranks decoding to
max_tokens(or an end token), and every later request waits behind it.This was found through a user report on the GLM-5.3-Flash DGX Spark recipe (issue 38 on MiaAI-Lab/GLM-5.3-Flash-EXL3-2x-DGX-Sparks-TensorFold): a client that left a long streamed request kept the server busy until the reply would have reached
max_tokens.The bug
families/glm5_next/cuda/decode.py, the serial, MTP and DFlash2 loops (andauto_decodeindrafter_choice.py) callon_tokens(...)but never read its result.GlmEngine.followruns rank 1 withlambda new: None, so rank 1 has no way to learn that rank 0 wants to stop.on_tokensreturnsTrue, but neither rank stops. Both decode to the end.The fix
stop.StopVote(a new module of about 50 lines) wrapson_tokens:sample_rows, or the nucleus rule's first gather.draft=True, the MTP chain) and the DFlash2 drafter's own gathers are unchanged.GlmEngine._run_oncesets the vote on every rank after prefill, and_runclears it in itsfinally."stopped": true.on_tokensis unchanged apart from its comment.Why replies are unchanged
choose_rows/nucleus_rowssee them, so every sampled token is the same as before.Receipt
main(9356df5, v0.6.3). CPU tests ran in the NVIDIA PyTorch container (PyTorch 2.13.0a0 nv26.07, Python 3.12, aarch64), with no GPU used.tests/test_glm_serial_stop.pyruns two ranks as threads over a real CPU all-gather, through the real decode loops (serial_decode,mtp_decode,dflash_decode,auto_decode). It covers greedy, top-k and nucleus. Each rank holds half of a fake model's vocabulary. Checked:GlmEngine._runon two ranks: both end after the same round and both reportstopped. The vote is cleared, and the unstopped run is unchanged.--parallel 1) whose client left after 5 s freed the server in 0.12 s, and the next request started 0.26 s later. Before the change, both ranks decoded tomax_tokens.pytest tests/test_glm*.py tests/test_cuda*.py tests/test_family_streams.py tests/test_server*.py tests/test_lane_server.py tests/test_exact_sampling.py: 1,263 passed, 22 skipped and 12 failed on this branch, against 1,230 passed, 22 skipped and the same 12 failed on unmodifiedmain.mlx, which isn't in the container:test_lane_server.py(11) andtest_exact_sampling.py::test_nucleus_without_top_k_matches_the_whole_vocabulary_draw.tests/test_glm_serial_stop.pyhas 33 tests: 31 fail onmainand all 33 pass here. It imports the CUDA modules under the fake-triton fixture fromtest_cuda_geometry.py, like the other GLM CPU tests.tests/cuda/test_glm_engine.py(test_a_stop_ends_the_run_after_the_next_round: serial, MTP and auto policies; top-k, nucleus and greedy). It was run in the recipe's build, not on upstreammain, because no GPU was free for this branch.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Sampling is untouched, and the vote word is removed before it.