{"record":{"id":"02bb77c02fb3da31","repo":"tracel-ai/burn","slug":"interpolate-backward-unsupported-mode-dtyp","errorCode":null,"errorMessage":"interpolate_backward: unsupported mode {:?} / dtype {:?}","messagePattern":"interpolate_backward: unsupported mode (.+?) / dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/module.rs","lineNumber":714,"sourceCode":"            }\n            (InterpolateMode::Bicubic, DType::F16) => {\n                interpolate::interpolate_bicubic_backward_f16(\n                    x,\n                    grad,\n                    output_size,\n                    options.align_corners,\n                )\n            }\n            (InterpolateMode::Bicubic, DType::BF16) => {\n                interpolate::interpolate_bicubic_backward_bf16(\n                    x,\n                    grad,\n                    output_size,\n                    options.align_corners,\n                )\n            }\n            (mode, dtype) => {\n                panic!(\n                    \"interpolate_backward: unsupported mode {:?} / dtype {:?}\",\n                    mode, dtype\n                )\n            }\n        }\n    }\n\n    fn attention(\n        query: FloatTensor<Flex>,\n        key: FloatTensor<Flex>,\n        value: FloatTensor<Flex>,\n        mask: Option<BoolTensor<Flex>>,\n        attn_bias: Option<FloatTensor<Flex>>,\n        options: AttentionModuleOptions,\n    ) -> FloatTensor<Flex> {\n        crate::ops::attention::attention(query, key, value, mask, attn_bias, options)\n    }\n","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/module.rs#L696-L732","documentation":"interpolate_backward mirrors the forward interpolate op: it dispatches on (InterpolateMode, x.dtype()) and implements all four modes for F32/F64/F16/BF16 only. Any other dtype reaches the catch-all arm, which panics reporting the unsupported mode/dtype pair during the gradient computation.","triggerScenarios":"Backpropagating through interpolate/upsample on the Flex backend when the saved input tensor x has a dtype other than F32/F64/F16/BF16, for any InterpolateMode.","commonSituations":"Training vision models where non-float tensors entered an upsampling layer; u8/int image data flowing into training; precision mismatch between forward and saved tensors after checkpoint load or backend switch.","solutions":["Cast the input/grad to a supported float dtype (e.g. .cast(DType::F32)) before the backward call.","Fix the forward pass so only float tensors reach interpolate, guaranteeing float saved state.","Add the missing (mode, dtype) match arm calling interpolate_<mode>_backward_<dtype> in crates/burn-flex/src/ops/module.rs."],"exampleFix":"// before\nlet dx = interpolate_backward::<F32>(x_u8, grad, Bilinear); // panics\n// after\nlet dx = interpolate_backward::<F32>(x_u8.cast(DType::F32), grad, Bilinear);","handlingStrategy":"validation","validationCode":"assert!(matches!(x.dtype(), burn::tensor::DType::F32 | burn::tensor::DType::F64 | burn::tensor::DType::F16 | burn::tensor::DType::BF16), \"interpolate_backward needs a float tensor, got {:?} (mode {:?})\", x.dtype(), options.mode);","typeGuard":"fn is_float_dtype(d: burn::tensor::DType) -> bool {\n    matches!(d, burn::tensor::DType::F32 | burn::tensor::DType::F64 | burn::tensor::DType::F16 | burn::tensor::DType::BF16)\n}","tryCatchPattern":"// Cast before backward through interpolate:\nlet x = if is_float_dtype(x.dtype()) { x } else { x.cast(burn::tensor::DType::F32) };","preventionTips":["Keep interpolate inputs float so autograd-saved tensors stay float for backward.","Test each used InterpolateMode with a forward/backward pass after backend changes.","Avoid quantized/integer tensors in upsampling paths of trainable models."],"tags":["rust","dtype","panic","interpolate","backward","burn"],"backgroundTag":"unsupported-dtype","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"}