Skip to content

Numpy 1.x compatibility fixes - #8118

Merged
rapids-bot[bot] merged 6 commits into
NVIDIA:release/26.06from
jcrist:numpy-1-compat
May 15, 2026
Merged

Numpy 1.x compatibility fixes#8118
rapids-bot[bot] merged 6 commits into
NVIDIA:release/26.06from
jcrist:numpy-1-compat

Conversation

@jcrist

@jcrist jcrist commented May 15, 2026

Copy link
Copy Markdown
Member

This:

  • Bumps our minimum supported numpy version to 1.26, to match that of cudf. Since cudf is a required dependency, we were effectively pinned at that already.
  • Adds numpy to our oldest deps test runs. This also effectively adds cupy==13.6, since cupy==14 requires numpy>=2.0. Explicitly specifying cupy==13.6 in an oldest-deps run is tricky since the pypi packages require cuda suffixes as well. I'm skipping that for now.
  • Fixes a few incompatibilities with numpy 1.x

@jcrist jcrist self-assigned this May 15, 2026
@jcrist
jcrist requested a review from a team as a code owner May 15, 2026 17:48
@jcrist jcrist added the improvement Improvement / enhancement to an existing function label May 15, 2026
@jcrist
jcrist requested a review from a team as a code owner May 15, 2026 17:48
@jcrist jcrist added the non-breaking Non-breaking change label May 15, 2026
@jcrist
jcrist requested review from betatim and gforsyth May 15, 2026 17:48
@github-actions github-actions Bot added conda conda issue Cython / Python Cython or Python issue labels May 15, 2026
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR raises the NumPy minimum to 1.26 across packaging and CI, implements NumPy 2.x-compatible dtype handling in validation (using dtype.kind and a np_asarray shim), updates CuPy array construction in linear solvers to align copy semantics, and adapts tests/skips accordingly.

Changes

NumPy 1.26 minimum and 2.x compatibility

Layer / File(s) Summary
Dependency version updates and test matrix configuration
conda/environments/all_cuda-129_arch-aarch64.yaml, conda/environments/all_cuda-129_arch-x86_64.yaml, conda/environments/all_cuda-132_arch-aarch64.yaml, conda/environments/all_cuda-132_arch-x86_64.yaml, conda/recipes/cuml/recipe.yaml, python/cuml/pyproject.toml, dependencies.yaml
All packaging/CI files updated to require numpy>=1.26,<3.0. dependencies.yaml also adds an explicit numpy==1.26 pin for the oldest test Python configuration.
NumPy 2.x dtype compatibility in validation module
python/cuml/cuml/internals/validation.py
Validation logic switched from np.isdtype() to dtype.kind checks; check_all_finite now only runs for float (kind == "f"), complex rejection uses kind == "c", pandas/device handling uses kind in "iufb", and a NumPy-version-dependent np_asarray shim preserves copy semantics across NumPy 1.x/2.x.
CuPy copy semantics alignment in linear models
python/cuml/cuml/linear_model/linear_regression.pyx, python/cuml/cuml/linear_model/ridge.pyx
F-order conversion changed from cp.asarray(...) to cp.array(...) to adjust copy behavior when preparing inputs for libcuml/eig solvers, preserving existing order="F" and conditional copy logic.
Test skips and exception-handling updates
python/cuml/tests/test_validation.py, python/cuml/tests/explainer/test_gpu_treeshap.py
test_check_array_dataframe_mixed_dtypes broadens accepted exception types for CUDA object-dtype errors; XGBoost TreeSHAP GPU tests now skip when NumPy < 2.0 via pytest.importorskip.

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • rapidsai/cuml#8066: Related updates to validation helpers and downstream callers aligning with new dtype/validation behavior.
  • rapidsai/cuml#8105: Related fixes for cuDF→CuPy conversion and dtype coercion in validation paths.
  • rapidsai/cuml#8043: Explainer cleanup that depends on updated check_array/validation semantics.

Suggested labels

conda, Cython / Python

Suggested reviewers

  • betatim
  • divyegala
  • csadorf
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective of the changeset: bumping numpy version support and fixing compatibility issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description accurately describes the main changes: bumping numpy to 1.26, adding numpy to oldest deps tests, and fixing numpy 1.x incompatibilities.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread python/cuml/cuml/internals/validation.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dependencies.yaml`:
- Around line 533-534: The oldest-dep matrix currently lists a plain
`cupy==13.6` alongside outputs `[conda, requirements, pyproject]`; change that
entry so the plain `cupy==13.6` is emitted only for the conda output and not for
requirements/pyproject. In practice, modify the oldest-dep matrix (the block
that mirrors `depends_on_cupy`) to: emit `cupy==13.6` under the conda-only
output type, and remove the plain `cupy==13.6` from requirements/pyproject so
the CUDA-suffixed variants (handled by the existing `depends_on_cupy` logic) are
used for pip-based outputs. Ensure you reference the existing `depends_on_cupy`
pattern when making the change.

In `@python/cuml/cuml/internals/validation.py`:
- Around line 487-497: The np_asarray compatibility shim incorrectly forwards
order=None to np.array which breaks on NumPy 1.26; modify the np_asarray
function so it only includes the order keyword when order is not None (i.e.,
build the call to np.array with dtype and copy always, but conditionally add
order), preserving the existing conversion of copy to bool(copy) and behavior
differences across NumPy versions; this change will ensure check_array (and
callers passing order=None, mem_type="host") works on NumPy 1.x while keeping
the np_asarray name and semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1ec64afc-2861-4c24-bc72-b688d79b5746

📥 Commits

Reviewing files that changed from the base of the PR and between b27eb30 and 1c4f408.

📒 Files selected for processing (3)
  • dependencies.yaml
  • python/cuml/cuml/internals/validation.py
  • python/cuml/tests/explainer/test_gpu_treeshap.py

Comment thread dependencies.yaml Outdated
Comment thread python/cuml/cuml/internals/validation.py Outdated
@jcrist

jcrist commented May 15, 2026

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit 87d7b8e into NVIDIA:release/26.06 May 15, 2026
109 checks passed
@jcrist
jcrist deleted the numpy-1-compat branch May 15, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conda conda issue Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants