Skip to content

DOC: Describe behaviors from array API#2707

Merged
david-cortes-intel merged 5 commits intouxlfoundation:mainfrom
david-cortes-intel:array_api_docs
Oct 10, 2025
Merged

DOC: Describe behaviors from array API#2707
david-cortes-intel merged 5 commits intouxlfoundation:mainfrom
david-cortes-intel:array_api_docs

Conversation

@david-cortes-intel
Copy link
Copy Markdown
Contributor

Description

This PR updates the doc section about array API support to reflect the behaviors of the library as of today.

Since it looks like there won't be major changes in the dispatching logic for a while, the PR tries to describe all of the current behaviors, even if they might not sound very logical.

I am not 100% certain that I'm getting all the details right so @icfaust please give it a thorough read. In particular, I am not sure when sklearnex models will have attributes that are array API classes and when not.

During the changes here, I noticed that the doc page for array API was linking to examples that pass dpnp/dpctl data, but those weren't using array API so data was being moved back and forth regardless. Since those do not have 'array_api' in their names I simply removed them and added a more descriptive example.


Checklist:

Completeness and readability

  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.

Comment thread doc/sources/array_api.rst

When passing array API inputs to methods such as ``.predict()`` of estimators with array API support, the output
will always be of the same class as the inputs, but be aware that array attributes of fitted models (e.g. ``coef_``
in a linear model) will not necessarily be of the same class as array API inputs passed to ``.fit()``, even though
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@icfaust Feel free to add a better paragraph here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll give it a look! Thanks for the work!

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
azure ?
github 73.02% <ø> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@icfaust icfaust left a comment

Choose a reason for hiding this comment

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

Small change necessary, can merge after.

Comment thread doc/sources/array_api.rst Outdated
DPCTL or DPNP inputs are not required to use `config_context(target_offload=device)`.
`sklearnex` will use input usm_ndarray sycl context for device offloading.
.. note::
Unlike |sklearn|, |sklearnex| does not require `array-api-compat <https://github.com/data-apis/array-api-compat>`__
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This note unfortunately needs to be removed. array-api-compat is necessary via sklearn's get_namespace which is used throughout on our side, as well as in validate_data. We just don't insist on array-api-compat in the onedal module/estimators (hence why its either lazy loaded there or functions like get_namespace are avoided).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Comment thread doc/sources/array_api.rst
Comment on lines +105 to +109
While full array API support is currently not implemented for all classes, :external+dpnp:doc:`dpnp.ndarray <reference/ndarray>`
and :external+dpctl:doc:`dpctl.tensor <api_reference/dpctl/tensor>` inputs are supported by all the classes
that have :ref:`GPU support <oneapi_gpu>`. Note however that if array API support is not enabled in |sklearn|,
when passing these classes as inputs, data will be transferred to host and then back to device instead of being
used directly.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Eloquently put.

@david-cortes-intel david-cortes-intel merged commit 3d86aeb into uxlfoundation:main Oct 10, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants