Repository navigation
Make example CI compile times flat and predictable (165s tail examples to ~2s) - #1198
Merged
Merged
Conversation
…crate smoketest routed the flag through global RUSTFLAGS, which re-keys every unit in the shared CARGO_TARGET_DIR: the one example rebuilt a full second dependency tree (~163 crates, ~192s of CPU, 165s wall on the CI runner) and also relinked the backend dylib in place, taxing the next example in line with the flip-back. The issue #343 guard only needs the flag on the example's own crate: MIR inlining rewrites the caller, and the kernel caller lives in the leaf. Carry it there via cargo's profile-rustflags feature; the generated .ll keeps the un-inlined DisjointSlice::len pattern verbatim (verified by diff against a wrapper build that flagged only the leaf), and the example's smoketest slot drops from 165s to ~1s. The NOINLINE_MIR / EXTRA_RUSTFLAGS machinery in smoketest.sh is deleted, replaced by a policy note; per-example rustc flags belong in the example's manifest.
The backend dylib's sha256 becomes the global backend-identity cfg for every application unit, so ambient flags that change the backend's bits fork a parallel cache universe for the entire application dependency tree, and because the freshness build has a single cache slot, alternating flag sets relink the dylib on every transition (smoketest's per-example RUSTFLAGS lane hit both failure modes). Pin CARGO_ENCODED_RUSTFLAGS to the empty string for the backend build: the empty-but-set value is cargo's highest-precedence flag source and resolves to zero flags, which also silences CARGO_TARGET_<TRIPLE>_ RUSTFLAGS and config-file [build]/[target.*] rustflags, sources that env_remove cannot reach. Print a one-line note when ambient flags are present so the asymmetry with application builds (which keep honoring them) is visible, and point at the CUDA_OXIDE_BACKEND escape hatch for custom backend builds.
…l-lib
Each example workspace committed its own Cargo.lock at a different point
in time, drifting into 34 distinct dependency resolutions across 219
examples (syn x6 versions, zerocopy x7, memchr x4, ...). Cargo keys its
cache on the resolved dependency subtree, so under CI's shared
CARGO_TARGET_DIR the first example in run order with each resolution
recompiled a private variant of the whole shared chain, bindgen re-run
over cuda.h included. That is 19 of the 25 examples that ran 15-68s
against a 2s median.
Re-resolve all 221 locks in one sweep (34 resolutions collapse to 8; the
8 survivors are genuinely different trees like tokio/rayon/cutile that
still share the common chain) and add scripts/sync-example-locks.sh:
--check CI gate, runs before any toolkit install: one version per
crate per semver range across all locks (source-aware, so a
git-rev drift is also a conflict), and unique local-crate
(name, version) across workspaces
--bump cargo update sweep over every lock (skips git-pinned locks)
--align precise-pin drifted locks to the majority; never touches
git pins
The uniqueness rule exists because the sync exposed a latent linkage
bug: cross_crate_embedded and cross_crate_kernel each nested a different
crate named kernel-lib v0.1.0, and cargo does not key workspace-member
cache slots on the manifest path. Once the lock sync made their
closures identical, both aliased one slot and cross_crate_kernel linked
the other example's library (E0425 on the macro-generated items). The
embedded example's crate is now embedded-kernel-lib, and the gate
rejects the pattern.
smoketest already builds the backend once up front, but every example invocation still re-ran cargo-oxide's backend freshness check (a cargo build in the backend workspace, ~1s each on CI runners, ~4 minutes across 219 examples). Export CUDA_OXIDE_BACKEND after the one-time setup so discovery short-circuits before any cargo call; this also means one run tests exactly one backend even if its sources change mid-run. An externally-set CUDA_OXIDE_BACKEND is honored as-is, and a missing path falls back to per-invocation discovery.
The cargo-deny SPDX gate rejects source files without it. Also make usage() print the doc block by scanning to the first non-comment line instead of a hardcoded sed range, which the header insertion had just invalidated for the second time.
elibol
added a commit
to elibol/cuda-rust
that referenced
this pull request
Aug 29, 2026
Main's NVIDIA#1198 gates CI on sync-example-locks.sh --check; align the git-pinned workspaces the way its own docs prescribe (--align never touches the git pins). 1920 pins moved, 221 locks agree.
nihalpasham
pushed a commit
to elibol/cuda-rust
that referenced
this pull request
Sep 3, 2026
Main's NVIDIA#1198 gates CI on sync-example-locks.sh --check; align the git-pinned workspaces the way its own docs prescribe (--align never touches the git pins). 1920 pins moved, 221 locks agree.
nihalpasham
added a commit
that referenced
this pull request
Sep 4, 2026
* feat: build the host-side crates from cutile-rs Switches the workspace's cuda-bindings, cuda-core, and cuda-async to the shared host-side crates from cutile-rs, pinned as git dependencies on its feat/cuda-oxide-host-support branch, which carries this workspace's surface under simt modules. The local copies leave the workspace members but stay on disk as standalone packages (the rustc-codegen-cuda pattern, manifests de-inherited), so the example workspaces keep building unchanged. Source changes are mechanical path edits: cuda_async module paths gain the simt level (55 sites in cuda-host and cuda-macros, including emitted code), and bare LaunchConfig becomes cuda_core::simt's, since the root export belongs to the Tile-side type. The cuda_launch_async! trybuild fixtures deepen their local cuda_async stub to match, and the recorded stderr baselines regenerate with the new paths. CI installs CUDA 13.2.0, the shared bindings' minimum. cuda-host and cuda-macros test suites pass against the shared crates, 194 tests plus the trybuild guards, on an RTX 5090. * ci: retire the departed host crates from the lanes; fmt; trybuild baselines cuda-core and cuda-async left the workspace for the shared crates, so the unit-test matrix drops their lanes and the exclusion comment stops naming cuda-bindings; their tests run in cutile-rs CI. The Justfile mirrors the matrix, as its guard requires. deny.toml allows the cutile-rs git source the workspace now pins. rustfmt over the files the path edits touched, and the remaining trybuild stderr baselines regenerate with the simt paths, under both the plain and all-features invocations. * examples: build against the shared host-side crates With cuda-host on the shared crates, every example graph carried two same-named cuda-cores, its own path dependency on the retired local copy and the shared one underneath cuda-host, which cannot type-check together. The example manifests move to the same git dependencies the workspace uses, their sources take the simt::LaunchConfig path the rest of the tree took, and all 218 lockfiles refresh against the new graph. The tile+simt interop example points its cutile dependencies at the same branch, collapsing its graph to a single cuda-core. * examples: rustfmt over the import rewrites * examples: sweep the nested workspaces too Four examples carry a nested device or kernel-lib workspace one level deeper than the sweep reached; they kept path dependencies on the retired local crates, recreating the two-cuda-core graph the sweep exists to remove. Their manifests and lockfiles follow the rest. * examples: catch the aligned-assignment manifests the sweep missed Nine manifests write their dependencies with aligned equals signs, which the exact-string sweep did not match, leaving them on the retired path dependencies. A whitespace-tolerant pass converts them; no path dependency on the retired crates remains anywhere under the examples. * examples: finish the shared-crate switch for all ten failing lanes The async examples take the simt-level module paths, matching cuda-host. The two primitive-f16 examples enable the shared crate's f16 feature, which carries the nightly-gated DeviceCopy impl. nvls_all_reduce builds against simt::vmm, with the multicast surface enabled by the shared crate's new build script, and error-module paths move to the root re-exports since the module is private there. Every lockfile pins the branch rev carrying those additions. * fix: keep tile interop on the tile async surface Signed-off-by: nihalp <[email protected]> * ci: back to CUDA 13.1.1, the shared bindings floor is 12.0 now The shared host-side crates keep cuda-oxide's 12.x support: the bindings floor dropped to 12.0 with the 13.x-only symbols behind header probes, so the toolkit bump this branch carried is no longer needed and the lanes return to their original 13.1.1. * build: pin the shared crates at the 12.8-floor revision Every red lane died in the pinned cuda-bindings build script, which still enforced the old 13.2 floor against the 13.1.1 CI toolkit. All 219 lockfiles move to the branch revision carrying the 12.8 floor, the probed host-function helper, peer, the published oxide-artifacts dependency, and the DeviceCopy derive crate. * build: repin the shared crates at the #233 conflict-resolution head The #233 branch was rewritten while resolving its conflicts with cutile main; 9620a6f is no longer in its history. Repin all 222 example locks at 5cf5a55, regenerate the five that predated the shared-crate switch, and move nvls_all_reduce to simt::vmm now that cutile main's #202 vmm module owns the root name. * build: align example locks to one version per crate Main's #1198 gates CI on sync-example-locks.sh --check; align the git-pinned workspaces the way its own docs prescribe (--align never touches the git pins). 1920 pins moved, 221 locks agree. * ci: detach the retired host crates and name them in the license guard cuda-bindings was never given the standalone [workspace] table its two siblings got at retirement, and main's stricter license guard now walks every tracked manifest. Detach it the same way, commit the three standalone locks the guard's --locked metadata needs, and name all three retired roots first-party so their declared dependencies stay in the inventory. * build: repin the shared crates at aaf1364 The #233 branch gained the extern "C" wrapper ABI and the cuInit coercion regression nihalpasham asked for; manifests are unchanged, so this is a pure pin substitution across all 222 locks. * examples: convert the three examples added on main to the shared crates reborrow, sparse_mma_ordered_float, and shared_stage_select arrived on main with local path deps and root LaunchConfig imports; convert them the established way and seed their locks from vecadd's per the sync script's doc, which lands them aligned on the first try (224 locks agree). This also clears the clippy and cargo-deny lanes, which were failing on the unconverted expansion and the stale --locked resolve. * deps: track cutile-rs main for the shared host crates cutile-rs#233 was squash-merged into cutile-rs main as a2c1ea4 and its feature branch deleted, so the git dependencies on feat/cuda-oxide-host-support no longer resolve. Point the 222 manifests that declare cuda-bindings, cuda-core, and cuda-async at branch main and repin the 225 lockfiles that carry the four shared packages (cuda-bindings, cuda-core, cuda-core-derive, cuda-async, all 0.3.0) at a2c1ea4bb4ae804f573a879785c96f870a4e1b84. The shared crates' manifests are unchanged since the previous pin, so the lock rewrite is a pure source substitution; every one of the 225 workspaces resolves with --locked. The only change in the four crates between aaf1364 and main is the host-side toolkit floor moving from CUDA 12.8 to 13.0 (MIN_CUDA_VERSION 13000 in cuda-bindings/build.rs); CI installs 13.1.1 and already clears it. From here cuda-oxide tracks cutile-rs main; advancing the pin is a deliberate cargo update, reviewed like any dependency bump. Signed-off-by: Melih Elibol <[email protected]> * deps: pin the shared host crates to cutile-rs v0.3.1 Point the 222 manifests that declare cuda-bindings, cuda-core, and cuda-async at the v0.3.1 tag instead of branch main, and re-resolve the 225 lockfiles that carry the four shared packages with cargo update, so they now record cuda-bindings, cuda-core, cuda-core-derive, and cuda-async 0.3.1 at the tag's current target, 9f68be2d0aff0882ec329a453ddc756ad6e4f9e7. Every workspace resolves with --locked and the example locks still agree on one version per crate. Referencing the tag rather than a commit means a re-tag before the final release costs one cargo update pass and no manifest edits. Between a2c1ea4 and the tag the shared crates gained toolkit-discovery parity (CUDA_HOME fallback, targets/<arch>/include lookup, CUDA_TOOLKIT_TARGET_DIR), executed host-crate tests, and the host runtime audit follow-ups; DType became an unsafe trait and several driver wrappers now return Result. None of those surfaces are used by cuda-oxide's own code, and the simt:: modules are unchanged, so nothing here needed adapting. Signed-off-by: Melih Elibol <[email protected]> * docs, scaffold: name the shared crates' simt surface everywhere users copy from The host runtime now comes from the cutile-rs crates, whose cuda-oxide API lives under cuda_core::simt and cuda_async::simt. Every snippet a user copies has to say so: the README, the cuda-host README, the book pages, two example READMEs, and the two cargo oxide new templates. The scaffold also pointed cuda-core, cuda-async, and cuda-bindings at this repository's git URL. With the local copies retired that either resolves to nothing or to a stale copy on an old revision, so the templates now take the crates.io release (SHARED_HOST_CRATES_VERSION) and a test checks no git pin comes back. cuda-bindings leaves the async template: nothing in it names cuda_bindings. Book links that pointed at crates/cuda-core/{src,tests} now point at the simt files in cutile-rs. Signed-off-by: Nihal Pasham <[email protected]> * retire the local host crates for real; CI, licensing, and docs follow the shared crates The switch to the cutile-rs crates left the old crates/cuda-bindings, crates/cuda-core, and crates/cuda-async on disk as standalone packages "so the example workspaces keep building unchanged". Nothing built them: every example already took the git pin, no CI lane tested them, and their only effect was to make `cargo oxide new` resolve `cuda-core` from this repository's git URL to a stale 0.2.1 copy. They are gone, together with the dead `#[derive(DeviceCopy)]` in cuda-macros (cuda-core now re-exports cuda-core-derive's), the three retired roots in the license inventory guard, the CODEOWNERS rule for the moved crate, and the comments that pointed at the old paths (root Cargo.toml, doctor.rs, spine_kernel_ptx.rs, docs.yml). The shared cuda-bindings loads libcuda at run time through libloading instead of linking it, so the libcuda.so.1 stub shadowing in unit-tests.yml, docs.yml, the Justfile, and CONTRIBUTING was dead plumbing; it is removed and the `--exclude cuda-bindings` doctest exclusions with it. bindgen now also reads curand.h, which the flake provides and the docs name. cutile_inter_kernel leaves the license-policy exemption (#953): its git source is allowed and every cutile-rs crate is Apache-2.0, so it is judged like every other example. dependency-licenses.csv describes the crates as resolved (0.3.1 from cutile-rs) and gains cuda-core-derive and dashmap rows. Docs: the CUDA floor is 13.0 with an R580+ driver (README, installation, building-from-source, example READMEs), the remaining root-path snippets move to the simt paths, the `f16` feature is explained where it is enabled, the cuda-host re-export of cuda_async says which surface is which, and the docs.rs links for LaunchConfig point at the simt page. Seven trybuild fixtures get the line-neutral formatting fixes the path rewrite skipped. Signed-off-by: Nihal Pasham <[email protected]> * guards: host-API paths in docs and templates; shared host-crate pin parity Two things the crate switch showed nothing was checking: - Some forty book, README, and scaffold lines kept spelling the old root paths (cuda_core::LaunchConfig, cuda_async::device_operation::...), which on the shared crates either do not resolve or bind cutile's Tile-side types. No lane compiles those snippets. check-host-api-paths.sh greps them for the root spellings that are wrong on the shared crates; it fails on the pre-fix tree at 50 sites and passes now. - The shared-crate release is named once in the root workspace and copied into 221 example manifests and the `cargo oxide new` templates. check-shared-crate-pin.sh requires every copy to agree with the root on version and form (git tag or crates.io), so the crates.io repin cannot leave a straggler and the scaffold cannot drift. Both run in the status-guard workflow and in `just check-guards`. Signed-off-by: Nihal Pasham <[email protected]> * oxide-artifacts: consume the crates.io release everywhere; the in-tree crate is the publish source The backend wrote artifact bundles with the in-tree crates/oxide-artifacts (a path dependency) while the shared cuda-core from cutile-rs reads them through crates.io oxide-artifacts 0.2.1. Same version, same code, but two crates to rustc: the root lock carried both, and nothing tied the two versions together. It worked only because just bytes cross the boundary. The root workspace and the backend workspace now take oxide-artifacts from crates.io like every other consumer, so writer and reader are one crate. crates/oxide-artifacts stays a workspace member as the source the release is published from; format changes go bump, publish, then move the requirement and relock. check-oxide-artifacts-parity.sh keeps the in-tree version, both manifest requirements, and the version resolved in every lock equal, and fails if any lock stops consuming the registry copy. It fails on a drifted in-tree bump and passes on this tree. Runs in status-guard and just check-guards. Validated on an RTX 5090: cargo-oxide, mir-importer, ptx-schedule and backend lib tests, workspace clippy and fmt, all guards, and the full smoketest (222/222) with the backend writing through the registry crate. Signed-off-by: Nihal Pasham <[email protected]> * deps: take the shared host crates from the crates.io 0.3.1 release cutile-rs 0.3.1 is on crates.io (cuda-bindings, cuda-core-derive, cuda-core, cuda-async, and the cutile stack), so the git-tag pin that bridged the gap goes away: - root workspace and all 224 example workspaces (nested ones included) name `"0.3.1"` from the registry; `features = ["f16"]` and the `package = "cuda-core"` rename in cutile_inter_kernel are kept, and cutile_inter_kernel's cutile / cutile-compiler pins move with them - every Cargo.lock re-resolved with `cargo update -w`: 684 source lines flip from `git+...cutile-rs?tag=v0.3.1` to the registry plus a checksum each; no other package moves - deny.toml drops the cutile-rs `allow-git` entry (pliron is the only git source left) - dependency-licenses.csv: the four rows become "1st Party (crates.io)" - async_mlp and async_vecadd drop their direct cuda-bindings dependency; neither names `cuda_bindings` anywhere - comments in the two license guards and the cutile_inter_kernel README stop describing a git dependency Provenance, checked before this commit: the published .crate archives match the v0.3.1 tag tree (cdc69c1) file for file, and their sha256 matches both the crates.io index and the new lock checksums. The tag moved from 9f68be2 (the previous pin) to cdc69c1 for the release; the shared-crate delta is confined to the Tile-side `AsyncKernelLaunch` argument storage in cuda-async plus workspace lint config. The `cuda_async::simt` launch path cuda-oxide uses is unchanged. Signed-off-by: nihalpasham <[email protected]> --------- Signed-off-by: nihalp <[email protected]> Signed-off-by: Melih Elibol <[email protected]> Signed-off-by: Nihal Pasham <[email protected]> Signed-off-by: nihalpasham <[email protected]> Co-authored-by: nihalp <[email protected]>
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.
The problem
CI builds all 219 examples into one shared build cache. So after the first example warms it, every other example should take 1-2s:
Instead, a couple dozen examples took 15-165s at seemingly random positions (run 33202084464: disjoint_slice_len 165s, aligned_field_loads 68s, array_init 53s, ...). Every one of them was the same disease: something kept that example from reusing the cache. Three causes, each confirmed with cargo's fingerprint log (
CARGO_LOG=cargo::core::compiler::fingerprint=info).Cause 1: lockfile drift (19 of the 25 slow examples)
Cargo.lock, generated at different times.cuda.h:Cause 2: a global RUSTFLAGS for one example (the 165s one)
RUSTFLAGS=-Zinline-mir=noso its issue Crash when compilingDisjointSlice::len#343 regression pattern stays un-inlined.Cause 3: same-named local crates alias one cache slot (real linkage bug, uncovered by the fix)
kernel-lib v0.1.0, with different code inside.E0425: cannot find function add_const_ptx_name in module kernels.The fixes (one commit each)
disjoint_slice_len carries its flag itself, scoped to its own package via cargo's
profile-rustflags:The generated .ll keeps the un-inlined Crash when compiling
DisjointSlice::len#343 pattern verbatim (verified by diff against a build that flagged only the leaf). TheNOINLINE_MIR_EXAMPLES/EXTRA_RUSTFLAGSmachinery in smoketest is deleted.cargo-oxide's backend build ignores ambient rustc flags:
CARGO_ENCODED_RUSTFLAGSis pinned to the empty string, cargo's highest-precedence flag source. That also silencesCARGO_TARGET_<TRIPLE>_RUSTFLAGSand config-file[build]/[target.*]rustflags, whichenv_removecan't reach. A one-line note explains when ambient flags are being ignored. Unit test extended.All 221 example locks re-resolved to one version set (34 mixes → 8; the survivors are genuinely different trees like tokio/rayon/cutile that still share the common chain), plus a new
scripts/sync-example-locks.sh:Negative-tested for version drift, git-rev drift, and duplicate crate names; legitimate 0.0.z coexistence passes. The embedded example's nested crate is renamed to
embedded-kernel-lib.smoketest resolves the backend once per run by exporting
CUDA_OXIDE_BACKENDafter its one-timesetup. Before, every example invocation re-ran a cargo freshness check on the backend workspace:Before / after
Full
--compile-onlyrun, cold shared cache, all 219 pass:Validation
--compile-onlyfrom a cold shared cache: 219/219 pass.cargo test -p cargo-oxide(185 tests), per-example fmt + clippy for the touched example, the smoketest contract checker, and the new--checkgate all pass.Deliberately out of scope: parallelizing example builds (cargo's target-dir lock caps in-runner concurrency at a measured ~1.5x) and matrix sharding. This PR makes per-example cost flat and predictable first.