Skip to content

[aot_autograd] Pin the "example_value" dynamic-shape read against a real Dynamo backend graph - #197357

Closed
bobrenjc93 wants to merge 57 commits into
gh/bobrenjc93/1269/basefrom
gh/bobrenjc93/1269/head
Closed

bobrenjc93 wants to merge 57 commits into
gh/bobrenjc93/1269/basefrom
gh/bobrenjc93/1269/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Summary. This is a follow-up to the _graph_has_dynamic_shapes fix that made the probe read "example_value" as well as "val": it adds the end-to-end regression test that fix was missing and tightens the surrounding prose. test_dynamo_dynamic_graph_runs_at_multiple_shapes compiles a module with torch.compile(dynamic=True) through a recording backend, lowers the captured graph with compile_to_python, and runs the artifact at three batch sizes; on the parent of the original fix the artifact specialized to the example size and failed assert_size_stride at every other size. The helper's docstring and the two unit tests now say precisely which graphs carry which key: make_fx writes only "val", the graph Dynamo hands a torch.compile backend carries only "example_value", and Dynamo's export paths stamp "val" as well, so "val" alone does not identify a make_fx graph. The unit test also covers the union in the other direction (a symbolic "val" beside a static "example_value").

The code change is prose only; the behaviour under test is the _graph_has_dynamic_shapes change in #197258 (the second commit of this stack), which is kept byte-identical because it is already approved.

Test Plan

python test/functorch/test_compile_to_python.py -k dynamic_graph_runs_at_multiple_shapes
python test/functorch/test_compile_to_python.py -k graph_has_dynamic_shapes
python test/functorch/test_compile_to_python.py

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Fable 5.1 [email protected]

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 48 Pending

As of commit 0d08436 with merge base d78bbf2 (image):
💚 Looks good so far! There are no failures yet. 💚

🟢 GREEN LIGHT - PR approved to be merged without human review:

  • Runtime behavior
    • The only non-test edit rewrites the _graph_has_dynamic_shapes docstring in torch/_functorch/_aot_autograd/to_standalone_python.py; the union loop over "val"/"example_value" at lines 844-857 is byte-identical
    • The new prose checks out: no node.meta["val"] write exists in torch/_dynamo/output_graph.py, while the export paths do stamp it at torch/_dynamo/eval_frame.py:2034-2069
  • Testing
    • Adds test_dynamo_dynamic_graph_runs_at_multiple_shapes (test/functorch/test_compile_to_python.py:258-283), which lowers a real dynamic=True backend graph and runs the artifact at three sizes
    • test_graph_has_dynamic_shapes_reads_either_key keeps every prior assertion and adds the reverse union case at lines 756-760; no coverage was dropped
    • common_utils.TestCase.run resets Dynamo around each test (torch/testing/_internal/common_utils.py:3840-3845, :4106-4111), so the ((gm, example_inputs),) = recorded unpack is not order-dependent
  • Scope and safety
    • Two files, no public API or signature change, no workflow or CI file touched, no new job in pull.yml/trunk.yml
    • _Pointwise has no parameters or buffers, so the [torch.SymInt, torch.SymInt, torch.Tensor] flat-input shape asserted at lines 273-276 is consistent with the module under test

reason: clean
Reviewed commit: 0d08436

Inference job

🐛 Report a wrong verdict

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

This was referenced Sep 16, 2026
bobrenjc93 added a commit that referenced this pull request Sep 20, 2026
…inst a real Dynamo backend graph

**Summary.** This is a follow-up to the `_graph_has_dynamic_shapes` fix that made the probe read `"example_value"` as well as `"val"`: it adds the end-to-end regression test that fix was missing and tightens the surrounding prose. `test_dynamo_dynamic_graph_runs_at_multiple_shapes` compiles a module with `torch.compile(dynamic=True)` through a recording backend, lowers the captured graph with `compile_to_python`, and runs the artifact at three batch sizes; on the parent of the original fix the artifact specialized to the example size and failed `assert_size_stride` at every other size. The helper's docstring and the two unit tests now say precisely which graphs carry which key: make_fx writes only `"val"`, the graph Dynamo hands a torch.compile backend carries only `"example_value"`, and Dynamo's export paths stamp `"val"` as well, so `"val"` alone does not identify a make_fx graph. The unit test also covers the union in the other direction (a symbolic `"val"` beside a static `"example_value"`).

The code change is prose only; the behaviour under test is the `_graph_has_dynamic_shapes` change in #197258 (the second commit of this stack), which is kept byte-identical because it is already approved.

## Test Plan

```
python test/functorch/test_compile_to_python.py -k dynamic_graph_runs_at_multiple_shapes
python test/functorch/test_compile_to_python.py -k graph_has_dynamic_shapes
python test/functorch/test_compile_to_python.py
```

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Fable 5.1 <[email protected]>

ghstack-source-id: 27d50e8
Pull-Request: #197357
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

/easycla

This was referenced Sep 21, 2026
bobrenjc93 added a commit that referenced this pull request Sep 21, 2026
…inst a real Dynamo backend graph

**Summary.** This is a follow-up to the `_graph_has_dynamic_shapes` fix that made the probe read `"example_value"` as well as `"val"`: it adds the end-to-end regression test that fix was missing and tightens the surrounding prose. `test_dynamo_dynamic_graph_runs_at_multiple_shapes` compiles a module with `torch.compile(dynamic=True)` through a recording backend, lowers the captured graph with `compile_to_python`, and runs the artifact at three batch sizes; on the parent of the original fix the artifact specialized to the example size and failed `assert_size_stride` at every other size. The helper's docstring and the two unit tests now say precisely which graphs carry which key: make_fx writes only `"val"`, the graph Dynamo hands a torch.compile backend carries only `"example_value"`, and Dynamo's export paths stamp `"val"` as well, so `"val"` alone does not identify a make_fx graph. The unit test also covers the union in the other direction (a symbolic `"val"` beside a static `"example_value"`).

The code change is prose only; the behaviour under test is the `_graph_has_dynamic_shapes` change in #197258 (the second commit of this stack), which is kept byte-identical because it is already approved.

## Test Plan

```
python test/functorch/test_compile_to_python.py -k dynamic_graph_runs_at_multiple_shapes
python test/functorch/test_compile_to_python.py -k graph_has_dynamic_shapes
python test/functorch/test_compile_to_python.py
```

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Fable 5.1 <[email protected]>

ghstack-source-id: 93e552a
Pull-Request: #197357
@bobrenjc93 bobrenjc93 closed this Sep 21, 2026
@github-actions
github-actions Bot deleted the gh/bobrenjc93/1269/head branch November 25, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant