Repository navigation
[precompile] The capture session and its guard-drop accounting - #195919
Closed
bobrenjc93 wants to merge 56 commits into
Closed
bobrenjc93 wants to merge 56 commits into
bobrenjc93 wants to merge 56 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195919
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Sep 3, 2026
Closed
Closed
Closed
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
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):
PrecompileSession is the capture-once driver behind
tracer="dynamo". Itgives one explicit capture its own Dynamo cache identity and isolated compile
region, runs the example calls under the grad mode
trainingselects(inference_mode disabled, since an example created inside it stays an
inference tensor and is refused up front), records every frame Dynamo compiles
plus every recompiled variant into a CompilePackage in explicit-capture mode,
and tears the region down on exit -- waiting for in-flight worker calls,
restoring the capture config, and clearing the region so nothing leaks into
the process's cache or automatic-dynamic state. A session is one-shot, and a
__enter__that raises cleans up after itself rather than wedging theconfig patch for the life of the process.
Its recording filter is where the guard accounting lives: every guard the
serialization filter drops or keeps is recorded per frame as a normalized
GuardFact, a drop is judged risky by the lint from the previous commit (or
by construction when a custom filter dropped it), and
summary()foldsthat into a PrecompileSummary whose gates
save()andartifact()apply:a capture that raised, that hit the recompile limit, that produced a frame
with no guarded code, or that compiled no graph at all is refused unless the
caller relaxes
require_complete, and a risky drop is refused unlessrequire_no_risky_dropsis.save()writes a single-file package andartifact()renders the standalone(python_code, cache)pair throughthe previous commit's emitter, with the compiled subgraphs re-lowered to source
where the backend can render them.
serving()scopes the fail-on-recompileoverride to the calling thread, and
_check_artifact_matchesrefuses anartifact captured from a different callable by module, qualname, code name and
first line. torch._precompile grows the thin wrapper that maps PackageError to
PrecompileError, which the public API will drive.
Test Plan:
Authored with an AI assistant.
[no ci]