# SPU: Secure Processing Unit
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/secretflow/spu/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/secretflow/spu/tree/main)
[![Python](https://img.shields.io/pypi/pyversions/spu.svg)](https://pypi.org/project/spu/)
[![PyPI version](https://img.shields.io/pypi/v/spu)](https://pypi.org/project/spu/)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/secretflow/spu/badge)](https://securityscorecards.dev/viewer/?uri=github.com/secretflow/spu)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8311/badge)](https://www.bestpractices.dev/projects/8311)
SPU (Secure Processing Unit) aims to be a `provable`, `measurable` secure computation device,
which provides computation ability while keeping your private data protected.
SPU could be treated as a programmable device, it's not designed to be used directly.
Normally we use SecretFlow framework, which use SPU as the underline secure computing device.
Currently, we mainly focus on `provable` security. It contains a secure runtime that evaluates
[XLA](https://www.tensorflow.org/xla/operation_semantics)-like tensor operations,
which use [MPC](https://en.wikipedia.org/wiki/Secure_multi-party_computation) as the underline
evaluation engine to protect privacy information.
SPU python package also contains a simple distributed module to demo SPU usage,
but it's **NOT designed for production** due to system security and performance concerns,
please **DO NOT** use it directly in production.
## Contribution Guidelines
If you would like to contribute to SPU, please check [Contribution guidelines](CONTRIBUTING.md).
If you would like to use SPU for research purposes, please check [research development guidelines](docs/SPU_gudience.pdf) from [@fionser](https://github.com/fionser).
This documentation also contains instructions for [build and testing](CONTRIBUTING.md#build).
## Installation Guidelines
### Supported platforms
| | Linux x86_64 | Linux aarch64 | macOS x64 | macOS Apple Silicon | Windows x64 | Windows WSL2 x64 |
|------------|--------------|---------------|----------------|---------------------|----------------|---------------------|
| CPU | yes | yes | yes<sup>1</sup>| yes | no | yes |
| NVIDIA GPU | experimental | no | no | n/a | no | experimental |
1. Due to CI resource limitation, macOS x64 prebuild binary is no longer available.
### Instructions
Please follow [Installation Guidelines](INSTALLATION.md) to install SPU.
### Hardware Requirements
| General Features | FourQ based PSI | GPU |
| ---------------- | --------------- | --- |
| AVX/ARMv8 | AVX2/ARMv8 | CUDA 11.8+ |
## Citing SPU
If you think SPU is helpful for your research or development, please consider citing our papers:
[USENIX ATC'23](https://www.usenix.org/conference/atc23/presentation/ma)
```text
@inproceedings {spu,
author = {Junming Ma and Yancheng Zheng and Jun Feng and Derun Zhao and Haoqi Wu and Wenjing Fang and Jin Tan and Chaofan Yu and Benyu Zhang and Lei Wang},
title = {{SecretFlow-SPU}: A Performant and {User-Friendly} Framework for {Privacy-Preserving} Machine Learning},
booktitle = {2023 USENIX Annual Technical Conference (USENIX ATC 23)},
year = {2023},
isbn = {978-1-939133-35-9},
address = {Boston, MA},
pages = {17--33},
url = {https://www.usenix.org/conference/atc23/presentation/ma},
publisher = {USENIX Association},
month = jul,
}
```
[ICML'24](https://proceedings.mlr.press/v235/wu24d.html)
```text
@inproceedings{ditto,
title = {Ditto: Quantization-aware Secure Inference of Transformers upon {MPC}},
author = {Wu, Haoqi and Fang, Wenjing and Zheng, Yancheng and Ma, Junming and Tan, Jin and Wang, Lei},
booktitle = {Proceedings of the 41st International Conference on Machine Learning},
pages = {53346--53365},
year = {2024},
editor = {Salakhutdinov, Ruslan and Kolter, Zico and Heller, Katherine and Weller, Adrian and Oliver, Nuria and Scarlett, Jonathan and Berkenkamp, Felix},
volume = {235},
series = {Proceedings of Machine Learning Research},
month = {21--27 Jul},
publisher = {PMLR},
pdf = {https://raw.githubusercontent.com/mlresearch/v235/main/assets/wu24d/wu24d.pdf},
url = {https://proceedings.mlr.press/v235/wu24d.html},
abstract = {Due to the rising privacy concerns on sensitive client data and trained models like Transformers, secure multi-party computation (MPC) techniques are employed to enable secure inference despite attendant overhead. Existing works attempt to reduce the overhead using more MPC-friendly non-linear function approximations. However, the integration of quantization widely used in plaintext inference into the MPC domain remains unclear. To bridge this gap, we propose the framework named Ditto to enable more efficient quantization-aware secure Transformer inference. Concretely, we first incorporate an MPC-friendly quantization into Transformer inference and employ a quantization-aware distillation procedure to maintain the model utility. Then, we propose novel MPC primitives to support the type conversions that are essential in quantization and implement the quantization-aware MPC execution of secure quantized inference. This approach significantly decreases both computation and communication overhead, leading to improvements in overall efficiency. We conduct extensive experiments on Bert and GPT2 models to evaluate the performance of Ditto. The results demonstrate that Ditto is about $3.14\sim 4.40\times$ faster than MPCFormer (ICLR 2023) and $1.44\sim 2.35\times$ faster than the state-of-the-art work PUMA with negligible utility degradation.}
}
```
## Acknowledgement
We thank the significant contributions made by [Alibaba Gemini Lab](https://alibaba-gemini-lab.github.io) and security advisories made by [VUL337@NISL@THU](https://netsec.ccert.edu.cn/vul337).
Raw data
{
"_id": null,
"home_page": "https://github.com/secretflow/spu",
"name": "spu",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "spu mpc secretflow compiler vm ABY3 secure computation",
"author": "SecretFlow Team",
"author_email": "secretflow-contact@service.alipay.com",
"download_url": null,
"platform": null,
"description": "# SPU: Secure Processing Unit\n\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/secretflow/spu/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/secretflow/spu/tree/main)\n[![Python](https://img.shields.io/pypi/pyversions/spu.svg)](https://pypi.org/project/spu/)\n[![PyPI version](https://img.shields.io/pypi/v/spu)](https://pypi.org/project/spu/)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/secretflow/spu/badge)](https://securityscorecards.dev/viewer/?uri=github.com/secretflow/spu)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8311/badge)](https://www.bestpractices.dev/projects/8311)\n\nSPU (Secure Processing Unit) aims to be a `provable`, `measurable` secure computation device,\nwhich provides computation ability while keeping your private data protected.\n\nSPU could be treated as a programmable device, it's not designed to be used directly.\nNormally we use SecretFlow framework, which use SPU as the underline secure computing device.\n\nCurrently, we mainly focus on `provable` security. It contains a secure runtime that evaluates\n[XLA](https://www.tensorflow.org/xla/operation_semantics)-like tensor operations,\nwhich use [MPC](https://en.wikipedia.org/wiki/Secure_multi-party_computation) as the underline\nevaluation engine to protect privacy information.\n\nSPU python package also contains a simple distributed module to demo SPU usage,\nbut it's **NOT designed for production** due to system security and performance concerns,\nplease **DO NOT** use it directly in production.\n\n## Contribution Guidelines\n\nIf you would like to contribute to SPU, please check [Contribution guidelines](CONTRIBUTING.md).\n\nIf you would like to use SPU for research purposes, please check [research development guidelines](docs/SPU_gudience.pdf) from [@fionser](https://github.com/fionser).\n\nThis documentation also contains instructions for [build and testing](CONTRIBUTING.md#build).\n\n## Installation Guidelines\n\n### Supported platforms\n\n| | Linux x86_64 | Linux aarch64 | macOS x64 | macOS Apple Silicon | Windows x64 | Windows WSL2 x64 |\n|------------|--------------|---------------|----------------|---------------------|----------------|---------------------|\n| CPU | yes | yes | yes<sup>1</sup>| yes | no | yes |\n| NVIDIA GPU | experimental | no | no | n/a | no | experimental |\n\n1. Due to CI resource limitation, macOS x64 prebuild binary is no longer available.\n\n### Instructions\n\nPlease follow [Installation Guidelines](INSTALLATION.md) to install SPU.\n\n### Hardware Requirements\n\n| General Features | FourQ based PSI | GPU |\n| ---------------- | --------------- | --- |\n| AVX/ARMv8 | AVX2/ARMv8 | CUDA 11.8+ |\n\n## Citing SPU\n\nIf you think SPU is helpful for your research or development, please consider citing our papers:\n\n[USENIX ATC'23](https://www.usenix.org/conference/atc23/presentation/ma)\n\n```text\n@inproceedings {spu,\n author = {Junming Ma and Yancheng Zheng and Jun Feng and Derun Zhao and Haoqi Wu and Wenjing Fang and Jin Tan and Chaofan Yu and Benyu Zhang and Lei Wang},\n title = {{SecretFlow-SPU}: A Performant and {User-Friendly} Framework for {Privacy-Preserving} Machine Learning},\n booktitle = {2023 USENIX Annual Technical Conference (USENIX ATC 23)},\n year = {2023},\n isbn = {978-1-939133-35-9},\n address = {Boston, MA},\n pages = {17--33},\n url = {https://www.usenix.org/conference/atc23/presentation/ma},\n publisher = {USENIX Association},\n month = jul,\n}\n```\n\n[ICML'24](https://proceedings.mlr.press/v235/wu24d.html)\n\n```text\n@inproceedings{ditto,\n title = {Ditto: Quantization-aware Secure Inference of Transformers upon {MPC}},\n author = {Wu, Haoqi and Fang, Wenjing and Zheng, Yancheng and Ma, Junming and Tan, Jin and Wang, Lei},\n booktitle = {Proceedings of the 41st International Conference on Machine Learning},\n pages = {53346--53365},\n year = {2024},\n editor = {Salakhutdinov, Ruslan and Kolter, Zico and Heller, Katherine and Weller, Adrian and Oliver, Nuria and Scarlett, Jonathan and Berkenkamp, Felix},\n volume = {235},\n series = {Proceedings of Machine Learning Research},\n month = {21--27 Jul},\n publisher = {PMLR},\n pdf = {https://raw.githubusercontent.com/mlresearch/v235/main/assets/wu24d/wu24d.pdf},\n url = {https://proceedings.mlr.press/v235/wu24d.html},\n abstract = {Due to the rising privacy concerns on sensitive client data and trained models like Transformers, secure multi-party computation (MPC) techniques are employed to enable secure inference despite attendant overhead. Existing works attempt to reduce the overhead using more MPC-friendly non-linear function approximations. However, the integration of quantization widely used in plaintext inference into the MPC domain remains unclear. To bridge this gap, we propose the framework named Ditto to enable more efficient quantization-aware secure Transformer inference. Concretely, we first incorporate an MPC-friendly quantization into Transformer inference and employ a quantization-aware distillation procedure to maintain the model utility. Then, we propose novel MPC primitives to support the type conversions that are essential in quantization and implement the quantization-aware MPC execution of secure quantized inference. This approach significantly decreases both computation and communication overhead, leading to improvements in overall efficiency. We conduct extensive experiments on Bert and GPT2 models to evaluate the performance of Ditto. The results demonstrate that Ditto is about $3.14\\sim 4.40\\times$ faster than MPCFormer (ICLR 2023) and $1.44\\sim 2.35\\times$ faster than the state-of-the-art work PUMA with negligible utility degradation.}\n}\n```\n\n## Acknowledgement\n\nWe thank the significant contributions made by [Alibaba Gemini Lab](https://alibaba-gemini-lab.github.io) and security advisories made by [VUL337@NISL@THU](https://netsec.ccert.edu.cn/vul337).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "SPU aims to be a 'provable', 'measurable' secure computation device.",
"version": "0.9.3b0",
"project_urls": {
"Homepage": "https://github.com/secretflow/spu"
},
"split_keywords": [
"spu",
"mpc",
"secretflow",
"compiler",
"vm",
"aby3",
"secure",
"computation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1bed0b1625a034607f36d5a261c74e5d6cd38d0a3ef1cf66d3cd9ef420249a6a",
"md5": "8d7e5fa8da3344039e6b78e2d3d93597",
"sha256": "6907c02179b9ee23ae346c5bea331d9aec6d69679027ac66ac9deb788ef5d8d8"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp310-cp310-macosx_13_0_arm64.whl",
"has_sig": false,
"md5_digest": "8d7e5fa8da3344039e6b78e2d3d93597",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 38607439,
"upload_time": "2024-12-19T14:16:27",
"upload_time_iso_8601": "2024-12-19T14:16:27.963021Z",
"url": "https://files.pythonhosted.org/packages/1b/ed/0b1625a034607f36d5a261c74e5d6cd38d0a3ef1cf66d3cd9ef420249a6a/spu-0.9.3b0-cp310-cp310-macosx_13_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1aa1ae52f0ba1875601dc3968dd53c8df5cc62dfe9dcaca0b3358488f67be21e",
"md5": "48c87fbfcb15a7da819dfb948f0fddb4",
"sha256": "9763add7bbfc2c087efa7338d49ad30fdfd6f4f81227922e66255a3631ae4e8a"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp310-cp310-manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "48c87fbfcb15a7da819dfb948f0fddb4",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 41762757,
"upload_time": "2024-12-19T14:09:10",
"upload_time_iso_8601": "2024-12-19T14:09:10.698368Z",
"url": "https://files.pythonhosted.org/packages/1a/a1/ae52f0ba1875601dc3968dd53c8df5cc62dfe9dcaca0b3358488f67be21e/spu-0.9.3b0-cp310-cp310-manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7a3e1977de91690bd8be71d4d3c5a3ff76a7faefb9bb8e22367e5b5af1f1e51f",
"md5": "5229b6d3b4dde0613dfda9c3ea726568",
"sha256": "1ea538e7907e78358692502b4e038357b1492e8fe024c68b57856a0a213e3590"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp310-cp310-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "5229b6d3b4dde0613dfda9c3ea726568",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 41437657,
"upload_time": "2024-12-19T14:14:57",
"upload_time_iso_8601": "2024-12-19T14:14:57.024826Z",
"url": "https://files.pythonhosted.org/packages/7a/3e/1977de91690bd8be71d4d3c5a3ff76a7faefb9bb8e22367e5b5af1f1e51f/spu-0.9.3b0-cp310-cp310-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ba6d9b8ae6954dc190e22da6b3cca279fcfbcad35ce25489030f8046b17405a9",
"md5": "ab4bdae85435806a40c425c02d0d3600",
"sha256": "cc611873c283d79816a5a3466d69b96edf5ac7351ce915888c5caa26dbf9ea64"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp311-cp311-macosx_13_0_arm64.whl",
"has_sig": false,
"md5_digest": "ab4bdae85435806a40c425c02d0d3600",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 38609957,
"upload_time": "2024-12-19T14:17:51",
"upload_time_iso_8601": "2024-12-19T14:17:51.322988Z",
"url": "https://files.pythonhosted.org/packages/ba/6d/9b8ae6954dc190e22da6b3cca279fcfbcad35ce25489030f8046b17405a9/spu-0.9.3b0-cp311-cp311-macosx_13_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f820cfc2c70acc02a69985beef8c3f6cf8f92591f449121ce497b9620ae29568",
"md5": "5bc0c9ad3a2ac48ca738ba073e4e5579",
"sha256": "94fa156f24b461638e029c9973a913496accfa45613e2ef4d892bb525da4b998"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp311-cp311-manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "5bc0c9ad3a2ac48ca738ba073e4e5579",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 41764668,
"upload_time": "2024-12-19T14:09:03",
"upload_time_iso_8601": "2024-12-19T14:09:03.323231Z",
"url": "https://files.pythonhosted.org/packages/f8/20/cfc2c70acc02a69985beef8c3f6cf8f92591f449121ce497b9620ae29568/spu-0.9.3b0-cp311-cp311-manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6bfabd0bee1b14709655e7d5a65f90cdb5ef5fb3914223de8623ffeaca358746",
"md5": "08add0f0d27d4e4ef3a95051d6c0e9d3",
"sha256": "28f0a441b29095a8cf3861b14643d473e5701a2841dc5d38b009afbdfc3a9089"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp311-cp311-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "08add0f0d27d4e4ef3a95051d6c0e9d3",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 41441133,
"upload_time": "2024-12-19T14:14:39",
"upload_time_iso_8601": "2024-12-19T14:14:39.471596Z",
"url": "https://files.pythonhosted.org/packages/6b/fa/bd0bee1b14709655e7d5a65f90cdb5ef5fb3914223de8623ffeaca358746/spu-0.9.3b0-cp311-cp311-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8dd00d382a922205d1d3253a758ed8fc7801999b5e15c9170c93a02b68bc920a",
"md5": "022ab37ebcbf90c553938133137e09f2",
"sha256": "18783ddac46bf29b30a975b61b6ebc60d91005887dbecffb6a22fc1bee2b82a9"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp39-cp39-macosx_13_0_arm64.whl",
"has_sig": false,
"md5_digest": "022ab37ebcbf90c553938133137e09f2",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 38607061,
"upload_time": "2024-12-19T14:17:31",
"upload_time_iso_8601": "2024-12-19T14:17:31.414022Z",
"url": "https://files.pythonhosted.org/packages/8d/d0/0d382a922205d1d3253a758ed8fc7801999b5e15c9170c93a02b68bc920a/spu-0.9.3b0-cp39-cp39-macosx_13_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "81cd65d1382fdeb402f1fbf7eb4d275170cbb8108dc9b9a87246068fda8d368a",
"md5": "3e96220c54331fd3c818a38c4b5b3a4b",
"sha256": "8b47a6bd07e7bd40ad65b4563f10829142abfc41fea55d9b58d8d000f3d70dba"
},
"downloads": -1,
"filename": "spu-0.9.3b0-cp39-cp39-manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "3e96220c54331fd3c818a38c4b5b3a4b",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": null,
"size": 41442324,
"upload_time": "2024-12-19T14:16:23",
"upload_time_iso_8601": "2024-12-19T14:16:23.626279Z",
"url": "https://files.pythonhosted.org/packages/81/cd/65d1382fdeb402f1fbf7eb4d275170cbb8108dc9b9a87246068fda8d368a/spu-0.9.3b0-cp39-cp39-manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 14:16:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "secretflow",
"github_project": "spu",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"circle": true,
"requirements": [
{
"name": "grpcio",
"specs": [
[
">=",
"1.42.0"
],
[
"!=",
"1.48.0"
]
]
},
{
"name": "numpy",
"specs": [
[
"<",
"2"
],
[
">=",
"1.22.0"
]
]
},
{
"name": "protobuf",
"specs": [
[
"<",
"5"
],
[
">=",
"4"
]
]
},
{
"name": "cloudpickle",
"specs": [
[
">=",
"2.0.0"
]
]
},
{
"name": "multiprocess",
"specs": [
[
">=",
"0.70.12.2"
]
]
},
{
"name": "cachetools",
"specs": [
[
">=",
"5.0.0"
]
]
},
{
"name": "jax",
"specs": [
[
">=",
"0.4.16"
],
[
"<=",
"0.4.34"
]
]
},
{
"name": "termcolor",
"specs": [
[
">=",
"2.0.0"
]
]
}
],
"lcname": "spu"
}