{"record":{"id":"f669511be95d7cdf","repo":"huggingface/candle","slug":"cannot-find-tensor-info-for-name","errorCode":null,"errorMessage":"cannot find tensor info for {name}","messagePattern":"cannot find tensor info for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/quantized/gguf_file.rs","lineNumber":577,"sourceCode":"        };\n        let tensor_data_offset = position.div_ceil(alignment) * alignment;\n        Ok(Self {\n            magic,\n            metadata,\n            tensor_infos,\n            tensor_data_offset,\n        })\n    }\n\n    pub fn tensor<R: std::io::Seek + std::io::Read>(\n        &self,\n        reader: &mut R,\n        name: &str,\n        device: &Device,\n    ) -> Result<QTensor> {\n        let tensor_info = match self.tensor_infos.get(name) {\n            Some(tensor_info) => tensor_info,\n            None => crate::bail!(\"cannot find tensor info for {name}\"),\n        };\n        tensor_info.read(reader, self.tensor_data_offset, device)\n    }\n}\n\nfn write_string<W: std::io::Write>(w: &mut W, str: &str) -> Result<()> {\n    let bytes = str.as_bytes();\n    w.write_u64::<LittleEndian>(bytes.len() as u64)?;\n    w.write_all(bytes)?;\n    Ok(())\n}\n\npub fn write<W: std::io::Seek + std::io::Write>(\n    w: &mut W,\n    metadata: &[(&str, &Value)],\n    tensors: &[(&str, &QTensor)],\n) -> Result<()> {\n    w.write_u32::<LittleEndian>(0x46554747)?;","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/quantized/gguf_file.rs#L559-L595","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect gguf.tensor_infos() keys and use an exact existing name (keys are case-sensitive)","Print/list available tensor names and adapt your name mapping","Use a consistent naming convention or a model mapping layer between architectures"],"exampleFix":"// before\nlet t = gguf.tensor(&mut reader, \"output.weight\", &device)?; // model uses lm_head\n// after\nlet name = gguf.tensor_infos()\n    .keys()\n    .find(|k| k.contains(\"output\") || k.contains(\"lm_head\"))\n    .ok_or_else(|| anyhow!(\"no output tensor found\"))?\n    .clone();\nlet t = gguf.tensor(&mut reader, &name, &device)?;","handlingStrategy":"validation","validationCode":"let infos = gguf.tensor_infos();\nlet name = \"output.weight\";\nif !infos.contains_key(name) {\n    return Err(anyhow!(\"tensor '{}' not present; available: {:?}\", name, infos.keys().collect::<Vec<_>>()));\n}","typeGuard":null,"tryCatchPattern":"match gguf.tensor(&mut reader, name, &device) {\n    Ok(t) => t,\n    Err(e) if e.to_string().starts_with(\"cannot find tensor info\") => {\n        eprintln!(\"available tensors: {:?}\", gguf.tensor_infos().keys().collect::<Vec<_>>());\n        return Err(e.into());\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Print gguf.tensor_infos() keys once when integrating a new model","Remember lookups are exact and case-sensitive","Build a per-architecture tensor-name mapping table"],"tags":["gguf","tensor-names","lookup"],"backgroundTag":"tensor-not-found","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}