Repository navigation
Conversation
`kittens::watchdog` polls the event behind a launch instead of blocking on it, so a kernel that stops making progress ends the process in 30 s naming the row the sweep last announced. Every host wait in the three kernel crates goes through it. `session` now runs the arms after a failed one and summarizes, so `bench --case sol-k` and `profile` -- barred from `ARMS` because a hanging launch takes every row after it -- have arms. `wedge_demo` is the control. Timeouts are re-derived from measured baselines with the baseline in a comment; `device_tests` moves 1200 -> 300 against its measured 83.5 s.
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
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.
A CUDA wait has no timeout, so a kernel that stops making progress stops the
host with it — and the only thing that ever ended one here was Modal's
timeout=, at B200 rates, for the whole of a ceiling sized for a cold build plusa sweep. That is how
bench --case sol-kwas found (#146:4096x4096x1024printing nothing for 1200 s), and it is why #226 had to keep that case and
profileout ofsession --arms: an arm that can wedge takes every rowafter it.
This is the deadline that removes the exclusion, plus the timeout audit that
should have accompanied it.
kittens::watchdog— the wait with a clock on itcuEventQueryanswers "has this retired" without blocking, so a wait can be aloop the host controls.
waitrecords an untimed event behind whatever is queuedon the stream and polls it; past 30 s it prints the row the sweep last announced
and calls
abort().Four decisions, argued in
docs/library/watchdog.md:cuEventSynchronizespins underCU_CTX_SCHED_AUTOtoo, so for a launch of a normal length this is the same wait, not an
addition to it. That is what lets the timed loop in
examples/src/bench.rsuseit:
wait_eventpolls thestopevent the clock already records, betweenstop.recordandelapsed_msreading a duration off that same pair. No eventcreated, no allocation, the bracket around the launch untouched.
abort()notexit(). When it expires the launch is stillrunning and the context will not release; a caller that recovered would be
timing a device still busy with the launch it gave up on.
exitruns thedriver's
atexithandler, which wants the wedged context.abortruns none,and the kernel dies when the OS reclaims the process. The isolation the design
needs is a process boundary, which
_runalways had.measured × 10. The slowest single launch in the tree is the16384³ GEMM at ~8 ms and ten times that would fire on a driver hiccup; a
guarded wait also covers staging copies and the driver's lazy module load,
which are seconds. So: three orders of magnitude above the work, two below the
3600 s a wedge used to ride.
KITTENS_LAUNCH_BUDGET_MSoverrides, and a valuethat is not a positive number is the default rather than the absence of a
deadline.
bench.rs::announceprints the row andhands the same string to
watching, sosol::sweep_k's "the last announcedrow is the one that did not return" stops being something a reader does
afterwards.
Coverage is the whole tree, and finding out what that meant took two runs.
Three of
cuda-core's conveniences synchronize inside themselves —DeviceBuffer::from_host,::zeroedand::to_host_vec— so an unguardedreadback taken after a launch is an unguarded wait, and so is an unguarded
staging call.
waitreplaces everystream.synchronize(),stage/clearedreplace the two constructors and
ReadBack::read_backreplaces the readback,across
src/,examples/,experiments/anddevice-tests/. Nothing waits ona device any other way.
The control, and what it cost to make it honest
modal_app.py::wedge_demois to this whatstallis toscripts/modal-run.experiments/src/wedge.rs, behind an off-by-defaultwedgefeature, queues akernel that spins for two minutes against a five-second budget immediately in
front of a row's own launch, on that row's own stream — everything loaded, everything staged, then a launch
that will not finish. Three arms go through it and the pass condition is the
shape: arm 2 failed, arms 1 and 3 did not. A wedged arm that passed is a
watchdog that did nothing; a green arm that failed is a wedge that took a
neighbour, which is the thing this PR claims cannot happen. Both raise.
The demonstration passes.
scripts/modal-run wedge_demo, exit 0:One row red, the rows after it green, the whole thing in one container. The
banner names the row rather than the exit code because the exit code cannot: the
abort happens in the kernel binary,
cargo oxide runreports the signal asFailed with exit code: None, andsubprocesssees cargo's 1. That is measuredand now said where the summary is built.
wedge_demoitself exits 0 because its pass condition is the shape — arm 2failed, arms 1 and 3 did not — and a wedged arm that passed would be a watchdog
that did nothing. A real
sessionwith a failed arm raises, and runs 5 and 6below are the evidence that raising from these entry points reddens the run.
It took nine runs, and two of them changed the design
The story is in
experiments/src/wedge.rsanddocs/library/watchdog.mdbecause every one of them is a fact about this tree:
bench::mainDeviceBuffer::from_host— the staging constructors synchronize too;stage/clearedexist because of thiskernels::loadthe only candidatewedge:markers were added*mut u64for the spin to store intoKITTENS_WATCHDOG_TRACEaddedwatchdog: waited 0.000 s— the guard reports; the spin is absentclock64instead ofglobaltimer.entry wedge,ld.volatile.global.b32, backwardbra— the loop is in the PTX, and the host blocked for the spin's whole length. No deadline fired.0.000 sRuns 5–6 were the kernel:
Semaphore::wait_beforespins correctly on the samenightly because its condition calls
mbarrier_try_wait_parity, which touchesmemory. A volatile load in the condition fixes it, and the PTX check now runs
before the arms so that is never again something a container discovers.
Runs 7–8 were the guard, and they are why this module has two deadlines.
waitbounds a driver call by recording an event behind it and polling thatevent — so it cannot bound a call that never returns. With a spin kernel
resident, the row's own
cuLaunchKernelExblocks: the host sat inside the launchfor the spin's whole life and the guarded wait after it was never reached. No
amount of reasoning had produced that; a device did. So
watchingnow also armsa sentinel thread with a budget on the row — 10 min by default, coarse
because a row legitimately includes host work (the 16384³ rows check 268 million
outputs on the CPU), and unevadable because no driver call can hold a thread that
is not in the driver.
wait/wait_eventwatching, at the row announcementNeither subsumes the other, and the demonstration only passes because both exist.
sol-kandprofilehave armsARMSgainsprofile(as_profile_arm, so a session and the entry point issuethe same commands,
ARMS' standing rule), and the exclusion note is gone.bench:sol-kneeded no new entry —bench:<case>already reached it — only thepolicy to change.
What batching them is worth.
bench:sol-kmeasured 106.2 s and 112.6 sin two three-arm sessions, sitting behind another
experiments/arm. Run aloneit would additionally pay an image pull, a container start and a cold dependency
compile — the three things #226 decomposed a session's saving into, at 97 s over
two avoided containers on its own three-arm measurement, and 60-72 s of cargo
cold against 28.6 s warm behind a same-crate arm. So each
sol-kinvocationthat rides a session instead of its own container is worth roughly 50 GPU-seconds
of B200, and the same again for
profile, on top of the exclusion's real cost:until now the answer to "take these two beside the others" was no.
sessionno longer throws the rest of the run away when an arm fails:_sessionruns the arms after a failure, prints a summary with each arm's outcome and
elapsed, and the caller decides what a failure means (which is how
wedge_democan require exactly one). The session is still red. The new rule is narrower and
worth keeping: an arm may fail, and may not take the container with it.
Timeouts, at ~3x a measured baseline
The convention oxide-train#131 wrote down for the twin repo, mirrored here: a
timeout is three times a measurement with the measurement in the comment beside
it, and an entry point whose work its arguments choose stays open-ended and
says so.
timeout=buildregcountupstream_ptxptxas; unmeasuredCHECKINGdevice_testsexamplesbench,session, the named sweepswedge_demodoctorstalldevice_testsis the one that moved: it sharedRUNNINGwithexamplesatfourteen times its own measurement. A ceiling is not a bill, so the only thing a
loose one costs is a wedge riding longer — which is also why they are no longer
the first line of defence.
Not planned, and the more important half: the cache volume was serving a stale build
The first
buildof this branch went red on a doctest in the new module —against a
libkittens.rlibthat had no such module.cargo clippy --features host --all-targetshad finished in 1.05 s having compiled nothing, and thecargo testafter it ran 127 unit tests: the count from before the two newones existed. With the volume emptied, the same tree built and ran 129.
clippy --features host_freshenCargo's freshness check for a path crate is mtime against the fingerprint, and
Modal's mounts do not hand the container mtimes newer than artifacts already on
the volume. Neither cargo nor the volume is wrong; the pairing is. The tell was
rustdoc, the one step that reads the sources unconditionally — without adoctest in the new module that run would have been green on a tree it had not
built.
_freshentouches every.rs,.tomland.lockunder the project once percontainer, before the first command. Measured on this tree, step time:
_freshenSo the volume still buys 89 s a run and #226's headline survives — its saving
was in the dependency tree all along, exactly as it argued, and none of it lives
under
PROJECT_DIR. What did not survive is the guarantee: any "identicaloutput" comparison taken across a warm volume before this fix was potentially
comparing two runs of the same artifacts.
Verification
scripts/modal-run build— green, 129 unit tests (127 before this PR, plusthe two in
watchdog) and 94 doctests. Run three times: warm-and-stale (red,the finding above), volume-emptied (green, 384.3 s of steps) and
warm-with-
_freshen(green, 295.2 s).scripts/modal-run wedge_demo— green, the summary above. Nine runs intotal; every guarded path ran clean throughout:
bench:softmax's whole table,sol-k's 22-row ladder with its cuBLASLt column,device-tests57/57._sessionreported per-arm outcome and elapsed every time, andwedge_demoraised on the wrong shape in runs 5, 6 and 8 — which is both the check and the
session's own red path doing their jobs.
scripts/modal-run regcount— green through_freshen, all four cratesrecompiled, occupancy-step gate green, and the jump-table finding above.
scripts/fmt --checkclean;cargo clippy --all-targetson all fourmanifests shows the same 64 warnings as
origin/mainand no new categories,locally against the
cuda_cudartredist.One thing the stale-cache fix turned up, and it is not mine to close
regcount, run through_freshenso all four crates demonstrably recompiled inthe container, reports:
Zero. #227's codegen table records "jump-table census: identical set,
identical counts (+ the new probe)" across the change that merged as b589b8a, and
the in-tree day-one census records 55 of 318 at its parent. 319 is 318 plus
shared_drain_quad, so the entry set is the one that comparison was about —only the counts differ, and they differ by all of them.
The direction is the intended one: #227 made both drains dispatch on
access_width_byteswith a wildcard, which is three cases, and LLVM branches atthree. So the fresh build says the fix removed every table in the tree rather
than none, and #227 concluded the opposite from a comparison taken across exactly
the warm-volume window
_freshenwas written for. That is a finding about themeasurement, not a defect in the fix — and it is the concrete instance of the
suspicion the stale-build section raises.
It also means the census's own arming condition is now met ("it arms into a
gate when the shipped set reads zero"). Deliberately not acted on here: one fresh
measurement of a report is not a gate, and arming one belongs with whoever
re-takes the before/after on two verified-fresh builds. The number and the
argument are written into
modal_app.py's census comment so the next personstarts from them.