huggingface/candle · error

cannot find tensor info for {name}

Error message

cannot find tensor info for {name}

What it means

Raised by `Content::tensor` in candle-core/src/quantized/gguf_file.rs when looking up a tensor by name in a parsed GGUF file and the name is absent from the file's tensor_infos map. It means the requested tensor does not exist in that GGUF file (typo, wrong model file, or a tensor stripped during quantization/conversion).

Source

Thrown at candle-core/src/quantized/gguf_file.rs:577

        };
        let tensor_data_offset = position.div_ceil(alignment) * alignment;
        Ok(Self {
            magic,
            metadata,
            tensor_infos,
            tensor_data_offset,
        })
    }

    pub fn tensor<R: std::io::Seek + std::io::Read>(
        &self,
        reader: &mut R,
        name: &str,
        device: &Device,
    ) -> Result<QTensor> {
        let tensor_info = match self.tensor_infos.get(name) {
            Some(tensor_info) => tensor_info,
            None => crate::bail!("cannot find tensor info for {name}"),
        };
        tensor_info.read(reader, self.tensor_data_offset, device)
    }
}

fn write_string<W: std::io::Write>(w: &mut W, str: &str) -> Result<()> {
    let bytes = str.as_bytes();
    w.write_u64::<LittleEndian>(bytes.len() as u64)?;
    w.write_all(bytes)?;
    Ok(())
}

pub fn write<W: std::io::Seek + std::io::Write>(
    w: &mut W,
    metadata: &[(&str, &Value)],
    tensors: &[(&str, &QTensor)],
) -> Result<()> {
    w.write_u32::<LittleEndian>(0x46554747)?;

View on GitHub (pinned to d5fee525bf)

Solutions

  1. Inspect gguf.tensor_infos() keys and use an exact existing name (keys are case-sensitive)
  2. Print/list available tensor names and adapt your name mapping
  3. Use a consistent naming convention or a model mapping layer between architectures

Example fix

// before
let t = gguf.tensor(&mut reader, "output.weight", &device)?; // model uses lm_head
// after
let name = gguf.tensor_infos()
    .keys()
    .find(|k| k.contains("output") || k.contains("lm_head"))
    .ok_or_else(|| anyhow!("no output tensor found"))?
    .clone();
let t = gguf.tensor(&mut reader, &name, &device)?;
Defensive patterns

Strategy: validation

Validate before calling

let infos = gguf.tensor_infos();
let name = "output.weight";
if !infos.contains_key(name) {
    return Err(anyhow!("tensor '{}' not present; available: {:?}", name, infos.keys().collect::<Vec<_>>()));
}

Try / catch

match gguf.tensor(&mut reader, name, &device) {
    Ok(t) => t,
    Err(e) if e.to_string().starts_with("cannot find tensor info") => {
        eprintln!("available tensors: {:?}", gguf.tensor_infos().keys().collect::<Vec<_>>());
        return Err(e.into());
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling gguf.tensor(reader, "name", &device) where "name" is misspelled, uses different casing, or the model was exported with different tensor naming conventions than expected.

Common situations: Hardcoded tensor names from another model family (e.g. llama vs phi tensor naming); case-sensitive lookup mismatch; expecting tensors that the quantizer stripped or renamed.

Related errors


AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02). Data as JSON: /api/errors/f669511be95d7cdf. Report an issue: GitHub.