Skip to content

[precompile] The capture session and its guard-drop accounting - #195919

Closed
bobrenjc93 wants to merge 56 commits into
gh/bobrenjc93/1121/basefrom
gh/bobrenjc93/1121/head
Closed

bobrenjc93 wants to merge 56 commits into
gh/bobrenjc93/1121/basefrom
gh/bobrenjc93/1121/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

PrecompileSession is the capture-once driver behind tracer="dynamo". It
gives one explicit capture its own Dynamo cache identity and isolated compile
region, runs the example calls under the grad mode training selects
(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 the
config 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() folds
that into a PrecompileSummary whose gates save() and artifact() 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 unless
require_no_risky_drops is. save() writes a single-file package and
artifact() renders the standalone (python_code, cache) pair through
the previous commit's emitter, with the compiled subgraphs re-lowered to source
where the backend can render them. serving() scopes the fail-on-recompile
override to the calling thread, and _check_artifact_matches refuses an
artifact 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:

python test/dynamo/test_precompile_package.py

Authored with an AI assistant.

[no ci]

[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/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.

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Sep 3, 2026
This was referenced Sep 3, 2026
[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]
@bobrenjc93 bobrenjc93 closed this Oct 16, 2026
@github-actions
github-actions Bot deleted the gh/bobrenjc93/1121/head branch November 17, 2026 01:46
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 release notes: dynamo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant