Repository navigation
runtime: retain batch costs by slot count and pass packing - #741
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix finding remains; the evidence and diagnostic requests are advisory.
Non-blocking
⚠ Attach evidence for the reviewed head: crates/gpu-gates/src/bin/shared/serve_seats/rounds.rs:314. The body reports an A/B of c3cdb34 against 648dd75; this review covers bc30951 against 8249381. Attach the selected owning gate commands and output for these revisions, plus identical PTX scans for the planner move, to verify the reviewed decode path.
⚠ Expose retained learning: crates/runtime/src/width.rs:459. Batch keys, reading counts and probe progress remain private; the existing width records expose the per-slot chooser. Expose the batch state through stats or records, or explain the omitted diagnostic layer, so later resets or timing merges can be diagnosed from a run.
Optimization headroom
- E. Less work: crates/runtime/src/width.rs:437. On each batch decode round, every unseen candidate recomputes every stored median. Maintain the existing sorted buffer when readings change to remove up to 64 × C × K / T bytes of scoring copies per output token [derived]: C unseen candidates, K stored layouts, up to eight f64 readings each, and T output tokens per round. No additional state is needed.
Checked
Duplicates: the app delegates packing to runtime; no second packing owner found. Dryer reported zero pairs and excluded GPU-gates; its changed caller was read manually.
Complexity: choose 25→31 adds state-selection and packing branches; observe 3→9 adds validation and layout insertion. Both grow existing functions within the batch owner; complexity alone yields no finding.
Silent failure: missing readings request exploration; absent slot 0 preserves order; unmatched packings interpolate or panic explicitly. Planner and observation errors propagate to callers.
Tests, static inspection only: packing assertions cover overflow and refusal preserving the plan; batch assertions cover packing isolation, alternating slot counts, invalid readings and interpolation. Rust tests were not run during validation.
Gates: no tolerance or threshold changed. The removed prompt-row overflow test case has a dated PIN and reason at width.rs:3188.
Escape catalog: C1–C4 do not match this diff.
Notes
The PR carries no just gate-* command with passing output. Its A/B does not satisfy the requested GPU gate evidence record.
Card check: needs-gpu. This pull request changes crates/app/src/lib.rs, crates/gpu-gates/src/bin/shared/serve_seats/rounds.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. |
MTP draft 폭을 고르는 비용 모델이 서로 다른 batch 구성의 측정값을 섞고 슬롯 수가 바뀔 때마다 학습을 잃던 두 가지 결함을 고칩니다.
Part of #565. Tracked in #699.
What and why
The cost-based draft width chooser prices one shared verify round by its measured wall time. Two defects in how it keeps those measurements made it choose widths from the wrong readings. Both come from
bb2173656(#690).[3, 3, 3, 3, 4]rows run as three passes and windows of[4, 4, 3, 3, 2]rows run as two, yet both total 16 rows and shared one reading. Three-pass and two-pass walls were averaged into one number, which distorts the width choice.c37a56a48, which has the same effect.The fix has three parts.
Batchincrates/runtime/src/width.rskeys its readings by the sorted row count of each actual pass, and keeps readings and probe progress per active-slot count and body pass bound, so returning to a slot count resumes its learning. A packing that was never observed is priced by interpolating wall time per pass by mean rows per pass and multiplying by the pass count. An observed packing's median is never merged with another packing's.runtime::round_passesincrates/runtime/src/lib.rs. The cost chooser and the app's round execution both call it, so the cost model prices the passes that actually run. The old packing code incrates/app/src/lib.rsis removed, and its function now only converts the error type. The planner tests the row sum aspacked <= max_rows - n, so a window ofusize::MAXrows cannot overflow.crates/gpu-gates/src/bin/shared/serve_seats/rounds.rspasses the body's pass bound (SlotRows::MAX_ROWS) and each window's real row count toBatch::chooseandBatch::observe. Qwen and GLM both go through this function, and the bound is data, so no rank count or model fact is hard coded.The minimum reading count, the margin, the probe period and the allowed-width rule are unchanged. Kernel arithmetic and the token acceptance rule are unchanged.
Release notes: Fixed: The MTP cost-based draft width choice no longer mixes timings of different pass layouts and keeps what it learned when the number of active slots changes.
Code shape
runtime::round_passes. The copy that lived incrates/app/src/lib.rsis deleted and the app calls the owner. A test in the app fails if that call is removed.MAX_ROWS. No model file gained a branch.RoundError, and a refusal leaves the previous plan untouched.cargo fmtandcargo clippyare clean on what I touched.cargo clippyhas not been run on this head, so the lint count is unchecked.Duplication found or removed (
path:line): the packing loop incrates/app/src/lib.rsround_passesmoved tocrates/runtime/src/lib.rsround_passes. The duplicate scan reports no remaining candidates.What I ran
The PR head is
c3cdb34a6d3645fa4713ddcb922e02219c77f980, two commits on main648dd751d9ed25f9a18d8a404e5f08e3fb52e512: a test commit that pins the isolation, then the fix. The unit tests and the app test below ran on a tree whose four changed files are identical to this head's.FAIL-first on the production width code of main, with only the two new regression tests added: both fail,
batch_costs_keep_different_packings_separate(the two-pass layout got readings[0, 0, 0, 0, 0]instead of[3, 3, 2, 2, 1]) andbatch_costs_survive_alternating_slot_counts(the learned plain steps for 2 slots were[3, 3]instead of[0, 0]). Test rc is 101. With the fix the runtime library passes with 288 passed and 0 failed.Overflow boundary: with the row sum written as an unchecked addition,
round_packing_keeps_windows_and_the_slot_zero_pass_lastfails withattempt to add with overflow. The checked formpacked <= max_rows - npasses.App caller: with the call to
runtime::round_passesremoved from the app,round_passes_keep_each_drafts_hidden_rowsfails. With the call restored it passes.cargo check --workspace --all-targetscompleted on the node, rc 0. All host results were produced on Linux.GPU Evidence
An A/B of this head against its base, on a DGX Spark (NVIDIA GB10,
sm_121):Base is
648dd751d9ed25f9a18d8a404e5f08e3fb52e512and head isc3cdb34a6d3645fa4713ddcb922e02219c77f980. Each tree was built withcargo oxide build --arch sm_121 -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve-qwen38, and both builds finished. The model isnvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300. Both servers ran withBLOOMERY_DRAFT=mtp BLOOMERY_MTP_WIDTH=cost BLOOMERY_HOST_ROOM=96Gandbloomery-serve-qwen38 --parallel 4 --ctx-size 16896 --cache-ram 0. Each case sends 4096 prompt ids and 128 output ids at concurrency 2 or 4, with temperature 0 or 0.7 and seed 1741, on two corpora (code and English prose). The corpora ids hash the same in both arms. Base ran first, then head, in one lease, each server loaded once. The GPU clock cap was lifted for the measurement and restored afterwards. This is one pair per case, with no repetition.tok/sis the summed client throughput while every request was active. Delta is(head / base - 1) * 100[derived].The output token ids are the same in all eight cases: 24 requests with 128 ids each matched between base and head. Seven cases are faster and prose at concurrency 2 with greedy decoding is 2.05% slower. In that case head picks width 2 more often than base. With one pair per case I do not read any of these as a speed gain or a regression. The sampled cases propose only one to six drafts, so they say little about sampled MTP.
just gate-gpu-qwen38-servenot run: it needs the maintainers' workstation.just contrib-checkand the pre-push check set were not run on this head either. The comparison above is the only GPU run.What I ran into
This section does not block the PR.
cargo clippywas not run on this head.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.