Skip to content

DOC: Document lack of support for sparse torch tensors#3186

Open
david-cortes-intel wants to merge 1 commit into
uxlfoundation:mainfrom
david-cortes-intel:unsupported_sp_torch
Open

DOC: Document lack of support for sparse torch tensors#3186
david-cortes-intel wants to merge 1 commit into
uxlfoundation:mainfrom
david-cortes-intel:unsupported_sp_torch

Conversation

@david-cortes-intel
Copy link
Copy Markdown
Contributor

Description

From some experiments, it appears that some cases with array API support in scikit-learn work fine with sparse torch arrays, even though these aren't strictly part of array API.

In sklearnex, the table convertors do not have any special handling of sparse torch arrays, so they usually error out. This PR documents the lack of support for them.


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
azure ?
github 80.33% <ø> (ø)

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

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

Comment thread doc/sources/array_api.rst
Sparse arrays
~~~~~~~~~~~~~

Currently, sparse arrays from libraries other than SciPy (e.g. ``torch.sparse``) are not supported.
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.

Are those supported in stock scikit?
I mean, I do not think we should specify in the docs everyting that might be supported, but is not supported for now in sklearnex.

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.

Their docs do not mention anything about them, but they work in some cases:
scikit-learn/scikit-learn#34087

Technically, sparse classes from pytorch are torch tensors and inherit from the class used by dense tensors, which according to the docs should be supported:

and ``.predict()``, such as |dpnp_array| or `torch.tensor <https://docs.pytorch.org/docs/stable/tensors.html>`__.

So this PR clarifies that they aren't actually supported.

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.

Form the conversation in scikit-learn/scikit-learn#34087 I still do not see that it is necessary to add this kind of note on our side.

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.

But our docs do mention that array API works on torch.Tensor:

and ``.predict()``, such as |dpnp_array| or `torch.tensor <https://docs.pytorch.org/docs/stable/tensors.html>`__.

.. and sparse tensor technically fall into that category.

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