Skip to content

A wedged container held a B200 for 26 minutes, and nothing was watching for it - #99

Merged
feitreim merged 1 commit into
mainfrom
modal-run-limits
Jul 28, 2026
Merged

feitreim merged 1 commit into
mainfrom
modal-run-limits

Conversation

@feitreim

Copy link
Copy Markdown
Owner

A B200 container wedged today and held the GPU for twenty-six minutes having
compiled nothing
— fifteen lines of NVIDIA banner and no $ <command> line,
which means it never reached Python. From the outside it was indistinguishable
from a cold build, and it was found by hand.

Two things were wrong, and they need different fixes.

1. The ceiling was ninety minutes and nobody chose it

Every GPU entry point carried timeout=5400, uniform across six functions doing
very different amounts of work.

entry point was now why
build, regcount 1800 900 CHECKING compile and lint, no launches. Ten CI runs: 155–221 s warm, ~7.5 min cold since #93
device_tests, examples 5400 1200 RUNNING compile plus a short harness
bench, clc_bench, ladder_bench, profile 5400 2700 SWEEPING 16384³ launched dozens of times — genuinely the long ones
doctor 600 300 ASKING one driver query, nothing built

The names carry the reasoning so the next person to add an entry point picks a
budget by saying what kind of work it is.

These are still partly estimates and the PR says so. build is measured;
the GPU durations are not, because nothing was recording them. So _run now
prints elapsed seconds per command — on the failure path too, since a step that
ran for nineteen of a twenty-minute budget and a step that died on contact are
different diagnoses and the exception alone does not tell them apart. The next
round tightens these from the log rather than from another guess.

2. timeout= is a ceiling on the function, not on reaching the function

This is the actual failure and the tighter timeouts only half-cover it. The
container printed the image banner and stopped. _run's first act is a
print, and that print never happened — so no guard inside modal_app.py
could ever have fired.
A subprocess.run(timeout=…), a stall detector in
_run: none of it runs. The guard has to live in the only process still awake,
which is the client.

scripts/modal-run is that guard.

scripts/modal-run device_tests
scripts/modal-run bench --case gemm-depth

It watches for the tell — a healthy run emits our $ <command> or a
Compiling … line within a few minutes of the banner — and distinguishes two
hangs, because they mean different things:

  • never reached Python (STARTUP_GRACE, 300 s) — the observed failure
  • started, then went silent (SILENCE_GRACE, 1200 s) — set well above any
    real gap between lines, since bench is legitimately quiet across a 16384³
    sweep

On either it kills the client and modal app stops the app, because killing
the client does not reliably stop the container and the container is the thing
being billed. Exit 3. It also exits 2 on the workspace spend limit, which fails
every entry point at once in about fifteen seconds and reads exactly like a
broken diff — that has cost real diagnosis time before.

The guard was watched failing, on all four paths

Both graces are env-overridable so this was possible at all; a check nobody
has seen fire is not a check (#67, #76, #95). Against a stub that reproduces the
observed failure:

=== CONTROL 1: container never reaches Python (the observed failure)
!! wedged: the run never reached Python in 5s. Stopping it rather than paying
   out the function timeout.
   stopped ap-Biq4JTeZchuInkKaeR7azC
exit=3

=== CONTROL 2: run started, then went silent
!! wedged: the run said nothing for 4s. Stopping it rather than paying
   out the function timeout.
   stopped ap-Biq4JTeZchuInkKaeR7azC
exit=3

=== CONTROL 3: spend limit
!! the workspace spend limit is exhausted -- this is not your diff.
exit=2

=== CONTROL 4: clean finish, run's own exit code passes through
exit=7

Control 4 matters as much as the other three: a watchdog that swallows the
run's own exit code would turn every real failure green.

What is not established

Whether Modal's timeout= clock covers container startup at all. If it
does, the wedged run would have died at 15 minutes under the new budget instead
of 26 under the old. If it does not, only scripts/modal-run catches this class
and the timeouts are purely about in-function hangs. I did not find a way to
settle it without deliberately wedging a container, which costs the thing this
PR exists to stop. Both changes are worth having either way, and the next
observed stall answers it for free — if a run dies at exactly RUNNING, the
clock covers startup.

Scope

  • modal_app.py: four named budgets replacing nine literals, elapsed logging in
    _run.
  • scripts/modal-run: new, ~110 lines.
  • CI.md: the tell, the wrapper, and the two exit codes, under §"Running it by
    hand".

No Rust changed, so tier 3 has nothing to say about this one.

…ceiling

Every GPU entry point carried timeout=5400 -- ninety minutes, uniform across
six functions doing very different work, derived from nothing. Sized them from
what the runs take instead, and added the elapsed line that lets the next round
tighten them from data rather than from another guess.

The timeout is a ceiling on the function, not on getting to the function. One
container wedged before Python started -- fifteen lines of NVIDIA banner, no
$ line, twenty-six minutes on a B200 having compiled nothing. Nothing inside
modal_app.py could have caught it. scripts/modal-run is the guard in the only
process still awake, watching for the tell (a healthy run emits Compiling
within a couple of minutes of the banner) and stopping the app rather than
paying out the ceiling.
@feitreim
feitreim merged commit bde86a5 into main Jul 28, 2026
4 checks passed
@feitreim
feitreim deleted the modal-run-limits branch July 28, 2026 22:06
feitreim added a commit that referenced this pull request Jul 29, 2026
The first run of this branch: build reaches its first `$ ` line 6.5 s in
having never been silent for more than 3.1 s, against a 300 s startup budget;
the longest quiet stretch anywhere in either job is 58.9 s of sm_100a codegen
against 1200 s. And in tier 2 the silence budget cannot bind at all -- the
entry point's own timeout=900 is shorter. Tier 3 is where a tighter value would
buy something and is the tier with no measurement here, so it keeps #99's.

Also: CI installs modal unpinned and drew 1.5.3, where #103's three exit-code
behaviours were measured on 1.5.1. That is the argument for the sentinel in one
line.
feitreim added a commit that referenced this pull request Jul 29, 2026
#118)

* Route CI through scripts/modal-run, so the two guards cover the checks

`cuda.yml` and `gpu.yml` called `modal run` directly, so #99's wedge watchdog
and #115's completion sentinel protected only runs a human started by hand.
Every performance number in this repo's recent history came through green
checks on the unguarded path.

The three jobs now call `scripts/modal-run` as the only command in their step,
so its exit code is the step's: 2 (spend limit), 3 (a wedge it stopped) and 4
(a run that ended without finishing) are each red, and nothing remaps them.

The wrapper also annotates those three when GITHUB_ACTIONS is set. They share a
property that makes them worth naming on the check rather than burying in a
log: none of them is the entry point failing, and all of them read from the
check list like a broken diff. The spend limit most of all -- it fails every
entry point at once, in seconds. No retry.

The graces keep their defaults. They budget *silence*, not elapsed time --
every client line resets the clock -- so a cold start costs wall time without
consuming one. `build` is 155-221 s warm and ~7.5 min cold (#99), and all of
that cold build is after Python is alive, printing `Compiling`, under the
1200 s silence budget; 300 s of startup silence is sized against the failure
itself, a container that said nothing for twenty-six minutes.

CI.md moves the wrapper out from under "running it by hand" -- it is now how
every Modal invocation here happens -- and tiers 2 and 3 say the guard covers
them.

* CI.md: the graces, justified from the runner's own timestamps

The first run of this branch: build reaches its first `$ ` line 6.5 s in
having never been silent for more than 3.1 s, against a 300 s startup budget;
the longest quiet stretch anywhere in either job is 58.9 s of sm_100a codegen
against 1200 s. And in tier 2 the silence budget cannot bind at all -- the
entry point's own timeout=900 is shorter. Tier 3 is where a tighter value would
buy something and is the tier with no measurement here, so it keeps #99's.

Also: CI installs modal unpinned and drew 1.5.3, where #103's three exit-code
behaviours were measured on 1.5.1. That is the argument for the sentinel in one
line.

* CI.md: the device_tests numbers, and what the graces actually cover

A dispatched gpu.yml run on this branch: first alive line at +9.2 s after 4.4 s
of silence, sentinel at +95 s, 97 s in the step. With that, all three entry
points CI invokes are measured, and the shape is clear -- SILENCE_GRACE (1200)
is at or above each one's own timeout= (900/900/1200), so it dead-heats with
Modal's clock and STARTUP_GRACE is what covers the failure timeout= cannot see.
A lower silence budget is what these numbers argue for; not on one warm sample
each.
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