noether.core.callbacks.default.train_time¶
Classes¶
Callback to log the time spent on dataloading. Is initialized by the |
Module Contents¶
- class noether.core.callbacks.default.train_time.TrainTimeCallback(callback_config, **kwargs)¶
Bases:
noether.core.callbacks.periodic.PeriodicCallbackCallback to log the time spent on dataloading. Is initialized by the
BaseTrainerand should not be added manually to the trainer’s callbacks.- Parameters:
callback_config (noether.core.schemas.callbacks.CallBackBaseConfig) – Configuration for the callback. See
CallBackBaseConfigfor available options.trainer – Trainer of the current run.
model – Model of the current run.
data_container –
DataContainerinstance that provides access to all datasets.tracker –
BaseTrackerinstance to log metrics to stdout/disk/online platform.log_writer –
LogWriterinstance to log metrics.checkpoint_writer –
CheckpointWriterinstance to save checkpoints.metric_property_provider –
MetricPropertyProviderinstance to access properties of metrics.name – Name of the callback.
- track_after_update_step(*, times, **_)¶
Hook called after each optimizer update step.
This method is invoked after a successful optimizer step and parameter update. It is typically used for tracking metrics that should be recorded once per update cycle, such as:
Latest loss values
Learning rates
Model parameter statistics (norms, etc.)
Training throughput and timing measurements
Unlike
periodic_callback(), this hook is called on every update step, making it suitable for maintaining running averages or high-frequency telemetry.Note
This method is executed within a
torch.no_grad()context.- Parameters:
update_counter –
UpdateCounterinstance to access current training progress.times (dict[str, float]) – Dictionary containing time measurements for various parts of the training step (e.g., ‘data_time’, ‘forward_time’, ‘backward_time’, ‘update_time’).
- Return type:
None
- periodic_callback(**_)¶
Hook called periodically based on the configured intervals.
This method is the primary entry point for periodic actions in subclasses. It is triggered when any of the configured intervals (
every_n_epochs,every_n_updates, orevery_n_samples) are reached.Subclasses should override this method to implement periodic logic such as:
Calculating and logging expensive validation metrics
Saving specific model checkpoints or artifacts
Visualizing training progress (e.g., plotting samples)
Adjusting training hyperparameters or model state
Note
This method is executed within a
torch.no_grad()context.- Parameters:
interval_type – “epoch”, “update”, “sample” or “eval” indicating which interval triggered this callback.
update_counter –
UpdateCounterinstance providing details about the current training progress (epoch, update, sample counts).**kwargs – Additional keyword arguments passed from the triggering hook (e.g., from
after_epoch()orafter_update()).
- Return type:
None
- after_training(**_)¶
Hook called once after the training loop finishes.
This method is intended to be overridden by derived classes to perform cleanup or final reporting tasks after training is complete. Common use cases include:
Performing a final evaluation on the test set
Saving final model weights or artifacts
Sending notifications (e.g., via Slack or email) about the completed run
Closing or finalizing experiment tracking sessions
Note
This method is executed within a
torch.no_grad()context.- Parameters:
update_counter –
UpdateCounterinstance to access current training progress.- Return type:
None