Fix test_lru_cache_insert_large_grid associativity on ROCm wavefront64#5899
Closed
q10 wants to merge 1 commit into
Closed
Fix test_lru_cache_insert_large_grid associativity on ROCm wavefront64#5899q10 wants to merge 1 commit into
q10 wants to merge 1 commit into
Conversation
Summary:
`test_lru_cache_insert_large_grid` (added by D105282095) hardcodes the LXU
cache associativity as `32`. The split-embeddings LXU cache is set-associative
with associativity == warp size == `DEFAULT_ASSOC` (32 on NVIDIA, 64 on AMD).
On AMD wavefront64 (gfx942 / MI300) `lru_cache_insert_kernel` strides cache
rows by `kWarpSize = 64` and writes `lxu_cache_state` / `lxu_cache_weights` /
`lru_state` for `slot` in `[0, 64)`, indexing past the 32-wide test
allocations -> out-of-bounds -> non-deterministic memory corruption ->
flaky `assertEqual(lru_state != time_stamp, 0)` failures in OSS ROCm CI
(see P2378242263). On NVIDIA (32 == 32) the allocation matches the kernel,
so the test passed.
Fix (test-only; no kernel/production change):
- Size the three cache tensors and assertions by `DEFAULT_ASSOC` instead of
the literal `32`, matching the established pattern in `lxu_cache_test.py`
and `nbit_cache_test.py`, so the allocation width matches the kernel's
`kWarpSize` associativity on both platforms.
- Fix `torch.accelerator.current_accelerator("cuda")` -> `current_accelerator()`
(the string was silently coerced to `check_available=True`; flagged by
ai_diff_reviewer).
- Generalize the docstring's NVIDIA-specific (32) grid math.
Differential Revision: D108540654
Contributor
|
@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108540654. |
q10
added a commit
to q10/FBGEMM
that referenced
this pull request
Jun 15, 2026
pytorch#5899) Summary: `test_lru_cache_insert_large_grid` (added by D105282095) hardcodes the LXU cache associativity as `32`. The split-embeddings LXU cache is set-associative with associativity == warp size == `DEFAULT_ASSOC` (32 on NVIDIA, 64 on AMD). On AMD wavefront64 (gfx942 / MI300) `lru_cache_insert_kernel` strides cache rows by `kWarpSize = 64` and writes `lxu_cache_state` / `lxu_cache_weights` / `lru_state` for `slot` in `[0, 64)`, indexing past the 32-wide test allocations -> out-of-bounds -> non-deterministic memory corruption -> flaky `assertEqual(lru_state != time_stamp, 0)` failures in OSS ROCm CI (see P2378242263). On NVIDIA (32 == 32) the allocation matches the kernel, so the test passed. Fix (test-only; no kernel/production change): - Size the three cache tensors and assertions by `DEFAULT_ASSOC` instead of the literal `32`, matching the established pattern in `lxu_cache_test.py` and `nbit_cache_test.py`, so the allocation width matches the kernel's `kWarpSize` associativity on both platforms. - Fix `torch.accelerator.current_accelerator("cuda")` -> `current_accelerator()` (the string was silently coerced to `check_available=True`; flagged by ai_diff_reviewer). - Generalize the docstring's NVIDIA-specific (32) grid math. Reviewed By: henrylhtsang Differential Revision: D108540654
Contributor
|
This pull request has been merged in 5fd50d1. |
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:
test_lru_cache_insert_large_grid(added by D105282095) hardcodes the LXUcache associativity as
32. The split-embeddings LXU cache is set-associativewith associativity == warp size ==
DEFAULT_ASSOC(32 on NVIDIA, 64 on AMD).On AMD wavefront64 (gfx942 / MI300)
lru_cache_insert_kernelstrides cacherows by
kWarpSize = 64and writeslxu_cache_state/lxu_cache_weights/lru_stateforslotin[0, 64), indexing past the 32-wide testallocations -> out-of-bounds -> non-deterministic memory corruption ->
flaky
assertEqual(lru_state != time_stamp, 0)failures in OSS ROCm CI(see P2378242263). On NVIDIA (32 == 32) the allocation matches the kernel,
so the test passed.
Fix (test-only; no kernel/production change):
DEFAULT_ASSOCinstead ofthe literal
32, matching the established pattern inlxu_cache_test.pyand
nbit_cache_test.py, so the allocation width matches the kernel'skWarpSizeassociativity on both platforms.torch.accelerator.current_accelerator("cuda")->current_accelerator()(the string was silently coerced to
check_available=True; flagged byai_diff_reviewer).
Differential Revision: D108540654