Repository navigation
server: n of 1 through 16 choices on chat and completions, each its own request on the one prompt - #3148
Merged
Conversation
ashhart
force-pushed
the
lead/n-choices
branch
3 times, most recently
from
November 15, 2026 21:48
d209ba4 to
96d301f
Compare
5 tasks done
ashhart
force-pushed
the
lead/n-choices
branch
from
November 18, 2026 00:11
96d301f to
a6e541f
Compare
3 tasks done
ashhart
force-pushed
the
lead/n-choices
branch
3 times, most recently
from
November 21, 2026 20:53
ca4e40e to
92e09b5
Compare
ashhart
force-pushed
the
lead/n-choices
branch
from
November 21, 2026 23:59
92e09b5 to
f6f2867
Compare
This was referenced Nov 22, 2026
…wn request on the one prompt A request with n above 1 runs n replies at once, each the route's own whole reply or stream on its thread, and merges them: choices[i] with its index, its own tensorfold block (seed, cached_tokens), stop_sequence, loop-stop error and tool-call ids, and usage with the prompt counted once. Choice 0 keeps the request's seed, so n of 1 is today's path byte for byte; choice i draws with mix(seed ^ i) in 63 bits, and a request that names no seed draws one for all its choices. Later choices resume the prompt the first fills through the prefix wait and the prompt cache. n above 1 with logprobs or a required tool call is refused, and on a --cortheon server so is a chat its turn loop would take; anything else outside 1-16 gets "n must be an integer between 1 and 16". /v1/responses and /v1/imprint serve one reply and keep refusing n other than 1, as before. Under --max-inflight and --max-inflight-per-key an n-choice request holds n places: after its body is read it takes the other n - 1, all or none, or answers the cap's own 429 before any choice starts.
Prompt lists and n choices fan one client reply over several engine requests and merge them. Share that machinery instead of keeping a second copy in choices.zig: prompt_list's Slot/Fan/Choice and its whole/mergeWhole/ streamed/stamp/count/usage helpers are now public, with two flags for what differs. A merge takes prompt_logprobs from choice 0 for n choices (not for a list) and counts the shared prompt once. choices.zig keeps only its seed, its lease widening and its per-choice run. Keep both Plan fields and both dispatch lines in openai.zig and refuse n above 1 with a list of prompts. The prompt-list test keeps its n=2 refusal under the new message and drops the single-prompt case, which n choices now serves. Note the feature under Unreleased in CHANGELOG.md.
Match prompt-list dispatch: the request journal observes the one merged reply, while only an unfanned generation shares the mutable Trace for prepared settings and timings. This avoids concurrent choice writers and leaves n=1 journaling unchanged.
…at the fake serves n 1 through 16 test_serial_json_script_and_refusal_never_join posts a streamed request the fake refuses and checks that it never claims the served-evidence pairing. It used n 2, which this PR's fake (refusal(), mirroring the server's new 1..16 range) now serves: the request went down the streamed path, claimed the pairing, and the mock's guard raised "unrelated path joined the served-evidence rendezvous". The PR moved test_bench_conformance's refused example to n 17 but not this one. It now posts n 17 and checks the whole 400 reply and its message, so the refusal it relies on cannot quietly become a served request again; claim is still asserted never called.
ashhart
force-pushed
the
lead/n-choices
branch
from
November 22, 2026 05:38
f6f2867 to
8e03ef7
Compare
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.
Closes #3114.
Chat and completions take
nfrom 1 to 16. Each choice is its own engine request on the one prompt, run at once and merged:choices[i]with its index, its owntensorfoldblock (seed,cached_tokens), stop sequence, loop-stop error and tool-call ids, andusagecounting the prompt once. Choice 0 keeps the request's seed, son: 1replies are unchanged. Choice i draws withmix(seed ^ i), named in itstensorfold.seed, so any choice replays alone. Without a seed, one is drawn per request. Later choices resume the prompt the first fills.An
nrequest takes n places under--max-inflightand--max-inflight-per-key, all or none. When they don't fit, it gets today's 429 (Retry-After,max_inflight_exceededormax_inflight_per_key_exceeded) and no choice reaches the engine; all n places are released together./v1/responsesand/v1/imprintstill refusen > 1with main's 400. The--cortheonrefusal applies only to chats Cortheon would take.Tests:
test-server-cpu1343 pass, 7 skip (main 1330), with 8 of the 9 choices tests failing on main; an HTTP test with--max-inflight 2(n=3 gets 429 and the engine is never called; n=2 holds two places and a plain request gets 429 until it ends) fails without the caps change;test-limit-pins-host27,test-server-security29,test-goldenpass.Device check pending (Qwen3.8-27B on an M5 and Qwen3.5 or Nemotron on a GB10,
--prompt-cache-gib 8, n=3, T 0.7, seed 1234, a prompt over 3,000 tokens, whole and streamed): each choice's token hash equals a solo request with its reported seed, drafted and not; with no seed, choice i's seed equals mix(seed0 ^ i) and replays; n absent or 1 equals main; choices 1 to n-1 show cached tokens; an unrelated stream beside an n=3 request keeps its tokens.