{"record":{"id":"2f9cbbea5866fc72","repo":"huggingface/candle","slug":"sliding-window-is-not-supported-2f9cbb","errorCode":null,"errorMessage":"sliding window is not supported","messagePattern":"sliding window is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-transformers/src/models/smol/smollm3.rs","lineNumber":174,"sourceCode":"    head_dim: usize,\n    hidden_size: usize,\n    // utils\n    rotary_emb: Option<Arc<SmolLM3RotaryEmbedding>>,\n    kv_cache: KvCache,\n    // NoPE flag\n    skip_rope: bool,\n}\n\nimpl SmolLM3Attention {\n    pub(crate) fn new(\n        cfg: &Config,\n        layer_idx: usize,\n        rotary_emb: Option<Arc<SmolLM3RotaryEmbedding>>,\n        vb: VarBuilder,\n    ) -> Result<Self> {\n        let use_sliding_window = cfg.use_sliding_window.unwrap_or(false);\n        if use_sliding_window {\n            candle::bail!(\"sliding window is not supported\")\n        }\n\n        let head_dim = cfg.head_dim();\n        let num_heads = cfg.num_attention_heads;\n        let num_kv_heads = cfg.num_key_value_heads;\n        let num_kv_groups = num_heads / num_kv_heads;\n\n        let attention_bias = cfg.attention_bias.unwrap_or(false);\n\n        let q_proj = linear_b(\n            cfg.hidden_size,\n            num_heads * head_dim,\n            attention_bias,\n            vb.pp(\"q_proj\"),\n        )?;\n\n        let k_proj = linear_b(\n            cfg.hidden_size,","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-transformers/src/models/smol/smollm3.rs#L156-L192","documentation":"SmolLM3 attention layers reject model configurations that enable sliding-window attention. The candle implementation of SmolLM3 only implements global (full) attention, so when cfg.use_sliding_window is true (or Some(true)) it aborts construction of the attention layer via candle::bail!. This is an explicit unsupported-feature guard, not an unexpected failure.","triggerScenarios":"Calling SmolLM3Attention::new (during model load) with a SmolLM3Config whose use_sliding_window field is Some(true), e.g. loading a checkpoint/config.json that specifies sliding-window attention.","commonSituations":"Loading a SmolLM3 variant released with sliding-window attention enabled in its HF config; hand-editing config.json to enable use_sliding_window; using a config ported from transformers where the flag defaults on for certain layers.","solutions":["Set use_sliding_window to false (or remove it / set it to null) in the SmolLM3Config before constructing the model","Check whether a newer candle version has added sliding-window support for SmolLM3 and upgrade","Use a model checkpoint that does not rely on sliding-window attention"],"exampleFix":"// before\nlet cfg = SmolLM3Config { use_sliding_window: Some(true), .. };\n// after\nlet cfg = SmolLM3Config { use_sliding_window: Some(false), .. };","handlingStrategy":"validation","validationCode":"if cfg.use_sliding_window.unwrap_or(false) {\n    return Err(anyhow::anyhow!(\"SmolLM3 sliding window unsupported; disable use_sliding_window\"));\n}","typeGuard":null,"tryCatchPattern":"match SmolLM3Model::new(&cfg, vb) {\n    Ok(m) => m,\n    Err(e) if e.to_string().contains(\"sliding window is not supported\") => {\n        let mut cfg = cfg.clone(); cfg.use_sliding_window = Some(false);\n        SmolLM3Model::new(&cfg, vb)?\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Always normalize use_sliding_window to false for SmolLM3 in candle","Sanitize HF config.json fields before mapping them into SmolLM3Config","Pin a candle version and check its SmolLM3 feature support before loading new checkpoints"],"tags":["rust","candle","unsupported-feature","model-config"],"backgroundTag":"unsupported-model-config-option","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}