tracel-ai/burn · error
Can't add a new input that is already used in an index opera
Error message
Can't add a new input that is already used in an index operation
What it means
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`.
Source
Thrown at crates/burn-cubecl-fusion/src/engine/trace/fuser.rs:189
pub fn input_unhandled(&mut self, tensor: &TensorIr) -> FuseArg {
if self.resources.indexed.contains_key(&tensor.id) {
panic!("Can't add a new input that is already used in an index operation");
}
self.resources.outputs.update(tensor);
let precision = tensor.dtype.into();
let new_input = self.resources.inputs.insert(precision, tensor.clone());
let arg = FuseArg::Input(new_input, precision, LayoutInfo::Unknown);
self.resources.inputs_unhandled.push(tensor.id);
arg
}
/// Register an input tensor.
pub fn input_quantized_unhandled(&mut self, tensor: &TensorIr) -> Option<(FuseArg, FuseArg)> {
if self.resources.indexed.contains_key(&tensor.id) {
panic!("Can't add a new input that is already used in an index operation");
}
let (precision, precision_scales) = match tensor.dtype {
DType::QFloat(scheme) => (
FuseType::from_quant_scheme(scheme)?,
FuseType::from_scale_dtype(scheme.scale_dtype())?,
),
_ => return None,
};
self.resources.outputs.update(tensor);
let (new_input, q_index) = self.resources.inputs.insert_quant(tensor.clone());
let input = FuseArg::Input(new_input, precision, LayoutInfo::Unknown);
let scales = FuseArg::Input(q_index, precision_scales, LayoutInfo::Unknown);
self.resources.inputs_unhandled.push(tensor.id);
Some((input, scales))View on GitHub (pinned to d16f7ba2ed)
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/burn-cubecl-fusion/src/engine/trace/fuser.rs:189 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/f26fc62e6f751e73.
Report an issue: GitHub.