Skip to content

Refactoring of benchmarks #133

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

Merged
merged 36 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
23a7df5
Refactor draft
Alexsandruss Dec 7, 2023
f865330
Fix dev.guide link
Alexsandruss Dec 7, 2023
94a2add
Configs update and minor fixes
Alexsandruss Dec 10, 2023
6831628
Copyright and doc fixes
Alexsandruss Jan 26, 2024
2cb6fa1
Add argument aliases
Alexsandruss Jan 26, 2024
5299104
Update configs and docs with corresponding code changes
Alexsandruss Feb 14, 2024
6a73712
Change INCLUDE directive in config spec
Alexsandruss Feb 20, 2024
ceb813e
Basic daal4py modelbuilders support
Alexsandruss Feb 20, 2024
2a1e134
Correction of configs
Alexsandruss Feb 20, 2024
610dc8e
Add basic sklearn-like emulation of approx. kNN
Alexsandruss Feb 29, 2024
80ce836
Change configs structure (add common sets);
Alexsandruss Mar 8, 2024
11d4a56
Linting
Alexsandruss Mar 8, 2024
6dd91ff
Update online computation mode
Alexsandruss Mar 12, 2024
780a141
Update for ANN emulators
Alexsandruss Mar 14, 2024
c44943c
Update xgboost configs;
Alexsandruss Mar 15, 2024
917cc32
Remove mutex from envs
Alexsandruss Mar 15, 2024
509dbba
Add modin format; fix for faiss ivf_pq compatibility
Alexsandruss Mar 15, 2024
37b21d3
Add modin support; fixes for ANN emulators
Alexsandruss Mar 15, 2024
22ce12e
Add SVS NearestNeighbors emulator
Alexsandruss Mar 16, 2024
1c6bd66
Update CI and minor code rework
Alexsandruss Apr 22, 2024
e318f64
Add dpnp and dpctl support
Alexsandruss Apr 22, 2024
6c8a08b
Intermediate changes: apply comments, bug fixes
Alexsandruss May 21, 2024
836ffcc
Pin CI Python version to 3.10
Alexsandruss May 21, 2024
8453243
CI command fix and doc links fix
Alexsandruss May 22, 2024
06ae1ab
Shell usage fix
Alexsandruss May 22, 2024
9d62d5d
SPMD support
Alexsandruss May 30, 2024
765a5c3
CI fixes
Alexsandruss May 30, 2024
6798d01
Update sklbench args info
Alexsandruss Jun 5, 2024
1510e96
Conda envs and CI conf update
Alexsandruss Jun 7, 2024
ef0b7c5
Example configs update and fixes:
Alexsandruss Jun 13, 2024
831df21
Fixes and comments applying:
Alexsandruss Jun 20, 2024
8359dea
Fix doctree link and add missing config warning
Alexsandruss Jun 20, 2024
96b7e15
CI matrix update and doc fixes
Alexsandruss Jul 3, 2024
dc00f5f
Docs, configs and codeowners changes
Alexsandruss Jul 3, 2024
f2fd91e
Update codeowners and doc fix
Alexsandruss Jul 4, 2024
7d144bc
Add examples run to CI
Alexsandruss Jul 5, 2024
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 SVS NearestNeighbors emulator
  • Loading branch information
Alexsandruss committed May 21, 2024
commit 22ce12ef9f17bc4fea7edc694d8f7335c9f54e0c
11 changes: 11 additions & 0 deletions configs/experiments/nearest_neighbors.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@
"m_subvectors": 0.2
}
}
},
{
"algorithm": {
"library": "sklbench.emulators.svs",
"device": "cpu",
"estimator_params": {
"algorithm": "vamana",
"graph_max_degree": 128,
"window_size": 256
}
}
}
],
"nearest neighbors common parameters": {
Expand Down
2 changes: 1 addition & 1 deletion sklbench/emulators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
# ===============================================================================

__all__ = ["common", "faiss", "raft"]
__all__ = ["common", "faiss", "raft", "svs"]
13 changes: 8 additions & 5 deletions sklbench/emulators/common/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ def get_params(self):
"metric": self.metric,
"metric_params": None,
"p": 2 if "euclidean" in self.metric else None,
"n_lists": self.n_lists,
"n_probes": self.n_probes,
"m_subvectors": self.m_subvectors,
"n_bits": self.n_bits,
}
optional_keys = ["intermediate_graph_degree", "graph_degree"]
optional_keys = [
"n_lists",
"n_probes",
"m_subvectors",
"n_bits",
"intermediate_graph_degree",
"graph_degree",
]
for optional_key in optional_keys:
if hasattr(self, optional_key):
result[optional_key] = getattr(self, optional_key)
Expand Down
20 changes: 20 additions & 0 deletions sklbench/emulators/svs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ===============================================================================
# Copyright 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

from .neighbors import NearestNeighbors


__all__ = ["NearestNeighbors"]
63 changes: 63 additions & 0 deletions sklbench/emulators/svs/neighbors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# ===============================================================================
# Copyright 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

import pysvs
from psutil import cpu_count
from ..common.neighbors import NearestNeighborsBase


class NearestNeighbors(NearestNeighborsBase):
"""
Minimal class emulating `sklearn.neighbors.NearestNeighbors` estimator
"""

def __init__(
self,
n_neighbors=5,
algorithm="vamana",
metric="euclidean",
graph_max_degree=64,
window_size=128,
n_jobs=cpu_count(logical=False),
):
self.n_neighbors = n_neighbors
self.algorithm = algorithm
self.metric = metric
self.graph_max_degree = graph_max_degree
self.window_size = window_size
self.n_jobs = n_jobs

def fit(self, X, y=None):
build_params = pysvs.VamanaBuildParameters(
graph_max_degree=self.graph_max_degree,
window_size=self.window_size,
num_threads=self.n_jobs,
)
self._index = pysvs.Vamana.build(
build_params,
X,
pysvs.DistanceType.L2,
num_threads=self.n_jobs,
)
return self

def kneighbors(self, X, n_neighbors=None, return_distance=True):
k = self.n_neighbors if n_neighbors is None else n_neighbors
indices, distances = self._index.search(X, k)
if return_distance:
return distances, indices
else:
return indices