tracel-ai/burn · error

{other:?} doesn't support native packing

Error message

{other:?} doesn't support native packing

What it means

PackedNative storage packs exactly two values per native element and is only defined for the E2M1 float type (via e2m1x2). Any other QuantValue under PackedNative has no native packing representation, so the library panics naming the offending value type.

Source

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

            }
            shape_value[rank - 1] = shape_last.div_ceil(num_quants);
            size_of::<u32>()
        }
        QuantStore::Native => match scheme.value {
            QuantValue::Q8F | QuantValue::Q8S | QuantValue::E4M3 | QuantValue::E5M2 => {
                size_of::<i8>()
            }
            QuantValue::Q4F
            | QuantValue::Q4S
            | QuantValue::Q2F
            | QuantValue::Q2S
            | QuantValue::E2M1 => {
                panic!("Can't store native sub-byte values")
            }
        },
        QuantStore::PackedNative(_) => match scheme.value {
            QuantValue::E2M1 => size_of::<e2m1x2>(),
            other => panic!("{other:?} doesn't support native packing"),
        },
    };

    let scales_dtype = match scheme.scale_dtype() {
        ScaleDtype::F32 => DType::F32,
        ScaleDtype::F16 => DType::F16,
        ScaleDtype::BF16 => DType::BF16,
        // Represented by U8 and reinterpreted in the kernel
        ScaleDtype::UE8M0 | ScaleDtype::UE4M3 => DType::U8,
    };

    let scales_shape = params_shape(&shape, &scheme);
    let data_desc = MemoryLayoutDescriptor::new(alloc_kind, shape_value.clone(), data_size);
    let scales_desc =
        MemoryLayoutDescriptor::new(alloc_kind, scales_shape.clone(), scales_dtype.size());

    let global_shape = Shape::new([1]);
    let global_dtype = global_scale_dtype(&scheme).map(|dtype| {

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Use QuantStore::PackedU32 for packing Q4/Q2 values
  2. Restrict PackedNative usage to QuantValue::E2M1
  3. Check scheme.value when constructing the scheme and assert the pairing

Example fix

// before
let scheme = scheme.with_store(QuantStore::PackedNative(_)).with_value(QuantValue::Q4F);
// after
let scheme = scheme.with_value(QuantValue::Q4F).with_store(QuantStore::PackedU32(QuantAccurate::No));
Defensive patterns

Strategy: validation

Validate before calling

if matches!(scheme.store, QuantStore::PackedNative(_)) {
    assert_eq!(scheme.value, QuantValue::E2M1, "PackedNative supports only E2M1");
}

Prevention

When it happens

Trigger: Calling new_qtensor/empty_qtensor with QuantStore::PackedNative and a scheme.value other than E2M1 (e.g. Q4F, Q2S packed natively).

Common situations: Confusing PackedNative (E2M1-only, 2 values per byte) with PackedU32 (general packing); following older quantization configs that packed Q4 natively before the API restricted it.

Related errors


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