Repository navigation
[dynamo] Record the container edge on __defaults__ and instance mappings, not just the base object - #196480
[dynamo] Record the container edge on __defaults__ and instance mappings, not just the base object#196480bobrenjc93 wants to merge 2 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/196480
Note: Links to docs will display an error until the docs builds have been completed. ❌ 21 New Failures, 2 Cancelled JobsAs of commit e5d5d12 with merge base e67c870 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
[ghstack-poisoned]
|
Claude finished @bobrenjc93's task in 42m 38s —— View job Reviewed: the two container-edge repairs look correct and well-motivated, but the Full reviewPR Review: #196480SummaryRecords the container->element edge on the real container ( Code Quality1. The The only consumer of Worse, for the remaining Nothing in the diff tests this arm. Deleting lines 1754-1764 removes the dead type/module branches, the false-positive risk, and the comment defending it — leaving just the 2. The membership test should be an identity check, not a key check.
3. This is unconditional — it runs for every 4. The writer accepts dict subclasses; the reader treats any subclass as unconditionally verbatim and never consults the edge. Harmless today (a dead entry), but the mismatch invites a future reader to assume subclass mappings are pruned. 5. The two repairs are 250 lines apart. The 6. Docstring enumerates shapes that will rot. Testing7. Neither new test verifies that the guard still discriminates after the round trip. Both tests are only That leaves the direction this PR actually risks untested. The change makes containers get pruned per value where they previously went verbatim; the bug it could introduce is pruning too much — dropping the guarded Every sibling test for this machinery does check it: 8. Untested branches. As noted in (1), the RecommendationRequest Changes The two real repairs (the I could not run the test suite: |
|
Superseded by #196479, redesigned: instead of recording container-to-element edges per source, GuardBuilder.EQUALS_MATCH records the plain dict/tuple values it reads whole and a rebuilt function's container is carried verbatim only for those. That fixes the whole-tuple EQUALS_MATCH silent miss, the still-broken unread unpicklable default, and removes the annotations read that raised NameError on 3.14. |
Stack from ghstack (oldest at bottom):
The container->element edge keys on
id(base_example_value). Two ordinaryshapes put the guarded element's REAL container somewhere else, so the edge
missed and
_keep_container_verbatimcarried the container whole with itsunpicklable sibling:
DefaultsSource,def forward(self, x, scale=2.0, junk=threading.Lock())called withoutscale) has the FUNCTIONas its base, while the whole-tuple SEQUENCE_LENGTH guard registers the
__defaults__tuple itself. Record the edge on the__defaults__/__kwdefaults__container too.func.tagrecords its edge onfunc, while a guard thatreads the whole
func.__dict__(DunderDictVariable registersAttrSource(base, "__dict__")) makes the mapping_keep. Record the edge onthe instance
__dict__that holds the attribute, and on__annotations__only when the base is a type, routine or module, since reading it off an
arbitrary instance would key on the class dict and can run a user
__getattr__.Neither shape is reachable through
_test_serialization, whose guard filterdrops the whole-container guard so the container is never
_keepto beginwith; the two new tests drive a real
torch.compileundercaching_precompileinstead.
Test Plan:
Both error on the previous commit with
PackageError: TypeError: cannot pickle '_thread.lock' object.Authored with an AI assistant.