Repository navigation
[Engine] serve: same answers with parallel > 1 as with parallel 1 - #287
Open
okada-shogo wants to merge 1 commit into
Open
okada-shogo wants to merge 1 commit into
okada-shogo wants to merge 1 commit into
Conversation
With "parallel" 2 or more, every request goes through the slot path, whose GEN and BGEN lines had no turn_at=N. The one-request path sends it, and the engine reads a prompt in calls that stop at that checkpoint. Inkling 2's greedy answer depends on how a prompt's rows are grouped into calls, so the same chat answered differently at "parallel" 1 and at 4 or 8 (reported by VecSzn on PR 226), even with every expert in VRAM: on an RTX 3090 with all 3,072 experts on the card, the same five GEN lines with turn_at removed changed two of five answers (at tokens 7 and 47), while --batch 0, 4 and 4-at-once gave the same ids for the same lines. The slot path now adds turn_key() to its keys, except for Hy4, as the one-request path does. The fake engine in test_parallel can log the raw lines (--rawlog); SlotTurnAt checks that a request alone and two admissions each carry the turn_at of their prompt (both fail without the fix). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem and result
With
"parallel"set to 2 or more, every request goes through the server's batch-slot path. That path's GEN and BGEN lines to the engine lack theturn_at=Nfield that the one-request path sends.turn_atmarks the turn checkpoint, and the engine splits the prompt's processing at that point. Inkling 2's greedy answer depends on how the prompt's rows are grouped into calls, so the same chat got a different answer at"parallel"4 or 8 than at 1. This was reported on #226.Now the slot path sends
turn_atthe same way as the one-request path, and greedy answers match across"parallel"1, 4 and 8 when the experts are split the same way between GPU and CPU.Server, IQ4_NL, 5 chats, greedy, 64 tokens. Each chat is sent one at a time, then all 5 at once. Experts are frozen and capped (
STRATA_GPU_EXPERTS=360 STRATA_FREEZE_EXPERTS=1,--cpu-share 0). RTX 2070 8 GB:"parallel"1"parallel"4"parallel"8The parallel 1 answers are the same with and without this PR.
Related discussion
#226 (comment 7113000670): greedy answers through the server differ between "parallel" 1 and 4/8 within the first words.
Approach
turn_key(ids)to its sampling keys, except for Hy4, which the one-request path skips too. It goes on both the GEN leg (a request alone) and the BGEN leg (an admission).test_parallel.pycan log the raw lines it gets (--rawlog).SlotTurnAtchecks that a request alone and two admissions each carry their prompt'sturn_at. Both cases fail without the fix.Why the answers moved: the engine gives the same tokens for the same lines
--batch0, 4 and 8, GEN or BGEN, and one or all at once. This holds on an RTX 2070 8 GB (360 experts in VRAM) and an RTX 3090 (all 3,072 experts in VRAM).turn_atoff those same lines changes 1 of 5 answers on the 2070 (at token 18). On the 3090 it changes 2 of 5 (at tokens 7 and 47).Validation
Passed:
python -m unittest serve.test_parallel.SlotTurnAt(terminal/): 2 tests pass. With main's server.py both fail.python -m unitteston serve.test_parallel, test_slots, test_parallel_yield, test_logprobs_parallel, test_yield_accounting, test_thinking_hold_batch, test_stream_ownership, test_replicas, test_close_cutoff, test_restart_waiters and test_inkling: OK (test_inkling skips 3). Linux, Python 3.10.12."parallel"1, 4 and 8, once with main's server and once with this PR's, both with strata-poly at this branch's base. The answers were compared as text and, for the one-at-a-time answers, as token ids.Failed:
serve.test_server.LoadSharedSettings.test_several_bad_keys_are_each_namedfails the same way with main's server.py on this machine, so it is not from this change.Not run:
Limits
STRATA_FREEZE_EXPERTS=1with a fixedSTRATA_GPU_EXPERTSgives the same answers.🤖 Generated with Claude Code