Skip to content

width: a losing chain probe runs one pass, and the diagnostics carry the gate rates - #975

Merged
juliankang4 merged 5 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-dfr-width-gate
Oct 29, 2026
Merged

juliankang4 merged 5 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-dfr-width-gate

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

MTP 폭 gate가 손해인 넓은 chain probe에 연속 4번의 verify를 강제하던 결함을 고치고, 진단 줄에 폭별 gate 비율과 id당 walk 비용을 추가합니다.

What and why

With a chain draft (MTP) under BLOOMERY_MTP_WIDTH=cost, a probe of a width past the open gate restarted that width's cost readings at every probe. The width then ran until it held min_timings readings again, so a probe that loses still forced four verify steps in a row. A probe now refreshes the means of the positions past the gate, as before, and restarts its cost readings only when the refreshed profile would move the gate at the held median or at the new reading. A losing probe is one verify step. The held median alone cannot move the gate against a new, slower wall.

The mtp width, mtp summary and draft summary lines now also print the gate rate of each width on the recent windows (rates=) and the estimated walk of one id (walk_ms=), so the chooser's decision can be read from the log. The five checked-in schemas and their docs follow the new lines.

The change is in the host chooser (crates/runtime/src/width.rs) and the record writer (crates/gpu-gates/src/record.rs). No kernel changes.

The end-to-end A/B below shows no speed change; the change removes forced verify steps and adds diagnostics, and it claims no speed-up.

Release notes: Fixed: a losing chain probe under the MTP width chooser runs one verify step instead of four, and the width diagnostics report the gate rates and the per-id walk cost.

Code shape

  • No second copy. The rates come from the chooser's existing gate_rate; the diagnostics call it instead of copying its arithmetic.
  • Model code holds only architecture facts. The change is in the common chooser and the common record writer; no model file changed.
  • Dead code is gone. The chain-only start_over call in the probe path is removed; the module doc describes the new rule.
  • No silent failure. Unread costs and rates print as -, as before; nothing is defaulted.
  • Comments state what is true now. The new doc comments describe the fields as they stand.
  • No relaxed gate. No band, tolerance or lint moved.
  • 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

Unit tests, before and after. The two new tests were added first and run against the old code:

cargo test -p bloomery-runtime width::tests::

Head ee7593632f11f368d1e335c74ebaa5a2b6909858 (tests added, old chooser):

assertion `left == right` failed: the losing probe ran again
  left: [4, 4]
 right: [4, 3]
test width::tests::a_losing_chain_probe_does_not_restart_its_cost ... FAILED
test width::tests::gate_diagnostics_include_the_rates_and_walk_cost ... FAILED
test result: FAILED. 33 passed; 2 failed; 0 ignored; 0 measured; 264 filtered out

A third case, a refreshed profile that pays at the held median but loses at the new wall, hit this assertion on edfcc20b398b7cd7a56229bea04f3ea189c62c9e before its fix:

assertion `left == right` failed: the stale median moved the gate
  left: 3
 right: 2

Head b1ee5a59870321a13430c2347c3c217b6b84c147:

test width::tests::a_losing_chain_probe_does_not_restart_its_cost ... ok
test width::tests::gate_diagnostics_include_the_rates_and_walk_cost ... ok
test result: ok. 35 passed; 0 failed; 0 ignored; 0 measured; 264 filtered out

The record writer's test, on a GeForce RTX 5090. Its first run on b1ee5a598 stopped on the expected line, which lacked the CSV brackets; the last commit fixes the test expectation:

bash tools/gate.sh --oxide --release -p bloomery-gpu-gates --features gpu --lib -- record::tests::
b1ee5a598: test record::tests::checked_in_schemas_are_current ... ok
b1ee5a598: test record::tests::width_records_include_gate_rates_and_walk_cost ... FAILED
c42284d35: test record::tests::width_records_include_gate_rates_and_walk_cost ... ok
c42284d35: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 213 filtered out

Serve gate on the same GeForce RTX 5090 at c42284d35e496055d23432a6ca2c885a0afca036, the Qwen3 fixture, lookup arm (the arm that reaches the common chooser and its cost mode):

