[Paper Review] Enabling Fast Differentially Private SGD via Just-in-Time Compilation and Vectorization
This paper proposes a high-performance implementation of differentially private stochastic gradient descent (DPSGD) using just-in-time (JIT) compilation and vectorization in JAX and TensorFlow Privacy. By leveraging XLA compilation and efficient per-example gradient computation, the approach achieves up to 50x speedup over baseline implementations, nearly eliminating the runtime overhead typically associated with DPSGD.
A common pain point in differentially private machine learning is the significant runtime overhead incurred when executing Differentially Private Stochastic Gradient Descent (DPSGD), which may be as large as two orders of magnitude. We thoroughly demonstrate that by exploiting powerful language primitives, including vectorization, just-in-time compilation, and static graph optimization, one can dramatically reduce these overheads, in many cases nearly matching the best non-private running times. These gains are realized in two frameworks: JAX and TensorFlow. JAX provides rich support for these primitives as core features of the language through the XLA compiler. We also rebuild core parts of TensorFlow Privacy, integrating features from TensorFlow 2 as well as XLA compilation, granting significant memory and runtime improvements over the current release version. These approaches allow us to achieve up to 50x speedups in comparison to the best alternatives. Our code is available at https://github.com/TheSalon/fast-dpsgd.
Motivation & Objective
- To address the significant runtime overhead—often two orders of magnitude—commonly incurred by differentially private SGD (DPSGD) in practice.
- To enable efficient computation of per-example gradients, which are essential for DPSGD's clipping mechanism but are typically unavailable or slow in mainstream ML frameworks.
- To reduce the performance gap between private and non-private training by optimizing DPSGD using language-level primitives such as JIT compilation and vectorization.
- To improve the performance and usability of differential privacy libraries, particularly in TensorFlow Privacy, through integration of XLA and enhanced vectorization.
- To demonstrate that modern compiler infrastructure can make private training nearly as efficient as standard training, enabling broader adoption in research and production.
Proposed method
- Employing JAX's XLA compiler to perform just-in-time (JIT) compilation and static graph optimization of DPSGD computation graphs.
- Using vectorized operations to compute per-example gradients efficiently across entire minibatches, avoiding sequential processing.
- Reimplementing core components of TensorFlow Privacy with XLA compilation and improved vectorization to accelerate DPSGD.
- Leveraging functional programming and pure functions in JAX to enable reliable and performant compilation and optimization.
- Integrating custom operations in TensorFlow using Custom TFP (TensorFlow Python) to support XLA-compiled DPSGD with minimal performance loss.
- Using the jax2tf converter to enable deployment of JAX-optimized models in TensorFlow-based production pipelines.
Experimental results
Research questions
- RQ1Can just-in-time compilation and vectorization significantly reduce the runtime overhead of differentially private SGD?
- RQ2To what extent can modern compiler infrastructure like XLA eliminate the performance penalty of DPSGD compared to non-private SGD?
- RQ3How does the performance of DPSGD vary across frameworks like JAX and TensorFlow when optimized with XLA and vectorization?
- RQ4What are the practical trade-offs of using functional programming and XLA-compiled code in private machine learning systems?
- RQ5Can the performance of existing privacy libraries like TensorFlow Privacy be substantially improved through integration of XLA and vectorization?
Key findings
- The proposed approach achieves up to 50x speedup over the best prior alternatives in DPSGD training, significantly reducing runtime overhead.
- In JAX, the combination of JIT compilation and vectorization nearly eliminates the performance penalty of DPSGD, achieving near-non-private training speeds.
- The integration of XLA and vectorization into TensorFlow Privacy reduced both memory usage and training time, outperforming previous release versions.
- The performance of DPSGD in JAX remained stable and efficient even when the highly optimized cuDNN kernel was unavailable, unlike in TensorFlow.
- The use of a small, functional API surface in JAX enabled more reliable and effective optimization compared to the larger, more complex APIs in TensorFlow.
- The study demonstrates that general-purpose compiler infrastructure can outperform hand-tuned kernels in privacy-preserving ML, especially in dynamic or evolving use cases.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.