Repository navigation
[precompile] Record a backend for a graph the compiler short-circuited - #195215
Closed
bobrenjc93 wants to merge 1 commit into
Closed
bobrenjc93 wants to merge 1 commit into
bobrenjc93 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195215
Note: Links to docs will display an error until the docs builds have been completed. ❌ 14 New Failures, 1 Unrelated FailureAs of commit 6971e19 with merge base 1b4e490 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 28, 2026
Closed
Closed
This was referenced Aug 28, 2026
Closed
Closed
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):
A graph that runs nothing and returns nothing no longer reaches the backend:
output_graph substitutes noop_graph_call for it rather than pay a metadata
pass, a joint trace and a cache miss for a function with nothing in it. That is
a good optimization and it does not interact with torch.compile, which discards
such a frame anyway.
It interacts with capture, which does not discard it. _capture_config sets
allow_empty_graphs, so the frame stays compiled and its guards reach the
artifact -- that is the whole reason the flag exists. Dynamo's transformed
bytecode still names __compiled_fn_N, and backend_ids is derived by scanning
co_names, so the id lands in the cache entry with nothing filed behind it. The
harvest then reports it as a compiled graph that lost its code and fails the
capture:
Unconditional, so no require_* gate relaxes it, and on a real model one such
frame is enough to take the whole capture down.
The id is recorded rather than excused. noop_graph_call is a module-level
function, so an EagerCacheArtifact holding it pickles by reference and
reconstructs to the same object, which keeps the entry self-consistent and
means the served artifact dispatches that frame to a no-op instead of skipping
it at install and silently running eager. Blunting the missing-backend check
instead would have traded a loud failure for a silent one, and that check has
caught real gaps.
Inductor only, in effect: the eager path already turns every cached backend
into an artifact, so it never saw this. It goes in _take_backend_artifacts
rather than _collect_backends because teardown clears cached_backends for a
non-eager backend and _collect_backends runs after it -- which is exactly the
path that was failing.
Test Plan:
test_precompile_records_a_backend_for_a_short_circuited_noop_graph captures a
region whose result is unused, so the graph's output prunes to nothing, and
asserts the artifact loads and serves. It fails without this change with the
verbatim error above.
The short-circuit is forced rather than provoked. Whether a real frame prunes to
an empty output depends on pruning details a toy model does not reproduce; the
test pins the packaging interaction, on a graph whose output IS already empty
and whose single call is dead, so short-circuiting it changes nothing
observable.
Authored with the assistance of an AI coding agent.