Skip to content

runtime::width: a slow start no longer fixes the width chooser's costs - #1095

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:spd-chooser-warmup
Nov 1, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:spd-chooser-warmup

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

MTP 폭 선택기가 서버 시작 직후 느린 구간에서 읽은 비용을 실행 끝까지 들고 가던 결함을 고쳤습니다.

What and why

The width chooser (runtime::width::Choosing) starts by reading every width's cost in a rotation, and those readings stay in each width's ring of recent costs. The first passes after a start can run slower than the rest. A width the gate does not hold is read only once per probe, so its median kept the slow start's readings for about 950 passes.

The chooser now keeps each width's median as the rotation left it. Once a width's median rests mostly on readings taken after the rotation and has left the margin_close band around the rotation's value, the rotation runs again, with every width started over as a probe does. The check runs once. All drafting seats share Choosing, so the fix applies to each of them. The change touches only crates/runtime/src/width.rs and adds no per-model or per-device code.

Release notes: Fixed: the MTP width chooser no longer keeps the costs it read during a slow server start.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none.

What I ran

Upstream base b8a8dcc4de75239bcca63563fdc7931c8750f336, PR head 679e181bcb190bdd70dc83ea5faad07d671c87a3.

Card and driver of the machine the tests ran on:

$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GB10, 595.84
$ nvidia-smi
Sun Nov  1 15:58:43 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| N/A   53C    P8              5W /  N/A  | Not Supported          |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Before the fix. The new test a_slow_start_is_read_again_once_it_ends counts the passes after a slow start until every width's cost equals its wall time, for a draft and a chain draft. Run against the unfixed chooser, it fails:

$ cargo test -p bloomery-runtime --lib width::tests::a_slow_start -- --nocapture
thread 'width::tests::a_slow_start_is_read_again_once_it_ends' panicked at crates/runtime/src/width.rs:2578:9:
the passes after the slow start until every cost is its wall, one draft and a chain draft: [Some(951), Some(951)], the bound 17
test width::tests::a_slow_start_is_read_again_once_it_ends ... FAILED
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s

After the fix. On the PR head, the whole runtime library suite passes, including the new test:

$ cargo test -p bloomery-runtime --lib
test width::tests::a_slow_start_is_read_again_once_it_ends ... ok
test result: ok. 314 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.72s

The new test also covers a start that is faster than the passes after it (the median leaves the band the other way), and it passes with a draft and with a chain draft.

Hardware (if the change is for a machine)

NVIDIA GB10, driver 595.84, CUDA 13.3. The change is host-side logic in crates/runtime; the tests above ran on this machine.

AI help

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

The chooser's first readings of every width come from the rotation at the
start, and the first requests after a server start can run slower than the
rest: on a DGX Spark, a start whose first two requests ran slow (prompt 2.14
and 2.00 s against 1.53 to 1.65 after) read every width's cost 16 to 22 %
high (costs=[38.48,47.10,57.08,66.64] against [33.18,39.34,47.50,54.78] in
a start that was not slow). The held width reads every pass and recovered
within the next request, but a width the gate does not hold reads once a
probe, three probe periods apart, and its median kept the start's readings
for about 950 passes: widths 0 to 2 kept them for the whole run, and the
next eight requests' windows verified 1 or 2 ids in 3 passes against 30 in
the run whose start was not slow.

Each width's median as the rotation left it is now kept until the width's
median rests on readings taken since, most of its ring. One that does and
has left the close band around the rotation's starts the rotation over:
every width is read again, its own median too. The check runs once and ends
without a restart once no median rests on the first rotation's readings. A
start that was not slow keeps its costs; a restart costs min_timings passes
of each width, once. A cost that moves for another reason before the check
ends, a longer context for one, restarts the rotation the same way; that is
intended, since the rotation's readings no longer price the widths either.

a_slow_start_is_read_again_once_it_ends: every wall 6/5 over the rotation
and the 74 passes after it, then 1; every cost is its wall 21 passes after
the slow passes end, for a draft and a chain draft (951 before). A start at
1 and passes at 6/5 after it leave the band the other way and take the same
21 passes.
@github-actions github-actions Bot added the host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset label Nov 1, 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 found in the recalibration state transitions.

Non-blocking

⚠ Validate decode timing: crates/runtime/src/width.rs:1453 restarts all widths when startup timing drift is detected. With full proposals, this adds one rotation of min_timings × (D::WIDTH + 1) calibration passes [derived]. Attach the dispatch path's same-lease just ab-decode comparison and just gate-runtime output for the reviewed commits. The supplied mock-clock test logs cite different commits.

Checked

Duplicates: 4 new items checked; no duplicate owner found. Dryer reported 0 pairs.
Complexity: Choosing::land rose 20 → 21 through the warm-up snapshot branch; no separate correctness defect found.
Silent failure: 2 new state/median guards followed; unavailable medians cannot decide the gate during refilling.
Tests: static mutation check: removing self.settle(k) at line 1298 leaves probe-only refresh, which the new 21-pass bound guards against. Both drift directions and both draft types are asserted.
Gates: no existing pin, threshold or test changed; FAIL-first output is supplied for the new regression.
Escape catalog: no pattern matched.

Notes

Static review; tests were not rerun. The PR contains no just gate-* run output, so GPU evidence is false.

🔨 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 cd7d880 into midagedev:main Nov 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant