Skip to content

Fix training enablement in AOTAutograd#95975

Closed
ezyang wants to merge 3 commits intogh/ezyang/1872/basefrom
gh/ezyang/1872/head
Closed

Fix training enablement in AOTAutograd#95975
ezyang wants to merge 3 commits intogh/ezyang/1872/basefrom
gh/ezyang/1872/head

Conversation

@ezyang
Copy link
Copy Markdown
Contributor

@ezyang ezyang commented Mar 3, 2023

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Mar 3, 2023

🔗 Helpful Links

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

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

✅ No Failures

As of commit cfaa39b:
💚 Looks good so far! There are no failures yet. 💚

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

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

[ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyangmeta.com>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Mar 3, 2023
Signed-off-by: Edward Z. Yang <ezyangmeta.com>

ghstack-source-id: 857f0c9
Pull Request resolved: #95975
aot_id: int
keep_inference_input_mutations: bool
# If None, defer to config
_dynamic_shapes: Optional[bool] = None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to just kill the functorch config completely, and base our decision completely off of whether the input fake tensors have a shape env?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same question here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to do this in a follow up, there is just annoying test suite fixing that would need to happen

dynamic_shapes = False
for x in full_args:
if isinstance(x, FakeTensor):
dynamic_shapes = x.fake_mode.shape_env is not None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert that this is all or nothing? (that either all fake tensors share the same shape env, or none of them have one?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proximal reason for this change is, the way I decided to configure if you do AOTAutograd with dynamic shapes or not was add an entry to AOTConfig. This means that anywhere I create an AOTConfig, I need to fill in this field, if I want dynamic shapes that are not controlled by the functorch config.

In particular, when aot_module_simplified is invoked, the way we tell if we were running with dynamo dynamic shapes (because we don't have access to torch._dynamo.config, due to layering problems) is by inspecting the input arguments and checking if any of them are fake. This logic is reduxed with create_aot_dispatcher_function which also does a similar sniffing (and a further refactor would be to extract the ShapeEnv and then eliminate the equivalent logic in create_aot_dispatcher_function).

If I didn't do this change, then when we compile backwards (where we pass in all real tensors), we would not compile with dynamic shapes. I do think this part is still a little creaky though.

@ezyang ezyang added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 3, 2023
@ezyang
Copy link
Copy Markdown
Contributor Author

ezyang commented Mar 5, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 5, 2023
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch/pytorch#95975
Approved by: https://github.com/ngimel, https://github.com/voznesenskym
ezyang added a commit that referenced this pull request Mar 6, 2023
As requested in
#95975 (comment)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Mar 6, 2023
As requested in
#95975 (comment)

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

ghstack-source-id: ea80ccb
Pull Request resolved: #96102
pytorchmergebot pushed a commit that referenced this pull request Mar 6, 2023
As requested in
#95975 (comment)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: #96102
Approved by: https://github.com/Skylion007
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 12, 2023
As requested in
pytorch/pytorch#95975 (comment)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch/pytorch#96102
Approved by: https://github.com/Skylion007
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 12, 2023
As requested in
pytorch/pytorch#95975 (comment)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch/pytorch#96102
Approved by: https://github.com/Skylion007
ydwu4 added a commit to ydwu4/pytorch that referenced this pull request Mar 13, 2023
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#95975
Approved by: https://github.com/ngimel, https://github.com/voznesenskym
ydwu4 added a commit to ydwu4/pytorch that referenced this pull request Mar 13, 2023
As requested in
pytorch#95975 (comment)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: pytorch#96102
Approved by: https://github.com/Skylion007
@ezyang ezyang added this to the 2.0.1 milestone Mar 20, 2023
@ezyang ezyang removed this from the 2.0.1 milestone Apr 21, 2023
@facebook-github-bot facebook-github-bot deleted the gh/ezyang/1872/head branch June 8, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: AO frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants