tracel-ai/burn · error

Quantization not supported for scheme {scheme:?}

Error message

Quantization not supported for scheme {scheme:?}

What it means

Panics because quantize was called with a QuantScheme that has no code path in this match arm of the per-block quantization branch. The scheme value reached the block-quantization arm (which expects block-quantized schemes with per-block scales and optionally a per-tensor global scale) but was not one of the supported block schemes, so no conversion could be performed. Fix by passing a supported block-quantization scheme (or route the tensor to the affine/per-tensor path appropriate for that scheme).

Source

Thrown at crates/burn-ndarray/src/ops/qtensor.rs:169

                    store: QuantStore::Native,
                    ..
                },
            ) => {
                let global = if global_scale_dtype(scheme).is_some() {
                    Some(global.expect("a two-level scheme should have a per-tensor scale"))
                } else {
                    None
                };
                quantize_per_block(
                    data_f.as_slice().unwrap(),
                    shape.clone(),
                    scheme,
                    block_size,
                    scales.as_slice(),
                    global,
                )
            }
            (_, scheme) => unimplemented!("Quantization not supported for scheme {scheme:?}"),
        };

        let q_bytes = QuantizedBytes {
            shape: data.shape.clone(),
            bytes: data.into_bytes(),
            scheme: *scheme,
        };
        let (values, _) = q_bytes.into_vec_i8();
        let data = TensorData::new(values, shape);

        NdArrayQTensor {
            qtensor: NdArrayTensor::from_data(data),
            scheme: *scheme,
            qparams,
            global,
        }
    }

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Quantize with a supported scheme (e.g., symmetric Q8F/Q8S)
  2. Check the scheme's QuantValue/QuantStore/QuantMode combination against ndarray's supported arms
  3. Use a different backend for exotic quantization schemes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/burn-ndarray/src/ops/qtensor.rs:169 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/ffdc21f3f47fba36. Report an issue: GitHub.