Skip to content

Use cudf to_cupy dtype conversions - #8085

Closed
csadorf wants to merge 1 commit into
NVIDIA:mainfrom
csadorf:cudf-22136-to-cupy-cleanup
Closed

Use cudf to_cupy dtype conversions#8085
csadorf wants to merge 1 commit into
NVIDIA:mainfrom
csadorf:cudf-22136-to-cupy-cleanup

Conversation

@csadorf

@csadorf csadorf commented May 12, 2026

Copy link
Copy Markdown
Contributor

Updates cuML cudf-to-cupy conversion paths to pass dtype directly through to_cupy, now that cuDF handles dtype coercion for numeric and non-numeric columns. Adds focused validation and encoder coverage for dtype-preserving CuPy output.

Follow-up to NVIDIA/cudf#22136

@csadorf
csadorf requested a review from a team as a code owner May 12, 2026 15:52
@csadorf
csadorf requested a review from betatim May 12, 2026 15:52
@csadorf csadorf added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels May 12, 2026
@github-actions github-actions Bot added the Cython / Python Cython or Python issue label May 12, 2026
@csadorf csadorf closed this May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c3b253e3-065b-409f-8e06-e97b18aa4f23

📥 Commits

Reviewing files that changed from the base of the PR and between 661a320 and 2188f74.

📒 Files selected for processing (4)
  • python/cuml/cuml/internals/validation.py
  • python/cuml/cuml/preprocessing/encoders.py
  • python/cuml/tests/test_ordinal_encoder.py
  • python/cuml/tests/test_validation.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved dtype conversion handling for GPU array operations, ensuring requested data types are correctly applied during conversion.
  • Tests

    • Added test coverage for dtype preservation in encoder GPU output operations.
    • Added validation tests for GPU array conversion type compatibility.

Walkthrough

Improved cudf-to-cupy dtype conversion by passing dtype directly to to_cupy() with fallback pre-casting. Applied changes to check_array validation logic and OrdinalEncoder output conversion, with parametrized tests validating dtype correctness in both cases.

Changes

Dtype Handling in cudf-to-cupy Conversions

Layer / File(s) Summary
check_array cudf-to-cupy dtype fallback logic
python/cuml/cuml/internals/validation.py, python/cuml/tests/test_validation.py
check_array dense cudf-to-device conversion now attempts to_cupy(dtype=...) directly; if unsupported dtype conversion raises TypeError, pre-casts the array and retries. Result wrapped with cp.asarray(..., dtype=..., order=...). Parametrized test validates correct dtype conversion from cudf.DataFrame to specified target dtype on device output.
OrdinalEncoder cupy output dtype conversion
python/cuml/cuml/preprocessing/encoders.py, python/cuml/tests/test_ordinal_encoder.py
_get_output() passes na_value=np.nan and dtype=dtype directly to to_cupy(), replacing prior astype(dtype).to_cupy(...) pre-casting. Test validates OrdinalEncoder(output_type="cupy", dtype=np.float32) produces a cupy array with matching float32 dtype.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • rapidsai/cuml#8038: Related modifications to cudf conversion and dtype-coercion logic in cuml/internals/validation.py, including dtype fallback patterns and check_array refactoring.
  • rapidsai/cuml#8052: Related updates to the cudf-to-cupy conversion path in cuml.internals.validation, including dtype and copy semantics handling.

Suggested labels

Cython / Python

Suggested reviewers

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

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

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.

3 participants