Skip to content

Commit 0de0530

Browse files
committed
Merge with recent commits to master
2 parents 1dbe54b + ea29129 commit 0de0530

7 files changed

Lines changed: 21 additions & 20 deletions

File tree

kernel_tuner/strategies/bayes_opt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def get_hyperparam(name: str, default, supported_values=list()):
238238
self.invalid_value = 1e20
239239
self.opt_direction = opt_direction
240240
if opt_direction == "min":
241-
self.worst_value = np.PINF
241+
self.worst_value = np.inf
242242
self.argopt = np.argmin
243243
elif opt_direction == "max":
244244
self.worst_value = np.NINF
@@ -265,7 +265,7 @@ def get_hyperparam(name: str, default, supported_values=list()):
265265
self.__visited_num = 0
266266
self.__visited_valid_num = 0
267267
self.__visited_searchspace_indices = [False] * self.searchspace_size
268-
self.__observations = [np.NaN] * self.searchspace_size
268+
self.__observations = [np.nan] * self.searchspace_size
269269
self.__valid_observation_indices = [False] * self.searchspace_size
270270
self.__valid_params = list()
271271
self.__valid_observations = list()
@@ -314,7 +314,7 @@ def is_not_visited(self, index: int) -> bool:
314314

315315
def is_valid(self, observation: float) -> bool:
316316
"""Returns whether an observation is valid."""
317-
return not (observation is None or observation == self.invalid_value or observation == np.NaN)
317+
return not (observation is None or observation == self.invalid_value or observation == np.nan)
318318

319319
def get_af_by_name(self, name: str):
320320
"""Get the basic acquisition functions by their name."""

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ classifiers = [
5050
# ATTENTION: if anything is changed here, run `poetry update`
5151
requires-python = ">=3.10,<4" # <4 is because of hip-python # NOTE when changing the Python versions, also change the test versions in the Noxfile and GitHub Actions
5252
dependencies = [
53-
"numpy (>=1.26.0,<2.0.0)", # Python 3.12 requires numpy at least 1.26, CuPy does not support 2.0
54-
"scipy>=1.14.1",
53+
"numpy>=2.0.0",
54+
"scipy>=1.14.1", # Python >=3.13 needs scipy >=1.14
5555
"packaging", # required by file_utils
5656
"jsonschema",
5757
"python-constraint2>=2.2.2",
@@ -153,4 +153,4 @@ select = [
153153
"D", # pydocstyle,
154154
]
155155
[tool.ruff.pydocstyle]
156-
convention = "google"
156+
convention = "google"

test/context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555

5656
try:
5757
from hip import hip
58+
hip.hipDriverGetVersion()
5859
hip_present = True
59-
except ImportError:
60+
except (ImportError, RuntimeError):
6061
hip_present = False
6162

6263
try:
@@ -84,7 +85,7 @@
8485
)
8586
skip_if_no_openmp = pytest.mark.skipif(not openmp_present, reason="No OpenMP found")
8687
skip_if_no_openacc = pytest.mark.skipif(not openacc_present, reason="No nvc++ on PATH")
87-
skip_if_no_pyhip = pytest.mark.skipif(not hip_present, reason="No HIP Python found")
88+
skip_if_no_hip = pytest.mark.skipif(not hip_present, reason="No HIP Python found or no HIP device detected")
8889
skip_if_no_methodology = pytest.mark.skipif(not methodology_present, reason="Autotuning Methodology not found")
8990

9091

test/strategies/test_bayesian_optimization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_bo_initialization():
7474
assert BO.searchspace == pruned_parameter_space
7575
assert BO.unvisited_cache == pruned_parameter_space
7676
assert len(BO.observations) == len(pruned_parameter_space)
77-
assert BO.current_optimum == np.PINF
77+
assert BO.current_optimum == np.inf
7878

7979
def test_bo_initial_sample_lhs():
8080
sample = BO.draw_latin_hypercube_samples(num_samples=1)

test/test_file_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from kernel_tuner.file_utils import get_input_file, output_file_schema, store_metadata_file, store_output_file
1515
from kernel_tuner.util import delete_temp_file, check_argument_list
16-
from .context import skip_if_no_pyhip
16+
from .context import skip_if_no_hip
1717

1818
from .test_runners import cache_filename, env, tune_kernel # noqa: F401
1919

@@ -80,7 +80,7 @@ def hip_check(call_result):
8080
raise RuntimeError(str(err))
8181
return result
8282

83-
@skip_if_no_pyhip
83+
@skip_if_no_hip
8484
def test_check_argument_list_device_array():
8585
"""Test check_argument_list with DeviceArray"""
8686
float_kernel = """

test/test_hip_functions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from kernel_tuner.backends import hip as kt_hip
77
from kernel_tuner.core import KernelInstance, KernelSource
88

9-
from .context import skip_if_no_pyhip
9+
from .context import skip_if_no_hip
1010

1111
try:
1212
from hip import hip, hiprtc
@@ -48,7 +48,7 @@ def env():
4848

4949
return ["vector_add", kernel_string, size, args, tune_params]
5050

51-
@skip_if_no_pyhip
51+
@skip_if_no_hip
5252
def test_ready_argument_list():
5353
size = 1000
5454
a = np.int32(75)
@@ -67,7 +67,7 @@ def test_ready_argument_list():
6767
assert gpu_args[1].value == a
6868
assert gpu_args[3].value == c
6969

70-
@skip_if_no_pyhip
70+
@skip_if_no_hip
7171
def test_compile():
7272
kernel_string = """
7373
__global__ void vector_add(float *c, float *a, float *b, int n) {
@@ -87,7 +87,7 @@ def test_compile():
8787
except Exception as e:
8888
pytest.fail("Did not expect any exception:" + str(e))
8989

90-
@skip_if_no_pyhip
90+
@skip_if_no_hip
9191
def test_memset_and_memcpy_dtoh():
9292
a = [1, 2, 3, 4]
9393
x = np.array(a).astype(np.int8)
@@ -101,7 +101,7 @@ def test_memset_and_memcpy_dtoh():
101101

102102
assert all(output == np.full(4, 4))
103103

104-
@skip_if_no_pyhip
104+
@skip_if_no_hip
105105
def test_memcpy_htod():
106106
a = [1, 2, 3, 4]
107107
x = np.array(a).astype(np.float32)
@@ -114,7 +114,7 @@ def test_memcpy_htod():
114114

115115
assert all(output == x)
116116

117-
@skip_if_no_pyhip
117+
@skip_if_no_hip
118118
def test_copy_constant_memory_args():
119119
kernel_string = """
120120
__constant__ float my_constant_data[100];
@@ -147,7 +147,7 @@ def test_copy_constant_memory_args():
147147

148148
assert (my_constant_data == output).all()
149149

150-
@skip_if_no_pyhip
150+
@skip_if_no_hip
151151
def test_smem_args(env):
152152
result, _ = tune_kernel(*env,
153153
smem_args=dict(size="block_size_x*4"),

test/test_observers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
skip_if_no_cupy,
1111
skip_if_no_opencl,
1212
skip_if_no_pycuda,
13-
skip_if_no_pyhip,
13+
skip_if_no_hip,
1414
skip_if_no_pynvml,
1515
)
1616
from .test_hip_functions import env as env_hip # noqa: F401
@@ -68,7 +68,7 @@ def test_register_observer_opencl(env_opencl):
6868
assert err.errisinstance(NotImplementedError)
6969
assert "OpenCL" in str(err.value)
7070

71-
@skip_if_no_pyhip
71+
@skip_if_no_hip
7272
def test_register_observer_hip(env_hip):
7373
with raises(NotImplementedError) as err:
7474
kernel_tuner.tune_kernel(*env_hip, observers=[RegisterObserver()], lang='HIP')

0 commit comments

Comments
 (0)