{"record":{"id":"5410d019e75c02d7","repo":"huggingface/candle","slug":"kv-cache-enabled-true-is-not-supported","errorCode":null,"errorMessage":"kv_cache_enabled=true is not supported","messagePattern":"kv_cache_enabled=true is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-transformers/src/models/metavoice.rs","lineNumber":449,"sourceCode":"    }\n\n    // https://github.com/metavoiceio/metavoice-src/blob/11550bb4e8a1ad032cc1556cc924f7a4e767cbfa/fam/llm/layers/attn.py#L18\n    struct SelfAttention {\n        c_attn: Linear,\n        c_proj: Linear,\n        n_head: usize,\n        span: tracing::Span,\n    }\n\n    impl SelfAttention {\n        fn new(cfg: &Config, vb: VarBuilder) -> Result<Self> {\n            // The different attention variants are likely to be identical but still we only accept\n            // TorchAttn for now.\n            if cfg.attn_kernel_type != AttnKernelType::TorchAttn {\n                candle::bail!(\"only TorchAttn is supported\")\n            }\n            if cfg.kv_cache_enabled {\n                candle::bail!(\"kv_cache_enabled=true is not supported\")\n            }\n            let c_attn = linear_b(cfg.n_embd, cfg.n_embd * 3, cfg.bias, vb.pp(\"c_attn\"))?;\n            let c_proj = linear_b(cfg.n_embd, cfg.n_embd, cfg.bias, vb.pp(\"c_proj\"))?;\n            Ok(Self {\n                c_attn,\n                c_proj,\n                n_head: cfg.n_head,\n                span: tracing::span!(tracing::Level::TRACE, \"self-attn\"),\n            })\n        }\n    }\n\n    impl Module for SelfAttention {\n        fn forward(&self, xs: &Tensor) -> Result<Tensor> {\n            let _enter = self.span.enter();\n            let (b, t, c) = xs.dims3()?;\n            let c_x = xs\n                .apply(&self.c_attn)?","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-transformers/src/models/metavoice.rs#L431-L467","documentation":"SelfAttention::new explicitly rejects configs with kv_cache_enabled set to true — the KV-cache attention path is not implemented in the candle metavoice port. This is a hard unsupported-feature guard, not a transient failure.","triggerScenarios":"Building the MetaVoice model with a Config where kv_cache_enabled == true, typically deserialized from a checkpoint's config.json that enables KV caching.","commonSituations":"Loading a checkpoint whose upstream config enables KV cache for inference speed; enabling KV cache manually to try to speed up generation; reusing a config from a framework that supports KV cache.","solutions":["Set kv_cache_enabled to false in the Config before constructing the model","Edit the model's config file to remove or disable the kv cache option and reload","Run generation without KV caching (accepting slower inference) since candle does not implement this path"],"exampleFix":"// before\nlet cfg = Config { kv_cache_enabled: true, .. };\n// after\nlet cfg = Config { kv_cache_enabled: false, .. };","handlingStrategy":"validation","validationCode":"if cfg.kv_cache_enabled {\n    return Err(\"kv_cache_enabled must be false for metavoice in candle\");\n}","typeGuard":null,"tryCatchPattern":"let model = Metavoice::new(&cfg, vb)\n    .map_err(|e| format!(\"kv-cache unsupported: {e}\"))?;","preventionTips":["Force kv_cache_enabled=false when deserializing Config","Do not enable KV cache options ported from non-candle configs","Review config.json for kv-cache flags before model construction"],"tags":["rust","candle","metavoice","kv-cache","unsupported-feature"],"backgroundTag":"unsupported-config-option","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}