{"record":{"id":"03419bb2bffe0801","repo":"tracel-ai/burn","slug":"can-delete-optimizer-checkpoint","errorCode":null,"errorMessage":"Can delete optimizer checkpoint.","messagePattern":"Can delete optimizer checkpoint\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/learner/base.rs","lineNumber":170,"sourceCode":"            lr_scheduler,\n            strategy,\n            _phantom: PhantomData,\n        }\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    }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/learner/base.rs#L152-L188","documentation":"Same checkpointing flow as the model delete: the optimizer checkpointer's `delete(epoch)` is unwrapped with expect() and panics with this message when the optimizer checkpoint for that epoch cannot be deleted (file missing or IO error).","triggerScenarios":"Applying CheckpointingAction::Delete(epoch) where the optimizer checkpoint file for `epoch` is absent, already removed, or the recorder lacks permission/disk access to remove it.","commonSituations":"Partial checkpoint sets (model file present but optimizer file deleted by disk cleanup or an interrupted save); wrong checkpoint directory; concurrent jobs deleting each other's files.","solutions":["Verify the optimizer checkpoint file for the epoch exists in the checkpoint directory and is writable.","Keep model/optimizer/scheduler checkpoints as an atomic set — restore or delete all three together.","Avoid external cleanup of individual checkpoint files while training is running.","Use a dedicated checkpoint directory per run to prevent concurrent deletion.","If your workflow deletes files externally, disable the Delete actions or make your wrapper tolerate missing epochs."],"exampleFix":"// before: deleting epoch 12 after manual cleanup removed only optim-12\n// after: delete the whole epoch as a unit or check first\nfor prefix in [\"model\", \"optim\", \"scheduler\"] {\n    assert!(Path::new(dir).join(format!(\"{prefix}-{epoch}\")).exists(), \"{prefix} checkpoint missing\");\n}\ncheckpointer.checkpoint(actions);","handlingStrategy":"validation","validationCode":"let optim_path = Path::new(&checkpoint_dir).join(format!(\"optim-{epoch}\"));\nassert!(optim_path.exists(), \"optimizer checkpoint for epoch {epoch} not found before delete\");","typeGuard":"fn has_full_checkpoint(dir: &str, epoch: usize) -> bool {\n    [\"model\", \"optim\", \"scheduler\"].iter().all(|p| Path::new(dir).join(format!(\"{p}-{epoch}\")).exists())\n}","tryCatchPattern":"let result = std::panic::catch_unwind(AssertUnwindSafe(|| checkpointer.checkpoint(actions)));\nif result.is_err() { /* restore or skip */ }","preventionTips":["Treat an epoch's three checkpoint files as one atomic unit — delete all or none.","Avoid manual cleanup scripts targeting individual component files.","Persist all components in the same directory with a consistent prefix scheme."],"tags":["rust","panic","io","checkpoint","optimizer-state"],"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"}