{"record":{"id":"a0b505ce7047314f","repo":"tracel-ai/burn","slug":"can-delete-learning-rate-scheduler-checkpoint","errorCode":null,"errorMessage":"Can delete learning rate scheduler checkpoint.","messagePattern":"Can delete learning rate scheduler checkpoint\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/learner/base.rs","lineNumber":173,"sourceCode":"        }\n    }\n\n    /// Create checkpoint for the training process.\n    pub fn checkpoint(&mut self, learner: &Learner<M>, epoch: usize, store: &EventStoreClient) {\n        let actions = self.strategy.checkpointing(epoch, store);\n\n        for action in actions {\n            match action {\n                CheckpointingAction::Delete(epoch) => {\n                    self.model\n                        .delete(epoch)\n                        .expect(\"Can delete model checkpoint.\");\n                    self.optim\n                        .delete(epoch)\n                        .expect(\"Can delete optimizer checkpoint.\");\n                    self.lr_scheduler\n                        .delete(epoch)\n                        .expect(\"Can delete learning rate scheduler checkpoint.\");\n                }\n                CheckpointingAction::Save => {\n                    self.model\n                        .save(epoch, learner.model.clone().into_record())\n                        .expect(\"Can save model checkpoint.\");\n                    self.optim\n                        .save(epoch, learner.optim.to_record())\n                        .expect(\"Can save optimizer checkpoint.\");\n                    self.lr_scheduler\n                        .save(epoch, learner.lr_scheduler.to_record())\n                        .expect(\"Can save learning rate scheduler checkpoint.\");\n                }\n            }\n        }\n    }\n\n    /// Load a training checkpoint.\n    ///","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/learner/base.rs#L155-L191","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Confirm the LR scheduler checkpoint file for the epoch exists in the configured directory and is deletable.","Ensure all three checkpoints (model, optimizer, scheduler) are saved/deleted atomically per epoch.","Point the checkpointer at the directory that actually holds the scheduler checkpoints.","Stop concurrent training jobs sharing the checkpoint directory.","If a prior crash left partial checkpoints, restore the set from backup or delete the whole epoch directory manually and resave."],"exampleFix":"// before\nactions = vec![CheckpointingAction::Delete(epoch)]; // scheduler file never written (previous crash)\n// after: save all components first, or guard the delete\nif scheduler_file_exists(dir, epoch) {\n    actions.push(CheckpointingAction::Delete(epoch));\n}\ncheckpointer.checkpoint(actions);","handlingStrategy":"validation","validationCode":"let sched_path = Path::new(&checkpoint_dir).join(format!(\"scheduler-{epoch}\"));\nif !sched_path.exists() {\n    eprintln!(\"scheduler checkpoint missing for epoch {epoch}; not scheduling delete\");\n}","typeGuard":"fn scheduler_checkpoint_exists(dir: &str, epoch: usize) -> bool {\n    Path::new(dir).join(format!(\"scheduler-{epoch}\")).exists()\n}","tryCatchPattern":"let result = std::panic::catch_unwind(AssertUnwindSafe(|| checkpointer.checkpoint(actions)));\nif result.is_err() { eprintln!(\"LR scheduler checkpoint delete failed\"); }","preventionTips":["Save and delete model/optimizer/scheduler checkpoints together so sets stay complete.","Recover from crashes by checking all three components exist before resuming or pruning.","Use create_dir_all on the checkpoint base dir before training starts."],"tags":["rust","panic","io","checkpoint","learning-rate-scheduler"],"backgroundTag":"checkpoint-io-failure","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}