From 12c3b4fc6be424d71ad6deb008975f0a6e52fef0 Mon Sep 17 00:00:00 2001 From: Franck Charras <29153872+fcharras@users.noreply.github.com> Date: Fri, 29 Dec 2023 12:20:42 +0100 Subject: [PATCH 1/2] Add note in Array API doc regarding support for devices without float64 support --- doc/modules/array_api.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/modules/array_api.rst b/doc/modules/array_api.rst index ebc157fb169d1..c54712cf1ebbe 100644 --- a/doc/modules/array_api.rst +++ b/doc/modules/array_api.rst @@ -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 a occurences +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 accross 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, +since it will avoid data copies and might benefit from higher FLOPS. + Note on MPS device support -------------------------- From 929261fc1e18ee83882863698bebff19f8e4683d Mon Sep 17 00:00:00 2001 From: Tim Head Date: Mon, 12 Feb 2024 14:45:33 +0100 Subject: [PATCH 2/2] Apply typo fixes Co-authored-by: Guillaume Lemaitre --- doc/modules/array_api.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/modules/array_api.rst b/doc/modules/array_api.rst index c54712cf1ebbe..29e7b79bb1d65 100644 --- a/doc/modules/array_api.rst +++ b/doc/modules/array_api.rst @@ -136,24 +136,24 @@ 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 ------------------------ +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 a occurences -in scikit-learn of _upcasting_, where some computational steps will always use float64 +`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 accross all +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 +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, -since it will avoid data copies and might benefit from higher FLOPS. +since it avoids data copies and benefits from a higher FLOPS. Note on MPS device support --------------------------