tracel-ai/burn · error

Distributed operations are not supported for device {other:?

Error message

Distributed operations are not supported for device {other:?}

What it means

The `dispatch_distributed_device!` macro matches a DispatchDevice against the backends compiled into the dispatch layer. If the device variant does not correspond to any supported backend, it panics with 'Distributed operations are not supported for device {other:?}'.

Source

Thrown at crates/burn-dispatch/src/ops/distributed.rs:66

                    type B = $crate::backends::$Backend;
                    let $inner_devices = $devices
                        .iter()
                        .map(|d| {
                            // In a build with only one dispatch variant compiled in, the
                            // pattern is irrefutable and the else clause is dead — which is
                            // the point: it only guards the multi-backend builds.
                            #[allow(irrefutable_let_patterns)]
                            let DispatchDevice::$Backend(dev) = d else {
                                unreachable!("All devices are expected to be of the same variant.")
                            };
                            dev.clone()
                        })
                        .collect::<Vec<_>>();
                    $body
                }
            )*
            #[allow(unreachable_patterns)]
            other => panic!("Distributed operations are not supported for device {other:?}"),
        }
    };
    (
        @autodiff
        $device:expr,
        $devices:expr,
        |$inner_devices:ident| $body:expr;
        $([$Backend:ident, $cfg:meta]),*
    ) => {
        match $device {
            $(
                #[cfg($cfg)]
                $crate::DispatchDevice::$Backend(_) => {
                    type B = $crate::backends::Autodiff<$crate::backends::$Backend>;
                    let $inner_devices = $devices
                        .iter()
                        .map(|d| {
                            // In a build with only one dispatch variant compiled in, the

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Enable the cargo feature for the backend owning the device (e.g. `wgpu`, `cuda`) before dispatching distributed ops
  2. Pass a device created via the correct backend's `default_device()`
  3. Verify the distributed operation supports the target backend

Example fix

// before
cargo run --features autodiff        # backend feature missing
// after
cargo run --features autodiff,wgpu-spirv  # enable the backend feature for the device
Defensive patterns

Strategy: validation

Validate before calling

// before dispatch: verify device backend is compiled in and supported
fn ensure_supported(dev: &DispatchDevice) -> Result<(), String> {
    matches!(dev, DispatchDevice::Cpu(_) | DispatchDevice::Wgpu(_)).then_some(()).ok_or("unsupported device".into())
}

Prevention

When it happens

Trigger: Invoking a distributed operation (all-reduce, all-gather, etc.) on a device whose DispatchDevice variant is not one of the enabled backend arms, e.g. a device for a backend feature that is not compiled in.

Common situations: Running distributed collectives with a backend feature flag missing at compile time; passing a device created under a different feature configuration.

Related errors


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