tracel-ai/burn · critical

unimplemented!()

Error message

unimplemented!()

What it means

The `all_reduce` operation in the distributed backend trait (`BackendOps` in crates/burn-backend/src/backend/distributed/ops.rs) is a default trait method whose body is `unimplemented!()`. Backends are expected to override it with a real collective implementation; calling the default means the selected backend does not implement distributed all-reduce.

Source

Thrown at crates/burn-backend/src/backend/distributed/ops.rs:121

        let _ = (tensor, distributed_params);
    }

    /// all_reduce operation.
    ///
    /// # Arguments
    ///
    /// * `tensors` - The tensors on which to perform all_reduce.
    /// * `op` - The [`ReduceOperation`].
    ///
    /// # Returns
    ///
    /// The corresponding [CollectiveTensor].
    fn all_reduce(
        _tensor: FloatTensor<B>,
        _op: ReduceOperation,
        _device_ids: Vec<DeviceId>,
    ) -> CollectiveTensor<B> {
        unimplemented!()
    }

    /// Sync the collective operations.
    ///
    /// # Arguments
    ///
    /// * `device` - The device to sync.
    fn sync_collective(_device: &B::Device) {
        unimplemented!()
    }

    /// Get the device of the tensor reference.
    ///
    /// # Arguments
    ///
    /// * `tensor` - The tensor reference.
    ///
    /// # Returns

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Use a backend that implements the distributed collective ops (e.g. the distributed/NCCL-style backend) instead of the default stub.
  2. Override `all_reduce` in your custom backend trait implementation with a real reduction.
  3. Guard distributed code paths so `all_reduce` is only invoked when a distributed backend is actually configured.

Example fix

// before
B::all_reduce(tensor, ReduceOperation::Sum, device_ids); // panics

// after
// build/run with a backend implementing distributed ops, e.g. the distributed backend feature,
// or implement in your backend:
fn all_reduce(tensor: FloatTensor<Self>, op: ReduceOperation, device_ids: Vec<DeviceId>) -> CollectiveTensor<Self> {
    /* real implementation */
}
Defensive patterns

Strategy: validation

Validate before calling

// Rust: ensure the backend supports distributed collectives before calling
if !B::SUPPORTS_DISTRIBUTED { /* or check via feature/capability flag */
    panic!("backend does not implement all_reduce; use a distributed backend");
}

Try / catch

// Rust panics are not catchable with catch_unwind across the whole program safely, but:
let result = std::panic::catch_unwind(|| B::all_reduce(t, op, devices));
if result.is_err() { /* fall back to single-device path */ }

Prevention

When it happens

Trigger: Calling `all_reduce(tensor, op, device_ids)` on a backend that has not overridden the default method (e.g. a single-device backend used in a distributed code path).

Common situations: Running a distributed training script while the backend only supports single-device execution; forgetting to enable/select the distributed backend feature; a partially migrated custom backend that left the default stub in place.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/98c8aca5c72dea3a. Report an issue: GitHub.