Repository navigation
width: the MTP width gate rates recent windows, and a width it left comes back once it pays - #846
Conversation
The cost chooser could hold a narrower gate for a server's life after a slow stretch of the wider width's readings. Three things kept it there: an open probe's reading only joined its width's median of eight, so one reading a probe could not move it; the probes took the widths in turn, so the width the gate left came after the plain step and the narrower width; and a chain draft held at the narrower width never reached the wider width's last positions, whose means kept what they last heard. A probe whose reading, put in place of its width's median, would move the gate now starts that width's readings over while open as it already did while closed, and the gate decides on `min_timings` readings taken since. A move of the gate starts the probe period over, and its first probe re-reads the width it left. A chain draft's width past an open gate's starts over at every probe, together with the means of the positions the gate's width does not reach.
The gate rated each width by `E(k)` over the mean profile, the product of each position's mean `p_i`. A draft's windows are not alike: a sure window is likely at every position and an unsure one unlikely at every one, so the mean of the products is above the product of the means, and each unsure window is cut to fewer rows than the gate's width. The mean profile missed both and rated the wider widths low; an MTP draft on code moved between widths 3 and 2 from one run of the same requests to the next, decoding slower on the runs that took 2. The gate now rates a width over the last `1 / calibrate` windows that filled their room: the rows they keep over the walls they cost, a chain draft's windows each verifying the width it cuts to with the walk of the gate's width paid. A window past the positions it reached is rated by the mean conditional on the ids before it. A chain draft's walk of one id is read off the passes a window cut below its walk. A window's own cut still rates each width at its own cost: the walk past a width is spent whatever the pass verifies, and charged to every width alike it would rate the wider widths up and keep windows wide that pay cut. A chain draft's gate whose windows mostly cut below it gives its seat to a narrower gate that rates as high, since those windows walk its width for nothing; otherwise a move still needs the margin. Rated over the recent windows, the gate can move between open widths faster than a probe period. Such a move now keeps the period and every width's reading age; only an open or a close starts the period over and sends its first probe to the side it left. Restarting the period at each move let alternating requests hold every probe off, and pointing each probe at the width just left could keep the other costs stale. A calibration step too small for its windows to be held is refused by name when the chooser is built.
There was a problem hiding this comment.
Verdict: CLEAN: I built failure paths for the chooser's new state transitions and found each one blocked; the open points are questions about evidence.
Non-blocking
⚠ The pushed head was not measured end to end: the PR body says the runs used 3126f6a, and width.rs changed after it (probe period kept across moves, gate_rate, the guard). The fp4l-mtp prose-en arm already reads -1.059% with separate ranges. Please re-run that arm on 60d87fc, or say why the later edits cannot move it.
⚠ A chain draft's probe of a width past the gate now costs more than one pass: width.rs:1611 calls start_over(k), so min_timings (4) consecutive passes are forced to the wider width and the gate is frozen, once per probe_every (64) passes. Term [derived]: 3 extra forced wide passes per 64, plus 4 passes with no gate decision, against 1 pass before. A timed A/B on a chain draft (BLOOMERY_MTP_WIDTH=cost against fixed) is the proof the change class asks for.
⚠ The PR body leaves two checks unrun: just contrib-check and the lint-count ratchet. Run both before merge.
Checked
- Duplicates: 9 new items checked (
recent,cut_of,gate_rate,decided,moves_on,start_over,walk,before/upto, test helpers), none duplicated.cut_ofreplaces the body ofcut;start_overreplacesTimings::restartand thewarm.push_backpair. dryer: 0 pairs. - Complexity:
decidedis new at 18 (one loop, one decision match).proposerose 29 to 32 by one branch (the chain probe at 1611); I found no better owner. - Silent failure: 5 sites followed, each guarded:
walk.median().unwrap_or(0.0)bylen >= min_timings;(f.walked - f.width)byKind::Cutneedingk < walked;learnwrites byn <= WIDTH;cutkeeps its old fallback; a step too small gets a namedWidthError::Rule. - Failure scenarios built and blocked: a window shorter than the gate;
walk_msstill 0 early; a gate frozen bywarm; a probe that moves the gate while open. - Hot path: the decode step.
decisionallocates nothing. The loop is about W × R × W² flops per filled proposal [derived, defaultcalibrate0.05], microseconds against a pass of milliseconds. - Tests, mutation:
a_chain_gate_inside_the_margin_holds_against_noiseturns red if2 * cut > recent_lenis dropped.short_requests_hold_the_gate…andalternating_requests_still_reread_every_costturn red on their mutants (the PR shows both). - Gates: no band, tolerance or lint moved. Escape catalog: none matched; no shell file changed.
Notes
- No
just gate-*output is in the PR body, so I mark GPU evidence as absent; the change is host code only.
🔨 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 폭 선택기가 느린 구간 한 번 때문에 좁은 폭에 머무르던 문제와, 짧은 요청마다 폭을 잘못 줄이던 문제를 고칩니다.
What and why
The cost chooser for MTP draft widths (
BLOOMERY_MTP_WIDTH=cost) could hold a narrower gate for a server's whole life after one slow stretch of the wider width's readings, and a draft on code moved between widths 3 and 2 from one run of the same requests to the next. This PR changescrates/runtime/src/width.rsin two commits.The first commit lets a width the gate left come back. An open probe's reading now starts its width's readings over when, put in place of the width's median, it would move the gate. Opening or closing the gate starts the probe period over and sends its first probe to the width it left. A chain draft's width past the gate's starts over at every probe, together with the means of the positions the gate does not reach.
The second commit rates the gate over the last
1 / calibratewindows that filled their room, instead of over the mean profile. A draft's windows are not alike: a sure window is likely at every position and an unsure one unlikely at every one. The mean of their products exceeds the product of their means, so the mean profile rated the wider widths low. Each window's own cut still rates each width at that width's own cost, because the ids a chain draft walked past a width are spent whatever the verify step checks, and charging them to every width would rate the wider widths up. A chain draft's gate whose windows mostly cut below it gives its seat to a narrower gate that rates as high.Rated over the recent windows, the gate can move between open widths faster than a probe period. Such a move keeps the probe period and every width's reading age. Restarting the period at each move let requests that alternate quickly hold every probe off, and pointing each probe at the width just left could keep the other costs stale.
The gate keeps those recent windows in buffers sized from the calibration step. A step too small for its windows to be held is refused with a named
WidthError::Rulewhen the chooser is built.Release notes: Fixed: The MTP width chooser no longer stays at a narrower width after a slow stretch, and it holds the width that pays on short requests.
Code shape
gate_ratecomputes a window's wall once, and the two single-call helpers it used are gone.walkedargument ofrateandbestand the two single-call helpers are removed.WidthError::Rule.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.cargo clippy -p bloomery-runtime --all-targets -- -D warningsis clean on that commit.Duplication found or removed (
path:line), or "none": none found.What I ran
Head
60d87fce435fc945dfc9c48b1771a31f5db11a5don main5b8619efc3066c720f7528c0401c2c4c648df9b5. The end-to-end runs below measured3126f6a79bcb0471f3c902364b49661ce52354caon mainc343a6292046c4e1575bb2632fde17f4b9e4844b. The pushed head differs from the measured one only incrates/runtime/src/width.rs: the construction guard, the singlegate_ratewall computation, the probe period kept across moves between open widths, and comments. I did not repeat the end-to-end runs on the pushed head, so the probe timing after a move between open widths is not measured end to end.Unit tests and clippy ran on
bff5b22d873377d57e1d331d490add9748fef94d, which differs from the pushed head only in the wording of one test doc comment (crates/runtime/src/width.rs, three lines):cargo test -p bloomery-runtime --lib width:::test result: ok. 33 passed; 0 failed.cargo clippy -p bloomery-runtime --all-targets -- -D warnings: finished with no warnings.FAIL-first, with the new tests on the code they guard:
short_requests_hold_the_gate_and_cut_what_does_not_pay(24 requests of 128 positions each, repeated withbegin) fails when the walk is charged to every width alike:0.9860 of the rate of the run that pays,test result: FAILED. 0 passed; 1 failed. With the fix it passes.undefined_input_is_a_named_error, with the added tiny-calibration cases, fails without the guard:attempt to multiply with overflowatcrates/runtime/src/width.rs:982,test result: FAILED. 0 passed; 1 failed. With the fix it passes.alternating_requests_still_reread_every_costfails when every move between open widths restarts the probe period:the plain step re-read at pass None, width 3 at pass None: the bound is pass 196,test result: FAILED. 32 passed; 1 failed. With the fix it passes.End to end,
fp4l-mtpandfp4l-offon the FP4-Local checkpoint,mainagainst the measured head, greedy output of 128 tokens equal in both runs, decode tok/s @ 4096-id prompt, n=128, one concurrent request, three rounds after one discarded lead-in round, eight windows:The medians are the middle of three rounds. In the
fp4l-mtpprose-en arm the three head rounds all lie below the three base rounds (the highest head round is 39.89 and the lowest base round is 39.97), so I am not claiming that arm is unchanged. Prefill tok/s and TTFT p95 moved by 0.492% or less in every arm.This change is host code only (
crates/runtime), so there is no PTX or device-path comparison.Hardware
One DGX Spark. Model:
nvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300, with the MTP draftMTP/mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguffromunsloth/Qwen3.8-Flash-Next-GGUFat revision766911a6b7369840a91dbcd95f9f997acaab6cd6. The prompts come from two token files,code-fn(SHA-2567520b471436fb307e91ee22640ad8100701d48e63e3da7de9160b705b92915d1) andprose-en(SHA-256d10c7044df8884fdd200304604772d81a4b56a228f802d5f05db724b245ef77a).Reproduction, per arm and per window (the offsets are 0, 50000, 100000, 150000, 200000, 250000, 300000 and 350000, after warm-up requests at 400000 and 404096; the base and head servers alternate, each restarted for its own round):
Send one request per window: a 4096-token prompt, 128 generated tokens, temperature 0, one request at a time.
For
fp4l-offthe server runs withBLOOMERY_DRAFT=offand without the MTP variables.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.