tracel-ai/burn · error

{other:?} doesn't support native packing

Error message

{other:?} doesn't support native packing

What it means

In `quantized_handles`, when the quantization scheme uses native storage, burn-cubecl matches on the `QuantValue` to pick the storage element type; any value variant that has no native (unpacked) storage mapping falls into `other => panic!("{other:?} doesn't support native packing")`. Note the message is inverted terminology: it means this quant value cannot be stored natively (unpacked) and requires packed u32 storage.

Source

Thrown at crates/burn-cubecl/src/tensor/quantization.rs:99

                    qparams: None,
                }
            }
            QuantStore::PackedNative(packed_dim) => match scheme.value {
                QuantValue::E2M1 => {
                    let packed_dim = self.rank() - packed_dim - 1;
                    let mut shape = self.shape();
                    shape[packed_dim] = shape[packed_dim].div_ceil(scheme.num_quants());

                    CubeTensor {
                        client: self.client.clone(),
                        handle: self.handle.clone(),
                        meta: Box::new(Metadata::new(shape, self.meta.strides.clone())),
                        device: self.device.clone(),
                        dtype: DType::U8,
                        qparams: None,
                    }
                }
                other => panic!("{other:?} doesn't support native packing"),
            },
        };

        Some((values, params))
    }

    /// Construct a separate tensor for the quantization scales, if present
    pub fn scales(&self) -> Option<CubeTensor> {
        self.param_tensor(|qparams| Some(&qparams.scales))
    }

    /// Construct a separate tensor for the per-tensor scale, for a two-level scheme.
    pub fn global(&self) -> Option<CubeTensor> {
        self.param_tensor(|qparams| qparams.global.as_ref())
    }

    fn param_tensor(
        &self,

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Use `QuantStore::PackedU32(...)` for the sub-byte quant value instead of `QuantStore::Native`.
  2. Use a natively-storable value (Q8F, Q8S, etc.) if you must keep `QuantStore::Native`.
  3. Take the scheme from a library constructor/constant known to be consistent rather than assembling it ad hoc.

Example fix

// before
let scheme = QuantScheme::default()
    .with_value(QuantValue::E2M1)
    .with_store(QuantStore::Native); // panic: no native storage for E2M1

// after
let scheme = QuantScheme::default()
    .with_value(QuantValue::E2M1)
    .with_store(QuantStore::PackedU32(PackedParam::Rhs));
Defensive patterns

Strategy: validation

Validate before calling

if matches!(scheme.store, QuantStore::Native) && !matches!(scheme.value, QuantValue::Q8F | QuantValue::Q8S | QuantValue::E4M3 | QuantValue::E5M2) {
    panic!("QuantValue {:?} cannot use QuantStore::Native; use PackedU32", scheme.value);
}

Prevention

When it happens

Trigger: Calling `quantize`/`into_contiguous_quantized`, `launch_matmul`, `dequantize`, or `q_reshape` on a tensor whose scheme is `QuantStore::Native` with a `QuantValue` that has no native store arm (e.g. E2M1 or other sub-byte values not covered by the native match arms).

Common situations: Hand-built `QuantScheme` combining `QuantStore::Native` with sub-byte `QuantValue`s; deserializing/constructing quantized models where scheme store mode and value disagree; changing only the store mode from PackedU32 to Native while keeping a 4-bit value.

Related errors


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