Skip to content

Remove unreachable test_direct_mapped_lxu_cache_lookup_large_grid#5900

Closed
q10 wants to merge 2 commits into
pytorch:mainfrom
q10:export-D108559251
Closed

Remove unreachable test_direct_mapped_lxu_cache_lookup_large_grid#5900
q10 wants to merge 2 commits into
pytorch:mainfrom
q10:export-D108559251

Conversation

@q10

@q10 q10 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary:
test_direct_mapped_lxu_cache_lookup_large_grid (added by D105286434)
tests an unreachable code path and fails on ROCm in OSS CI
(see P2378802042).

direct_mapped_lxu_cache_lookup_kernel takes linear_cache_indices
as a PackedTensorAccessor32 (lxu_cache.cu:326,530). Building a 32-bit
accessor runs validate_tensor, which TORCH_CHECKs
numel < INT32_MAX (~2.1B). The test passes N = 2**32 + 1 (~4.3B) to
try to exceed HIP's 2**32 thread-per-launch limit, but the accessor
rejects the tensor at ~2.1B elements, before the kernel launch is ever
reached:

RuntimeError: lxu_cache.hip(538): direct_mapped_lxu_cache_lookup_kernel:
Tensor 'linear_cache_indices' numel needs to be smaller than int32_t
max; otherwise, please use [packed_]accessor64

So the host-side grid cap added by D105286434
(cap_grid_dim_x_from_workload) is unreachable on this kernel: any N
large enough to need it (>= 232) is rejected by the 32-bit accessor
(>= 2
31) first. The regression test therefore cannot validate
anything and only breaks ROCm CI.

This mirrors the abandoned D105202994 (delinearize_unique_index_kernel),
which had the identical PackedTensorAccessor32 INT32_MAX limitation.

Removes the test and its now-unused gpu_memory_lt_gb import. No
production change; the cap is left in place (harmless, and correct once
the accessor is upgraded to 64-bit).

Differential Revision: D108559251

q10 added 2 commits June 14, 2026 18:14
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.

Differential Revision: D108540654
Summary:
`test_direct_mapped_lxu_cache_lookup_large_grid` (added by D105286434)
tests an unreachable code path and fails on ROCm in OSS CI
(see P2378802042).

`direct_mapped_lxu_cache_lookup_kernel` takes `linear_cache_indices`
as a `PackedTensorAccessor32` (lxu_cache.cu:326,530). Building a 32-bit
accessor runs `validate_tensor`, which TORCH_CHECKs
`numel < INT32_MAX` (~2.1B). The test passes `N = 2**32 + 1` (~4.3B) to
try to exceed HIP's 2**32 thread-per-launch limit, but the accessor
rejects the tensor at ~2.1B elements, before the kernel launch is ever
reached:

  RuntimeError: lxu_cache.hip(538): direct_mapped_lxu_cache_lookup_kernel:
  Tensor 'linear_cache_indices' numel needs to be smaller than int32_t
  max; otherwise, please use [packed_]accessor64

So the host-side grid cap added by D105286434
(`cap_grid_dim_x_from_workload`) is unreachable on this kernel: any N
large enough to need it (>= 2**32) is rejected by the 32-bit accessor
(>= 2**31) first. The regression test therefore cannot validate
anything and only breaks ROCm CI.

This mirrors the abandoned D105202994 (delinearize_unique_index_kernel),
which had the identical PackedTensorAccessor32 INT32_MAX limitation.

Removes the test and its now-unused `gpu_memory_lt_gb` import. No
production change; the cap is left in place (harmless, and correct once
the accessor is upgraded to 64-bit).

Differential Revision: D108559251
@meta-cla meta-cla Bot added the cla signed label Jun 15, 2026
@meta-codesync

meta-codesync Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108559251.

q10 added a commit to q10/FBGEMM that referenced this pull request Jun 15, 2026
…torch#5900)

Summary:
X-link: facebookresearch/FBGEMM#2821


`test_direct_mapped_lxu_cache_lookup_large_grid` (added by D105286434)
tests an unreachable code path and fails on ROCm in OSS CI
(see P2378802042).

`direct_mapped_lxu_cache_lookup_kernel` takes `linear_cache_indices`
as a `PackedTensorAccessor32` (lxu_cache.cu:326,530). Building a 32-bit
accessor runs `validate_tensor`, which TORCH_CHECKs
`numel < INT32_MAX` (~2.1B). The test passes `N = 2**32 + 1` (~4.3B) to
try to exceed HIP's 2**32 thread-per-launch limit, but the accessor
rejects the tensor at ~2.1B elements, before the kernel launch is ever
reached:

  RuntimeError: lxu_cache.hip(538): direct_mapped_lxu_cache_lookup_kernel:
  Tensor 'linear_cache_indices' numel needs to be smaller than int32_t
  max; otherwise, please use [packed_]accessor64

So the host-side grid cap added by D105286434
(`cap_grid_dim_x_from_workload`) is unreachable on this kernel: any N
large enough to need it (>= 2**32) is rejected by the 32-bit accessor
(>= 2**31) first. The regression test therefore cannot validate
anything and only breaks ROCm CI.

This mirrors the abandoned D105202994 (delinearize_unique_index_kernel),
which had the identical PackedTensorAccessor32 INT32_MAX limitation.

Removes the test and its now-unused `gpu_memory_lt_gb` import. No
production change; the cap is left in place (harmless, and correct once
the accessor is upgraded to 64-bit).

Reviewed By: henrylhtsang

Differential Revision: D108559251
@meta-codesync meta-codesync Bot closed this in 1864530 Jun 15, 2026
@meta-codesync meta-codesync Bot added the Merged label Jun 15, 2026
@meta-codesync

meta-codesync Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 1864530.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants