Skip to content

CI: gate the device surface on every PR, and put the two costly tiers behind explicit triggers - #57

Merged
feitreim merged 3 commits into
mainfrom
infra/ci-workflows
Jul 28, 2026
Merged

feitreim merged 3 commits into
mainfrom
infra/ci-workflows

Conversation

@feitreim

@feitreim feitreim commented Jul 28, 2026 •

Copy link
Copy Markdown
Owner

Three workflows under .github/workflows/, plus CI.md with the policy. The tier
table, the cost of each, the fork story and the by-hand GPU invocation live in
CI.md rather than in this PR body: a contributor asking "why didn't the GPU tier
run on my PR" is reading the repo, not doing archaeology on a merged PR.

What runs where

tier 1 ci.yml tier 2 cuda.yml tier 3 gpu.yml
Needs nothing CUDA toolkit B200
Runs on GitHub runner Modal, CPU Modal, B200
Secrets none Modal token Modal token
Cost free Modal CPU-minutes ~10 GPU-minutes a run
Trigger every push to main, every PR push to main, same-repo PRs, manual labelled PR, src/+device-tests/ on main, manual

Tier 1 is fmt, lockfile freshness, clippy --all-targets -- -D warnings,
test, and doc --no-deps under RUSTDOCFLAGS=-D warnings. Compilation is
root-only — device-tests/ and examples/ reach cuda-core -> cuda-bindings,
whose build script wants cuda.h — but parsing and resolution need neither a
toolkit nor a GPU, so both kernel crates get cargo fmt --check and
cargo metadata --locked here for free. That second one earned its place
immediately; see the lockfile fix below.

Tier 2 is modal run modal_app.py::build. The cargo oxide build --arch sm_100a of both kernel crates against the driver stub is the point of it: a
post-monomorphization const { assert!(..) } fires at codegen and is invisible to
cargo 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.04
as a job container gets cuda.h cheaply — but the toolkit is the small half. The
rest is LLVM 21 from apt.llvm.org, the pinned nightly with
rust-src/rustc-dev/llvm-tools, cargo-oxide from git, and a bootstrap build
of 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.py and free to drift from it. One definition, invoked identically from
a 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.repository up front. pull_request_target is not
used 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
ref input, so a maintainer who has read the diff runs
gh workflow run cuda.yml -f ref=refs/pull/<N>/merge. The workflow definition
still 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 issue
suggested reg.rs/shared.rs/ldst.rs/tmem.rs. A hand-maintained list rots —
mma.rs and sync.rs are device primitives too, and a new module would be
omitted 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-ci label
(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 secrets context is not readable from
a job-level if, so "no Modal token" cannot be turned into a skip — and a check
that 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 install with a Modal auth traceback.

Caching. Tier 1 uses Swatinem/rust-cache@v2; cuda-oxide is pinned to one
rev, 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.lock is not stale. At 3a19783 it already carries
cuda-core under ferro-kittens; cargo metadata --locked in all three crates
passes and leaves every lockfile untouched. So CI enforces --locked.

Fixes the new gates forced

cargo doc was broken twice over. On the device surface, four unresolved
intra-doc links. [`SharedTile::SUBTILE_COLS`] in global's module docs was
broken under any feature set — SharedTile is imported inside mod host, not
at module scope; now the full path. The other three name global types that exist
only under host, so a
#![cfg_attr(not(feature = "host"), allow(rustdoc::broken_intra_doc_links))] in
lib.rs lets the device-only build past them and a new
cargo doc --no-deps --features host in modal_app.py::build is where they
resolve for real.

Then that new host doc build found a third kind: private_intra_doc_links. The
SharedVec TileBox impl links GlobalLayout::descriptor_shape, which is
private. Fixed with plain backticks, over the two 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; and making descriptor_shape public would change
the API to satisfy a doc comment, when it returns raw ([u64; RANK], [u32; RANK])
driver arrays and its only callers are tensor_map and this crate's own tests.
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. Swept the crate: it is the
sole private link target, and check_driver_requirements is the only other
private 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 versions in
both kernel crates — modal_app.py mounted the root Cargo.lock but not
device-tests/Cargo.lock or examples/Cargo.lock, so cargo re-resolved against
crates.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.

rustfmt was missing from rust-toolchain.toml's components, so cargo fmt
depended on rustup's default profile happening to include it. Added.

actions/checkout@v4 / setup-python@v5 draw a Node 20 deprecation
annotation; both are at v7.

What I actually ran

Locally, every tier 1 step verbatim from cargo clean on the pinned
nightly-2026-04-03 — fmt --check and metadata --locked in all three crates,
clippy --all-targets --locked -D warnings, test --locked (59 passed),
RUSTDOCFLAGS=-D warnings cargo doc --no-deps --locked — all clean. All three
workflows pass actionlint 1.7.12.

Tier 2, locally against Modal, unpiped, exit status captured explicitly:

$ modal run modal_app.py::build > build.log 2>&1
$ echo "MODAL BUILD EXIT STATUS: $?"
MODAL BUILD EXIT STATUS: 0

69 host tests pass, cargo doc --features host generates cleanly, both
cargo oxide build --arch sm_100a runs 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 secrets
    landed mid-review, so this is a real end-to-end run, not a prediction.)
  • gpu — skipped, correctly: synchronize fires it, the if declines it for
    want 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-ci if you want that
proven before merge; otherwise its first real run is the next push to main
touching src/.

Known gaps, not addressed here

  • modal_app.py::build runs cargo clippy --all-targets on device-tests/ and
    examples/ without -D warnings, so those two cannot fail on a lint.
    examples/ currently emits 7 (type_complexity, three manual_is_multiple_of,
    missing_safety_doc, neg_cmp_op_on_partial_ord). Pre-existing; tightening the
    flag means fixing those first, which does not belong in a CI PR.
  • Each Modal build recompiles the pinned dependencies from scratch: the image's
    warm cargo caches were populated for /opt/warmup, and the project builds into
    a fresh target/. A Modal Volume on the target dir would cut most of it.

Closes #17

… 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
@feitreim feitreim added the infra Tests, CI, tooling label Jul 28, 2026
feitreim added 2 commits July 27, 2026 22:07
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.
@feitreim
feitreim merged commit c216229 into main Jul 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infra Tests, CI, tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: gate the device surface, the host feature, and the B200 harness

1 participant