Repository navigation
Conversation
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces GPU-native global aggregation and standard deviation operators, adds a suite of GPU-native preprocessors with a fused GPUChain execution path, and optimizes GPU hash aggregation with actor-local compaction and improved backpressure handling. The review feedback highlights three critical issues: a potential TypeError in the CPU fallback path of Chain.fit_transform due to unsupported keyword arguments, a missing import of cast in hash_aggregate.py causing a runtime NameError, and incorrect null-checking logic in encoder.py that fails to handle pandas NaN and pd.NA values.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
Reviewed by Cursor Bugbot for commit 137bd0d. Configure here.
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
Signed-off-by: Lee Yang <[email protected]>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
This pull request has been automatically closed because there has been no more activity in the 14 days Please feel free to reopen or open a new pull request if you'd still like this to be addressed. Again, you can always ask for help on our discussion forum or Ray's public slack channel. Thanks again for your contribution! |
…ggregation (#66088) ## Why are these changes needed? Encoder preprocessors (`OrdinalEncoder`, `OneHotEncoder`, `MultiHotEncoder`, `LabelEncoder`, `Categorizer`) currently fit through `compute_unique_value_indices`: a `map_batches` that emits per-block value counters, followed by a loop **on the driver** that merges them into global counts. `SimpleImputer(strategy="most_frequent")` has the same shape via `_get_most_frequent_values`. That driver-side merge is a scalability bottleneck, and because it is registered as a *callable stat*, it can never be batched with other statistics into a single `Dataset.aggregate()` query. This PR moves those fits onto the stat computation plan as real distributed aggregations: - The five encoders register `Unique` (or `TopKUnique` when `max_categories` is set) with the same `unique_values({col})` alias the transform code reads. - `SimpleImputer("most_frequent")` registers `TopKUnique(k=1, ignore_nulls=True)`. It returns the most frequent non-null value, breaks frequency ties by picking the smallest value, and yields no value for an all-null column, which gives the same results as before. It uses the vectorized column-wise merge, so no driver-side argmax helper is needed. - `Unique` (and `TopKUnique`) fall back to collecting values in Python when the vectorized path can't handle a column's type: types without an Arrow `unique`/`value_counts` kernel, such as tensor columns, and list-typed columns when the optional `polars` package isn't installed. Lists and arrays become tuples, so the encoders produce the same categories as before. `HASH` list encoding still requires `polars`, since a Python fallback can't reproduce polars' hashes. Behavior is preserved: `stats_` key names, the "contains null values … consider imputing" errors, list-column encoding (flatten vs whole-list), and global cross-partition top-k semantics for `max_categories` are all unchanged, which the existing suites verify. Each fit is now a single `Dataset.aggregate()` query per preprocessor with no driver-side merge. The legacy helpers `compute_unique_value_indices` and `_get_most_frequent_values` are removed; nothing uses them. Behavior notes for reviewers: - `ds.aggregate(Unique(...))` on a tensor column, or on a list column without `polars` installed, now works instead of raising. This comes from the fallback above and benefits any `Unique` user, not only the encoders. - Whole-list categories stay whole lists when merged from several partial aggregates, with or without `polars` (see the new tests below). - With `max_categories`, a null tied with a real value at the cut-off no longer raises "contains null values": nulls now rank last, whereas the old path broke ties by insertion order. Otherwise it raises in the same cases as before. - Pre-existing and unchanged: a block that holds *only* null rows of a list column is typed `null` rather than `list`, so its nulls count as a value and the fit raises. This depends on how rows are split into blocks, as it did before this PR; I'll file a follow-up. ## Related issue number N/A. Not a duplicate: searched open PRs/issues for encoder/imputer fit work; no overlap found (#66012 covers GPU transforms, not fitting). Part 2 of 4 of the preprocessor fitting series (RFC: #66090). Part 1 (`TopKUnique`, #66087) has merged; parts 3 and 4 (#66091, #66092) build on this. ## Checks - [x] I've signed off every commit (DCO). - [x] I've run pre-commit hooks — all hooks pass. - [x] Testing (macOS / Python 3.12, source build): - `pytest python/ray/data/tests/preprocessors/ --ignore=.../test_torch.py` (torch not installed) — 411 passed, 5 skipped, 0 failed (clean master at the same base: 392 passed). Includes `test_preprocessors_arrow_backed.py`. Env matches CI pins (pandas 2.3.3, pyarrow 23.0.1, cloudpickle 3.1.1). - `pytest python/ray/data/tests/test_aggregations.py` — 62 passed (clean master: 57). - New tests: encoders/imputer assert they register plan aggregators (no callable stats); most_frequent never imputes null (including `None`, `NaN`, `pd.NA` and float32 `NaN`, even when they outnumber every real value); deterministic tie-break; most_frequent picks the value from counts summed across blocks; whole-list categories (`OrdinalEncoder(encode_lists=False)`, `OneHotEncoder`) stay whole lists when merged from several partial aggregates; encoders fit tensor columns (whole arrays, flattened arrays, `max_categories`); whole-list encoding with and without `polars`; `Unique` on tensor columns and on list columns without `polars`; `HASH` mode still requires `polars`; a null row in a list column adds no categories. AI assistance was used to draft this change (Claude Code); every line has been reviewed by the submitter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Abhishek Verma <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>

Description
This PR adds GPU support for
ray.data.preprocessorAPIs.Key changes:
HashingVectorizer,OneHotEncoder,OrdinalEncoder,PowerTransformer,SimpleImputer,StandardScaler.GPUChainimplementation that fuses the fit/transform stages of chained preprocessors.min_evidenceargument toOrdinalEncoderto exclude categories below a count threshold.Related issues
Related to #63708
Additional information
Automatic conversion to GPU implementations (for supported preprocessors) is enabled via new arguments in the standard API: