Unit 12 of 12 · about 6 hours · measure
SFT, DPO, rejection and best-of-N controls, matched budgets and training traces
Online RL can spend much more sampling compute than its controls. The evidence must distinguish learned behavior from extra candidates, a permissive verifier or a changed evaluation denominator.
You'll be able to
- Compare a small online policy update with SFT, DPO, rejection fine-tuning and inference-time selection controls.
- Account for generated tokens, verifier calls, updates and wall time, including failed and filtered attempts.
- Interpret reward and independent quality traces with KL, entropy, length, validity and prompt-level uncertainty.
Covers
Read
In this order, only the parts listed
0 of 3 done
- DeepSeekMath: controls and sampling versus improvementDeepSeekMath - GRPO
arXiv:2402.03300v3, Sections 5.2.1 and 5.2.2, Table 10 and Figures 5 and 7
Read the control definitions and evaluation distinction only. These comparisons do not establish an algorithm ranking under your budgets; DPO is a preference objective, not an on-policy policy-gradient estimator.
- Post-Training Laboratory: matched evidenceLLM Post-Training Laboratory - Online RL
Hardware variants, Milestones B, E and F, Measurement requirements and Design-defense questions
Apply these standards to the section's reduced-scale online study, not the entire laboratory. Reuse earlier SFT, DPO, verifier and evaluation components.
- TRL 1.15.0: trace definitionsTRL GRPO Trainer
Logged metrics:
num_tokens,step_time,reward,entropy,kl, completion length and clipping metricsUse definitions, not the eight-GPU Quick start.
num_tokensincludes prompts and completions, andklis logged only whenbetais nonzero; add separate generated-token and verifier-call counters.
Focus on
- Use a tiny CPU text policy and short verifiable completions first. If your GPU fits weights, optimizer state, activations and generation buffers, repeat with a small decoder or adapter. Frozen rollouts establish loss correctness, not online behavior improvement.
- Start controls from the same checkpoint and prompt split. SFT imitates specified targets; DPO uses scored pairs; rejection fine-tuning imitates accepted samples; best-of-N selects without updating weights. Name the selector available at deployment and any oracle-only upper bound.
- Reuse Matched interaction and compute budgets, tuning budgets and final-evaluation isolation. Match a prespecified main budget axis and disclose the others; equal updates do not imply equal tokens or compute. Count collection, retries, rejected groups, verification, training and evaluation separately.
- Plot raw reward, independent quality, reference KL, token entropy, length, validity and signal coverage against both consumed budget and update count. Evaluate fresh held-out outputs at common decoding settings and selection budgets. Pair by prompt and report seed spread or prompt-level uncertainty; preserve failures and reward-hacking probes.
Common mistakes · 3
- Calling a best-of-N gain a learned policy improvement. Selection changes the delivered answer without changing model weights.
- Building DPO pairs with extra uncounted generations or charging only the accepted samples in rejection fine-tuning.
- Choosing checkpoints or reward parameters on the final held-out score. The final evaluation then becomes tuning data.
Try it yourself
Closed-book, before checking anything
[5, 6, 7, 8] for each prompt. Score every completion once and retain six for training. The collection ledger must still show 78 generated tokens, 12 verifier calls and 12 attempted completions, with six retained. Use that accounting rule in the mini-project's bounded online study. Compare fresh held-out outputs before and after training with the named controls; report a gain, no detectable gain or a regression without requiring a particular score.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.What would support learned improvement rather than extra inference compute?Answer
Fresh outputs from the updated policy outperform the starting policy at the same decoding and selection budget on independent held-out evaluation. Matched training controls strengthen attribution.
2.Is rising training reward with flat external quality a successful result?Answer
It shows proxy fitting, not established behavior improvement. Inspect hacking, validity, length and evaluation uncertainty.
3.Must every control consume identical wall time and token counts?Answer
Usually that is infeasible. Choose the main matching axis in advance, disclose all costs and compare quality-cost trade-offs rather than claiming universal superiority.
You're done when
The cost fixture balances, controls disclose every budget axis, and fresh independent evaluation supports a hardware-scoped conclusion with failed attempts and uncertainty retained.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 10 more in the section
- DeepSeekMath - GRPODeepSeek AI · required
Study the GRPO method and group-relative advantage construction, not the unrelated pretraining details. Implement all-equal and mixed-reward group tests and separate algorithmic changes from additional sampling.
- TRL GRPO TrainerHugging Face · support
After scratch estimator tests pass, inspect the GRPOTrainer for TRL 1.15.0: its reward-function, generation, loss and logging contracts. Its defaults changed across releases (
loss_type="dapo"andbeta=0.0in 1.15.0), so differential-test one batch and record every default you rely on. - LLM Post-Training Laboratory - Online RLRoadmap-Final · required
Complete one PPO-style, RLOO or verifiable group-relative update with immutable rollouts, fixed tests, bounded queues, SFT and direct-preference controls, reward-hacking probes and all failed or filtered samples retained.
Also in this section
- RLHF Book - Policy Gradients and RegularizationNathan Lambert · primary
Study Chapter 6 completely (REINFORCE, RLOO, PPO, GRPO, GSPO, CISPO, loss aggregation, asynchronous systems, truncated importance sampling) and Chapter 15 on KL and regularization. Implement REINFORCE, PPO-style, RLOO and GRPO fixed-rollout losses from the chapter equations, then verify masks, ratios, group baselines and one-gradient-step simplifications.
- RLHF Book Course - Lectures 3 and 4Nathan Lambert · required
Use Lecture 3 (RL motivation and math, Chapter 6 part 1) and Lecture 4 (RL implementation and practice, Chapter 6 part 2: loss aggregation, asynchronous training). Reproduce the loss on a tiny frozen rollout before using any trainer library.
- Back to Basics: REINFORCE Style Optimization for Learning from Human FeedbackAhmadian et al. · required
Study the RLOO estimator, baseline construction and system simplifications. Compare RLOO with a value-baseline or grouped estimator under matched completions and reward calls.
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - LLM RL Lecture and Homework 4UC Berkeley · required
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 Lecture 14 (LLM RL) and the Homework 4 handout: log probabilities, minibatching, advantage normalization, GR-REINFORCE and GRPO on a format task and a math task, plus a GRPO hyperparameter study. It is configured for H100 GPUs on Modal (about 8 GPU hours), so port the code paths to a tiny model on your GPU or run them on pre-generated rollouts.
- DAPO: An Open-Source LLM Reinforcement Learning System at ScaleYu et al. (2025) · support
Read Sections 2 and 3: decoupled clipping bounds, dynamic sampling that drops all-equal groups, the token-level loss and overlong reward shaping, and the removal of the KL term. Compare its token-level aggregation with GRPO's per-sequence mean on a fixed group.
- Understanding R1-Zero-Like Training: A Critical Perspective (Dr. GRPO)Liu et al. (COLM 2025) · support
Read Section 3: the response-length bias of per-sequence normalization and the question-difficulty bias of dividing by the group standard deviation. DAPO keeps the standard deviation that Dr. GRPO removes, so treat the choice as open and test both on a fixed group.
- Build a Reasoning Model (From Scratch) - Chapters 6 and 7Sebastian Raschka (Manning) · support
Use Chapter 6 (rollouts, rewards, group advantages, sequence log probabilities and the GRPO loss on Qwen3 0.6B) and Chapter 7 (metrics, clipped ratios, the KL term and a format reward) as the smallest runnable GRPO loop. Listing 6.13 is the unclipped loss; the clipped and KL versions come in Chapter 7. Its advantages use the unbiased
torch.std. - TensorTonic - GRPO ProblemsTensorTonic · support
Solve Normalize GRPO Group Advantages (
cs336-l16-grpo-group-advantages), Compute a Clipped GRPO Surrogate (cs336-l16-clipped-grpo-surrogate) and Compare Sequence and Token Length Normalization (cs336-l16-grpo-length-normalization-audit), free problems in the Language Modeling from Scratch plan, as closed-book checks after your own estimator passes. - Hands-on Modern RL - Chapter 15 GRPO and RLVRWalking Labs · support
Use the GRPO practice and mechanism page and the RLVR page: its group-normalization demo and rule-based reward script run on CPU in seconds. Its TRL examples pin TRL 0.24, whose defaults differ from current releases. Run only a small verifier task and preserve zero-variance, length-hacking and invalid-output cases. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its
code/chapterNNfolders do not follow the site chapter numbers. - RLHF Book Code - Policy GradientsNathan Lambert · support
Use the
code/policy_gradientspackage at natolambert/rlhf-book at commit 1042143 as a differential reference after the hand implementation passes (loss.pyholds the masked means, the GRPO and PPO losses and the , , KL estimators). Trace every tensor to prompt, completion and policy version and extend the tests with stale-log-prob and mask defects.