Repository navigation
[guards] Make the bound-method reducer a fixed point over its own output - #194966
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/194966
Note: Links to docs will display an error until the docs builds have been completed. ❌ 13 New Failures, 2 Unrelated FailuresAs of commit 234af16 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 26, 2026
Closed
Closed
This was referenced Aug 26, 2026
Closed
This was referenced Aug 28, 2026
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 twice aborts the capture when a bound method's receiver
was pruned:
The branch emits a bound method -- _unpickle_bound_method(func, method_self) --
and then decides, on a later pass, whether to take that branch again by READING
the receiver: getattr(method_self, func.name). Pruning replaces a receiver
no guard reaches with the _Missing sentinel, so the second pass reads the name
off a sentinel and dies. func.name is what supplies the "forward" in the
message; the _Missing is the method's self, not the value the path names.
Only torch.compiler.precompile's public path serializes twice: it sets
_prune_invariant_guards, so PrecompileSession.exit runs _apply_guard_policy,
which rebuilds each frame from the pickle capture already made, with
save_guards=True. The capture session's _drop_unrebuildable_guards probes
without save_guards and never re-pickles, so the same model captured fine there
and aborted here.
Decide from the receiver's FATE instead of reading it. When the receiver is, or
is about to become, the sentinel, carry the binding unconditionally. The branch
then reduces its own output to itself, which is the property the second pass
needs, and the reduction stops depending on the receiver resolving the name at
load -- which is a second bug: where the attribute was NOT shadowed the branch
fell through to pickle's default method reduce, (getattr, (self, name)), and
raised a raw unwrapped AttributeError out of pickle.loads on the serving
machine.
The method stays a real method. Degrading it to the sentinel instead also stops
the abort, and was the first thing I tried, but it re-pins a TYPE_MATCH on the
method to _Missing: the artifact captures, loads, and then matches no live
receiver ever again. An abort is better than a permanent silent serve-miss, so
the test asserts SERVING rather than capture -- that assertion is the only thing
that distinguishes the two fixes.
Nothing extra is retained: the receiver still ships as the sentinel, and only
the encoding of an already-serialized method changes.
Not the cause, but worth recording while it is fresh. The pruning invariant
holds -- get_guard_manager_from_source recurses into source.base, so a guard on
x.a.b registers x and x.a too, and a value on a guard's path is never pruned.
The receiver here is reached by no guard at all. Separately,
_prune_unguarded_attributes marking an exact list/dict/tuple/set is a silent
no-op, because CPython's C pickler never routes exact builtins through
reducer_override; that is why the method was in the pickle to begin with.
Test Plan:
test_precompile_serves_a_bound_method_whose_receiver_was_pruned is parametrized
over the eight shapes this family has -- receiver an nn.Module or a plain
object, the attribute shadowed or not, the saved method read by the region or
only carried -- and each one captures, loads, and is checked against eager.
Three abort on the unfixed tree and two more die in pickle.loads.
Authored with the assistance of an AI coding agent.