PyTorch fixes dynamic adaptive pooling crash
Critical PyTorch bug crashes dynamic adaptive pooling under torch.compile
PyTorch maintainers resolved a critical bug (#185369) in adaptive average pooling that caused compilation failures when using dynamic output sizes with torch.compile(dynamic=True). The issue occurred because the Inductor lowering for aten._adaptive_avg_pool2d computed maximum pooling windows as symbolic Python expressions (SymPy), which crashed during Python control flow evaluation.
The fix introduces two key changes: guarding large-window fallback predicates with sizevars.guard_or_true and protecting small-window unrolled loop extents before use in Python range bounds. Benchmarks show minimal performance impact (28.025µs → 28.722µs median latency) while enabling previously crashing workloads to compile successfully. The fix also includes regression tests verifying eager correctness across multiple output sizes and shape changes.
- Fixed crash in PyTorch's adaptive_avg_pool2d when using torch.compile(dynamic=True) with dynamic output sizes
- Median performance impact: 2.5% slower (28.025µs → 28.722µs) based on microbenchmarks
- New regression tests verify correctness across dynamic input/output sizes and shape changes
Why It Matters
Enables stable compilation of dynamic neural network architectures that previously crashed in PyTorch's inductor backend.