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

Avoid graph breaks in torch.compile caused by inner classes in the backward hooks #7062

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

deepcharm
Copy link
Contributor

This PR is part of the effort to improve Deepspeed performance when using PyTorch compile.

There is a known bug in torch.compile which causes a graph break when an inner class is defined within
a method that is being compiled. The following would then appear in the log:

[__graph_breaks] torch._dynamo.exc.Unsupported: missing: LOAD_BUILD_CLASS

This is the case with the inner classes PreBackwardFunctionForModule and PostBackwardFunctionModule.

While there is an open PyTorch PR#133805 for this, we can solve the issue by moving the inner classes into the initialization code.

No graph breaks and the corresponding logs are produced anymore.

This PR is part of the effort to improve Deepspeed
performance when using PyTorch compile.

There is a known bug in torch.compile
(pytorch/pytorch#128942)
which causes a graph break when a inner class
is defined within a method that is being compiled
and logs the following message:

[__graph_breaks] torch._dynamo.exc.Unsupported: missing: LOAD_BUILD_CLASS

This is the case with the inner classes
PreBackwardFunctionForModule and PostBackwardFunctionModule.

While there is an open PR for this
(pytorch/pytorch#133805),
we can solve the issue by moving the inner classes
into the initialization code.

No graph breaks and the corresponding logs
are produced anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants