DL0108 PPO vs DPO vs GRPO

Explain the architectural and mathematical differences between PPO, DPO (Direct Preference Optimization), and GRPO (Group Relative Policy Optimization).

Answer

All three optimize the same underlying target, maximize a preference-derived reward while staying close to a frozen reference policy, and they differ in how many networks must be resident, how the advantage is estimated, and whether the training data is sampled from the current policy. PPO is the full actor-critic loop used in InstructGPT-style RLHF: it keeps four networks (trained policy, frozen reference, frozen reward model, trained critic), samples rollouts on-policy, and updates with a clipped importance ratio against token-level GAE advantages produced by the critic. DPO deletes the RL loop entirely by inverting the closed-form solution of the KL-constrained objective: the implied reward is \beta \log(\pi_\theta / \pi_{ref}), the partition function cancels inside a Bradley-Terry pairwise likelihood, and what remains is a supervised binary-classification loss on fixed (y_w, y_l) pairs with only two networks and no sampling. GRPO keeps online sampling and the clipped surrogate but removes the critic: for each prompt it draws a group of G completions, uses the group’s mean reward as the baseline, and z-scores the rewards to get one scalar advantage that is broadcast to every token of its completion. So the axis is not “better versus worse” but which piece of machinery you are willing to pay for: PPO buys fine-grained credit assignment with a learned value function, DPO buys simplicity by giving up exploration, and GRPO buys on-policy learning with a Monte Carlo baseline.

(1) Networks Resident: PPO needs policy, reference, reward model, and critic; GRPO drops the critic; DPO drops both the critic and the reward model.
(2) Advantage Estimation: PPO uses GAE over a learned V_\psi, GRPO uses a group-relative z-score of sequence rewards, and DPO never forms an advantage at all, only a reward margin between two responses.
(3) On-Policy Versus Offline: PPO and GRPO resample from the current policy every iteration, so the clip and importance ratio are meaningful; DPO trains on a static dataset and is therefore exposed to distribution shift.
(4) KL Control: PPO and GRPO add an explicit KL penalty (GRPO commonly uses the low-variance k3 estimator), while DPO’s KL constraint is baked into the log-ratio parameterization and controlled solely by \beta.
(5) Credit Granularity: only PPO assigns different advantages to different tokens; GRPO gives every token in a completion the same scalar, and DPO gives a whole-sequence gradient.
(6) Where Each Fits: verifiable rewards from a checker or unit test favor GRPO, a cheap single-pass alignment on collected preferences favors DPO, and a nuanced learned reward model with long generations favors PPO.

Three side-by-side data-flow panels: PPO with prompt, trained policy, rollout, frozen reward model plus trained critic, and GAE advantage; DPO with a static preference pair scored by the trained policy and frozen reference into a logistic loss; GRPO with a prompt, trained policy, a group of G rollouts, a frozen verifier, and a group z-scored advantage

Figure 1: The three objectives differ mainly in what sits between the policy and the loss: PPO inserts a reward model plus a trained critic, GRPO replaces the critic with a group of sampled rollouts, and DPO removes the sampling stage so the frozen reference is the only extra network.

DPO’s derivation is what makes the contrast precise. The KL-constrained bandit objective has the closed-form optimum \pi^*(y \mid x) \propto \pi_{ref}(y \mid x) \exp(r(x,y)/\beta); solving for the reward gives r = \beta \log(\pi^*/\pi_{ref}) + \beta \log Z(x), and because the Bradley-Terry likelihood depends only on reward differences for the same prompt, the intractable partition function Z(x) cancels. The reward model therefore never has to be materialized, since its optimal policy is the object you were going to train anyway. The price is that this equivalence is exact only when the preference pairs come from \pi_{ref}; on off-policy pairs the loss can raise the margin while pushing down the probability of the chosen response as well, the failure mode usually called likelihood displacement. GRPO takes the opposite trade, keeping the on-policy ratio and clip but swapping the critic’s learned variance reduction for a Monte Carlo baseline over G samples of the same prompt, which is cheap and well-behaved when the reward is a verifiable 0/1 signal from a math checker or unit test. That is exactly the regime DeepSeek used when introducing GRPO for DeepSeekMath and then scaling it for R1.

