Skip to content

[Engine] serve: same answers with parallel > 1 as with parallel 1 - #287

Open
okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/slot-turn-at
Open

okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/slot-turn-at

Conversation

@okada-shogo

@okada-shogo okada-shogo commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 the turn_at=N field that the one-request path sends. turn_at marks 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_at the 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:

Server "parallel" 1 "parallel" 4 "parallel" 8
main 10 of 10 answers same 8 of 10 same as parallel 1 8 of 10 same as parallel 1
this PR 10 of 10 same 10 of 10 same as parallel 1 10 of 10 same as parallel 1

The 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

  • The slot path adds 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).
  • With this, a slot request also keeps the turn checkpoint that the next turn of its chat resumes from, as a single request already does.
  • Test: the fake engine in test_parallel.py can log the raw lines it gets (--rawlog). SlotTurnAt checks that a request alone and two admissions each carry their prompt's turn_at. Both cases fail without the fix.
Why the answers moved: the engine gives the same tokens for the same lines
  • With the same lines from the server, strata-poly gives identical token ids for --batch 0, 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).
  • Taking turn_at off 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 unittest on 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.
  • End to end on an RTX 2070 8 GB, IQ4_NL, fp16 KV, 32K context, the table above. The server ran at "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_named fails the same way with main's server.py on this machine, so it is not from this change.

Not run:

  • The end-to-end server run on a card that holds every expert. The RTX 3090 run was cut short when its container restarted. That case is covered only by the engine-level check above.
  • Windows and macOS. The change is Python-only and doesn't depend on the platform.

Limits

  • On a card that cannot hold every expert, the batch slots' caches take VRAM from the expert cache: on an 8 GB card, 928 experts fit at "parallel" 1, 655 at 4 and 363 at 8. An expert summed on the CPU rounds differently from one on the GPU, so greedy answers can still differ between "parallel" settings there. That is placement, as with one request whose expert cache changes. STRATA_FREEZE_EXPERTS=1 with a fixed STRATA_GPU_EXPERTS gives the same answers.

🤖 Generated with Claude Code

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>
@okada-shogo okada-shogo changed the title [Other] serve: turn_at on the batch slots' GEN and BGEN lines [Fix] serve: pass turn_at on batch slots so parallel > 1 gives the same answers as parallel 1 Nov 24, 2026
@okada-shogo okada-shogo changed the title [Fix] serve: pass turn_at on batch slots so parallel > 1 gives the same answers as parallel 1 [Engine] serve: pass turn_at on batch slots so parallel > 1 gives the same answers as parallel 1 Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] serve: pass turn_at on batch slots so parallel > 1 gives the same answers as parallel 1 [Engine] serve: send turn_at from the batch slots so "parallel" > 1 gives the same answers as "parallel" 1 Nov 24, 2026
@okada-shogo okada-shogo changed the title [Engine] serve: send turn_at from the batch slots so "parallel" > 1 gives the same answers as "parallel" 1 [Engine] serve: same answers with parallel > 1 as with parallel 1 Nov 24, 2026
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.

1 participant