Repository navigation
perf(cute): speed up the CuTe verifier's provenance analysis - #1648
Conversation
`OrdinaryFacts` kept one flat map keyed by (value, field path), so `entries(value)` scanned every key in the map. The ordinary plumbing and the poison pass call it for every cast, aggregate, store, load and block argument of a scope, which made each sweep quadratic in the scope's size. Key the facts by SSA value first and by field path second. `entries`, `at_path` and `copy_entries` now touch only the named carrier, and `copy_entries` still forwards a snapshot of the source taken before the copy. The shared-MMA use closure walks the nested map and tests scope membership through a set instead of a linear search. Signed-off-by: juliankang4 <[email protected]>
…tions The scheduler, pipeline and shared-MMA stories built their provenance facts for every scope, including every function with no CuTe operation at all. Each analysis seeds every integer value of the scope, so this cost was paid for every ordinary kernel. Return before building the facts when the scope holds no operation of the story's family. Every check in those stories starts from such an operation, so a scope without one was already accepted after the analysis; consumer-only (malformed) stories still reach their checks because their operations belong to the family. Signed-off-by: juliankang4 <[email protected]>
Seeding gives every factless integer value an origin that names the value itself (`Unknown`, and `Scalar` for shared MMA). Propagation merges those origins through block arguments and closed local cells, so a value's set grew with the length of every chain that reaches it, and each sweep of the fixed point copied the grown sets: verification time grew with the cube of the scope size. Consumers read a set only through its size, its sole origin, or whether it holds a given semantic origin, and they skip opaque origins when walking a set. Two opaque origins therefore report a merge exactly as any larger number does. `insert_path` now drops a third one, through a `CarrierFact` trait that each family's fact type implements. Path presence and semantic origins are unchanged, so every accept or reject decision and the diagnostic each consumer reports stay the same. Tests cover the cap, the snapshot copy, a scheduler state carried through 48 blocks and cells, and the rejection wording for cursors that merge one to eight unrelated values. Signed-off-by: juliankang4 <[email protected]>
Every load and store that forwards provenance through a closed local cell called `local_cell_is_closed`, which walks all uses of the cell and its aliases. A cell with N accesses therefore cost N walks of N uses on every fixed-point sweep, so verification time grew with the square of the number of accesses to one cell. The verifier does not change the IR it reads, so a cell's closedness is fixed for the whole analysis. `LocalCells` walks the alias graph of each `mir.alloca` in the scope once, and the scheduler, pipeline and shared-MMA fact builders, the shared-MMA use closure and the epilogue plumbing check look cells up there. A cell allocated outside the scope is still walked on demand, so every answer is the one the walk gives. The ordinary plumbing and the poison pass also read each incoming edge's successor operands once per block instead of once per block argument. A new test compares the table with the alias walk for closed, aliased and escaped cells, with and without their allocations in the scope. Signed-off-by: juliankang4 <[email protected]>
|
Tested on bloomery, a crate of large SIMT kernels with no CuTe operation, on its own box. Cold release build of one binary: 9df9e7c alone did not finish in 1700 s; with this PR, 480 s (388 s at 0143af5, before #1598). The PTX of 809 kernel entries is identical to a build that skips the verifier in scopes without CuTe operations. A block-chain probe with no CuTe operation verifies in 0.006 s at 800 blocks and 0.050 s at 8000. |
…used by name without it; host flags generated per triple tools/oxide-backend.sh applies tools/oxide-backend/cuda-rust-1648.patch to a copy of the pin's checkout, builds the backend and records the patch's sha256 in PROVENANCE; tools/oxide-host.sh checks it before every cargo oxide build and writes .cargo/cuda-oxide.toml's flags from .cargo/config.toml's table for the target triple, with the llc major check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…used by name without it; host flags generated per triple tools/oxide-backend.sh applies tools/oxide-backend/cuda-rust-1648.patch to a copy of the pin's checkout, builds the backend and records the patch's sha256 in PROVENANCE; tools/oxide-host.sh checks it before every cargo oxide build and writes .cargo/cuda-oxide.toml's flags from .cargo/config.toml's table for the target triple, with the llc major check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: nihalpasham <[email protected]>
|
/ok to test 42c30cd |
|
Thanks, indexing At |
What This PR Does
Speeds up$O(N^3)$ to linear $O(N)$ time without changing any accepted/rejected kernel or diagnostic:
dialect-cute's whole-module semantic provenance verifier fromcfg.rs,scheduler.rs,pipeline.rs,mma.rs):scope_has_anyskips building fixed-point provenance tables when a function has no operations from that semantic family.provenance.rs): IndexesOrdinaryFactsasHashMap<Value, HashMap<Vec<u32>, HashSet<F>>>soentriesandcopy_entrieslook up a carrier in(Value, path)entry in the function.LocalCells& Capped Opaque Facts (provenance.rs): Precomputeslocal_cell_is_closedonce permir.allocain the scope and keeps at most2opaque (Unknown/Scalar) facts per path (sufficient to triggerlen() != 1merge rejection without unbounded set growth).Verification
cargo test -p dialect-cute --all-targets: 101/101 PASS (93lib tests +global_store,public_paths, andsm100_attention).just fmt-check,cargo clippy -p dialect-cute --all-targets -- -D warnings, and repository guards: PASSCloses #1647