Repository navigation
A stopped run is not a passing run, and the exit code will not say which (#103) - #115
Merged
Merged
Conversation
…ich (#103) `scripts/modal-run` returned whatever `modal run` returned, which is not a completion signal. Measured on client 1.5.1 against a `stall` entry point and a `modal app stop` from a second shell: stopping an app mid-function raises RemoteError and exits 1, stopping one between app creation and the function call hangs the client on AppHeartbeat indefinitely, and the field report that opened this issue saw 0. Three answers to one question. So `modal_app.py` now prints a completion sentinel after each entry point's last line -- `completes`, one print -- and the wrapper returns 0 only having seen it, and 4 otherwise. Absence of failure is not evidence of completion. `stall` is the control, and it is committed rather than scratch: one `$ ` line then a sleep, so stopping it reproduces the whole thing for a fractional CPU.
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.
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.
Closes #103.
scripts/modal-rundecided whether a run passed by askingmodal run. That isnot a question the client can answer, and step 1 of the issue was to find out
what it answers instead.
1. What
modal runactually returns when its app is stoppedA
stallentry point (CPU-only,_run(["sleep", …])) plusmodal app stop -yfrom a second shell. Bare
modalon purpose — the CLI's own behaviour is whatis under test, and this is the one place the wrapper is not the right tool.
Client 1.5.1, macOS, three runs.
Stopped while the function body is running — twice, independently:
Stopped between app creation and the function call — the stop issued from
the same script so it wins the race against container start:
That one never exits. It repeated that heartbeat every 15 s for 30
consecutive attempts (7½ minutes) before I killed it; the app was
stoppedwith0 tasks throughout, so nothing was billing — the client was simply waiting for a
result that was never coming.
So: I could not reproduce exit 0. The issue's observation stands as a
report; my two mid-function stops both gave 1. Stated plainly, because it
matters: the exact symptom #103 was opened on is unconfirmed on this client
version, and if the report was a misattribution — an agent stopping a
different duplicate app than the one its wrapper was running, which is exactly
the situation described — then the wrapper exited 0 correctly that day.
What the evidence does establish is the thing the fix rests on: the client's
exit code is not a completion signal. One question, three answers — 1, an
indefinite hang, and a field report of 0 — none documented, all incidental to
which internal path the client happens to take. A gate cannot be built on that,
and "it returned 1 the two times I stopped it in the middle" is not a guarantee
for the eviction, the mid-run spend limit, or the next client release.
2. The fix
modal_app.pygrows a sentinel and an eight-line decorator:applied under
@app.functionon all ten entry points, so it runs in thecontainer and the sentinel arrives on the stream the client is already reading.
An exception skips it, which is the point: only a finished body prints it.
scripts/modal-runreturns 0 only having seen that line. The reasoning livesnext to the constant in both files, because the next reader's question is "why
not just trust the exit code" and the answer is the section above.
Exit 4, not an overload of 2 or 3. 2 and 3 are both diagnoses — the
workspace is out of money; this wrapper watched a container wedge and stopped it
itself. 4 is the absence of one: the run ended, it did not fail, and it did not
finish, and the wrapper does not know why. Stopped, evicted, or the client
returning on something other than a result all land here and want the same
response (look at
modal app listand the log), which is a different responsethan either 2 or 3 asks for.
Order matters too: a run that failed on its own returns its own code, not 4. A
failed run is incomplete by definition and its own code says more.
The duplicated string.
scripts/modal-runcannot importCOMPLETED—modalships as its own venv (~/.local/share/uv/tools/modal/…) and thewrapper runs under whatever
python3is on PATH, whereimport modalis aModuleNotFoundError. I tried the import first; that is why it is not there. Sothe literal is spelled twice, with a comment in each naming the other. It is
safe because it fails closed: change one and every run exits 4 with a message
naming both files (control 4d below), rather than quietly passing.
3. The controls
#99's four, extended in place rather than joined by a fifth — its 4 splits into
the clean finish it always covered plus the three cases it did not. Same
stub-
modal-on-PATH harness #99 used, withMODAL_RUN_STARTUP_GRACE=5 MODAL_RUN_SILENCE_GRACE=4:4c is the case the issue is named for, and it is the one branch that cannot be
exercised against the real client — precisely because I could not make the real
client exit 0. So it is stubbed, and the two that can be real are run for real:
Real clean finish —
scripts/modal-run stall --seconds 5. This also proves@completessurvives Modal's CLI argument parsing (--secondsreaches thefunction through
functools.wraps), the one thing that could have gone wrongwith a decorator under
@app.function:Real stopped run —
scripts/modal-run stall --seconds 180, stopped from asecond shell once it was under way:
Non-zero, no sentinel, no false pass. On this client version it lands on the
run's-own-code branch rather than on 4, which is the honest result and is why
the acceptance criterion is met twice over: the client happened to be non-zero
here, and the sentinel would have caught it had it not been.
stallis committed rather than left in a scratch file, because it is the onlyway anyone watches this fire again, and it costs a fractional CPU and a minute.
Scope, and what is not done
Three files:
modal_app.py,scripts/modal-run,CI.md. No Rust —git diff --name-onlymatches nothing undersrc/,device-tests/,examples/, or any manifest, andscripts/fmt --checkis clean, so tier 1 isuntouched. No workflow runs a Python linter;
py_compilepasses on both files.CI.md§"Running Modal by hand" is now the three ways it costs you money,with the measurements above, the full exit-code table, and
stall.Not done, and it is the obvious next thing:
cuda.ymlandgpu.ymlstillcall
modal rundirectly, so neither this guard nor #99's watchdog covers CI atall — a wedged CI container still rides its
timeout=, and a stopped one isstill whatever the client decides to return. That is #99's unfinished business
rather than this issue's, and it is now written down in
CI.mdinstead of beingimplied.