Best Checkpoint Saving#
By default, TAO writes a periodic model_epoch_*.pth checkpoint at every
train.checkpoint_interval and maintains a *_latest symlink that points at the most
recent one. This periodic history is unbounded. It keeps every interval checkpoint and does not
consider model performance on the validation metric. The best epoch is not necessarily the last
one, so the *_latest checkpoint is not always the one you want to deploy.
The train.checkpointer configuration adds metric-based checkpointing: TAO monitors a
validation metric and keeps the checkpoint(s) that score best on it. This lets you retain the
best model without having to inspect the training logs and copy checkpoints by hand.
Parameters#
All fields live under train.checkpointer:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Save checkpoint(s) ranked by a monitored metric. This is additive to periodic
checkpointing unless |
|
bool |
|
When best-checkpoint saving is enabled, replace the unbounded periodic checkpoint
callback with a single metric-best checkpoint and make it own the |
|
str |
|
Metric to rank checkpoints by; for example, |
|
str |
|
Direction that counts as “better” for |
|
int |
|
How many best checkpoints to keep ( |
Additive vs. Replace Behavior#
Best-checkpoint saving has two modes, both gated on enable_topk=True:
Additive (default,
replace_periodic=False). TAO appends a second, metric-monitored checkpoint callback alongside the existing periodic one. The periodicmodel_epoch_*.pthhistory, the*_latestsymlink, and the exception checkpoint are all left untouched; you simply also get up tosave_top_kbest-scoring checkpoints (model_best_*.pth). Use this when you want the full periodic history and the best checkpoints.Replace (
replace_periodic=True). TAO removes the unbounded periodic checkpoint callback and keeps a single metric-best checkpoint instead. That best checkpoint then owns the*_latestsymlink, so downstream steps that consume*_latest(evaluate, export, inference) automatically pick up the best epoch. This mode always keeps exactly one checkpoint, sosave_top_khas no effect. Use it to bound disk usage and make*_latestmean “best” rather than “most recent.” Exception checkpointing remains independent in either mode.
Choosing the Monitor and Mode#
monitor names the validation metric to rank by and mode gives its direction.
When both are left unset, TAO falls back to the network’s default monitored metric and
direction, which is the recommended starting point. Each network already declares a sensible
default (for example, a detection network monitors mAP with mode: max, while a network
trained to a loss uses val_loss with mode: min). Override them only when you want to
rank on a different metric than the network default. If you set monitor to a metric
that is not logged during validation, no best checkpoint can be selected, so make sure the
metric name matches one the network reports.
When to Prefer Metric-Best Checkpoints#
Deploying the best model, not the last one. With periodic-only checkpointing you must read the logs to find the best epoch and copy it out by hand. Metric-best checkpointing keeps it for you, and
replace_periodic=Trueadditionally makes*_latestpoint at it.Bounding disk usage. The periodic callback keeps every interval checkpoint. Setting
replace_periodic=Truekeeps exactly one, andsave_top_kbounds the additive mode to a fixed number.Guarding against late-training regressions. If a run overfits or diverges near the end, the last checkpoint can be worse than an earlier one. Metric-best checkpointing preserves the peak-performing epoch regardless of what happens afterward.
Keep periodic checkpointing (leave enable_topk=False) when you need the full training
history. For example, to resume from an arbitrary epoch or to analyze training dynamics.
Example#
Keep the single best checkpoint by validation loss, in addition to the periodic checkpoints:
train:
checkpoint_interval: 1
checkpointer:
enable_topk: true
monitor: val_loss
mode: min
save_top_k: 1
Keep the three best checkpoints by mAP, still alongside the periodic history:
train:
checkpointer:
enable_topk: true
monitor: mAP
mode: max
save_top_k: 3
Replace the periodic history with a single best-by-mIoU checkpoint that owns *_latest:
train:
checkpointer:
enable_topk: true
replace_periodic: true
monitor: val_miou
mode: max
The same overrides work from the command line, for example:
<task> train \
-e /path/to/experiment.yaml \
results_dir=/path/to/results \
train.checkpointer.enable_topk=True \
train.checkpointer.replace_periodic=True \
train.checkpointer.monitor=val_miou \
train.checkpointer.mode=max
Note
The tao-deploy TrainConfig carries the same train.checkpointer schema, so a
specification file written for training remains valid across the deploy tasks.