tracel-ai/burn · error

Can delete learning rate scheduler checkpoint.

Error message

Can delete learning rate scheduler checkpoint.

What it means

In `Learner::checkpoint`, the learning-rate-scheduler checkpointer's `delete(epoch)` is unwrapped with expect(). It panics with this message when the LR scheduler checkpoint for that epoch cannot be deleted by the file recorder.

Source

Thrown at crates/burn-train/src/learner/base.rs:173

        }
    }

    /// Create checkpoint for the training process.
    pub fn checkpoint(&mut self, learner: &Learner<M>, epoch: usize, store: &EventStoreClient) {
        let actions = self.strategy.checkpointing(epoch, store);

        for action in actions {
            match action {
                CheckpointingAction::Delete(epoch) => {
                    self.model
                        .delete(epoch)
                        .expect("Can delete model checkpoint.");
                    self.optim
                        .delete(epoch)
                        .expect("Can delete optimizer checkpoint.");
                    self.lr_scheduler
                        .delete(epoch)
                        .expect("Can delete learning rate scheduler checkpoint.");
                }
                CheckpointingAction::Save => {
                    self.model
                        .save(epoch, learner.model.clone().into_record())
                        .expect("Can save model checkpoint.");
                    self.optim
                        .save(epoch, learner.optim.to_record())
                        .expect("Can save optimizer checkpoint.");
                    self.lr_scheduler
                        .save(epoch, learner.lr_scheduler.to_record())
                        .expect("Can save learning rate scheduler checkpoint.");
                }
            }
        }
    }

    /// Load a training checkpoint.
    ///

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Confirm the LR scheduler checkpoint file for the epoch exists in the configured directory and is deletable.
  2. Ensure all three checkpoints (model, optimizer, scheduler) are saved/deleted atomically per epoch.
  3. Point the checkpointer at the directory that actually holds the scheduler checkpoints.
  4. Stop concurrent training jobs sharing the checkpoint directory.
  5. If a prior crash left partial checkpoints, restore the set from backup or delete the whole epoch directory manually and resave.

Example fix

// before
actions = vec![CheckpointingAction::Delete(epoch)]; // scheduler file never written (previous crash)
// after: save all components first, or guard the delete
if scheduler_file_exists(dir, epoch) {
    actions.push(CheckpointingAction::Delete(epoch));
}
checkpointer.checkpoint(actions);
Defensive patterns

Strategy: validation

Validate before calling

let sched_path = Path::new(&checkpoint_dir).join(format!("scheduler-{epoch}"));
if !sched_path.exists() {
    eprintln!("scheduler checkpoint missing for epoch {epoch}; not scheduling delete");
}

Type guard

fn scheduler_checkpoint_exists(dir: &str, epoch: usize) -> bool {
    Path::new(dir).join(format!("scheduler-{epoch}")).exists()
}

Try / catch

let result = std::panic::catch_unwind(AssertUnwindSafe(|| checkpointer.checkpoint(actions)));
if result.is_err() { eprintln!("LR scheduler checkpoint delete failed"); }

Prevention

When it happens

Trigger: Applying CheckpointingAction::Delete(epoch) where the LR scheduler checkpoint file for that epoch does not exist or cannot be removed (permissions, IO error, wrong directory).

Common situations: Incomplete checkpoint sets where the scheduler file was never saved (e.g. crash between model and scheduler saves) or was cleaned externally; misconfigured checkpoint path; concurrent runs.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/a0b505ce7047314f. Report an issue: GitHub.