Mathematical Formulation:
r_t(\theta) = \frac{\pi_\theta(a_t \mid s_t)}{\pi_{old}(a_t \mid s_t)}
\tilde r_t = \mathrm{clip}(r_t, 1 - \epsilon, 1 + \epsilon)
\mathcal{L}_{PPO} = -\mathbb{E}\left[\min(r_t A_t,\ \tilde r_t A_t)\right]
A_t = \sum_{l \geq 0} (\gamma \lambda)^l \delta_{t+l}
\delta_t = R_t + \gamma V_\psi(s_{t+1}) - V_\psi(s_t)
\hat r_\theta(x, y) = \beta \log \frac{\pi_\theta(y \mid x)}{\pi_{ref}(y \mid x)}
\Delta = \hat r_\theta(x, y_w) - \hat r_\theta(x, y_l)
\mathcal{L}_{DPO} = -\mathbb{E}\left[\log \sigma(\Delta)\right]
A_i = \frac{R_i - \mathrm{mean}(R_{1:G})}{\mathrm{std}(R_{1:G})}
\mathcal{L}_{GRPO} = -\mathbb{E}\left[\min(r_i A_i,\ \tilde r_i A_i)\right]
\qquad + \beta \, \mathbb{D}_{KL}\left[\pi_\theta \,\|\, \pi_{ref}\right]

Where:

  • \pi_\theta is the trained policy, \pi_{ref} the frozen reference (normally the SFT checkpoint), and \pi_{old} the policy that generated the current batch of rollouts.
  • s_t is the prompt-plus-prefix state and a_t the token emitted at position t; R_t is the per-step reward, which in RLHF is usually nonzero only at the final token.
  • V_\psi is the learned critic, \delta_t the TD residual, and A_t the GAE advantage with discount \gamma and trace decay \lambda.
  • \epsilon is the clip half-width (typically 0.1 to 0.2) and \beta is the KL coefficient in PPO and GRPO, or the implicit-reward temperature in DPO (typically 0.01 to 0.5).
  • y_w and y_l are the preferred and rejected responses for prompt x, \sigma is the logistic function, and \hat r_\theta is the reward implied by the policy itself.
  • i \in \{1, \ldots, G\} indexes the group of completions sampled per prompt (commonly G = 8 to 64), R_i is its sequence-level reward, and A_i is shared by every token of completion i.
  • Required initial condition in all three: \pi_\theta is initialized from \pi_{ref}, otherwise the KL term and the log-ratio reward have no meaningful anchor.
Stacked bar chart of resident bf16 weight memory for a 7B policy: PPO 56 GB with 28 GB trained, GRPO with a reward model 42 GB with 14 GB trained, GRPO with a rule verifier 28 GB, and DPO 28 GB with 14 GB trained

Figure 2: Counting only weights at 7B scale in bf16, PPO holds four copies and trains two of them, so its Adam state is roughly double GRPO’s; a rule-based verifier removes the reward model entirely, making GRPO as light as DPO in weight memory while still sampling online.

PropertyPPODPOGRPO
Networks residentPolicy, reference, reward model, critic (two trained)Policy and frozen reference (one trained)Policy, reference, reward model or verifier (one trained)
Data sourceFresh on-policy rollouts from promptsStatic offline preference pairs, no generationGroups of G on-policy rollouts per prompt
Baseline for the gradientLearned value function, GAE per tokenThe rejected response acts as the baselineGroup mean reward, normalized by group std
Credit granularityPer token, values differ along the sequenceWhole sequence, one margin per pairOne scalar per completion, broadcast to all its tokens
KL controlExplicit penalty or reward shaping, often adaptiveImplicit in the log-ratio, tuned only through betaExplicit term with the k3 estimator, sometimes dropped
Cost per updateHighest: generation plus four forward passes plus critic trainingLowest: two forward passes on cached textGeneration dominates, G completions per prompt
Main failure modeCritic instability and reward hacking, many coupled hyperparametersOff-policy shift and likelihood displacement on unseen responsesDegenerate groups with zero reward variance, length and difficulty bias

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *