{"record":{"id":"bea392bb80d920ed","repo":"tracel-ai/burn","slug":"failed-to-load-module-from-file","errorCode":null,"errorMessage":"Failed to load module from file","messagePattern":"Failed to load module from file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-core/src/module/base.rs","lineNumber":510,"sourceCode":"    where\n        Self: Sized,\n    {\n        self.into_record().save(path)\n    }\n\n    /// Load this module's parameters from a burnpack file on disk, returning the loaded module.\n    ///\n    /// Uses the default load behavior. Panics on I/O or validation errors; use\n    /// [`try_load_file`](Module::try_load_file) for the fallible variant, or go through\n    /// [`ModuleRecord`](crate::store::ModuleRecord) to configure dtype policy, partial loading or\n    /// validation.\n    #[cfg(feature = \"std\")]\n    fn load_file<P: AsRef<std::path::Path>>(self, path: P) -> Self\n    where\n        Self: Sized,\n    {\n        self.try_load_file(path)\n            .expect(\"Failed to load module from file\")\n    }\n\n    /// Fallible variant of [`load_file`](Module::load_file).\n    ///\n    /// Reads the record from `path` with [`ModuleRecord::load`](crate::store::ModuleRecord::load)\n    /// and applies it through [`try_load_record`](Module::try_load_record).\n    #[cfg(feature = \"std\")]\n    fn try_load_file<P: AsRef<std::path::Path>>(\n        self,\n        path: P,\n    ) -> Result<Self, crate::store::RecordError>\n    where\n        Self: Sized,\n    {\n        let record = crate::store::ModuleRecord::load(path)?;\n        self.try_load_record(record)\n    }\n}","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-core/src/module/base.rs#L492-L528","documentation":"load_file loads a module's record from disk and applies it; the expect fires when reading or deserializing the file fails (missing file, unreadable path, or invalid/corrupt record format). It is the panicking convenience wrapper over try_load_file.","triggerScenarios":"Calling model.load_file(path) with a nonexistent path, a file saved with an incompatible recorder/format, or a truncated/corrupted checkpoint.","commonSituations":"Typo in checkpoint path, relative vs absolute path confusion at runtime, loading a .mpk/.bin file produced by a different burn version, or file deleted between existence check and load.","solutions":["Verify the path exists and is readable before loading (std::path::Path::exists).","Use try_load_file and match on the Result to get the underlying io/deserialization error.","Re-export the checkpoint with the same burn version and recorder used at save time."],"exampleFix":"// before\nlet model = Model::load_file(\"weights.mpk\");\n// after\nlet model = Model::try_load_file(\"weights.mpk\")\n    .unwrap_or_else(|e| panic!(\"failed to load weights.mpk: {e}\"));","handlingStrategy":"try-catch","validationCode":"let path = std::path::Path::new(\"weights.mpk\");\nassert!(path.exists() && path.is_file(), \"checkpoint file missing: {}\", path.display());","typeGuard":null,"tryCatchPattern":"let model = Model::try_load_file(&path)\n    .unwrap_or_else(|e| panic!(\"failed to load checkpoint {}: {e}\", path.display()));","preventionTips":["Check path existence/readability before load","Use try_load_file to surface the real io/serialization error","Save and load checkpoints with the same burn version and recorder type"],"tags":["rust","io","checkpoint","file-loading","panic"],"backgroundTag":"checkpoint-load-failed","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"}