{"record":{"id":"b7ffa8e0d0209a4a","repo":"huggingface/candle","slug":"not-a-f64-v","errorCode":null,"errorMessage":"not a f64 {v:?}","messagePattern":"not a f64 (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/quantized/gguf_file.rs","lineNumber":294,"sourceCode":"\n    pub fn to_i64(&self) -> Result<i64> {\n        match self {\n            Self::I64(v) => Ok(*v),\n            v => crate::bail!(\"not a i64 {v:?}\"),\n        }\n    }\n\n    pub fn to_f32(&self) -> Result<f32> {\n        match self {\n            Self::F32(v) => Ok(*v),\n            v => crate::bail!(\"not a f32 {v:?}\"),\n        }\n    }\n\n    pub fn to_f64(&self) -> Result<f64> {\n        match self {\n            Self::F64(v) => Ok(*v),\n            v => crate::bail!(\"not a f64 {v:?}\"),\n        }\n    }\n\n    pub fn to_bool(&self) -> Result<bool> {\n        match self {\n            Self::Bool(v) => Ok(*v),\n            v => crate::bail!(\"not a bool {v:?}\"),\n        }\n    }\n\n    pub fn to_vec(&self) -> Result<&Vec<Value>> {\n        match self {\n            Self::Array(v) => Ok(v),\n            v => crate::bail!(\"not a vec {v:?}\"),\n        }\n    }\n\n    pub fn to_string(&self) -> Result<&String> {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/quantized/gguf_file.rs#L276-L312","documentation":"Value::to_f64 throws this when the Value holds any variant other than F64. GGUF metadata values are stored with an explicit type tag, and candle refuses implicit conversions between them. The message includes a Debug dump of the actual value so you can see what type is really there.","triggerScenarios":"Calling .to_f64() on a metadata value that is F32, an integer type (U8..I64), String, Bool, or Array — e.g. reading 'rope.freq_base' that a writer emitted as f32.","commonSituations":"Reading GGUF files from tools (llama.cpp converters) that store floats as f32 by default; assuming a field is f64 because Rust literals default to f64; parsing a hand-built GGUF test file with the wrong ValueType.","solutions":["Use .to_f32() if the value was written as F32 (the usual GGUF float width).","Read the actual variant from the error text and call the corresponding accessor.","Match on the Value enum to accept both F32 and F64 explicitly.","Regenerate the GGUF file writing the field as ValueType::F64."],"exampleFix":"// before\nlet freq_base = value.to_f64()?;\n// after\nlet freq_base = match value {\n    gguf_file::Value::F64(v) => v,\n    gguf_file::Value::F32(v) => v as f64,\n    other => candle_core::bail!(\"unexpected rope.freq_base {other:?}\"),\n};","handlingStrategy":"type-guard","validationCode":"fn is_f64(v: &gguf_file::Value) -> bool { matches!(v, gguf_file::Value::F64(_)) }\nif !is_f64(value) { bail!(\"expected f64 metadata, got {value:?}\"); }","typeGuard":"fn as_f64(v: &gguf_file::Value) -> Option<f64> {\n    if let gguf_file::Value::F64(x) = v { Some(*x) } else { None }\n}","tryCatchPattern":"let f = match value.to_f64() {\n    Ok(f) => f,\n    Err(_) => value.to_f32().map(|x| x as f64).unwrap_or(DEFAULT_FREQ_BASE),\n};","preventionTips":["Default to to_f32 for GGUF floats — f64 is rare in practice","Write a small helper that accepts F32 and F64 variants","Check candle's gguf_file::ValueType docs for each known key","Unit-test your parser against a sample file from the same producer"],"tags":["candle","gguf","type-mismatch"],"backgroundTag":"unexpected-value-type","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}