{"record":{"id":"a85a11133196693f","repo":"tracel-ai/burn","slug":"autodiff-context-requires-the-autodiff-feature","errorCode":null,"errorMessage":"autodiff context requires the `autodiff` feature","messagePattern":"autodiff context requires the `autodiff` feature","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/burn-backend-extension/src/routing.rs","lineNumber":1068,"sourceCode":"                #concrete_enabled\n            }\n        }\n    };\n    let enabled = match float_inputs {\n        FloatInputPresence::Always => autodiff_enabled,\n        FloatInputPresence::Never => concrete_enabled_route,\n        FloatInputPresence::Runtime(expression) => {\n            let concrete_runtime = if operation.output.contains_float() {\n                quote! {\n                    #autodiff_attr\n                    false => {\n                        type #backend_alias = #backend_root::#backend;\n                        #concrete_inputs\n                        #concrete_invoke\n                        #concrete_enabled_output\n                    }\n                    #no_autodiff_attr\n                    false => panic!(\"autodiff context requires the `autodiff` feature\"),\n                }\n            } else {\n                quote! {\n                    false => {\n                        type #backend_alias = #backend_root::#backend;\n                        #concrete_inputs\n                        #concrete_invoke\n                        #concrete_enabled\n                    }\n                }\n            };\n            quote! {\n                #context::Enabled(__strategy) => match #expression {\n                    #autodiff_attr\n                    true => #autodiff_call,\n                    #no_autodiff_attr\n                    true => panic!(\"autodiff context requires the `autodiff` feature\"),\n                    #concrete_runtime","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-backend-extension/src/routing.rs#L1050-L1086","documentation":"Generated routing code matches on whether the `autodiff` feature is compiled in. When an autodiff-enabled execution branch is requested but the crate was built without the `autodiff` feature, the `false` arm of the feature check panics with this message. It is a compile-time configuration error surfacing as a runtime panic.","triggerScenarios":"Enabling autodiff context at runtime (Enabled arm) while the workspace crate `burn-backend-extension` (or the consuming crate) was built without `features = [\"autodiff\"]` — the `#no_autodiff_attr` arm's `true => panic!(...)` fires.","commonSituations":"Dependency declared without feature: `burn = { version, features = [\"wgpu\"] }` missing `\"autodiff\"`; feature unification surprises in a workspace; enabling autodiff via config file that the build ignores; CI building with `--no-default-features`.","solutions":["Add the `autodiff` feature to the dependency: `burn-backend-extension = { version = \"...\", features = [\"autodiff\"] }` (or enable it on the umbrella `burn` crate).","Verify with `cargo tree -e features` that the feature is unified into the final build.","If autodiff is genuinely unneeded, stop selecting the autodiff branch (use the inference path) instead of enabling the feature."],"exampleFix":"// before (Cargo.toml)\n[dependencies]\nburn = { version = \"0.18\", features = [\"wgpu\"] }\n\n// after\n[dependencies]\nburn = { version = \"0.18\", features = [\"wgpu\", \"autodiff\"] }","handlingStrategy":"validation","validationCode":"// build.rs or CI check\n// fail fast if the feature is missing when autodiff code is compiled:\n#[cfg(not(feature = \"autodiff\"))]\ncompile_error!(\"autodiff feature required\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List the `autodiff` feature explicitly in Cargo.toml rather than relying on default features.","Run `cargo tree -e features | grep autodiff` in CI to verify feature unification.","Keep feature flags identical across dev/CI/release profiles."],"tags":["autodiff","cargo-features","compile-time","burn"],"backgroundTag":"missing-cargo-feature","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}