Skip to content
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

Dynamo: contextlib.contextmanager doesn't work #128651

Open
zou3519 opened this issue Jun 13, 2024 · 0 comments
Open

Dynamo: contextlib.contextmanager doesn't work #128651

zou3519 opened this issue Jun 13, 2024 · 0 comments
Labels
dynamo-ctx-manager module: dynamo oncall: pt2 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@zou3519
Copy link
Contributor

zou3519 commented Jun 13, 2024

We should be able to support this if there are no graph breaks:

import torch
import contextlib

lst = []

@contextlib.contextmanager
def lst_append():
    try:
        yield
    finally:
        lst.append(4)

@torch.compile(backend="eager", fullgraph=True)
def f(x):
    with lst_append():
        pass
    return

x = torch.randn(2)
f(x)
print(lst)

cc @ezyang @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng

@eellison eellison added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module module: dynamo labels Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamo-ctx-manager module: dynamo oncall: pt2 triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

4 participants