Skip to content
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

(do not merge) Dev/raw with spmd incremental2 #2268

Draft
wants to merge 71 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
daed528
ENH: using only raw inputs for onedal backend
samir-nasibli Nov 5, 2024
1be2ffb
minor fix
samir-nasibli Nov 5, 2024
a23b677
lin
samir-nasibli Nov 5, 2024
664e140
fix usw_raw_input True/False with dpctl tensor on device
ahuber21 Nov 5, 2024
518dceb
Add hacks to kmeans
ahuber21 Nov 5, 2024
df9d930
Basic statistics online
samir-nasibli Nov 5, 2024
2954913
Merge branch 'enh/raw_inputs' of https://github.com/samir-nasibli/sci…
samir-nasibli Nov 5, 2024
3ef345c
Covariance support
ethanglaser Nov 5, 2024
f1c9233
Merge branch 'enh/raw_inputs' of https://github.com/samir-nasibli/sci…
ethanglaser Nov 5, 2024
66d7b2d
DBSCAN support
samir-nasibli Nov 5, 2024
c5d26a4
Merge branch 'enh/raw_inputs' of https://github.com/samir-nasibli/sci…
samir-nasibli Nov 5, 2024
1350c10
minor fix for dbscan
samir-nasibli Nov 5, 2024
8aaaa70
minor fix for DBSCAN
samir-nasibli Nov 5, 2024
f0d92ae
Apply raw input for batch linear and logistic regression
Alexsandruss Nov 5, 2024
3b58beb
Apply linters
Alexsandruss Nov 5, 2024
d7f2c3c
fix for DBSCAN
samir-nasibli Nov 5, 2024
1aca420
support for Random Forest
samir-nasibli Nov 5, 2024
362930a
PCA support (batch)
ethanglaser Nov 5, 2024
bc37391
Merge branch 'enh/raw_inputs' of https://github.com/samir-nasibli/sci…
ethanglaser Nov 5, 2024
102dcae
minor fix for dbscan and rf
samir-nasibli Nov 5, 2024
6edab5b
fully fixed DBSCAN
samir-nasibli Nov 6, 2024
e153a28
Add Incremental Linear Regression
Alexsandruss Nov 6, 2024
37d32c9
Linting
Alexsandruss Nov 6, 2024
71c5135
add modification to knn
ahuber21 Nov 6, 2024
db9f021
minor update for RF
samir-nasibli Nov 6, 2024
bc353da
fix for RandomForestClassifier
samir-nasibli Nov 7, 2024
e873205
minor for RF
samir-nasibli Nov 7, 2024
fe3222a
Update online algos
olegkkruglov Nov 7, 2024
5b3ad17
Merge branch 'enh/raw_inputs' of https://github.com/samir-nasibli/sci…
samir-nasibli Nov 7, 2024
eaaab32
fix for RF regressor
samir-nasibli Nov 7, 2024
a7f0c2d
fix workaround for knn
ahuber21 Nov 7, 2024
d9a2966
kmeans predict support
ethanglaser Nov 12, 2024
3562c69
Merge remote-tracking branch 'origin/main' into enh/raw_inputs
ahuber21 Dec 16, 2024
42c3614
fix merge errors
ahuber21 Dec 16, 2024
53bcc7b
fix some tests
ahuber21 Dec 17, 2024
9964c5a
fixup
ahuber21 Dec 17, 2024
84afb62
undo more changes that broke tests
ahuber21 Dec 17, 2024
cf5b736
format
ahuber21 Dec 17, 2024
92393b9
restore original behavior when running without raw inputs
ahuber21 Dec 18, 2024
13471e5
restore original behavior when running without raw inputs
ahuber21 Dec 18, 2024
a8f3f19
align code
ahuber21 Dec 18, 2024
2b07c00
restore original from_table
ahuber21 Dec 19, 2024
6104736
add use_raw_input tests for incremental covariance
ahuber21 Dec 19, 2024
df03233
Add basic statistics testing
ahuber21 Dec 19, 2024
8a166b7
add incremental basic statistics
ahuber21 Dec 19, 2024
fb5f5fa
add dbscan
ahuber21 Dec 19, 2024
7072041
Merge remote-tracking branch 'origin/main' into dev/ahuber/raw-inputs…
ahuber21 Dec 19, 2024
91384ed
add kmeans
ahuber21 Dec 20, 2024
6dec57d
add covariance
ahuber21 Dec 20, 2024
529a7b8
align get_config() import and use_raw_input retrieval
ahuber21 Dec 20, 2024
9f78cbd
add incremental_pca
ahuber21 Dec 20, 2024
658ccc1
add pca
ahuber21 Dec 20, 2024
5e74a54
add incremental linear
ahuber21 Dec 20, 2024
dfbf223
add linear_model
ahuber21 Dec 22, 2024
c4094fb
Merge branch 'dev/ahuber/raw-inputs-dispatching' into enh/raw_inputs
ahuber21 Dec 22, 2024
6112457
Refactor incremental spmd algos
ethanglaser Jan 9, 2025
bb5206f
raw inputs updates for functional forest predict
ethanglaser Jan 9, 2025
9c72d9c
Clear spmd impls, specify non-spmd get_policy in base cls
ethanglaser Jan 10, 2025
e455c56
black
ethanglaser Jan 10, 2025
572bae5
minor bs fix
ethanglaser Jan 10, 2025
da5c27c
apply changes to PCA predict and add transform
ethanglaser Jan 14, 2025
6fdcbaa
add comments
ethanglaser Jan 14, 2025
4acc102
Merge branch 'uxlfoundation:main' into dev/eglaser-online-spmd-refactor
ethanglaser Jan 14, 2025
8211a23
fixes for logreg predict_proba, knnreg, inc cov, inc pca
ethanglaser Jan 18, 2025
e3425bf
dbscan + inc linreg changes
ethanglaser Jan 20, 2025
0630bc1
Merge 'upstream/main' into enh/raw_inputs
ethanglaser Jan 20, 2025
52ba18a
black
ethanglaser Jan 20, 2025
90b7175
temporary for CI
ethanglaser Jan 21, 2025
f4d18cd
isorted
ethanglaser Jan 21, 2025
f9e6b36
merge main into branch
ethanglaser Jan 21, 2025
087bd26
merge incremental spmd updates with raw inputs changes
ethanglaser Jan 21, 2025
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
Prev Previous commit
Next Next commit
Add hacks to kmeans
ahuber21 committed Nov 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 518dceb471a36f348d26dd3f747013d61d78f59d
3 changes: 1 addition & 2 deletions onedal/basic_statistics/basic_statistics.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
# limitations under the License.
# ==============================================================================

