tracel-ai/burn · error
lookup quantization is not supported for iteration
Error message
lookup quantization is not supported for iteration
What it means
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.
Source
Thrown at crates/burn-std/src/data/tensor/conversion.rs:215
.iter()
.map(|e: &i8| e.elem::<E>())
.collect::<Vec<_>>()
.into_iter(),
)
}
QuantScheme {
mode: QuantMode::Symmetric,
value:
QuantValue::E4M3 | QuantValue::E5M2 | QuantValue::E2M1,
..
} => {
unimplemented!("Not yet implemented for iteration");
}
QuantScheme {
mode: QuantMode::Lookup,
..
} => {
unimplemented!("lookup quantization is not supported for iteration");
}
},
}
}
}
/// Converts the data to the dtype represented by `E`.
///
/// # Panics
///
/// Panics if storage access fails, the conversion isn't supported, or the stored
/// representation or element count is invalid.
#[track_caller]
pub fn convert<E: Element>(self) -> Self {
// TODO: deprecate?
self.try_cast_as::<E>()
.unwrap_or_else(|err| panic!("Failed to convert TensorData: {err}"))
}View on GitHub (pinned to d16f7ba2ed)
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.
Example fix
// before let vals: Vec<f32> = lookup_quantized_data.iter::<f32>().collect(); // panics // after let dequant = lookup_quantized.dequantize(); // resolves lookup entries to floats let vals: Vec<f32> = dequant.iter::<f32>().collect();
Defensive patterns
Strategy: type-guard
Validate before calling
fn lookup_mode(dtype: &DType) -> bool {
matches!(dtype, DType::QFloat(QuantScheme { mode: QuantMode::Lookup, .. }))
}
if lookup_mode(&data.dtype) {
// do not call data.iter::<E>() — resolve via lookup dequantization instead
} Type guard
fn is_lookup_scheme(scheme: &QuantScheme) -> bool {
matches!(scheme.mode, QuantMode::Lookup)
} Try / catch
// guard before iterating
if is_lookup_scheme(&scheme) {
let values = resolve_lookup(data); // dequantize via lookup table
} else {
let values: Vec<f32> = data.iter::<f32>().collect();
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- todo!("Quantization not supported yet")
- lookup quantization does not travel as a QFloat tensor
- unimplemented!()
- Can't format yet
- Not yet implemented for iteration
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/a2191aaf45b58837.
Report an issue: GitHub.