{"record":{"id":"62b36f31fbb86b8c","repo":"huggingface/candle","slug":"gguf-tensor-tensor-name-has-n-dimensions-di","errorCode":null,"errorMessage":"gguf: tensor '{tensor_name}' has {n_dimensions} dimensions, max is {GGUF_MAX_TENSOR_DIMS}","messagePattern":"gguf: tensor '(.+?)' has (.+?) dimensions, max is (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/quantized/gguf_file.rs","lineNumber":519,"sourceCode":"            crate::bail!(\n                \"gguf: header declares {tensor_count} tensors and {metadata_kv_count} metadata entries, needs at least {needed} bytes, only {remaining} remaining\"\n            )\n        }\n\n        let mut metadata = HashMap::new();\n        for _idx in 0..metadata_kv_count {\n            let key = read_string(reader, &magic, file_size)?;\n            let value_type = reader.read_u32::<LittleEndian>()?;\n            let value_type = ValueType::from_u32(value_type)?;\n            let value = Value::read(reader, value_type, &magic, 0, file_size)?;\n            metadata.insert(key, value);\n        }\n        let mut tensor_infos = HashMap::new();\n        for _idx in 0..tensor_count {\n            let tensor_name = read_string(reader, &magic, file_size)?;\n            let n_dimensions = reader.read_u32::<LittleEndian>()?;\n            if n_dimensions > GGUF_MAX_TENSOR_DIMS {\n                crate::bail!(\n                    \"gguf: tensor '{tensor_name}' has {n_dimensions} dimensions, max is {GGUF_MAX_TENSOR_DIMS}\"\n                )\n            }\n\n            let mut dimensions: Vec<usize> = match magic {\n                VersionedMagic::GgufV1 => {\n                    let mut dimensions = vec![0; n_dimensions as usize];\n                    reader.read_u32_into::<LittleEndian>(&mut dimensions)?;\n                    dimensions.into_iter().map(|c| c as usize).collect()\n                }\n                VersionedMagic::GgufV2 | VersionedMagic::GgufV3 => {\n                    let mut dimensions = vec![0; n_dimensions as usize];\n                    reader.read_u64_into::<LittleEndian>(&mut dimensions)?;\n                    dimensions.into_iter().map(|c| c as usize).collect()\n                }\n            };\n\n            dimensions.reverse();","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/quantized/gguf_file.rs#L501-L537","documentation":"Each tensor in a GGUF file declares its number of dimensions. candle enforces a sanity cap (GGUF_MAX_TENSOR_DIMS) to prevent absurd dimension vectors from exhausting memory. A declared dim count above the cap indicates a corrupt or malicious file.","triggerScenarios":"GgufFile::read while parsing tensor infos: a tensor entry's n_dimensions u32 field exceeds GGUF_MAX_TENSOR_DIMS.","commonSituations":"Reading a GGUF file produced by an incompatible or buggy converter; corrupted downloads; files from untrusted sources.","solutions":["Re-convert the model with a current, reputable GGUF converter (llama.cpp convert script) and verify checksum","Re-download the file and verify integrity","Confirm the file was produced for the GGUF spec version candle supports"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// only load files converted with your verified pipeline\nassert_eq!(&std::fs::read(\"model.gguf\")?[..4], b\"GGUF\");\nassert_eq!(sha256_file(\"model.gguf\")?, EXPECTED_SHA256);","typeGuard":null,"tryCatchPattern":"match GgufFile::from_reader(&mut reader) {\n    Ok(g) => g,\n    Err(e) if e.to_string().contains(\"dimensions, max is\") => {\n        eprintln!(\"corrupt or incompatible gguf tensor metadata; re-convert the model\");\n        return Err(e.into());\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Re-convert models with the current llama.cpp convert script","Verify checksums of converted files","Don't use gguf files from untrusted sources"],"tags":["gguf","corrupt-file","file-format"],"backgroundTag":"gguf-header-count-exceeds-limit","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}