{"record":{"id":"ef4c64fe358cb9fb","repo":"tracel-ai/burn","slug":"lanczos3-interpolation-backward-is-not-supported-b","errorCode":null,"errorMessage":"lanczos3 interpolation backward is not supported by PyTorch/tch backend","messagePattern":"lanczos3 interpolation backward is not supported by PyTorch/tch backend","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-tch/src/ops/module.rs","lineNumber":481,"sourceCode":"            }\n            InterpolateMode::Bilinear => tch::Tensor::upsample_bilinear2d_backward(\n                &grad.tensor,\n                output_size,\n                input_size,\n                align_corners,\n                None,\n                None,\n            ),\n            InterpolateMode::Bicubic => tch::Tensor::upsample_bicubic2d_backward(\n                &grad.tensor,\n                output_size,\n                input_size,\n                align_corners,\n                None,\n                None,\n            ),\n            InterpolateMode::Lanczos3 => {\n                panic!(\"lanczos3 interpolation backward is not supported by PyTorch/tch backend\")\n            }\n        };\n\n        TchTensor::new(tensor)\n    }\n\n    fn attention(\n        query: TchTensor,\n        key: TchTensor,\n        value: TchTensor,\n        mask: Option<TchTensor>,\n        attn_bias: Option<TchTensor>,\n        options: AttentionModuleOptions,\n    ) -> TchTensor {\n        if attn_bias.is_some() {\n            return attention_fallback::<Self>(query, key, value, mask, attn_bias, options);\n        }\n","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-tch/src/ops/module.rs#L463-L499","documentation":"The burn-tch backend does not implement the backward pass for Lanczos3 interpolation; LibTorch exposes no lanczos upsampling backward, so the backend panics. Forward Lanczos3 is likewise unsupported in tch (module.rs:433). It is an unimplemented-feature panic, hit only during gradient computation.","triggerScenarios":"Backward pass of an interpolate/upsample op configured with InterpolateOptions { mode: InterpolateMode::Lanczos3 } under the tch (LibTorch) backend — i.e. training or grad computation on a resize layer set to lanczos3.","commonSituations":"Reusing a configuration or model definition written for a backend that supports Lanczos3 (e.g. burn-cube/wgpu) and then training it on burn-tch; switching backends for GPU/CPU training without revisiting interpolation settings.","solutions":["Change the interpolate mode to Bilinear or Bicubic, which have supported tch backward kernels","Use InterpolateMode::Nearest if exactness of lanczos filtering is not required","Run the training/backward graph on a backend that implements Lanczos3 (e.g. burn-cube/wgpu) and keep tch for inference only","Validate the interpolation mode against the selected backend at startup and fail early with a clear message"],"exampleFix":"// before\nlet options = InterpolateOptions::new(InterpolateMode::Lanczos3);\n// after\nlet options = InterpolateOptions::new(InterpolateMode::Bicubic);","handlingStrategy":"validation","validationCode":"fn ensure_interpolate_backward_supported(options: &InterpolateOptions) {\n    match options.mode {\n        InterpolateMode::Lanczos3 | InterpolateMode::NearestExact => {\n            panic!(\"mode {:?} has no backward in burn-tch; use Nearest/Bilinear/Bicubic\", options.mode)\n        }\n        _ => {}\n    }\n}","typeGuard":null,"tryCatchPattern":"let result = std::panic::catch_unwind(|| loss.backward());\nif result.is_err() {\n    eprintln!(\"unsupported interpolation backward; rebuild graph with Bicubic\");\n}","preventionTips":["Restrict training configs to modes with tch backward support: Nearest, Bilinear, Bicubic","Keep Lanczos3 configs separate per backend (inference-only on tch)","Test backward passes of resize layers whenever you change backend","Validate InterpolateOptions against the backend before constructing the training loop"],"tags":["rust","burn","tch","unsupported-operation","interpolation","backward-pass"],"backgroundTag":"unsupported-op-backend","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"}