Repository navigation
[precompile] Harden the artifact install/serve lifecycle and disk writes - #195926
Closed
bobrenjc93 wants to merge 8 commits into
Closed
bobrenjc93 wants to merge 8 commits into
bobrenjc93 wants to merge 8 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195926
Note: Links to docs will display an error until the docs builds have been completed. ❌ 14 New Failures, 5 Cancelled Jobs, 1 Unrelated FailureAs of commit aa2ae85 with merge base 1ad121e ( NEW FAILURES - The following jobs have failed:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
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 Sep 3, 2026
Closed
Closed
Closed
bobrenjc93
marked this pull request as draft
September 3, 2026 20:23
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
bobrenjc93
added a commit
that referenced
this pull request
Sep 4, 2026
An installed artifact is now prepared once at load (CompilePackage.prepare builds the guard trees and deserializes the backends; install() consumes them rather than rebuilding), so an artifact that does not fit its host says so at load instead of several batches into a training loop. Serving runs from a private copy of the artifact's dynamo state, so a serve-time recompile no longer writes its backend id back into the artifact and breaks the next install; a served frame's user globals win over the artifact's own names; an installed entry gets back the defaults its code object lost; unload() takes back only the PrecompileContext keys this install added, and only while they still hold the object it recorded. The installed driver checks the same Python and torch version locks the standalone driver does and raises the documented PrecompileError; the standalone driver carries INLINED_SOURCES and refuses drifted inlined source, treating an absent or source-less module as unverifiable rather than rejecting a working artifact. The package stops shipping every inlined module's whole source, resolves code defined under property/cached_property, and revalidates a memoized module-by-file hit. Neither driver rebuilds closure cells for the entry: capture refuses a closure entry, so _entry_binding carries defaults only and _reject_uninstallable_entry_defaults refuses a tensor or unpicklable default before the capture runs. _write_artifact writes each half through a uniquely named scratch file beside its target, renames both into place only after both are fsynced, and moves the previous artifact aside first so a failed second rename puts the previous pair back; _artifact_paths refuses one file named for both halves. Nothing calls _write_artifact/_read_artifact/_artifact_paths yet: the on-disk entry points that use them land above this commit, and the lifecycle tests here drive _write_artifact directly. Test Plan: ``` python test/test_precompile.py -k artifact_write -k installed_entry_keeps -k user_global_wins -k serving_does_not_mutate -k takes_back_only_its_own_keys -k foreign_torch_build -k drifted_inlined_source -k handle_lifecycle python test/dynamo/test_precompile_package.py -k descriptor -k pybind_property -k stale_module_memo python test/test_precompile.py python test/dynamo/test_precompile_package.py ``` Authored with an AI assistant. ghstack-source-id: 9f20a0b Pull-Request: #195926
[ghstack-poisoned]
[ghstack-poisoned]
bobrenjc93
added a commit
that referenced
this pull request
Sep 5, 2026
An installed artifact is now prepared once at load (CompilePackage.prepare builds the guard trees and deserializes the backends; install() consumes them rather than rebuilding), so an artifact that does not fit its host says so at load instead of several batches into a training loop. Serving runs from a private copy of the artifact's dynamo state, so a serve-time recompile no longer writes its backend id back into the artifact and breaks the next install; a served frame's user globals win over the artifact's own names; an installed entry gets back the defaults its code object lost; unload() takes back only the PrecompileContext keys this install added, and only while they still hold the object it recorded. The installed driver checks the same Python and torch version locks the standalone driver does and raises the documented PrecompileError; the standalone driver carries INLINED_SOURCES and refuses drifted inlined source, treating an absent or source-less module as unverifiable rather than rejecting a working artifact. The package stops shipping every inlined module's whole source, resolves code defined under property/cached_property, and revalidates a memoized module-by-file hit. Neither driver rebuilds closure cells for the entry: capture refuses a closure entry, so _entry_binding carries defaults only and _reject_uninstallable_entry_defaults refuses a tensor or unpicklable default before the capture runs. _write_artifact writes each half through a uniquely named scratch file beside its target, renames both into place only after both are fsynced, and moves the previous artifact aside first so a failed second rename puts the previous pair back; _artifact_paths refuses one file named for both halves. Nothing calls _write_artifact/_read_artifact/_artifact_paths yet: the on-disk entry points that use them land above this commit, and the lifecycle tests here drive _write_artifact directly. Test Plan: ``` python test/test_precompile.py -k artifact_write -k installed_entry_keeps -k user_global_wins -k serving_does_not_mutate -k takes_back_only_its_own_keys -k foreign_torch_build -k drifted_inlined_source -k handle_lifecycle python test/dynamo/test_precompile_package.py -k descriptor -k pybind_property -k stale_module_memo python test/test_precompile.py python test/dynamo/test_precompile_package.py ``` Authored with an AI assistant. ghstack-source-id: 0f6d75e Pull-Request: #195926
Contributor
Author
|
/easycla |
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):
An installed artifact is now prepared once at load (CompilePackage.prepare
builds the guard trees and deserializes the backends; install() consumes them
rather than rebuilding), so an artifact that does not fit its host says so at
load instead of several batches into a training loop. Serving runs from a
private copy of the artifact's dynamo state, so a serve-time recompile no
longer writes its backend id back into the artifact and breaks the next
install; a served frame's user globals win over the artifact's own names; an
installed entry gets back the defaults its code object lost; unload() takes
back only the PrecompileContext keys this install added, and only while they
still hold the object it recorded. The installed driver checks the same
Python and torch version locks the standalone driver does and raises the
documented PrecompileError; the standalone driver carries INLINED_SOURCES and
refuses drifted inlined source, treating an absent or source-less module as
unverifiable rather than rejecting a working artifact. The package stops
shipping every inlined module's whole source, resolves code defined under
property/cached_property, and revalidates a memoized module-by-file hit.
Neither driver rebuilds closure cells for the entry: capture refuses a
closure entry, so _entry_binding carries defaults only and
_reject_uninstallable_entry_defaults refuses a tensor or unpicklable default
before the capture runs.
_write_artifact writes each half through a uniquely named scratch file
beside its target, renames both into place only after both are fsynced, and
moves the previous artifact aside first so a failed second rename puts the
previous pair back; _artifact_paths refuses one file named for both halves.
Nothing calls _write_artifact/_read_artifact/_artifact_paths yet: the on-disk
entry points that use them land above this commit, and the lifecycle tests
here drive _write_artifact directly.
Test Plan:
Authored with an AI assistant.