Repository navigation
serve: observe drafted overlap in engine-call order - #745
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: The revised gate measures engine progress and retains checks against serialized requests.
Checked
Duplicates: 1 new function checked (open_stream); no duplicate owner found. Existing request helpers consume the response. dryer reported 0 candidate pairs.
Complexity: crapper flagged no changed function.
Silent failure: 3 changed record lookups followed. Missing slot records panic by name.
Tests: six changed tests checked by static mutation review:
- UTF-8 reader: discard the payload at crates/serve/tests/slots/mod.rs:736; chunk equality fails.
- Draft overlap: process only the first active request at crates/serve/src/worker.rs:773; the new overlap assertion fails.
- Plain delivery: remove the pump at crates/serve/src/worker.rs:881; delivery before the held drafted pass fails.
- Reasoning close: recompute pass eligibility after pumping at crates/serve/src/worker.rs:887; the resumed pass runs before the original draft and the order assertion fails.
- Prompt delivery: remove the pump at crates/serve/src/worker.rs:504; B's first token waits behind C's held prompt and the delivery assertion fails.
- Schema delivery: defer pumping the completed fill at crates/serve/src/worker.rs:792; the property name waits behind the other fill and the delivery assertion fails.
Overlap predicate: an independent interval-and-adjacency check agreed on all 8,190 binary traces of lengths 1–12. Serialized, repeated-live-slot, missing-slot and empty traces were rejected.
Gates: the replaced arrival-order clause has a dated PIN and reason at crates/serve/tests/slots/mod.rs:875. The PR documents the old clause's false failure and a failing serialized-worker mutant.
Escape catalog: no pattern matched. No production hot path changed.
Notes
Rust tests were not rerun. The PR reports 42 passing slot tests and the serialized-worker mutation failure.
🔨 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. |
1 similar comment
|
The review is done and the contribution check passed, so I'm merging this. |
두 요청이 겹쳐 진행되는지 보는 SSE 시험이 읽는 쪽 스레드의 실행 순서에 흔들리지 않도록, 엔진이 실제로 기록한 호출 순서로 판정하게 고칩니다.
Part of #565. Tracked in #699.
What and why
hw_drafted_passes_interleave_across_slotschecks that two drafted requests run side by side. Besides the engine's call order, it also compared the arrival order of chunks in a log that both client reader threads append to. That order says when each reader thread got scheduled, not when the server sent a chunk. If the second reader starts late, the first stream is fully read before the second reader takes its first chunk, and the gate stops with "the streams did not overlap" even though the server interleaved the requests correctly.The change is test-only and sits in
crates/serve/tests/slots/mod.rs, plus the call sites of the other tests that readSeenChunk:open_streamnow owns connecting and sending the request.read_streamcalls it and then reads, so the existing callers keep their behavior.SeenChunkno longer carries an arrival timestamp, since nothing may read client arrival order as server progress. It is now the slot, the stop flag and the chunk. The two readers inyields.rsand the plain-step and reasoning-close delivery tests inmod.rsuse the new shape; the delivery tests read the slot.The final-chunk, per-slot ids, draft count, accepted count and concurrent-slot metric assertions are unchanged. No production code, output bit, default or GPU path changed.
Release notes: internal: the drafted-overlap serve test no longer reports a false error when a client reader thread is scheduled late.
Code shape
read_streamintoopen_stream, which both paths use. The existingread_chunksstays the only chunk reader.expecton a missing slot record and name both slots in the message.SeenChunkandread_streamdocs describe client observation only, and the reader order is not claimed to be the server's.PINwith the reason, and the serial mutant below shows it still catches requests that do not overlap.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.rustfmt --edition 2024 --checkon the changed file andgit diff --checkare clean; clippy has not been run on this head.Duplication found or removed (
path:line), or "none": none. The duplicate scan reported no candidate.What I ran
The tests use mock engines and loopback HTTP, so they need no GPU and no model. They ran on a Linux x86_64 CPU machine at head
104d57a3a6cf0381bede2ff1e895f7399510ee5d, withRUSTFLAGS='-C target-cpu=native'and locked, offline Cargo.FAIL-first, with the arrival-order overlap check put back into the gate on this head (rc 101):
cargo test --locked --offline -p bloomery-serve --test serve slots::hw_drafted_passes_interleave_across_slots -- --ignored --exact --nocaptureThe gate panicked with
stream 0 ended before stream 1 began: the streams did not overlap, and the run ended withtest result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 106 filtered out.With the change,
cargo test --locked --offline -p bloomery-serve --test serve slots:: -- --include-ignored --nocapture --test-threads 4ended withtest result: ok. 42 passed; 0 failed. That covers the interleave gate,stream_chunks_preserve_utf8,stream_chunks_refuse_invalid_or_incomplete_frames, the twoyields.rstests, the plain-step and reasoning-close delivery tests, andhw_each_slot_gives_its_request_alone_ids.Mutant on the real server: I changed
Worker::stepto advance only the first active request (while k < self.active.len()becamewhile k < self.active.len().min(1)), so the second request starts after the first has finished. The gate then failed with rc 101 on the new assertion,slot 0 ended before slot 1 began: the passes did not overlap, with all 23 of slot 0's passes recorded before slot 1's 23. Both mutants were restored andgit diff --exit-codepassed; neither was committed.Not run: clippy,
t0, the full workspace test run, and any GPU gate. The change touches no production code and no CUDA path, so I took no timing or output-bit measurement.Reproduction
cargo test --locked --offline -p bloomery-serve --test serve slots:: -- --include-ignored --nocapture --test-threads 4What I ran into
This does not block the PR. Four delivery tests, two in
mod.rsand two inyields.rs, each carry the same loop that rereads the client log every 5 ms untilBOUND. They could share one helper; I left them as they are, since moving them is a test cleanup apart from this fix. It has no effect on decode, prefill or time to first token.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.