[compile] logger statements create unnecessary guards during dynamo tracing #11987
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If compiling with
fullgraph=True
, we first need to remove thetorch.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 totensor.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)