invalid inputs to TorchElastic APIs (e.g. min > max nodes) |
Worker Failure | any failures on the worker child process |
Platform Error | n/a | failures caused by the agent |
Infra Error | n/a | failures outside the domain of the agent and workers
(e.g. host failures) |
All errors other than “Worker Failure” are either raised canonically from the
agent process or implicitly or explicitly crash the agent process. So the
standard language (python) provided exception handling strategies apply.
Worker Failures are special because the exception/failure originates on a different
process from the agent so the error needs to be propagated inter-process
(e.g. the agent cannot simply try-catch an exception raised on the worker process).
Any function or binary entrypoint decorated with record()
will write uncaught exceptions (with the trace information) to a file specified by the
environment variable TORCHELASTIC_ERROR_FILE. The parent process (e.g. agent)
sets this env var on each child it launches, then aggregates the error files for all
children, and propagates the one with the smallest timestamp (e.g. the first error).
0: scheduler-init-process:
|- 1: torchelastic_agent:
|- 2: trainer_0 (ok)
|- 3: trainer_1 (fail) -> error.json
|- ...
|- n+2: trainer_n (ok)
|- n+3: other processes
|- ...
In the example above, trainer 1’s failure (written into error.json) is
the root cause and should be reported to the scheduler’s init process.
The torchelastic agent raises a ChildFailedError("trainer", {1: "trainer_1/error.json"})
upon detecting trainer 1’s failure which would propagate the contents
of trainer 1’s error file to the scheduler’s init process.
Note
It is assumed that the error_file is written by
torch.distributed.elastic.multiprocessing.errors.error_handler.ErrorHandler.
Otherwise the behavior is undefined.