Questions about the code
Hello,
I really enjoyed reading the JustGRPO paper—especially the discussion of the “flexibility tax” of arbitrary-order generation in diffusion LLMs and the idea of defining an AR policy during RL to simplify training.
-
While studying the released code, I had a question about the GRPO implementation. In grpo.py, inside logprob_loss, the ratio is computed as ratio = exp(token_log_prob - token_log_prob.detach()) and then clipped. Would it be correct to interpret this as an approximation to the ratio in Eq. (8): ρ = exp(log πθ − log πθ₍old₎) without explicitly storing logprob_old? If so, could you share the motivation for implementing it this way?
-
Also, Eq. (8) appears to include a KL penalty term (−β KL), but I couldn’t find a separate reference/old model or an explicit KL term in the code. (1) Is this a minimal variant with β set to 0, or (2) is the KL/ref/old logprob handled elsewhere (e.g., another file or an option)?
I may be missing something since I don’t have much hands-on experience implementing GRPO, so any clarification would be greatly appreciated. Even a brief pointer would help a lot.
Thank you!
Hi,
Thank you for your interest in the paper and for looking into the code so closely.
Regarding your questions about the implementation in grpo.py:
1. Ratio Calculation
Your interpretation is correct. The expression (token_log_prob - token_log_prob.detach()).exp() is indeed an implementation trick.
This is valid specifically because JustGRPO uses 1 Policy Update Step per sampling iteration, as shown in Table 2 of the paper. Since there is only one update step, the "old" policy () is identical to the current policy () at the moment of the update.
Consequently, the ratio is mathematically exactly 1.0. By using (log_p - log_p.detach()).exp(), the code ensures the forward pass value is 1.0 while still allowing the gradient to flow correctly during backpropagation. This avoids the computational and memory overhead of explicitly calculating and storing logprob_old.
2. KL Penalty You are also correct that the KL term is missing from the code. This is intentional.
As listed in Table 2 (Appendix A.2), the KL Penalty Coefficient is set to 0.0. Since the coefficient is zero, we removed the explicit KL calculation from the codebase. This simplifies the training loop and removes the need to load a reference model, which also saves GPU memory.
I hope this clarifies things!
Hello, I'm new to RL and have a question. Previously, the d1 involved sampling once, then updating 12 times with the same batch of data. This ensured subsequent ratios weren't 1, maintaining distinct old and new strategies to implement GRPO's core theory. If the current code keeps the ratio value at 1, is this RL update reasonable? @LeapLabTHU