Opacus: User-Friendly Differential Privacy Library in PyTorch

Ashkan Yousefpour, Igor Shilov, Alexandre Sablayrolles, Davide Testuggine, Karthik Prasad +7 more
9/25/2021
cs.LGcs.CR

Official code: meta-pytorch/opacus (1,967 stars, Apache-2.0, PyTorch, last commit 2026-09-24).

Abstract

We introduce Opacus, a free, open-source PyTorch library for training deep learning models with differential privacy (hosted at opacus.ai). Opacus is designed for simplicity, flexibility, and speed. It provides a simple and user-friendly API, and enables machine learning practitioners to make a training pipeline private by adding as little as two lines to their code. It supports a wide variety of layers, including multi-head attention, convolution, LSTM, GRU (and generic RNN), and embedding, right out of the box and provides the means for supporting other user-defined layers. Opacus computes batched per-sample gradients, providing higher efficiency compared to the traditional "micro batch" approach. In this paper we present Opacus, detail the principles that drove its implementation and unique features, and benchmark it against other frameworks for training models with differential privacy as well as standard PyTorch.

View on arXivView PDF

Code Implementations(1)

PyTorchApache-2.0

Training PyTorch models with differential privacy

1,967402CSS, ShellDec 7, 20193 weeks agoApache-2.0
deep-learningdifferential-privacymachine-learningneural-networkprivacy-preserving-machine-learning+1 more

Similar Papers

Cite this paper

@article{yousefpour2021opacus,
  title  = {Opacus: User-Friendly Differential Privacy Library in PyTorch},
  author = {Ashkan Yousefpour and Igor Shilov and Alexandre Sablayrolles and Davide Testuggine and Karthik Prasad and Mani Malek and John Nguyen and Sayan Ghosh and Akash Bharadwaj and Jessica Zhao and Graham Cormode and Ilya Mironov},
  year   = {2021},
  eprint = {2109.12298},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2109.12298}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2109.12298.svg)](https://codeofpaper.com/paper/2109.12298)

Discussion