Repository navigation
[precompile] Drop invariant guards on exit, and write the invariants report - #195920
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/195920
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):
Only the guards that DISCRIMINATE need to be serialized. On a 62-frame ranking
model 738 of 1207 guard slots held the same fact in every captured variant;
such a guard selects nothing, and precompile's contract -- the environment is
identical at capture and at runtime, every variation comes from the inputs --
is what licenses dropping it. Which slots discriminate is knowable only once
every variant exists, but guards are serialized per compilation as each is
produced, and a capture is not free of side effects (a training step's
gradients accumulate, BatchNorm stats advance), so re-running the examples was
never an option.
_apply_guard_policytherefore runs on exit andre-serializes each frame's guards from the pickle the capture already made,
inside the try that converts failures to PackageError.
The policy is fail-closed: only the explicit
_INVARIANT_DROPPABLE_GUARD_TYPESmay be dropped, and only when rooted in the environment (a global, or sourceless
process state) -- a droppable type reached through an input is a pin on that
input and stays; shape-bearing and semantic guards survive even a single-example
capture, unmodelled and unclassified types are kept, and no-op marker types are
neither dropped nor reported. The pruned guard states are committed only after
every frame re-serialized, so a failure leaves the package and its accounting
exactly as the capture made them. Policy-dropped facts are re-marked rather than
deleted, so the invariants report --
invariants()per frame, andwrite_invariants()as a file stable across runs whose header promises thata dropped line is a precondition NOTHING checks -- lists them. The report is
written on a clean exit only; a partial capture reads exactly like a complete
one, so the session says why the file did not appear instead.
Test Plan:
Authored with an AI assistant.
[no ci]