Policy gradient loss combines rollout advantages with log probabilities to push the policy toward actions that earned better outcomes and away from worse ones. section 6.2.1 section 6.9
It is computed as the negative mean of advantage-weighted sequence log probabilities, with advantages detached so only policy parameters receive gradients. section 6.9
The update flow uses it to:
- turn rollout logprobs into a tensor before scoring them. section 6.9
- apply a sign flip so a maximization objective fits a minimization optimizer. section 6.9
- feed the result into the later model weight update step. section 6.2.1 section 6.9
Concrete loss computation
A listed implementation stacks rollout log probabilities and computes pg_loss = -(advantages.detach() * logps).mean(). section 6.9
Figure 6.8 Overview of the GRPO algorithm for RLVR using a chef analogy. Multiple rollouts are generated and scored, relative advantages are computed, and a policy gradient objective with a KL-based regularization loss term is used to update the model parameters.
Shows the GRPO flow where multiple rollouts are scored, relative advantages are computed, and the policy gradient objective updates parameters. section 6.2.1
Figure 6.17 The fifth stage in the GRPO pipeline computes the policy gradient loss that we’ll use to update the model. Stage 6, the model weight update, will be implemented later as part of the training loop.
Places policy gradient loss as stage five in the GRPO pipeline, before the separate weight update stage. section 6.9


