Repository navigation
[aot_autograd] Do not lower an inline-backward graph as inference - #194250
Closed
bobrenjc93 wants to merge 2 commits into
Closed
bobrenjc93 wants to merge 2 commits into
bobrenjc93 wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194250
Note: Links to docs will display an error until the docs builds have been completed. ❌ 10 New FailuresAs of commit 82dfbb8 with merge base 1b4e490 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 20, 2026
Closed
This was referenced Aug 20, 2026
Closed
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This was referenced Aug 20, 2026
This was referenced Aug 22, 2026
Closed
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stack from ghstack (oldest at bottom):
compile_to_pythondecided "is this inference?" by asking whether AOTAutogrademitted a joint. That conflates two different questions. Whether there is a
JOINT decides what to compose; whether the computation DIFFERENTIATES decides
what to tell Inductor. A graph traced through a
.backward()-- which is whatthe make_fx tracer produces for a train step, and what
torch.compile(torch.func.grad(...))produces -- has its backward inlined andno joint at all, so it was being lowered as inference.
That is not cosmetic.
GraphLowering.decide_layout_opttakes a differentbranch for inference (torch/_inductor/graph.py:856); on such a graph it returns
True where the training path returns False, converts the conv to channels-last,
and cuDNN then serves an NHWC TF32 kernel where the same model under
torch.compile gets an NCHW ffma one. The gradients differ by ~2e-4 RELATIVE,
with nothing to indicate it. Measured on a conv train step, gradients against
eager:
Note the diagnosis this replaces. I had recorded this as the rendered path
"selecting a TF32 conv", implying something in the codegen chose a precision.
Nothing does: the conv is an ATen extern call in both paths, there is no Triton
template and no allow_tf32 in the generated source. cuDNN picks the kernel from
the LAYOUT, and layout is what differed. Matching on the op name is enough to
tell the graphs apart here, because the only thing
is_inferencechanges onthis path is that layout decision, and decide_layout_opt returns early unless
the graph has convolutions -- whose backward is a named
convolution_backward.Scope worth stating: this is NOT precompile-specific.
torch.compile(torch.func.grad(loss))builds the same inline-backward graphand shows the identical 1.997e-04, and that path is untouched here. Fixing it
properly belongs in decide_layout_opt, which would change torch.compile's own
behaviour and wants its own discussion.
Test Plan:
The new test asserts a forward-only capture does not classify as
differentiating while a make_fx trace through .backward() does, and that the
latter is detected via convolution_backward -- the op that makes the
classification load-bearing.
Authored with an AI assistant.
Differential Revision: D116840942