Skip to content

Conversation

tugsbayasgalan
Copy link
Contributor

@tugsbayasgalan tugsbayasgalan commented Apr 18, 2023

@pytorch-bot
Copy link

pytorch-bot bot commented Apr 18, 2023

🔗 Helpful Links

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

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

❌ 5 New Failures

As of commit ae41c99:

NEW FAILURES - The following jobs have failed:

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

guard_nn_modules = False

# Optionally functionalize the produced export graph module
functionalize = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets not add more things to config. Can you use **kwargs in export API for now to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

Copy link
Contributor

Choose a reason for hiding this comment

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

side note - @anijain2305 what's our stance towards BC on torch._dynamo.export? Are we ok with removing kwargs later?

Copy link
Contributor

Choose a reason for hiding this comment

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

All the options seem equally bad to me. Imo, export is going through a heavy refactoring, and I would wait for aot_export etc to be finalized before we set the API in stone.

@anijain2305
Copy link
Contributor

This looks ok to me for short-term. @bdhirsh Can you take a look?

torch._enable_functionalization(reapply_views=True)
yield pytree.tree_map(to_fun, args)
finally:
torch._disable_functionalization()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will still cause problems, if your Interpreter(graph).run() call lower down raises an exception. You need that to be wrapped by the try/finally to make sure that functionalization is always properly turned off afterwards.

One way would be to change this context manager into a decorator that wraps your interpreter call. Or you can just not bother with the decorator here, and manually try/finally around the interpreter call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I will just do plain try/finally.

@bdhirsh
Copy link
Contributor

bdhirsh commented Apr 18, 2023

Otherwise look ok to me!

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

[ghstack-poisoned]
Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

[ghstack-poisoned]
tugsbayasgalan added a commit that referenced this pull request Apr 18, 2023
ghstack-source-id: f3099a6
Pull Request resolved: #99461
Copy link
Contributor

@bdhirsh bdhirsh left a comment

Choose a reason for hiding this comment

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

lgtm!

@tugsbayasgalan
Copy link
Contributor Author

@tugsbayasgalan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
@tugsbayasgalan
Copy link
Contributor Author

@tugsbayasgalan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
tugsbayasgalan added a commit that referenced this pull request Apr 19, 2023
ghstack-source-id: ea5b76b
Pull Request resolved: #99461
@tugsbayasgalan
Copy link
Contributor Author

@tugsbayasgalan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
if functionalize and not aten_graph:
raise UserError(
UserErrorType.ANTI_PATTERN,
"TorchDynamo won't functionalize non-aten graphs. Please set `functionalize` to true",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"TorchDynamo won't functionalize non-aten graphs. Please set `functionalize` to true",
"TorchDynamo won't functionalize non-aten graphs. Please set `aten_graph` to true",

with torch.fx.traceback.preserve_node_meta():
return torch.fx.Interpreter(graph).run(*args)
if functionalize:
torch._enable_functionalization(reapply_views=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we concluded to allow views in the graph, should we have reapply_views=True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh lol you are right. We will replace them with view_copy later as pass


new_graph.recompile()

# TODO remove this once Executorch uses proper functionalization
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this deletion!

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
@tugsbayasgalan
Copy link
Contributor Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/tugsbayasgalan/110/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/99461)

Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
tugsbayasgalan added a commit that referenced this pull request May 3, 2023
Pull Request resolved: #99461


Fixes: #99000

cc @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D45106409/)!
ghstack-source-id: 188007117
Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
Fixes: #99000

cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409)

[ghstack-poisoned]
tugsbayasgalan added a commit that referenced this pull request May 5, 2023
Pull Request resolved: #99461


Fixes: #99000

cc @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @desertfire

Differential Revision: [D45106409](https://our.internmc.facebook.com/intern/diff/D45106409/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D45106409/)!
ghstack-source-id: 188187442
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 5, 2023
@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants