-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[export] Update swap's forward function #137102
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
Downstream APS code was failing to run the previously swapped module because of some fx.GraphModule forward function weirdness. So to fix this, I just attached a custom forward function which matches the unflattened module's forward function. Differential Revision: [D63683422](https://our.internmc.facebook.com/intern/diff/D63683422/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/137102
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1338d9d with merge base f2d174c ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
This pull request was exported from Phabricator. Differential Revision: D63683422 |
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.
Please commit the suggested changes from pytorch's linter.
torch/export/unflatten.py
Outdated
| flat_args, in_spec = pytree.tree_flatten( | ||
| (args, reordered_kwargs) | ||
| ) |
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.
| flat_args, in_spec = pytree.tree_flatten( | |
| (args, reordered_kwargs) | |
| ) | |
| flat_args, in_spec = pytree.tree_flatten((args, reordered_kwargs)) |
torch/export/_unlift.py
Outdated
| # TODO(suo) this should not be optional, but is since we still ahve | ||
| # capture_pre_autograd_graph grr | ||
| graph_signature: Optional[ExportGraphSignature] = None, | ||
| _check_input_constraints: bool = True, |
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.
Hmm why would we not want to run this check when swapping?
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.
I think it's an additional QPS optimization? This is currently something the unflattener also supports, and is turned off in APS here.
Downstream APS code was failing to run the previously swapped module because of some fx.GraphModule forward function weirdness. So to fix this, I just attached a custom forward function which matches the unflattened module's forward function. Differential Revision: [D63683422](https://our.internmc.facebook.com/intern/diff/D63683422/) [ghstack-poisoned]
|
This pull request was exported from Phabricator. Differential Revision: D63683422 |
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.
Please commit the suggested changes from pytorch's linter.
torch/export/unflatten.py
Outdated
| flat_args, in_spec = pytree.tree_flatten( | ||
| (args, reordered_kwargs) | ||
| ) |
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.
| flat_args, in_spec = pytree.tree_flatten( | |
| (args, reordered_kwargs) | |
| ) | |
| flat_args, in_spec = pytree.tree_flatten((args, reordered_kwargs)) |
Downstream APS code was failing to run the previously swapped module because of some fx.GraphModule forward function weirdness (P1594789677). So to fix this, I just attached a custom forward function which matches the unflattened module's forward function. Differential Revision: [D63683422](https://our.internmc.facebook.com/intern/diff/D63683422/) [ghstack-poisoned]
|
This pull request was exported from Phabricator. Differential Revision: D63683422 |
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.
Dislike the _check_input_constraints flag polluting the API. What does it even do? If it's something we want to support officially, OK let's do it more systematically. But as is it feels very weird.
Downstream APS code was failing to run the previously swapped module because of some fx.GraphModule forward function weirdness (P1594789677). So to fix this, I just attached a custom forward function which matches the unflattened module's forward function. Differential Revision: [D63683422](https://our.internmc.facebook.com/intern/diff/D63683422/) [ghstack-poisoned]
|
This pull request was exported from Phabricator. Differential Revision: D63683422 |
Downstream APS code was failing to run the previously swapped module because of some fx.GraphModule forward function weirdness (P1594789677). So to fix this, I just attached a custom forward function which matches the unflattened module's forward function. Differential Revision: [D63683422](https://our.internmc.facebook.com/intern/diff/D63683422/) [ghstack-poisoned]
|
This pull request was exported from Phabricator. Differential Revision: D63683422 |
|
@pytorchbot merge -f 'Landed internally' (Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally) |
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 |
Refactor so that unflattener doesn't become too messy Differential Revision: [D63719648](https://our.internmc.facebook.com/intern/diff/D63719648/) Pull Request resolved: #137134 Approved by: https://github.com/avikchaudhuri ghstack dependencies: #136191, #137102
Stack from ghstack (oldest at bottom):
Downstream APS code was failing to run the previously swapped module because of some fx.GraphModule forward function weirdness (P1594789677). So to fix this, I just attached a custom forward function which matches the unflattened module's forward function.
Differential Revision: D63683422