{"record":{"id":"92345fd30c92b359","repo":"tracel-ai/burn","slug":"split-reshape-of-nd-block-quantized-tensor-is-not","errorCode":null,"errorMessage":"Split reshape of ND block-quantized tensor is not yet supported.","messagePattern":"Split reshape of ND block-quantized tensor is not yet supported\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl/src/ops/base.rs","lineNumber":392,"sourceCode":"        match analysis_values {\n            ReshapeAnalysis::IsContiguous => {\n                if let Some(block_size) = scheme.block_size()\n                    && block_size.len() > 1\n                    && !is_unsqueeze\n                {\n                    // General reshape (e.g. [32, 4] -> [16, 8]): only valid if\n                    // reshaped dimension is aligned with the block boundaries.\n                    unimplemented!(\"Reshape of ND block-quantized tensor is not yet supported.\");\n                }\n            }\n            ReshapeAnalysis::Broadcasted => {} // only preprends unit dims\n            ReshapeAnalysis::Split => {\n                if let Some(block_size) = scheme.block_size()\n                    && block_size.len() > 1\n                {\n                    // Split reshape (e.g. [32, 4] -> [32, 2, 2]): only valid if\n                    // reshaped dimension is aligned with the block boundaries.\n                    unimplemented!(\n                        \"Split reshape of ND block-quantized tensor is not yet supported.\"\n                    );\n                }\n            }\n            other => unreachable!(\"Reshape analysis {other:?} should not update strides.\"),\n        }\n    }\n\n    let shape_last = *shape.last().unwrap();\n\n    // The per-tensor scale is a scalar in its own region, so only the block grid moves.\n    let shape_scales = match scheme.block_size() {\n        None => scales.meta.shape().clone(), // always [1], invariant under reshape\n        Some(block_size) if block_size.len() == 1 && shape_last < (block_size[0] as usize) => {\n            // If the new last dimension is smaller than the block size,\n            // it means a single block now spans across multiple rows.\n            if scales.meta.shape().num_elements() > 1 {\n                unimplemented!(\"Reshape would split a block across multiple rows.\");","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl/src/ops/base.rs#L374-L410","documentation":"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.","triggerScenarios":"Calling q_reshape where the reshape analysis classifies as Split and the quantization scheme has block_size with more than one dimension (ND blocks).","commonSituations":"Splitting batched/feature dims of ND-block-quantized activations; reshaping to add heads/groups dimension in attention code on quantized tensors.","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"],"exampleFix":"// before\nlet heads = x.reshape([b, h, s, d]); // split of ND block-quant -> panic\n// after\nlet heads = x.dequantize().reshape([b, h, s, d]);","handlingStrategy":"validation","validationCode":"fn split_reshape_safe(scheme: &QuantScheme, analysis: ReshapeAnalysis) -> bool {\n    !(analysis == ReshapeAnalysis::Split && scheme.block_size().map_or(false, |b| b.len() > 1))\n}","typeGuard":"fn supports_split(scheme: &QuantScheme) -> bool {\n    scheme.block_size().map_or(true, |b| b.len() <= 1)\n}","tryCatchPattern":"// Guard before split reshape:\nif supports_split(&scheme) { x.reshape(split_shape) } else { x.dequantize().reshape(split_shape) }","preventionTips":["Do not split dims covered by ND quant blocks","Dequantize before adding dimensions (heads, groups)","Use 1D blocks where split reshapes are needed"],"tags":["quantization","reshape","block-quantization","unimplemented"],"backgroundTag":"unsupported-quantized-reshape","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"}