Skip to content

server: a raw completions prompt list gets one choice a prompt, each the reply that prompt gets alone - #3194

Merged
ashhart merged 4 commits into
mainfrom
lead/completions-prompt-list
Nov 17, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/completions-prompt-list

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

A /v1/completions request whose prompt is a list of strings used to be joined with newlines and served as one prompt with one choice. Now each string runs as its own request and the server merges the replies into one.

  • Each prompt takes the body's other fields (max_tokens, seed, stop and the rest) as it would if it were the only prompt.
  • choices[i] is prompt i's choice with index i, its own stop and its own tensorfold block, which also carries that prompt's cached_tokens. usage sums every prompt's and every reply's tokens.
  • A stream sends one head, then each prompt's chunks with its index, then the finishes in list order, then one usage chunk when stream_options.include_usage is set, then one [DONE]. Without include_usage the last finish carries the summed usage.
  • The first refusal in list order is the reply, and no prompt starts after one is refused.
  • Up to eight prompts run at once. Under --max-inflight or --max-inflight-per-key the request still holds one place, so its prompts run one at a time.
  • A list holds at most 64 prompts. A 65th gets a 400 before anything reaches the engine.

Single prompts don't change. Only a list of two or more strings takes the new path. A string, a one-string list, a token-id list, a list of token-id lists and a mixed list build the same single prompt as before. n must still be 1 for a list, as for one prompt; n per prompt follows #3148's n choices, and whichever of the two lands second shares one fan-out module.

Tests on the fake engine, in prompt_list_test.zig:

  • A list's choices have the text and token_sha of each prompt sent alone, whole and streamed, and usage is their sum.
  • 64 prompts are served and 65 are refused with nothing submitted, as a limit pins: case.
  • n: 2 is refused for a list as for one prompt, and max_tokens: 1 stops every prompt at its first token, as it does alone.
  • A prompt's stop string stays on its own choice and off the merged reply.
  • Under --max-inflight no two prompts of a list are in the engine at once.
  • A token-id list, a list of token-id lists, a one-string list and a mixed list still give one choice.

Six of the seven fail on main; the token-id case passes on both. The strings completions golden now has two choices. test-server-cpu passes 1350 with 7 skipped, and test-golden, test-limit-pins-host, test-admission-host, test-server-security and test-request-seeds-host pass.

Part of #3171 (the rest is n per prompt, after #3148).

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the lead/completions-prompt-list branch 2 times, most recently from 25e9629 to 202d83e Compare November 14, 2026 07:28
ashhart added a commit that referenced this pull request Nov 17, 2026
…back under 600 (#3194)

On main 3f1290f the prompt-list route takes zig/src/server/openai.zig to 601 lines even with three blank lines
removed. legacyPrompt and its helpers (promptId, allInts, promptText), main's reading of a raw completion's
prompt, move unchanged to completion_prompt.zig, and the three blank lines come back: openai.zig is 562 lines.
@ashhart
ashhart force-pushed the lead/completions-prompt-list branch from 202d83e to 4259f39 Compare November 17, 2026 06:04
…rompt

A /v1/completions prompt of two to 64 strings was joined with newlines into one prompt. Each string now runs as
its own request with the body's other fields and the replies merge into one: choice i is prompt i's own text, stop
and tensorfold block, usage sums them, and a stream sends each prompt's chunks with its index, then the finishes in
order. Up to eight run at once; under --max-inflight or --max-inflight-per-key they take turns in the request's one
place. A string, a one-string list and the token-id forms are unchanged; n must still be 1. The strings golden now
has two choices.

Issue #3171.
…back under 600 (#3194)

On main 3f1290f the prompt-list route takes zig/src/server/openai.zig to 601 lines even with three blank lines
removed. legacyPrompt and its helpers (promptId, allInts, promptText), main's reading of a raw completion's
prompt, move unchanged to completion_prompt.zig, and the three blank lines come back: openai.zig is 562 lines.
@ashhart
ashhart force-pushed the lead/completions-prompt-list branch from 4259f39 to 2a2350f Compare November 17, 2026 14:31
@ashhart
ashhart merged commit 49cdc85 into main Nov 17, 2026
2 of 11 checks passed
ashhart added a commit that referenced this pull request Nov 17, 2026
…back under 600 (#3194)

On main 3f1290f the prompt-list route takes zig/src/server/openai.zig to 601 lines even with three blank lines
removed. legacyPrompt and its helpers (promptId, allInts, promptText), main's reading of a raw completion's
prompt, move unchanged to completion_prompt.zig, and the three blank lines come back: openai.zig is 562 lines.
@ashhart
ashhart deleted the lead/completions-prompt-list branch November 17, 2026 14:31
ashhart added a commit that referenced this pull request Nov 17, 2026
Seven duplicate entries go (a PR's own line beside its lines-file line), five outside authors are thanked, #1503 gets the line its close note promised, and eleven lines now match their PRs' code and receipts (#3129, #3194, #3258, #2696, #2921, #3365, #3345, #3384, #3679, #3682, #3699, #3393).
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