Repository navigation
serve, qwen38: a long prompt yields to busy slots on the positions' quantum grid, which the Qwen3.8 seat names as its checkpoint grid - #1069
Conversation
…uantum grid, which the Qwen3.8 seat names as its checkpoint grid Engine::prompt_quantum names a grid of positions: a prompt call of more than one quantum is cut at the multiples of q inside it (and at the engine's message cuts), not every q ids from each call's start. An engine that keeps checkpoints on a grid of its own (runtime::seqstate::marks) names a multiple of it, so the cut calls take the checkpoints the one call takes and a later request keeps the same prefix whatever the load. A multiple inside an image span is not cut. A constrained run fed beside busy slots is cut on the same grid. The Qwen3.8 seat names CHECKPOINT_EVERY (not under the MTP draft on more than one slot). Body38::resolve_prompt runs a call that starts or ends on that grid as the ubatch walk at any length, as the one call's units cut there run, so a cut prompt's short first or last call keeps the one call's bits. gate_qwen4exp_mtp's hw_quantum_cuts holds the cut calls to the one call: argmax, logits' bits, three steps and checkpoints.
There was a problem hiding this comment.
Verdict: CLEAN: The remaining finding asks for corrected test evidence.
Non-blocking
⚠ Correct the FAIL-first evidence: crates/gpu/src/arch/qwen3moe/body38.rs:4648.
Removing this arm on the gate's whole-card load makes the four checks in gate_qwen4exp_mtp.rs:3214 return [true, true, false, false]. The PR reports [false, true, true, true], which does not match this mutation. Rerun with this arm removed and attach the output to establish recurrence prevention.
Checked
Duplicates: the cut rule serves both prompt and fixed-id paths; the GPU gate reuses closed_run. Dryer reported 0 qualifying pairs in serve/levers; GPU crates were outside its scan.
Complexity: crapper flagged no function. resolve_prompt adds one guarded match arm.
Silent failure: quantum_end's unwrap_or(end) selects the final call when no eligible grid position remains; callers feed the remaining ids.
Tests: static inspection confirms that removing grid routing fails the last two path checks in hw_quantum_cuts. The prompt-grid, fixed-id and image tests assert the changed cut behavior. Builds and hardware gates were not run during validation.
Gates: no tolerance or threshold relaxed. The new GPU test is ignored and returns an error when its checks fail.
Escape catalog: no C1–C4 pattern matched. No ledger lessons apply.
Notes
GPU evidence is incomplete: the PR supplies a card/driver table and gate output, but no raw nvidia-smi line required by CONTRIBUTING.md. gpu.json records evidence: false.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen4exp_mtp.rs, crates/gpu-gates/src/bin/generate_qwen3moe.rs, crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 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. |
Qwen3.8 서버에서 긴 prompt가 들어와도 다른 slot에서 돌던 요청이 멈추는 시간을 6.3초에서 1.7초로 줄입니다.
Part of #565.
What and why
With
--parallel 2, a long prompt arriving beside a decoding stream blocks that stream for the whole prefill. For a 16,385 id prompt the stream's longest gap between two tokens is 6,308.9 ms. The serve loop already cuts a prompt into calls ofEngine::prompt_quantumids so a busy slot can decode between the calls, but only the mock engine named a quantum and the cuts counted from each call's start, which put them off the checkpoint marks.This change makes the quantum a grid of positions and makes the Qwen3.8 seat name its checkpoint grid (4,096) as the quantum. A prompt longer than the quantum is cut at the next multiple of 4,096 positions. Those places are marks that one uncut call also writes (
runtime::seqstate::marks), so the cut prompt leaves the same checkpoints as one call, and a later request reuses the samecache_nwhatever the load.On the 16,385 id prompt the stream's longest gap falls from 6,308.9 ms to 1,719.7 ms, and the long prompt's first token comes 2.4% later. The numbers and commands are under "What I ran".
crates/serve/src/engine.rs,genloop.rs,worker.rs,mock.rs):Engine::prompt_quantumis a grid of positions.quantum_endpicks the next cut for a prompt (quantum_ends) and for a constrained-decoding run of fixed ids (Gen::fill). A cut never falls inside an image span.crates/gpu-gates/src/bind.rs):Seat::prompt_quantum,Noneby default, read once at load bySeatEngine.serve_seats/qwen38.rs): the quantum isCHECKPOINT_EVERY. It isNonewhen the MTP draft serves two or more slots and when--mmprojloads an image encoder, so those keep one call per prompt.crates/gpu/src/arch/qwen3moe/body38.rs,resolve_prompt): inAuto, a call that starts or ends at a non-zero multiple ofCHECKPOINT_EVERYruns as an ubatch walk whatever its length, because one uncut call also cuts its units at that mark and walks. Without this rule the short first or last piece of a cut prompt would take the short-prompt path and its bits would differ from the uncut call. The same rule applies to a short call at such a position when the request runs alone.hw_quantum_cutsis added tojust gate-gpu-qwen4exp-mtp-input. Docs:docs/serving.md.Release notes: Changed: on Qwen3.8, a long prompt now yields to decoding slots every 4,096 positions, which shortens the pause of an already running stream.
Code shape
quantum_end, which replaced the two earlier loops inquantum_endsandGen::fill. The grid spacing reusesCHECKPOINT_EVERY, and the marks stay owned byseqstate::marks.quantum_endhas no failure path, and noResultis ignored.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line): the cut loop inquantum_endsand thefed + qcut inGen::fillare now one function,quantum_endincrates/serve/src/genloop.rs.What I ran
Measurement on
bloomery-serve, base6791d577b09c6054d6293b9f6b6a1e2fb54f9970(main) against headda88f00398e420cd93a916df6335b6ad3c5e18be, both built in the same session and served in turn on the card below. Modelnvidia__Qwen3.8-Flash-Next-FP4-Local@b9ce18a6887e18c089fdea8509a33e63429a3300.Each round erases both slots (
/slots/N?action=erase), starts request A (a 64 id prompt, a streamed 400 token answer), and once A has produced 20 tokens sends request B (a 16,385 id prompt, no cache, 8 tokens) to/completion. One warm-up and three measured rounds, medians with ranges. "A longest gap" is the longest time between two tokens of A from the moment B is sent to B's first token.On the head, B runs as calls of 4,096, 4,096, 4,096, 4,096 and 1 ids and A emits a token between the calls. One head round had a longest gap of 3,083.5 ms; the other three were 1,715.9 to 1,723.0 ms.
The same run checks the output of both builds:
B-idscompares B's 8 ids when B runs alone and beside A.C-cache_nsends a request C that shares B's first 5,146 ids and checks that itscache_nis 4096 alone and beside A.A-idscompares A's 400 ids with and without B.GPU gate (
just gate-gpu-qwen4exp-mtp-input, head98afe38f93ef6e052b8a8adfe7bf60a791d1d329), run asBLOOMERY_BOX_LOCAL=1 BLOOMERY_QWEN38_FOLDER=<the model above> just gate-gpu-qwen4exp-mtp-input. WithBody38::resolve_prompttreating position 0 as a grid position (itsp > 0check removed), the new clause andhw_close_foldreport FAIL:With the rule in place:
Host tests for the serve crate (
cargo test -p bloomery-serve --libandcargo test -p bloomery-serve --test serve -- --include-ignored yields), head0b5c6d81d5e96baf8ee6c21a2c354e78a6f510db. With the run's cut put back to every q ids from its start,hw_a_run_of_fixed_ids_is_a_call_a_round_beside_a_decoding_streamfails (calls end off the quantum's grid at [13, 17, 21, 25, 29, 33, 37, 41]). With the change:Hardware (if the change is for a machine)
nvidia-smi --query-gpu=name,driver_version --format=csv,noheaderin the gate run:AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.