-
Notifications
You must be signed in to change notification settings - Fork 534
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
Experimental command line interface UX #6135
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d63e222
ENH Make get_param_names a class method to match Scikit-learn
dantegd 4a1a7bc
ENH Make get_param_names a class method in cython files too
dantegd 9eb0255
FIX remove changes to dask estimators
dantegd 1086f75
Merge branch 'branch-24.12' into 2412-fix-classmethod
dantegd abf81bd
Style fixes
dantegd f43e580
FIX self to cls in qn.pyx
dantegd c902164
FIX final typo fix hopefully
dantegd 00c14d6
Merge remote-tracking branch 'upstream/branch-24.12' into 2412-fix-cl…
divyegala d46c31d
passing tests
divyegala 24a8047
Merge branch 'branch-24.12' into 2412-fix-classmethod
divyegala 009546c
Update ESTIMATOR_GUIDE.md
divyegala 9c3edce
FEA First commit
dantegd 502886b
FIX typo
dantegd 5c441a3
FIX fixes and improvements
dantegd 15ac83d
FIX typo
dantegd 7b8fdd4
ENH Hyperparameter translation improvements
dantegd 33c6a7e
Merge branch 'branch-24.12' into fea-cli
dantegd 20c345b
ENH Simplification of proxy estimator code and multiple fixes/improve…
dantegd cb2234d
FIX conditional for dispatching in base and add clarifying comment
dantegd 4f5e7c5
FIX Remove commented code
dantegd 4e193d0
ENH Simplify proxy estimator to remove meta class and add docstrings
dantegd 5772e0d
ENH Multiple improvements, cleanups and fixes from PR review
dantegd 881ada1
Style fixes
dantegd b32495d
ENH simplification of hyperparam translator method as suggested by PR…
dantegd 26f64ad
FIX correct value in elastic net dict
dantegd de51949
FEA Use new ProxyModule simpler mechanism
dantegd 510da44
FIX Multiple fixes
dantegd dfa7828
Style fixes
dantegd cd84519
Style fixes
dantegd f4d78c7
FIX PR fix and small fix for ridge, tsne and dask
dantegd a599330
FIX change directory path before running accel tests
dantegd 43a7f7a
FIX separate tests into their own file to fix codevoc configuration f…
dantegd 0730087
Merge branch 'branch-24.12' into fea-cli
dantegd d5d64db
FIX permissions of CI file
dantegd 38ab735
Merge branch 'fea-cli' of github.com:dantegd/cuml into fea-cli
dantegd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
# Support invoking run_cuml_singlegpu_pytests.sh outside the script directory | ||
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuml/cuml/tests/experimental/accel | ||
|
||
python -m pytest -p cuml.experimental.accel --cache-clear "$@" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA 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 importlib | ||
|
||
from .magics import load_ipython_extension | ||
|
||
from cuml.internals import logger | ||
from cuml.internals.global_settings import GlobalSettings | ||
from cuml.internals.memory_utils import set_global_output_type | ||
|
||
__all__ = ["load_ipython_extension", "install"] | ||
|
||
|
||
def _install_for_library(library_name): | ||
importlib.import_module(f"._wrappers.{library_name}", __name__) | ||
return True | ||
|
||
|
||
def install(): | ||
"""Enable cuML Accelerator Mode.""" | ||
logger.set_level(logger.level_info) | ||
logger.set_pattern("%v") | ||
|
||
logger.info("cuML: Installing experimental accelerator...") | ||
loader_sklearn = _install_for_library(library_name="sklearn") | ||
loader_umap = _install_for_library(library_name="umap") | ||
loader_hdbscan = _install_for_library(library_name="hdbscan") | ||
|
||
GlobalSettings().accelerator_loaded = all( | ||
[loader_sklearn, loader_umap, loader_hdbscan] | ||
) | ||
|
||
GlobalSettings().accelerator_active = True | ||
|
||
if GlobalSettings().accelerator_loaded: | ||
logger.info( | ||
"cuML: experimental accelerator successfully initialized..." | ||
) | ||
else: | ||
logger.info("cuML: experimental accelerator failed to initialize...") | ||
|
||
set_global_output_type("numpy") | ||
|
||
|
||
def pytest_load_initial_conftests(early_config, parser, args): | ||
# https://docs.pytest.org/en/7.1.x/reference/\ | ||
# reference.html#pytest.hookspec.pytest_load_initial_conftests | ||
try: | ||
install() | ||
except RuntimeError: | ||
raise RuntimeError( | ||
"An existing plugin has already loaded sklearn. Interposing failed." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA 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 click | ||
import code | ||
import os | ||
import runpy | ||
import sys | ||
|
||
from . import install | ||
|
||
|
||
@click.command() | ||
@click.option("-m", "module", required=False, help="Module to run") | ||
@click.option( | ||
"--strict", | ||
is_flag=True, | ||
default=False, | ||
help="Turn strict mode for hyperparameters on.", | ||
) | ||
@click.argument("args", nargs=-1) | ||
def main(module, strict, args): | ||
|
||
if strict: | ||
os.environ["CUML_ACCEL_STRICT_MODE"] = "ON" | ||
|
||
install() | ||
|
||
if module: | ||
(module,) = module | ||
# run the module passing the remaining arguments | ||
# as if it were run with python -m <module> <args> | ||
sys.argv[:] = [module] + args # not thread safe? | ||
runpy.run_module(module, run_name="__main__") | ||
elif len(args) >= 1: | ||
# Remove ourself from argv and continue | ||
sys.argv[:] = args | ||
runpy.run_path(args[0], run_name="__main__") | ||
else: | ||
if sys.stdin.isatty(): | ||
banner = f"Python {sys.version} on {sys.platform}" | ||
site_import = not sys.flags.no_site | ||
if site_import: | ||
cprt = 'Type "help", "copyright", "credits" or "license" for more information.' | ||
banner += "\n" + cprt | ||
else: | ||
# Don't show prompts or banners if stdin is not a TTY | ||
sys.ps1 = "" | ||
sys.ps2 = "" | ||
banner = "" | ||
|
||
# Launch an interactive interpreter | ||
code.interact(banner=banner, exitmsg="") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA 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. | ||
# | ||
|
||
wrapped_estimators = { | ||
"KMeans": ("cuml.cluster", "KMeans"), | ||
"DBSCAN": ("cuml.cluster", "DBSCAN"), | ||
"PCA": ("cuml.decomposition", "PCA"), | ||
"TruncatedSVD": ("cuml.decomposition", "TruncatedSVD"), | ||
"KernelRidge": ("cuml.kernel_ridge", "KernelRidge"), | ||
"LinearRegression": ("cuml.linear_model", "LinearRegression"), | ||
"LogisticRegression": ("cuml.linear_model", "LogisticRegression"), | ||
"ElasticNet": ("cuml.linear_model", "ElasticNet"), | ||
"Ridge": ("cuml.linear_model", "Ridge"), | ||
"Lasso": ("cuml.linear_model", "Lasso"), | ||
"TSNE": ("cuml.manifold", "TSNE"), | ||
"NearestNeighbors": ("cuml.neighbors", "NearestNeighbors"), | ||
"KNeighborsClassifier": ("cuml.neighbors", "KNeighborsClassifier"), | ||
"KNeighborsRegressor": ("cuml.neighbors", "KNeighborsRegressor"), | ||
"UMAP": ("cuml.manifold", "UMAP"), | ||
"HDBSCAN": ("cuml.cluster", "HDBSCAN"), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA 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 ..estimator_proxy import intercept | ||
|
||
|
||
HDBSCAN = intercept( | ||
original_module="hdbscan", | ||
accelerated_module="cuml.cluster", | ||
original_class_name="HDBSCAN", | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the no-code change magic kicks in when running the pytest suite? Very cool.
By the way, does it affect the other pytests that are outside
cuml.experimental.accel
? Many of our existing tests assert that cuML algorithm matches output of sklearn's counterpart.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only affects pytests that are run with the
-p
flagpytest -p cuml.experimental.accel ...