Proximal Policy Optimization (PPO)
Proximal Policy Optimization stabilizes policy-gradient training by limiting how far each update moves the policy. It computes the probability ratio between the current and old policy and clips it to [1−ε, 1+ε] (ε=0.2 in the paper). It then takes the minimum of the clipped and unclipped advantage-weighted objectives, so the gradient goes to zero when an update would push the ratio further outside the range. Six ratio/advantage cases show when updates happen, and the method is contrasted with TRPO's KL constraint. The final actor-critic loss combines the clipped objective, a value loss and an entropy bonus, followed by a pointer to a from-scratch PyTorch implementation trained on CartPole-v1 and LunarLander-v2.
Related posts
- Policy Gradient with PyTorch
Hugging Face easyNovicePolicy-gradient methods optimize a stochastic policy directly via gradient ascent on expected return, instead of deriving a policy from learned Q-values as in Deep Q-Learning. Their advantages are built-in exploration, robustness to perceptual aliasing, and handling of continuous or high-dimensional action spaces. Their drawbacks are convergence to local maxima, slow training and high variance. Reinforce (Monte Carlo Policy Gradient) collects a full episode, estimates the gradient from the log-probabilities of the actions weighted by the return, and updates the weights. A linked Colab notebook implements it in PyTorch on CartPole-v1, PixelCopter and Pong.
- Engineering and algorithmic interventions for multimodal post-training at Microsoft scale
Engineering@Microsoft hardMasterProduction-scale RL post-training of multimodal Copilot agents fails silently because policy gradient advantage estimates lose informativeness even as aggregate reward climbs. Five interventions address this: a staged curriculum (verifiable rewards only for the first 30% of training, with an entropy floor), an adaptive loop that injects near-miss trajectories when effective sample size drops below 20%, per-trajectory gradient normalization by σ_source·sqrt(length) to cut gradient concentration (Gini ~0.75 to ~0.35), softplus constraint penalties plus an annealed parallelism reward to avoid serial collapse, and mixed-horizon sampling instead of horizon curricula. ESS collapse proved a leading indicator of learning stalls by about 35 epochs, and each fix comes with explicit costs such as ~15% memory overhead or lower peak single-horizon performance.
- Diagnosing instability in production-scale agent reinforcement learning
Engineering@Microsoft hardMasterLate-phase instability in on-policy RL for tool-using agents can come from variance amplification in tool-conditioned contexts. Post-tool states fall in low-support regions of the reference policy, so importance-ratio tails grow while loss, reward, entropy and global KL stay flat. A small-scale reproduction shows p95 per-token log-ratio growth and right-tail CDF stretching in post-tool slices, with effective sample size used as a supporting signal; constraining tool outputs or drift-aware baselines suppressed the growth. The proposed fix is monitoring rather than a new optimizer: slice diagnostics by pre-tool versus post-tool contexts, track tail percentiles in-stream across workers, and treat KL caps and rollbacks as load-bearing guardrails. These checks ship in Microsoft's open-source Post-Training Toolkit, now integrated into Hugging Face TRL.
- Putting RL back in RLHF
Hugging Face hardMasterRLOO (REINFORCE Leave-One-Out) is now available as a trainer in Hugging Face TRL. It is an online RLHF algorithm that drops PPO's value model. It treats the whole completion as a single action, uses the REINFORCE loss, and computes each sample's baseline as the mean reward of the other k−1 completions for the same prompt. That cuts vRAM by roughly 50-70% and makes training 2-3x faster than PPO on Pythia 1B and 6.9B, while matching PPO's GPT-4-judged win rate (78.7% for 6.9B on TL;DR) and beating DPO. Code walkthroughs show the advantage computation and that REINFORCE is a special case of the PPO loss. There is a caveat: bf16 numerical mismatches between generation and training logprobs hurt RLOO more than PPO.
- Toward RL on mixed-precision, mixed-accelerator samplers
Modal hardMaster
RL training of Qwen3.6-35B-A3B on agentic coding stays stable when samplers run on six accelerator types (A100 through B300, RTX PRO 6000) in NVFP4, FP8 and BF16 with their own kernels, feeding a BF16 trainer on B200. Uncorrected GRPO collapses on both mixed and homogeneous samplers. Only score centering plus masked importance sampling (optionally with top-p mask replay) trains to the end, matching homogeneous-sampler SWE-bench Pro V2 pass@4 despite 4.7× larger sampler–trainer KL, at about 15% lower sampling cost per update. The central claim is that stability depends on whether mismatch keeps growing, not on its size, so off-policy correction can stand in for bitwise-identical on-policy matching. Collapse shows up as falling reward, KL growing 3× or more, and episodes ending when the model stops calling its tool.