Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-129_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies:
- nltk
- numba-cuda>=0.22.2,<0.29.0
- numba>=0.60.0,<0.65.0
- numpy>=1.23,<3.0
- numpy>=1.26,<3.0
- numpydoc
- numpydoc<1.9
- nvidia-ml-py>=12
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-129_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies:
- nltk
- numba-cuda>=0.22.2,<0.29.0
- numba>=0.60.0,<0.65.0
- numpy>=1.23,<3.0
- numpy>=1.26,<3.0
- numpydoc
- numpydoc<1.9
- nvidia-ml-py>=12
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-132_arch-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies:
- nltk
- numba-cuda>=0.22.2,<0.29.0
- numba>=0.60.0,<0.65.0
- numpy>=1.23,<3.0
- numpy>=1.26,<3.0
- numpydoc
- numpydoc<1.9
- nvidia-ml-py>=12
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-132_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies:
- nltk
- numba-cuda>=0.22.2,<0.29.0
- numba>=0.60.0,<0.65.0
- numpy>=1.23,<3.0
- numpy>=1.26,<3.0
- numpydoc
- numpydoc<1.9
- nvidia-ml-py>=12
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/cuml/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ requirements:
- libcuml =${{ version }}
- numba >=0.60.0,<0.65.0
- numba-cuda >=0.22.2,<0.29.0
- numpy >=1.23,<3.0
- numpy >=1.26,<3.0
- scikit-learn >=1.4
- scipy >=1.14.0
- packaging
Expand Down
3 changes: 2 additions & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ dependencies:
packages:
- joblib>=0.11
- numba>=0.60.0,<0.65.0
- &numpy numpy>=1.23,<3.0
- &numpy numpy>=1.26,<3.0
- scipy>=1.14.0
- packaging
- rich
Expand Down Expand Up @@ -530,6 +530,7 @@ dependencies:
- scikit-learn==1.5.0
- umap-learn==0.5.7
- hdbscan==0.8.39
- numpy==1.26
- matrix: {dependencies: "intermediate"}
packages:
- scikit-learn==1.7.2
Expand Down
29 changes: 19 additions & 10 deletions python/cuml/cuml/internals/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def check_all_finite(array, *, allow_nan=False, input_name=None) -> None:
input_name : str or None, default=None
The input parameter name to use in error messages.
"""
if not np.isdtype(array.dtype, "real floating"):
if not array.dtype.kind == "f":
# No-op for non floating inputs
return

Expand Down Expand Up @@ -484,6 +484,19 @@ def _index_as_mem_type(index, mem_type=None):
return index


if np.lib.NumpyVersion(np.__version__) >= "2.0.0b1":
np_asarray = np.asarray
else:

def np_asarray(x, dtype=None, order=None, copy=None):
"""A compatibility shim for `np.asarray`.

numpy 2.0 added the `copy` arg to `np.asarray`, as well as changed the
meaning of copy=False to "error if a copy required" rather than "only
copy if needed" (which is now `copy=None`)."""
return np.array(x, dtype=dtype, order=order or "K", copy=bool(copy))


def check_array(
array,
*,
Expand Down Expand Up @@ -600,7 +613,7 @@ def check_array(
# Infer proper output dtype
if array_dtype is not None:
# Check for complex inputs before conversion when possible
if np.isdtype(array_dtype, "complex floating"):
if array_dtype.kind == "c":
raise ValueError("Complex data not supported")
if dtype is None:
dtype = array_dtype
Expand Down Expand Up @@ -703,7 +716,7 @@ def check_array(
elif (
mem_type is None
and cudf.pandas.LOADED
and np.isdtype(array.dtype, ("numeric", "bool"))
and array.dtype.kind in "iufb"
):
# We treat pandas objects with supported dtypes as device
# memory when running under cudf.pandas. Note that the output
Expand Down Expand Up @@ -732,8 +745,7 @@ def check_array(
array, dtype=dtype, order=order, copy=(copy or None)
)
else:
# XXX: using np.array for compat with numpy < 2
array = np.array(
array = np_asarray(
array, dtype=dtype, order=order, copy=(copy or None)
)

Expand Down Expand Up @@ -761,7 +773,7 @@ def check_array(
)

# Check for complex inputs after conversion for cases when `dtype=None`
if np.isdtype(array.dtype, "complex floating"):
if array.dtype.kind == "c":
raise ValueError("Complex data not supported")

# Validate data meets expected value requirements
Expand Down Expand Up @@ -1052,10 +1064,7 @@ def check_y(
input_dtype = y.dtype
if mem_type is None:
mem_type = "host" if isinstance(y, np.ndarray) else "device"
if (
np.isdtype(y.dtype, ("numeric", "bool"))
and return_classes is True
):
if y.dtype.kind in "iufb" and return_classes is True:
y = cp.asarray(y)
elif (
y.dtype == "object"
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/linear_model/linear_regression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class LinearRegression(Base,
)

# All libcuml solvers require F-ordered X, and mutate the inputs.
X = cp.asarray(X, order="F", copy=None if may_mutate_X else True)
X = cp.array(X, order="F", copy=None if may_mutate_X else True)
if not may_mutate_y:
y = y.copy()
if sample_weight is not None and not may_mutate_sample_weight:
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/linear_model/ridge.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class Ridge(Base,
# The `eig` solver requires X be F-contiguous. Additionally, all inputs
# are mutated when weighted or `fit_intercept=True`.
mutates = self.fit_intercept or sample_weight is not None
X = cp.asarray(X, order="F", copy=True if mutates and not may_mutate_X else None)
X = cp.array(X, order="F", copy=True if mutates and not may_mutate_X else None)
if mutates and not may_mutate_y:
y = y.copy()
if sample_weight is not None and mutates and not may_mutate_sample_weight:
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dependencies = [
"libcuml==26.6.*,>=0.0.0a0",
"numba-cuda>=0.22.2,<0.29.0",
"numba>=0.60.0,<0.65.0",
"numpy>=1.23,<3.0",
"numpy>=1.26,<3.0",
"nvidia-nvjitlink>=13.0,<14",
"packaging",
"pylibraft==26.6.*,>=0.0.0a0",
Expand Down
6 changes: 6 additions & 0 deletions python/cuml/tests/explainer/test_gpu_treeshap.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ def count_categorical_split(tl_model):
)
def test_xgb_regressor(objective):
xgb = pytest.importorskip("xgboost")
pytest.importorskip(
"numpy", minversion="2.0", reason="Test fails on numpy < 2"
)

n_samples = 100
X, y = make_regression(
Expand Down Expand Up @@ -197,6 +200,9 @@ def test_xgb_regressor(objective):
)
def test_xgb_classifier(objective, n_classes):
xgb = pytest.importorskip("xgboost")
pytest.importorskip(
"numpy", minversion="2.0", reason="Test fails on numpy < 2"
)

n_samples = 100
X, y = make_classification(
Expand Down
5 changes: 3 additions & 2 deletions python/cuml/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,9 @@ def test_check_array_dataframe_mixed_dtypes(kind, mem_type):
)
# Non-numeric columns -> object dtype by default
if is_cuda_output(mem_type, df):
# cupy doesn't support object dtypes
with pytest.raises((ValueError, TypeError), match="object"):
# cupy doesn't support object dtypes. We don't care what the exception
# is here, just that one is raised.
with pytest.raises(Exception, match="object"):
check_array(df, mem_type=mem_type)
else:
# dtype=None does no conversion by default
Expand Down
Loading