{"record":{"id":"fd0de0d722285fea","repo":"tracel-ai/burn","slug":"can-t-differentiate-embedding-backward","errorCode":null,"errorMessage":"Can't differentiate embedding backward.","messagePattern":"Can't differentiate embedding backward\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-autodiff/src/ops/module.rs","lineNumber":60,"sourceCode":"        match Embedding\n            .prepare::<C>([weights.node])\n            .compute_bound()\n            .stateful()\n        {\n            OpsKind::Tracked(prep) => prep.finish(\n                (weights.primitive.clone(), indices.clone()),\n                B::embedding(weights.primitive, indices),\n            ),\n            OpsKind::UnTracked(prep) => prep.finish(B::embedding(weights.primitive, indices)),\n        }\n    }\n\n    fn embedding_backward(\n        _weights: AutodiffTensor<B>,\n        _output: AutodiffTensor<B>,\n        _indices: IntTensor<B>,\n    ) -> AutodiffTensor<B> {\n        panic!(\"Can't differentiate embedding backward.\");\n    }\n\n    fn linear(\n        x: AutodiffTensor<B>,\n        weight: AutodiffTensor<B>,\n        bias: Option<AutodiffTensor<B>>,\n    ) -> AutodiffTensor<B> {\n        #[derive(Debug)]\n        struct LinearWithBias;\n        #[derive(Debug)]\n        struct LinearNoBias;\n\n        impl<B: Backend> Backward<B, 3> for LinearWithBias {\n            type State = (Option<NodeId>, Option<NodeId>);\n\n            fn backward(\n                self,\n                ops: Ops<Self::State, 3>,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-autodiff/src/ops/module.rs#L42-L78","documentation":"The BackendRouter's QTensorOps implementation is entirely stubbed: q_from_data (creating a quantized tensor from raw data) panics with unimplemented!. The router does not yet support creating quantized tensors directly from data.","triggerScenarios":"Calling q_from_data::<BackendRouter<...>>(data, device) — e.g. deserializing a quantized checkpoint or constructing a quantized tensor from stored TensorData on a routed backend.","commonSituations":"Loading quantized models from disk on a router backend; code generic over Backend that happens to resolve to BackendRouter; quantization support gaps between concrete backends and the router.","solutions":["Run quantized workloads on a concrete backend that implements QTensorOps, not BackendRouter.","Quantize at runtime instead: create a float tensor from data, then quantize it with a backend supporting quantize (note: router quantize is also stubbed, so this requires a concrete backend).","Upstream/downgrade: check burn version for router quantization support."],"exampleFix":"// before\nlet q = BackendRouter::<R>::q_from_data(data, &device); // panics\n// after\nlet f = B::float_from_data(data, &device);\nlet q = B::quantize(f, &scheme, qparams); // on a concrete backend","handlingStrategy":"fallback","validationCode":"fn supports_router_qtensor<B: Backend>() -> bool {\n    // BackendRouter's QTensorOps is stubbed; require a concrete backend\n    false\n}","typeGuard":"fn is_qfloat(dtype: &burn_tensor::DType) -> bool {\n    matches!(dtype, burn_tensor::DType::QFloat(_))\n}","tryCatchPattern":"let q = std::panic::catch_unwind(|| B::q_from_data(data.clone(), &device))\n    .map_err(|_| anyhow::anyhow!(\"q_from_data unsupported on router; use a concrete backend\"))?;","preventionTips":["Do not construct quantized tensors directly on BackendRouter.","Create float tensors and quantize on a concrete backend.","Keep quantization at model-build time on the native backend.","Add a compile-time or startup check that quantized ops run on a non-router backend."],"tags":["rust","burn-router","quantization","unimplemented"],"backgroundTag":"unimplemented-api-stub","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"}