Skip to content

Conversation

jon-chuang
Copy link
Collaborator

@jon-chuang jon-chuang commented Feb 13, 2023

Replacement to #94672.

Follow up to #94137.

We simply replace the set grad mode try except blocks with one for a more generic contextmanager (using __enter__ and __exit__), storing the context manager into a symbolic_local for the duration of the try block.

(see pytorch/torchdynamo#207 for the original motivation)

This allows us to handle calling inner functions with graph breaks for any arbitrarily deep nesting of live context managers subclassing AbstractContextManager. (see tests)

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

@ngimel ngimel added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 16, 2023
@yanboliang
Copy link
Contributor

Gently ping @jon-chuang, can you address these inline comments? We hit another bug #94758, which potentially can be fixed by this. It's good we can merge this ASAP.

@jon-chuang
Copy link
Collaborator Author

Hello @yanboliang , should be ready now.

@jon-chuang
Copy link
Collaborator Author

We need to add a not-user-facing label

@ngimel ngimel added the topic: not user facing topic category label Mar 2, 2023
Copy link
Contributor

@yanboliang yanboliang left a comment

Choose a reason for hiding this comment

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

LGTM, cc @williamwen42 to check if this breaks any Python 3.11 change.

@jon-chuang
Copy link
Collaborator Author

jon-chuang commented Mar 5, 2023

if this breaks any Python 3.11 change.

I guess full 3.11 testing is not currently in CI? Else if it is, it seems safe to merge.

@jon-chuang
Copy link
Collaborator Author

@pytorchmergebot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 6, 2023
@jon-chuang
Copy link
Collaborator Author

jon-chuang commented Mar 6, 2023

Else if it is, it seems safe to merge.

Anw, if it turns out there is a problem, we can fix it, for now I'll assume CI is the source of truth here.

@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

cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 12, 2023
…ger setup/teardown (#94758)

Replacement to pytorch/pytorch#94672.

Follow up to pytorch/pytorch#94137.

We simply replace the set grad mode try except blocks with one for a more generic contextmanager (using `__enter__` and `__exit__`), storing the context manager into a `symbolic_local` for the duration of the try block.

(see pytorch/torchdynamo#207 for the original motivation)

This allows us to handle calling inner functions with graph breaks for any arbitrarily deep nesting of live context managers subclassing `AbstractContextManager`. (see tests)

Pull Request resolved: pytorch/pytorch#94758
Approved by: https://github.com/yanboliang
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 12, 2023
…ger setup/teardown (#94758)

Replacement to pytorch/pytorch#94672.

Follow up to pytorch/pytorch#94137.

We simply replace the set grad mode try except blocks with one for a more generic contextmanager (using `__enter__` and `__exit__`), storing the context manager into a `symbolic_local` for the duration of the try block.

(see pytorch/torchdynamo#207 for the original motivation)

This allows us to handle calling inner functions with graph breaks for any arbitrarily deep nesting of live context managers subclassing `AbstractContextManager`. (see tests)

Pull Request resolved: pytorch/pytorch#94758
Approved by: https://github.com/yanboliang
ydwu4 added a commit to ydwu4/pytorch that referenced this pull request Mar 13, 2023
…ger setup/teardown (pytorch#94758)

Replacement to pytorch#94672.

Follow up to pytorch#94137.

We simply replace the set grad mode try except blocks with one for a more generic contextmanager (using `__enter__` and `__exit__`), storing the context manager into a `symbolic_local` for the duration of the try block.

(see pytorch/torchdynamo#207 for the original motivation)

This allows us to handle calling inner functions with graph breaks for any arbitrarily deep nesting of live context managers subclassing `AbstractContextManager`. (see tests)

Pull Request resolved: pytorch#94758
Approved by: https://github.com/yanboliang
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 Merged module: dynamo open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants