Repository navigation
serve: flush each completed prompt before the next call - #671
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: completed schema fills still hold ready text behind another request's fill.
Must fix
1. Drain a completed schema fill before the next fill (kind A)
crates/serve/src/worker.rs:778 Two resident JSON-schema streams with fixed runs between decisions can both need Fill. A's final fill makes tokens ready (crates/serve/src/genloop.rs:2415), but this loop runs B's fill before pumping A. A's text waits through B's fill call; the drain after step() arrives too late. This is the same defect on the schema sibling path.
Fixing this boundary now lets the regression cover both prefill producers. Insert this after tick_of(...) and before needs.push(Need::Fill):
let Some(need) = self.pump_at(k) else {
continue;
};
self.active[k].need = Some(need);This caches the next call for the next round and handles a removed request without misaligning needs. Extend the regression with two schema streams: hold B's fill after A's final fill, and assert that A's text arrives before releasing B.
Non-blocking
⚠ Complete the verification evidence: crates/serve/src/worker.rs:515. Supply the timing commands and output, the source commit used for the timed candidate, and full just gate-serve output. The PR supplies the base commit and binary hashes, but its posted integration run selects only slots::. Identify a retained tools/ probe or stats/record for this delay, or explain its omission, so the result is reproducible and a recurrence diagnosable.
Checked
Duplicates: 3 new items checked; no duplicate owner. Dryer reported 0 pairs.
Complexity: crapper flagged no changed functions; the new production helpers consume cached needs and scan active requests.
Silent failure: the optional-need paths end completion and pump errors through end_request; engine-call errors remain fatal.
Tests: the new regression checks delivery before prompt boundaries. The PR reports FAIL-first rc=101 and failure when each drain at worker.rs:504, :515 and :750 is removed. It does not exercise two schema fills.
Gates: none removed or relaxed; the new regression is hw_-prefixed and ignored.
Escape catalog: no C1–C4 pattern matched.
Notes
Static validation only; tests were not executed here.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
926dcae to
bf5a0fd
Compare
There was a problem hiding this comment.
Verdict: CLEAN: No behavior or quality defect survived review.
Non-blocking
⚠ Make the latency probe reproducible: worker.rs:504. The GB10 timing table omits the benchmark commands and their output, and identifies the measured head by binary hash rather than source SHA. Identify the probe or diagnostic record and attach the server/client commands, output and both measured source SHAs, as required by CONTRIBUTING.md:71–74.
Checked
Duplicates: 2 new worker helpers reuse pump_at; dryer reported 0 pairs.
Complexity: crapper flagged no changed function.
Silent failure: pump_at returns None after request removal and completion/error handling through end_request.
Tests: the new assertions check token delivery before blocked prompt work and schema delivery before another slot's fill completes. The PR reports failures when each drain at worker.rs:504, 515 or 750, or the post-fill pump at line 792, is removed; these runs were not repeated during review.
Gates: 2 new ignored hw_ tests; no pins moved or cases removed.
State: cached needs are consumed once; traversal retries the current index after request removal; ended resident slots are queued for sealing.
Escape catalog: none of C1–C4 matched.
Notes
Tests were not run during this review. No gate-recipe run is attached, so GPU evidence is false.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
서버가 새 prompt 작업을 시작하기 전에 이미 만들어진 token을 먼저 클라이언트로 보내서, 동시 요청의 중간 응답이 기다리는 시간을 줄입니다.
Part of #565.
What and why
With several requests in flight, the serve worker started the next prompt before it sent the tokens that were already ready. A request that had finished its prompt waited behind every prefill that was still queued. The worker now sends ready tokens after each completed prompt start, each completed prompt plan and each decode round, before it seals a cache or runs more prompt work.
pump_readyreusespump_at, so completion, cancellation and error handling stay in one place.take_needgives the turn-based worker the same cached-need consumption. No model, kernel, device allocation, rank constant or public API changes. The worker is shared by every model seat, and no model code changes.On one DGX Spark with four concurrent 4096-token requests, the median request TTFT fell from 43.925 s to 20.399 s (-53.56%, one main/head pair). The responses now arrive one after another as each prefill finishes, where on main three of them arrived together after the last prefill. Greedy output is identical on all six request pairs.
Release notes: Changed: the server sends ready tokens before it starts another prompt, which lowers the TTFT of the middle requests in a concurrent batch.
Code shape
pump_at. The inline branches this replaces were moved there. The turn worker and the slot worker sharetake_need.end_request, and engine errors stay fatal.cargo fmt --allpasses.cargo clippyhas not been run on this head, so the lint count is unchecked.Duplication found or removed (
path:line), or "none": none.python3 tools/dup-scan.pyfound no candidates in the diff.What I ran
The PR head is two commits on main
e53cabebbb9b16249c81b7c26a026da1670f7d9d. The timing below ran on that head.GPU Evidence
On an NVIDIA GB10, inside the build container and on the host:
just gate-serveis not run. The tests it names are mock-backed, and I ran them directly on a Linux host:TTFT at two and four concurrent requests
One GB10 loaded the server once per arm, main then head, with FP4-Local as shipped (
nvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300), draft off, greedy, parallel 4 and total context 16896. Each arm sent one group of two and one group of four concurrent requests, each with 4096 input ids and 128 output ids from a code corpus. Both arms ran under a passive Nsight Systems launch. Driver 595.84, CUDA 13.3.1 build image. The GPU clock cap was lifted for each timed window and restored afterwards. No CUDA process ran before the lease, and the pre-lease load average was 0.66.Main binary SHA256
16dc844eef2a0b43a7c2b0d483b9c54e07c9f4175004e2e25e06cc4bb7c523b1, headd5f13a4b1c577dcc39d63f7612d3036acf99528f0539761df0db0cace9c535c0. Corpus SHA2567520b471436fb307e91ee22640ad8100701d48e63e3da7de9160b705b92915d1.C@4 TTFT p50 decreased by 53.56% in one main/head pair. Group makespan throughput changed by +139.424% at C@2 and +31.472% at C@4. These are single observations, not significance or sustained-throughput claims. Main prompt durations were 10.277 to 14.813 s versus 8.089 to 8.189 s on head, so this pair does not isolate a pure host-delivery effect.
TTFT p50 is the median of the per-request values, and p95 is nearest-rank (the maximum for groups this small). Group makespan runs from the earliest send to the last delivered token, and group tok/s counts all generated ids over that time. The other percentage changes are derived from these values.
Sorted first-delivery times after the group's first send, C@4 main
[10.376, 43.926, 43.926, 43.927]s and head[8.193, 16.352, 24.447, 32.641]s. On main the last three responses arrived together after the final prefill. On the head each response arrives as its own prefill completes.This is one main/head pair, so these are single observations with no spread. Server load took 278.864 s on main and 244.795 s on head, outside request timing.
Correctness
FAIL-FIRST main rc=101) and on a variant that drains only before the admission list (FAIL-FIRST initial fix rc=101). Removing each of the three drain calls fails it too: after a completed decode (completed decode rc=101), after a new prompt (new prompt rc=101) and after a prompt's last part (last prompt part rc=101). Restored code passes.1 passed; 0 failed). With the new four-line pump after each fill removed, it fails at the delivery assertion (panicked at crates/serve/tests/slots/yields.rs:736), and the elevenslots::yields::tests pass again once the line is restored.cargo test -p bloomery-serve: 344 unit tests pass.What I ran into
This does not block the PR. Prefill of the queued prompts is still serial, so the last response of a group of four still arrives at about 33 s. Changing prompt quanta or mixed prompt and verify passes would be separate work.
Hardware
One NVIDIA DGX Spark (GB10), driver 595.84, CUDA 13.3.1 build image. The
slots::tests andjust contrib-check --tier t0ran on a Linux x86 host.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.