{"record":{"id":"e0369c5452c4dadd","repo":"huggingface/candle","slug":"mergeable-ranks-key-is-not-a-u64","errorCode":null,"errorMessage":"mergeable_ranks '{key}' is not a u64","messagePattern":"mergeable_ranks '(.+?)' is not a u64","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-transformers/src/models/metavoice.rs","lineNumber":226,"sourceCode":"                Some(offset) => match offset.as_u64() {\n                    None => candle::bail!(\"offset field is not a positive int\"),\n                    Some(offset) => offset as usize,\n                },\n            };\n            let mut ranks = HashMap::new();\n            for id in 0u8..=255 {\n                ranks.insert(vec![id], id as u32);\n            }\n            let mergeable_ranks = match json.get(\"mergeable_ranks\") {\n                None => candle::bail!(\"json object has no mergeable_ranks field\"),\n                Some(mr) => match mr.as_object() {\n                    None => candle::bail!(\"mergeable_ranks is not an object\"),\n                    Some(mr) => mr,\n                },\n            };\n            for (key, value) in mergeable_ranks.iter() {\n                let value = match value.as_u64() {\n                    None => candle::bail!(\"mergeable_ranks '{key}' is not a u64\"),\n                    Some(value) => value as u32,\n                };\n                if value < 256 {\n                    continue;\n                }\n                // No escaping for other keys.\n                let key = key.as_bytes().to_vec();\n                ranks.insert(key, value);\n            }\n            Ok(Self {\n                re,\n                end_of_text,\n                offset,\n                ranks,\n                span: tracing::span!(tracing::Level::TRACE, \"bpe\"),\n            })\n        }\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-transformers/src/models/metavoice.rs#L208-L244","documentation":"from_json iterates the mergeable_ranks object and requires every value to be a JSON integer (as_u64). This error is raised when a rank value in the \"mergeable_ranks\" map is not a number — e.g. a string, float, bool, nested object, or null. The library parses ranks as u64 and casts them to u32, so any non-integer value aborts loading.","triggerScenarios":"Calling Encoding::from_json with a tokenizer JSON where at least one key in \"mergeable_ranks\" maps to a non-u64 value, such as \"256\" (string), 256.5 (float), or null.","commonSituations":"Tokenizer files converted between formats with quoted numeric values; hand-edited rank tables; scripts that dumped ranks as strings or floats; corrupted downloads where part of the JSON was mangled.","solutions":["Find the offending key named in the error message and change its value to a plain JSON integer","Regenerate the tokenizer JSON with the rank values emitted as numbers, not strings or floats","Re-download the original tokenizer file for the MetaVoice checkpoint instead of a converted copy"],"exampleFix":"// before\n{\"AA==\": \"256\"}\n// after\n{\"AA==\": 256}","handlingStrategy":"validation","validationCode":"let mr = json[\"mergeable_ranks\"].as_object()\n    .ok_or(\"mergeable_ranks must be an object\")?;\nfor (k, v) in mr {\n    if v.as_u64().is_none() {\n        return Err(format!(\"rank for '{k}' is not a u64\"));\n    }\n}","typeGuard":"fn all_u64(v: &serde_json::Value) -> bool {\n    v.as_object().map_or(false, |o| {\n        o.values().all(|x| x.is_u64())\n    })\n}","tryCatchPattern":"let enc = Encoding::from_json(&json)\n    .map_err(|e| format!(\"invalid rank in tokenizer: {e}\"))?;","preventionTips":["Ensure rank values are emitted as unquoted JSON integers by any converter script","Checksum tokenizer files after download to catch corruption","Spot-check a few mergeable_ranks entries after format conversion"],"tags":["rust","candle","json","tokenizer","type-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}