tracel-ai/burn · error
todo!("Quantization not supported yet")
Error message
todo!("Quantization not supported yet") What it means
In burn-dispatch's transaction unwrapping macro, when a transaction containing quantized tensors (`read_qfloats`) is dispatched to a backend, the quantized tensors are not converted — each element is mapped to `todo!("Quantization not supported yet")`, panicking. Transactions (batched read/write ops) currently support floats, ints, and bools only.
Source
Thrown at crates/burn-dispatch/src/macros.rs:443
macro_rules! transaction_op_arms {
($tx:ident, $first:expr; $([$Backend:ident, $cfg:meta]),*) => {{
match &$first.kind {
// Autodiff arm first
#[cfg(feature = "autodiff")]
$crate::DispatchTensorKind::Autodiff(inner) => {
// Recursively dispatch on inner
match **inner {
$(
#[cfg($cfg)]
$crate::DispatchTensorKind::$Backend(_) => {
type B = $crate::backends::$Backend;
// Unwrap vec
let floats = unwrap_vec!(@autodiff $Backend, $tx.read_floats, autodiff_inner);
let ints = unwrap_vec!($Backend, $tx.read_ints, int);
let bools = unwrap_vec!($Backend, $tx.read_bools, bool);
// Not supported
let qfloats = $tx.read_qfloats.into_iter().map(|_t| todo!("Quantization not supported yet")).collect();
B::tr_execute(TransactionPrimitive::new(floats, qfloats, ints, bools)).await
}
)*
$crate::DispatchTensorKind::Autodiff(..) => unreachable!("Autodiff should not wrap an autodiff tensor.")
}
},
$(
#[cfg($cfg)]
$crate::DispatchTensorKind::$Backend(_) => {
type B = $crate::backends::$Backend;
// Unwrap vec
let floats = unwrap_vec!($Backend, $tx.read_floats, float);
let ints = unwrap_vec!($Backend, $tx.read_ints, int);
let bools = unwrap_vec!($Backend, $tx.read_bools, bool);
// Not supportedView on GitHub (pinned to d16f7ba2ed)
Solutions
- Avoid transactions for quantized tensors: execute the quantized op standalone instead of within a batched transaction.
- Dequantize to float before the ops that get transactionalized, and quantize afterwards.
- Use a backend/feature path with quantization support so quantized primitives are unwrapped correctly.
- Upgrade burn — this is a known gap that may be implemented in newer versions.
Example fix
// before let out = TransactionPrimitive::new(floats, vec![q_tensor], ints, bools); // panics in dispatch // after let f = q_tensor.dequantize(); let out = TransactionPrimitive::new(floats_with_f, vec![], ints, bools); // floats only
Defensive patterns
Strategy: validation
Validate before calling
fn transaction_supported(tx: &Transaction) -> bool {
tx.read_qfloats.is_empty() && tx.write_qfloats.is_empty()
} Type guard
fn has_qfloats(tx: &Transaction) -> bool { !tx.read_qfloats.is_empty() || !tx.write_qfloats.is_empty() } Prevention
- Exclude quantized tensors from batched transactions; run them as standalone ops.
- Dequantize before ops that may be fused into transactions.
- Confirm backend quantization support before enabling quantized inference.
- Pin to burn versions where transaction quantization is implemented if you need it.
When it happens
Trigger: Executing a transaction (e.g. `tr_execute` / `execute_async` through the dispatch layer, as in the autodiff transaction op at crates/burn-autodiff/src/ops/transaction.rs:18) where the transaction's `read_qfloats` vec contains at least one quantized tensor.
Common situations: Running quantized inference through the autodiff/dispatch stack where ops get batched into a transaction; mixing quantized and float ops so the quantized tensor ends up in a multi-op transaction; calling backends that route through dispatch macros without quantization support.
Related errors
- todo!("Local transfer of {dtype:?} tensors is not supported
- todo!("Local transfer of quantized tensors is not supported
- Quantization scheme is not valid for dtype {other:?}
- Can't store native sub-byte values
- {other:?} doesn't support native packing
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/d087bae76b9fc8fd.
Report an issue: GitHub.