Skip to content

Add smoke test for dynamic indirect indexing codegen (gh-194490) - #195024

Closed
atalman wants to merge 2 commits into
mainfrom
atalman/smoke-test-dynamic-indirect-indexing
Closed

atalman wants to merge 2 commits into
mainfrom
atalman/smoke-test-dynamic-indirect-indexing

Conversation

@atalman

@atalman atalman commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Adds a wheel-level regression check for gh-194490.

What it covers that the existing test doesn't

gh-194490 was a 2.13 Inductor regression — a gather/scatter pair around a loop reduction produced Triton whose epilogue read a temporary defined only inside the reduction body:

tmp41 = tl.where(tmp38, tmp40, tmp19)
                               ^
NameError: tmp19 is not defined

It was found by a user training Dion3 through vllm-project/speculators, not by CI.

The fix (gh-194786) added test_loop_epilogue_indirect_load_scope to test/inductor/test_indexing.py, and that remains the authoritative test — it asserts codegen structure via FileCheck, which this cannot. But it compiles with dynamic=True, whereas the reported failure only appeared on the second compile, once a differing shape triggered automatic dynamic shapes. Those are different paths.

So this check does two trials with different row counts and no dynamic= flag: the first compiles statically, the second generalizes. That's the route users actually hit.

Fidelity to the reproducer

The torch.where over a tensor predicate is kept deliberately — the failure surfaced inside a tl.where, so simplifying it to a plain lerp risks not regenerating the same codegen. I had simplified it initially and put it back for that reason.

Shapes shrink from the reproducer's (6, 4096, 4096) to 2 x k x 4096, but the 4096-wide reduction dim is preserved on purpose so the reduction stays non-persistent and the loop path is actually emitted. Smaller and it becomes a persistent reduction and stops covering the bug.

Blast radius

Runs under the existing torch-compile gate (already skipped on Python 3.15+ and non-Linux/macOS), and returns early without CUDA — so CPU and Windows wheels are unaffected. Roughly two torch.compile invocations on ~128K-element tensors.

Tolerances are loose (rtol/atol 1e-4). The assertion that matters is that codegen succeeds at all; a 4096-wide reduction over bf16 inputs differs between eager and Inductor by reduction order alone, and a wheel check must not fail on that.

Caveats, stated plainly

I could not run this — no GPU on the machine I authored it on. Syntax and wiring are verified; the codegen behaviour is not. It needs one real run on a CUDA wheel before it's trusted. If it turns out the reduction goes persistent at these shapes, the test passes while covering nothing, and the reduction dim needs raising.

Coverage is heuristic-dependent. If Inductor's persistent-reduction threshold changes, this silently stops exercising the bug rather than failing. That's noted in the docstring with a pointer to the inductor test, which has no such dependency.

On placement: my own view is that compiler-codegen regressions belong in test/inductor/, not in the release smoke test — the smoke test validates that the binary works, and this adds a GPU-only, Triton-dependent, config-sensitive path to every wheel check. Adding it here anyway at @atalman's direction, since the escape happened on a release binary and the release gate is where he wants the net. Recording the tradeoff so the next person editing this file knows why it's here.


Filed with the help of Claude Code.

gh-194490 was a 2.13 Inductor regression: a gather/scatter pair around a loop
reduction produced Triton whose epilogue read a temporary defined only inside
the reduction body, failing with `NameError: tmp19 is not defined`. It was found
by a user training Dion3 through vllm-project/speculators, not by CI.

The fix (gh-194786) added test_loop_epilogue_indirect_load_scope to
test/inductor/test_indexing.py, which remains the authoritative test. That test
compiles with `dynamic=True`, though, while the reported failure only appeared
on the *second* compile, once a differing shape triggered automatic dynamic
shapes. This check covers that path: two trials with different row counts and no
`dynamic=` flag, so the first compiles statically and the second generalizes.

Kept faithful to the reproducer where it matters. The `torch.where` over a
tensor predicate is retained because the failure surfaced inside a `tl.where`
in the epilogue; simplifying it to a plain lerp may not regenerate the same
codegen. Shapes are shrunk from the reproducer's (6, 4096, 4096) to 2 x k x 4096,
but the 4096-wide reduction dim is preserved deliberately so the reduction stays
non-persistent and the loop path is actually emitted.

Runs under the existing torch-compile gate (skipped on Python 3.15+ and on
non-Linux/macOS targets) and additionally returns early without CUDA, so CPU and
Windows wheels are unaffected.

Tolerances are loose (rtol/atol 1e-4). The assertion that matters is that codegen
succeeds at all; a 4096-wide reduction over bf16 inputs differs between eager and
Inductor by reduction order alone, and a wheel check must not fail on that.

Known limitation: coverage depends on the reduction staying non-persistent. If
Inductor's persistent-reduction heuristic changes, this silently stops exercising
the bug rather than failing -- noted in the docstring, with a pointer to the
inductor test that does not have that dependency.
@atalman
atalman requested a review from a team as a code owner August 27, 2026 16:35
@pytorch-bot

pytorch-bot Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195024

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 11 Pending

As of commit b53ef47 with merge base 14fb825 (image):
💚 Looks good so far! There are no failures yet. 💚

GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

This adds `smoke_test_compile_dynamic_indirect_indexing()` to the release
wheel-validation gate at .ci/pytorch/smoke_test/smoke_test.py:532, called from
smoke_test_cuda at line 365, but nothing in pytorch's PR CI ever executes the
new body: check_binary.sh:270 only invokes `test_linalg`,
binary_linux_test.sh:92-94 pass `--torch-compile-check disabled`, and the macOS
path (_binary-test-macos.yml:87) returns early at the
`torch.cuda.is_available()` guard. The PR body itself states the author could
not run it ("no GPU on the machine I authored it on ... It needs one real run on
a CUDA wheel before it's trusted"), so an unexecuted, Triton-codegen-dependent
check would first run in nightly/release wheel validation, where a failure
blocks the release gate. The body also records an unresolved placement
disagreement (author prefers test/inductor/, added "at @​atalman's direction")
with no maintainer confirmation in the comments, and the docstring concedes the
check silently stops covering gh-194490 if Inductor's persistent-reduction
heuristic shifts — all of which warrant a human look.

reason: build_or_ci_risk
Reviewed commit: 18564a6 (NOT the current head b53ef47)

Inference job

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Aug 27, 2026
@atalman
atalman requested review from eellison and karthickai August 27, 2026 16:46
- Removed `assert len(actual) == len(expected)` -- RUFF S101 flags bare
  asserts, and it was defensive noise over two fixed-length tuples.
- Collapsed the `torch.stack(...)` call onto one line to satisfy PYFMT.
- Cut the commentary down to the docstring plus two one-liners.
@atalman atalman added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Aug 27, 2026
@atalman

atalman commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "lint is green and infra failures are not related"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Aug 31, 2026
test-infra's Release Binaries Validations checks out smoke_test.py from pytorch main but installs the published stable wheel. The regression check added in #195024 covers gh-194490, whose fix (#194786) landed after the 2.13 branch cut, so it reds all six linux CUDA 12.6 legs against the immutable 2.13.0 artifact with NameError('tmp19 is not defined').

Gate on the first release series containing the fix: 2.14, which has it via cherry-pick #194833. Reverting #195024 was the alternative, but it drops nightly coverage and leaves the next regression test added here to hit the same trap.

Test Plan:

2.13.0 skips; 2.14.0, main and nightly run.

```
python -c "
from torch.torch_version import TorchVersion
for v in ['2.13.0+cu126','2.14.0+cu130','2.15.0a0+gitabc','2.15.0.dev20260829+cu126']:
    print(v, TorchVersion(v) < (2, 14))
"
lintrunner -a --paths-cmd 'echo .ci/pytorch/smoke_test/smoke_test.py'
```

Authored with assistance from Claude Code.
Pull Request resolved: #195306
Approved by: https://github.com/pytorchgreenlight, https://github.com/atalman
orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
… (pytorch#195024)

Adds a wheel-level regression check for pytorchgh-194490.

## What it covers that the existing test doesn't

pytorchgh-194490 was a 2.13 Inductor regression — a gather/scatter pair around a loop reduction produced Triton whose epilogue read a temporary defined only inside the reduction body:

```
tmp41 = tl.where(tmp38, tmp40, tmp19)
                               ^
NameError: tmp19 is not defined
```

It was found by a user training Dion3 through vllm-project/speculators, not by CI.

The fix (pytorchgh-194786) added `test_loop_epilogue_indirect_load_scope` to `test/inductor/test_indexing.py`, and **that remains the authoritative test** — it asserts codegen structure via FileCheck, which this cannot. But it compiles with `dynamic=True`, whereas the reported failure only appeared on the **second** compile, once a differing shape triggered *automatic* dynamic shapes. Those are different paths.

So this check does two trials with different row counts and no `dynamic=` flag: the first compiles statically, the second generalizes. That's the route users actually hit.

## Fidelity to the reproducer

The `torch.where` over a tensor predicate is kept deliberately — the failure surfaced *inside* a `tl.where`, so simplifying it to a plain lerp risks not regenerating the same codegen. I had simplified it initially and put it back for that reason.

Shapes shrink from the reproducer's `(6, 4096, 4096)` to `2 x k x 4096`, but the **4096-wide reduction dim is preserved on purpose** so the reduction stays non-persistent and the loop path is actually emitted. Smaller and it becomes a persistent reduction and stops covering the bug.

## Blast radius

Runs under the existing torch-compile gate (already skipped on Python 3.15+ and non-Linux/macOS), and returns early without CUDA — so CPU and Windows wheels are unaffected. Roughly two `torch.compile` invocations on ~128K-element tensors.

Tolerances are loose (`rtol/atol 1e-4`). The assertion that matters is that codegen succeeds at all; a 4096-wide reduction over bf16 inputs differs between eager and Inductor by reduction order alone, and a wheel check must not fail on that.

## Caveats, stated plainly

**I could not run this** — no GPU on the machine I authored it on. Syntax and wiring are verified; the codegen behaviour is not. It needs one real run on a CUDA wheel before it's trusted. If it turns out the reduction goes persistent at these shapes, the test passes while covering nothing, and the reduction dim needs raising.

**Coverage is heuristic-dependent.** If Inductor's persistent-reduction threshold changes, this silently stops exercising the bug rather than failing. That's noted in the docstring with a pointer to the inductor test, which has no such dependency.

**On placement:** my own view is that compiler-codegen regressions belong in `test/inductor/`, not in the release smoke test — the smoke test validates that the binary works, and this adds a GPU-only, Triton-dependent, config-sensitive path to every wheel check. Adding it here anyway at @atalman's direction, since the escape happened on a release binary and the release gate is where he wants the net. Recording the tradeoff so the next person editing this file knows why it's here.

---

Filed with the help of Claude Code.
Pull Request resolved: pytorch#195024
Approved by: https://github.com/eellison, https://github.com/karthickai
orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
…ch#195306)

test-infra's Release Binaries Validations checks out smoke_test.py from pytorch main but installs the published stable wheel. The regression check added in pytorch#195024 covers pytorchgh-194490, whose fix (pytorch#194786) landed after the 2.13 branch cut, so it reds all six linux CUDA 12.6 legs against the immutable 2.13.0 artifact with NameError('tmp19 is not defined').

Gate on the first release series containing the fix: 2.14, which has it via cherry-pick pytorch#194833. Reverting pytorch#195024 was the alternative, but it drops nightly coverage and leaves the next regression test added here to hit the same trap.

Test Plan:

2.13.0 skips; 2.14.0, main and nightly run.

```
python -c "
from torch.torch_version import TorchVersion
for v in ['2.13.0+cu126','2.14.0+cu130','2.15.0a0+gitabc','2.15.0.dev20260829+cu126']:
    print(v, TorchVersion(v) < (2, 14))
"
lintrunner -a --paths-cmd 'echo .ci/pytorch/smoke_test/smoke_test.py'
```

Authored with assistance from Claude Code.
Pull Request resolved: pytorch#195306
Approved by: https://github.com/pytorchgreenlight, https://github.com/atalman
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
… (pytorch#195024)

Adds a wheel-level regression check for pytorchgh-194490.

## What it covers that the existing test doesn't

pytorchgh-194490 was a 2.13 Inductor regression — a gather/scatter pair around a loop reduction produced Triton whose epilogue read a temporary defined only inside the reduction body:

```
tmp41 = tl.where(tmp38, tmp40, tmp19)
                               ^
NameError: tmp19 is not defined
```

It was found by a user training Dion3 through vllm-project/speculators, not by CI.

The fix (pytorchgh-194786) added `test_loop_epilogue_indirect_load_scope` to `test/inductor/test_indexing.py`, and **that remains the authoritative test** — it asserts codegen structure via FileCheck, which this cannot. But it compiles with `dynamic=True`, whereas the reported failure only appeared on the **second** compile, once a differing shape triggered *automatic* dynamic shapes. Those are different paths.

So this check does two trials with different row counts and no `dynamic=` flag: the first compiles statically, the second generalizes. That's the route users actually hit.

## Fidelity to the reproducer

The `torch.where` over a tensor predicate is kept deliberately — the failure surfaced *inside* a `tl.where`, so simplifying it to a plain lerp risks not regenerating the same codegen. I had simplified it initially and put it back for that reason.

Shapes shrink from the reproducer's `(6, 4096, 4096)` to `2 x k x 4096`, but the **4096-wide reduction dim is preserved on purpose** so the reduction stays non-persistent and the loop path is actually emitted. Smaller and it becomes a persistent reduction and stops covering the bug.

## Blast radius

Runs under the existing torch-compile gate (already skipped on Python 3.15+ and non-Linux/macOS), and returns early without CUDA — so CPU and Windows wheels are unaffected. Roughly two `torch.compile` invocations on ~128K-element tensors.

Tolerances are loose (`rtol/atol 1e-4`). The assertion that matters is that codegen succeeds at all; a 4096-wide reduction over bf16 inputs differs between eager and Inductor by reduction order alone, and a wheel check must not fail on that.

## Caveats, stated plainly

**I could not run this** — no GPU on the machine I authored it on. Syntax and wiring are verified; the codegen behaviour is not. It needs one real run on a CUDA wheel before it's trusted. If it turns out the reduction goes persistent at these shapes, the test passes while covering nothing, and the reduction dim needs raising.

**Coverage is heuristic-dependent.** If Inductor's persistent-reduction threshold changes, this silently stops exercising the bug rather than failing. That's noted in the docstring with a pointer to the inductor test, which has no such dependency.

**On placement:** my own view is that compiler-codegen regressions belong in `test/inductor/`, not in the release smoke test — the smoke test validates that the binary works, and this adds a GPU-only, Triton-dependent, config-sensitive path to every wheel check. Adding it here anyway at @atalman's direction, since the escape happened on a release binary and the release gate is where he wants the net. Recording the tradeoff so the next person editing this file knows why it's here.

---

Filed with the help of Claude Code.
Pull Request resolved: pytorch#195024
Approved by: https://github.com/eellison, https://github.com/karthickai
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
…ch#195306)

test-infra's Release Binaries Validations checks out smoke_test.py from pytorch main but installs the published stable wheel. The regression check added in pytorch#195024 covers pytorchgh-194490, whose fix (pytorch#194786) landed after the 2.13 branch cut, so it reds all six linux CUDA 12.6 legs against the immutable 2.13.0 artifact with NameError('tmp19 is not defined').

Gate on the first release series containing the fix: 2.14, which has it via cherry-pick pytorch#194833. Reverting pytorch#195024 was the alternative, but it drops nightly coverage and leaves the next regression test added here to hit the same trap.

Test Plan:

2.13.0 skips; 2.14.0, main and nightly run.

```
python -c "
from torch.torch_version import TorchVersion
for v in ['2.13.0+cu126','2.14.0+cu130','2.15.0a0+gitabc','2.15.0.dev20260829+cu126']:
    print(v, TorchVersion(v) < (2, 14))
"
lintrunner -a --paths-cmd 'echo .ci/pytorch/smoke_test/smoke_test.py'
```

Authored with assistance from Claude Code.
Pull Request resolved: pytorch#195306
Approved by: https://github.com/pytorchgreenlight, https://github.com/atalman
@github-actions
github-actions Bot deleted the atalman/smoke-test-dynamic-indirect-indexing branch November 10, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries Trigger all binary build and upload jobs on the PR Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants