- Purpose: Accelerate scikit-learn using Intel oneDAL optimizations
- License: Apache 2.0
- Languages: Python, C++, Cython
- Platforms: CPU (x86_64, ARM), GPU (Intel via SYCL)
User Apps → sklearnex/ ⇒ {daal4py/, onedal/} → Intel oneDAL C++
↓ ↓
(Cython ext) (pybind11)
Layer Functions:
sklearnex/: sklearn API compatibility, patching, uses both daal4py and onedaldaal4py/: Direct oneDAL access via Cython, model builders, legacy compatibilityonedal/: Modern pybind11 bindings, memory management, GPU/CPU backend selectionsrc/: C++/Cython core implementation shared by both bindings
sklearn acceleration - Global patching or selective imports from sklearnex
Native oneDAL - Direct algorithm access via daal4py for maximum performance
Model conversion - Convert XGBoost/LightGBM/CatBoost models to oneDAL format for accelerated inference
- Clustering: DBSCAN, K-Means
- Classification: SVM, RandomForest, LogisticRegression, NaiveBayes
- Regression: LinearRegression, Ridge, Lasso, ElasticNet, SVR
- Decomposition: PCA, IncrementalPCA
- Neighbors: KNeighbors (classification/regression)
- Preprocessing: Scalers, normalizers
- Statistics: Basic statistics, covariance
GPU offloading and device control available through sklearnex config_context for supported algorithms.
- Memory: Zero-copy NumPy↔oneDAL, SYCL USM for GPU
- Parallelism: Intel TBB threading, MPI distributed (SPMD), SIMD vectorization
- Fallbacks: oneDAL → sklearn cascading fallback on unsupported operations
- Speedups: 10-100X acceleration over sklearn (varies by algorithm and data characteristics)
sklearnex/dispatcher.py: Patching system and algorithm dispatchsklearnex/_device_offload.py: Device selection and offloadingonedal/__init__.py: Backend selection (DPC++/Host)daal4py/__init__.py: Native API entry pointsrc/: C++/Cython core (distributed computing, memory management)
# Recommended: via conda
conda install -c conda-forge scikit-learn-intelex
# Or via pip
pip install scikit-learn-intelex# 1. Install oneDAL and set DALROOT
export DALROOT=/path/to/onedal # Required
# 2. Install dependencies
pip install -r dependencies-dev
# 3. Build in development mode
python setup.py developDALROOT: Path to oneDAL (required for source builds)MPIROOT: Path to MPI for distributed supportNO_DPC: Disable GPU supportNO_DIST: Disable distributed computingNO_STREAM: Disable streaming mode
Core test suites cover legacy tests, native oneDAL (daal4py), sklearn compatibility (sklearnex), low-level backend (onedal), and global patching. MPI required for distributed (SPMD) testing.
oneDAL acceleration requires:
- Supported dtypes: float32, float64
- Contiguous memory layout preferred
- Algorithm-specific parameter compatibility
- Full GPU: DBSCAN, K-Means, PCA, KNeighbors
- Limited GPU: LogisticRegression, SVM
- CPU Only: Ridge, IncrementalPCA
Fallback chain: oneDAL → sklearn → error. Configurable via allow_sklearn_after_onedal setting.
oneDAL requires contiguous data for zero-copy operations. C-contiguous preferred over Fortran-contiguous.
Supported Intel GPUs: Integrated (UHD Graphics, Iris Xe), Discrete (Arc series), Datacenter (Flex) Requirements: SYCL/DPC++ support, Intel oneAPI toolkit, Unified Shared Memory (USM)
Verify GPU availability:
python -c "import dpctl; print(dpctl.get_devices())"Common GPU issues:
- "No GPU device found" → Install Intel GPU drivers and
intel-opencl-icd(Linux) or Intel Graphics drivers (Windows). For conda environments, also installintel-gpu-ocl-icd-systemfrom Intel's conda channel. ImportError: dpctl→ Install GPU runtime:pip install dpctl dpnp- Fallback to CPU → Check
verbose=Trueto see reason (unsupported param, sparse data, etc.) - Out of memory → Reduce data size or use
target_offload="cpu"
Build/Setup:
- "Not set DALROOT variable" → Export DALROOT pointing to oneDAL installation
- "MPIROOT is not set" → For distributed mode, set MPIROOT or use
NO_DIST=1
Runtime:
- "oneDAL backend not available" → Algorithm/parameter not supported by oneDAL, fallback to sklearn
- "Unsupported parameter" → Parameter value incompatible with oneDAL (check documentation)
- "Sparse data not supported" → Convert to dense or use sklearn (except SVM, NaiveBayes support CSR)
- MPI errors in SPMD → Call
daal4py.daalinit()before distributed operations,daalfini()at end
For current supported versions, always check:
setup.py- Python version classifiersrequirements-test.txt- scikit-learn and runtime dependenciesdependencies-dev- Build dependencies
Python: Supports officially maintained Python versions. Support for newly released versions may be delayed; support for older versions may extend beyond EOL to accommodate user needs.
scikit-learn: Aims to support the last 4 scikit-learn releases. sklearn 1.0 maintained as special case for production environments.
oneDAL: Backwards compatible with oneDAL 2021.1+. Forward compatibility not guaranteed.
The generator/ directory contains automated code generation from oneDAL C++ headers to Python bindings. Modify generator/wrappers.py to add new oneDAL algorithms; use direct Python implementation for sklearn compatibility layers.
sklearnex/AGENTS.md: API patterns, device offloadingdaal4py/AGENTS.md: Native oneDAL bindings, model buildersonedal/AGENTS.md: Pybind11 implementation, memory managementsrc/AGENTS.md: C++/Cython core, distributed computingexamples/AGENTS.md: Usage patterns and example scriptstests/AGENTS.md: Testing infrastructure, validation patterns.ci/AGENTS.md: CI/CD pipeline and build infrastructuredoc/AGENTS.md: Documentation build system