Automatic Clipping: Differentially Private Deep Learning Made Easier and Stronger

Zhiqi Bu, Yu-Xiang Wang, Sheng Zha, George Karypis

TL;DR

Training deep learning models with Differential Privacy (DP) usually requires a painful 2D grid search to find the right clipping threshold ($R$) and learning rate ($\eta$). This paper introduces Automatic Clipping (AUTO-S), a simple drop-in replacement that effectively eliminates $R$ as a hyperparameter. This makes DP training as easy to tune as non-private training while matching or beating state-of-the-art performance.

The Problem: The "Goldilocks" Clipping Threshold

To train a model with Differential Privacy, practitioners typically use DP-SGD. This involves two extra steps compared to regular SGD:

  1. Per-example clipping: Each individual gradient in a batch is scaled down so its $L_2$ norm is at most a threshold $R$.
  2. Noise addition: Random Gaussian noise is added to the sum of these clipped gradients.

The core issue is finding the "Goldilocks" clipping threshold $R$. If $R$ is too small, you destroy the gradient signal. If $R$ is too large, the noise (which scales linearly with $R$) becomes so massive it drowns out the signal. Finding the perfect $R$ requires an expensive 2D grid search alongside the learning rate. For massive foundation models like GPT-3, this extra dimension of hyperparameter tuning can turn a week of training into months of compute.

The Solution: Automatic Normalization

The authors propose moving away from traditional "clipping" (which keeps gradients as-is if they are small) and toward automatic normalization.

  • AUTO-V (Vanilla): They first consider a simple normalization: $\hat{g}_i = g_i / \|g_i\|_2$. This forces every gradient to have a norm of 1, effectively setting $R=1$ and removing it from the equation.
  • AUTO-S (Stable): To fix issues where very small gradients get "blown up" or gradients in a "lazy region" cancel each other out, they introduce a stability constant $\gamma$: $$\hat{g}_i = \frac{g_i}{\|g_i\|_2 + \gamma}$$ By setting a default $\gamma = 0.01$, the optimizer preserves the magnitude information of small gradients while still bounding the sensitivity of large ones.

The "Magic" of Automaticity

The true power of this approach lies in how it simplifies hyperparameter tuning by fundamentally altering how the optimizer interacts with the clipping norm:

  • For SGD: The authors prove that $R$ and the learning rate $\eta$ are strictly coupled. Changing $R$ is mathematically equivalent to changing $\eta$. Therefore, you only need to tune $\eta$.
  • For Adam/Adaptive Optimizers: They show that $R$ actually cancels out in the update rule. In adaptive optimizers, the clipping threshold has zero effect on the final update direction, making it truly "automatic."
Heatmaps demonstrating hyperparameter coupling. Left: In DP-Adam, the clipping norm cancels out, leaving only the learning rate to be tuned (horizontal bands). Right: In standard DP-SGD, learning rate and clipping norm are strictly coupled (diagonal band).

Key Insights and Theoretical Guarantees

  • The "Small R" Bias: Recent SOTA results in DP-NLP often use very small clipping thresholds (like $R=0.1$). This suggests that the direction of the gradient is much more important than its magnitude in private training. Automatic clipping leans into this by treating DP training more like normalized optimization.
  • Theoretical Convergence: The authors provide a rigorous proof showing that AUTO-S converges in non-convex settings at a rate of $O(T^{-1/4})$, which matches the asymptotic rate of standard, non-private SGD.
  • Ease of Adoption: Because it's a simple change to the gradient scaling logic, it can be implemented in popular DP libraries like Opacus or ObJAX with just 1-2 lines of code change.

Experimental Results

The researchers validated their approach across a wide range of tasks, including image classification (MNIST, CIFAR-10, ImageNette), sentence classification (GLUE benchmark), and table-to-text generation (E2E dataset).

  • Hyperparameter Savings: By removing $R$, the authors reduced the cost of ablation studies by roughly 5x.
  • Language Modeling: On the E2E dataset with GPT-2 Large, AUTO-S achieved a BLEU score of 64.18 ($\epsilon=3$), outperforming previous SOTA methods like LoRA (58.15) and RGP (58.48).
  • Vision Tasks: On ImageNette (a subset of ImageNet), AUTO-S achieved 60.71% accuracy, slightly edging out Abadi’s standard clipping (60.29%).
  • Robustness: They demonstrated that the choice of $\gamma$ is highly robust; a wide range (from 0.001 to 1.0) yields similar high-accuracy results, unlike $R$, which causes performance to crash if misconfigured.

Limitations and Future Work

  • Bias: Normalizing per-sample gradients introduces a specific type of bias (the average of normalized gradients is not necessarily in the same direction as the average of raw gradients). While the paper proves this doesn't stop convergence, the implications for very specific loss landscapes are still worth exploring.
  • Interaction with Data Augmentation: The paper notes they didn't use common "tricks" like multi-sample data augmentation. Future work could investigate if automatic clipping provides even greater gains when combined with these advanced DP training techniques.
  • The $\gamma$ Default: While $\gamma=0.01$ worked well across all tested tasks, extremely large-scale models (trillions of parameters) might eventually require a different stability constant.

Summary updated

BibTeX
@inproceedings{bu2023automatic,
  author = {Zhiqi Bu and Yu-Xiang Wang and Sheng Zha and George Karypis},
  title = {{Automatic Clipping: Differentially Private Deep Learning Made Easier and Stronger}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=e8i7OaPj0q},
}
Figure