tracel-ai/burn · error
a two-level scheme should have a per-tensor scale
Error message
a two-level scheme should have a per-tensor scale
What it means
Invariant check in the ndarray backend's `quantize`: the scheme is two-level (requires a global scale), but the per-tensor scale is missing from the quantization parameters, so the `global.expect(...)` panics.
Source
Thrown at crates/burn-ndarray/src/ops/qtensor.rs:156
Some(block_size),
QuantScheme {
mode: QuantMode::Symmetric,
#[cfg(not(feature = "export_tests"))]
value: QuantValue::Q8F | QuantValue::Q8S,
#[cfg(feature = "export_tests")]
value:
QuantValue::Q8F
| QuantValue::Q8S
| QuantValue::Q4F
| QuantValue::Q4S
| QuantValue::Q2F
| QuantValue::Q2S,
store: QuantStore::Native,
..
},
) => {
let global = if global_scale_dtype(scheme).is_some() {
Some(global.expect("a two-level scheme should have a per-tensor scale"))
} else {
None
};
quantize_per_block(
data_f.as_slice().unwrap(),
shape.clone(),
scheme,
block_size,
scales.as_slice(),
global,
)
}
(_, scheme) => unimplemented!("Quantization not supported for scheme {scheme:?}"),
};
let q_bytes = QuantizedBytes {
shape: data.shape.clone(),
bytes: data.into_bytes(),View on GitHub (pinned to d16f7ba2ed)
Solutions
- Supply a per-tensor global scale in QuantizationParametersPrimitive for two-level schemes
- Use a one-level scheme if no global scale is available
- Check how the scheme and qparams were created (e.g., loaded from a checkpoint)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/burn-ndarray/src/ops/qtensor.rs:156 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/7991c824fab36d46.
Report an issue: GitHub.