Sharpness-Aware Minimization in Logit Space Efficiently Enhances Direct Preference Optimization

Haocheng Luo, Zehang Deng, Thanh-Toan Do, Mehrtash Harandi, Dinh Phung, Trung Le

Abstract

Direct Preference Optimization (DPO) is a favored algorithm for aligning Large Language Models (LLMs) with human preferences due to its simplicity. However, it suffers from a "squeezing effect" where the model unintentionally becomes less likely to generate preferred responses during training. This paper introduces logits-SAM, a computationally efficient variant of Sharpness-Aware Minimization (SAM) that targets only the model's output layer. By smoothing the optimization landscape, logits-SAM effectively mitigates the squeezing effect with negligible training overhead, consistently improving the performance of DPO and its variants.

The Problem: The Squeezing Effect

Aligning LLMs with human values traditionally involves Reinforcement Learning from Human Feedback (RLHF). While DPO simplified this pipeline by removing the need for a separate reward model, it introduced a new vulnerability known as the squeezing effect (or likelihood displacement).

In theory, DPO should increase the probability of a "chosen" response and decrease the probability of a "rejected" one. In practice, the gradients interact in ways that can cause the probability of both responses to decrease during training, while the probability of irrelevant or incorrect tokens spikes. This unintended drift degrades model performance and can even compromise safety guardrails.

Training dynamics illustrating the squeezing effect and SAM's mitigating impact.

Theoretical analysis reveals that the negative-gradient updates used to penalize rejected responses act like "anti-gravity," pushing the model into unstable, high-curvature regions of the loss landscape. This causes the model's residuals to explode along these sharp directions in logit space.

The Solution: Logits-SAM

To counter this sharp optimization trajectory, the authors turn to Sharpness-Aware Minimization (SAM). SAM is an optimization technique that actively seeks out "flat" minima—regions where the loss remains stable despite small parameter perturbations. Flatter minima generally correlate with better generalization.

However, standard SAM is computationally expensive, requiring two full forward and backward passes per step. To solve this, the authors propose logits-SAM, which applies the SAM perturbation exclusively to the output layer (the language modeling head).

By perturbing only this final linear layer—which typically accounts for less than 2-5% of the model's total parameters—logits-SAM achieves the curvature-regularization benefits of full SAM without the massive computational cost. The authors mathematically demonstrate that setting the perturbation radius ($\rho$) to share the same sign as the learning rate effectively suppresses the squeezing effect.

Experimental Validation and Key Results

The researchers validated logits-SAM across diverse benchmarks (Anthropic-HH, Reddit TL;DR, UltraFeedback Binarized, SorryBench) using models like Pythia-2.8B, Mistral-7B, and Gemma-2B-IT. Logits-SAM proved to be a seamless, "plug-and-play" enhancement that integrates easily with standard DPO, SLiC-HF, and CPO.

Win rates of standard alignment methods versus their logits-SAM enhanced variants on the Anthropic-HH and TL;DR datasets.

Key findings include: * Consistent Performance Boost: Logits-SAM improved win rates across the board. For instance, on the Anthropic-HH dataset, enhancing DPO with logits-SAM increased the win rate against the Supervised Fine-Tuning (SFT) baseline from 70.52% to 72.28%. * Safety Recovery: On the SorryBench dataset, standard DPO inadvertently decreased the model's refusal rate for harmful prompts compared to the reference model. DPO+logits-SAM reversed this degradation, significantly increasing the refusal rate of harmful content from approximately 70% to 75%. * High Efficiency: While vanilla SAM doubles training time, logits-SAM adds only about 2–3% computational overhead. This makes it a practically "free" upgrade for alignment pipelines. * Flatter Solutions: Measurements of the Hessian trace (a metric for sharpness) confirmed that logits-SAM produces significantly flatter, more stable solutions than standard AdamW optimization.

Limitations and Future Work

The theoretical analysis primarily operates in the "kernel regime," assuming fixed features, which may not fully capture the complex, non-linear dynamics of deep network internal layers. Additionally, while the perturbation scale ($\rho$) is smaller than in standard SAM, it still requires hyperparameter tuning. Future research could explore adaptive methods for setting this radius or apply these logit-space insights to online RLHF methods where models generate their own training data dynamically.

Summary updated

BibTeX
@inproceedings{luo2026sharpness,
  author = {Haocheng Luo and Zehang Deng and Thanh-Toan Do and Mehrtash Harandi and Dinh Phung and Trung Le},
  title = {{Sharpness-Aware Minimization in Logit Space Efficiently Enhances Direct Preference Optimization}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=4mE2FlL66E},
}
Figure