From 6821139e062b9e2d7d498bddc5c8729bddd80d74 Mon Sep 17 00:00:00 2001 From: ethanglaser Date: Fri, 10 Jul 2026 11:29:30 -0700 Subject: [PATCH] Update sklearnex gpu to use array_api_dispatch and dpnp --- README.md | 6 ++++++ configs/BENCH-CONFIG-SPEC.md | 2 +- configs/common/sklearn.json | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 80c8ef57..4341c8f2 100755 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ conda env create -n sklearn -f envs/conda-env-sklearn.yml conda env create -n rapids --solver=libmamba -f envs/conda-env-rapids.yml ``` +GPU benchmarks using `sklearnex`'s `device: gpu` rely on scikit-learn's Array API support (`array_api_dispatch`), which requires `SCIPY_ARRAY_API=1` to be set in the environment before running: + +```bash +export SCIPY_ARRAY_API=1 +``` + ## 🚀 How To Use Scikit-learn_bench ### Benchmarks Runner diff --git a/configs/BENCH-CONFIG-SPEC.md b/configs/BENCH-CONFIG-SPEC.md index c34f4743..7e23e548 100644 --- a/configs/BENCH-CONFIG-SPEC.md +++ b/configs/BENCH-CONFIG-SPEC.md @@ -98,7 +98,7 @@ Configs have the three highest parameter keys: | `data`:`distributed_split` | None | None, `rank_based` | Split type used to distribute data between machines in distributed algorithm. `None` type means usage of all data without split on all machines. `rank_based` type splits the data equally between machines with split sequence based on rank id from MPI. | |

Algorithm parameters

|||| | `algorithm`:`library` | None | | Python module containing measured entity (class or function). | -| `algorithm`:`device` | `default` | `default`, `cpu`, `gpu` | Device selected for computation. | +| `algorithm`:`device` | `default` | `default`, `cpu`, `gpu` | Device selected for computation. `sklearnex`+`gpu` cases enable sklearn's `array_api_dispatch` and use `dpnp` data by default (see `sklearn_context` below); requires `SCIPY_ARRAY_API=1` to be set in the environment. | ## Benchmark-Specific Parameters diff --git a/configs/common/sklearn.json b/configs/common/sklearn.json index 6b988ba7..0ac26ef8 100644 --- a/configs/common/sklearn.json +++ b/configs/common/sklearn.json @@ -6,12 +6,18 @@ { "library": "sklearnex", "device": "cpu" } ] }, - "sklearn-ex[cpu,gpu] implementations": { - "algorithm": [ - { "library": "sklearn", "device": "cpu" }, - { "library": "sklearnex", "device": ["cpu", "gpu"] } - ] - }, + "sklearn-ex[cpu,gpu] implementations": [ + { "algorithm": { "library": "sklearn", "device": "cpu" } }, + { "algorithm": { "library": "sklearnex", "device": "cpu" } }, + { + "algorithm": { + "library": "sklearnex", + "device": "gpu", + "sklearn_context": { "array_api_dispatch": true } + }, + "data": { "format": "dpnp" } + } + ], "sklearnex spmd implementation": { "algorithm": { "library": "sklearnex.spmd",