{"record":{"id":"f26fc62e6f751e73","repo":"tracel-ai/burn","slug":"can-t-add-a-new-input-that-is-already-used-in-an-i","errorCode":null,"errorMessage":"Can't add a new input that is already used in an index operation","messagePattern":"Can't add a new input that is already used in an index operation","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl-fusion/src/engine/trace/fuser.rs","lineNumber":189,"sourceCode":"    pub fn input_unhandled(&mut self, tensor: &TensorIr) -> FuseArg {\n        if self.resources.indexed.contains_key(&tensor.id) {\n            panic!(\"Can't add a new input that is already used in an index operation\");\n        }\n\n        self.resources.outputs.update(tensor);\n\n        let precision = tensor.dtype.into();\n        let new_input = self.resources.inputs.insert(precision, tensor.clone());\n        let arg = FuseArg::Input(new_input, precision, LayoutInfo::Unknown);\n\n        self.resources.inputs_unhandled.push(tensor.id);\n        arg\n    }\n\n    /// Register an input tensor.\n    pub fn input_quantized_unhandled(&mut self, tensor: &TensorIr) -> Option<(FuseArg, FuseArg)> {\n        if self.resources.indexed.contains_key(&tensor.id) {\n            panic!(\"Can't add a new input that is already used in an index operation\");\n        }\n\n        let (precision, precision_scales) = match tensor.dtype {\n            DType::QFloat(scheme) => (\n                FuseType::from_quant_scheme(scheme)?,\n                FuseType::from_scale_dtype(scheme.scale_dtype())?,\n            ),\n            _ => return None,\n        };\n\n        self.resources.outputs.update(tensor);\n\n        let (new_input, q_index) = self.resources.inputs.insert_quant(tensor.clone());\n        let input = FuseArg::Input(new_input, precision, LayoutInfo::Unknown);\n        let scales = FuseArg::Input(q_index, precision_scales, LayoutInfo::Unknown);\n\n        self.resources.inputs_unhandled.push(tensor.id);\n        Some((input, scales))","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl-fusion/src/engine/trace/fuser.rs#L171-L207","documentation":"Fusion-engine resource conflict: a tensor ID already registered as an indexed resource (used as an index operand in a gather/scatter-like op) is being re-registered as a new fusion input via `input_unhandled`. Fusion compilation cannot represent a tensor that is simultaneously an index source and a plain data input, so the panic fires; the offending input is the tensor whose ID appears in `resources.indexed`.","triggerScenarios":"Thrown at crates/burn-cubecl-fusion/src/engine/trace/fuser.rs:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Materialize the index tensor outside the fused kernel (clone or detach it into a separate operation) so it is not registered twice.","Check the trace builder so a tensor previously used for indexing is routed through the indexed-input path, not `input_unhandled`.","Update the fusion engine to reuse the existing indexed argument instead of inserting a new input for that ID."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}