tracel-ai/burn · error

unimplemented!()

Error message

unimplemented!()

What it means

q_flip for the CubeCl quantized-tensor backend is a stub that immediately panics with unimplemented!(). Flipping a quantized tensor along axes is not implemented, even though q_permute is. This is a pure backend completeness gap; no input can make it succeed.

Source

Thrown at crates/burn-cubecl/src/ops/qtensor.rs:322

            shape,
            dtype,
        })
    }

    fn q_swap_dims(
        tensor: QuantizedTensor<Self>,
        dim1: usize,
        dim2: usize,
    ) -> QuantizedTensor<Self> {
        swap_dims(tensor, dim1, dim2)
    }

    fn q_permute(tensor: QuantizedTensor<Self>, axes: &[usize]) -> QuantizedTensor<Self> {
        permute(tensor, axes)
    }

    fn q_flip(_tensor: QuantizedTensor<Self>, _axes: &[usize]) -> QuantizedTensor<Self> {
        unimplemented!()
    }

    fn q_matmul(lhs: TensorPrimitive<Self>, rhs: TensorPrimitive<Self>) -> TensorPrimitive<Self> {
        let (settings, scheme) = match (&lhs, &rhs) {
            (TensorPrimitive::QFloat(lhs), _) => {
                (get_device_settings::<Self>(&lhs.device), lhs.scheme())
            }
            (_, TensorPrimitive::QFloat(rhs)) => {
                (get_device_settings::<Self>(&rhs.device), rhs.scheme())
            }
            _ => unreachable!(),
        };

        // Inherit precision for mixed inputs, default to `FloatElem` for fully quantized.
        let out_dtype = match (&lhs, &rhs) {
            (TensorPrimitive::Float(lhs), _) => lhs.dtype,
            (_, TensorPrimitive::Float(rhs)) => rhs.dtype,
            _ => settings.float_dtype.into(),

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Flip the tensor BEFORE quantizing it (dequantize -> flip -> requantize if needed).
  2. Re-express flip as slicing + cat or as permute/slice operations that are implemented for quantized tensors.
  3. Perform the flip on a non-quantized (float) tensor and quantize afterwards.
  4. Contribute an implementation to crates/burn-cubecl/src/ops/qtensor.rs (q_flip) upstream.

Example fix

// before
let flipped = qtensor.flip(&[3]); // panics: q_flip unimplemented
// after
let flipped = tensor.flip(&[3]).quantize(&scheme, &device); // flip then quantize
Defensive patterns

Strategy: validation

Validate before calling

fn assert_not_quantized<T: QTensorPrimitive>(t: &T) { /* flip only non-quantized tensors */ }
// or: only call .flip on float tensors, quantize afterwards

Type guard

fn can_flip_qtensor() -> bool { false } // q_flip is a stub for CubeCl; never call it

Prevention

When it happens

Trigger: Calling q_flip (or Tensor::flip on a quantized tensor / QTensorPrimitive) with the CubeCl backend, regardless of axes or shape.

Common situations: Data augmentation pipelines that flip quantized images on GPU; generic tensor code that calls flip without knowing the tensor is quantized; migrating models that apply flips after quantization.

Related errors


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