Developer Tools

PyTorch fixes symbolic tensor crash in overlap status check

PyTorch's overlap status now returns TooHard for symbolic tensor sizes, fixing Dynamo crashes

Deep Dive

PyTorch's overlap status helper `get_overlap_status` previously checked `TensorImpl::numel()` before considering whether either input had symbolic sizes or strides. When Dynamo recompiles dynamic shapes, FakeTensor uses symbolic metadata, so `gather.out` meta reached `assert_no_overlap(result, self)` and failed while trying to compute a concrete numel for the symbolic input. This caused a crash in the meta path, breaking dynamic shape support for operators like `gather.out`.

The fix, merged as PR #186471 and credited to jansel, returns `MemOverlapStatus::TooHard` as soon as either tensor has symbolic sizes or strides, after preserving the exact same-impl `Full` case. This keeps the existing conservative overlap contract for cases that cannot be precisely classified and avoids entering concrete-only storage range arithmetic for symbolic tensors. The fix is placed at the root overlap-status helper rather than a narrower gather-specific workaround, ensuring other symbolic out/in-place meta paths don't hit the same concrete-only helper. It resolves issue #122773 and was verified by reproducing the original issue, building `torch_python`, installing, and running `test_gather_out_dynamic_shapes` plus `lintrunner`.

Key Points
  • Fix returns `MemOverlapStatus::TooHard` for symbolic tensors instead of computing concrete `numel`
  • Bug caused `gather.out` meta to crash during Dynamo recompilation with dynamic shapes (issue #122773)
  • Root-level fix prevents similar failures in other symbolic out/in-place meta paths

Why It Matters

For PyTorch devs using dynamic shapes, this fix removes a crash in Dynamo compilation, enabling smoother model training and inference.

📬 Get the top 10 AI stories daily