kempnerforge.checkpoint.ownership¶
One training run per checkpoint directory.
Before a training run resumes or saves, rank 0 records the run in <checkpoint.dir>/.owner,
and it marks the record released when the run ends cleanly. Two live runs in one directory
would overwrite each other’s checkpoints, prune them and resume from them, so a run is
refused a directory that another run still owns.
Functions
|
Record this run as the owner of |
|
Mark |
|
A new owner record for this process. |
Exceptions
Another run that is alive, or not known to have ended, owns the checkpoint directory. |
- exception kempnerforge.checkpoint.ownership.CheckpointDirInUseError[source]¶
Bases:
RuntimeErrorAnother run that is alive, or not known to have ended, owns the checkpoint directory.
- kempnerforge.checkpoint.ownership.this_run()[source]¶
A new owner record for this process.
claimis new for every record.processis a random id of this process, by which it knows its own records.pid_nsis the pid namespacepidis numbered in, since containers that share the host name but not that namespace reuse pids.slurm_jobis the SLURM job, or job array element (<array job>_<task>), that runs the process, andslurm_restartcounts the times SLURM requeued it.
- kempnerforge.checkpoint.ownership.claim_checkpoint_dir(directory)[source]¶
Record this run as the owner of
directoryunless another run owns it.The record is written to a temp file of its own and linked into place, so it appears whole and only one claimer creates it. A record this process wrote is replaced, unless it released it, since another claimer may be taking a released record over. A record of a run that has ended is replaced by one claimer alone (see
_take_over), which reads the record back before it counts the claim; the replacement is logged as a warning unless the record was released. Claims and releases in one process run one at a time.- Returns:
The new record’s claim id, for
release_checkpoint_dir.- Raises:
CheckpointDirInUseError – A run that is alive, or whose state this host cannot check, owns
directory, or another claimer is taking it over.- Parameters:
directory (Path)
- Return type:
- kempnerforge.checkpoint.ownership.release_checkpoint_dir(directory, claim)[source]¶
Mark
directory’s owner record released when it is the record ofclaim.The record is replaced, through the same token as a takeover (see
_take_over), by a released record with a claim id of its own; nothing removes.owner, so a removal that NFS replays cannot remove a later run’s record. An error marking it is logged rather than raised, so the rest of the run’s teardown still runs.