This document summarizes guidelines and best practices for contributions to the python component of the library cuML, the machine learning component of the RAPIDS ecosystem. This is an evolving document so contributions, clarifications and issue reports are highly welcome.
Please start by reading:
Refer to the section on thread safety in C++ DEVELOPER_GUIDE.md
- PEP8 and flake8 is used to check the adherence to this style.
- sklearn coding guidelines
- Make sure that this algo has been implemented in the C++ side. Refer to C++ DEVELOPER_GUIDE.md for guidelines on developing in C++.
- Refer to the next section for the remaining steps.
- Create a corresponding algoName.pyx file inside
python/cuml
folder. - Ensure that the folder structure inside here reflects that of sklearn's. Example,
pca.pyx
should be kept inside thedecomposition
sub-folder ofpython/cuml
. . Match the corresponding scikit-learn's interface as closely as possible. Refer to their developer guide on API design of sklearn objects for details. - Always make sure to have your class inherit from
cuml.Base
class as your parent/ancestor. - Ensure that the estimator's output fields follow the 'underscore on both sides' convention explained in the documentation of
cuml.Base
. This allows it to support configurable output types.
If you are trying to call into cuda runtime APIs inside cuml.cuda
, in case of any errors, they'll raise a cuml.cuda.CudaRuntimeError
. For example:
from cuml.cuda import Stream, CudaRuntimeError
try:
s = Stream()
s.sync
except CudaRuntimeError as cre:
print("Cuda Error! '%s'" % str(cre))
TBD
We mostly follow PEP 257 style docstrings for documenting the interfaces.
We use https://docs.pytest.org/en/latest/ for writing and running tests. To see existing examples, refer to any of the test_*.py
files in the folder cuml/test
.
TODO: talk about enabling RMM here when it is ready
If you want to schedule the execution of two algorithms concurrently, it is better to create two separate streams and assign them to separate handles. Finally, schedule the algorithms using these handles.
import cuml
from cuml.cuda import Stream
s1 = Stream()
h1 = cuml.Handle()
h1.setStream(s1)
s2 = Stream()
h2 = cuml.Handle()
h2.setStream(s2)
algo1 = cuml.Algo1(handle=h1, ...)
algo2 = cuml.Algo2(handle=h2, ...)
algo1.fit(X1, y1)
algo2.fit(X2, y2)
To know more underlying details about stream ordering refer to the corresponding section of C++ DEVELOPER_GUIDE.md
We currently have Single Process Multiple GPU (SPMG) versions of KNN, OLS and tSVD. Our upcoming versions will concentrate on One Process per GPU (OPG) paradigm.
TODO: Add more details.