PyTorch PR #184255 fixes convolution backward with dynamic dilation shapes
Dynamic shapes broke convolution backward kernels when dilation wasn't an integer.
PyTorch PR #184255 addresses a bug in convolution backward (bwd) lowering when using dynamic shapes. The issue occurred because Triton bwd templates (added in #178945) substitute DILATION_H/W values directly into generated kernel source via Jinja templating. Under dynamic shapes, these values arrive as sympy symbolic expressions (e.g., s54) rather than concrete integers. When the kernel source is rendered, it references an undefined name, surfacing as a NameError: name 's54' is not defined.
The fix ensures dilation values are guarded to integers before substitution. This is similar to the forward convolution lowering, which already handles this because its template hard-codes dilation=1 in index math and gates the Triton branch on is_ones(dilation). However, the bwd templates parameterize dilation to support arbitrary values, so the same assumption doesn't transfer. The PR resolves eight failing tests in test_conv2d_backward_parametrized_dilation with various configurations of dilation, stride, padding, kernel size, channels, groups, and NHWC format. This fix is essential for production users relying on dynamic shapes with convolution backward passes.
- Bug caused NameError when dynamic shape sympy symbols (e.g., s54) were substituted into Triton kernel source via Jinja
- Fix guards dilation values to integers before kernel generation, preventing undefined symbol references
- Resolves 8 failing tests in DynamicShapesCodegenGPUTests across various convolution backward configurations
Why It Matters
Ensures convolution backward works with dynamic shapes, critical for flexible model deployment and PyTorch's export workflows.