Repository navigation
FIX invalidate AvgPool2dWithConv cache on exact device changes - #1217
Merged
bruAristimunha merged 6 commits intoOct 5, 2026
Merged
bruAristimunha merged 6 commits into
bruAristimunha merged 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1217 +/- ##
==========================================
+ Coverage 87.84% 87.96% +0.12%
==========================================
Files 151 151
Lines 17602 17609 +7
==========================================
+ Hits 15462 15490 +28
+ Misses 2140 2119 -21 🚀 New features to boost your workflow:
|
Resolved docs/whats_new.rst by keeping both changelog entries.
Resolved docs/whats_new.rst by keeping both changelog entries.
bruAristimunha
approved these changes
Oct 5, 2026
bruAristimunha
left a comment
Collaborator
There was a problem hiding this comment.
Thanks. Reproduced the stale-cache bug on master; exact-device invalidation verified; default outputs unchanged. Import order fixed for ruff.
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.
Summary
Fix
AvgPool2dWithConvso its cached averaging kernel is reused only when shape, dtype, and the exact device still match the current input.The current cache validity check compares only
is_cudaand tensor type. That treatscuda:0andcuda:1as equivalent, so a module moved between CUDA devices can reuse a stale cached kernel and fail insideconv2dwith a device mismatch. The same coarse distinction can also be wrong for non-CUDA backends.Fix
self._pool_weights.device == x.device;.to(device=x.device, dtype=x.dtype).Regression coverage
Adds tests that:
AvgPool2dWithConvremains numerically equivalent toavg_pool2d;cuda:0fromcuda:1at the cache-validity boundary without requiring a CUDA runner.This is a narrow cache-correctness fix; pooling semantics and the public API are unchanged.