Skip to content

The cargo cache belongs on the CPU tiers, and the GPU's build is irreducible - #226

Merged
feitreim merged 1 commit into
mainfrom
gpu-spend-economy
Aug 7, 2026
Merged

feitreim merged 1 commit into
mainfrom
gpu-spend-economy

Conversation

@feitreim

@feitreim feitreim commented Aug 7, 2026

Copy link
Copy Markdown
Owner

target/ moves onto a Modal Volume (ferro-kittens-cargo), mounted by the two tier-2 entry points and deliberately not by the GPU ones. _cached_target derives the per-crate directory from the working directory _run was given, and mounting the volume is the only switch there is — an entry point that mounts it builds onto it, one that does not builds where it always did.

CI.md's "Known inefficiency: … A Modal Volume mounted at the project's target directory would cut most of that. Not done here" is what this closes.

What it bought — tier 2 build, at 41f9e57

wall steps of which clippy×4
before, no volume 470.8 s 457.1 s 67.6 s
after, volume cold (first fill) 364.8 s 352.8 s 53.8 s
after, volume warm 291.8 s 281.1 s 17.3 s

176 s of step time per run, 38%. Cold costs nothing over the baseline. The saving lands exactly where the theory says: the four clippy steps collapse, the five cargo oxide build steps barely move — they are codegen, and codegen is redone every time. Tier 2 runs two such jobs per push, so ≈350 CPU-seconds a push.

Semantics are unchanged, and regcount is the proof

Run against 41f9e57 and against this tree, regcount's output is identical over all 1650 lines — every register count, the shape ladder, #63's timed twins, #95's occupancy-step gate, the opcode census and the local-memory depot census. cargo-oxide writes the emitted PTX to the working directory rather than under target/, so nothing this file reads moved. Same commands, same pass/fail meaning, everywhere.

The GPU half of the plan was measured and rejected

The obvious design — fill the cache on CPU, let the B200 skip its compile — does not work here, and the negative result is written into both modal_app.py and CI.md so it is not redone. On device_tests, cache warm from a preceding build:

dependency crates compiled cargo in the container
no volume 58 53.3 s
volume, warm 1 66.0 s
volume, warm, run again 1 60.0 s

The cache does exactly what it claims and the container still gets slower. The 58 dependencies were never the cost — they compile in parallel on cpu=8 behind the long pole, which is the crate's own device codegen, and cargo-oxide redoes that on every invocation: two consecutive runs of an unchanged tree both rebuilt device-tests in full. So on a GPU function the volume trades work that was already free for artifact I/O over a network filesystem.

Note there was no GPU-held build tier to reclaim: build, regcount and upstream_ptx have been cpu=8 all along, because cargo oxide build emits PTX and the driver stub satisfies the link. The rule is now written down rather than merely observed.

So the lever is fewer containers: session --arms

session runs any comma-separated set of named sweeps in one container. The arms are one ARMS table and the individual entry points are now thin wrappers over it, so a session and N separate modal runs issue byte-identical commands — batching cannot change a number, only how many containers paid for it. It also gives multi-arm claims one device, one driver, one clock and one cuBLASLt, which is the control #98 and #118 keep paying for by hand.

Measured on bench:softmax,bench:layernorm,device-tests:

wall
three separate runs 258.2 s
one session --arms … 161.2 s

