{"record":{"id":"7991c824fab36d46","repo":"tracel-ai/burn","slug":"a-two-level-scheme-should-have-a-per-tensor-scale","errorCode":null,"errorMessage":"a two-level scheme should have a per-tensor scale","messagePattern":"a two-level scheme should have a per-tensor scale","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-ndarray/src/ops/qtensor.rs","lineNumber":156,"sourceCode":"                Some(block_size),\n                QuantScheme {\n                    mode: QuantMode::Symmetric,\n                    #[cfg(not(feature = \"export_tests\"))]\n                        value: QuantValue::Q8F | QuantValue::Q8S,\n                    #[cfg(feature = \"export_tests\")]\n                        value:\n                        QuantValue::Q8F\n                        | QuantValue::Q8S\n                        | QuantValue::Q4F\n                        | QuantValue::Q4S\n                        | QuantValue::Q2F\n                        | QuantValue::Q2S,\n                    store: QuantStore::Native,\n                    ..\n                },\n            ) => {\n                let global = if global_scale_dtype(scheme).is_some() {\n                    Some(global.expect(\"a two-level scheme should have a per-tensor scale\"))\n                } else {\n                    None\n                };\n                quantize_per_block(\n                    data_f.as_slice().unwrap(),\n                    shape.clone(),\n                    scheme,\n                    block_size,\n                    scales.as_slice(),\n                    global,\n                )\n            }\n            (_, scheme) => unimplemented!(\"Quantization not supported for scheme {scheme:?}\"),\n        };\n\n        let q_bytes = QuantizedBytes {\n            shape: data.shape.clone(),\n            bytes: data.into_bytes(),","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-ndarray/src/ops/qtensor.rs#L138-L174","documentation":"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.","triggerScenarios":"Thrown at crates/burn-ndarray/src/ops/qtensor.rs:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}