Repository navigation
CI: gate the device surface on every PR, and put the two costly tiers behind explicit triggers - #57
Merged
Merged
Conversation
… behind explicit triggers
Three workflows, ordered by what they cost.
ci.yml runs on every push to main and every pull request, forks included,
with no toolkit and no credential: fmt and lockfile freshness across all
three crates (parsing and resolution need neither cuda.h nor a GPU), then
clippy --all-targets -D warnings, tests, and doc --no-deps -D warnings on
the device-only surface.
cuda.yml is modal_app.py::build -- the host feature, and a real
`cargo oxide build --arch sm_100a` of both kernel crates against the driver
stub, which is the only thing that sees a post-monomorphization const
assert. Invoking Modal rather than standing up a CUDA container in Actions
keeps one definition of the toolchain: the toolkit is the cheap half, and
LLVM 21 + rustc-dev + the codegen backend bootstrap have no GHA cache story.
gpu.yml is the B200 harness. Label a PR `gpu-ci`, or push to main touching
src/ or device-tests/, or dispatch it by hand at a ref. Never on a plain
push. Fork PRs skip tiers 2 and 3 rather than fail; pull_request_target is
not used anywhere.
Two things had to be fixed to make the gates pass:
* `cargo doc` failed on four intra-doc links. One (SharedTile::SUBTILE_COLS
from global's module docs) was broken outright; the other three name
`global` types that exist only under `host`, so they are allowed off that
feature and checked by a new `cargo doc --features host` in the Modal
build, where they resolve.
* rustfmt was missing from rust-toolchain.toml's components, which made
`cargo fmt` depend on rustup's default profile.
Closes #17
actions/checkout and actions/setup-python at v4/v5 draw a Node 20 deprecation annotation on every run; both are at v7 now. The Modal jobs failed with a bare Modal auth traceback on a repo with no token configured. `secrets` is not readable from a job-level `if`, so that case cannot be a skip -- and a check that silently passes without running is worse than a red one. Fail it on the first step instead, with the two secret names in the error.
…nst their lockfiles
`cargo doc --features host` failed on `rustdoc::private_intra_doc_links`:
the `SharedVec` `TileBox` impl links `GlobalLayout::descriptor_shape`,
which is private. Pre-existing, surfaced by the new doc check.
Plain backticks rather than the alternatives. `#[allow(..)]` renders
*identically* -- rustdoc will not link a reader to an item absent from the
docs either way -- so it buys nothing and costs a suppressed lint that
would hide the next case. Making `descriptor_shape` public would change
the API to satisfy a doc comment: it returns raw `([u64; RANK],
[u32; RANK])` driver arrays, its only callers are `tensor_map` and this
crate's own tests, and `tensor_map` being public is not a precedent --
that is the function you call to get a descriptor, this is how it computes
half of one. It is the sole private link target in the crate;
`check_driver_requirements` is also private but nothing links it.
Separately, the run showed both kernel crates re-resolving against
crates.io on every build ("Locking 60 packages to latest ... compatible
versions"), because only the root Cargo.lock was mounted. Tier 1 now gates
all three lockfiles, so tier 2 was building a dependency set nothing in the
repo pins. Mount the other two.
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.
Three workflows under
.github/workflows/, plusCI.mdwith the policy. The tiertable, the cost of each, the fork story and the by-hand GPU invocation live in
CI.mdrather than in this PR body: a contributor asking "why didn't the GPU tierrun on my PR" is reading the repo, not doing archaeology on a merged PR.
What runs where
ci.ymlcuda.ymlgpu.ymlsrc/+device-tests/on main, manualTier 1 is
fmt, lockfile freshness,clippy --all-targets -- -D warnings,test, anddoc --no-depsunderRUSTDOCFLAGS=-D warnings. Compilation isroot-only —
device-tests/andexamples/reachcuda-core->cuda-bindings,whose build script wants
cuda.h— but parsing and resolution need neither atoolkit nor a GPU, so both kernel crates get
cargo fmt --checkandcargo metadata --lockedhere for free. That second one earned its placeimmediately; see the lockfile fix below.
Tier 2 is
modal run modal_app.py::build. Thecargo oxide build --arch sm_100aof both kernel crates against the driver stub is the point of it: apost-monomorphization
const { assert!(..) }fires at codegen and is invisible tocargo check.Tier 3 is
modal run modal_app.py::device_tests.Design calls
Modal, not a CUDA container in Actions.
nvidia/cuda:13.0.0-devel-ubuntu24.04as a job container gets
cuda.hcheaply — but the toolkit is the small half. Therest is LLVM 21 from apt.llvm.org, the pinned nightly with
rust-src/rustc-dev/llvm-tools,cargo-oxidefrom git, and a bootstrap buildof the cuda-oxide codegen backend. On Modal that is a content-addressed layer that
already exists. On a fresh runner it is a cold build every time, unless we publish
our own image to GHCR — a second definition of the toolchain, maintained beside
modal_app.pyand free to drift from it. One definition, invoked identically froma laptop and from CI. The price is a credential, hence no tier 2/3 on fork PRs.
(Observed: 2m25s end to end for the whole tier 2 job.)
Fork PRs skip, they do not fail. Both Modal jobs test
head.repo.full_name == github.repositoryup front.pull_request_targetis notused anywhere — it would run a fork's code with our Modal credential in the
environment on the strength of a PR being opened. Instead both workflows take a
refinput, so a maintainer who has read the diff runsgh workflow run cuda.yml -f ref=refs/pull/<N>/merge. The workflow definitionstill comes from the default branch; only the tree comes from the fork. That
manual read is the entire security boundary, which is why it is a deliberate act.
The GPU path filter is all of
src/, not the four primitive files. The issuesuggested
reg.rs/shared.rs/ldst.rs/tmem.rs. A hand-maintained list rots —mma.rsandsync.rsare device primitives too, and a new module would beomitted by default — and it rots toward not running a correctness gate, which is
the wrong direction to fail. Restricting the trigger to push-to-main bounds the
cost far more than narrowing paths does. On PRs the gate is the
gpu-cilabel(created on the repo), which also re-runs on later pushes while the label is on;
remove the label to stop the spend.
An unconfigured repo fails loudly. The
secretscontext is not readable froma job-level
if, so "no Modal token" cannot be turned into a skip — and a checkthat silently passes without running is worse than a red one. Both Modal jobs
start with a preflight that fails in one second naming the two secrets, rather
than after a minute of
pip installwith a Modal auth traceback.Caching. Tier 1 uses
Swatinem/rust-cache@v2; cuda-oxide is pinned to onerev, so keyed on the lockfiles it is fetched and compiled once and restored until
the pin moves (34s cold, 20-24s warm, observed). Tiers 2/3 cache nothing
GitHub-side — the expensive artifacts are Modal image layers, already
content-addressed.
examples/Cargo.lockis not stale. At3a19783it already carriescuda-coreunderferro-kittens;cargo metadata --lockedin all three cratespasses and leaves every lockfile untouched. So CI enforces
--locked.Fixes the new gates forced
cargo docwas broken twice over. On the device surface, four unresolvedintra-doc links.
[`SharedTile::SUBTILE_COLS`]inglobal's module docs wasbroken under any feature set —
SharedTileis imported insidemod host, notat module scope; now the full path. The other three name
globaltypes that existonly under
host, so a#![cfg_attr(not(feature = "host"), allow(rustdoc::broken_intra_doc_links))]inlib.rslets the device-only build past them and a newcargo doc --no-deps --features hostinmodal_app.py::buildis where theyresolve for real.
Then that new host doc build found a third kind:
private_intra_doc_links. TheSharedVecTileBoximpl linksGlobalLayout::descriptor_shape, which isprivate. Fixed with plain backticks, over the two alternatives:
#[allow(..)]renders identically — rustdoc will not link a reader to an itemabsent from the docs either way — so it buys nothing and costs a suppressed lint
that would hide the next case; and making
descriptor_shapepublic would changethe API to satisfy a doc comment, when it returns raw
([u64; RANK], [u32; RANK])driver arrays and its only callers are
tensor_mapand this crate's own tests.tensor_mapbeing public is not a precedent — that is the function you call toget a descriptor, this is how it computes half of one. Swept the crate: it is the
sole private link target, and
check_driver_requirementsis the only otherprivate item (nothing links it).
Tier 2 was not building the pinned dependency set. The first green Modal run
printed
Locking 60 packages to latest Rust 1.96.0-nightly compatible versionsinboth kernel crates —
modal_app.pymounted the rootCargo.lockbut notdevice-tests/Cargo.lockorexamples/Cargo.lock, so cargo re-resolved againstcrates.io every run. An upstream release could have broken tier 2 with no change
of ours, and the lockfiles tier 1 gates were not what tier 2 built. Both are now
mounted; the re-resolution lines are gone.
rustfmtwas missing fromrust-toolchain.toml's components, socargo fmtdepended on rustup's default profile happening to include it. Added.
actions/checkout@v4/setup-python@v5draw a Node 20 deprecationannotation; both are at v7.
What I actually ran
Locally, every tier 1 step verbatim from
cargo cleanon the pinnednightly-2026-04-03—fmt --checkandmetadata --lockedin all three crates,clippy --all-targets --locked -D warnings,test --locked(59 passed),RUSTDOCFLAGS=-D warnings cargo doc --no-deps --locked— all clean. All threeworkflows pass
actionlint1.7.12.Tier 2, locally against Modal, unpiped, exit status captured explicitly:
69 host tests pass,
cargo doc --features hostgenerates cleanly, bothcargo oxide build --arch sm_100aruns finish, and no crate re-resolves.On GitHub Actions, from this PR, all three tiers now green or correctly
skipped:
ci— pass, every step, 20s warm.cuda— pass, 2m25s, including the credential preflight. (The secretslanded mid-review, so this is a real end-to-end run, not a prediction.)
gpu— skipped, correctly:synchronizefires it, theifdeclines it forwant of
gpu-ci.Still not exercised: tier 3's actual B200 run. The gating logic is confirmed,
but no GPU has been allocated by CI. Label this PR
gpu-ciif you want thatproven before merge; otherwise its first real run is the next push to main
touching
src/.Known gaps, not addressed here
modal_app.py::buildrunscargo clippy --all-targetsondevice-tests/andexamples/without-D warnings, so those two cannot fail on a lint.examples/currently emits 7 (type_complexity, threemanual_is_multiple_of,missing_safety_doc,neg_cmp_op_on_partial_ord). Pre-existing; tightening theflag means fixing those first, which does not belong in a CI PR.
buildrecompiles the pinned dependencies from scratch: the image'swarm cargo caches were populated for
/opt/warmup, and the project builds intoa fresh
target/. A Modal Volume on the target dir would cut most of it.Closes #17