Understand: state assumptions, shapes/units and a counterexample.
Implement: reproduce a numerical example and inspect boundaries.
Investigate: compare one alternative under a matched budget.
Understand the mechanism
PPO compares current and rollout-policy action probabilities. Its clipped objective limits certain improvements in a surrogate objective. For positive advantage the upper side clips; for negative advantage the lower side matters. The old policy is a frozen reference for the collected batch, not necessarily the original pretrained model. Reusing increasingly stale trajectories changes the validity of the approximation.
Original schematic; read the steps from top to bottom. SVG ↓
Symbols and assumptions
Symbol
Meaning
ρ
Current / rollout-policy sampled action probability
Â
Estimated advantage for a sampled action
ε
Clipping threshold, not a guaranteed KL limit
Freeze old log probabilities for a rollout batch. Compute the ratio as exp(logπθ−logπold) to avoid division of tiny probabilities.
At and positive advantage, a ratio above 1.2 receives no additional surrogate incentive. At negative advantage, a ratio below 0.8 is the analogous clipped side.
For and Â=−2, raw objective is −1, clipped candidate −1.6, and the minimum is −1.6. The sign of advantage determines which branch is pessimistic.
Experiment checkpoint
Test both signs and clipping boundaries. If all updates clip immediately, inspect learning rate, advantage scale and rollout staleness.
LOCAL / SYNTHETIC / INTERACTIVE
Change one variable. Explain what moves.
Original teaching calculation, not a reproduction of the paper’s benchmark. Bars are relative within this panel; numeric values and units are authoritative.
Original exercise & analysis
At and , compare Â=+1 and Â=−1. The objectives are 1.2 and −1.5. Then try : they are 0.5 and −0.8. Explain each branch before opening the answer.
Clipping does not guarantee a fixed KL bound or monotonically improved task reward. Monitor both.
What should be logged besides reward?
Approximate KL, entropy, clipping fraction, advantage distribution, value loss, rollout length and held-out task metrics.
Maximize the clipped surrogate, or minimize its negative. Freeze old log probabilities and advantages during each policy update. The sampled old-policy probability must be nonzero; clipping is not a hard KL constraint.
Formula conditions, units and worked arithmetic reviewed. The implementation isolates one numerical mechanism; it does not train a policy or control real hardware.
Before running: predict a boundary case
Negative advantages require min after multiplying, not clipping the final objective.
Hint: isolate the assumption
Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.
Minimal executable example
Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node ppo-updates.mjs. No third-party runtime dependencies.
Negative advantages require min after multiplying, not clipping the final objective.
Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.
Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.
The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope