Unit 11 of 11 · about 6 hours · measure
Policy collapse, critic failure, stale log probabilities and multi-seed evaluation
Improving reward does not establish a correct PPO implementation. A defensible result must survive fixed-batch failures, independent evaluation and the seed distribution.
You'll be able to
- Diagnose stale denominators, entropy collapse and critic defects from stored rollouts before inspecting the offending code.
- Evaluate a small policy across prespecified training seeds with separate evaluation streams and complete diagnostic traces.
- Report interaction efficiency, wall time, uncertainty and failed runs without selecting the best seed.
Covers
Read
In this order, only the parts listed
0 of 4 done
- PPO debugging and reproducibility recommendationsThe 37 Implementation Details of Proximal Policy Optimization
Recommendations: Seed everything, Check if , Check KL divergence, Check other metrics, Enumerate implementation details used, Release locked source code and Track experiments
Skip the Breakout score rule and do not use the article's typical KL value as a universal threshold. Match a reference only when its environment and implementation setup match yours.
- CleanRL: what the logged metrics actually measureCleanRL PPO
ppo.py, Explanation of the logged metrics (page read 2026-10-14)Cross-check aggregation against the pinned code below. Its last minibatch losses are not full-rollout means, and clip fraction counts out-of-interval ratios rather than only flat objective branches.
- CleanRL: explained variance and metric writesCleanRL PPO
ppo.py, lines 295 to 309: old-value explained variance, final-minibatch losses, averaged clip fractions and steps per second - Control Laboratory: failure and evaluation evidenceReinforcement Learning Control Laboratory - Policy Core
Milestone D, Failure handling; Milestone E, Measurement / optimization; Milestone F, Final evaluation; Measurement requirements
Focus on
- Start with invariants: unchanged-policy ratios, reward/action alignment, target detachment and boundary masks. Rising KL, falling entropy or poor value fit are symptoms, not unique diagnoses.
- Compare critic predictions with frozen targets using residuals and squared error as well as explained variance. Explained variance can miss a constant prediction offset and is undefined when target variance is zero.
- On CPU, use your tested policylab PPO on
CartPole-v1with Gymnasium 1.4.0. Prespecify five training seeds and 100000 valid environment transitions per seed; record hyperparameters, versions and all attempts. This is an experiment budget, not a return target. - Evaluate frozen checkpoints on separate seed streams, with the action rule declared as sampling or argmax. Plot per-training-seed returns and entropy, KL, value error, ratio and gradient diagnostics against interactions and wall time. Treat the training run, not its many evaluation episodes, as the unit for across-run uncertainty.
Common mistakes · 3
- Calling low entropy policy collapse without checking the task and evaluation policy. A useful deterministic policy can have low entropy; poor independent return and lost action support supply the failure evidence.
- Reporting only successful runs or the best checkpoint chosen on final evaluation seeds. Keep failures and separate tuning, checkpoint selection and final evaluation.
- Treating training episode returns or a lower pseudo-loss as proof of generalization. Evaluate a frozen policy independently and keep evaluation out of the update data.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Ratios remain exactly 1 after several optimizer steps. Is that reassuring?Answer
Not by itself. The actor may not have moved, but the old log probabilities may also have been refreshed incorrectly. Recompute against the immutable behavior snapshot.
2.Why can explained variance equal 1 for a poor critic?Answer
It uses the variance of residuals, which ignores a constant offset. Predictions shifted uniformly from the targets have zero residual variance but nonzero squared error.
3.Can many evaluation episodes from one trained model replace multiple training seeds?Answer
No. They estimate that model's evaluation variability, not variability caused by training randomness.
4.What does an entropy-coefficient ablation need for fair attribution?Answer
The same environment, seed set, interaction budget, evaluation policy and tuning budget, with all attempts retained. Keep unrelated algorithm choices fixed.
You're done when
You detect both fixed-batch defects and retain a complete multi-seed evaluation report with two diagnosed induced failures, raw curves and no best-seed claim.
Only when you can do this without notes.
Leads to
- Evaluation policies and seeds, episodes and environments as uncertainty unitsDeepen evaluation-policy and uncertainty design.
- Policy, reference, critic, reward and verifier roles, and SFT as initializationCarry policy and critic identity into language-model RL without assuming model-scale post-training knowledge.
Notes
Resources · 3 for this unit, 10 more in the section
- The 37 Implementation Details of Proximal Policy OptimizationHuang et al. (ICLR Blog Track 2022) · required
Use the core and continuous-action details as an audit checklist for your PPO: vectorized environments, advantage normalization, value clipping, entropy, global gradient clipping, learning-rate annealing and observation and reward normalization. For each detail you adopt, show its effect with an ablation on your own task.
- CleanRL PPOCleanRL · support
Use the single-file implementation and implementation-details notes as a post-implementation audit. Trace rollout shapes, advantage calculation, minibatch epochs, ratios, clipping, value loss, entropy, seeding and environment semantics. Like the DQN script it reads
final_info, which Gymnasium 1.x next-step autoreset no longer provides; pingymnasium==0.29.1or patch the episode logging. - Reinforcement Learning Control Laboratory - Policy CoreRoadmap-Final · required
Complete REINFORCE with baseline, actor-critic, GAE and PPO requirements. Match hand-computed log probabilities, advantages, ratios and clipped losses and diagnose stale-policy, ratio, GAE and evaluation leakage defects.
Also in this section
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Policy Gradients, Actor-Critic and Advanced Policy GradientsUC Berkeley · primary
Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lectures 5 (policy gradients), 6 (actor-critic), 9 and 10 (advanced policy gradients). Work Homework 2 (
src/agents/pg_agent.py: return estimators, reward-to-go, a neural baseline and a GAE sweep); its runs take seconds to minutes on a laptop CPU. The homework pinsgym==0.25.2, which fails on NumPy 2, so port it to Gymnasium (terminatedandtruncated) or pinnumpy<2in its own environment, and turn off its forced WandB logging. - Stanford CS224R Spring 2026 - Policy Gradients and Actor-CriticStanford University · support
Use Lectures 03 (policy gradients) and 04 (actor-critic) as a second derivation, and the Homework 2 PPO handout for its exact GAE recursion and its note that several epochs on one batch is not strictly on-policy. Its runs need cloud GPUs, and its actor is a truncated normal, not a tanh-squashed Gaussian. Follow the Stanford honor code for course materials.
- Reinforcement Learning: An Introduction (2nd ed.) - Chapter 13Richard Sutton and Andrew Barto · required
The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Sections 13.1 to 13.5 and 13.7: the policy-gradient theorem, REINFORCE, REINFORCE with baseline, actor-critic and Gaussian policies. Reproduce Example 13.1 (the short corridor) with and without a baseline, and derive the gradient and baseline result in the notation of the shared trajectory schema.
- Proximal Policy Optimization AlgorithmsOpenAI · required
Read the clipped objective, implementation variants and experiments. Build hand cases for positive and negative advantages, compare clipped and unclipped losses and show that clipping alone does not enforce a hard KL bound.
- High-Dimensional Continuous Control Using Generalized Advantage EstimationSchulman et al. · required
Derive GAE from TD residuals, implement backward recursion with terminal and truncation masks and sweep and on fixed trajectories before training.
- Spinning Up - Intro to Policy Optimization and PPOOpenAI · support
Read Part 3 (Intro to Policy Optimization: the simplest policy gradient, reward-to-go, the expected grad-log-prob lemma, baselines) and the PPO page's background, which states that the clipped objective has no hard KL bound. Do not install its code: it needs TensorFlow 1, MPI and the retired Gym stack.
- Hands-on Modern RL - REINFORCE, Actor-Critic and PPOWalking Labs · support
Use the REINFORCE page, the actor-critic chapter and the PPO and GAE pages for worked numbers: the three advantage-sign cases and the five-step GAE table.
code/chapter05_policy_gradient/reinforce_cartpole.pyandcode/chapter07_ppo/ppo_from_scratch.pyrun on CPU in minutes. Audit completion masks against the Gymnasium docs (its GAE helper cuts the bootstrap on truncation) and do not adopt its KL sketch as a reference. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; itscode/chapterNNfolders do not follow the site chapter numbers. - Deep-ML - Policy-Gradient ProblemsDeep-ML · support
Use named problems as closed-book checks after your own implementation passes: 481 (REINFORCE with baseline), 482 (one-step actor-critic), 485 (PPO clipped surrogate with clip diagnostics) and 487 (GAE with episode boundaries). Read each problem's tests before trusting its statement.
- Soft Actor-Critic: action-bound density correctionHaarnoja et al. · reference
Appendix C, Enforcing Action Bounds, Equations 20 and 21 in arXiv:1801.01290v2. Supplies the change-of-variables derivation missing from the pool's action-clipping checklist; do not study SAC training here.
- Gymnasium vector autoreset modesFarama Foundation · reference
Read Next-Step Mode, Same-Step Mode and Disabled Mode in the official autoreset explainer, then SyncVectorEnv's reset and step API. Check against Gymnasium 1.4.0; pages read 2026-10-14. Supplies current rollout semantics missing from the older PPO examples.