janhq/jan · error · KVCacheError
ArchitectureNotFound
ArchitectureNotFound
Error message
Invalid metadata: architecture not found
What it means
KVCacheError::ArchitectureNotFound is returned when estimating KV-cache size from GGUF metadata but the required `general.architecture` key is missing from the parsed KV map. Without the architecture name the estimator cannot select the per-layer layout, so it refuses rather than guessing.
Solutions
- Re-export the model so `general.architecture` is written into the KV metadata (standard llama.cpp conversions always include it)
- Fall back to the caller's known architecture (pass it explicitly instead of deriving it from the file)
- Check with gguf_dump whether the key exists under a different name (e.g. old 'general.architecture' variants)
- If handling programmatically, map this variant to a user-facing 'unsupported/unannotated model file' message
Example fix
// before
let meta = read_gguf_metadata(File::open("bare.gguf")?)?;
let est = estimate_kv_cache(&meta)?; // ArchitectureNotFound
// after
let meta = read_gguf_metadata(File::open("bare.gguf")?)?;
if !meta.metadata.contains_key("general.architecture") {
log::warn!("model lacks architecture metadata; using configured default");
return estimate_kv_cache_for(arch_from_config, &meta);
}
let est = estimate_kv_cache(&meta)?; Defensive patterns
Strategy: fallback
Validate before calling
fn has_architecture(meta: &GgufMetadata) -> bool {
meta.metadata.contains_key("general.architecture")
}
// check before calling the KV-cache estimator Try / catch
match estimate_kv_cache(&meta) {
Err(KVCacheError::ArchitectureNotFound) => {
eprintln!("model file has no architecture metadata; provide it explicitly");
}
other => other?,
} Prevention
- Prefer standard llama.cpp-converted GGUF files, which always write general.architecture
- Check for the key with gguf_dump before estimating KV usage
- Allow callers to supply the architecture explicitly as a fallback
When it happens
Trigger: Calling a KV-cache estimation routine on a GgufMetadata whose metadata HashMap has no `general.architecture` entry - the file has an empty KV section or the key was stripped by a converter.
Common situations: Minimal or hand-built GGUF files without metadata, conversion tools that drop KV entries, reading a shard or file type that carries no model metadata.
Related errors
- Array length is unreasonably large
- BlockCountInvalid
- ContextLengthInvalid
- EmbeddingLengthInvalid
- Error reading metadata entry
AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17).
Data as JSON: /api/errors/22c93f86c27bbeda.
Report an issue: GitHub.
Appendix: 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 7205d770c1)