Repository navigation
[dynamo] Probe a bound method's function name inside the reducer's try, pin the dict-served case - #196764
[dynamo] Probe a bound method's function name inside the reducer's try, pin the dict-served case#196764bobrenjc93 wants to merge 6 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/196764
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 84cdcbe with merge base 0929b23 ( GREEN LIGHT - PR approved to be merged without human review:
reason: UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Claude finished @bobrenjc93's task in 17m 48s —— View job Reviewed: the reducer fix and the two new tests are correct, but the Full reviewPR Review: #196764SummaryMoves Code Quality
Testing
Verified as correct, for the record: the new I could not execute the test plan — this checkout has no built RecommendationApprove — the reducer fix is correct and each new test pins a real shape that was previously unguarded. Nothing here blocks landing; the |
… longer overflows on a deep list) [ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: inductor / unit-test / inductor-cpu-test / test (inductor_aoti_fallback, 2, 2, mt-l-x86iamx-8-64, unstable) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
Follow-up to the reviews of #196473 and #196474.
_reduce_bound_methodreadfunc.__name__before itstry.getattrwith adefault swallows only AttributeError, and
__func__is an arbitrary callableby the reducer's own premise, so a proxy that raises anything else escaped the
reducer while the receiver-side probe two lines down was already guarded:
The read moves inside the
try, after the__getattr__gate (which takes thepair without probing
funcat all), whereexplicitis already built for theexceptto return.The
__dict__half of the per-instance condition had no test:SlottedByNamehas no instance dict, so the slot test lands on the
getattr_statichalf, andablating the
__dict__clause left the suite green while the shape it existsfor broke at load:
Pinned now, and the comment says which receivers reach that clause: one that
HAS an instance dict, which a pure-slots receiver does not (a slotted subclass
of a non-slotted base has both, and either clause gives the same answer), and a
class defining
__getattr__(every nn.Module) takes the pair before it eitherway.
Two tests from #196474 were not pinning what they said. The shared-closure-cell
test used a
<locals>pair, whose branch returns before theguard_tree_valuesgate, so the dict it built was inert and the test passed on the parent; it now
uses two module-level
functools.wrapswrappers sharing one cell, which onlythe gate carries. The module-method test's comment described the
<locals>rebuild bug from the commit that fixed it; the comment is gone and the test
asserts the rebuilt function's
__name__isforward, which is a record ofwhat the rebuild carries rather than a regression guard (the name path is
pinned by
test_rebuilt_locals_function_keeps_its_name), so the comment nowpoints at the call as the assertion that catches the placeholder.
Type nits from the same reviews:
objectinstead ofAnyfor the resolutionwalk and both rebuilt scopes; the bound-method reducer returns its real shape,
tuple[Callable[..., Any], tuple[Any, ...]] | None; the state tuple staysAny, since its elements are assigned to typed function slots and the checkerrejects
objectthere.One #196474 comment is not a code change here: at that commit the by-value
payload carried every closure cell and default unconditionally, so a
wrapswrapper capturing a lock no guard read failed the dump. #196476, two commits
above it, prunes each cell and default through the same
guard_tree_valuestest, and that is where the prune lives in this stack.
Test Plan:
The proxy test fails on the previous commit with the RuntimeError above. Its
second case pins the ORDERING rather than the
try: the receiver is a proxywhose class defines
__getattr__, so the gate takes the pair and the name isnever asked for, which the fixture records; moving the read back above the gate
fails that assertion while the rest of the test stays green. The
monkeypatched-method test fails against the
__dict__clause ablated. Theshared-cell test fails when the fqn-mismatched pair is not in
guard_tree_values(both prune to_Missing), which the old<locals>paircould not show.
Authored with an AI assistant.
🤖 Generated with Claude Code
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98