Skip to content

[precompile] Stop requiring AOTAutogradCache to key a graph before recording it - #194452

Closed
bobrenjc93 wants to merge 3 commits into
gh/bobrenjc93/1039/basefrom
gh/bobrenjc93/1039/head
Closed

bobrenjc93 wants to merge 3 commits into
gh/bobrenjc93/1039/basefrom
gh/bobrenjc93/1039/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

A capture of a large sharded model ends with:

Precompilation captured graphs but their compiled backends were never
recorded... AOTAutograd bypassed 15 time(s) here.
Bypassing autograd cache due to: Unsupported call_function target
    <function get_external_object_by_index ...>

That function is how Dynamo threads a non-tensor external -- a process group, a
stream, a mempool -- into a graph, so a sharded model is built out of them.
AOTAutogradCache is not on the allowlist for it, declines to KEY the graph, and
therefore never SAVES; the bundled artifact precompile records is produced by
that save path, so the capture ends with a backend id and nothing behind it.

The gate being tripped asks "is this key enough to tell this graph's behaviour
apart from another's". A precompile artifact does not depend on that answer: it
is addressed by backend id and refuses to load against a different torch build.
So fall back to a nonce key rather than declining -- which is exactly what
torch._dynamo.aot_compile and aot_compile_joint_with_descriptors already
do, with the config's own comment giving this rationale. Precompile was the one
bundled-artifact producer that did not set it.

This removes the whole class rather than a name at a time. Widening the
allowlist would have needed at least two entries for this one model, and the
second reason it reports -- "Unsupported call_method target getitem" -- is not
even an allowlist gap: method_target there is the RECEIVER node, so it means
a method was called on a node named getitem that carries no example_value.

Sequenced behind the commit below it, which is not optional. With a nonce key
the keyed lookup still runs, so every graph in one capture shares a keyspace;
until that key was unique per call, turning this on made the second unkeyable
graph in a capture hit the first one's entry.

Test Plan:

python test/test_precompile.py
python test/dynamo/test_aot_autograd_cache.py
python test/dynamo/test_package.py
python test/dynamo/test_guard_serialization.py
python test/dynamo/test_precompile_context.py

Two new tests. The first captures with backend="inductor" a model calling
something the cache will not key, and serves it -- it fails without this change
with the exact "never recorded" error. The second asserts every fallback key in
one capture is distinct, and needs the model to be unkeyable on BOTH sides of a
graph break, since one unkeyable graph cannot collide with anything.

Authored with an AI assistant.

Differential Revision: D117073083

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194452

Note: Links to docs will display an error until the docs builds have been completed.

❌ 12 New Failures, 1 Unrelated Failure

As of commit dcb3556 with merge base 1b4e490 (image):

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.

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Aug 22, 2026
This was referenced Aug 22, 2026
@bobrenjc93

Copy link
Copy Markdown
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 23, 2026
[ghstack-poisoned]
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bobrenjc93

Copy link
Copy Markdown
Contributor Author

Superseded by the canonical precompile stack #195353-#195362; this change lives in #195362 (with the guard-drop policy half in #195360). Closing to consolidate review there. The branch is kept on GitHub.

@bobrenjc93 bobrenjc93 closed this Sep 3, 2026
@github-actions
github-actions Bot deleted the gh/bobrenjc93/1039/head branch November 11, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request module: dynamo topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant