Skip to content

[precompile] Write the artifact to paths, and hand back what the examples returned - #194948

Closed
bobrenjc93 wants to merge 2 commits into
gh/bobrenjc93/1070/basefrom
gh/bobrenjc93/1070/head
Closed

bobrenjc93 wants to merge 2 commits into
gh/bobrenjc93/1070/basefrom
gh/bobrenjc93/1070/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

precompile makes the example calls itself, so their return values were the one
thing a caller could not get at. An integration that captures a training step
had to reach past the public entry point into the private session form purely
so its own wrapper could return that batch's losses to a metrics path.

Naming both output files switches precompile to the on-disk form: it writes the
same (python_code, cache) pair to artifact_path and cache_path and returns
instead what each example_inputs call returned, in order. Both or neither -- the
cache carries a sha256 of exactly the python_code it was emitted with, so naming
one without the other would write half an artifact that can never be loaded.
load() takes the same pair of paths.

Keeping the two forms rather than replacing the in-memory one: a real capture's
artifact runs to hundreds of megabytes of rendered source, so paths are the
right default for production, but the pair is what 233 call sites and every
make_fx caller use. The switch is an argument the caller passes, not a hidden
capture-time property, so which form is in play is visible in their own source.

make_fx traces fn under proxy tensors, so what it returned during the trace is a
proxy rather than a value. It writes both files and returns []; only the dynamo
tracer runs the example calls for real.

The API reference documented a return type that never existed (a session object
"for keyword example_inputs") and both of its examples raised -- one passed the
example call positionally, the other gave a graph-breaking function to the
make_fx tracer along with two example_inputs. Rewritten and checked by running
them.

Test Plan:

python test/test_precompile.py
python test/functorch/test_compile_to_python.py
python test/dynamo/test_package.py

New tests cover the on-disk form's results and written files, the make_fx
empty-results case, the both-or-neither rule on each of precompile and load, and
load refusing the pair in memory and on disk at once.

Authored with the assistance of an AI coding agent.

[ghstack-poisoned]
@bobrenjc93 bobrenjc93 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Aug 26, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 14 New Failures, 1 Unrelated Failure

As of commit d0d9220 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 26, 2026
This was referenced Aug 25, 2026
This was referenced Aug 26, 2026
[ghstack-poisoned]
@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/1070/head branch November 11, 2026 01:47
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