Repository navigation
autotune: the MXFP8 gemv of four to eight columns picks its way at load, on the model's own weights, by the margin on every repeat (#1151) - #1161
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the new cache gate silently discards directory-entry errors.
Must fix
1. Propagate errors while enumerating the cost store
crates/gpu-gates/src/bin/gate_mxfp8.rs:592 drops each ReadDir error. An error followed by a valid .costs entry still reaches the cache checks and can report PASS. This is a kind B silent-failure defect.
Propagating the error now keeps the new gate from accepting an invalid run. Replace .filter_map(Result::ok) with:
.collect::<Result<Vec<_>, _>>()?
.into_iter()2. Remove the single-use launch wrapper
crates/gpu/src/autotune.rs:324 introduces a seven-argument wrapper used only by race at line 279. It only constructs the existing launch arguments and forwards the call. This is a kind B unneeded element.
Inlining removes a function and leaves race within R12's two-screen limit. Delete launch, change the import to use cuda_core::DeviceBuffer;, and replace the rotation expression inside gpu.capture with:
ws.iter().cycle().take(launches).try_for_each(|&w| {
q8.enqueue_e4m3_gemv_way(
st,
E4m3GemvArgs {
w,
x,
m: sig.m,
out: GemvOut::TokenMajor,
y: &mut *y,
},
way,
)
})Non-blocking
⚠ Supply FAIL-first evidence: crates/gpu-gates/src/bin/gate_mxfp8.rs:651. The body shows passing runs, but no failing run for the new clauses. Change the split output offset to zero and separately bypass cached-pick validation; attach the failing gate output and the restored passing output. This establishes recurrence coverage before merge.
⚠ Supply timing for the changed dispatch: crates/gpu/src/q8f32.rs:3571. Each split adds one launch and another rows*k*33/32 logical weight bytes per affected projection per verify pass. The launch-count change has its owning bit gate; the body reports isolated race medians and equal completion tokens. An off/on verify A/B on a workload selecting split would establish the effect on serving time.
Checked
Duplicates/elements: 57 new declaration occurrences checked; no proven duplicate; one unnecessary wrapper above. Dryer produced no pairs because it did not run.
Complexity: no crapper results. Manually reviewed the added dispatch branches in e4m3_gemv, validation branches in Store::entry, and the capture/warmup/sample stages in new race.
Silent failure: 8 sites followed. Directory errors disappear as reported above; absent levers and picks use defined defaults; the replay clamp bounds work; invalid cache bytes remeasure or error; String formatting cannot fail; ignored test cleanup can leave its directory.
Tests: static mutation review only. Dropped per-repeat comparison, ignored installed picks, skipped cache validation, wrong split offset, omitted props, ignored lever override, and changed invalid-UTF-8 handling reach failing assertions or gate checks. CUDA tests were not rerun.
Gates: none relaxed or removed; no existing pin moved.
Adversarial checks: split windows preserve both layouts' bounds; corrupt picks are validated before indexing; empty/non-MXFP8 weight sets install the default rule.
Escape catalog: no matching patterns. No ledger lessons were in force.
Notes
Dryer and crapper did not run because their Python modules were missing.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/bench_picks.rs, crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_mxfp8.rs … and carries a gate run on the author's card, which counts as verified.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| let first = autotune::tune(gpu, &w, "gate_mxfp8", &store)?; | ||
| let second = autotune::tune(gpu, &w, "gate_mxfp8", &store)?; | ||
| let entry = std::fs::read_dir(&store_dir)? | ||
| .filter_map(Result::ok) |
There was a problem hiding this comment.
Propagate directory-entry errors instead of allowing the cache gate to pass after discarding them.
| .filter_map(Result::ok) | |
| .collect::<Result<Vec<_>, _>>()? | |
| .into_iter() |
…ad, on the model's own weights, by the margin on every repeat (midagedev#1151) One owner beside site.rs, bloomery_gpu::autotune. A site registers its bit-equal ways; the MXFP8 gemv at four to eight columns over rows the staged entries read has three (Mcol): today's rule, the plain _mcol walk, and the first four columns staged with the rest by the rule at their count. After the load and before any capture, GpuModel::autotune times each way on every resident MXFP8 weight of a signature (rows, k, m), rotating over the weights up to 512 MiB and 64 of them, five repeats with the ways interleaved. A way replaces the rule only when it is faster on every repeat and its median gain exceeds the larger repeat spread (runtime::autotune::winner). The picks are installed once on the card's launchers and never change while it serves. Each pick is kept in the cost store under the card, the driver, the build and the signature (Store::get_or_retime): a later load reads it and times nothing, and an entry that does not decode or names a way its signature does not race is timed again. The qwen38 seat takes --autotune on|off over BLOOMERY_AUTOTUNE, on by default; off runs today's rule with no timing and no store. The load prints an autotune pick line a signature and the wall, and /props' engine.autotune lists the picks. gate_mxfp8 runs every way in both layouts against the walk's bits, and the picker's miss, hit and bad entry on a store of its own. bench_picks forces each way the picker races, in place of the proxy pair at k - 128, on Qwen3.8's verify shapes.
f365a93 to
2b82d25
Compare
There was a problem hiding this comment.
Since the last review:
- Must-fix 1 fixed: directory-entry errors now propagate.
- Must-fix 2 fixed: the single-use launch wrapper is removed.
- FAIL-first evidence still open: gate_mxfp8.rs:652.
- Split-dispatch timing still open: q8f32.rs:3571.
Verdict: CLEAN: both previous must-fix items are resolved, and the interdiff introduces no proven defect.
Non-blocking
⚠ Supply FAIL-first evidence: crates/gpu-gates/src/bin/gate_mxfp8.rs:652. The body still shows only passing runs. Set the split output offset to zero and separately bypass cached-pick validation. Attach the failing gate output and restored passing output to establish recurrence coverage.
⚠ Supply timing for the changed dispatch: crates/gpu/src/q8f32.rs:3571. Each split adds one launch and another rows*k*33/32 logical weight bytes per affected projection per verify pass [derived]. The body has isolated race medians and equal completion tokens. Attach an off/on verify A/B on a workload selecting split to establish its effect on serving time.
Checked
Duplicates/elements: 0 new declarations in the interdiff; one wrapper removed. No new duplicate. Dryer supplied no pairs.
Complexity: crapper supplied no results. Inlining in race adds no branch; directory enumeration now collects errors before searching.
Silent failure: 2 paths followed. Directory-entry errors abort the gate. Launch errors abort capture and prevent a cache write or pick installation.
Tests: no assertions changed. Static mutation review: a zero split output offset fails the bit comparison; bypassed cache validation fails the corrupt-entry case. CUDA gates were not rerun.
Gates: no gate removed or relaxed; no pin moved.
Adversarial checks: an entry error after a valid cache filename still propagates; failure on a later rotated weight stops capture and reaches the caller. Launch arguments and order are preserved.
Escape catalog: no matching patterns. No ledger lessons were in force.
Notes
Dryer and crapper did not run because their Python modules were missing. Attached GPU evidence covers the previously reviewed head f365a93f; this interdiff was reviewed statically.
Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/bench_picks.rs, crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_mxfp8.rs … and carries a gate run on the author's card, which counts as verified.
🔨 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. |
모델을 올릴 때 MXFP8 gemv(4~8열)의 실행 방식을 그 모델의 실제 weight로 재서 고르고, 결과를 cost store에 저장해 다음 load에서 다시 쓰게 했습니다.
What and why
At load, after the weights are resident and before the graphs are captured, the Qwen3.8 seat times each MXFP8 gemv signature (rows, k, m for m = 4 to 8) on the model's own resident weights. The candidate ways are today's rule, the plain
_mcolwalk and, for m above 4, a split (the first four columns staged, the rest by the rule for that column count). A way replaces the rule only when it is faster on every repeat and its median gain is larger than the larger of the two spreads. A bad or non-finite sample is a named panic, and a cache entry that does not decode is timed again. The picks are kept in the cost store under the card, the build, the kernel and the signature, so a second load reads them and measures nothing.Refs #1151.
--autotune on|off(leverBLOOMERY_AUTOTUNE, default on) controls it; off keeps today's dispatch and opens no store./propsreportsengine.autotunewith each pick, its way and whether it was measured or stored.gate_mxfp8gains the clausesways.bits(every way, both output layouts, bit for bit against the column-by-column result) andautotune.miss,autotune.hitandautotune.bad_entry.bench_picksnow launches each way it races, so its MXFP8 candidates are the real ones.docs/serving.mdanddocs/research/kernel-picks.mddescribe the load step.Release notes: Added: the Qwen3.8 load picks the fastest way to run the MXFP8 gemv at four to eight columns on the card in use, keeps the picks in the cost store, and leaves the output unchanged;
--autotune offkeeps the fixed rule.Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).PIN(YYYY-MM-DD):and its reason.
cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": the gate's own forced-way bench is gone andbench_picksis the one bench for the MXFP8 ways (crates/gpu-gates/src/bin/gate_mxfp8.rs,crates/gpu-gates/src/bin/bench_picks.rs).Store::get_orandStore::get_or_retimeshare one body,Store::entry(crates/runtime/src/costs.rs:442). The staged-kernelkmultiple has one owner,STAGED_K(crates/gpu/src/q8f32.rs:1576), and the weight size comes fromplanes::Format(crates/gpu/src/autotune.rs:244).What I ran
Upstream base
c446bc7420e365a0b15d1181fa7efc20a723f5af, PR head2b82d258412c9a7b7abbc3df5d2398fc5bd5058d.Static checks (the clippy ratchet lint with the workspace feature set,
tools/lint-ratchet.txt):GB10 gate and unit tests. The card and driver:
On the PR head,
just gate-gpu-mxfp8fails with each of two edits to the code and passes once they are undone. First the split's trailing columns written at output offset 0 (WindowMut::<f32>::of_mut(y, 0, y.len() - at)incrates/gpu/src/q8f32.rs), then the cached-pick check bypassed (let keep = |_: &[f64]| true;incrates/gpu/src/autotune.rs):bench_picksforces each way that the picker races and compares the bits against the other ways:Real load of Qwen3.8 FP4-Local with MTP,
--autotune off, thenonover an empty cost store, thenonagain over the same store, each followed by one greedy completion (96 tokens, temperature 0). Model:nvidia/Qwen3.8-Flash-Next-FP4-Local, revisionb9ce18a6887e18c089fdea8509a33e63429a3300(nvidia__Qwen3.8-Flash-Next-FP4-Local/b9ce18a6887e18c089fdea8509a33e63429a3300, 32 files, every file checked against itsSHA256SUMS).$MODELSholds that folder,$FEATURESis the feature list intools/release/build.sh.req.jsonholds the prompt" ".join(f"Paragraph {i}: the river carries silt to the delta, where farmers plant rice in the wet season and wheat in the dry one." for i in range(40)) + "\nSummarize the farming pattern in three sentences:"withn_predict96,temperature0,cache_promptfalse andreturn_tokenstrue.On the GB10, the loads and the picks that moved off the rule (
rule_usis today's rule,way_usthe picked way, microseconds):On the RTX 5090, the card and driver:
The loads and picks:
Hardware (if the change is for a machine)
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.