Repository navigation
fix(mir-importer): adapt shared pointers at ordinary call boundaries - #3
Conversation
Backported from NVIDIA/cuda-rust 927d462 (NVIDIA#1598) by nihalpasham <[email protected]>. Reuse the existing normalization helper under its current name and preserve its type and provenance checks for ordinary Rust calls. Build both non-inlined shared-memory helper variants in the workflow on main and bloomery, and document their call-boundary contract. Signed-off-by: nihalpasham <[email protected]> Signed-off-by: juliankang4 <[email protected]>
|
Thanks for this backport. We are moving bloomery off the fork, to depend on NVIDIA/cuda-rust directly. The upstream commit with this fix (927d462, NVIDIA#1598) also adds the cute verifier. On our crates it is quadratic in kernel size and runs on every scope, so We will work around the verifier in bloomery and move to upstream HEAD today, so this fix lands in bloomery. The verifier defect goes upstream as a separate PR. |
|
What we found so far on the slow build, so you do not have to start over. Where the time goes: two gdb stacks on Build times on the box (cold
The guard skips a scope that holds no CuTe semantic op. An indexed lookup in scope guard (dialect-cute/src/verify)--- ghosts.rs 2026-10-26 06:13:11.127219447 +0900
+++ cuda-oxide/cute-rs-preview/dialect-cute/src/verify/ghosts.rs 2026-10-26 07:00:55.183837939 +0900
@@ -150,7 +150,7 @@
}
/// Collect the closed set of operations allowed to carry semantic ghosts or metadata.
-fn all_high_level_semantic_ids() -> Vec<OpId> {
+pub(super) fn all_high_level_semantic_ids() -> Vec<OpId> {
let mut ids = tensor_semantic_ids().to_vec();
ids.push(crate::ops::copy::CuteStoreGlobalNoAllocateOp::get_opid_static());
ids.extend(gemv_semantic_ids());
--- mod.rs 2026-10-26 06:13:11.127219447 +0900
+++ cuda-oxide/cute-rs-preview/dialect-cute/src/verify/mod.rs 2026-10-26 07:00:55.183837939 +0900
@@ -52,7 +52,7 @@
use cfg::operations_by_scope;
use epilogue::verify_epilogue_story;
use gemv::verify_gemv_story;
-use ghosts::audit_cute_ghosts;
+use ghosts::{all_high_level_semantic_ids, audit_cute_ghosts};
pub use ghosts::type_contains_cute_ghost;
use mma::verify_smem_mma_story;
use pipeline::verify_pipeline_story;
@@ -297,7 +297,17 @@
verify_local_op(ctx, *operation)?;
}
audit_cute_ghosts(ctx, &all_ops)?;
+ let semantic_ids = all_high_level_semantic_ids();
for scope in operations_by_scope(ctx, module, &all_ops) {
+ // A scope with no CuTe semantic operation has no story to verify. Each story builds provenance
+ // facts, and `OrdinaryFacts::entries` scans the whole fact map for every store, so a large SIMT
+ // kernel would cost time quadratic in its size for nothing.
+ if !scope
+ .iter()
+ .any(|operation| semantic_ids.contains(&Operation::get_opid(*operation, ctx)))
+ {
+ continue;
+ }
verify_scheduler_story(ctx, &scope)?;
verify_pipeline_story(ctx, &scope)?;
verify_tma_story(ctx, &scope)?; |
|
Correction to my last comment: the verify time is cubic, not quadratic. The fixpoint rounds grow with the block count, and each round scans the whole fact map. 800 blocks: 248 s without the guard, 0.005 s with it. Filed upstream with the patch and a timing test: NVIDIA#1647. bloomery is moving to upstream 9df9e7c and will carry this one patch until upstream takes a fix. |
Summary
Backport the ordinary-call pointer adaptation from NVIDIA/cuda-rust commit
927d462eebe1ca2dde13439ef37c44184eadbb13(NVIDIA#1598) ontobloomery. A pointer fromDynamicSharedArrayretains shared address space 3, while a Rust helper's raw-pointer parameter uses generic address space 0. Without the adaptation, MIR call verification rejects the argument before code generation.Changes
emit_function_call, using the existingnormalize_foreign_pointer_argumenthelper under its current name. Pointee, mutability and pointer kind must still agree.examples-compileworkflow builds bothshared_memory_helpervariants (local-helperandcross-crate-helper) onmainandbloomery, both with#[inline(never)].This targets
midagedev/cuda-oxide:bloomery, whose previous pin is87bc951864b79f723b4da9c11fa229f5600aefcb. It does not overlap the tool-selection files in #2.Before merging, tag the current
bloomerytip aspin/87bc9518to preserve the previous pin.Testing
On a DGX Spark (NVIDIA GB10, driver 595.84 reporting CUDA driver API 13.3), using the pinned
nightly-2026-08-28toolchain (rustc 1.100.0-nightly e457a7b0d):87bc951864b79f723b4da9c11fa229f5600aefcb, both helper builds exited 101 withMirCallOp argument 0 type does not match callee signature.9 launches, 36 CTA data/barrier checks; the direct control reported the same count.cargo test -p mir-importer --lib foreign_pointer_argument:4 passed; 0 failed.Reproduce from
cuda-oxide/with the pinned toolchain:just check(full CI mirror; not run here).What I ran into
This does not block the PR. Full
just checkand Compute Sanitizer were not run here.Checklist
git commit -s). The commit attributes the upstream block and retains its original sign-off.