Failures¶
What AUTONMI does when an agent fails, when a worker dies, when a model server goes away, and when a population fails.
An agent's end¶
Every agent ends once: done, failed, cancelled or interrupted. One agent's failure never stops
another. Its row says how it ended (status, error), and the run's report counts the agents by
end. Of these ends, only an agent done without its result (status done, finished false) fails the
run, through the campaign's check every_done_agent_has_its_result. Whether failed or cancelled
agents fail the run is for the application's own checks to say.
- A tool-calling agent's model reads a failed task's error, and may call again.
- A scripted agent fails (
SimulationFailed) when one of its simulations fails or is cancelled, unless it reads failures as values (ScriptedAgent(task_errors="value")): the step then gets aTaskFailedin the task's place, with the call's id and why. - A scripted agent also fails when its step does what its runner refuses: a model call past
model_calls_limit(RuntimeError); aLookupwith nolookupcallback, a step that returns no action, or a plain step that returns an awaitable (TypeError); acall_idused again since the agent's last model call (ValueError). Its row'serrorsays which. ARememberorReportwith no callback does nothing. - A model call that the fleet cannot complete fails its agent.
A worker that dies¶
A worker killed for memory, or crashed in native code, fails the simulations it was running. The
population counts them (lost_tasks in population.json). autonmi.pools.lost tells such a
failure from one in the simulation's own code.
| Where | What a dead worker costs |
|---|---|
| Under Dragon | RHAPSODY's native backend fails only the dead worker's task, and replaces the worker |
Locally, autonmi.pools.GpuPools |
every task in that GPU's pool, running or queued; the pool replaces itself at the next task |
Locally, executor="autonmi.pools:spawn_pool" |
every task in the pool; the pool replaces itself (pool_replaced counts it) |
Locally, a plain ProcessPoolExecutor |
every task in the pool, and every later one: the pool stays broken |
A scripted agent's simulation whose worker died runs again, with the same call and arguments, up to
PopulationConfig.retries times (2), and the agent waits for that run. After the last, the agent
fails with "its worker died in each of its 3 runs" (with retries=2), or with task_errors="value"
its step gets a TaskFailed that says so. max_retries caps how many lost simulations the
population runs again, over all its agents (no cap by default); past it, a lost simulation gives no
value at once. A simulation's own errors never run again. Locally one death fails every task in its
pool, so the other agents' tasks lost with it run again too, and count toward their own retries
and the population's max_retries.
The runner's stats in population.json count the lost tasks (lost), the runs again (rerun), those
out of runs (lost_for_good), and whether max_retries left one to fail (max_retries_spent). The
rows' tasks_failed counts the lost runs.
retries and max_retries apply to scripted agents only: a tool-calling agent's model reads the
failure instead, and may call again.
Rule: every simulation must be safe to run again for the same call.
A model server that goes away¶
A call that fails with a transient error (a refused connection, a timeout, a 5xx, a 401 after a new
key) is not lost: the fleet waits for its replica to come back, for at most outage_s (1,800 s),
checking every poll_s (5 s), and sends the call again.
- A server restarted in place comes back at its URL.
- A model job that was preempted and requeued comes back on new ports with a new key. The fleet reads
the model job's
endpointsandapi-keyfiles again, and rebuilds the replica's transport. - A call sent again counts once in the agents' rows and in the check
fleet_calls_match_the_rows. - After a restart or a move, the servers' counters no longer cover the whole run, so
tokens_match_the_serversdoes not compare them, and says why. - With
outage_s0 a failed call fails at once.
A population that fails¶
The populations run as one. When one fails, or the populations together outlast
CampaignConfig.timeout_s, the campaign:
- cancels the others, and waits for them to end, at most
cancel_grace_s(60 s); - writes why to
app/failure.json: which failed, and which were cancelled or timed out; locally, also which were still running after the grace; - records the check
every_population_ranas failed in the run's report; - raises. The script stops the services after that, in a
finally(close()stops them if it does not), so only an abandoned population (below) may still be using them.
Locally a cancelled population still waits for the simulations it has running, which a thread cannot
stop. One still running after the grace is listed as abandoned in app/failure.json. It runs on
until its simulations end. Under Dragon, RHAPSODY's native backend ends a cancelled population's
process. When the run times out with no population failed, the campaign writes the stack of every
thread of the mini-app's process to RUN/campaign-stacks.txt.
A population that fails cannot be recovered: its agents are not run elsewhere.