-
Notifications
You must be signed in to change notification settings - Fork 184
DOC, MAINT: Improve GPU docs, remove references to dpctl arrays #2721
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
david-cortes-intel
merged 13 commits into
uxlfoundation:main
from
david-cortes-intel:better_gpu_docs
Nov 17, 2025
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
74804ba
clarify details on gpu support, remove references to dpctl arrays
david-cortes-intel 5db1c51
formatting
david-cortes-intel 947b872
more links
david-cortes-intel f21f741
more hints
david-cortes-intel dbbc3e0
add torch examples
david-cortes-intel b7b0c67
standardize references to sycl
david-cortes-intel d71a1cf
prefer links to parent pages
david-cortes-intel 931d886
more links
david-cortes-intel d4f32eb
Update sklearnex/_config.py
david-cortes-intel 57e45c1
Update doc/sources/oneapi-gpu.rst
david-cortes-intel aae3d17
Update doc/sources/oneapi-gpu.rst
david-cortes-intel be5582d
Update doc/sources/config-contexts.rst
david-cortes-intel 6473702
Update doc/sources/oneapi-gpu.rst
david-cortes-intel 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
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,91 @@ | ||
| .. Copyright contributors to the oneDAL project | ||
| .. | ||
| .. Licensed under the Apache License, Version 2.0 (the "License"); | ||
| .. you may not use this file except in compliance with the License. | ||
| .. You may obtain a copy of the License at | ||
| .. | ||
| .. http://www.apache.org/licenses/LICENSE-2.0 | ||
| .. | ||
| .. Unless required by applicable law or agreed to in writing, software | ||
| .. distributed under the License is distributed on an "AS IS" BASIS, | ||
| .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| .. See the License for the specific language governing permissions and | ||
| .. limitations under the License. | ||
| .. include:: substitutions.rst | ||
| .. _config_contexts: | ||
|
|
||
| ========================================= | ||
| Configuration Contexts and Global Options | ||
| ========================================= | ||
|
|
||
| Overview | ||
| ======== | ||
|
|
||
| Just like |sklearn|, the |sklearnex| offers configurable options which can be managed | ||
| locally through a configuration context, or globally through process-wide settings, | ||
| by extending the configuration-related functions from |sklearn| (see :obj:`sklearn.config_context` | ||
| for details). | ||
|
|
||
| Configurations in the |sklearnex| are particularly useful for :doc:`GPU functionalities <oneapi-gpu>` | ||
| and :doc:`SMPD mode <distributed-mode>`, and are necessary to modify for enabling :doc:`array API <array_api>`. | ||
|
|
||
| Configuration context and global options manager for the |sklearnex| can either be imported directly | ||
| from the module ``sklearnex``, or can be imported from the ``sklearn`` module after applying patching. | ||
|
|
||
| Note that options in the |sklearnex| are a superset of options from |sklearn|, and options passed to | ||
| the configuration contexts and global settings of the |sklearnex| will also affect |sklearn| if the | ||
| option is supported by it - meaning: the same context manager or global option setter is used for | ||
david-cortes-intel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| both libraries. | ||
|
|
||
| Example usage | ||
| ============= | ||
|
|
||
| Example using the ``target_offload`` option to make computations run on a GPU: | ||
|
|
||
| With a local context | ||
| -------------------- | ||
|
|
||
| Here, only the operations from |sklearn| and from the |sklearnex| that happen within the 'with' | ||
| block will be affected by the options: | ||
|
|
||
| .. code:: python | ||
|
|
||
| import numpy as np | ||
| from sklearnex import config_context | ||
| from sklearnex.cluster import DBSCAN | ||
|
|
||
| X = np.array([[1., 2.], [2., 2.], [2., 3.], | ||
| [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) | ||
| with config_context(target_offload="gpu"): | ||
| clustering = DBSCAN(eps=3, min_samples=2).fit(X) | ||
|
|
||
| As a global option | ||
| ------------------ | ||
|
|
||
| Here, all computations from |sklearn| and from the |sklearnex| that happen after the option | ||
| is modified are affected: | ||
|
|
||
| .. code:: python | ||
|
|
||
| import numpy as np | ||
| from sklearnex import set_config | ||
| from sklearnex.cluster import DBSCAN | ||
|
|
||
| X = np.array([[1., 2.], [2., 2.], [2., 3.], | ||
| [8., 7.], [8., 8.], [25., 80.]], dtype=np.float32) | ||
|
|
||
| set_config(target_offload="gpu") # set it globally | ||
| clustering = DBSCAN(eps=3, min_samples=2).fit(X) | ||
| set_config(target_offload="auto") # restore it back | ||
|
|
||
| API Reference | ||
| ============= | ||
|
|
||
| Note that all of the options accepted by these functions in |sklearn| are also accepted | ||
| here - these just list the additional options offered by the |sklearnex|. | ||
|
|
||
| .. autofunction:: sklearnex.config_context | ||
|
|
||
| .. autofunction:: sklearnex.get_config | ||
|
|
||
| .. autofunction:: sklearnex.set_config | ||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor naming conventions nitpick - I'd say it makes more sense to refer to "|sklearnex|" compared to "the |sklearnex|". The name of the project is Extension for scikit-learn. This could apply to line 24, 29, 32, 36, 48, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a macro that expands to "Extension for Scikit-learn*":
scikit-learn-intelex/doc/sources/conf.py
Line 132 in 186b741
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but I mean to remove "the" in "the |sklearnex|" and just refer to it as |sklearnex|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in this case "Just like |sklearn|, the Extension for Scikit-learn offers configurable options which can be managed" would be "Just like |sklearn|, Extension for Scikit-learn offers configurable options which can be managed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say
.. sounds more correct to me than
.. if put within a larger paragraph.