Skip to content

[precompile] Check a standalone artifact's inlined source before trusting it - #194389

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

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

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

An installed artifact rebuilds a CompilePackage at load, and that constructor
verifies that every function Dynamo inlined into a captured graph still has the
source it had at capture. A standalone artifact builds no package, so it never
ran that check -- and the failure mode is not a missing warning, it is a wrong
answer:

eager = 20.0   artifact = 12.0

after changing a constant in an inlined helper between capture and load.

Emit the records the check needs -- module, line range, checksum, no content --
and check them in the driver rather than in load(). The artifact's own
stated invariant is that it is self-contained, and its header documents
exec(open(...).read(), ns); ns["forward"](model, x) as a supported way to
use it; a check in load() is bypassed by exactly that path. The logic stays
in torch and only the call is frozen into the emitted source, matching how the
driver already reaches load_guard_manager.

__main__ records are skipped. They name the LOADER's script on another
machine, so checking them would refuse a portable artifact with a false
diagnosis -- and capture-in-a-script, serve-elsewhere is what a standalone
artifact is for. Verified: an artifact captured from a script still serves
correctly when loaded by a different script whose __main__ defines a
conflicting function of the same name.

Test Plan:

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

The new test captures against an importable helper, serves it, rewrites the
helper's arithmetic, and asserts the reload refuses -- and asserts the artifact
is in the standalone mode first, so it cannot silently start testing the
installed path.

Authored with an AI assistant.

Differential Revision: D116962605

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 199 New Failures, 2 Unrelated Failures

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

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

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

This was referenced Aug 21, 2026
This was referenced Aug 22, 2026
[ghstack-poisoned]
[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/1026/head branch November 12, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant