Inferensys

Glossary

DP-SGD

A differentially private variant of stochastic gradient descent that clips per-sample gradients and adds calibrated Gaussian noise to the aggregated batch gradient, providing provable privacy guarantees during model training.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
DIFFERENTIALLY PRIVATE STOCHASTIC GRADIENT DESCENT

What is DP-SGD?

DP-SGD is the primary algorithm for training deep neural networks with formal differential privacy guarantees, protecting individual records in the training dataset from extraction or inference attacks.

Differentially Private Stochastic Gradient Descent (DP-SGD) is a training algorithm that modifies standard SGD by clipping per-sample gradients to a fixed norm and then adding calibrated Gaussian noise to the aggregated batch gradient. This ensures the final model parameters are statistically indistinguishable from those trained on a dataset differing by one record, providing a provable privacy guarantee bounded by the privacy loss parameter epsilon.

The core mechanism relies on the subsampled Gaussian mechanism, where random batch selection amplifies privacy through Privacy Amplification by Subsampling. A privacy accountant tracks cumulative privacy loss across training steps using composition theorems like Rényi Differential Privacy (RDP) or Gaussian Differential Privacy (GDP). The clipping threshold and noise multiplier jointly control the privacy-utility trade-off, with tighter clipping and larger noise yielding stronger guarantees at the cost of model accuracy.

MECHANICS

Key Features of DP-SGD

Differentially Private Stochastic Gradient Descent (DP-SGD) modifies the standard training loop with two critical operations to provide provable privacy guarantees against gradient leakage and membership inference.

01

Per-Sample Gradient Clipping

Before aggregation, the gradient for each individual data point is computed and its L2 norm is bounded by a fixed threshold C. This limits the maximum influence any single record can have on the model update. If the gradient norm exceeds C, it is scaled down proportionally. This step is essential because the sensitivity of the query—the maximum change in output from adding or removing one record—must be bounded to calibrate the noise correctly. Without clipping, a single outlier could dominate the gradient and require infinite noise to mask.

02

Gaussian Noise Injection

After clipping per-sample gradients and summing them into a batch gradient, calibrated Gaussian noise is added to the aggregate. The noise scale is proportional to the clipping threshold C and inversely proportional to the target privacy budget ε. This ensures the final model update is statistically indistinguishable from one computed on a dataset that excludes any single record. The noise is sampled from a zero-mean normal distribution with standard deviation σ · C, where σ is the noise multiplier derived from the privacy accountant.

03

Privacy Accountant & Budget Tracking

DP-SGD employs a privacy accountant—typically based on Rényi Differential Privacy (RDP) or Gaussian Differential Privacy (GDP)—to track cumulative privacy loss across training iterations. Key components:

  • Moments Accountant: Computes tight bounds on the privacy loss random variable across sequential queries
  • Poisson Subsampling: Each example is included in a batch with fixed probability q, amplifying privacy via the subsampled Gaussian mechanism
  • Composition Theorems: Combine per-iteration losses into a total (ε, δ)-DP guarantee
  • The accountant outputs the final privacy budget spent, enabling practitioners to stop training before exceeding a predefined threshold.
04

Ghost Clipping for Memory Efficiency

Standard per-sample gradient clipping requires materializing the gradient for every example in a batch, multiplying memory usage by batch size. Ghost clipping avoids this by computing per-sample gradient norms directly from the loss gradient with respect to the activations, using the chain rule. This technique:

  • Reduces peak memory from O(B · P) to O(P), where B is batch size and P is parameter count
  • Enables DP-SGD on large models like fine-tuned LLMs without prohibitive hardware
  • Is implemented in libraries like Opacus and TensorFlow Privacy for practical deployment
05

Privacy-Utility Trade-off

The core tension in DP-SGD is balancing privacy (ε) against model accuracy. Smaller ε (stronger privacy) requires larger noise, degrading utility. Mitigation strategies include:

  • Larger batch sizes: Reduce noise variance through aggregation before noising
  • More training epochs: Compensate for noisy updates with additional iterations, though this consumes more privacy budget
  • Tighter accounting: Using GDP or RDP instead of basic composition can save 2-5x in ε for the same noise level
  • Public pre-training: Starting from a model pre-trained on public data reduces the number of private updates needed
  • Typical deployments target ε ∈ [1, 8] for production systems, with ε < 1 considered strong privacy.
06

Defense Against Gradient Leakage

DP-SGD directly counters gradient inversion attacks like Deep Leakage from Gradients (DLG) by ensuring shared gradients carry a formal privacy guarantee. The Gaussian noise added during training destroys the fine-grained signal that optimization-based reconstruction relies on. Combined with secure aggregation in federated settings, DP-SGD provides defense-in-depth:

  • The server never sees individual client updates in plaintext (cryptographic protection)
  • Even the aggregated update is differentially private (statistical protection)
  • An adversary with full access to the noisy aggregate cannot reconstruct training data beyond the ε guarantee
DP-SGD EXPLAINED

Frequently Asked Questions

Clear, technically precise answers to the most common questions about differentially private stochastic gradient descent, the foundational algorithm for training machine learning models with provable privacy guarantees.

DP-SGD, or Differentially Private Stochastic Gradient Descent, is a training algorithm that modifies standard SGD to provide provable privacy guarantees for individual records in a training dataset. It works through two core mechanisms applied during each training step: per-sample gradient clipping and calibrated noise injection. First, the gradient is computed individually for each example in a batch, and each per-sample gradient's L2 norm is bounded to a fixed clipping threshold C. This prevents any single outlier example from having a disproportionately large influence on the update. The clipped gradients are then aggregated, and isotropic Gaussian noise drawn from N(0, σ²C²I) is added to the sum. The noise scale σ is calibrated against a target privacy budget (ε, δ) using a privacy accountant, which tracks cumulative privacy loss across all training iterations. The result is a model update whose distribution is nearly indistinguishable whether or not any specific individual's data was included in the training set, formalized through the mathematical framework of (ε, δ)-differential privacy.

PRIVACY MECHANISM COMPARISON

DP-SGD vs. Standard SGD vs. Gradient Perturbation

A technical comparison of the core mechanisms, privacy guarantees, and computational trade-offs between standard stochastic gradient descent, its differentially private variant, and output perturbation approaches.

FeatureDP-SGDStandard SGDGradient Perturbation

Core Mechanism

Per-sample clipping + batched Gaussian noise

Raw gradient computation on mini-batch

Noise added to aggregated batch gradient

Privacy Guarantee

Formal (ε, δ)-DP via subsampled Gaussian mechanism

None

Approximate; depends on noise scale

Per-Sample Clipping

Privacy Amplification

Yes, via Poisson sampling

Privacy Accounting

Moments Accountant or RDP composition

Computational Overhead

2-10x vs. standard SGD

1x (baseline)

1.01-1.5x vs. standard SGD

Model Utility at ε=8

95-98% of non-private baseline

100% (no privacy)

90-95% of non-private baseline

Defends Against Gradient Leakage

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.