97 GPU-seconds, 38%. Saved: the image pull and container start, three times down to one, plus the dependency compile for an arm following one in the same crate (bench:layernorm built in 28.6 s behind bench:softmax's 40.6 s, against 72 s cold). Not saved: the device codegen, per rule 1.

bench --case sol-k and profile deliberately have no arm — a launch that hangs takes every row after it, which is how sol-k was found, so an arm that can wedge the container keeps its own process.

Also here

  • CI.md gains a ## Spending policy section: the three rules above with their measurements, and the measurement ladder — local typecheck first (CUDA_TOOLKIT_PATH at an unpacked cuda_cudart redist reaches all four crates including --features host, typecheck only, not codegen), then tier 2 on CPU, then one container per same-arm A/B, then a batched session for a multi-arm claim.
  • Tier 3's cost line is corrected from a budgeted "ten GPU-minutes a run" to the measured 83.5 s — 57 cases in ~20 s of B200 behind a compile costing two and a half times as much.
  • cuda.yml and gpu.yml header comments updated to match.

Verification

All green, on this tree: build (cold and warm), regcount (and diffed against the baseline tree), device_tests 57/57 twice, bench --case softmax, bench --case layernorm, session --arms bench:softmax,bench:layernorm,device-tests 57/57. scripts/fmt --check clean.

…ducible

`target/` moves onto a Modal Volume (`ferro-kittens-cargo`), mounted by the two
tier-2 entry points and deliberately not by the GPU ones. `_cached_target`
derives the per-crate directory from the working directory `_run` was given, and
mounting the volume is the only switch there is.

Tier 2 `build` at 41f9e57, warm against the same tree cold:

    wall     470.8 s -> 291.8 s
    steps    457.1 s -> 281.1 s   (-176 s, -38%)
    clippy    67.6 s ->  17.3 s   (four crates)

A cold first fill costs nothing over the baseline. `regcount` is the check that
this is placement and not measurement: run against 41f9e57 and against this
tree, its output is identical over all 1650 lines -- every register count, the
ladder, the timed twins, the occupancy gate, both censuses.

The GPU half of the plan was measured and rejected. Warm on `device_tests` the
cache does what it claims -- 58 dependency crates compiled become 1 -- and the
container still gets *slower*, 53.3 s of cargo becoming 66.0 s and 60.0 s over
two runs. The 58 dependencies were never the cost: they compile in parallel on
`cpu=8` behind the long pole, which is the crate's own device codegen, and
cargo-oxide redoes that on every invocation regardless. Two consecutive `run`s
of an unchanged tree both rebuilt `device-tests` in full. So the volume trades
free work for network-filesystem I/O there, and loses.

What that leaves is the lever this PR adds instead: **fewer containers**.
`session --arms` runs any comma-separated set of the named sweeps in one
container, off one `ARMS` table that the individual entry points are now thin
wrappers over -- so a session and N separate `modal run`s issue byte-identical
commands and batching cannot change a number. Measured on
`bench:softmax,bench:layernorm,device-tests`: 258.2 s as three runs, 161.2 s as
one session, 97 GPU-seconds and 38% saved. `bench --case sol-k` and `profile`
have no arm on purpose -- an arm that can wedge the container belongs in its own
process.

CI.md gains a spending policy section carrying all of the above plus the
measurement ladder (local typecheck, tier 2, one container per A/B, a batched
session for a multi-arm claim), and tier 3's cost line is corrected from a
budgeted ten GPU-minutes to a measured 83.5 s.
@feitreim
feitreim merged commit bda3329 into main Aug 7, 2026
3 checks passed
feitreim added a commit that referenced this pull request Aug 7, 2026
…is a gate (#225) (#229)

* The jump tables were #219's after all, and the census that missed it is a gate (#225)

Three readings of `regcount`'s jump-table census, each from a build that
`_freshen` (#228) forced and whose four crates are seen to recompile in the
container log, same image and same pinned nightly:

    3ae07a8   #218, before the access ladder        0 of 309
    bda3329   after #219, before #227              55 of 318   (9 shipped)
    09beda9   main, after #227                      0 of 319

#219 introduced every `brx` in this tree and #227 removed every one of them,
which is the consumer's bisect exactly. #227 reported the opposite -- 51 already
present at 3ae07a8, identical counts across its own fix -- from a comparison
taken across the warm cache volume #228 later found serving stale builds. Both
numbers are superseded. 3ae07a8 has no `AccessWidth` to match on at all, so
zero is the only count that tree can produce.

Half of #225's "necessary but not sufficient" survives and half does not. No GPU
entry point mounts the cache volume (#226), so #227's B200 runs at then-main
really were runs of the 55-table tree and those modules really did load.
`shared_drain_quad` is the half that goes: it was added on the fix branch, after
the fix had put both drains back on a three-case dispatch, so it has never
carried a table and it is inside main's 0 of 319. Its doc said it demonstrated a
JIT taking four of them; it demonstrated nothing of the kind, and now says so.

So the census arms on the condition it set for itself. A kernel in the shipped
set -- `examples/` plus `GATED_KERNELS` -- carrying a `brx` fails the run;
probes are printed and do not, the way the local-memory depot's are. The table
stays as the diagnostic.

Watched in both directions: green at this branch (0 of 319) and red at bda3329's
sources under the same armed `modal_app.py`, naming the nine shipped kernels.

* The access ladder's note carries the in-tree numbers, not only the consumer's
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant