Repository navigation
[dynamo] Revalidate a memoized module-by-file hit before handing it back - #194952
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/194952
Note: Links to docs will display an error until the docs builds have been completed. ❌ 17 New Failures, 1 Unrelated FailureAs of commit 577104b 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 25, 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):
_scan_sys_modules_for_file caches a hit outright and re-scans a miss only while
len(sys.modules) is unchanged. That length is an ABA check rather than a
version, so a plain
del sys.modules[m]with no re-import is invisible to it,and the memo kept handing back a name that no longer resolved. SourceInfo.
add_code indexes sys.modules with it directly and raised KeyError on the dead
name -- a hazard the function's own docstring described.
A cached hit is now checked against sys.modules before it is returned, for one
dict lookup rather than the O(len(sys.modules)) scan the memo exists to avoid.
A stale hit falls through and re-scans, so the miss path stays as it was.
Test Plan:
test_precompile_stale_module_memo_is_revalidated imports a temp module, scans
it, deletes it from sys.modules without re-importing, and calls add_code. It
raises KeyError unfixed.
Authored with the assistance of an AI coding agent.