Skip to content

serve: a request that bans an id draws in the draft's passes - #719

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-ignore-eos-mtp
Oct 23, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-ignore-eos-mtp

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

ignore_eos를 켠 요청이 MTP 초안(draft)을 쓰지 못하고 토큰을 하나씩 생성하던 결함을 고쳐서, 고정 길이 디코드가 일반 요청과 같은 속도로 돌게 하는 수정입니다.

Part of #565. Tracked in #699.

What and why

A request with ignore_eos never used the speculative draft. Gen::new puts the vocabulary's stop ids in the request's banned list, and takes_passes let only a request with an empty banned list take drafted rounds. Every token after the first was a one-row step, the draft never proposed, and the response carried no draft_n, so a client saw no sign of it. Fixed-length decode runs, which usually set ignore_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) -> Sampler in crates/serve/src/genloop.rs replaces choose. 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, or sampling::argmax (first of equals) for a greedy request.
  • Gen::new wraps the request's sampler with banning when banned is not empty. The request then draws like a sampled one: through Engine::advance_sampled rounds 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_passes loses its banned parameter. It is private, so no public signature changes.
  • A greedy banning request keeps the engine's argmax on a step unless that id is banned (new greedy field), so a step scans the row only where it did before.
  • Docs that said an id-banning request steps now say where it drafts: docs/serving.md, the BLOOMERY_DRAFT lever text, and the comments in engine.rs, gate_qwen38_serve.rs, serve_seats/qwen38.rs and serve_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_bias or grammar is a 400 at the API edge. A request that follows a program (json_schema, a forced tool call) cannot set ignore_eos and 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_eos uses the MTP draft, so fixed-length decode runs are faster.

Code shape

  • No second copy. banning replaces choose, the only place that masked a row. The other NEG_INFINITY sites in crates/serve (logprobs and sampling tests) do not mask a row. The new test reuses the helpers of sampdraft.rs.
  • Model code holds only architecture facts. No model code changes; the seat files only get comment edits.
  • Dead code is gone. choose and the banned parameter of takes_passes are removed.
  • No silent failure. No new Result. A banned id that still reaches the loop keeps failing with GenError::Banned.
  • Comments state what is true now. The comments describe the current behavior.
  • No relaxed gate. No band, tolerance or lint moved. The ignore_eos arm of the old step test becomes the new drafting test, and its forced-close arm stays as hw_a_forced_close_steps with a PIN(2026-10-23) line.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up. rustfmt --edition 2024 --check is 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.

NVIDIA GB10, 595.84
NVIDIA GB10, 595.84, 2067 MHz, 3003 MHz, 9.34 W, 53
NVIDIA GB10, 595.84, 2437 MHz, 3003 MHz, 58.88 W, 79
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.2     |

FAIL-first: the new test hw_a_banned_id_drafts (crates/serve/tests/sampdraft.rs) on the base without the fix:

cargo test -p bloomery-serve --test sampdraft -- --include-ignored hw_a_banned_id_drafts
thread 'hw_a_banned_id_drafts' panicked at crates/serve/tests/sampdraft.rs:376:13:
T 0, seed 1: the banned request drafted nothing
test hw_a_banned_id_drafts ... FAILED

The test sends ignore_eos requests (temperature 0 and 0.8, seeds 1 to 4, 24 ids, prompt abacadaez) 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 (--lib and the integration tests, --include-ignored) ran with 0 failures, including the new test:

cargo test -p bloomery-serve --lib --test serve --test dsml --test glmxml --test hermes --test qwenxml --test callstream --test limits --test anthropic --test penalty --test sampdraft -- --include-ignored
test hw_a_banned_id_drafts ... ok
test hw_ignore_eos_does_not_outlive_its_request ... ok
test result: ok. 345 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.22s
test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.33s
test result: ok. 101 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.30s

just gate-gpu-qwen38-serve not run: the gate needs the maintainers' workstation.

The existing unit test a_sampled_request_tells_a_drafting_engine_its_passes now expects an ignore_eos request 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), main 7cc05a289 against head 0315a7049, each built from its own tree. FP4-Local b9ce18a6 and NVFP4 fc694b54, 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 greedy ignore_eos code requests, 2 greedy ignore_eos prose requests, 4 sampled ignore_eos code requests (temperature 0.8, seed 11 + i), and 4 greedy code requests without ignore_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.

Case (one GB10, C@1, MTP on, 4096-id prompt, 128 ids) main head change draft (accepted/proposed), main head
FP4-Local, greedy ignore_eos code-fn, decode tok/s 29.109 54.150 +86.03% 0/0 358/418
FP4-Local, greedy ignore_eos prose-en, decode tok/s 29.316 37.229 +26.99% 0/0 107/179
FP4-Local, sampled (T 0.8) ignore_eos code-fn, decode tok/s 29.119 50.259 +72.60% 0/0 338/412
FP4-Local, greedy code-fn without ignore_eos, decode tok/s 54.188 54.900 +1.31% 351/412 358/424
NVFP4, greedy ignore_eos code-fn, decode tok/s 21.600 38.849 +79.85% 0/0 351/476
NVFP4, greedy ignore_eos prose-en, decode tok/s 21.556 23.970 +11.20% 0/0 118/272
NVFP4, sampled (T 0.8) ignore_eos code-fn, decode tok/s 21.634 40.141 +85.54% 0/0 351/467
NVFP4, greedy code-fn without ignore_eos, decode tok/s 40.637 37.487 -7.75% 345/450 351/455

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_eos request 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_eos against 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):

  • main and head, every window of every scenario on both checkpoints (28 checks: greedy ignore_eos, sampled ignore_eos and 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_eos and plain on the head and on main, greedy code requests on each of the four arms (16 checks): the 128 ignore_eos ids equal the ids of the same window without ignore_eos. No plain answer ended early, so the comparison runs to the full 128 ids.

Reproduction

cargo test -p bloomery-serve --test sampdraft -- --include-ignored hw_a_banned_id_drafts
BLOOMERY_DRAFT=mtp bloomery-serve --parallel 1 --ctx-size 8192 <model options>

Send the same prompt with ignore_eos set and not set, and compare draft_n and the decode speed in the response timings.

What I ran into

This does not block the PR.

  • The NVFP4 control (greedy code without 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.
  • NVFP4 prose gains least (+11.20%): 118 of 272 proposals were kept there, against 74% on code.
  • gate_qwen38_serve's slots_drafted_sampled_* pair runs ignore_eos alone runs that now draft. The gate is listed under What I ran. The parity above is the GB10 evidence for the same loop.
  • The timed run used the Qwen seat only. The GLM seat, which also drafts sampled requests, has no GB10 run here.
  • A banning request still steps while another slot is busy and on the DSpark and ds41 seats, and structured output (json_schema, forced tool calls) still steps every token.
  • Not run: t0, clippy and the other static checks.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

`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.
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve labels Oct 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit a322790 into midagedev:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant