{"record":{"id":"a2191aaf45b58837","repo":"tracel-ai/burn","slug":"lookup-quantization-is-not-supported-for-iteration","errorCode":null,"errorMessage":"lookup quantization is not supported for iteration","messagePattern":"lookup quantization is not supported for iteration","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-std/src/data/tensor/conversion.rs","lineNumber":215,"sourceCode":"                                .iter()\n                                .map(|e: &i8| e.elem::<E>())\n                                .collect::<Vec<_>>()\n                                .into_iter(),\n                        )\n                    }\n                    QuantScheme {\n                        mode: QuantMode::Symmetric,\n                        value:\n                            QuantValue::E4M3 | QuantValue::E5M2 | QuantValue::E2M1,\n                        ..\n                    } => {\n                        unimplemented!(\"Not yet implemented for iteration\");\n                    }\n                    QuantScheme {\n                        mode: QuantMode::Lookup,\n                        ..\n                    } => {\n                        unimplemented!(\"lookup quantization is not supported for iteration\");\n                    }\n                },\n            }\n        }\n    }\n\n    /// Converts the data to the dtype represented by `E`.\n    ///\n    /// # Panics\n    ///\n    /// Panics if storage access fails, the conversion isn't supported, or the stored\n    /// representation or element count is invalid.\n    #[track_caller]\n    pub fn convert<E: Element>(self) -> Self {\n        // TODO: deprecate?\n        self.try_cast_as::<E>()\n            .unwrap_or_else(|err| panic!(\"Failed to convert TensorData: {err}\"))\n    }","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-std/src/data/tensor/conversion.rs#L197-L233","documentation":"The same TensorData::iter::<E>() match (crates/burn-std/src/data/tensor/conversion.rs:211-216) also rejects QuantMode::Lookup schemes with a dedicated `unimplemented!`. Lookup-table quantization has no element iteration path: values are indices into a lookup table and the machinery to resolve them during iteration does not exist, so the library panics with this message.","triggerScenarios":"Calling `tensor_data.iter::<E>()` (or morph_impl's conversion path that calls iter) on a TensorData with dtype DType::QFloat(scheme) where scheme.mode == QuantMode::Lookup.","commonSituations":"Using a lookup-based quantization scheme (e.g. LUT / non-symmetric per-value codebook quantization) and then attempting to read elements back via iter/convert instead of the dedicated lookup dequantization path.","solutions":["Avoid QuantMode::Lookup if you need element-wise iteration; use Symmetric int8/sub-byte schemes instead.","Dequantize lookup-quantized data through the lookup-specific API before inspecting values.","File/track an upstream burn issue for lookup-mode iteration support and upgrade when available."],"exampleFix":"// before\nlet vals: Vec<f32> = lookup_quantized_data.iter::<f32>().collect(); // panics\n// after\nlet dequant = lookup_quantized.dequantize(); // resolves lookup entries to floats\nlet vals: Vec<f32> = dequant.iter::<f32>().collect();","handlingStrategy":"type-guard","validationCode":"fn lookup_mode(dtype: &DType) -> bool {\n    matches!(dtype, DType::QFloat(QuantScheme { mode: QuantMode::Lookup, .. }))\n}\nif lookup_mode(&data.dtype) {\n    // do not call data.iter::<E>() — resolve via lookup dequantization instead\n}","typeGuard":"fn is_lookup_scheme(scheme: &QuantScheme) -> bool {\n    matches!(scheme.mode, QuantMode::Lookup)\n}","tryCatchPattern":"// guard before iterating\nif is_lookup_scheme(&scheme) {\n    let values = resolve_lookup(data); // dequantize via lookup table\n} else {\n    let values: Vec<f32> = data.iter::<f32>().collect();\n}","preventionTips":["Never call iter/convert on lookup-quantized TensorData.","Prefer symmetric quantization when you need element-level reads.","Keep a helper that routes lookup schemes to the correct dequantization API."],"tags":["rust","burn","quantization","lookup-table","unimplemented"],"backgroundTag":"unimplemented-feature-panic","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"}