{"id":18646473,"url":"https://github.com/ucbrise/piranha","last_synced_at":"2025-06-22T09:36:39.023Z","repository":{"id":40605849,"uuid":"494520163","full_name":"ucbrise/piranha","owner":"ucbrise","description":"Piranha: A GPU Platform for Secure Computation","archived":false,"fork":false,"pushed_at":"2023-04-02T11:57:17.000Z","size":75007,"stargazers_count":95,"open_issues_count":11,"forks_count":27,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T18:05:55.952Z","etag":null,"topics":["gpu-acceleration","multi-party-computation","privacy-preserving-machine-learning"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ucbrise.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-20T15:40:41.000Z","updated_at":"2025-04-05T01:42:04.000Z","dependencies_parsed_at":"2025-04-11T13:08:00.599Z","dependency_job_id":null,"html_url":"https://github.com/ucbrise/piranha","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ucbrise/piranha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucbrise%2Fpiranha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucbrise%2Fpiranha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucbrise%2Fpiranha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucbrise%2Fpiranha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ucbrise","download_url":"https://codeload.github.com/ucbrise/piranha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucbrise%2Fpiranha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261271889,"owners_count":23133782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpu-acceleration","multi-party-computation","privacy-preserving-machine-learning"],"created_at":"2024-11-07T06:20:09.968Z","updated_at":"2025-06-22T09:36:34.009Z","avatar_url":"https://github.com/ucbrise.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Piranha: A GPU Platform for Secure Computation\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/ucbrise/piranha/blob/main/files/piranha-fish.png?raw=true\" alt=\"cute cuddly PIRANHA \u003e:D courtesy of Vivian Fang @ vivi.sh\" width=20% height=20%/\u003e\n\u003c/p\u003e\n\nPiranha is a C++-based platform for accelerating secure multi-party computation (MPC) protocols on the GPU in a protocol-independent manner. It is designed both for MPC developers, providing a modular structure for easily adding new protocol implementations, and secure application developers, allowing execution on any Piranha-implemented protocols. This repo currently includes a secure ML inference and training application, which you can find in `/nn`.\n\nPiranha is described in more detail in our [USENIX Security '22 paper](https://eprint.iacr.org/2022/892)! If you have questions, please create git issues; for eventual replies, you can also reach out to `jlw@berkeley.edu`.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/ucbrise/piranha/blob/main/files/images/usenixbadges-available.png?raw=true\" alt=\"usenix-available\" width=10% height=10%/\u003e\n    \u003cimg src=\"https://github.com/ucbrise/piranha/blob/main/files/images/usenixbadges-functional.png?raw=true\" alt=\"usenix-functional\" width=10% height=10%/\u003e\n    \u003cimg src=\"https://github.com/ucbrise/piranha/blob/main/files/images/usenixbadges-reproduced.png?raw=true\" alt=\"usenix-reproduced\" width=10% height=10%/\u003e\n\u003c/p\u003e\n\n**Warning**: This is an academic proof-of-concept prototype and has not received careful code review. This implementation is NOT ready for production use.\n\n## Build\n\nThis project requires an NVIDIA GPU, and assumes you have your GPU drivers and the [NVIDIA CUDA Toolkit](https://docs.nvidia.com/cuda/) already installed. The following has been tested on AWS with the `Deep Learning Base AMI (Ubuntu 18.04 ) Version 53.5` AMI.\n\n1. Checkout external modules\n```\ngit submodule update --init --recursive\n```\n\n1. Build CUTLASS\n\n```\ncd ext/cutlass\nmkdir build\ncmake .. -DCUTLASS_NVCC_ARCHS=\u003cYOUR_GPU_ARCH_HERE\u003e -DCMAKE_CUDA_COMPILER_WORKS=1 -DCMAKE_CUDA_COMPILER=\u003cYOUR NVCC PATH HERE\u003e\nmake -j\n```\n\n1. Install GTest. We use it for unit testing.\n\n```\nsudo apt install libgtest-dev libssl-dev\ncd /usr/src/gtest\nsudo mkdir build\ncd build\nsudo cmake ..\nsudo make\nsudo make install\n```\n\n2. Create some necessary directories\n\n```\nmkdir output; mkdir files/MNIST; mkdir files/CIFAR10\n```\n\n3. Download the MNIST/CIFAR10 datasets, if using. This step might take a while\n\n```\ncd scripts\nsudo pip install torch torchvision\npython download_{mnist, cifar10}.py\n```\n\n4. Build Piranha at a specific fixed point precision and for a particular protocol. 3-party replicated secret sharing is the default and doesn't require a command-line flag.\n\n```\nmake -j8 PIRANHA_FLAGS=\"-DFLOAT_PRECISION=\u003cNBITS\u003e -D{TWOPC,FOURPC}\"\n```\n\n## Run\n\n1. Copy and set up a run configuration using `config.json` as a base. It is already set up to perform a 10-epoch SecureML training run; simply specify party IPs in the configuration.\n\n2. Run Piranha on each machine with a party number (0 -\u003e n_parties - 1):\n\n```\n./piranha -p \u003cPARTY NUM\u003e -c \u003cCONFIG FILE\u003e\n```\n\n### Running locally\n\nYou may want to run Piranha on a local machine for development. An example configuration for 3-party local execution can be found at `files/samples/localhost_config.json` with an accompanying runfile. You can modify the runfile to change which GPUs Piranha uses for each party using the `CUDA_VISIBLE_DEVICES` environment variable. The script uses GPUs 0-2 by default, but can be changed to run on a single GPU as well. Note that due to contention, hosting several parties on a single GPU will limit the problem sizes you can test and incur some additional overhead.\n\nStart the computation with:\n\n```\n./files/samples/localhost_runner.sh\n```\n\n## Citation\n\nYou can cite the paper using the following BibTeX entry (the paper links to this repo):\n\n```\n@inproceedings {watson22piranha,\n    author = {Watson, Jean-Luc and Wagh, Sameer and Popa, Raluca Ada},\n    title = {Piranha: A {GPU} Platform for Secure Computation},\n    booktitle = {31st USENIX Security Symposium (USENIX Security 22)},\n    year = {2022},\n    isbn = {978-1-939133-31-1},\n    address = {Boston, MA},\n    pages = {827--844},\n    url = {https://www.usenix.org/conference/usenixsecurity22/presentation/watson},\n    publisher = {USENIX Association},\n    month = aug,\n}\n```\n\n## Artifact Evaluation\n\nFor our experiments, we use a cluser of AWS GPU-provisioned machines. Reviewers should have credentials to access the environment, but due to resource limits, we can only support one reviewer evaluating at a time. You can run Piranha to regenerate Figures 4, 5, 6, and 7, as well as Tables 2, 3, and 4.\n\nEvaluation runs through `experiments/run_experiment.py`, which should be executed on the control instance we provide with the required dependencies. Here are the relevant options:\n\n```\nusage: run_experiment.py [-h] [--start] [--stop] [--figure FIGURE] [--table TABLE] [--generate] [--fast] [--verbose]\n\nRun artifact evaluation!\n\noptional arguments:\n  -h, --help       show this help message and exit\n  --start          Provision cluster for experiments. _Please suspend the cluster while not running experiments :)_\n  --stop           Suspend evaluation machines.\n  --figure FIGURE  Figure # to run.\n  --table TABLE    Table # to run.\n  --generate       Generate figure/table images.\n  --fast           Run all the (relatively) fast runs, see README for more information\n  --verbose        Display verbose run commands, helpful for debugging\n```\n\n* You can start and stop the cluster with `--start` and `--stop`, respectively. Please use these if you're not running evaluation! GPU instances are not cheap and cost about $450/day to keep running.\n\n* Use the `--figure` and `--table` flags to run data generation for each of the paper's figures/tables. They're fairly automatic and should run without intervention. \n\n* Generate each figure/table with the `--generate` flag. You can run the evaluation script on partial results and the results will reflect those partial values. Figures generate `.png` files in `artifact_figures/artifact` while table replication generates JSON. You can compare to the paper figures/tables generated into `artifact_figures/paper` from hardcoded data.\n\n* **Very important note on timing.** Unfortunately, MPC still requires a significant amount of time (~30 hrs/training run) on a larger network like VGG16. A conservative estimate is that for Figure 5 alone, \u003e 270 computation-hours are required to replicate the full figure. We've included a `--fast` flag if you'd like to replicate every other datapoint first (will still require a number of compute-hours), then come back to the VGG-based values.\n\n* Use `--verbose` if something isn't working and you want to take a look at the raw output or need an error message. In the backend, we use Ansible to communicate with each of the machines in the cluster.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucbrise%2Fpiranha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucbrise%2Fpiranha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucbrise%2Fpiranha/lists"}