Skip to content

Feature/sklearnex and remove faiss#33

Open
NetZissou wants to merge 3 commits into
mainfrom
feature/sklearnex-and-remove-faiss
Open

Feature/sklearnex and remove faiss#33
NetZissou wants to merge 3 commits into
mainfrom
feature/sklearnex-and-remove-faiss

Conversation

@NetZissou
Copy link
Copy Markdown
Collaborator

@NetZissou NetZissou commented Jun 2, 2026

Closes issue #32

  1. Patch sklearn with sklearnex.
  2. Remove faiss entirely from backend.

About sklearnex

Good API stability:

Unlike other libraries in the Python ecosystem, classes and functions in the Extension for Scikit-learn* are not just scikit-learn-compatible, but rather are built atop of scikit-learn itself by inheriting from their classes directly, defining the same attributes that the stock version of scikit-learn would do for each estimator, and reusing most of scikit-learn’s estimator methods where appropriate.

The Extension for Scikit-learn* is regularly tested for API compatibility and for correctness against scikit-learn’s own test suite (see Scikit-learn’s test suite for more information), and can be easily swapped in place of the stock scikit-learn library by patching it.

sklearnex is powered by the oneDAL library that provides accelerations on x86_64 Linux and Windows machines, and silently fall back to vanilla sklearn on unsupported architectures like Apple Silicon and ARM Linux. The package is under the UXL Foundation (a Linux Foundation project) so cross-vendor support is a stated goal.

NetZissou added 2 commits June 2, 2026 10:58
The FAISS KMeans backend added meaningful installation weight and
startup import noise for a marginal benefit. Removing it simplies the
backend selection logic to two cases:
- cuML if GPU available
- else sklearn

Changes
- Drop `faiss-cpu` & `faiss-gpu-cu12` from main deps and `gpu-*` extras
- Remove FAISS from backend scripts `resolve_brackend()`, `run_kmeans()` dispatch
- Remove "faiss" from clustering backend dropdowns in the webUI
- Update README & BACKEND_PIPELINE doc to reflect the changes
Add `scikit-learn-intelex` as default dependency and patch sklearn at
import time in `shared/utils/clustering.py`. Accelerates the existing
`sklearn` PCA / TSNE / KMeans calls on CPU.

UMAP is unaffected as `umap-learn` is not part of the `sklearn`
algorithm.

Set Set EMB_EXPLORER_DISABLE_SKLEARNEX=1 to opt out for debugging
vanilla sklearn behavior.
@NetZissou NetZissou self-assigned this Jun 2, 2026
@NetZissou NetZissou added the enhancement New feature or request label Jun 2, 2026
@NetZissou NetZissou linked an issue Jun 2, 2026 that may be closed by this pull request
Comment thread README.md Outdated
Comment thread docs/BACKEND_PIPELINE.md Outdated
Comment thread docs/BACKEND_PIPELINE.md Outdated
Comment thread docs/BACKEND_PIPELINE.md Outdated
Comment thread docs/BACKEND_PIPELINE.md
Comment thread README.md
Co-authored-by: Net Zhang <48858129+NetZissou@users.noreply.github.com>
@NetZissou NetZissou requested a review from egrace479 June 3, 2026 17:05
Copy link
Copy Markdown
Member

@egrace479 egrace479 left a comment

Choose a reason for hiding this comment

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

Footnote formatting fix

Comment thread docs/BACKEND_PIPELINE.md
Comment on lines +15 to +19
│ Backend: cuML (GPU) → sklearn (CPU, auto-accelerated by `sklearn-intelex` [^1])
├─► Step 2: Dimensionality Reduction to 2D
│ Method: PCA / t-SNE / UMAP
│ Backend: cuML → sklearn
│ Backend: cuML (GPU) → sklearn (CPU, auto-accelerated by `sklearn-intelex` for PCA/TSNE [^1])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
│ Backend: cuML (GPU) → sklearn (CPU, auto-accelerated by `sklearn-intelex` [^1])
├─► Step 2: Dimensionality Reduction to 2D
│ Method: PCA / t-SNE / UMAP
│ Backend: cuML → sklearn
│ Backend: cuML (GPU) → sklearn (CPU, auto-accelerated by `sklearn-intelex` for PCA/TSNE [^1])
│ Backend: cuML (GPU) → sklearn (CPU, auto-accelerated by `sklearn-intelex`)
├─► Step 2: Dimensionality Reduction to 2D
│ Method: PCA / t-SNE / UMAP
│ Backend: cuML (GPU) → sklearn (CPU, auto-accelerated by `sklearn-intelex` for PCA/TSNE)

