tracel-ai/burn · error
Split reshape of ND block-quantized tensor is not yet suppor
Error message
Split reshape of ND block-quantized tensor is not yet supported.
What it means
A Split reshape ([32,4] -> [32,2,2]) of an ND block-quantized tensor would split data inside existing quantization blocks, invalidating the scale layout. This case is explicitly not implemented and panics.
Source
Thrown at crates/burn-cubecl/src/ops/base.rs:392
match analysis_values {
ReshapeAnalysis::IsContiguous => {
if let Some(block_size) = scheme.block_size()
&& block_size.len() > 1
&& !is_unsqueeze
{
// General reshape (e.g. [32, 4] -> [16, 8]): only valid if
// reshaped dimension is aligned with the block boundaries.
unimplemented!("Reshape of ND block-quantized tensor is not yet supported.");
}
}
ReshapeAnalysis::Broadcasted => {} // only preprends unit dims
ReshapeAnalysis::Split => {
if let Some(block_size) = scheme.block_size()
&& block_size.len() > 1
{
// Split reshape (e.g. [32, 4] -> [32, 2, 2]): only valid if
// reshaped dimension is aligned with the block boundaries.
unimplemented!(
"Split reshape of ND block-quantized tensor is not yet supported."
);
}
}
other => unreachable!("Reshape analysis {other:?} should not update strides."),
}
}
let shape_last = *shape.last().unwrap();
// The per-tensor scale is a scalar in its own region, so only the block grid moves.
let shape_scales = match scheme.block_size() {
None => scales.meta.shape().clone(), // always [1], invariant under reshape
Some(block_size) if block_size.len() == 1 && shape_last < (block_size[0] as usize) => {
// If the new last dimension is smaller than the block size,
// it means a single block now spans across multiple rows.
if scales.meta.shape().num_elements() > 1 {
unimplemented!("Reshape would split a block across multiple rows.");View on GitHub (pinned to d16f7ba2ed)
Solutions
- Dequantize before splitting, then re-quantize the new shape
- Avoid splitting dimensions covered by ND quantization blocks
- Use 1D block sizes so split reshapes (aligned) are permitted
- Upgrade burn and retest
Example fix
// before let heads = x.reshape([b, h, s, d]); // split of ND block-quant -> panic // after let heads = x.dequantize().reshape([b, h, s, d]);
Defensive patterns
Strategy: validation
Validate before calling
fn split_reshape_safe(scheme: &QuantScheme, analysis: ReshapeAnalysis) -> bool {
!(analysis == ReshapeAnalysis::Split && scheme.block_size().map_or(false, |b| b.len() > 1))
} Type guard
fn supports_split(scheme: &QuantScheme) -> bool {
scheme.block_size().map_or(true, |b| b.len() <= 1)
} Try / catch
// Guard before split reshape:
if supports_split(&scheme) { x.reshape(split_shape) } else { x.dequantize().reshape(split_shape) } Prevention
- Do not split dims covered by ND quant blocks
- Dequantize before adding dimensions (heads, groups)
- Use 1D blocks where split reshapes are needed
When it happens
Trigger: Calling q_reshape where the reshape analysis classifies as Split and the quantization scheme has block_size with more than one dimension (ND blocks).
Common situations: Splitting batched/feature dims of ND-block-quantized activations; reshaping to add heads/groups dimension in attention code on quantized tensors.
Related errors
- Reshape of ND block-quantized tensor is not yet supported.
- Reshape would split a block across multiple rows.
- Cannot reshape a block-quantized tensor when the reshape req
- Cannot reshape packed tensor: inner dimension {} is not alig
- ctc_loss_backward: 2 * max_target_len + 1 = {} exceeds the k
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/92345fd30c92b359.
Report an issue: GitHub.