RayTrainReportCallback#

class ray.train.lightning.RayTrainReportCallback(*args: Any, **kwargs: Any)[source]#

Bases: Callback

A simple callback that reports checkpoints to Ray on train epoch end.

This callback is a subclass of lightning.pytorch.callbacks.Callback.

It fetches the latest trainer.callback_metrics and reports together with the checkpoint on each training epoch end.

Checkpoints will be saved in the following structure:

checkpoint_00000*/      Ray Train Checkpoint
└─ checkpoint.ckpt      PyTorch Lightning Checkpoint

For customized reporting and checkpointing logic, implement your own lightning.pytorch.callbacks.Callback following this user guide: Saving and Loading Checkpoints.

Parameters:
  • checkpoint_upload_mode (CheckpointUploadMode | None) – The manner in which to upload the checkpoint. See Checkpoint upload modes for more details. Ray Train v2 only. Defaults to CheckpointUploadMode.SYNC.

  • validation (bool | ValidationTaskConfig) – Whether to asynchronously validate the checkpoint, or a ValidationTaskConfig for the validation task. See Validating checkpoints asynchronously for more details. Ray Train v2 only.

  • checkpoint_frequency (int) – Only report a checkpoint and metrics every checkpoint_frequency epochs. Defaults to 1, which reports on every epoch. If max_epochs isn’t a multiple of checkpoint_frequency, the epochs after the last multiple aren’t reported.

Raises:
  • TypeError – If checkpoint_frequency isn’t an integer.

  • ValueError – If checkpoint_frequency is less than 1, or if checkpoint_upload_mode or validation is set on Ray Train v1.

PublicAPI (beta): This API is in beta and may change before becoming stable.

Methods

on_train_epoch_end

Report metrics and a checkpoint to Ray Train at the end of an epoch.

Attributes