Skip to content

Commit f8799cf

Browse files
authored
Add cupy & cuML support for GPU-native imputation (#23)
Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>
1 parent 1ea5cbf commit f8799cf

File tree

11 files changed

+516
-312
lines changed

11 files changed

+516
-312
lines changed

.github/workflows/test-gpu.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: nvidia-smi
4141

4242
- name: Install Python
43-
uses: actions/setup-python@v5
43+
uses: actions/setup-python@v6
4444
with:
4545
python-version: "3.12"
4646

@@ -50,7 +50,7 @@ jobs:
5050
cache-dependency-glob: pyproject.toml
5151

5252
- name: Install fknni
53-
run: uv pip install --system -e ".[test,faissgpu]"
53+
run: uv pip install --system -e ".[test,faissgpu,rapids12]"
5454
- name: Pip list
5555
run: pip list
5656

ci/environment.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/notebooks/faiss.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 1,
31+
"execution_count": null,
3232
"metadata": {
3333
"ExecuteTime": {
3434
"end_time": "2024-04-25T13:28:24.303873023Z",
@@ -40,7 +40,7 @@
4040
"source": [
4141
"import numpy as np\n",
4242
"import pandas as pd\n",
43-
"from fknni import FaissImputer\n",
43+
"from fknni import FastKNNImputer\n",
4444
"from sklearn.impute import KNNImputer"
4545
]
4646
},
@@ -795,7 +795,7 @@
795795
},
796796
{
797797
"cell_type": "code",
798-
"execution_count": 4,
798+
"execution_count": null,
799799
"metadata": {
800800
"ExecuteTime": {
801801
"end_time": "2024-04-25T13:28:24.316976982Z",
@@ -822,7 +822,7 @@
822822
}
823823
],
824824
"source": [
825-
"faiss_imputer = FaissImputer(n_neighbors=5, strategy=\"weighted\")\n",
825+
"faiss_imputer = FastKNNImputer(n_neighbors=5, strategy=\"weighted\")\n",
826826
"\n",
827827
"df_imputed_faiss = faiss_imputer.fit_transform(df_missing)\n",
828828
"df_imputed_faiss"
@@ -965,7 +965,7 @@
965965
},
966966
{
967967
"cell_type": "code",
968-
"execution_count": 10,
968+
"execution_count": null,
969969
"metadata": {
970970
"ExecuteTime": {
971971
"end_time": "2024-04-25T13:29:06.633118482Z",
@@ -998,7 +998,7 @@
998998
"X.values[np.unravel_index(missing_indices, X.shape)] = np.nan\n",
999999
"\n",
10001000
"knn_imputer = KNNImputer(n_neighbors=5)\n",
1001-
"faiss_imputer = FaissImputer(n_neighbors=5)\n",
1001+
"faiss_imputer = FastKNNImputer(n_neighbors=5)\n",
10021002
"\n",
10031003
"start_time = time.time()\n",
10041004
"knn_imputed = knn_imputer.fit_transform(X)\n",
@@ -1009,7 +1009,7 @@
10091009
"faiss_time = time.time() - start_time\n",
10101010
"\n",
10111011
"times = [knn_time, faiss_time]\n",
1012-
"labels = [\"scikit-learn KNNImputer\", \"FaissImputer\"]\n",
1012+
"labels = [\"scikit-learn KNNImputer\", \"FastKNNImputer\"]\n",
10131013
"plt.bar(labels, times, color=[\"blue\", \"green\"])\n",
10141014
"plt.ylabel(\"Time in seconds\")\n",
10151015
"plt.title(\"Imputation Time Comparison for 10000 samples and 50 features with 10% missing rate\")\n",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ classifiers = [
2121
"Programming Language :: Python :: 3.13",
2222
]
2323
dependencies = [
24-
"lamin-utils",
24+
"array-api-compat",
2525
"pandas",
2626
"scikit-learn",
2727
]

src/fknni/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from importlib.metadata import version
22

3-
__all__ = ["faiss"]
3+
__version__ = version("fknni")
44

5-
from .faiss import FaissImputer
5+
from .knn import FastKNNImputer
66

7-
__version__ = version("fknni")
7+
__all__ = ["FastKNNImputer", "FaissImputer"]

src/fknni/faiss/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/fknni/faiss/faiss.py

Lines changed: 0 additions & 266 deletions
This file was deleted.

src/fknni/knn/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .knn import FastKNNImputer

0 commit comments

Comments
 (0)