{"record":{"id":"2185ad43fc3a4688","repo":"huggingface/candle","slug":"only-torchattn-is-supported","errorCode":null,"errorMessage":"only TorchAttn is supported","messagePattern":"only TorchAttn is supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-transformers/src/models/metavoice.rs","lineNumber":446,"sourceCode":"                Self::LayerNorm(m) => m.forward(xs),\n            }\n        }\n    }\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();","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-transformers/src/models/metavoice.rs#L428-L464","documentation":"SelfAttention::new in the metavoice model only implements the TorchAttn attention kernel; any other attn_kernel_type in the model Config causes this bail. The comment notes the other variants (like FusedAttn) are probably identical but are intentionally rejected until verified. This is an explicit unsupported-feature guard.","triggerScenarios":"Constructing the MetaVoice self-attention layer with a Config parsed from a checkpoint whose config.json sets attn_kernel_type to anything other than \"TORCH_ATTN\" (e.g. FAVA, or another kernel variant).","commonSituations":"Loading a MetaVoice variant exported with different attention kernels; a converted config that preserves the original kernel type; hand-writing a Config with a non-default attn_kernel_type.","solutions":["Set attn_kernel_type to AttnKernelType::TorchAttn in the Config (or in the source config file) before building the model","Use a checkpoint/config that was exported with the TorchAttn kernel","Patch SelfAttention::new to implement (or verify) the other kernel if you truly need it"],"exampleFix":"// before\nlet cfg = Config { attn_kernel_type: AttnKernelType::FusedAttn, .. };\n// after\nlet cfg = Config { attn_kernel_type: AttnKernelType::TorchAttn, .. };","handlingStrategy":"validation","validationCode":"if cfg.attn_kernel_type != AttnKernelType::TorchAttn {\n    return Err(\"metavoice in candle requires attn_kernel_type = TorchAttn\");\n}","typeGuard":null,"tryCatchPattern":"let model = Metavoice::new(&cfg, vb)\n    .map_err(|e| format!(\"unsupported attention kernel: {e}\"))?;","preventionTips":["Pin attn_kernel_type to TorchAttn in your Config","Check checkpoint config.json for non-TorchAttn kernels before loading in candle","Keep to officially exported MetaVoice checkpoints"],"tags":["rust","candle","metavoice","unsupported-feature","config"],"backgroundTag":"unsupported-config-option","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}