This release is a pre-release and may not be stable for production use.
SML: Secure Machine Learning
SML is a python module implementing machine learning algorithm with JAX, which can do secure training and inferring under the magic of SPU.
Our vision is to establish a general-purpose privacy-preserving machine learning(PPML) library, being a secure version of scikit-learn.
Normally, the APIs of our algorithms are designed to be as consistent as possible with scikit-learn. However, due to safety considerations and certain limitations of the SPU, some APIs will undergo changes. Detailed explanations will be provided for any differences in the doc.
Why not scikit-learn
First, scikit-learn is built top on Numpy and SciPy, running on centralized mode. So you must collect all data into one node, which can't protect the privacy of data.
The implementations in scikit-learn are usually very efficient and valid, then why not we just "translate" it to MPC?
The quick answer for this question is accuracy and efficiency.
In PPML, we observe that most framework encodes floating-point to fixed-point number,
which parameterized by field(bitwidth of underlying integer) and fxp_fraction_bits(fractional part bitwidth),
greatly restricting the effective range and precision of floating-point numbers.
on other hand, The major determinant of computational overhead is determined by the MPC protocol,
so the origin cpu-friendly ops may have pool performance.
Our Solution
So we establish a new library SML trying to bridge these gaps:
- accuracy: optimize and test the algorithm based on fixed-point number,
e.g. prefer high-precision ops(
rsqrtrather than1/sqrt), essential re-transform to accommodate the valid range of non-linear ops (see fxp pitfalls). - efficiency: use MPC-friendly op to replace CPU-friendly op, e.g. use numeric approximation trick to avoid sophistic computation, prefer arithmetic ops to comparison ops.
Of course, we also supply an easy-to-test toolbox for advanced developer who wants to develop their own MPC program:
Simulator: provide a fixed-point computation environment and run at high speed. But it's unable to provide a real SPU performance environment, the test results cannot reflect the actual performance of the algorithm.Emulator: emulate on the real MPC protocol using multiple processes/Docker(coming soon), and can provide effective performance results.
So the accuracy can be proved if the algorithm pass the test of simulator,
and you should test the efficiency using emulator.
WARNING: currently, SML is undergoing rapid developments, so it is not recommended for direct use in production environments.
Installation
First, you should clone the spu repo to your local disk:
git clone https://github.com/secretflow/spu.git
Some Prerequisites are required according to your system. After all these installed, you can run any test like:
# run kmeans simulation
# simulation: run program in single process
# used for correctness test
pytest -n auto sml/sml/cluster/tests/kmeans_test.py
# run kmeans emulation
# emulation: run program with multiple processes(LAN setting)
# or multiple dockers(WAN setting, will come soon)
# used for efficiency test.
python3 sml/sml/cluster/emulations/kmeans_emul.py
Algorithm Support lists
See support lists for all our algorithms and features we support.
Development
See development if you would like to contribute to SML.
FAQ
We collect some FAQ, you can check it first before submitting an issue.
Metadata
Release files for sf-sml 0.1.0.dev20250623
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sf_sml-0.1.0.dev20250623-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for sf_sml-0.1.0.dev20250623-py3-none-manylinux_2_28_aarch64.whl |
| sf_sml-0.1.0.dev20250623-py3-none-manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details for sf_sml-0.1.0.dev20250623-py3-none-manylinux2014_x86_64.whl |
| sf_sml-0.1.0.dev20250623-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details for sf_sml-0.1.0.dev20250623-py3-none-macosx_12_0_arm64.whl |
Total release size: 627.2 kB
Release files / sf_sml-0.1.0.dev20250623-py3-none-manylinux_2_28_aarch64.whl
| Download URL | sf_sml-0.1.0.dev20250623-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 209.1 kB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
f49d2d9953aafd22743e3c146ef615a4d18c2ce0ddace6eb698b88f03c66cbc4
|
|
BLAKE2b-256 checksum How to use checksums |
ac15701d0df4bd8da6e743eb4901be098a9f3a2be1cd3205948a5a937981bdb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|
Release files / sf_sml-0.1.0.dev20250623-py3-none-manylinux2014_x86_64.whl
| Download URL | sf_sml-0.1.0.dev20250623-py3-none-manylinux2014_x86_64.whl |
|---|---|
| Size | 209.1 kB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
d3733b91ccf1b13562ae92f7269f81424f5ee45005893fba46d56f1d5e6abb8f
|
|
BLAKE2b-256 checksum How to use checksums |
8f510fbece1086b734e5ab0a5505315594f4ccc189d066392f974b2ee718ff64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|
Release files / sf_sml-0.1.0.dev20250623-py3-none-macosx_12_0_arm64.whl
| Download URL | sf_sml-0.1.0.dev20250623-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 209.1 kB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
12d49cf6f6382ce8d8c8f28bc3c7279999fdb20278f31edc996eda25b11df53f
|
|
BLAKE2b-256 checksum How to use checksums |
46c6cd4a1c8de87f80aab6c60888c07e2769b16175016e43b618ec8d3480f6bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.18
|
Security for sf-sml 0.1.0.dev20250623
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.