Skip to content

Fix CDMG xfails for numpy 2.4 - #7918

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:release/26.04from
jcrist:fix-cd-mg-numpy-24
Mar 20, 2026
Merged

Fix CDMG xfails for numpy 2.4#7918
rapids-bot[bot] merged 1 commit into
NVIDIA:release/26.04from
jcrist:fix-cd-mg-numpy-24

Conversation

@jcrist

@jcrist jcrist commented Mar 20, 2026

Copy link
Copy Markdown
Member

Numpy 2.4 no longer coerces 1 element arrays to scalars automatically. Small update to this line to support both 1-element alpha arrays and scalars. Fixes #7873.

@jcrist jcrist self-assigned this Mar 20, 2026
@jcrist
jcrist requested a review from a team as a code owner March 20, 2026 01:27
@jcrist jcrist added the improvement Improvement / enhancement to an existing function label Mar 20, 2026
@jcrist
jcrist requested a review from divyegala March 20, 2026 01:27
@jcrist jcrist added the non-breaking Non-breaking change label Mar 20, 2026
@github-actions github-actions Bot added the Cython / Python Cython or Python issue label Mar 20, 2026
@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4de61145-4704-4adc-8d42-9cbde9dbbb2c

📥 Commits

Reviewing files that changed from the base of the PR and between 2e65466 and dbad904.

📒 Files selected for processing (2)
  • python/cuml/cuml/solvers/cd_mg.pyx
  • python/cuml/tests/dask/test_dask_coordinate_descent.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved robustness of parameter handling in the coordinate descent solver to correctly process scalar values in all cases.
  • Tests

    • Removed version-dependent test conditions, enabling consistent test execution across all NumPy versions.

Walkthrough

This PR fixes a NumPy 2.4 compatibility issue where non-scalar array inputs could not be implicitly converted to C doubles in Cython. The fix explicitly checks scalar status and extracts scalar values before assignment, then removes corresponding test xfails that are no longer needed.

Changes

Cohort / File(s) Summary
Cython scalar coercion fix
python/cuml/cuml/solvers/cd_mg.pyx
Updated CDMG._fit to more robustly coerce self.alpha to C double by checking np.isscalar() and using .item() extraction for non-scalar values before assignment, addressing NumPy 2.4 implicit conversion restrictions.
Test cleanup
python/cuml/tests/dask/test_dask_coordinate_descent.py
Removed NumPy version gating logic (packaging.version.Version and numpy_gte_24 flag) and associated pytest.mark.xfail conditions for unit-scale test cases, replacing them with unconditional parametrizations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Cython / Python

Suggested reviewers

  • viclafargue
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing CDMG xfails that were introduced due to NumPy 2.4 incompatibilities.
Description check ✅ Passed The description clearly relates to the changeset, explaining the NumPy 2.4 issue with array-to-scalar coercion and referencing the specific fix.
Linked Issues check ✅ Passed The changes address issue #7873 by modifying cd_mg.pyx to handle both scalar and 1-element arrays, and removing the corresponding xfails from the test file.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the NumPy 2.4 compatibility issue: the alpha coercion fix in cd_mg.pyx and removal of xfails in test_dask_coordinate_descent.py.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

@csadorf

csadorf commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 4a5c8ea into NVIDIA:release/26.04 Mar 20, 2026
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants