{"record":{"id":"e824a998a7d30b79","repo":"tracel-ai/burn","slug":"can-save-learning-rate-scheduler-checkpoint","errorCode":null,"errorMessage":"Can save learning rate scheduler checkpoint.","messagePattern":"Can save learning rate scheduler checkpoint\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-train/src/learner/base.rs","lineNumber":184,"sourceCode":"                        .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    ///\n    /// No device is taken: checkpoints are device-free burnpack records (file-backed bytes). On\n    /// load, the model keeps the device of the learner's existing parameters, and the optimizer\n    /// state is migrated to each parameter's device on the next step. The training device is fixed\n    /// earlier, when the learner's model is created/forked.\n    pub fn load_checkpoint(&self, mut learner: Learner<M>, epoch: usize) -> Learner<M> {\n        let record = self\n            .model\n            .restore(epoch)\n            .expect(\"Can load model checkpoint.\");\n        learner.load_model(record);\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-train/src/learner/base.rs#L166-L202","documentation":"On CheckpointingAction::Save, the learning-rate scheduler record is written via its checkpointer and unwrapped with expect(). Failure to serialize or write the scheduler checkpoint panics with this message.","triggerScenarios":"Calling checkpoint() with Save when the LR scheduler record cannot be written: unwritable/missing checkpoint directory, disk full, or serialization error for the scheduler record.","commonSituations":"Scheduler checkpointer configured with a different (typo'd) path than the other checkpointers; permissions changed on the dir after startup; disk filled during the save sequence (model and optimizer succeeded, scheduler failed).","solutions":["Verify the scheduler FileCheckpointer's directory matches the other checkpointers and is writable.","Check free disk space — saves happen sequentially, so an almost-full disk often fails on the last component.","Create the directory up front (create_dir_all) before training starts.","If a partial save happened, delete that epoch's three files and re-run the Save action.","Keep all three checkpointers pointed at the same base directory to spot misconfiguration quickly."],"exampleFix":"// before\nlet sched_cp = FileCheckpointer::new(Recorder, \"/checkpoint/sched\", \"scheduler\"); // wrong dir\n// after\nlet base = \"/checkpoints/run-1\";\nstd::fs::create_dir_all(base)?;\nlet model_cp = FileCheckpointer::new(Recorder, base, \"model\");\nlet optim_cp = FileCheckpointer::new(Recorder, base, \"optim\");\nlet sched_cp = FileCheckpointer::new(Recorder, base, \"scheduler\");","handlingStrategy":"validation","validationCode":"let dir = Path::new(&checkpoint_dir);\nstd::fs::create_dir_all(dir).expect(\"create checkpoint dir\");\nassert!(dir.metadata().unwrap().permissions().readonly() == false, \"checkpoint dir read-only\");","typeGuard":"fn dir_writable(dir: &str) -> bool {\n    let p = Path::new(dir).join(\".probe\");\n    std::fs::write(&p, b\"1\").is_ok() && std::fs::remove_file(p).is_ok()\n}","tryCatchPattern":"let result = std::panic::catch_unwind(AssertUnwindSafe(|| checkpointer.checkpoint(actions)));\nif result.is_err() { eprintln!(\"scheduler checkpoint save failed; check dir/disk\"); }","preventionTips":["Configure all three checkpointers with the same base directory to catch path typos.","Create the checkpoint directory before constructing checkpointers.","Check disk headroom before each save epoch — sequential saves fail last on a full disk."],"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"}