Skip to content

Commit 618a551

Browse files
okakarpajataylo
andauthored
[AUTOGENERATED] [release/2.5] [release/2.7] [SWDEV-543214] Reland #2416 Fix warps runtime part 2 (#2452)
Cherry-pick of #2442 --------- Co-authored-by: Jack Taylor <[email protected]>
1 parent da9b5e3 commit 618a551

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

torch/_inductor/runtime/coordinate_descent_tuner.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import itertools
44
import logging
55
from typing import Callable, Optional
6+
from functools import lru_cache
67

78
from .hints import TRITON_MAX_BLOCK
89
from .runtime_utils import red_text, triton_config_to_hashable
@@ -69,10 +70,16 @@ def get_config_max(self, prefix: str) -> int:
6970
size_hint = self.prefix_to_size_hint(prefix)
7071
return min(max_block, size_hint) if size_hint is not None else max_block
7172

73+
@lru_cache(maxsize=1)
7274
def get_warpsmax(self):
73-
# Currently, CUDA has a maximum of 1024 threads, so 32 is the max
74-
# number of warps.
75-
return 1024 // 32
75+
# CUDA/ROCm has a maximum of 1024 threads per block
76+
from torch.cuda import current_device, get_device_properties, is_available
77+
78+
warp_size = (
79+
get_device_properties(current_device()).warp_size if is_available() else 32
80+
)
81+
82+
return 1024 // warp_size
7683

7784
def cache_benchmark_result(self, config, timing):
7885
self.cached_benchmark_results[triton_config_to_hashable(config)] = timing

0 commit comments

Comments
 (0)