Skip to content

DOC Add note in Array API doc regarding support for devices without float 64 support #28034

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions doc/modules/array_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ automatically skipped. Therefore it's important to run the tests with the
pip install array-api-compat # and other libraries as needed
pytest -k "array_api" -v

Note on `float64` support
-------------------------

`float64` precision can sometimes be mandatory, where `float32` or inferior precision
might result in catastrophic numerical errors. For this reason there are occurrences
in scikit-learn of _upcasting_, where some computational steps will always use `float64`
precision, even if the input data is given with inferior precision.

However, some array manipulation libraries might leverage devices that do not support
operations with `float64` precision, such as MPS on macOS or Intel® integrated GPUs.
scikit-learn always favors consistency of the numerical stability across all
use-cases, and it will locally dispatch the compute to numpy for steps that have
a minimal precision requirement that is not supported by the device, at the costs of
a transfer to CPU.

Minimizing the usage of `float64` upcasting in scikit-learn is an open improvement
direction, to maybe yield better performance from devices that do not support it,
Copy link
Member

@glemaitre glemaitre Jan 12, 2024

Choose a reason for hiding this comment

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

Suggested change
direction, to maybe yield better performance from devices that do not support it,
direction, to yield better performance from devices that do not support it,

Copy link
Member

Choose a reason for hiding this comment

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

I think we need the "yield"

Copy link
Member

Choose a reason for hiding this comment

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

Oh actually, I wanted to remove the "maybe"

Copy link
Member

Choose a reason for hiding this comment

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

I can't reconstruct what I meant to say. Reading my comment now I am confused.com about what I was trying to say (it seems like a comment written while distracted) :-/

Let's ignore it?

since it avoids data copies and benefits from a higher FLOPS.

Note on MPS device support
--------------------------

Expand Down