Repository navigation
autotune: the race reads each weight from DRAM, as a step does, rotating past twice the card's L2 - #1164
Conversation
…ing past twice the card's L2 A step reads every other weight of the model between two reads of one, so each of its MXFP8 gemvs reads its weight cold. The race rotated over the signature's own weights only, so a signature whose weights fit in L2 (the 96, 128, 512 and 640 row projections of Qwen3.8) was timed warm. There the plain _mcol walk can beat the staged entry while it loses on the cold weights a step reads: at four columns the picker took plain for the 96 and 128 row weights, which in the decode graph ran 10 and 16 percent slower per launch than the staged entry they replaced. The rotation now spans twice the card's L2, read from the driver (CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE): the signature's own weights in name order, then whole windows of its rows cut from the other resident MXFP8 weights of its k (site::view), one weight at least and all there are when they span less. ROTATE_BYTES and ROTATE_MAX go; a large signature reaches the span with a few of its own weights, as it did before. The cost store keys a pick by the build, so a new build times again.
There was a problem hiding this comment.
Verdict: CLEAN: No reachable behavior failure or proven quality defect was found in the changed code.
Non-blocking
⚠ Validate the changed picker in the A/B: crates/gpu/src/autotune.rs:189. The reported comparison disables autotune on the head, so it bypasses the new rotation and its picks. Those picks select serving kernels at crates/gpu/src/q8f32.rs:3569. Run base and head with autotune enabled, using fresh cost stores, and attach the commands and output.
⚠ Cover a partial byte budget: crates/gpu/src/autotune.rs:463. Replacing cold.div_ceil(weight_bytes(rows, k)) at line 301 with floor division passes every current assertion, despite permitting a rotation shorter than cold. Add this assertion to the existing test to catch that boundary regression:
assert_eq!(rotations(&shapes, 3 * one + 1)[&(96, 2560)], [(0, 0), (3, 0), (1, 0), (1, 96)]);Checked
Duplicates: 5 new items checked; no duplicate owner found. Row views reuse site::view. No dryer pairs were available.
Complexity: crapper produced no results. Manual review covered tune and the new planner/device-view functions; growth is load-time selection logic.
Silent failure: 1 exclusion site followed; unsupported formats and widths are intentionally skipped. Driver and row-view errors reach the caller.
Tests: an independent model confirms that dropping the windows at line 302 fails the assertion at line 459. The floor-division mutant passes all current assertions in the rotation test; the proposed assertion catches it. Rust/GPU tests were not rerun.
Gates: no bands, tolerances or gate pins moved. The PR reports a passing MXFP8 gate on an RTX 5090.
Escape catalog: no patterns matched. Boundary windows, mixed widths, empty selections and window lifetimes were checked.
Notes
Dryer and crapper did not run because their Python modules were missing.
The PR does not report a FAIL-first run for the warm-weight defect.
Card check: gpu-evidence. This pull request changes crates/gpu/src/autotune.rs, crates/gpu/src/site.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)
| rotations(&shapes, 3 * one)[&(96, 2560)], | ||
| [(0, 0), (3, 0), (1, 0)] | ||
| ); | ||
| assert_eq!(rotations(&shapes, 0)[&(96, 2560)], [(0, 0)]); |
There was a problem hiding this comment.
Floor division passes the current rotation-test cases; add a partial byte budget to catch a rotation shorter than cold.
| assert_eq!(rotations(&shapes, 0)[&(96, 2560)], [(0, 0)]); | |
| assert_eq!(rotations(&shapes, 3 * one + 1)[&(96, 2560)], [(0, 0), (3, 0), (1, 0), (1, 96)]); | |
| assert_eq!(rotations(&shapes, 0)[&(96, 2560)], [(0, 0)]); |
|
The review is done and the contribution check passed, so I'm merging this. |
MXFP8 커널 선택 race가 L2에 남은 weight를 읽어 재던 결함을 고쳐, 실제 decode처럼 카드 메모리에서 읽어 재도록 했습니다.
What and why
The load-time race that picks a way for the MXFP8 gemv of four to eight columns timed a signature's weights warm. For small signatures (96, 128, 512 and 640 rows) the whole rotation fit in the card's L2, so a way was timed on weights an earlier launch had left there. A decode pass reads every other weight of the model between two reads of one weight, so each launch reads its weight from DRAM, and some picks that won the race lost in the pass.
The rotation now spans twice the card's L2 (read from
CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE): it takes the signature's own weights in name order, then windows of the signature's rows cut from other resident MXFP8 weights of the samek, until it is long enough. The margin rule and the default (--autotuneon) are unchanged. The first load takes longer (45 shapes measured, 1.596 s before and 2.465 s after on an RTX 5090) because the small signatures now rotate over more launches; a load that finds its picks in the cost store measures nothing (0.005 s).docs/serving.mdanddocs/research/kernel-picks.mdsay what the race reads now.Release notes: Fixed: the load-time kernel race for MXFP8 projections at four to eight columns times weights read from the card's memory, as a decode step reads them, so its picks hold in the real pass.
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": none. The row windows reusesite::viewandView(madepub(crate)incrates/gpu/src/site.rs) and the existingraw_device_attribute;ROTATE_BYTES,ROTATE_MAXandmcol_groupsare replaced byCOLD_L2andmcol_rotations.What I ran
Base
b96cfcc05ee8720a360ca7332665682df51e5a0c, headc45161da90800d1c219d88bcbfd64e8dc3d2acd8. The gate and the A/B run below are on the head. Model:nvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300(MODEL_FP4Lis a local checkout of it); SHA-256 of its files:Card:
Gate (MXFP8 gate and the
autotune::tests):The gate run had 745
PASSlines and noFAIL.a_rotation_reads_cold_bytes_of_its_rows_from_its_kis the new test of the rotation plan.Load picks (the real server, MTP draft on, one card, same command before and after):
Before (a load of the server without this change):
After:
End-to-end A/B (base runs the server with autotune on, head runs it with
BLOOMERY_AUTOTUNE=off; 4,096-id prompt, 128 generated tokens, two rounds each, after a warm-up;fp4l-mtpis one stream,fp4l-mtp-c2stwo). The server was started as above, with--parallel 2for the two-stream arm andBLOOMERY_AUTOTUNE=offfor the head arm, and each timed request was sent with:The two-stream arm uses
--count 2 --conc 2 --temperature 0.7 --seed 42.Differences between the arms point in both directions and stay within the measurement noise where ranges overlap. This PR fixes what the race measures and claims no speed gain.
Hardware (if the change is for a machine)
The gate, the load picks and the A/B ran on this card.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.