Inferensys

Glossary

DP-SGD

Differentially Private Stochastic Gradient Descent (DP-SGD) is a training algorithm that modifies standard SGD by clipping per-example gradients and injecting calibrated Gaussian noise to train deep learning models with provable differential privacy guarantees.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
CORE TRAINING ALGORITHM

What is DP-SGD?

Differentially Private Stochastic Gradient Descent (DP-SGD) is the foundational algorithm for training deep learning models with formal, provable privacy guarantees by injecting calibrated noise into the optimization process.

DP-SGD is a modification of standard stochastic gradient descent that achieves differential privacy by performing two critical operations on per-example gradients before updating model weights: gradient clipping to bound the sensitivity of each individual training sample, and the addition of calibrated Gaussian noise to the aggregated clipped gradients. This ensures the final model's parameters do not memorize or expose information about any single record in the training dataset.

The privacy cost is rigorously tracked using a moments accountant, which provides tight bounds on the cumulative privacy loss across training iterations by leveraging privacy amplification by subsampling and composition theorems. Unlike output perturbation methods, DP-SGD injects noise directly into the gradient descent step, making it the standard approach for training differentially private neural networks in production frameworks like TensorFlow Privacy and Opacus.

CORE MECHANISMS

Key Characteristics of DP-SGD

Differentially Private Stochastic Gradient Descent (DP-SGD) modifies standard deep learning by introducing two critical steps—gradient clipping and noise injection—to provide provable privacy guarantees during training.

01

Per-Example Gradient Clipping

Unlike standard SGD which computes gradients over a mini-batch, DP-SGD computes per-example gradients for each data point independently. Each gradient's L2 norm is then bounded to a fixed threshold C:

  • If ||g(x_i)||_2 > C, the gradient is scaled down to C * g(x_i) / ||g(x_i)||_2
  • If ||g(x_i)||_2 ≤ C, the gradient remains unchanged

This bounding operation limits the sensitivity of the training update—the maximum influence any single record can exert on the model—which is a prerequisite for meaningful privacy guarantees.

L2 Norm
Clipping Metric
02

Calibrated Gaussian Noise Injection

After clipping and averaging the per-example gradients, DP-SGD adds isotropic Gaussian noise to the aggregated gradient before applying the optimizer update:

  • Noise is drawn from N(0, σ²C²I) where σ is the noise multiplier
  • The standard deviation is proportional to the clipping threshold C and inversely proportional to the privacy budget ε
  • This step ensures the final model update satisfies (ε, δ)-differential privacy via the Gaussian mechanism

The noise obscures the contribution of any individual example, making it impossible to determine whether a specific record was included in the training set.

σ
Noise Multiplier
03

Privacy Amplification by Subsampling

DP-SGD leverages Poisson subsampling or uniform random sampling to select mini-batches, which provides a crucial privacy amplification effect:

  • Each example is included in a batch with probability q = B/N (batch size / dataset size)
  • The randomness of sampling introduces uncertainty about whether any given record participated in a training step
  • This amplifies the effective privacy guarantee beyond what the Gaussian mechanism alone provides

The Moments Accountant tracks this amplified privacy loss across iterations, yielding significantly tighter bounds than basic composition theorems.

q = B/N
Sampling Probability
04

Moments Accountant for Tight Bounds

The Moments Accountant is the privacy accounting algorithm introduced alongside DP-SGD that tracks cumulative privacy loss more accurately than standard composition theorems:

  • Computes the log moments of the privacy loss random variable at each training step
  • Accumulates these moments across all iterations using linear composition
  • Converts the total moment bound back to an (ε, δ) guarantee via tail bounds

This technique reduces the estimated privacy budget consumption by orders of magnitude compared to advanced composition, making deep learning with differential privacy practically feasible.

Orders of Magnitude
Tighter Than Advanced Composition
05

Privacy-Utility Trade-off

DP-SGD introduces a fundamental privacy-utility trade-off governed by three hyperparameters:

  • Noise multiplier (σ): Higher values increase privacy but degrade model accuracy
  • Clipping threshold (C): Too low destroys signal; too high requires more noise
  • Batch size (B): Larger batches improve utility but reduce subsampling amplification

Practical deployments require careful tuning. Typical settings achieve ε ≈ 8 with < 5% accuracy degradation on CIFAR-10, while tighter budgets (ε < 1) may incur 10-20% drops. Rényi Differential Privacy (RDP) accounting can further optimize this trade-off.

ε ≈ 8
Practical Privacy Budget
06

Post-Processing Immunity

A critical property of DP-SGD is that the trained model enjoys post-processing immunity:

  • Any computation applied to the model's outputs—inference, fine-tuning, ensembling, or publishing—cannot weaken the original privacy guarantee
  • This holds because differential privacy is closed under arbitrary post-processing
  • An adversary with access to the model cannot infer more about the training data than what the (ε, δ) bound permits, regardless of how they query or manipulate the model

This property ensures that models trained with DP-SGD remain safe for deployment in untrusted environments, including public API endpoints and on-device inference.

Post-Processing Resilience
DP-SGD DEEP DIVE

Frequently Asked Questions

Clear, technically precise answers to the most common questions about Differentially Private Stochastic Gradient Descent, the foundational algorithm for training deep learning models with provable privacy guarantees.

Differentially Private Stochastic Gradient Descent (DP-SGD) is a training algorithm that modifies standard SGD to provide formal differential privacy guarantees for the training data. It works by introducing two critical steps into each training iteration: per-example gradient clipping and calibrated noise injection. First, the gradient of the loss is computed individually for each example in a minibatch. Each per-example gradient's L2 norm is then clipped to a fixed threshold C, bounding the influence of any single training example on the model update. The clipped gradients are aggregated, and random noise drawn from a Gaussian distribution calibrated to the clipping threshold and a desired privacy parameter σ is added to the sum. Finally, the noisy, aggregated gradient is used to update the model weights via standard gradient descent. This process ensures the resulting model's parameters are statistically indistinguishable from those trained on a dataset differing by one record, providing a quantifiable privacy loss bound tracked by a privacy accountant.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.