Repository navigation
serve: a request that bans an id draws in the draft's passes - #719
Conversation
`ignore_eos` puts the vocabulary's stop ids in a request's banned list, and takes_passes let a request pass only with no banned id, so every token after the first was a plain step: a client that sets ignore_eos ran with the draft off. The ban is now the request's draw, as llama-server's logit_bias_eog sits in its sampler chain: a copy of the row with each banned id's logit at -inf, then the request's sampler, or for a greedy request the copy's argmax (first of equals, the engine's own tie rule). A step and a sampled pass (Engine::advance_sampled) draw from it alike, so an id-banning request passes where a sampled one does (alone in its round, on an engine that drafts sampled requests), and a proposed stop id is taken back at its row. The draw masks a copy, so the row a request's probabilities read stays as the engine wrote it. A greedy request's step still keeps the engine's argmax when it is not banned, so a step scans the row only where it did before. sampdraft's banned arm becomes its own gate, hw_a_banned_id_drafts: greedy and sampled ignore_eos requests draft on the drafting mock with the plain twin's ids; the forced-close arm stays as hw_a_forced_close_steps. The docs and the BLOOMERY_DRAFT lever text that said an id-banning request steps now say where it drafts.
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect survived checks of masked draws, context bounds, forced closes, and slot transitions.
Non-blocking
⚠ Complete the timing reproduction: crates/serve/src/genloop.rs:367 copies V f32 logits per masked draw: 4V bytes copied [derived]. Greedy plain steps skip this draw when the engine's argmax is allowed. Provide the exact model files and timing/request commands with their output for both revisions; <model options> leaves the reported A/B unreproducible.
Optimization headroom
- E. Less work: crates/serve/src/genloop.rs:1731 makes greedy banning requests keep sampler history, although their draw ignores it. The decode path copies that history per drafted pass at L1292. Use the existing
greedyfield to skip history seeding and appending for these requests, saving 4 × (prompt-tail IDs + generated IDs) bytes copied per pass [derived].
Checked
Duplicates: 5 new or renamed functions checked; no duplicate owner found. Dryer reported 0 pairs. Its excluded gpu-gates hunks contain comment changes only.
Complexity: crapper flagged no changed function. No kernel body changed.
Silent failure: 1 moved optional-index masking site followed to its consumer. A returned banned ID raises GenError::Banned before output.
Tests: static mutation review of crates/serve/src/genloop.rs: removing L370's zero normalization fails the greedy-zero test; applying it to sampled rows fails the sampled-zero test. Removing L374's mask or restoring a ban veto at L396 fails hw_a_banned_id_drafts. Bypassing L2273's think-budget bound fails hw_a_forced_close_steps. Restoring the ban veto also fails the updated reply-count assertion. Tests were not rerun.
Gates: no tolerance moved. The replaced step-only ban case has a dated PIN explaining its replacement and FAIL-first evidence in the PR body; forced-close coverage remains.
Escape catalog: no C1–C4 pattern matched. The additional clean-result check confirmed that logprobs still read the original row and disable drafted passes.
Notes
No GPU serving gate output is supplied; the PR explicitly reports that gate as unrun. The GB10 timing table does not satisfy the GPU gate evidence requirement.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/bin/shared/serve_seats/glm.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. |
ignore_eos를 켠 요청이 MTP 초안(draft)을 쓰지 못하고 토큰을 하나씩 생성하던 결함을 고쳐서, 고정 길이 디코드가 일반 요청과 같은 속도로 돌게 하는 수정입니다.Part of #565. Tracked in #699.
What and why
A request with
ignore_eosnever used the speculative draft.Gen::newputs the vocabulary's stop ids in the request'sbannedlist, andtakes_passeslet only a request with an emptybannedlist take drafted rounds. Every token after the first was a one-row step, the draft never proposed, and the response carried nodraft_n, so a client saw no sign of it. Fixed-length decode runs, which usually setignore_eos, therefore measured the server with MTP off.The guard was there because the step path masked the banned ids in the request's own logits buffer before its draw, and a drafted round's verified rows never went through that mask. It came in with 875ac01 (the first drafted serve path) and stayed when sampled requests started to draft in 0a420c5.
This PR masks each verified row before the request's draw, so a banning request can take the same drafted rounds as any request that draws:
banning(draw, banned) -> Samplerincrates/serve/src/genloop.rsreplaceschoose. It copies the row into a buffer it owns (reused on each call), sets every banned id's logit to negative infinity, then applies the request's sampler, orsampling::argmax(first of equals) for a greedy request.Gen::newwraps the request's sampler withbanningwhenbannedis not empty. The request then draws like a sampled one: throughEngine::advance_sampledrounds when the seat drafts sampled requests and the slot runs alone in the round, and through plain steps otherwise. A proposed stop id is never kept; the draw takes another id at that row and the round ends there, as for any rejected proposal.takes_passesloses itsbannedparameter. It is private, so no public signature changes.greedyfield), so a step scans the row only where it did before.docs/serving.md, theBLOOMERY_DRAFTlever text, and the comments inengine.rs,gate_qwen38_serve.rs,serve_seats/qwen38.rsandserve_seats/glm.rs. The DSpark and ds41 docs stay as they are, because those seats do not draft sampled requests and a banning request still steps there.No other request bans an id: a non-empty
logit_biasorgrammaris a 400 at the API edge. A request that follows a program (json_schema, a forced tool call) cannot setignore_eosand still steps. The change is in the request loop, above any rank split, so the rank count is not involved.Release notes: Fixed: a request with
ignore_eosuses the MTP draft, so fixed-length decode runs are faster.Code shape
banningreplaceschoose, the only place that masked a row. The otherNEG_INFINITYsites incrates/serve(logprobs and sampling tests) do not mask a row. The new test reuses the helpers ofsampdraft.rs.chooseand thebannedparameter oftakes_passesare removed.Result. A banned id that still reaches the loop keeps failing withGenError::Banned.hw_a_forced_close_stepswith aPIN(2026-10-23)line.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.rustfmt --edition 2024 --checkis clean on the touched Rust files. Clippy has not been run on this head.Duplication found or removed (
path:line), or "none": none; the duplicate scan found no candidate.What I ran
Hardware: one NVIDIA DGX Spark (GB10) for the timed run; the tests ran on a CPU-only Mac.
FAIL-first: the new test
hw_a_banned_id_drafts(crates/serve/tests/sampdraft.rs) on the base without the fix:The test sends
ignore_eosrequests (temperature 0 and 0.8, seeds 1 to 4, 24 ids, promptabacadaez) to the drafting mock and to its plain twin. Per request it asserts that the ids equal the twin's, that none is the end id, and that the banning request drafted while the twin did not. Over all requests it asserts that some proposals were kept and some taken back, and that the drafting server ran sampled rounds. The prompt ends on an id the mock never saw, so the target's argmax is the end id and the greedy run's first round proposes it.On the fix head the serve test set (
--liband the integration tests,--include-ignored) ran with 0 failures, including the new test:just gate-gpu-qwen38-servenot run: the gate needs the maintainers' workstation.The existing unit test
a_sampled_request_tells_a_drafting_engine_its_passesnow expects anignore_eosrequest to tell the engine its rounds ([Some(7), Some(7)], was[Some(7), Some(0)]).Speed
Measured on one DGX Spark (
NVIDIA GB10, driver 595.84), main7cc05a289against head0315a7049, each built from its own tree. FP4-Localb9ce18a6and NVFP4fc694b54, each with its own MTP layer,BLOOMERY_DRAFT=mtp,--parallel 1 --ctx-size 8192, width chooser at its default. One server load per arm in the order fp4l-base, fp4l-head, nvfp4-head, nvfp4-base. Each arm runs one warm request, then the same windows: 4 greedyignore_eoscode requests, 2 greedyignore_eosprose requests, 4 sampledignore_eoscode requests (temperature 0.8, seed 11 + i), and 4 greedy code requests withoutignore_eos, which take a path this change does not touch. Prompts are 4096 ids, 128 ids are generated, no prompt cache, and the GPU clock cap is lifted for each timed arm and restored after it. Decode tok/s is a scenario's predicted ids over its predicted ms. These are paired observations from one sitting, not a significance claim.Decode tok/s, head against main: +86.03% (FP4-Local greedy ignore_eos code), +79.85% (NVFP4 greedy ignore_eos code); control without ignore_eos +1.31% (FP4-Local) and -7.75% (NVFP4).
On main every
ignore_eosrequest decodes one token per step (29.1 tok/s FP4-Local, 21.6 NVFP4, the same for greedy and sampled, no draft counts). On the head it drafts like the plain request: code decode rises between +72.60% and +86.03% on both checkpoints and for both greedy and sampled draws, and prose rises +26.99% on FP4-Local and +11.20% on NVFP4. On the head,ignore_eosagainst the plain control on the same load is 54.150 against 54.900 tok/s on FP4-Local and 38.849 against 37.487 on NVFP4, so the masked host draw per verified row costs no more than the load-to-load spread.Output parity
Per window, the ids of the 128 generated tokens were compared (44 checks, 0 unequal):
ignore_eos, sampledignore_eosand the control). For the sampled windows this compares the head's drafted rounds, each kept id drawn from a verified row, with main's one-row steps.ignore_eosand plain on the head and on main, greedy code requests on each of the four arms (16 checks): the 128ignore_eosids equal the ids of the same window withoutignore_eos. No plain answer ended early, so the comparison runs to the full 128 ids.Reproduction
Send the same prompt with
ignore_eosset and not set, and comparedraft_nand the decode speed in the response timings.What I ran into
This does not block the PR.
ignore_eos) is 7.75% slower on the head than on main, on a path the change does not touch. The whole head load was slower: its prefill, which the change also does not touch, ran at 893.9 to 1135.6 tok/s with p95 time to first token of 4.39 to 4.69 s across its five scenarios, against 1100.4 to 1166.0 tok/s and 3.55 to 3.74 s on the main load. The width chooser also measured each draft width 14 to 18% dearer on that load (costs 52.40/68.97/80.68/90.88 against 46.04/59.74/68.13/76.73). The FP4-Local control, on the same code and request order, moved by +1.31%. I did not run a second NVFP4 sitting that would separate a slow load from a lasting effect of the sampled passes, so this is a reading of the prefill and chooser numbers and not a proof.gate_qwen38_serve'sslots_drafted_sampled_*pair runsignore_eosalone runs that now draft. The gate is listed under What I ran. The parity above is the GB10 evidence for the same loop.json_schema, forced tool calls) still steps every token.t0, clippy and the other static checks.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.