Skip to content

[guards] Do not prune interned values, which id()-keyed pruning cannot scope - #194249

Closed
bobrenjc93 wants to merge 2 commits into
gh/bobrenjc93/1001/basefrom
gh/bobrenjc93/1001/head
Closed

bobrenjc93 wants to merge 2 commits into
gh/bobrenjc93/1001/basefrom
gh/bobrenjc93/1001/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

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:

TypeError: empty_strided(): argument 'dtype' must be torch.dtype, not _Missing

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:

python test/test_precompile.py
python test/dynamo/test_guard_serialization.py
python test/dynamo/test_package.py

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

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🔗 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 Failures

As of commit 5262e18 with merge base 1b4e490 (image):

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.

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Aug 20, 2026
@bobrenjc93 bobrenjc93 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Aug 20, 2026
@bobrenjc93

Copy link
Copy Markdown
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 22, 2026
[ghstack-poisoned]
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bobrenjc93

Copy link
Copy Markdown
Contributor Author

Superseded by the canonical precompile stack #195353-#195362; this change lives in #195360. Closing to consolidate review there. The branch is kept on GitHub.

@bobrenjc93 bobrenjc93 closed this Sep 3, 2026
@github-actions
github-actions Bot deleted the gh/bobrenjc93/1001/head branch November 11, 2026 01:44
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 topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant