Opacus

Click to visit website
About
Opacus is a library that enables training PyTorch models with differential privacy. It supports training with minimal code changes required on the client, has little impact on training performance and allows the client to online track the privacy budget expended at any given moment. Opacus features scalable vectorized per-sample gradient computation, is built on PyTorch and supports most types of PyTorch models, and has an extensible open source, modular API for differential privacy research.
Platform
Task
Features
• extensible: open source, modular api for differential privacy research.
• built on pytorch: supports most types of pytorch models and can be used with minimal modification to the original neural network.
• scalable: vectorized per-sample gradient computation that is 10x faster than microbatching
FAQs
What is Opacus?
Opacus is a library that enables training PyTorch models with differential privacy. It supports training with minimal code changes required on the client, has little impact on training performance and allows the client to online track the privacy budget expended.
Is Opacus open-source? What is the license?
Yes! Opacus is open-source for public use, and it is licensed under the Apache 2.0 license.
How can I report a bug or ask a question?
You can report bugs or ask questions by submitting GitHub issues. To submit a GitHub issue, please click here.
I'd like to contribute to Opacus. How can I do that?
Thank you for your interest in contributing to Opacus! Submit your contributions using GitHub pull requests here. Please take a look at Opacus contribution guide.
If I use Opacus in my paper, how can I cite it?
If you use Opacus in your papers, you can cite it as follows: @article{opacus, title={Opacus: {U}ser-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}, journal={arXiv preprint arXiv:2109.12298}, year={2021} }
What is DP-SGD?
DP-SGD is an algorithm described in this paper; Opacus is its Pytorch implementation. Please refer to this blog post to read more about DP-SGD.
How do I attach the privacy engine?
Training with Opacus is as simple as instantiating a `PrivacyEngine` and attaching it to the `optimizer`...
What is the secure_rng argument in PrivacyEngine?
Not all pseudo random number generators (RNGs) are born equal... Opacus supports a CSPRNG provided by the torchcsprng library. This option is controlled by setting `secure_rng` to `True`...
My model doesn’t converge with default privacy settings. What do I do?
Opacus has several settings that control the amount of noise, which affects convergence. The most important one is `noise_multiplier`, which is typically set between 0.1 and 2.
How to deal with out-of-memory errors?
Dealing with per-sample gradients will inevitably put more pressure on your memory...The first sanity check to do is to make sure that you don’t go out of memory with "standard" training (without DP).
What does epsilon=1.1 really mean? How about delta?
The (epsilon, delta) pair quantifies the privacy properties of the DP-SGD algorithm (see the blog post). A model trained with (epsilon, delta)-differential privacy (DP) protects the privacy of any training example, no matter how strange, ill-fitting, or perfect this example is.
How does batch size affect my privacy budget?
Assuming that batches are randomly selected, an increase in the batch size increases the sampling rate, which in turn increases the privacy budget. This effect can be counterbalanced by choosing a larger learning rate (since per-batch gradients approximate the true gradient of the model better) and aborting the training earlier.
My model throws IncompatibleModuleException. What is going wrong?
Your model most likely contains modules that are not compatible with Opacus. The most prominent example of these modules is batch-norm types. Before validating you model try to fix incompatible modules using `ModuleValidator.fix(model)` as described here
What is virtual batch size?
Opacus computes and stores _per-sample_ gradients under the hood. What this means is that, for every regular gradient expected by the optimizer, Opacus will store `batch_size` per-sample gradients on each step.
What are `alphas`?
Although we report expended privacy budget using the (epsilon, delta) language, internally, we track it using Rényi Differential Privacy (RDP) . In short, (alpha, epsilon)-RDP bounds the Rényi divergence of order alpha between the distribution of the mechanism’s outputs on any two datasets that differ in a single element.
Job Opportunities
There are currently no job postings for this AI tool.
Ratings & Reviews
No ratings available yet. Be the first to rate this tool!
Featured Tools
Songmeaning
Songmeaning uses AI to reveal the stories and meanings behind song lyrics. It offers lyric translation and AI music generation.
View DetailsWhisper Notes
Offline AI speech-to-text transcription app using Whisper AI. Supports 80+ languages, audio file import, and offers lifetime access with a one-time purchase. Available for iOS and macOS.
View DetailsGitGab
Connects Github repos and local files to AI models (ChatGPT, Claude, Gemini) for coding tasks like implementing features, finding bugs, writing docs, and optimization.
View Details
nuptials.ai
nuptials.ai is an AI wedding planning partner, offering timeline planning, budget optimization, vendor matching, and a 24/7 planning assistant to help plan your perfect day.
View DetailsMake-A-Craft
Make-A-Craft helps you discover craft ideas tailored to your child's age and interests, using materials you already have at home.
View Details
Pixelfox AI
Free online AI photo editor with comprehensive tools for image, face/body, and text. Features include background/object removal, upscaling, face swap, and AI image generation. No sign-up needed, unlimited use for free, fast results.
View Details
Smart Cookie Trivia
Smart Cookie Trivia is a platform offering a wide variety of trivia questions across numerous categories to help users play trivia, explore different topics, and expand their knowledge.
View Details
Code2Docs
AI-powered code documentation generator. Integrates with GitHub. Automates creation of usage guides, API docs, and testing instructions.
View Details