Repository navigation
Conversation
[Medium impact] The changes affect T3 restart decisions and its long-running SA and ARC work. The PR needs changes before merging because queued RMG retries and pressure-dependent SA still bypass the intended stop behavior. FindingsSummaryThis PR recognizes RMG's own wall-time stop and adds timers around SA and ARC work.
Reviews (2) · Last reviewed commit: "Treat RMG's own wall-time stop as termin..." · Reviewed by Greptile |
dc62617 to
198d51f
Compare
…lltime check_rmg_status() now reports a third state. When the latest run in RMG.log ends in RMG's wall-time TERMINATED block, the run is terminal, so a restart no longer re-runs it. Its stop time is recorded in T3.rmg_walltime_stops, apart from a normally completed run. Logs without that block (crash, foreign kill, max-iterations stop) are restarted as before. max_T3_walltime is now enforced while the SA and ARC steps run, not only between steps. A SIGALRM timer cuts the step, terminates T3's multiprocessing children, and skips the final RMG run.
198d51f to
5523c3e
Compare
|
@greptileai review |
| rmg_status = self.check_rmg_status() | ||
| if rmg_status.walltime_stop is not None: | ||
| self.record_rmg_walltime_stop(iteration=self.iteration, walltime_stop=rmg_status.walltime_stop) |
There was a problem hiding this comment.
run_rmg() checks for a wall-time stop only after rmg_runner() returns. With rmg_execution_type='local', the runner still treats that stop as a failure and can submit the same run up to five times before returning. Users can therefore spend the same wall-time budget repeatedly. Apply the terminal-stop check inside the runner's retry decision too.
| if self.t3['sensitivity']['global_observables'] is not None \ | ||
| and any(go.lower() == 'idt' for go in self.t3['sensitivity']['global_observables']): | ||
| idt_simulate_adapter = simulate_factory(simulate_method='CanteraIDT', | ||
| with self._bounded_by_max_t3_walltime(): |
There was a problem hiding this comment.
The new SA timer ends before determine_species_and_reactions_to_calculate(), but that method also runs pressure-dependent SA. For a selected pressure-dependent reaction without cached results, it reaches run_arkane_job() without a timeout. That calculation can still exceed max_T3_walltime indefinitely. Include this SA path in the remaining budget and pass that budget to the Arkane timeout.
…rkane job The local-queue re-submit loop now ends when the run it waited for stopped at RMG's own wall time. The wall-time detector moved from t3/main.py to t3/runners/rmg_runner.py so both can use the one parser. A crash is re-submitted exactly as before. The P-dep SA's Arkane job gets the remaining max_T3_walltime as its timeout. A spent budget or a timed-out job raises T3WalltimeExceeded, so T3 ends as it does when the Cantera SA or ARC runs out of time. Without max_T3_walltime the call is unbounded, as before. ArkaneMESolverAdapter takes a timeout and forwards it.
Summary
T3 reads "the terminal marker is absent" as "the step did not finish", with no third state for "the
step was killed at a recorded time". Two symptoms fall out of that one gap, and this PR closes both.
A run that RMG itself stopped at its wall time is now terminal:
restart_rmgis not set, so thesame wall time is not spent twice. The stop time is kept per iteration in
rmg_walltime_stops, readfrom RMG's
execution terminated atline, else the run start plus its lastExecution time, elseRMG.log's mtime — the source is recorded alongside the time, so a weaker source is visible as one.max_T3_walltimenow bounds the long step rather than only the gap between steps. The timerterminates live
multiprocessingchildren before raising, because aProcessPoolExecutorotherwisewaits for its running tasks on the way out.
T3WalltimeExceededderives fromBaseExceptionso anexcept Exceptioninside the bounded step cannot swallow the budget.No scheduler coupling: T3 learns nothing about PBS.
max_T3_walltime's default and units areunchanged, and a normally completed run is handled exactly as before.
Evidence
Before: a wall-time-killed RMG writes no
MODEL GENERATION COMPLETED, socheck_rmg_status()returned
(True, False),restart_rmgwas set, and the run was repeated from the start — whichcontradicts the project decision that a wall-time kill counts as converged with its kill time
recorded. A step that never returned was never cut, because the only budget check sat after it.
After: 16 new tests in
tests/test_main.pycover both halves, including the negative controlsthat matter most here —
Full suite on the branch, run locally:
2 failed, 2899 passed, 463 warnings in 2555.52s.tests/test_main.pyalone at this head:63 passed in 208.22s.ruff check .→ All checks passed!Build and Test T3is red at this head, and it is red onmaintoo — this branch did not causeit.
main's own daily CI was green through 2026-11-15 and has failed every day from 2026-11-16to 2026-11-24 inclusive, nine consecutive runs, the last six at the unchanged head
4043bb98. ThisPR was opened 2026-11-24, eight days after
mainwent red. The 14 failures are all intests/test_pdep/test_pes_qm.pyandtests/test_pdep/test_pes_loop_integration.pyand arelevel-of-theory spelling mismatches (
wb97xdvswb97xd2023) plus the prior-QM adoption thatdepends on them — CI resolves ARC at its HEAD rather than a pin, so an upstream rename turned the
expectations stale. Those two files are not reachable from this diff, which touches only
t3/main.py's wall-time path andtests/test_main.py, and all 66 of their tests pass locallyat this head (
66 passed in 107.28s) against an older local ARC.Both failures are pre-existing and environmental, proven by running each id alone in a separate
source tree at
official/main, one at a time:official/maintests/test_functional.py::test_computing_thermocantera._utils.CanteraError … Application::findInputFiletests/test_simulate/test_cantera_idt.py::test_worker_failure_loggingsocket.py:236 PermissionError: [Errno 1] Operation not permittedThe second is the sandbox the run happened in, not the code: its brute-force IDT SA spawns workers
that cannot open a socket there. It is expected to pass in CI.
What a user sees change, and what is still not covered (CLEAN line 6)
1. ARC jobs already submitted to a server are left running, and now say so. When the budget runs
out inside the bounded ARC step, nothing cancels anything server-side. Until this PR that was also
silent:
T3WalltimeExceededderives fromBaseException, so theexcept Exceptionaroundarc.execute()cannot see it, and theARC terminated, execution time: ...line is skipped — theunwind reached only
log_max_time_reached(), which names a time limit and no directory.run_arcnow logs an error naming the ARC project directory (
self.paths['ARC']) and saying the submittedjobs may still be running there and that T3 will not collect their results.
Test:
test_a_cut_arc_run_logs_its_project_directory— asserts the project directory and bothclaims appear in the message; proven red without the handler in a clean
git archivetree(
AssertionError: Expected 'error' to have been called once. Called 0 times.).Not covered: T3 still does not cancel those jobs. This PR makes the fact visible; it does not add
cancellation, and a user who wants the jobs stopped must do it on the server.
2. A cut inside
process_arc_runcannot be read as done on the next run. The ARC finalizationmarker is the idempotence guard:
run_arcclears it before the run and it is written only once themethod completes, so a cut anywhere inside leaves no marker,
check_arc_finalization_complete()isFalse, and the restart re-runs the whole method. Themid-method
t3_statusupdates are in memory and die with the process, so no partial status ispersisted. The one step that writes a durable directory,
_capture_pdep_ts_artifacts(), iscrash-safe by construction rather than by luck: the capture is built in a staging directory,
self-verified with the same
verify_capture()a downstream consumer would use, and only thenswapped into place (existing tree renamed aside, then
os.replaceonto the vacant path), soPDep_captureis never observed partial and theos.path.isdir(...)check upstream of it cannotsee a torn capture.
Test: the restart path is covered by
test_resumed_arc_run_is_bounded_by_max_t3_walltime; themarker and capture-swap behaviour is pre-existing and already covered by the
tests/test_pdepcapture tests this PR does not touch.
Not covered: a cut mid-capture can leave the staging directory and the renamed-aside
old-capturetemporary directory on disk. That is disk litter, not a wrong read — nothingenumerates either — and this PR does not clean it up.
3. The timer terminates only the children the bounded step itself started, and none of them holds
a file T3 reads later.
_on_alarmsnapshotsmultiprocessing.active_children()on entry andterminates only children absent from that snapshot, so a caller's own pool survives. Of the children
a bounded step starts, the only one that writes a file is the brute-force SA worker in
t3/simulate/cantera_idt.py, and it writes exactly one: the perturbed mechanism copy<SA>/{thermo|kinetics}_{index}.yaml, removed in afinallythat aSIGTERMfromterminate()skips — so a cut can leave one behind. Nothing reads it: there is no
globorlistdiroverpaths['SA']anywhere int3/, the path is deterministic per task, and the next run'sperturb_enthalpy/perturb_reaction_rate_coefficientoverwrites it unconditionally. The SA YAMLsthemselves (
paths['SA IDT dict'],paths['SA IDT dict top X']) are written by the parent afterthe pool closes, and the workers run with
save_yaml=False— so a terminated child cannot leave ahalf-written SA YAML at all.
Test:
test_max_t3_walltime_bound_leaves_the_callers_children_alone(the snapshot) andtest_max_t3_walltime_bound_stops_a_process_pool(no pool worker survives the cut).Not covered: the leftover perturbed-mechanism file is not deleted on a cut.
What a reviewer should look at: the
finallyin_bounded_by_max_t3_walltime()— it restoresthe caller's handler before rearming the caller's timer, and restores the remaining time rather
than the original delay. Getting that order wrong lands the caller's alarm in our handler and raises
out of a
finally.Merge Danger
Door: two-way
Every change is additive or a widening of a return value; reverting restores the previous behaviour
exactly. Nothing persisted on disk changes format.
Blast Radius: callers of
check_rmg_status()check_rmg_status()returnsRMGRunStatusinstead oftuple[bool, bool]. It is still a tuple, soindexing and
began, terminated, *_ = ...keep working, but a caller written asbegan, terminated = t3.check_rmg_status()now raisesValueError: too many values to unpack—walltime_stopis a third field. Every in-tree caller is updated; an out-of-tree caller of thismethod would need the same one-line change.
The second risk worth naming is the
SIGALRMtimer. It is armed only whenmax_T3_walltimeis set,only from the main thread (elsewhere it logs a warning and runs unbounded, as before), and the
previous handler and timer are restored in a
finally. A process that installs its ownSIGALRMhandler around a T3 call gets it back unchanged.