huggingface/candle · error
No data in file {}
Error message
No data in file {} What it means
Raised by `read_imatrix` (imatrix_file::read) in candle-core/src/quantized/imatrix_file.rs when the i32 entry count read from the start of an importance-matrix (imatrix) file is less than 1. It means the imatrix file is empty or corrupt and contains no calibration entries.
Source
Thrown at candle-core/src/quantized/imatrix_file.rs:37
})?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).map_err(|e| {
crate::Error::msg(format!(
"Failed to read file {}: {}",
fname.as_ref().display(),
e
))
})?;
let mut cursor = Cursor::new(buffer);
let n_entries = cursor
.read_i32::<LittleEndian>()
.map_err(|e| crate::Error::msg(format!("Failed to read number of entries: {e}")))?
as usize;
if n_entries < 1 {
crate::bail!("No data in file {}", fname.as_ref().display());
}
for i in 0..n_entries {
// Read length of the name
let len = cursor.read_i32::<LittleEndian>().map_err(|e| {
crate::Error::msg(format!(
"Failed to read name length for entry {}: {}",
i + 1,
e
))
})? as usize;
// Read the name
let mut name_buf = vec![0u8; len];
cursor.read_exact(&mut name_buf).map_err(|e| {
crate::Error::msg(format!("Failed to read name for entry {}: {}", i + 1, e))
})?;
let name = String::from_utf8(name_buf).map_err(|e| {View on GitHub (pinned to d5fee525bf)
Solutions
- Regenerate the imatrix file with the quantization toolchain and confirm it is non-empty
- Check file size > 4 bytes before loading and verify the path is correct
- Re-download the imatrix file if it came from a remote source
Example fix
// before
let imatrix = load_imatrix("imatrix.gguf")?; // empty file
// after
let meta = std::fs::metadata("imatrix.gguf")?;
assert!(meta.len() > 4, "imatrix file is empty or truncated");
let imatrix = load_imatrix("imatrix.gguf")?; Defensive patterns
Strategy: validation
Validate before calling
let meta = std::fs::metadata("imatrix.dat")?;
if meta.len() <= 4 {
return Err(anyhow!("imatrix file is empty or truncated ({} bytes)", meta.len()));
} Try / catch
match load_imatrix(&fname) {
Ok(m) => m,
Err(e) if e.to_string().contains("No data in file") => {
eprintln!("imatrix file has zero entries; regenerate it");
return Err(e.into());
}
Err(e) => return Err(e.into()),
} Prevention
- Check file size before loading imatrix files
- Confirm the imatrix generation job completed successfully
- Verify paths point to the imatrix file, not a placeholder
When it happens
Trigger: load_imatrix on a zero-byte or truncated file whose first i32 reads as 0 or negative (e.g. all-zero bytes from a failed download).
Common situations: Pointing at an empty placeholder file; interrupted imatrix generation producing an empty output; wrong path passed for the imatrix argument.
Related errors
- Invalid nval for entry {}: {}
- {} is a dummy type and does not support parsing
- unrecognized value-type {v:#08x}
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/a8b9067bc6e7342e.
Report an issue: GitHub.