import warnings
from abc import ABCMeta, abstractmethod

import numpy as np
@@ -74,7 +73,6 @@ def __init__(self, result_options="all", algorithm="by_default"):
super().__init__(result_options, algorithm)

def fit(self, data, sample_weight=None, queue=None):
policy = self._get_policy(queue, data, sample_weight)
is_csr = _is_csr(data)

use_raw_input = _get_config().get("use_raw_input", False) is True
@@ -91,6 +89,7 @@ def fit(self, data, sample_weight=None, queue=None):

# TODO
# use xp for dtype.
policy = self._get_policy(queue, data, sample_weight)
data, sample_weight = _convert_to_supported(policy, data, sample_weight)

data_table = to_table(data, sua_iface=_get_sycl_namespace(data)[0])
32 changes: 22 additions & 10 deletions onedal/cluster/kmeans.py
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@
from ..common._mixin import ClusterMixin, TransformerMixin
from ..datatypes import _convert_to_supported, from_table, to_table
from ..utils import _check_array, _is_arraylike_not_scalar, _is_csr
from ..utils._array_api import _get_sycl_namespace
from .._config import _get_config


class _BaseKMeans(onedal_BaseEstimator, TransformerMixin, ClusterMixin, ABC):
@@ -80,7 +82,7 @@ def _get_kmeans_init(self, cluster_count, seed, algorithm):
def _get_basic_statistics_backend(self, result_options):
return BasicStatistics(result_options)

def _tolerance(self, X_table, rtol, is_csr, policy, dtype):
def _tolerance(self, X_table, rtol, is_csr, policy, dtype, sua_iface):
"""Compute absolute tolerance from the relative tolerance"""
if rtol == 0.0:
return rtol
@@ -94,7 +96,7 @@ def _tolerance(self, X_table, rtol, is_csr, policy, dtype):
return mean_var * rtol

def _check_params_vs_input(
self, X_table, is_csr, policy, default_n_init=10, dtype=np.float32
self, X_table, is_csr, policy, default_n_init=10, dtype=np.float32, sua_iface=None
):
# n_clusters
if X_table.shape[0] < self.n_clusters:
@@ -103,7 +105,7 @@ def _check_params_vs_input(
)

# tol
self._tol = self._tolerance(X_table, self.tol, is_csr, policy, dtype)
self._tol = self._tolerance(X_table, self.tol, is_csr, policy, dtype, sua_iface)

# n-init
# TODO(1.4): Remove
@@ -261,18 +263,28 @@ def _fit_backend(
)

def _fit(self, X, module, queue=None):
policy = self._get_policy(queue, X)
is_csr = _is_csr(X)
X = _check_array(
X, dtype=[np.float64, np.float32], accept_sparse="csr", force_all_finite=False
)

use_raw_input = _get_config().get("use_raw_input") is True
if use_raw_input and _get_sycl_namespace(X)[0] is not None:
queue = X.sycl_queue

if not use_raw_input:
X = _check_array(
X, dtype=[np.float64, np.float32], accept_sparse="csr", force_all_finite=False
)

policy = self._get_policy(queue, X)

X = _convert_to_supported(policy, X)
dtype = get_dtype(X)
X_table = to_table(X)
sua_iface = _get_sycl_namespace(X)[0]
X_table = to_table(X, sua_iface=sua_iface)

self._check_params_vs_input(X_table, is_csr, policy, dtype=dtype)
self._check_params_vs_input(X_table, is_csr, policy, dtype=dtype, sua_iface=sua_iface)

params = self._get_onedal_params(is_csr, dtype)
# not used?
# params = self._get_onedal_params(is_csr, dtype)

self.n_features_in_ = X_table.column_count

2 changes: 1 addition & 1 deletion onedal/datatypes/_data_conversion.py
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ def convert_one_from_table(table, sycl_queue=None, sua_iface=None, xp=None):
def convert_one_to_table(arg, sua_iface=None):
# Note: currently only oneDAL homogen tables are supported and the
# contiuginity of the input array should be checked in advance.
if sua_iface:
if arg is not None and sua_iface:
return _backend.sua_iface_to_table(arg)

if not _is_csr(arg):