{"record":{"id":"b18957aebfaf08a4","repo":"tracel-ai/burn","slug":"other-doesn-t-support-native-packing-b18957","errorCode":null,"errorMessage":"{other:?} doesn't support native packing","messagePattern":"(.+?) doesn't support native packing","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl/src/ops/qtensor.rs","lineNumber":107,"sourceCode":"            }\n            shape_value[rank - 1] = shape_last.div_ceil(num_quants);\n            size_of::<u32>()\n        }\n        QuantStore::Native => match scheme.value {\n            QuantValue::Q8F | QuantValue::Q8S | QuantValue::E4M3 | QuantValue::E5M2 => {\n                size_of::<i8>()\n            }\n            QuantValue::Q4F\n            | QuantValue::Q4S\n            | QuantValue::Q2F\n            | QuantValue::Q2S\n            | QuantValue::E2M1 => {\n                panic!(\"Can't store native sub-byte values\")\n            }\n        },\n        QuantStore::PackedNative(_) => match scheme.value {\n            QuantValue::E2M1 => size_of::<e2m1x2>(),\n            other => panic!(\"{other:?} doesn't support native packing\"),\n        },\n    };\n\n    let scales_dtype = match scheme.scale_dtype() {\n        ScaleDtype::F32 => DType::F32,\n        ScaleDtype::F16 => DType::F16,\n        ScaleDtype::BF16 => DType::BF16,\n        // Represented by U8 and reinterpreted in the kernel\n        ScaleDtype::UE8M0 | ScaleDtype::UE4M3 => DType::U8,\n    };\n\n    let scales_shape = params_shape(&shape, &scheme);\n    let data_desc = MemoryLayoutDescriptor::new(alloc_kind, shape_value.clone(), data_size);\n    let scales_desc =\n        MemoryLayoutDescriptor::new(alloc_kind, scales_shape.clone(), scales_dtype.size());\n\n    let global_shape = Shape::new([1]);\n    let global_dtype = global_scale_dtype(&scheme).map(|dtype| {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl/src/ops/qtensor.rs#L89-L125","documentation":"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.","triggerScenarios":"Calling new_qtensor/empty_qtensor with QuantStore::PackedNative and a scheme.value other than E2M1 (e.g. Q4F, Q2S packed natively).","commonSituations":"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.","solutions":["Use QuantStore::PackedU32 for packing Q4/Q2 values","Restrict PackedNative usage to QuantValue::E2M1","Check scheme.value when constructing the scheme and assert the pairing"],"exampleFix":"// before\nlet scheme = scheme.with_store(QuantStore::PackedNative(_)).with_value(QuantValue::Q4F);\n// after\nlet scheme = scheme.with_value(QuantValue::Q4F).with_store(QuantStore::PackedU32(QuantAccurate::No));","handlingStrategy":"validation","validationCode":"if matches!(scheme.store, QuantStore::PackedNative(_)) {\n    assert_eq!(scheme.value, QuantValue::E2M1, \"PackedNative supports only E2M1\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember PackedNative == E2M1-only; use PackedU32 for everything else","Validate QuantScheme store/value pairing at construction time","Document the restriction in your quantization config schema"],"tags":["quantization","packing","config","burn"],"backgroundTag":"quant-store-alignment","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}