Developer Tools

trunk/7333ec93b6214b18534dc4849cb1440b406b3103: Skip test_conv_error when TORCH_SHOW_CPP_STACKTRACES=1 (#181142)

A subtle env variable clash broke aarch64 CI for PyTorch's conv2d error test...

Deep Dive

PyTorch has merged pull request #181142 to address a subtle CI failure in the `test_conv_error` unit test, which validates that C++ backtraces do not leak into user-visible RuntimeError messages from failed scripted conv2d calls. The test originally asserted that the word "frame" does not appear in the error message. However, when the environment variable `TORCH_SHOW_CPP_STACKTRACES=1` is set, the JIT interpreter's `handleError` function intentionally appends `e.what()`—including the full backtrace—to the message, causing the assertion to fail by design.

The issue was compounded by PyTorch's test runner (`test/run_test.py`), which flips `TORCH_SHOW_CPP_STACKTRACES=1` on test retries. This meant any unrelated flakiness in the test could trigger a retry and then produce a spurious "frame" failure. The problem was partially masked by an `@xfailIf(IS_ARM64)` decorator, which expected the test to fail on ARM64 architectures. However, on newer m8g runners—where the test does not flake—the xfail was "XPASS'ing" (unexpectedly passing), breaking the aarch64 CI job entirely.

Author aorenste fixed this by replacing the platform-specific xfail with an environment-based skip. The test now explicitly checks for `TORCH_SHOW_CPP_STACKTRACES` and skips itself when the variable is set, avoiding the conflict. The now-unused `IS_ARM64` import was removed. The PR, authored with assistance from Claude, resolves issue #177255 and was approved by bobrenjc93.

Key Points
  • Test `test_conv_error` fails when `TORCH_SHOW_CPP_STACKTRACES=1` is set, as backtraces intentionally appear in error messages
  • PyTorch's test runner flips this env var on retry, turning flaky tests into consistent failures
  • Fix replaces ARM64-specific xfail with an env-based skip, resolving CI breaks on m8g runners

Why It Matters

Fixes CI reliability for aarch64 builds, ensuring PyTorch's error handling tests remain valid across architectures.