{"record":{"id":"e3c24ad0d5432712","repo":"tracel-ai/burn","slug":"not-implemented-e3c24a","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-tch/src/ops/qtensor.rs","lineNumber":12,"sourceCode":"use burn_backend::{\n    ExecutionError, FloatDType, IntDType, Shape, TensorData,\n    ops::QTensorOps,\n    quantization::{QuantScheme, QuantizationParametersPrimitive},\n    tensor::{Device, FloatTensor, IntTensor, QuantizedTensor},\n};\n\nuse crate::{LibTorch, LibTorchDevice};\n\nimpl QTensorOps<Self> for LibTorch {\n    fn q_from_data(_data: TensorData, _device: &LibTorchDevice) -> QuantizedTensor<Self> {\n        unimplemented!()\n    }\n\n    fn quantize(\n        _tensor: FloatTensor<Self>,\n        _scheme: &QuantScheme,\n        _qparams: QuantizationParametersPrimitive<Self>,\n    ) -> QuantizedTensor<Self> {\n        unimplemented!()\n    }\n\n    fn quantize_dynamic(\n        _tensor: FloatTensor<Self>,\n        _scheme: &QuantScheme,\n    ) -> QuantizedTensor<Self> {\n        unimplemented!()\n    }\n\n    fn dequantize(_tensor: QuantizedTensor<Self>, _dtype: FloatDType) -> FloatTensor<Self> {","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-tch/src/ops/qtensor.rs#L1-L30","documentation":"`q_from_data` in the `QTensorOps` trait implementation for the LibTorch backend is a stub that calls `unimplemented!()`. The tch backend does not implement creating a quantized tensor directly from raw data. Any attempt to build a `QuantizedTensor` from `TensorData` on this backend panics with 'not implemented'.","triggerScenarios":"Calling `QTensorOps::q_from_data` on the burn-tch backend, e.g. loading a pre-quantized checkpoint with `TensorData` and materializing it as a quantized tensor, or any burn API that internally constructs quantized tensors from raw bytes.","commonSituations":"Loading quantized model weights from file into a tch-backed burn model; deserializing a quantized record whose backend differs from the runtime backend; implementing quantization-aware deployment that expects q_from_data support.","solutions":["Use `quantize` (if implemented elsewhere) or create a float tensor from data on tch instead of constructing a quantized tensor directly.","Switch to a backend that implements q_from_data for quantized loading.","Quantize at runtime via `quantize`/`quantize_dynamic` on a supported backend rather than passing pre-quantized data.","Contribute an implementation: build a `at::Tensor` with `torch::quantize_per_tensor` from the data inside burn-tch."],"exampleFix":"// before\nlet q = QTensorOps::q_from_data(data, &device); // panics on tch\n\n// after\nlet f = Tensor::<LibTorch, 4>::from_data(data.convert::<f32>(), &device);\nlet q = QTensorOps::quantize(f.into_primitive(), &scheme, qparams);","handlingStrategy":"validation","validationCode":"// Ensure you never construct quantized tensors on the tch backend:\nfn ensure_not_tch_quantized<B: burn::tensor::backend::Backend>() {\n    // Only call q_from_data on backends advertising QTensorOps support\n    let _ = std::any::TypeId::of::<B>();\n    // Prefer: cfg-gate quantized loading per backend feature\n    #[cfg(feature = \"tch\")]\n    compile_error!(\"q_from_data is unimplemented for tch; use float loading\");\n}","typeGuard":null,"tryCatchPattern":"let q = std::panic::catch_unwind(|| QTensorOps::<B>::q_from_data(data.clone(), &device))\n    .map_err(|_| \"q_from_data unsupported on this backend\")\n    .ok()\n    .unwrap_or_else(|| load_float_and_keep_float(data));","preventionTips":["Treat burn-tch as float-only: never load or build QuantizedTensor values on it.","Serialize models as float records and quantize on a backend that supports it.","Feature-gate quantization code paths behind non-tch backend features.","Add CI tests that construct every tensor type your loader produces on every target backend."],"tags":["rust","burn","libtorch","quantization","unimplemented"],"backgroundTag":"unimplemented-op-panic","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"}