Repository navigation
feat(mma_frag): predicate accumulator registers against a logical extent - #511
Merged
Merged
Conversation
Follows NVIDIA#474, which derived the layout. A tile shape rarely divides the problem, and the accumulator makes the mismatch awkward: each lane's four values are scattered across the tile, so clipping is not a contiguous prefix. Two lanes disagree about the same register index. At M = 9 against the 16-row tile, j 0 and 1 land on row `group` and are always inside; j 2 and 3 land on row `group + 8` and are inside only for group 0. So lanes 0..3 keep four registers and every other lane keeps two, which is 4*4 + 28*2 = 72 = 9 * 8 - the whole logical tile and nothing more. The predicate is per register, so it is returned as a 4-bit mask: a kernel tests one mask instead of recomputing bounds per store, and the warp stays convergent because every lane evaluates the same shape. `acc_mask_is_uniform` reports whether a lane is all-in or all-out, which is what decides whether an epilogue can take one unpredicated path. Masking cannot introduce a race: it removes registers from a bijection, so the surviving stores stay pairwise disjoint. Asserted rather than argued, by claiming each element and failing on a double claim. Verified against hardware with the destination prefilled with a sentinel, which is what distinguishes 'computed the right values' from 'suppressed the wrong stores': valid rows written: 72 (expect 72) wrong values : 0 padding clobbered : 0 Tests sweep every extent from 0x0 to 16x8 and assert the valid count equals rows * cols, so a wrong predicate surfaces as a wrong total rather than as missing output. Column clipping is covered separately because it behaves differently: columns come from `tig`, so a narrow extent removes whole lanes rather than registers. Signed-off-by: abder <[email protected]>
…he rebase The predication commit was written against a pre-NVIDIA#474 version of the module docs and its context hunks reverted two maintainer passages: the paragraph stating the accumulator mapping also applies to the bf16/tf32/s8 `m16n8` shapes, and the `crate::disjoint::DisjointSlice` cross-reference. The replacement text also linked `crate::thread::DisjointBlock` and `crate::thread::DisjointTiling`, which do not exist, breaking rustdoc under -D warnings. Restore the current main text; the additive predication section and its tests are untouched.
…otes Predication does not by itself keep a warp convergent: the mask is computed from straight-line expressions, but its value differs across lanes, so stores guarded on mask bits can still diverge exactly as any bounds check would. Say what the mask actually buys - fewer tests per store and a uniform fast path when `acc_mask_is_uniform` holds for every lane - instead of overclaiming convergence.
Collaborator
|
Thanks, landed with two maintainer doc commits on top: r
The six new predication tests, clippy, and rustdoc -D warnings are all clean. Closes no open issue. Merging |
nihalpasham
approved these changes
Jul 28, 2026
honeyspoon
pushed a commit
to honeyspoon/cuda-oxide
that referenced
this pull request
Jul 29, 2026
…t promise Exploratory work on gap #31 (89 graph FFI entry points, none wrapped). Graph replay is the largest measured win in the harness — a fixed ~1 µs per launch, 0.170/0.179/0.178 ms across FP16/INT8/W8A16 — and it is currently driven by raw FFI with `assert_eq!` on every status. Wraps the minimum useful slice: `begin_capture` -> `StreamCapture` guard -> `CapturedGraph` -> `GraphExec::launch`, all RAII, all returning `DriverError`. Two obligations the types now discharge: * Capture must be terminated even on the error path. The driver documents that an invalidated capture leaves the stream unusable until `cuStreamEndCapture` runs, and that a capturing blocking stream also makes the legacy null stream unusable. The existing raw-FFI code panics via `assert_eq!` between begin and end, which skips termination. `StreamCapture` terminates in `Drop`, so unwinding cannot poison the stream. Two hardware tests cover it: the stream is idle and usable after an abandoned capture, and can be recaptured. * Concurrent replay of one exec is not permitted, so `launch` takes `&mut self`. And one it cannot, now measured rather than assumed. A `GraphExec` outliving a buffer captured into it is undiagnosed and silently plausible: launch = Ok(()) sync = Ok(()) read = Ok(()) dst = [7, 8, 9, 10] (captured source was [7, 8, 9, 10]) The replay read freed device memory that still held the old bytes, so it "worked". No error at launch, synchronize, or read-back. Stream-ordered deallocation returning pages to a pool makes that the likely presentation, not a rare one, and it is the worst failure mode available: correct in testing, corrupt later. Because of that, `instantiate` being `unsafe` is probably the honest default; the module names the hole and the three ways to close it instead of choosing one. Findings worth keeping regardless of what happens to this code: * The doc's "89 FFI entry points" reproduces exactly as `grep -c "pub fn cuGraph"`. About 10 of those are `cuGraphics*` GL interop and some are `_v2` aliases, so unique true graph-API names are 83. There is no bindgen allowlist, so all of them really are reachable. * This crate resolves module-level intra-doc links against the *crate root*, because every module carries both a `///` on its `pub mod` line and `//!` docs in the file. `[CudaEvent]` works only because `event::CudaEvent` is re-exported. A new module whose types are not re-exported gets broken links that `rustdoc -D warnings` rejects — the same class of failure as upstream NVIDIA#511. Fixed by following the convention and re-exporting. Gates on nightly-2026-04-03: fmt, clippy --all-targets -D warnings, rustdoc -D warnings, doctests clean. `graph_capture` is 4 passed / 1 ignored (the ignored one is the deliberate use-after-free probe). `cargo test -p cuda-core` has one failure, `device_copy_derive_compile_pass`, which reproduces identically on an untouched `main`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #474, which derived the layout.
A tile shape rarely divides the problem, and the accumulator makes the mismatch awkward. Each lane's four values are scattered across the tile, so clipping is not a contiguous prefix — two lanes disagree about the same register index:
j0 and 1 land on rowgroupand are always inside;j2 and 3 land on rowgroup + 8and are inside only for group 0. So lanes 0..3 keep four registers and every other lane keeps two:4*4 + 28*2 = 72 = 9 * 8. The whole logical tile, nothing more.API
A 4-bit mask per lane, not a per-store bounds check — a kernel tests one mask, and the warp stays convergent because every lane evaluates the same shape.
acc_mask_is_uniformreports all-in or all-out, which is what decides whether an epilogue can take one unpredicated path.Masking cannot introduce a race
It removes registers from a bijection, so surviving stores stay pairwise disjoint. Asserted rather than argued: the test claims each element and fails on a double claim.
Hardware validation
Real
mma.syncon sm_86 with the destination prefilled with a sentinel — that is what distinguishes "computed the right values" from "suppressed the wrong stores":Tests
Every extent from
0x0to16x8swept, asserting the valid count equalsrows * cols— a wrong predicate surfaces as a wrong total rather than as missing output. Column clipping covered separately, because it behaves differently: columns come fromtig, so a narrow extent removes whole lanes rather than registers.12 tests,
clippy --all-targetsclean.