{"record":{"id":"587900f0609dce3f","repo":"tracel-ai/burn","slug":"lookup-quantization-does-not-travel-as-a-qfloat-te","errorCode":null,"errorMessage":"lookup quantization does not travel as a QFloat tensor","messagePattern":"lookup quantization does not travel as a QFloat tensor","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl/src/ops/qtensor.rs","lineNumber":243,"sourceCode":"                        QuantValue::Q8F\n                        | QuantValue::Q8S\n                        | QuantValue::Q4F\n                        | QuantValue::Q4S\n                        | QuantValue::Q2F\n                        | QuantValue::Q2S\n                        | QuantValue::E4M3\n                        | QuantValue::E5M2\n                        | QuantValue::E2M1,\n                    ..\n                } => {\n                    // TensorData quantized representation is the same, with multiple quantized values\n                    // packed into u32 and quantization parameters appended to the bytes\n                    new_qtensor_optimized(data.bytes, data.shape.clone(), scheme, device)\n                }\n                QuantScheme {\n                    mode: QuantMode::Lookup,\n                    ..\n                } => unimplemented!(\"lookup quantization does not travel as a QFloat tensor\"),\n            },\n            _ => panic!(\n                \"Invalid dtype (expected DType::QFloat, got {:?})\",\n                data.dtype\n            ),\n        }\n    }\n\n    // TODO: quantize_dynamic (we can compute min-max on the fly and scale, especially when not per-tensor)\n\n    fn quantize(\n        tensor: FloatTensor<Self>,\n        scheme: &QuantScheme,\n        qparams: QuantizationParametersPrimitive<Self>,\n    ) -> QuantizedTensor<Self> {\n        // The kernel reads this at the scheme's scale dtype, not the tensor's actual dtype.\n        if let Some(global) = &qparams.global {\n            assert_eq!(","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl/src/ops/qtensor.rs#L225-L261","documentation":"Quantized tensors with a lookup-table QuantScheme (QuantMode::Lookup) cannot be constructed from raw TensorData because lookup quantization is not representable/travelable as a QFloat tensor in the CubeCl backend. q_from_data only supports the other quantization schemes (per-tensor/block data packed into u32 with quantization parameters appended). Hitting this means you tried to build a lookup-quantized tensor via from_data/q_from_data.","triggerScenarios":"Calling q_from_data (directly or via QuantizedTensor::from_data / quantization APIs) on a CubeCl backend with TensorData whose dtype is DType::QFloat and whose QuantScheme has mode: QuantMode::Lookup.","commonSituations":"Loading lookup-quantized model weights from disk; configuring a quantization scheme to LookupTable and then instantiating tensors from data on GPU; version changes where lookup quantization support was added partially (inference only, no data-path construction).","solutions":["Use a supported QuantScheme mode (e.g. per-block affine/symmetric int8) when constructing quantized tensors from data.","Keep lookup-quantized weights in a format that avoids the QFloat data path, or construct them via the dedicated lookup-quantization init API if available.","Quantize on CPU or with a backend that supports lookup-mode construction, then transfer if the target backend supports it.","File/check a burn issue for QuantMode::Lookup support in q_from_data on CubeCl."],"exampleFix":"// before\nlet scheme = QuantScheme::default().with_mode(QuantMode::Lookup);\nlet q = QTensorPrimitive::from_data(data, scheme, &device); // panics\n// after\nlet scheme = QuantScheme::default().with_mode(QuantMode::PerBlockAffine);\nlet q = QTensorPrimitive::from_data(data, scheme, &device);","handlingStrategy":"validation","validationCode":"match scheme.mode() {\n    QuantMode::Lookup => panic!(\"lookup quantization cannot be built via q_from_data; use another scheme\"),\n    _ => { /* safe to construct */ }\n}","typeGuard":"fn is_data_constructible_scheme(scheme: &QuantScheme) -> bool {\n    scheme.mode() != QuantMode::Lookup\n}","tryCatchPattern":null,"preventionTips":["Avoid QuantMode::Lookup when constructing quantized tensors from TensorData on CubeCl","Use per-block/per-tensor affine schemes for the from_data path","Verify quantization scheme compatibility with the target backend early in the pipeline","Keep lookup-quantized weights in inference-only load paths that do not use QFloat data"],"tags":["rust","burn","cubecl","quantization","lookup-table"],"backgroundTag":"unsupported-quantization-mode","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"}