Skip to content

Releases: pytorch/opacus

Opacus v1.4.1

11 Feb 17:28
Compare
Choose a tag to compare

Bug fixes

  • Fix DP MultiheadAttention (#598)
  • Fix: make prv accountant robust to larger epsilons (#606)
  • Fix the corner case when the optimizer has no trainable parameters (#619)

Opacus v1.4.0

24 Mar 15:59
Compare
Choose a tag to compare

Highlight: Upgraded to PyTorch 1.13+ as required dependency

New features

  • Added clipping schedulers (#556)
  • Util to check per sample gradients (#532)

Bug fixes

  • Align DataLoader interface with vanilla PyTorch (#543)
  • Fix GDP accountant epsilon retrieval changing internal state (#541)
  • Add option to specify number of steps in UniformSampler (#550)
  • Fix privacy computation script (#565)

Opacus v1.3

14 Nov 13:48
Compare
Choose a tag to compare

New features

Bug fixes

  • Fix benchmarks (#503, #507, #508)
  • Align make_private_with_epsilon with make_private (#509, #526)
  • Test fixes (#513, #515, #527, #533)
  • Summed discriminator losses to perform one backprop step (#474)
  • Fixed issue with missing argument in MNIST example (#520)
  • Functorch gradients: investigation and fix (#510)
  • Support empty batches (#530)

Opacus v1.2

09 Sep 17:50
Compare
Choose a tag to compare

We're glad to present Opacus v1.2, which contains some major updates to per sample gradient computation mechanisms and includes all the good stuff from the recent PyTorch releases.

Highlights

Functorch - per sample gradients for all

With the recent release of functorch it's now easy to compute per sample gradients for any module, without any limitations we've had to set before.

Here's the new default behaviour:

  1. First, we check if the input module contains any layers known to be incompatible with the DP-SGD (e.g. BatchNorm). Note, that these restrictions are fundamental to how DP-SGD works and will always be revelant
  2. Then, for each layer we select a method of computing per sample gradients. For performance reasons, we still use old manually written grad samplers for the layers we support and fall back to the generic functorch-based grad sampler for all other layers.

You can also force functorch-based grad sampler for every layer by passing grad_sample_mode="functorch" to PrivacyEngine.make_private() or force_functorch=False to GradSampleModule's constructor.

If you're using functorch for your training pipeline already, consider using GradSampleModuleNoOp (grad_sample_mode="no_op") . As suggested by the name, is performs no action and expects client to compute per sample gradients themselves. See our CIFAR-10 example for code demonstration.

Note, that this functionality is still in beta and we haven't fully explored it's limitations. Please report any weird behaviour or inconsistencies you encounter to out github issues, we greatly appreciate the feedback.

ExpandedWeights - yet another way to compute per sample gradients

One more exciting feature now available in core PyTorch is ExpandedWeights. This feature uses old Opacus' approach of manually-written vectorized per sample gradient computations, but achieves much better performance.

To activate ExpandedWeights pass grad_sample_mode="ew" to PrivacyEngine.make_private() or use GradSampleModuleExpandedWeights

Summary: 3 different ways to compute per sample gradients

With the recent updates, Opacus now supports 3 different ways to compute per sample gradients. Below is the quick comparison. For more details refer to the grad sample README.md

TL;DR: If you want stable implementation, use GradSampleModule (grad_sample_mode="hooks").
If you want to experiment with the new functionality, you have two options. Try
GradSampleModuleExpandedWeights(grad_sample_mode="ew") for better performance and grad_sample_mode=functorch
if your model is not supported by GradSampleModule.

Please switch back to GradSampleModule(grad_sample_mode="hooks") if you encounter strange errors or unexpexted behaviour.
We'd also appreciate it if you report these to us

xxx Hooks Expanded Weights Functorch
Required PyTorch version 1.8+ 1.13+ 1.12 (to be updated)
Development status Underlying mechanism deprecated Beta Beta
Runtime Performance† baseline ✅ ~25% faster 🟨 0-50% slower
Any DP-allowed†† layers Not supported Not supported ✅ Supported
Most popular nn.* layers ✅ Supported ✅ Supported ✅ Supported
torchscripted models Not supported ✅ Supported Not supported
Client-provided grad sampler ✅ Supported Not supported ✅ Not needed
batch_first=False ✅ Supported Not supported ✅ Supported
Recurrent networks ✅ Supported Not supported ✅ Supported
Padding same in Conv ✅ Supported Not supported ✅ Supported

† Note, that performance differences are unstable and can vary a lot depending on the exact model and batch size.
Numbers above are averaged over benchmarks with small models consisting of convolutional and linear layers.
Note, that performance differences are only observed on GPU training, CPU performance seem to be almost identical
for all approaches.

†† Layers that produce joint computations on batch samples (e.g. BatchNorm) are not allowed under any approach

Other improvements

  • Fix utils.unfold2d with non-symmetric pad/dilation/kernel_size/stride (#443)
  • Add support for "same" and "valid" padding for hooks-based grad sampler for convolution layers
  • Improve model validation to support frozen layers and catch copied parameters (#489)
  • Remove annoying logging from set_to_none (#471)
  • Improved documentation (#480, #478, #482, #485, #486, #487, #488)
  • Imtegration test improvements (#407, #479, #481. #473)

Opacus v1.1.3

13 Jul 13:36
Compare
Choose a tag to compare

Improvements

  • Checkpoint support (#429)
  • Support for layers with mix of frozen and trainable params (#437)
  • Optimized einsum (#440)
  • Improved parameter sanity check (#439)

Bug Fixes

  • Fix unfold2d (#443)
  • Switch CI to latest PyTorch version (#434)
  • Typos and editing (#430, #438, #449)

Misc

  • Tutorials on distributed training (#428)

Opacus v1.1.2

06 May 09:42
Compare
Choose a tag to compare

Bug fixes

  • Support tied parameters (#417)
  • Fix callsite sensitiveness of zero_grad() (#422, #423)
  • Improve microbenchmark argument parsing and tests (#425)
  • Fix opacus nn.functional import (#426)

Miscellaneous

  • Add microbenchmarks (#412, #416)
  • Add more badges to readme (#424)

Opacus v1.1.1

08 Apr 18:54
Compare
Choose a tag to compare

Bug fixes

  • Fix accountant when using number of steps instead of epochs
  • Add params check when converting BatchNorm to GroupNorm (#390)
  • Fix typo in gdp accountant mechansim name (#386)
  • Fix linter errors (#392)
  • Add friendly and detailed message for unsupported layers (#401)
  • Run linter on nightly workflow (#399)
  • Add warning for Gaussian DP accounting (#400)
  • Clone replacement modules on the same device as original (#356)
  • Implementing 3D dilation (#408)
  • fix(batch_memory_manager): Ensures split_idxs use native python types (#410)

Miscellaneous

  • Migrate nightly CircleCI flows to scheduled pipelines (#402)
  • Migrate from ubuntu 16.04 to 20.04 on CircleCI (#403)

Opacus v1.1.0

15 Mar 12:52
Compare
Choose a tag to compare

v1.1.0

New Feature

  • Add support for GDP accounting in get_noise_multiplier (#303)

Bug fixes

  • Conservative search for target epsilon in get_noise_multiplier (#348)
  • Warn and ignore "drop_last" when set in DPDataLoader (#357)
  • Fix per-layer clipping in distributed (#347)

Miscellaneous

  • Update code of conduct and file headers
  • Add "Support Ukraine" banner to opacus website homepage
  • Lint fixes

Opacus v1.0.2

09 Feb 23:25
Compare
Choose a tag to compare

Bug fixes

  • DPOptimizer
    • Passes through .defaults field to match pytorch Optimizer (#329)
    • Better exception message in .step() when p.grad_sample=None (#331)
    • Correct closure call after applying DP noise (#330)
  • Proper gradient scaling in DDP mode
  • Corrections of typos and errors in tutorials

Miscellaneous

  • Opacus can be installed with conda: added recipe in conda-forge (#326)
  • Formatting change in accordance with black-22.1.0

Opacus v1.0.1

04 Jan 00:19
Compare
Choose a tag to compare

Bug fixes

  • Hidden states of RNN is passed to device (#314)
  • Validate and fix trainable modules only (#316)

Miscellaneous

  • Minor corrections and typo fixes in links, documentation, and tutorials.