Repository navigation
[precompile] Keep a guard's own subject out of the value pruning, and validate what ships - #194427
Closed
bobrenjc93 wants to merge 2 commits into
Closed
bobrenjc93 wants to merge 2 commits into
bobrenjc93 wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194427
Note: Links to docs will display an error until the docs builds have been completed. ❌ 14 New Failures, 1 Unrelated FailureAs of commit dc143b7 with merge base 1b4e490 ( 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 Aug 22, 2026
Closed
Closed
This was referenced Aug 22, 2026
Closed
This was referenced Aug 28, 2026
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
Author
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):
A TENSOR_MATCH carries its subject inside its
create_fnpartial, andnormalize_create_fndereferences the weakref, so the pickle ships that copyas well as the scope. On a SECOND serialization the two stop being the same
object: a module in
global_scoperound-trips by ALIAS, so the source walkreaches the LIVE tensor and repopulates
guard_tree_valueswith its id, whilethe guard's carried copy round-trips by VALUE and comes back a FakeTensor. The
id-keyed pruning then finds the carried copy unreachable and writes
_Missing("tensor guard tree")over a KEPT guard's own subject. Load dies:Any model that reads a module-global tensor from an inlined frame hits it; no
rebinding of the global is required, though rebind-on-first-use is how it was
found. Local-rooted TENSOR_MATCHes are fine, because after load the scope entry
and the carried copy are the same object through the pickle memo.
Seed the pruning with the tensors kept guards carry. TENSOR_MATCH is the only
guard that carries one -- HASATTR, DICT_NOT_CONTAINS and DUPLICATE_INPUT carry
strings and Sources -- so this is complete for today's guard set, and subclass
inner tensors follow once the outer is in the dict. It costs +184 bytes, because
the tensor reducer stores metadata rather than data, and the guard keeps its
teeth: change the global's dtype and the artifact still refuses to serve.
The existing merge two builds down does not cover this and cannot: both sides of
it are populated by source walks, and the carried copy is never a source-walk
result.
DROPPING the guard instead was measured and rejected. With it gone, changing the
global's dtype makes an eager artifact serve correctly (eager re-dispatches) and
an INDUCTOR artifact serve float32 where eager gives float64, silently. That is
the harm _SHAPE_BEARING_GUARD_TYPES exists to prevent.
Second half: validate the pickle that SHIPS.
_apply_guard_policyrebuilt thepickle it READ and shipped the one it WROTE, and those differ on every frame --
across test_precompile.py, 230 of 230 shipped blobs were never rebuilt and 88 of
them had lost values the validated one still had. So the capture-time gate's
guarantee was "the bytes I read rebuild", not "the bytes I ship rebuild", and a
failure landed on the serving machine 35 minutes later. Both the policy path and
the session path now rebuild what they wrote and heal it through the existing
drop machinery, in a bounded loop because healing re-serializes.
Test Plan:
The new test writes a module with a global tensor, captures a function reading
it, serves it, and then changes the global's dtype and asserts the artifact
refuses -- the second half being the point, since a guard that survives without
discriminating is not worth keeping. It fails without the seeding.
The build-count test now counts builds PER MANAGER rather than in total, because
validating what ships is a deliberate extra build; what it pins -- no redundant
inspection build inside one manager -- is unchanged and still fails if the third
build comes back.
Authored with an AI assistant.
Differential Revision: D117030054