bash tools/gpu-gate.sh generate_qwen3moe --place gate --tokens "$REF_TOKENS" -n 16 > "$width_gate_dir/gen.log"
bash tools/gpu-gate.sh gate_qwen38_serve --arm lookup --gen "$width_gate_dir/gen.log" --prompt "The capital of France is" --ids "$REF_TOKENS" --dir "$width_gate_dir/lookup"
check lookup_cost_0_ids_are_draft_off: PASS
check lookup_cost_1_ids_are_draft_off: PASS
check lookup_cost_slots_take_turns: PASS
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 20 s (exit 0)

Real chain MTP on an NVIDIA GB10 (driver 595.84, CUDA 13.3), base 4c549a477835d471929aa3c04718062488864d3b against head c42284d35e496055d23432a6ca2c885a0afca036, one bloomery-serve per revision with the MTP draft read from the same checkpoint folder. Model nvidia/Qwen3.8-Flash-Next-FP4-Local at revision b9ce18a6887e18c089fdea8509a33e63429a3300. Prompt 4096 ids, 128 generated tokens, 8 windows, one request at a time, three rounds per revision after a warm-up, run in the order base, head, head, base, base, head:

env -u BLOOMERY_MTP_DRAFT BLOOMERY_DRAFT=mtp BLOOMERY_HOST_ROOM=96G BLOOMERY_MTP_WIDTH=cost ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896

Greedy output was equal on every request. Every difference is inside the run's spread, so the A/B shows no speed change in either direction.

metric base head difference ranges overlap
code-fn decode tok/s 58.2762 58.2228 -0.091 % yes
code-fn prefill tok/s 2420.47 2420.6 +0.005 % yes
code-fn TTFT p95 ms 1698.75 1698.58 +0.010 % yes
prose-en decode tok/s 42.0397 41.9903 -0.117 % yes
prose-en prefill tok/s 2496.19 2494.82 -0.055 % no
prose-en TTFT p95 ms 1646.82 1647.82 -0.061 % yes

The new fields on a real run, from a head server log:

mtp width windows=78 kept=[40,26,12,0] widths=[0,25,52,1] e=1.641 gate=2 costs=[32.92,39.01,43.31,50.12] a=[0.444,0.349,0.083] rates=[0.030375,0.036135,0.036741,0.036849] walk_ms=0.042 closed=0

AI help

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

@github-actions github-actions Bot added 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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 29, 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 reachable behavior failure or proven quality defect was found in the changed code.

Non-blocking

⚠ Complete the hardware evidence: crates/runtime/src/width.rs:1233. The PR supplies gate output and an A/B table, but omits the nvidia-smi line and the timed client command. Attach both with their output to satisfy CONTRIBUTING.md and make the GB10 comparison reproducible. The submitted evidence does not qualify for gpu-evidence.

Checked

Duplicates: 5 new functions checked; none duplicated. Dryer reported 0 runtime pairs; gpu-gates was outside its scan and was checked manually. Rate calculation reuses gate_rate; record formatting has one shared owner.

Complexity: Choosing::land rose 19 → 20 through an added condition on the existing probe-reset branch. Gate decisions remain at the existing owner.

Silent failure: 2 unread-rate paths followed through the record writer; absent readings remain None and print -. Invalid walls and probabilities retain named errors.

Tests, static mutation review: restoring the early reset at width.rs:1641 breaks the losing-probe row assertion; dropping the held-median check at line 1233 breaks the stale-median assertions. Replacing gate_rate with mean-profile rate at width.rs:1135 breaks the diagnostic-rate assertion. Omitting either field in record.rs:3387 breaks the record assertions.

Gates: no tolerance, threshold, lint level or test was removed or relaxed. FAIL-first output is supplied for the new runtime tests; no PIN moved.

Adversarial checks: a slower probe cannot promote the stale median while its replacement warms; truncated proposals stay bounded by the returned length; interrupted flights are discarded; zero-width diagnostic reads avoid the drafted-rate path.

Escape catalog: C1–C4 have no matches. The added recipe preserves failures through &&.

Notes

Tests and mutation effects were reviewed statically; builds and hardware runs were not repeated.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/record.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 7144a79 into midagedev:main Oct 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant