Skip to content

Remove legacy array and reflection machinery - #8385

Merged
rapids-bot[bot] merged 18 commits into
NVIDIA:release/26.08from
jcrist:rip-out-legacy
Jul 17, 2026
Merged

Remove legacy array and reflection machinery#8385
rapids-bot[bot] merged 18 commits into
NVIDIA:release/26.08from
jcrist:rip-out-legacy

Conversation

@jcrist

@jcrist jcrist commented Jul 16, 2026

Copy link
Copy Markdown
Member

This PR removes:

  • All usage of CumlArray in cuml.testing. This required a bit of code reorg, but the tests should run functionally the same as before. This is handled in the first few commits, the rest should be pure deletion.
  • All CumlArray-specific hypothesis strategies
  • All of cuml.internals.array
  • All of cuml.internals.array_sparse
  • All of cuml.internals.output_utils
  • All of cuml.common.array_descriptor
  • cuml.internals.interop.to_gpu/cuml.internals.interop.to_cpu
  • cuml.internals.outputs.reflect and cuml.internals.outputs.run_in_internal_context
  • All tests related to the above

Fixes #8177.

@jcrist jcrist self-assigned this Jul 16, 2026
@jcrist
jcrist requested a review from a team as a code owner July 16, 2026 17:44
@jcrist
jcrist requested a review from csadorf July 16, 2026 17:44
@jcrist jcrist added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Refactor

    • Streamlined array handling and output conversion across the library.
    • Removed legacy array wrappers, sparse-array support, reflection utilities, and related public exports.
    • Updated linear model components to use the consolidated device-pointer handling.
    • Simplified pandas, NumPy, CuPy, and dataframe conversion behavior.
  • Tests

    • Updated conversion and estimator tests for the streamlined APIs.
    • Removed tests covering retired dense and sparse array abstractions.
    • Added and adopted direct NumPy/CuPy conversion helpers in test utilities.

Walkthrough

The PR removes CumlArray and SparseCumlArray integration, deletes legacy reflection and output utilities, updates conversion behavior and mlfunc, relocates cuda_ptr, and migrates testing utilities and coverage to NumPy/CuPy-based paths.

Changes

Array and output migration

