-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[export] simplify automatic dynamic shapes processing #136591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/136591
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New FailuresAs of commit db71c3d with merge base c878ea2 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
Summary: Pull Request resolved: #136591 Differential Revision: D63358628
4016546 to
9201fda
Compare
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
9201fda to
e4bbb73
Compare
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
avikchaudhuri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine as long as tests pass, but I'm not entirely sure what the effect of the change is in this PR, could you write a summary please?
What I'd like is the some kind of invariant to hold around STATIC, constant dims, DYNAMIC, AUTO, and None here. Looks like we're not transforming specs any more, but using a marking scheme to get what we want. Who consumes these markings, is it just dynamo, or is it make_fx as well?
torch/_export/non_strict_utils.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, trying to understand...so you start off with mostly STATIC here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, for now everything here can be static except those marked with Dim.AUTO. This doesn't interfere with the old Dim() specs.
torch/_export/non_strict_utils.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does AUTO come in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DimHints now get handled in _process_dynamic_shapes
torch/export/_trace.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this buy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing functionality wise, we just don't have to maintain this specs inverting which is already pretty confusing to me today
torch/export/dynamic_shapes.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, so we'll only allow specs to dictate which ones are marked? Should we warn if any of these were set, asking to use specs instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah added a comment in the last PR description line
torch/export/dynamic_shapes.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else what? Maybe handle that explicitly with a pass and then assert / give a useful error if anything unexpected happens?
Ah sorry, just realized the diff description didn't update the PR description too |
|
@pianpwk has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
22a8917 to
430edf7
Compare
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
430edf7 to
f5a6ac6
Compare
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
1 similar comment
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
Summary: Removing `_transform_shapes_for_default_dynamic` and `assume_static_by_default=False` as added in #133620. This reverts back to `assume_static_by_default=True` with the use of dynamo decorators (e.g. `maybe_mark_dynamic, mark_static`, instead) for handling Dim.AUTO & Dim.STATIC instead. This is easier to maintain, as it doesn't requiring reasoning about "inverting" the dynamic_shapes specs, and also opens up usage of other decorators (`mark_dynamic, mark_unbacked`). On the user side this change has no effect, but internally this means dynamic behavior is determined only by the `dynamic_shapes` specs (ignoring user-side input decorators following #135536), but transferring this information for _DimHints via decorators, for Dynamo/non-strict to create symbolic_contexts accordingly, e.g. https://github.com/pytorch/pytorch/blob/7c6d543a5b3d65d8f49420e60cda150faaa5b8a0/torch/_dynamo/variables/builder.py#L2646-L2666 One caveat is we don't raise errors for dynamic decorators on the user side, since we don't know if they're from user markings, or from re-exporting with inputs we've previously marked. Pull Request resolved: #136591 Differential Revision: D63358628 Pulled By: pianpwk
f5a6ac6 to
362cb31
Compare
Summary: Removing `_transform_shapes_for_default_dynamic` and `assume_static_by_default=False` as added in #133620. This reverts back to `assume_static_by_default=True` with the use of dynamo decorators (e.g. `maybe_mark_dynamic, mark_static`, instead) for handling Dim.AUTO & Dim.STATIC instead. This is easier to maintain, as it doesn't requiring reasoning about "inverting" the dynamic_shapes specs, and also opens up usage of other decorators (`mark_dynamic, mark_unbacked`). On the user side this change has no effect, but internally this means dynamic behavior is determined only by the `dynamic_shapes` specs (ignoring user-side input decorators following #135536), but transferring this information for _DimHints via decorators, for Dynamo/non-strict to create symbolic_contexts accordingly, e.g. https://github.com/pytorch/pytorch/blob/7c6d543a5b3d65d8f49420e60cda150faaa5b8a0/torch/_dynamo/variables/builder.py#L2646-L2666 One caveat is we don't raise errors for dynamic decorators on the user side, since we don't know if they're from user markings, or from re-exporting with inputs we've previously marked. Differential Revision: D63358628 Pulled By: pianpwk
362cb31 to
db71c3d
Compare
|
This pull request was exported from Phabricator. Differential Revision: D63358628 |
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchbot merge -f "unrelated lint" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary: sam_fast changes from timeout to fail_to_run after #136591, which "regressed" in a good way. Update the expected result file and continue investigating. [ghstack-poisoned]
Summary: sam_fast changes from timeout to fail_to_run after #136591, which "regressed" in a good way. Update the expected result file and continue investigating. Pull Request resolved: #136996 Approved by: https://github.com/ezyang
@pianpwk , as a retrospect, the |
Summary: sam_fast changes from timeout to fail_to_run after pytorch#136591, which "regressed" in a good way. Update the expected result file and continue investigating. Pull Request resolved: pytorch#136996 Approved by: https://github.com/ezyang
@desertfire Ah sorry. I should've realized the test no longer timing out was related |
Removing
_transform_shapes_for_default_dynamicandassume_static_by_default=Falseas added in #133620.This reverts back to
assume_static_by_default=Truewith the use of dynamo decorators (e.g.maybe_mark_dynamic, mark_static, instead) for handling Dim.AUTO & Dim.STATIC instead. This is easier to maintain, as it doesn't requiring reasoning about "inverting" the dynamic_shapes specs, and also opens up usage of other decorators (mark_dynamic, mark_unbacked).On the user side this change has no effect, but internally this means dynamic behavior is determined only by the
dynamic_shapesspecs (ignoring user-side input decorators following #135536), but transferring this information for _DimHints via decorators, for Dynamo/non-strict to create symbolic_contexts accordingly, e.g.pytorch/torch/_dynamo/variables/builder.py
Lines 2646 to 2666 in 7c6d543
One caveat is we don't raise errors for dynamic decorators on the user side, since we don't know if they're from user markings, or from re-exporting with inputs we've previously marked.
Differential Revision: D63358628