Repository navigation
[precompile] Report guard drift and drop unrebuildable guards - #195925
Closed
bobrenjc93 wants to merge 7 commits into
Closed
bobrenjc93 wants to merge 7 commits into
bobrenjc93 wants to merge 7 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195925
Note: Links to docs will display an error until the docs builds have been completed. ❌ 37 New Failures, 1 Unrelated FailureAs of commit 9cd0a96 with merge base 1ad121e ( NEW FAILURES - The following jobs have failed:
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]
bobrenjc93
added a commit
that referenced
this pull request
Sep 4, 2026
Serialization records a guard's VALUE, and rebuilding the tree walks its SOURCE against the reconstructed scope, so a source reaching state the reconstruction does not restore serializes fine and then fails on the serving machine. A guard that cannot be rebuilt is now dropped, and actually removed from the pickle that ships, with a report -- recorded as RISKY, so the default require_no_risky_drops still refuses -- instead of the whole artifact being refused. Its HASATTR companion leaves with it, since that guard is recomputed from the dropped subject at load and would rebuild inverted. A guard that rebuilds into a DIFFERENT check than the live build made is reported as drift and refused under the same gate; drift is measured on the C++ LEAF guards of the tree the serving machine builds, via GuardManagerWrapper.leaf_fingerprint, so LAMBDA_GUARD and relational guards are not compared. The live leaves are recorded through a ContextVar keyed by the guard state each variant serializes, so drift into ANOTHER variant's value is still caught, and a torch.compile on another thread neither records into a capture's leaves nor clobbers another session's. Each frame's guard tree is built twice, not three times; the probe rebuilds pass explicit_capture, and so does load_guard_manager. The HASATTR builder registers the attribute value for tensor bases only, where the inversion actually occurs. Every dropped slot's rendered check is recorded as summary().dropped_guard_code and the artifact's DROPPED_GUARD_CODE section, so the drop lists can be audited; save() shares _gated_summary rather than duplicating the gate code. The policy pass only drops environment-rooted slots (_environment_rooted) and judges a Guard's DERIVED types too. Test Plan: ``` python test/test_precompile.py -k cannot_be_rebuilt -k guard_drift_is_reported -k records_what_each_dropped_slot -k hasattr_guard_survives -k derived_type_must_survive python test/dynamo/test_guard_serialization.py -k live_guard_leaf python test/test_precompile.py python test/dynamo/test_precompile_package.py python test/dynamo/test_aot_compile.py ``` Authored with an AI assistant. ghstack-source-id: 2dbd92f Pull-Request: #195925
[ghstack-poisoned]
[ghstack-poisoned]
bobrenjc93
added a commit
that referenced
this pull request
Sep 5, 2026
Serialization records a guard's VALUE, and rebuilding the tree walks its SOURCE against the reconstructed scope, so a source reaching state the reconstruction does not restore serializes fine and then fails on the serving machine. A guard that cannot be rebuilt is now dropped, and actually removed from the pickle that ships, with a report -- recorded as RISKY, so the default require_no_risky_drops still refuses -- instead of the whole artifact being refused. Its HASATTR companion leaves with it, since that guard is recomputed from the dropped subject at load and would rebuild inverted. A guard that rebuilds into a DIFFERENT check than the live build made is reported as drift and refused under the same gate; drift is measured on the C++ LEAF guards of the tree the serving machine builds, via GuardManagerWrapper.leaf_fingerprint, so LAMBDA_GUARD and relational guards are not compared. The live leaves are recorded through a ContextVar keyed by the guard state each variant serializes, so drift into ANOTHER variant's value is still caught, and a torch.compile on another thread neither records into a capture's leaves nor clobbers another session's. Each frame's guard tree is built twice, not three times; the probe rebuilds pass explicit_capture, and so does load_guard_manager. The HASATTR builder registers the attribute value for tensor bases only, where the inversion actually occurs. Every dropped slot's rendered check is recorded as summary().dropped_guard_code and the artifact's DROPPED_GUARD_CODE section, so the drop lists can be audited; save() shares _gated_summary rather than duplicating the gate code. The policy pass only drops environment-rooted slots (_environment_rooted) and judges a Guard's DERIVED types too. Test Plan: ``` python test/test_precompile.py -k cannot_be_rebuilt -k guard_drift_is_reported -k records_what_each_dropped_slot -k hasattr_guard_survives -k derived_type_must_survive python test/dynamo/test_guard_serialization.py -k live_guard_leaf python test/test_precompile.py python test/dynamo/test_precompile_package.py python test/dynamo/test_aot_compile.py ``` Authored with an AI assistant. ghstack-source-id: 91aad8e Pull-Request: #195925
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):
Serialization records a guard's VALUE, and rebuilding the tree walks its
SOURCE against the reconstructed scope, so a source reaching state the
reconstruction does not restore serializes fine and then fails on the serving
machine. A guard that cannot be rebuilt is now dropped, and actually removed
from the pickle that ships, with a report -- recorded as RISKY, so the default
require_no_risky_drops still refuses -- instead of the whole artifact being
refused. Its HASATTR companion leaves with it, since that guard is recomputed
from the dropped subject at load and would rebuild inverted. A guard that
rebuilds into a DIFFERENT check than the live build made is reported as drift
and refused under the same gate; drift is measured on the C++ LEAF guards of
the tree the serving machine builds, via GuardManagerWrapper.leaf_fingerprint,
so LAMBDA_GUARD and relational guards are not compared. The live leaves are
recorded through a ContextVar keyed by the guard state each variant
serializes, so drift into ANOTHER variant's value is still caught, and a
torch.compile on another thread neither records into a capture's leaves nor
clobbers another session's.
Each frame's guard tree is built twice, not three times; the probe rebuilds
pass explicit_capture, and so does load_guard_manager. The HASATTR builder
registers the attribute value for tensor bases only, where the inversion
actually occurs. Every dropped slot's rendered check is recorded as
summary().dropped_guard_code and the artifact's DROPPED_GUARD_CODE section,
so the drop lists can be audited; save() shares _gated_summary rather than
duplicating the gate code. The policy pass only drops environment-rooted slots
(_environment_rooted) and judges a Guard's DERIVED types too.
Test Plan:
Authored with an AI assistant.