Layer / File(s) Summary
Remove legacy array surfaces
python/cuml/cuml/comm/serialize.py, python/cuml/cuml/common/__init__.py, python/cuml/cuml/internals/*
CumlArray and SparseCumlArray imports, exports, serialization registrations, interop helpers, and legacy array references are removed.
Streamline output conversion and mlfunc
python/cuml/cuml/internals/outputs.py, python/cuml/cuml/internals/base.py
convert_arrays uses one_col_2d_as_series, mlfunc drops _legacy, and reflect/run_in_internal_context are removed.
Relocate CUDA pointer helper
python/cuml/cuml/linear_model/base.py, python/cuml/cuml/linear_model/*.pyx
cuda_ptr moves to linear_model.base, and linear-model modules update their imports.
Update conversion utilities and generators
python/cuml/cuml/testing/*, python/cuml/cuml/preprocessing/encoders.py
Testing conversions and generated inputs use direct NumPy, CuPy, and series values with the revised output conversion path.
Migrate and remove legacy tests
python/cuml/tests/*
Kernel, serialization, reflection, and strategy tests use the new helpers, while legacy array-specific coverage is removed.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: csadorf, divyegala, viclafargue, dantegd

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.74% 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 concisely captures the main change: removing legacy array and reflection machinery.
Description check ✅ Passed The description is directly about removing CumlArray, SparseCumlArray, and related modules and tests.
Linked Issues check ✅ Passed The PR fulfills issue #8177 by removing CumlArray/SparseCumlArray modules, reflection plumbing, and related wrappers/tests.
Out of Scope Changes check ✅ Passed The extra edits are supporting refactors and test removals tied to the same cleanup, with no clear unrelated changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
python/cuml/cuml/testing/strategies.py (1)

144-146: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the misspelled default strategy name.

cuml_array_input_tyes() should be cuml_array_input_types().

As per coding guidelines, check all files for spelling mistakes using codespell and fix identified errors.

🤖 Prompt for 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.

In `@python/cuml/cuml/testing/strategies.py` around lines 144 - 146, Rename the
misspelled default strategy call in the input-type configuration from
cuml_array_input_tyes() to cuml_array_input_types(), and run codespell across
the repository to correct any additional reported spelling errors.

Source: Coding guidelines

python/cuml/cuml/testing/datasets.py (1)

76-80: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve the float32 representability constraint.

Removing the legacy helper also widens this test predicate, allowing values previously rejected as incompatible. Replace it with an equivalent NumPy-based bounds check so the CumlArray removal preserves dataset-generation behavior.

🤖 Prompt for 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.

In `@python/cuml/cuml/testing/datasets.py` around lines 76 - 80, Update the
dataset validity predicate in the surrounding validation function to retain the
float32 representability constraint removed with the legacy helper. Add an
equivalent NumPy-based bounds check for X_train values alongside the existing
shape and finiteness checks, preserving rejection of values outside float32
limits.
🤖 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 `@python/cuml/cuml/internals/base.py`:
- Around line 65-66: Update the subclass guidance near the removed reflect
documentation to reference cuml.internals.mlfunc(set_input_type=True) instead of
cuml.internals.reflect(reset=True), matching the existing example below.

In `@python/cuml/cuml/testing/test_preproc_utils.py`:
- Around line 56-60: Update the convert helper to disable one-column Series
coercion when calling convert_arrays for dataframe or cudf output, ensuring
converted_dataset is a dataframe before rename(columns=renaming). Add a
regression test covering a one-column input with cudf output and verify the
renamed column is preserved.

---

Outside diff comments:
In `@python/cuml/cuml/testing/datasets.py`:
- Around line 76-80: Update the dataset validity predicate in the surrounding
validation function to retain the float32 representability constraint removed
with the legacy helper. Add an equivalent NumPy-based bounds check for X_train
values alongside the existing shape and finiteness checks, preserving rejection
of values outside float32 limits.

In `@python/cuml/cuml/testing/strategies.py`:
- Around line 144-146: Rename the misspelled default strategy call in the
input-type configuration from cuml_array_input_tyes() to
cuml_array_input_types(), and run codespell across the repository to correct any
additional reported spelling errors.
🪄 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: 5bd7279e-f404-499a-9dff-34ba9024380b

📥 Commits

Reviewing files that changed from the base of the PR and between 504864a and 21a1c1b.

📒 Files selected for processing (27)
  • python/cuml/cuml/comm/serialize.py
  • python/cuml/cuml/common/__init__.py
  • python/cuml/cuml/common/array_descriptor.py
  • python/cuml/cuml/internals/__init__.py
  • python/cuml/cuml/internals/array.py
  • python/cuml/cuml/internals/array_sparse.py
  • python/cuml/cuml/internals/base.py
  • python/cuml/cuml/internals/interop.py
  • python/cuml/cuml/internals/output_utils.py
  • python/cuml/cuml/internals/outputs.py
  • python/cuml/cuml/linear_model/base.py
  • python/cuml/cuml/linear_model/lars.pyx
  • python/cuml/cuml/linear_model/linear_regression.pyx
  • python/cuml/cuml/linear_model/ridge.pyx
  • python/cuml/cuml/preprocessing/encoders.py
  • python/cuml/cuml/testing/datasets.py
  • python/cuml/cuml/testing/strategies.py
  • python/cuml/cuml/testing/test_preproc_utils.py
  • python/cuml/cuml/testing/utils.py
  • python/cuml/tests/dask/test_dask_serialization.py
  • python/cuml/tests/test_array.py
  • python/cuml/tests/test_array_sparse.py
  • python/cuml/tests/test_input_utils.py
  • python/cuml/tests/test_kernel_density.py
  • python/cuml/tests/test_kernel_ridge.py
  • python/cuml/tests/test_reflection.py
  • python/cuml/tests/test_strategies.py
💤 Files with no reviewable changes (8)
  • python/cuml/cuml/common/array_descriptor.py
  • python/cuml/tests/test_array_sparse.py
  • python/cuml/cuml/internals/output_utils.py
  • python/cuml/cuml/internals/interop.py
  • python/cuml/tests/test_input_utils.py
  • python/cuml/cuml/internals/array_sparse.py
  • python/cuml/tests/test_array.py
  • python/cuml/cuml/internals/array.py

Comment thread python/cuml/cuml/internals/base.py Outdated
Comment thread python/cuml/cuml/testing/test_preproc_utils.py
@github-actions github-actions Bot added the Cython / Python Cython or Python issue label Jul 16, 2026

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/cuml/cuml/testing/strategies.py (1)

144-145: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the documented default strategy name.

Line 145 says cuml_array_input_tyes(), but the callable is cuml_array_input_types().

Proposed fix
-        default=cuml_array_input_tyes()
+        default=cuml_array_input_types()
🤖 Prompt for 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.

In `@python/cuml/cuml/testing/strategies.py` around lines 144 - 145, In the
strategy definition, replace the misspelled default callable
`cuml_array_input_tyes()` with the existing `cuml_array_input_types()` function,
leaving the `input_types` strategy and other configuration unchanged.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@python/cuml/cuml/testing/strategies.py`:
- Around line 144-145: In the strategy definition, replace the misspelled
default callable `cuml_array_input_tyes()` with the existing
`cuml_array_input_types()` function, leaving the `input_types` strategy and
other configuration unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9bd2c415-21d2-4fff-a652-be5b0722c618

📥 Commits

Reviewing files that changed from the base of the PR and between 21a1c1b and d2031f2.

📒 Files selected for processing (27)
  • python/cuml/cuml/comm/serialize.py
  • python/cuml/cuml/common/__init__.py
  • python/cuml/cuml/common/array_descriptor.py
  • python/cuml/cuml/internals/__init__.py
  • python/cuml/cuml/internals/array.py
  • python/cuml/cuml/internals/array_sparse.py
  • python/cuml/cuml/internals/base.py
  • python/cuml/cuml/internals/interop.py
  • python/cuml/cuml/internals/output_utils.py
  • python/cuml/cuml/internals/outputs.py
  • python/cuml/cuml/linear_model/base.py
  • python/cuml/cuml/linear_model/lars.pyx
  • python/cuml/cuml/linear_model/linear_regression.pyx
  • python/cuml/cuml/linear_model/ridge.pyx
  • python/cuml/cuml/preprocessing/encoders.py
  • python/cuml/cuml/testing/datasets.py
  • python/cuml/cuml/testing/strategies.py
  • python/cuml/cuml/testing/test_preproc_utils.py
  • python/cuml/cuml/testing/utils.py
  • python/cuml/tests/dask/test_dask_serialization.py
  • python/cuml/tests/test_array.py
  • python/cuml/tests/test_array_sparse.py
  • python/cuml/tests/test_input_utils.py
  • python/cuml/tests/test_kernel_density.py
  • python/cuml/tests/test_kernel_ridge.py
  • python/cuml/tests/test_reflection.py
  • python/cuml/tests/test_strategies.py
💤 Files with no reviewable changes (8)
  • python/cuml/cuml/internals/interop.py
  • python/cuml/cuml/common/array_descriptor.py
  • python/cuml/cuml/internals/array_sparse.py
  • python/cuml/cuml/internals/output_utils.py
  • python/cuml/cuml/internals/array.py
  • python/cuml/tests/test_input_utils.py
  • python/cuml/tests/test_array_sparse.py
  • python/cuml/tests/test_array.py
🚧 Files skipped from review as they are similar to previous changes (15)
  • python/cuml/cuml/internals/init.py
  • python/cuml/cuml/common/init.py
  • python/cuml/cuml/linear_model/base.py
  • python/cuml/cuml/linear_model/ridge.pyx
  • python/cuml/tests/test_kernel_density.py
  • python/cuml/tests/test_strategies.py
  • python/cuml/cuml/preprocessing/encoders.py
  • python/cuml/tests/dask/test_dask_serialization.py
  • python/cuml/cuml/testing/datasets.py
  • python/cuml/cuml/linear_model/linear_regression.pyx
  • python/cuml/tests/test_kernel_ridge.py
  • python/cuml/cuml/testing/utils.py
  • python/cuml/cuml/testing/test_preproc_utils.py
  • python/cuml/tests/test_reflection.py
  • python/cuml/cuml/internals/outputs.py

@csadorf csadorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fantastic clean up!

As part of this PR, we should remove all mentions of the legacy machinery within the ESTIMATOR_GUIDE.md.

@csadorf csadorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see the docs update is handled in #8386. :shipit:

jcrist added 2 commits July 17, 2026 15:01
Also removes some no longer used strategies.
@csadorf
csadorf changed the base branch from main to release/26.08 July 17, 2026 20:02
@csadorf
csadorf requested review from a team as code owners July 17, 2026 20:02
@csadorf
csadorf requested a review from gforsyth July 17, 2026 20:02
@csadorf
csadorf removed request for a team and gforsyth July 17, 2026 20:04

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/cuml/cuml/testing/datasets.py (1)

77-80: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Validate all supplied dataset components.

Line 79 only checks X_train, so X_test or y_train may contain NaN/inf while the dataset is reported as cuML-compatible. Preserve the finite-value validation across all non-None inputs; removing only the representability-range restriction should not remove this safety check.

Proposed fix
     return (
         X_train.shape[0] >= 2
         and X_train.shape[1] >= 1
-        and np.isfinite(X_train).all()
+        and all(
+            np.isfinite(x).all()
+            for x in (X_train, X_test, y_train)
+            if x is not None
+        )
     )
🤖 Prompt for 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.

In `@python/cuml/cuml/testing/datasets.py` around lines 77 - 80, Update the
dataset compatibility validation around the existing shape and finiteness checks
to apply np.isfinite(...).all() to every supplied non-None component, including
X_train, X_test, and y_train. Keep the validation for required dimensions and
retain the finite-value safety check while removing only the
representability-range restriction.
🧹 Nitpick comments (1)
python/cuml/cuml/linear_model/base.py (1)

176-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct tests for cuda_ptr. Cover CUDA-interface objects, non-CUDA inputs returning None, and the data[0] == 0 edge case.

🤖 Prompt for 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.

In `@python/cuml/cuml/linear_model/base.py` around lines 176 - 180, Add direct
tests for the cuda_ptr function covering an object with __cuda_array_interface__
and verifying its data[0] pointer, ordinary non-CUDA inputs returning None, and
CUDA-interface objects whose data[0] is zero still returning 0.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@python/cuml/cuml/testing/datasets.py`:
- Around line 77-80: Update the dataset compatibility validation around the
existing shape and finiteness checks to apply np.isfinite(...).all() to every
supplied non-None component, including X_train, X_test, and y_train. Keep the
validation for required dimensions and retain the finite-value safety check
while removing only the representability-range restriction.

---

Nitpick comments:
In `@python/cuml/cuml/linear_model/base.py`:
- Around line 176-180: Add direct tests for the cuda_ptr function covering an
object with __cuda_array_interface__ and verifying its data[0] pointer, ordinary
non-CUDA inputs returning None, and CUDA-interface objects whose data[0] is zero
still returning 0.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 005b7723-e23c-4e2c-bb86-75329e7ff13e

📥 Commits

Reviewing files that changed from the base of the PR and between d2031f2 and 279ac74.

📒 Files selected for processing (27)
  • python/cuml/cuml/comm/serialize.py
  • python/cuml/cuml/common/__init__.py
  • python/cuml/cuml/common/array_descriptor.py
  • python/cuml/cuml/internals/__init__.py
  • python/cuml/cuml/internals/array.py
  • python/cuml/cuml/internals/array_sparse.py
  • python/cuml/cuml/internals/base.py
  • python/cuml/cuml/internals/interop.py
  • python/cuml/cuml/internals/output_utils.py
  • python/cuml/cuml/internals/outputs.py
  • python/cuml/cuml/linear_model/base.py
  • python/cuml/cuml/linear_model/lars.pyx
  • python/cuml/cuml/linear_model/linear_regression.pyx
  • python/cuml/cuml/linear_model/ridge.pyx
  • python/cuml/cuml/preprocessing/encoders.py
  • python/cuml/cuml/testing/datasets.py
  • python/cuml/cuml/testing/strategies.py
  • python/cuml/cuml/testing/test_preproc_utils.py
  • python/cuml/cuml/testing/utils.py
  • python/cuml/tests/dask/test_dask_serialization.py
  • python/cuml/tests/test_array.py
  • python/cuml/tests/test_array_sparse.py
  • python/cuml/tests/test_input_utils.py
  • python/cuml/tests/test_kernel_density.py
  • python/cuml/tests/test_kernel_ridge.py
  • python/cuml/tests/test_reflection.py
  • python/cuml/tests/test_strategies.py
💤 Files with no reviewable changes (8)
  • python/cuml/cuml/internals/array.py
  • python/cuml/cuml/internals/interop.py
  • python/cuml/cuml/internals/output_utils.py
  • python/cuml/tests/test_input_utils.py
  • python/cuml/cuml/internals/array_sparse.py
  • python/cuml/cuml/common/array_descriptor.py
  • python/cuml/tests/test_array_sparse.py
  • python/cuml/tests/test_array.py
🚧 Files skipped from review as they are similar to previous changes (14)
  • python/cuml/cuml/linear_model/lars.pyx
  • python/cuml/cuml/linear_model/ridge.pyx
  • python/cuml/cuml/common/init.py
  • python/cuml/cuml/internals/init.py
  • python/cuml/cuml/linear_model/linear_regression.pyx
  • python/cuml/tests/dask/test_dask_serialization.py
  • python/cuml/cuml/comm/serialize.py
  • python/cuml/cuml/testing/test_preproc_utils.py
  • python/cuml/cuml/testing/utils.py
  • python/cuml/tests/test_kernel_ridge.py
  • python/cuml/tests/test_kernel_density.py
  • python/cuml/cuml/testing/strategies.py
  • python/cuml/tests/test_reflection.py
  • python/cuml/cuml/internals/outputs.py

@jcrist

jcrist commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit 67774e0 into NVIDIA:release/26.08 Jul 17, 2026
94 checks passed
@jcrist
jcrist deleted the rip-out-legacy branch July 20, 2026 16:57
@jcrist jcrist mentioned this pull request Aug 4, 2026
rapids-bot Bot pushed a commit that referenced this pull request Aug 4, 2026
- Removes serializer override for `MultinomialNB`, this is unnecessary
- Simplifies the registration of serializers for other types, and improves the comments to better state why overrides are needed.

This is a small followup to #8385. I noticed in that PR that some of the code here could be simplified/was no longer necessary.

This should have no runtime effects (the same effective code should run before and after), it's just a small code cleanup.

Authors:
  - Jim Crist-Harif (https://github.com/jcrist)

Approvers:
  - Victor Lafargue (https://github.com/viclafargue)

URL: #8443
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.

Remove CumlArray/SparseCumlArray

4 participants