On a few pitfalls in KL divergence gradient estimation for RL

Yunhao Tang, Rémi Munos
6/11/2025
cs.LG
rl

No confident code implementation found for this paper.

Abstract

We point out a few pitfalls in implementing gradient estimation for KL divergence in RL training for LLM, as seen in a number of open source projects and papers. The first major pitfall is to differentiate through the KL estimate as loss functions to minimize KL divergence.

Show full abstract

We show that such implementations are generally incorrect and do not produce the desired KL gradient. Secondly, we show that some implementations do not account for the sequential nature of the estimation problem and produce a partial gradient at best. We demonstrate the impact of such issues with illustrative tabular and LLM experiments, and show the correct way to implement the KL gradient.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{tang2025pitfalls,
  title  = {On a few pitfalls in KL divergence gradient estimation for RL},
  author = {Yunhao Tang and Rémi Munos},
  year   = {2025},
  eprint = {2506.09477},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2506.09477v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2506.09477.svg)](https://codeofpaper.com/paper/2506.09477)

Discussion