huggingface/candle · error
cannot find {s} in metadata
Error message
cannot find {s} in metadata What it means
Thrown by quantized_qwen3_moe::Model::from_gguf when a metadata key required by the MoE loader is missing from the GGUF content. Unlike the dense loader, this one first reads general.architecture and then builds keys like '{arch}.attention.head_count' dynamically, so any missing '{arch}.*' key (head counts, expert counts, feed_forward sizes, etc.) triggers this bail.
Source
Thrown at candle-transformers/src/models/quantized_qwen3_moe.rs:253
pub struct GGUFQWenMoE {
tok_embeddings: Embedding,
layers: Vec<LayerWeights>,
norm: RmsNorm,
output: QMatMul,
dtype: DType,
device: Device,
}
impl GGUFQWenMoE {
pub fn from_gguf<R: std::io::Seek + std::io::Read>(
ct: gguf_file::Content,
reader: &mut R,
device: &Device,
dtype: DType,
) -> Result<Self> {
let mut gg = Gguf::new(ct, reader, device.clone());
let md_get = |s: &str| match gg.metadata().get(s) {
None => candle::bail!("cannot find {s} in metadata"),
Some(v) => Ok(v),
};
let arch = md_get("general.architecture")?.to_string()?;
let head_count =
md_get(format!("{arch}.attention.head_count").as_str())?.to_u32()? as usize;
let head_count_kv =
md_get(format!("{arch}.attention.head_count_kv").as_str())?.to_u32()? as usize;
let head_dim = md_get(format!("{arch}.attention.key_length").as_str());
let embedding_length =
md_get(format!("{arch}.embedding_length").as_str())?.to_u32()? as usize;
let head_dim = if let Ok(head_dim) = head_dim {
head_dim.to_u32()? as usize
} else {
embedding_length / head_count
};
let context_length = md_get(format!("{arch}.context_length").as_str())?.to_u32()? as usize;View on GitHub (pinned to d5fee525bf)
Solutions
- Dump the GGUF metadata and confirm general.architecture plus all '{arch}.*' keys the MoE loader expects (attention head counts, expert_count, expert_used_count, feed_forward lengths)
- Re-convert the checkpoint with an up-to-date exporter that writes complete qwen3-moe metadata
- Load with the correct model module for the file's architecture (e.g. quantized_qwen3 for dense files)
Example fix
// before (missing expert keys in a dense qwen3 GGUF)
let model = quantized_qwen3_moe::Model::from_gguf(content, &mut file, &device, dtype)?;
// after (route by architecture)
let arch = content.metadata.get("general.architecture")?.to_string()?;
let model = match arch.as_str() {
"qwen3moe" | "qwen3-moe" => quantized_qwen3_moe::Model::from_gguf(content, &mut file, &device, dtype)?,
_ => quantized_qwen3::Model::from_gguf(content, &mut file, &device)?,
}; Defensive patterns
Strategy: validation
Validate before calling
let arch = content.metadata.get("general.architecture")?.to_string()?;
let head_count_key = format!("{arch}.attention.head_count");
if !content.metadata.contains_key(&head_count_key) {
anyhow::bail!("GGUF lacks {head_count_key}; wrong loader or incomplete conversion");
} Type guard
fn moe_keys_present(md: &std::collections::HashMap<String, gguf_file::Value>, arch: &str) -> bool {
md.contains_key(&format!("{arch}.expert_count"))
&& md.contains_key(&format!("{arch}.attention.head_count"))
} Try / catch
match quantized_qwen3_moe::Model::from_gguf(content, &mut file, &device, dtype) {
Ok(m) => m,
Err(e) if e.to_string().contains("cannot find") => {
anyhow::bail!("incomplete MoE GGUF metadata: {e}")
}
Err(e) => return Err(e.into()),
} Prevention
- Read general.architecture first and route to the matching model module
- Validate expert_count/expert_used_count keys exist for MoE files
- Re-convert with the latest llama.cpp/convert script if keys are missing
When it happens
Trigger: Calling quantized_qwen3_moe::Model::from_gguf with a GGUF whose metadata lacks general.architecture, or any '{arch}.attention.head_count', '{arch}.attention.head_count_kv', '{arch}.expert_count', '{arch}.expert_used_count' or similar derived key.
Common situations: Loading a MoE GGUF exported by a tool that omits expert metadata; passing a non-MoE or differently-prefixed GGUF to the MoE loader; hand-edited GGUF metadata.
Related errors
- cannot find {s} in metadata
- {} is a dummy type and cannot be constructed
- {} is a dummy type and cannot be converted
- {} is a dummy type and cannot be converted to scalar
- {} is a dummy type and does not support storage
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/b9339693206970b7.
Report an issue: GitHub.