Repository navigation
[guards] Do not prune interned values, which id()-keyed pruning cannot scope - #194249
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/194249
Note: Links to docs will display an error until the docs builds have been completed. ❌ 10 New Failures, 2 Unrelated FailuresAs of commit 5262e18 with merge base 1b4e490 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following job failed but was 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 20, 2026
Closed
This was referenced Aug 20, 2026
Closed
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This was referenced Aug 20, 2026
This was referenced Aug 22, 2026
Closed
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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):
Serializing guard state prunes any value the guard tree does not reach,
replacing it with a _Missing sentinel. The bookkeeping is keyed by id(), which
asks "is this the same OBJECT" when the question it means is "is this the same
REFERENCE". For an interned value those come apart.
torch.float32 is one object. A module attribute holding it that no guard reads
registers that id as missing, and from then on EVERY reference to that dtype
resolves to the sentinel -- including the ones the artifact genuinely needs. The
artifact then fails at LOAD, far from the cause:
The tell is that it depends on which dtype: an unguarded torch.float32 breaks a
float32 graph while an unguarded torch.bfloat16 does not, because only the
former is also needed elsewhere.
Interned values are also exactly the ones pruning gains nothing from -- they are
immutable, trivially picklable, and a handful of bytes -- so they are skipped
rather than asked to carry a distinction identity cannot express. Both
registration sites need it: the pytree-leaf walk, and the nn.Module dict
walk, which is the one real models hit.
This supersedes the earlier mitigation. Pruning was already changed to follow
the UNFILTERED guard tree so that dropping a guard could not drop the value it
named; that removed one way in but not the collision itself, which is why the
same error survived it. This removes the collision.
Test Plan:
The new test parametrizes the unguarded attribute over a dtype, an int, a str
and a device and asserts the artifact loads and matches eager for each. Without
the fix the dtype case fails with the TypeError above and the rest pass, which
is the asymmetry that makes this hard to spot in the wild.
Authored with an AI assistant.
Differential Revision: D116840947