Repository navigation
Conversation
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.
At high output rates, PD master spends CPU constructing per-token API models and forwarding already-ready output. Serialize common chat/completion deltas directly, group chat SSE events at ready-batch boundaries, and merge ready completion text per choice before serialization.
Single-choice PD requests consume the source generator directly instead of using a forwarding task and queue, with source cleanup on cancellation. WebSocket receives keep their timeout without creating a task per message, tool metadata is computed once per stream, and length validation accepts a token count directly.
The first completion chunk, batch end, finish, or 32-token/64K-character limit flushes immediately; there is no timer waiting for another model token. Preserve chat event ordering, per-choice output text, tool arguments, echo/logprobs payloads and token-based usage. Flush buffered output before stream errors. Merge current main while retaining its prefill/cache metadata and finish-status handling.
Validation: 379 tests passed across streaming contracts, completion batching, PD continuation/cache/lifecycle, multi-choice cancellation, application stop, tool calls and reasoning. Black 21.12b0, Flake8 6.1.0 and diff whitespace checks passed for all 9 changed files.
Historical performance evidence for the added completion batching + single-choice bypass is recorded in speedup_1012.md: in the controlled 1P1D H100 experiment (16K input, 4096 output, concurrency 512), output TPS increased 26,730.2 → 30,066.7 (+12.48%) and mean request TPOT fell 15.4485 → 13.0199 ms (−15.72%). Each side was one run; this measures those two changes on that deployment, not the whole PR on current main. No new service benchmark was run for this update.