-
Notifications
You must be signed in to change notification settings - Fork 660
DOC Add third-party app example for cuml.accel #8094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 6 commits into
NVIDIA:release/26.06
from
betatim:embedding-atlas-example
May 15, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
99fbcf6
Add third-party app example for cuml.accel
betatim a283af8
Merge remote-tracking branch 'upstream/main' into embedding-atlas-exa…
betatim 45b53e2
Less precise benchmark numbers
betatim 3670d25
Move to examples/ directory
betatim 5df3ca9
Add cross-reference
betatim e7ee359
Merge remote-tracking branch 'upstream/release/26.06' into embedding-…
betatim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| Accelerating Third-Party Applications | ||
| ====================================== | ||
|
|
||
|
betatim marked this conversation as resolved.
|
||
| The ``CUML_ACCEL_ENABLED`` environment variable lets you GPU-accelerate any | ||
| Python application that uses ``sklearn``, ``umap``, or ``hdbscan``. | ||
| Even applications whose code you cannot modify. This is useful for | ||
| installed CLI tools, applications, and third-party libraries. | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| CUML_ACCEL_ENABLED=1 some-third-party-tool [args...] | ||
|
|
||
| When :ref:`CUML_ACCEL_ENABLED=1 is defined <cuml-accel-env-var>`, | ||
| `cuml.accel` will be enabled as part of the normal Python interpreter | ||
| startup, letting you accelerate Python applications without modification | ||
|
|
||
| This means you do not need access to an application's source code: set the | ||
| environment variable and the acceleration applies automatically. | ||
|
|
||
| Example: Embedding Visualization with embedding-atlas | ||
| ----------------------------------------------------- | ||
|
|
||
| `embedding-atlas <https://github.com/apple/embedding-atlas>`_ is Apple's | ||
| open-source tool for interactive visualization of large embedding datasets. | ||
| Given a text dataset, it computes sentence embeddings, projects them to 2D | ||
| using `UMAP <https://umap-learn.readthedocs.io/>`_, and launches a | ||
| browser-based explorer. | ||
|
|
||
| Install it alongside ``cuml``: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| pip install embedding-atlas | ||
|
|
||
| Run it on a Hugging Face dataset. The example below uses | ||
| `TinyStories <https://huggingface.co/datasets/roneneldan/TinyStories>`_, | ||
| a dataset of 2M+ short stories: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| # CPU -- UMAP runs on CPU | ||
| embedding-atlas roneneldan/TinyStories --text text \ | ||
| --split train --sample 1000000 | ||
|
|
||
| # GPU -- set environment variable; no other changes needed | ||
| CUML_ACCEL_ENABLED=1 embedding-atlas roneneldan/TinyStories --text text \ | ||
| --split train --sample 1000000 | ||
|
|
||
| The only change between the two commands is the environment variable. | ||
| ``embedding-atlas`` computes embeddings with sentence-transformers (which | ||
| already uses the GPU), then runs UMAP for dimensionality reduction. | ||
| ``cuml.accel`` intercepts the ``umap.UMAP`` call inside ``embedding-atlas`` | ||
| and dispatches ``fit_transform`` to cuML's GPU implementation. | ||
|
|
||
| Use a smaller ``--sample`` value (e.g. 250000) for a quicker test run. | ||
| The UMAP speedup grows with dataset size. | ||
|
|
||
| To confirm GPU dispatch, add ``CUML_ACCEL_LOG_LEVEL=info``: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| CUML_ACCEL_ENABLED=1 CUML_ACCEL_LOG_LEVEL=info embedding-atlas \ | ||
| roneneldan/TinyStories --text text --split train --sample 1000000 | ||
|
|
||
| You should see the following messages amongst the other output: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| [cuml.accel] Accelerator installed. | ||
| [cuml.accel] `UMAP.fit_transform` ran on GPU | ||
|
|
||
| Results | ||
| ~~~~~~~ | ||
|
|
||
| At the time of writing and on the hardware the author used the | ||
| ``fit_transform`` step saw a roughly **~4x speedup** because cuML's GPU | ||
| UMAP replaces the CPU optimization. The KNN step (``nearest_neighbors``) | ||
| is a standalone function call that ``cuml.accel`` does not currently | ||
| intercept, so it runs on CPU in both cases. Despite this, the overall | ||
| UMAP step is still **~2x faster**. | ||
|
|
||
| At smaller scales (< 100K rows) the UMAP step is already fast on CPU and | ||
| the speedup is less pronounced. The benefit grows with dataset size. | ||
|
|
||
|
|
||
| Identifying Acceleratable Applications | ||
| --------------------------------------- | ||
|
|
||
| Any Python tool that calls one of the following is a candidate for | ||
| ``CUML_ACCEL_ENABLED``: | ||
|
|
||
| - ``sklearn`` estimators (KMeans, PCA, DBSCAN, RandomForest, | ||
| LogisticRegression, NearestNeighbors, and | ||
| :doc:`many more <../faq>`) | ||
| - ``umap.UMAP`` | ||
| - ``hdbscan.HDBSCAN`` | ||
|
|
||
| A quick way to check: search an application's dependencies for | ||
| ``scikit-learn``, ``umap-learn``, or ``hdbscan``, or run with | ||
| ``CUML_ACCEL_LOG_LEVEL=info`` and look for ``ran on GPU`` messages | ||
| in the output. | ||
|
|
||
| Checking for CPU Fallbacks | ||
| -------------------------- | ||
|
|
||
| Not all parameter combinations are supported on the GPU. When | ||
| ``cuml.accel`` encounters an unsupported configuration, it silently | ||
| falls back to CPU execution. To detect this, set the log level to | ||
| ``info`` or ``debug``: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| CUML_ACCEL_ENABLED=1 CUML_ACCEL_LOG_LEVEL=info python app.py | ||
|
|
||
| Lines containing ``ran on GPU`` confirm GPU execution. Lines | ||
| containing ``falling back to CPU`` indicate a fallback, along with | ||
| the reason. See :doc:`../logging-and-profiling` for more detail. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.