Content-Length: 239334 | pFad | http://github.com/pytorch/pytorch/issues/155331

13 Can't use torch.compile inside of a torch_dispatch mode · Issue #155331 · pytorch/pytorch · GitHub
Skip to content

Can't use torch.compile inside of a torch_dispatch mode #155331

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

Open
zou3519 opened this issue Jun 6, 2025 · 1 comment
Open

Can't use torch.compile inside of a torch_dispatch mode #155331

zou3519 opened this issue Jun 6, 2025 · 1 comment
Labels
dynamo-triage-jan2025 module: dynamo module: pt2-dispatcher PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op, 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 6, 2025

Repro:

from torch.utils._python_dispatch import TorchDispatchMode

backend = torch._dynamo.testing.EagerAndRecordGraphs()

class YoloMode(TorchDispatchMode):
    def __torch_dispatch__(self, func, types, args=(), kwargs=None):
        out = torch.compile(func, backend=backend, fullgraph=True)(
            *args, **kwargs
        )
        return out

x = torch.randn(5)
with YoloMode():
    out = torch.add(x, x)

See #148712 for previous attempt

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

@zou3519 zou3519 added oncall: pt2 module: dynamo module: pt2-dispatcher PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op, dynamo-triage-jan2025 labels Jun 6, 2025
@yf225 yf225 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 6, 2025
@narekmalk
Copy link
Contributor

My PyTorch version is 2.7.1+cu126. When I run your code, I get
AttributeError: module 'torch._dynamo' has no attribute 'testing'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamo-triage-jan2025 module: dynamo module: pt2-dispatcher PT2 dispatcher-related issues (e.g., aotdispatch, functionalization, faketensor, custom-op, 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

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/pytorch/pytorch/issues/155331

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy