{"record":{"id":"9a58f187c9b038e4","repo":"huggingface/candle","slug":"swiglu-multiple-of-has-to-be-set","errorCode":null,"errorMessage":"swiglu-multiple-of has to be set","messagePattern":"swiglu-multiple-of has to be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-transformers/src/models/metavoice.rs","lineNumber":515,"sourceCode":"    }\n\n    impl MLP {\n        fn new(cfg: &Config, vb: VarBuilder) -> Result<Self> {\n            let hidden_dim = 4 * cfg.n_embd;\n            let slf = match cfg.nonlinearity_type {\n                NonLinearityType::Gelu => {\n                    let c_fc = linear_b(cfg.n_embd, hidden_dim, cfg.bias, vb.pp(\"c_fc\"))?;\n                    let c_proj = linear_b(hidden_dim, cfg.n_embd, cfg.bias, vb.pp(\"c_proj\"))?;\n                    Self::Gelu {\n                        c_fc,\n                        c_proj,\n                        span: tracing::span!(tracing::Level::TRACE, \"mlp-gelu\"),\n                    }\n                }\n                NonLinearityType::Swiglu => {\n                    let hidden_dim = (2 * hidden_dim) / 3;\n                    let swiglu_multiple_of = match cfg.swiglu_multiple_of {\n                        None => candle::bail!(\"swiglu-multiple-of has to be set\"),\n                        Some(smo) => smo,\n                    };\n                    let hidden_dim = swiglu_multiple_of * (hidden_dim + swiglu_multiple_of - 1)\n                        / swiglu_multiple_of;\n                    let w1 = linear_b(cfg.n_embd, hidden_dim, cfg.bias, vb.pp(\"w1\"))?;\n                    let w3 = linear_b(cfg.n_embd, hidden_dim, cfg.bias, vb.pp(\"w3\"))?;\n                    let c_proj = linear_b(hidden_dim, cfg.n_embd, cfg.bias, vb.pp(\"c_proj\"))?;\n                    Self::Swiglu {\n                        w1,\n                        w3,\n                        c_proj,\n                        span: tracing::span!(tracing::Level::TRACE, \"mlp-swiglu\"),\n                    }\n                }\n            };\n            Ok(slf)\n        }\n    }","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-transformers/src/models/metavoice.rs#L497-L533","documentation":"When the MLP non-linearity is Swiglu, the layer computes its hidden dimension by rounding down to a multiple of cfg.swiglu_multiple_of. If that config field is None, the computation is impossible, so new bails with this message. It is a missing-required-config-field error for Swiglu MLPs.","triggerScenarios":"Building the MetaVoice MLP with non_linearity_type = Swiglu while cfg.swiglu_multiple_of is None (field absent from the deserialized config.json or left unset in a hand-built Config).","commonSituations":"Checkpoint configs that omit swiglu_multiple_of because the original model used a different activation; manually constructed Config structs; partially converted configs between model versions.","solutions":["Set cfg.swiglu_multiple_of to the value used by the checkpoint (commonly 128) in the Config or source config.json","Switch non_linearity_type to a supported variant that does not require this field if that matches the checkpoint","Compare your config.json against the official MetaVoice config and add all missing Swiglu-related fields"],"exampleFix":"// before\nlet cfg = Config { non_linearity_type: NonLinearityType::Swiglu, swiglu_multiple_of: None, .. };\n// after\nlet cfg = Config { non_linearity_type: NonLinearityType::Swiglu, swiglu_multiple_of: Some(128), .. };","handlingStrategy":"validation","validationCode":"if cfg.non_linearity_type == NonLinearityType::Swiglu && cfg.swiglu_multiple_of.is_none() {\n    return Err(\"swiglu_multiple_of must be set when using Swiglu\");\n}","typeGuard":null,"tryCatchPattern":"let model = Metavoice::new(&cfg, vb)\n    .map_err(|e| format!(\"config incomplete: {e}\"))?;","preventionTips":["Provide swiglu_multiple_of (typically 128) whenever Swiglu is selected","Diff your config.json against the official MetaVoice config","Validate required fields per non-linearity type before building the model"],"tags":["rust","candle","metavoice","config","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}