Skip to content

[aot_autograd] compile_to_python training support - #195885

Closed
bobrenjc93 wants to merge 1 commit into
gh/bobrenjc93/1112/basefrom
gh/bobrenjc93/1112/head
Closed

bobrenjc93 wants to merge 1 commit into
gh/bobrenjc93/1112/basefrom
gh/bobrenjc93/1112/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

compile_to_python / to_standalone_python can now emit the training (backward)
path, not just inference, on top of the undefined-tangent backward
specialization two commits below: a training artifact composes the forward,
the base backward and one backward variant per tangent mask observed at
capture, and serves the variant for the mask a backward call presents.

Differentiability of a generated graph is decided by scanning call nodes'
operator names (to_standalone_python._graph_differentiates), not by
substring-matching graph names.

Standalone artifacts. compile_to_python training artifacts import AOTAutograd
only through standalone_runtime: source_emit redirects every re-exported object
there by identity, and the surface holds the runtime helpers, the metadata
types, the whole closed set of descriptor classes, FunctionalTensor (the
raw_type baked into output metadata) and SymIntEqByExpr (baked MetadataKey
entries); BackwardState is bound into the forward only when the graph has
backward state, and the surface test matches every private torch path an
artifact could reach internals through. The direct compile_to_python path
captures under aot_autograd_prune_unused_outputs, matching the flag the emitted
glue bakes on, so the exact retrace is available and a declined retrace warns
instead of silently falling back to structural pruning; the standalone mask
compiler follows the live runtime's fallback policy and always serves mask 0.
standalone_compile marks user-visible outputs under keep_output_stride as
compile_fx does; module renaming converts ast byte offsets to str offsets; the
module names shared with torch._precompile are constants; the passthrough
backward consumes its argument list; a corrupt cache bundle does not discard
the good ones in a merge.

Suggested review order: to_standalone_python.py (the training composer),
standalone_runtime.py and source_emit.py (the stable import surface),
torch/_inductor/standalone_compile.py (user-visible output marking), then
torch/compiler/_cache.py.

Test Plan:

python test/functorch/test_compile_to_python.py
python test/inductor/test_compile_to_python.py

New tests: a training artifact loading in a fresh subprocess, the
stable-surface import assertion for training artifacts across private paths,
non-ASCII module renaming, passthrough argument release, and cache-merge
tolerance.

Authored with an AI assistant.

Co-Authored-By: Claude Fable 5.1 [email protected]

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures, 7 Cancelled Jobs, 15 Pending

As of commit eba5ed7 with merge base 3d3d3f4 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: aot autograd"

@pytorch-bot pytorch-bot Bot added the release notes: aot autograd release notes category label Sep 3, 2026
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

Closing in favor of the canonical stack #195353-#195362 (now also #195911-#195929), which carries an equivalent of this change. Final state of this PR's stack is preserved locally for reference.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant