Differentially private optimization for non-decomposable objective functions

Weiwei Kong, Andres Munoz medina, Mónica Ribero

Training foundation models often relies on unsupervised pre-training using contrastive loss. This approach teaches models to understand data by pushing similar examples together and pulling distinct ones apart in the embedding space. However, integrating Differential Privacy (DP) into this process introduces significant scaling challenges. In a recent paper, researchers introduce Logit-DP, a novel optimization framework designed to solve a fundamental sensitivity problem in private contrastive learning.

The Challenge of Non-Decomposable Losses

Standard differentially private stochastic gradient descent (DP-SGD) algorithms rely on a crucial assumption: the objective function must be decomposable. This means the total loss is simply the sum of individual, independent losses for each data point.

Contrastive losses, however, are non-decomposable. Calculating the loss for a single image requires comparing it against every other image in the batch. Adding or removing one example alters the loss calculation for every other example. In the context of DP, this creates a sensitivity nightmare. To guarantee privacy, noise proportional to the gradient's sensitivity must be added. For contrastive losses, this sensitivity scales linearly with the batch size ($O(n)$). Consequently, increasing the batch size to improve training stability forces the addition of overwhelming noise, often destroying the model's ability to learn.

Logit-DP: A Scalable Solution

To overcome this, the authors propose Logit-DP, a variant of DP-SGD. Instead of the standard approach—clipping the gradient of the total loss for each example—Logit-DP decomposes the gradient into its constituent pairwise similarity gradients (the "logits").

The Logit-DP algorithm operates in three main steps:

  1. Decompose: Break the batch gradient down into gradients of the similarities between pairs of inputs.
  2. Clip Pairwise: Apply clipping to these pairwise gradients individually.
  3. Sum and Noise: Reconstruct the total gradient from these clipped components and add Gaussian noise.

Crucially, the authors prove that for common non-decomposable functions like the canonical contrastive loss, this method results in a summed gradient sensitivity of $O(1)$. This means the sensitivity remains constant regardless of the batch size $n$, allowing practitioners to leverage large batches without an explosion in privacy-preserving noise.

Key Results

The researchers evaluated Logit-DP on standard computer vision benchmarks, including CIFAR-10 for unsupervised pre-training and CIFAR-100 for fine-tuning.

Relative Contrastive Loss Values comparing Logit-DP, Naive-DP, and Non-Private models. Logit-DP tracks the non-private baseline much more closely than the naive approach.

The experiments demonstrate that Logit-DP significantly outperforms naive private baselines ("Naive-DP," which clips the aggregated batch gradient) and approaches non-private performance levels. As observed in the training plots, Naive-DP often results in stagnant loss due to a poor signal-to-noise ratio, whereas Logit-DP maintains a strong learning trajectory.

Table showing relative aggregate test metrics for CIFAR-10. Logit-DP maintains high accuracy, recall, and precision compared to the naive private baseline across different architectures.

On CIFAR-10 pre-training, Logit-DP achieved relative accuracy scores (compared to a non-private baseline) of 0.819 for a generic embedding network and 0.730 for a ResNet18. In contrast, Naive-DP's performance degraded significantly on more complex architectures. Furthermore, on CIFAR-100 fine-tuning tasks, Logit-DP effectively preserved the utility of pre-trained features, showing it can successfully bridge the gap between privacy and model utility.

Limitations and Future Directions

While Logit-DP solves the statistical scaling issue, it introduces a computational one. The current implementation requires materializing $n^2$ logit gradients for a batch of size $n$, creating a significant memory bottleneck for very large batches.

The authors suggest that future work could utilize low-rank matrix decompositions to compute the sum of clipped gradients without materializing every individual pair, potentially reducing the memory cost to $O(n)$. Additionally, while tested primarily on vision tasks, the theoretical framework holds promise for Large Language Models (LLMs) that utilize similar contrastive objectives.

Summary updated

BibTeX
@inproceedings{kong2025differentially,
  author = {Weiwei Kong and Andres Munoz medina and Mónica Ribero},
  title = {{Differentially private optimization for non-decomposable objective functions}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=F52tAK5Gbg},
}
Figure