Wrong spot for footnotes (they won't function in the codeblock)

Comment thread docs/BACKEND_PIPELINE.md
└─► Scatter Plot (Altair)
Color = cluster, position = 2D projection
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Note that `sklearn-intelex` acceleration is used for CPU operations where available[^1].

Comment thread docs/BACKEND_PIPELINE.md
| **cuML** | GPU available + >500 samples | GPU-accelerated KMeans via RAPIDS. Runs on CuPy arrays. Falls back to sklearn on any error. |
| **FAISS** | No GPU + >500 samples | Facebook's optimized CPU KMeans using L2 index. Fast for medium datasets. Falls back to sklearn on error. |
| **sklearn** | Small datasets or fallback | Standard scikit-learn KMeans. Always works, no special dependencies. |
| **sklearn** | CPU path (default on machines without a GPU) | Standard scikit-learn KMeans, auto-accelerated by [scikit-learn-intelex](https://github.com/uxlfoundation/scikit-learn-intelex) (Intel oneDAL) when installed — typically 10–17× faster than vanilla sklearn on CPU. Disable with `EMB_EXPLORER_DISABLE_SKLEARNEX=1`. |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
| **sklearn** | CPU path (default on machines without a GPU) | Standard scikit-learn KMeans, auto-accelerated by [scikit-learn-intelex](https://github.com/uxlfoundation/scikit-learn-intelex) (Intel oneDAL) when installed — typically 10–17× faster than vanilla sklearn on CPU. Disable with `EMB_EXPLORER_DISABLE_SKLEARNEX=1`. |
| **sklearn** | CPU path (default on machines without a GPU) | Standard scikit-learn KMeans, auto-accelerated by [scikit-learn-intelex](https://github.com/uxlfoundation/scikit-learn-intelex) (Intel oneDAL) when installed[^1] — typically 10–17× faster than vanilla sklearn on CPU. Disable with `EMB_EXPLORER_DISABLE_SKLEARNEX=1`. |

Comment thread docs/BACKEND_PIPELINE.md
|-----------|-----------|
| KMeans | cuML if GPU + >500 samples, else FAISS if available + >500 samples, else sklearn |
| Dim. Reduction | cuML if GPU + >5000 samples, else sklearn |
| KMeans | cuML if GPU + >500 samples, else sklearn (auto-accelerated by `sklearn-intelex` when installed [^1]) |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
| KMeans | cuML if GPU + >500 samples, else sklearn (auto-accelerated by `sklearn-intelex` when installed [^1]) |
| KMeans | cuML if GPU + >500 samples, else sklearn (auto-accelerated by `sklearn-intelex` when installed[^1]) |

Comment thread README.md
```

The app auto-detects GPU availability at runtime and falls back to CPU if anything goes wrong — no configuration needed. You can also manually select backends (cuML, FAISS, sklearn) in the sidebar.
The app auto-detects GPU availability at runtime and falls back to CPU if anything goes wrong — no configuration needed. The CPU sklearn path is auto-accelerated by [scikit-learn-intelex](https://github.com/uxlfoundation/scikit-learn-intelex) [^1]. You can also manually select backends (`cuML`, `sklearn`) in the sidebar.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The app auto-detects GPU availability at runtime and falls back to CPU if anything goes wrong — no configuration needed. The CPU sklearn path is auto-accelerated by [scikit-learn-intelex](https://github.com/uxlfoundation/scikit-learn-intelex) [^1]. You can also manually select backends (`cuML`, `sklearn`) in the sidebar.
The app auto-detects GPU availability at runtime and falls back to CPU if anything goes wrong — no configuration needed. The CPU sklearn path is auto-accelerated by [scikit-learn-intelex](https://github.com/uxlfoundation/scikit-learn-intelex)[^1]. You can also manually select backends (`cuML`, `sklearn`) in the sidebar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend Acceleration on CPU Cores

2 participants