Commit 5fd50d1
Fix test_lru_cache_insert_large_grid associativity on ROCm wavefront64 (#5899)
Summary:
Pull Request resolved: #5899
`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
fbshipit-source-id: ccdcc7d18b64dadfe78abd38b353e3bcd8e2ef841 parent 0fb6911 commit 5fd50d1
1 file changed
Lines changed: 20 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
1041 | 1042 | | |
1042 | 1043 | | |
1043 | 1044 | | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1048 | 1051 | | |
1049 | 1052 | | |
1050 | 1053 | | |
| |||
1055 | 1058 | | |
1056 | 1059 | | |
1057 | 1060 | | |
1058 | | - | |
| 1061 | + | |
1059 | 1062 | | |
1060 | 1063 | | |
1061 | 1064 | | |
| |||
1071 | 1074 | | |
1072 | 1075 | | |
1073 | 1076 | | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
1074 | 1081 | | |
1075 | 1082 | | |
1076 | | - | |
| 1083 | + | |
1077 | 1084 | | |
1078 | 1085 | | |
1079 | 1086 | | |
1080 | 1087 | | |
1081 | | - | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
1082 | 1092 | | |
1083 | | - | |
1084 | 1093 | | |
1085 | 1094 | | |
1086 | 1095 | | |
| |||
1102 | 1111 | | |
1103 | 1112 | | |
1104 | 1113 | | |
1105 | | - | |
1106 | | - | |
| 1114 | + | |
| 1115 | + | |
1107 | 1116 | | |
1108 | 1117 | | |
1109 | 1118 | | |
1110 | 1119 | | |
1111 | 1120 | | |
1112 | | - | |
| 1121 | + | |
1113 | 1122 | | |
1114 | 1123 | | |
1115 | 1124 | | |
| |||
0 commit comments