Fast and Memory Efficient Differentially Private-SGD via JL Projections

Zhiqi Bu, Sivakanth Gopi, Janardhan Kulkarni, Yin Tat Lee, Judy Hanwen Shen, Uthaipon Tantipongpipat

Training machine learning models with Differential Privacy (DP) is notoriously slow and memory-intensive. The standard algorithm, Differentially Private SGD (DP-SGD), requires computing individual gradient norms for every sample in a batch. This paper introduces DP-SGD-JL, a framework that uses Johnson-Lindenstrauss (JL) projections to approximate these norms, making private training nearly as fast and memory-efficient as standard, non-private training across any network architecture.

The Bottleneck: Per-Sample Gradients

Deep learning models are prone to "unintended memorization," where they inadvertently store sensitive details from their training data. DP-SGD is the gold standard for preventing this, but it comes with a massive performance tax.

The bottleneck lies in Gradient Clipping. To ensure privacy, the algorithm must limit the influence of any single data point by "clipping" its gradient if its norm exceeds a threshold. However, modern deep learning frameworks are optimized to compute the average gradient of a batch, not the individual gradients. Forcing the computer to calculate per-sample gradients typically results in a 10x–100x slowdown and massive memory consumption. This often makes it impossible to use large batch sizes—which are exactly what DP models need to maintain high accuracy.

Comparison of various optimizers across privacy, speed, memory, and generalizability.

As shown in the table above, previous attempts to speed up DP-SGD often sacrificed memory efficiency or generalizability (working only on specific architectures). DP-SGD-JL is designed to check all the boxes, offering a robust solution without these compromises.

The Solution: Johnson-Lindenstrauss Projections

The authors propose a clever algorithmic shortcut: instead of computing the full, high-dimensional gradient for each sample just to find its length (norm), they use Johnson-Lindenstrauss (JL) Projections.

  1. The JL Trick: A high-dimensional vector's norm can be accurately estimated by projecting it onto a small number of random directions.
  2. Efficiency via JVP: They use the Jacobian-vector product (jvp)—a standard tool in auto-differentiation—to compute these projections during the forward pass of the network. This avoids the need to ever materialize the full per-sample gradients in memory.
  3. The "Knob" ($r$): They introduce the JL dimension ($r$) as a tunable parameter. A small $r$ is incredibly fast but provides a rougher estimate; a larger $r$ is more accurate and provides tighter privacy guarantees.
  4. New Privacy Analysis: Because the sensitivity of the gradient is now a random variable (due to the approximation), standard privacy accounting tools don't work. The authors developed a more sophisticated analysis using Privacy Loss Random Variables (PRVs) and Fast Fourier Transforms (FFT) to prove the privacy of their method.

Key Results and Insights

The researchers evaluated their approach on two primary benchmarks: an IMDb sentiment analysis task using a Recurrent Neural Network (RNN), and an MNIST image classification task using a Convolutional Neural Network (CNN).

  • Massive Speedups: On the IMDb RNN task, DP-Adam-JL(30) was 30x faster than the standard implementation in TensorFlow Privacy (TFP), while achieving similar privacy-vs-accuracy tradeoffs.
  • Extreme Memory Efficiency: On MNIST, standard DP-SGD crashed at a batch size of 512. In contrast, DP-SGD-JL handled a batch size of 60,000 on the same hardware. The memory footprint of DP-SGD-JL is almost identical to non-private SGD.
  • Black-Box Generality: Unlike previous speed-up attempts that only worked for specific layers, the JL approach works for any architecture in a black-box manner.
Test accuracy vs. training time for IMDb dataset, showing DP-Adam-JL achieving target accuracy much faster than Vanilla DP-Adam.

The performance gains are stark. As illustrated above, DP-Adam-JL reaches the target test accuracy in a fraction of the time required by the Vanilla DP-Adam implementation, bridging the gap toward non-DP training speeds. Furthermore, the training time scales linearly with the JL dimension $r$, giving users a direct way to trade off computation time for privacy guarantee tightness.

Limitations and Future Work

While the empirical results are strong, the authors note a few areas for further exploration:

  • Loose Bounds for Small $r$: The mathematical privacy bounds they could prove for very small JL dimensions (like $r=1$ or $r=5$) are currently quite loose, even though the models perform well in practice. Tighter theoretical analysis for these cases is an open challenge.
  • Framework Support: The method relies on efficient jvp implementations. While JAX and newer versions of TensorFlow support this well, implementations in other frameworks might require more complex workarounds to achieve the same speedups.

Summary updated

BibTeX
@inproceedings{bu2021fast,
  author = {Zhiqi Bu and Sivakanth Gopi and Janardhan Kulkarni and Yin Tat Lee and Judy Hanwen Shen and Uthaipon Tantipongpipat},
  title = {{Fast and Memory Efficient Differentially Private-SGD via JL Projections}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=WwZbupAKWo},
}
Figure