Repository navigation
[inductor] Stop caching op packet names in kernel metadata - #200953
anijain2305 wants to merge 1 commit into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/200953
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 75ea782 with merge base 207451c ( 🟢 GREEN LIGHT - PR approved to be merged without human review:
reason: 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. |
|
@claude review this PR |
|
Claude finished @anijain2305's task in 29s —— View job The cache removal looks correct and I found nothing blocking. The one open question is whether to also fix the underlying copy problem in DetailsPR Review: #200953SummaryThe PR removes the I checked the PR's reasoning against
Nothing else references Code Quality
RecommendationApprove. This is a small removal of a cache that wasn't working, with a large measured compile-time win. No test is needed because behavior doesn't change. Please consider the |
|
Starting merge as part of PR stack under #200954 |
1 similar comment
|
Starting merge as part of PR stack under #200954 |
`OpOverload`, `OpOverloadPacket` and `HigherOrderOperator` define `__deepcopy__` to return `self` because each must be unique, but they did not define `__copy__`. A shallow copy therefore built a new instance: - FX copies node metadata such as `original_aten` with `copy.copy` when tracing with preserved node meta, so every node traced by AOTAutograd carried its own copy of its op. The copies hash like the op but compare unequal, which defeats any cache or identity check keyed on the op. - `copy.copy(torch.ops.aten.add)` never finished: the half-built packet's `__getattr__` and `__str__` recursed through each other. Return `self` from `__copy__`, matching `__deepcopy__`. Pull Request resolved: #200954 Approved by: https://github.com/pytorchgreenlight ghstack dependencies: #200953
Stack from ghstack (oldest at bottom):
https://www.internalfb.com/intern/paste/P2550697715/
#194010 memoized
str(op._overloadpacket)inget_kernel_metadatawith anlru_cachekeyed on theOpOverload, assuming ops are singletons. They arenot in
node.meta["original_aten"]: FX copies that field withcopy.copy,and
OpOverloaddefines__deepcopy__but not__copy__, so every tracednode carries its own copy of its op. The copies hash alike but compare
unequal, so the cache fills with colliding keys and almost always misses.
On a large training backward graph (1,544 kernels, up to 2,699
origin nodes per kernel) the cache recorded 2.53M misses and 18.8K hits, and
get_kernel_metadatatook 98s of a 293s cold compile. Computing the stringdirectly costs about 0.25us; with this change the function takes 2.5s and the
compile 201s.
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo