Skip to content

[compile] logger statements create unnecessary guards during dynamo tracing #11987

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

Merged
merged 2 commits into from
Jul 25, 2025

Conversation

a-r-r-o-w
Copy link
Member

@a-r-r-o-w a-r-r-o-w commented Jul 24, 2025

If compiling with fullgraph=True, we first need to remove the torch.compiler.disable calls we have. Once this is done, Dynamo will error out on the logger statements because they can't be traced. We can conditionally log them to fix this error (what this PR does). We will then hit an error because of using context manager for pinning tensors. We can move the body of that function into the functions directly to avoid using context managers. We will then error out on the call to tensor.is_pinned() because Dynamo cannot trace it, which seems like a problem that needs to be fixed on pytorch-side.

If compiling with fullgraph=False, we add a lot of unnecessary guards and have some more graph breaks. By only conditionally doing the logging, we can avoid some of them.

See this comment: #11960 (comment)

@a-r-r-o-w a-r-r-o-w requested a review from yiyixuxu July 24, 2025 20:02
@a-r-r-o-w a-r-r-o-w changed the title [compile] logger statements error during dynamo tracing, so conditionally log if compiling [compile] logger statements create unnecessary guards during dynamo tracing Jul 24, 2025
@a-r-r-o-w a-r-r-o-w requested review from sayakpaul and removed request for yiyixuxu July 24, 2025 20:15
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thanks!

@a-r-r-o-w a-r-r-o-w merged commit 3d2f8ae into main Jul 25, 2025
14 of 15 checks passed
@a-r-r-o-w a-r-r-o-w deleted the group-offloading-logger-compile branch July 25, 2025 18:58
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.

3 participants