Repository navigation
gemm: a warp's code copy of the native NVFP4 walk reads eight rows' whole steps - #1005
Conversation
…he walk reads both operands' codes as stored
There was a problem hiding this comment.
Verdict: MUST_FIX: One new asynchronous copy uses a safety justification explicitly forbidden by R1.
Must fix
1. State the second copy's safety invariant locally
crates/gpu/src/gemm/nvfp4mma.rs:505 Kind B: R1's addendum explicitly rejects “as above” as a safety justification. This block delegates its source-bound and publication proof to another operation.
Write the proof while introducing the layout, so later edits can be checked at this copy.
Replace the comment with:
// SAFETY: wr1's aligned chunk is within its checked plane; st < STAGES, cr < 64 and
// cq < 4 select unique words in row cr + 64, read only after the copy wait and barrier.Non-blocking
⚠ Supply the numerical proof: crates/gpu/src/gemm/nvfp4mma.rs:117 permutes K positions within each scale block for both MMA operands. The “float sum order or precision” class requires an error model and gate-gpu-e2e count-pin output. Add those results; the reported kernel bands and equal greedy tokens do not establish that pin.
⚠ Identify the tested head and request command: crates/gpu/src/gemm/nvfp4mma.rs:1372 changes the timed kernel, but the PR body identifies the tested head only as “this branch” and omits the benchmark request-driver command. Record the full tested head SHA and that command with output so the GB10 results are reproducible and tied to the reviewed code.
Checked
Duplicates: tile_column replaces both local column mappings; no second owner found in gemm.
Complexity: tile_column has one conditional; the kernel bodies remain together.
Silent failure: changed row/column clamps pad tiles; live stores retain their bounds.
Tests: no gate tests changed. The bank-layout const assertion checks the revised copy mapping.
Gates: no tolerance relaxed; the unsafe ceiling decreases from 2841 to 2838.
Escape catalog: C1–C4 matched none.
Notes
Validation was static; GPU gates were not run by the validator.
Card check: needs-gpu. This pull request changes crates/gpu/src/gemm/nvfp4mma.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)
| $wq0.as_ptr().add($wr0 * $steps * 8 + at), | ||
| ) | ||
| }; | ||
| // SAFETY: as above, for the second weight row into row cr + 64 < TILE_ROWS. |
There was a problem hiding this comment.
R1's addendum forbids “as above”; state this copy's bounds, ownership and publication invariant here.
| // SAFETY: as above, for the second weight row into row cr + 64 < TILE_ROWS. | |
| // SAFETY: wr1's aligned chunk is within its checked plane; st < STAGES, cr < 64 and | |
| // cq < 4 select unique words in row cr + 64, read only after the copy wait and barrier. |
708b6f6 to
4ab8c96
Compare
There was a problem hiding this comment.
Since the last review: must-fix 1 is fixed at crates/gpu/src/gemm/nvfp4mma.rs:505. The second copy now states its bounds, ownership and publication invariant locally.
Verdict: CLEAN: The interdiff resolves the safety-comment finding and introduces no executable change.
Non-blocking
⚠ Numerical proof remains open: crates/gpu/src/gemm/nvfp4mma.rs:117 permutes K positions within each scale block for both operands. Supply the error model and gate-gpu-e2e count-pin output required by the “float sum order or precision” class. Kernel bands and equal greedy tokens do not establish that pin.
⚠ Tested-head and request-command evidence remains open: crates/gpu/src/gemm/nvfp4mma.rs:1374 participates in the timed kernel. The body identifies the tested head as “this branch” and omits the benchmark request-driver command. Add the full tested head SHA and the command with output to make the GB10 results reproducible.
Checked
Duplicates: 0 new items in the interdiff; dryer reported 0 candidate pairs.
Complexity: crapper flagged no functions; the interdiff changes only a comment.
Silent failure: 0 new sites; checked copy bounds, unique destinations and wait/barrier publication.
Tests: no tests changed; mutation check is not applicable. Static copy arithmetic covered all 256 threads and final half-steps.
Gates: no pins, thresholds or cases changed in the interdiff.
Escape catalog: C1–C4 matched none.
Notes
Validation was static; GPU gates were not run during this review. GPU evidence remains incomplete because the PR text lacks the tested head SHA.
Card check: needs-gpu. This pull request changes crates/gpu/src/gemm/nvfp4mma.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)
|
The review is done and the contribution check passed, so I'm merging this. |
Qwen3.8 FP4-Local의 긴 프롬프트 prefill에서 routed expert의 NVFP4 gemm을 DGX Spark에서 빠르게 하는 속도 PR입니다.
What and why
The routed FC1 (gate/up) and FC2 (down) kernels of the native NVFP4 walk in
crates/gpu/src/gemm/nvfp4mma.rsspent their time waiting on shared-memory copies. Each thread copied half a row's 16-byte chunk, so a warp'scp.asyncwrites landed on 16-way shared-memory bank conflicts.iandi + 8in bytei, the order the weight uses, so the walk reads both operands' codes as stored and the per-step repack is gone.tools/unsafe-ratchet.txt: thegpuunsafe block count goes from 2841 to 2839, the count the file now reaches.Prefill on Qwen3.8 FP4-Local at a 4096-token prompt is 10.469% faster with the same greedy output. Decode is unchanged.
Release notes: Changed: Qwen3.8 FP4-Local prefill and time to first token are about 10% faster on a DGX Spark, with the same greedy output.
Code shape
tile_columnbesidelive_rowsinnvfp4mma.rs; both callers use it.packed_pair) is deleted with its last use.gpuwent down, from 2841 to 2839.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none.What I ran
Speed
Model
nvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300, draft off. Each request is a 4096-id prompt and 128 greedy tokens from eight corpus windows 50,000 ids apart, after one lead-in. Base is upstream main02238d00df9b9c9ae6cc70b271d95b769150d8d8; head is this branch, each built from its own tree and run alternately for six rounds, three a side. Each cell is the median of three rounds. Greedy output is identical on every request.Build the head the same way, serve it with the same flags, and send the requests above, alternating the two trees. Ranges are "separate" when the three head rounds and the three base rounds do not overlap.
Prefill and TTFT p95 are resolved (resolution 0.500%). Decode is not changed by this PR; its row is inside the 0.500% the run can resolve.
Gates and tests
cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features gpu --release --bin gate_gemm BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_CARD=local BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case nvfp4_native BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_CARD=local BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case nvfp4_gate_up BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_CARD=local BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_gemm --case nvfp4_swiglu BLOOMERY_BOX_LOCAL=1 ./tools/box.sh 'bash tools/gate.sh --gpu --oxide --release -p bloomery-gpu --lib -- --ignored --exact gemm::nvfp4mma::tests::hw_native_activation_planes --nocapture'None of the three gate outputs has a FAIL line.
Hardware (if the change is for a machine)
The change targets the GB10 (sm_121a). The timed runs and the gates ran on a DGX Spark.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.