Repository navigation
[dynamo] Name inlined code by the file that defines it - #195914
Closed
bobrenjc93 wants to merge 53 commits into
Closed
bobrenjc93 wants to merge 53 commits into
bobrenjc93 wants to merge 53 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195914
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Sep 3, 2026
Closed
Closed
Closed
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
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):
The source checksum a package records for an inlined code object was keyed on
inspect.getmodule(code).__name__, and that name is wrong in two ways.getmodule can hand back a module that merely re-exports the code from a
private implementation file that sets its own
__name__to the public name--
_collections_abc, whose__name__is "collections.abc", is the stdlibinstance -- so
SourceInfo.add_codecompared the code's line range against afile that does not contain it and aborted the capture with its Source mismatch
assertion. And that
__name__is not importable back to the same object: itimports to the shim. (On CPython 3.11+ the stdlib copy is frozen, co_filename
is
<frozen _collections_abc>and getmodule already returns None, so thechecksum is skipped either way; the fix matters on 3.10 and for any module that
uses the same rename idiom.)
_defining_module_namereturns the sys.modules KEY whose file iscode.co_filename, falling back to a memoized scan of sys.modules. A hit iscached for as long as the key still names a module with that file; a miss is
cached only while sys.modules has not changed size, because the usual reason
for one is that the module has not been imported yet, and caching that
permanently would silently drop the checksum for every lazily imported file.
SourceInfo.add_codeuses it and skips the checksum rather than record oneagainst the wrong file; the cold path of
CompilePackage.initializeuses itas the entry code's python_module and falls back to
fn.__module__when noloaded module owns the file.
Test Plan:
Authored with an AI assistant.
[no ci]