Skip to content

perf(server): reduce HTTP and PD streaming overhead - #1605

Open
WANDY666 wants to merge 3 commits into
mainfrom
perf/http-pd-streaming
Open

WANDY666 wants to merge 3 commits into
mainfrom
perf/http-pd-streaming

Conversation

@WANDY666

@WANDY666 WANDY666 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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.

@WANDY666
WANDY666 requested a review from hiworldwzj October 8, 2026 03:15
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.

2 participants