janhq/jan · error · KVCacheError::ArchitectureNotFound
Invalid metadata: architecture not found
Error message
Invalid metadata: architecture not found
What it means
`KVCacheError::ArchitectureNotFound` — the KV-cache estimator could not find the `.general.architecture` metadata key in the parsed GGUF map. Architecture (e.g. `llama`, `gpt2`, `falcon`) gates all downstream sizing formulas, so its absence makes any estimate impossible.
Source
Thrown at src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs:63
}
}
}
#[derive(Serialize)]
pub struct GgufMetadata {
pub version: u32,
pub tensor_count: u64,
pub metadata: HashMap<String, String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct KVCacheEstimate {
pub size: u64,
pub per_token_size: u64,
}
#[derive(Debug, thiserror::Error)]
pub enum KVCacheError {
#[error("Invalid metadata: architecture not found")]
ArchitectureNotFound,
#[error("Invalid metadata: block_count not found or invalid")]
BlockCountInvalid,
#[error("Invalid metadata: head_count not found or invalid")]
HeadCountInvalid,
#[error("Invalid metadata: embedding_length not found or invalid")]
EmbeddingLengthInvalid,
#[error("Invalid metadata: context_length not found or invalid")]
ContextLengthInvalid,
}
impl serde::Serialize for KVCacheError {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&self.to_string())
}View on GitHub (pinned to fad3f12a14)
Solutions
- Dump the parsed metadata map keys and confirm whether `general.architecture` (or the variant your lookup expects) is present.
- If the key is present under a different prefix, update the lookup to handle both bare and prefixed forms.
- Use a known-good GGUF (e.g. one from TheBloke/huggingface) to confirm the parser and lookup agree.
- If metadata is genuinely absent, reject the file upstream with a clearer user-facing message rather than failing mid-estimate.
Example fix
// before
let arch = meta.metadata.get("general.architecture")
.ok_or(KVCacheError::ArchitectureNotFound)?;
// after - try multiple key forms and report which keys exist
let arch = meta.metadata.get("general.architecture")
.or_else(|| meta.metadata.keys().find(|k| k.ends_with(".architecture")).and_then(|k| meta.metadata.get(k)))
.ok_or_else(|| KVCacheError::ArchitectureNotFound)?; Defensive patterns
Strategy: validation
Validate before calling
fn has_architecture(meta: &GgufMetadata) -> bool {
meta.metadata.contains_key("general.architecture")
|| meta.metadata.keys().any(|k| k.ends_with(".architecture"))
} Type guard
fn architecture_of(meta: &GgufMetadata) -> Option<&str> {
meta.metadata.get("general.architecture").map(|s| s.as_str())
} Try / catch
match estimate_kv_cache(&meta) {
Ok(est) => Ok(est),
Err(KVCacheError::ArchitectureNotFound) => {
Err(UserError::UnsupportedModel("missing general.architecture".into()))
}
Err(e) => Err(e.into()),
} Prevention
- Dump metadata keys when adding support for a new architecture.
- Handle both bare and arch-prefixed key forms.
- Reject stripped-metadata files at the UI layer with a clear message.
When it happens
Trigger: Calling the KV-cache estimation API on a GGUF whose metadata map lacks an entry whose key ends in `.general.architecture` (or however the lookup is keyed). This happens with stripped or partial metadata, or when the lookup uses a key prefix the file did not set.
Common situations: Loading a converted GGUF that omitted architecture metadata; a lookup that hard-codes a key prefix (e.g. `general.architecture` vs `<arch>.general.architecture`); a file from a converter that names keys differently. Real llama.cpp GGUFs always set `general.architecture`.
Related errors
- Invalid metadata: block_count not found or invalid
- Invalid metadata: head_count not found or invalid
- Invalid metadata: embedding_length not found or invalid
- Invalid metadata: context_length not found or invalid
- Error reading metadata entry {}: {}
AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12).
Data as JSON: /api/errors/b7ed5caddcd454fe.
Report an issue: GitHub.