tracel-ai/burn · error
Failed to load record
Error message
Failed to load record
What it means
load_record is the infallible wrapper around try_load_record; it panics with 'Failed to load record' when the record does not match the module's structure (missing/extra fields, shape or dtype mismatches). The library panics because record validation failures are considered programming errors rather than runtime conditions.
Source
Thrown at crates/burn-core/src/module/base.rs:482
self,
record: crate::store::ModuleRecord,
) -> Result<Self, crate::store::RecordError>
where
Self: Sized,
{
record.apply(self)
}
/// Apply a [`ModuleRecord`](crate::store::ModuleRecord) to this module, consuming and returning
/// it.
///
/// Panics if validation fails; use [`try_load_record`](Module::try_load_record) for the
/// fallible variant.
fn load_record(self, record: crate::store::ModuleRecord) -> Self
where
Self: Sized,
{
self.try_load_record(record).expect("Failed to load record")
}
/// Save this module's parameters to a burnpack file on disk.
///
/// Convenience for [`into_record`](Module::into_record) followed by
/// [`ModuleRecord::save`](crate::store::ModuleRecord::save). For non-default load behavior
/// (dtype policy, partial loading, validation), go through the record directly.
#[cfg(feature = "std")]
fn save_file<P: AsRef<std::path::Path>>(self, path: P) -> Result<(), crate::store::RecordError>
where
Self: Sized,
{
self.into_record().save(path)
}
/// Load this module's parameters from a burnpack file on disk, returning the loaded module.
///
/// Uses the default load behavior. Panics on I/O or validation errors; useView on GitHub (pinned to d16f7ba2ed)
Solutions
- Switch to try_load_record and handle the Result to inspect the exact validation error.
- Regenerate the record/checkpoint from the current module definition.
- Ensure the module architecture (shapes, dtypes, names) matches the one that saved the record.
Example fix
// before
let model = Model::load_record(record);
// after
let model = Model::try_load_record(record)
.expect("checkpoint mismatch: regenerate the record for the current model"); Defensive patterns
Strategy: validation
Validate before calling
// Verify record compatibility before loading (fallible variant)
let model = match Model::try_load_record(record) {
Ok(m) => m,
Err(e) => panic!("record incompatible with model: {e}"),
}; Try / catch
let model = Model::try_load_record(record)
.unwrap_or_else(|e| panic!("Failed to load record: {e}")); Prevention
- Prefer try_load_record in application code
- Keep checkpoints and model definitions versioned together
- Assert shapes/dtypes after architecture changes before loading old checkpoints
When it happens
Trigger: Calling module.load_record(record) where the record was saved from a module whose parameter shapes, dtypes, or field names differ from the target module.
Common situations: Loading checkpoints saved from an older model version after changing layer sizes; loading a checkpoint into a differently-configured model; record serialization format changes between burn versions.
Related errors
- Should match at least one parameter group.
- Optimizer record tensors should carry a parameter id.
- burn-store: a panic escaped Module::map during ModuleSnapsho
- Failed to load module from file
- Can delete model checkpoint.
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/0721af9ce0389165.
Report an issue: GitHub.