Skip to content

scripts/modal-run returns 0 for a run that was stopped, so a killed gate reads as a passing one #103

Closed

Description

@feitreim

#99 added scripts/modal-run to stop a wedged container rather than let it ride
the function timeout. It passes the run's own exit code through, which is
correct and was one of its four positive controls.

But modal run appears to exit 0 when its app is stopped out from under it.
Observed while #102 was in flight: an agent killed a duplicate ::regcount
container with modal app stop -y, and the wrapper reported exit 0. It noticed,
made no claim from it, and said so — which is the only reason this is written
down rather than sitting in a PR body as a green check that never ran.

That is the wrong way for this to fail. A stopped run and a passing run must not
be the same exit code, because the whole point of the wrapper is that a human or
an agent acts on what it reports.

Why it matters more than it looks

The wrapper's own wedge path calls modal app stop (#99). So on the branch
where it correctly detects a hang, it stops the app — and if the client then
exits 0, the only thing distinguishing "I killed a wedged run" from "the run
passed" is the wrapper's own bookkeeping. It happens to have that bookkeeping
(it returns 3 explicitly), so its own path is sound. The unsound path is
everything else
: a concurrent agent stopping an app, a Modal-side eviction, a
spend limit tripping mid-run, someone hitting the dashboard's stop button.

An agent that reads exit 0 as "the gate passed" then reports verified work that
was never verified. That failure mode has already cost this repo once, in a
different guise — see the memory of a red build that was the spend limit and
not the diff.

Scope

  1. Establish what modal run actually returns when its app is stopped
    externally. One observation from a session that was doing something else is
    not enough to build on. A CPU-only function and a modal app stop from a
    second shell settles it for the price of a container-minute.
  2. Make a stopped run non-zero, whatever the CLI does. If the exit code
    cannot be trusted, the wrapper needs positive evidence of completion rather
    than absence of failure — the entry point's own final line, or a sentinel
    _run prints after the last command, checked before the wrapper returns 0.
    Prefer the sentinel: it is one line in modal_app.py and it does not depend
    on parsing anyone's CLI output.
  3. A positive control, per layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67/softmax is now the slow kernel by 5.8x, and its CHUNK rung is only a quarter of it #76/gemm_cg2 is three registers from losing a third of its occupancy, and nothing is watching #95/A wedged container held a B200 for 26 minutes, and nothing was watching for it #99: stop an app mid-run and watch
    the wrapper go non-zero. A wedged container held a B200 for 26 minutes, and nothing was watching for it #99's four controls are the shape to copy — the
    fourth of them (a clean finish passing its own exit code through) is exactly
    the one this issue says is incomplete, so extend that control rather than
    adding a fifth beside it.

Acceptance

scripts/modal-run cannot return 0 for a run that did not finish, demonstrated
by stopping one. The reasoning for whichever mechanism is chosen lives next to
it, since the next reader's question will be "why not just trust the exit code".

Related: #99 (the wrapper and its controls), #93 (the fractional-CPU fix that
preceded it), #100 (regcount as a tier-2 job, which is why running gates by
hand is now redundant and this class of mistake is rarer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions