Repository navigation
[precompile] Always serialize shape-bearing guards - #194248
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/194248
Note: Links to docs will display an error until the docs builds have been completed. ❌ 11 New Failures, 1 Unrelated FailureAs of commit bf43912 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 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):
Invariant-guard dropping is what makes a real artifact viable -- most guards
cannot be serialized at all, and of those that can the majority held identically
in every captured variant, so keeping them means refusing models over guards
that never chose anything. The rule is "it discriminated nothing", and it is
sound when there is something to discriminate between.
With a SINGLE example there is one variant per frame, so nothing can differ and
the rule drops everything: not just the shape check but every input guard, the
whole TENSOR_MATCH carrying dtype, device, stride and rank. What is left is
GLOBAL_STATE and the torch-function mode stack, which is to say a guard tree
that accepts anything --
mgr.check({"x": "hello"})returns True. Anout-of-domain call then reaches a kernel specialized for a different shape:
loud on inductor (its size assert fires), silent on eager.
That is a degenerate case rather than the documented trade. The justification is
"held identically in every variant", and with one variant nothing was PROVED
invariant, only observed once -- which is exactly the argument the code already
makes for _UNMODELLED_GUARD_TYPES ("never shown to be constant, only never
analyzed") and then failed to apply here.
Shape-bearing guards are now exempt alongside those, on the same grounds and for
the axis a caller is most likely to vary and least likely to expect to be
unchecked. The exemption sits where the filter is APPLIED rather than in
varying_guard_slots, so what the analysis reports as discriminating is unchanged
and only the serialization decision moves.
Test Plan:
The new test captures one example and asserts the captured call still serves
while a different batch, a different feature dim, a different rank and a
different dtype are each refused with "no captured variant" -- all four of which
previously either crashed inside a kernel or were served unchecked.
Authored with an AI assistant.
Differential Revision: D116840941