Repository navigation
fix(flash next cuda): both ranks stop a reply when its caller asks - #231
Closed
plotarmordev wants to merge 1 commit into
Closed
plotarmordev wants to merge 1 commit into
plotarmordev wants to merge 1 commit into
Conversation
On two ranks Flash Next threw away on_tokens' True (the client left, a stop string, a gate cut the reply) and both ranks decoded on to max_tokens. On two DGX Sparks a 4,000-token reply whose client left after 3 s kept the pair busy 46 s. Only rank 0 sees the client, so rank 0 alone can't stop: rank 1 would wait in the next round's collectives. StopVote all-gathers rank 0's stop (one int, sticky) after each round, and both ranks end after the same round; rank 1's follow now passes a vote that never asks. The decode loops already break on True. The design is pulseandthread's stop vote for GLM in ashhart#194.
Closed
8 tasks done
Owner
|
Thank you, @plotarmordev. You found a real cost, a 28-token reply that took 38.7 s because both ranks decoded all 3,000 tokens after a stop string. The Zig engine stops both sides together. Its cluster is leader-driven. Followers run only what rank 0 broadcasts, and a release frees the slot on every rank. Flash Next on two Macs, the new speed-up mode, sends rank 0's stop decision, a stop string or a cancel, to rank 1 at every step, so both Macs end on the same round. That is the fix your PR makes for the Python engine's two Sparks. The Python engine is frozen (#286), so this PR closes with that. Thanks for measuring it so clearly. |
grearjake-star
added a commit
to grearjake-star/TensorFold
that referenced
this pull request
Oct 8, 2026
On two ranks Flash Next threw away on_tokens' True ("both ranks decode to the end") and rank 1 followed
with no callback, so when a client left, a stop string matched or a gate cut the reply, both ranks
decoded on to max_tokens (a 28-token reply took 38.7 s on two Sparks). A StopVote all-gathers rank
0's sticky stop, one int a round, and both ranks end after the same round; rank 1's follower passes a
vote that never asks. One GPU is unchanged: the vote is only built when tp == 2.
Upstream: ashhart#231 (GLM's stop vote from ashhart#194 ported to Flash Next), closed unmerged with
the Python engine frozen. Host tests only here; the fork's gate runs one GPU, so two-rank serving is
not exercised by it.
Co-authored-by: plotarmordev <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On two ranks, Flash Next throws away
on_tokens' True (generate:on_tokens = lambda new: (emit(new), False)[1] # both ranks decode to the end), and rank 1'sfollowdecodes with no callback. So when the client leaves, a stop string matches or a gate cuts the reply, both ranks decode on tomax_tokens. Only rank 0 sees the client, so rank 0 can't stop alone: rank 1 would wait in the next round's collectives.This is @pulseandthread's stop vote from #194 (GLM), ported to Flash Next at his suggestion.
StopVoteall-gathers rank 0's stop (one int, sticky) after each round, and both ranks end after the same round. Rank 1'sfollowpasses a vote that never asks. The decode loops already break on True. One GPU is unchanged.Two DGX Sparks, Flash Next (Vontra MLX 4-bit),
--tp 2 --context 16384, v0.6.1 against v0.6.1 + this PR, and with #218:max_tokens3,000)"draft": false),token_shaTests.
tests/test_flashnext_stop_vote.py, from #194's GLM test: two ranks in lockstep both stop after the round rank 0 asks, and a vote stays asked.tests/test_flashnext_message_points.py's follower test builds a bare engine, so it now sets the gatherfollowuses. The Flash Next and qwen4 CPU tests: 100 passed, 14 skipped, and 1 failure that v0.6.1 has too (test_flash_next_pass_rows.py::test_a_rounds_pass_keeps_decoding_its_share).Not covered.
--parallelon two ranks (#141) goes through the scheduler, not this path; I didn't change or test it. #219 keepscomm.all_gather, which is all the vote uses, so either merge order works (as @pulseandthread noted on #218).