Maps to: UC Berkeley EE 290/194 Scalable AI, Fall 2026 Lecture 14, Reasoning Models (slides
lecture14.pdf), §3 “RL at scale is an inference problem”; Spring 2026 Lecture 16, Case Study: Post-Training of Nemotron Nano v3 and NeMo RL (guest lecture, NVIDIA; second part, NeMo RL: Efficient Reinforcement Learning from single to thousands of GPUs, by Gerald Shen and contributors; slideslecture_16_2.pdf). The Fall 2026 offering’s Lecture 16 covers RL systems; its slides were not public when these notes were written. Recommended reading:
- Asynchrony and the long tail: Kimi Team, Kimi k1.5 §2.6 (partial rollouts, arXiv:2501.12599); Kimi K2 §3.3 (checkpoint engine, arXiv:2507.20534); Fu et al., AReaL (asynchronous RL, arXiv:2505.24298); Seer (rollout long tails, arXiv:2511.14617).
- Engine–trainer mismatch: MiniMax, MiniMax-M1 (FP32 output layer, arXiv:2506.13585); Yao et al., Your Efficient RL Framework Secretly Brings You Off-Policy RL Training (TIS, blog 2025); He et al., Defeating Nondeterminism in LLM Inference (Thinking Machines, 2025).
- Frontier systems reports: GLM-4.5 (arXiv:2508.06471); GLM-5 (arXiv:2602.15763); DeepSeek-V3.2 (arXiv:2512.02556); DeepSeek-V4 (arXiv:2606.19348); Kimi K3 (arXiv:2607.24653).
- Frameworks: NeMo RL and NeMo Gym (github.com/NVIDIA-NeMo/RL, github.com/NVIDIA-NeMo/Gym); verl (github.com/volcengine/verl). Code:
code/lecture19/contains:rl_sim.py: a simulator of the generation side of an RL step;- four demos: step anatomy, staleness, engine mismatch, Gym-style servers and sandboxes.
Reading time: ~2 hours for the prose; ~1 minute to run all demos.
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Draw one RL step as two systems, a serving system that generates and a training system that updates, and say where each problem of RL at scale sits in that loop.
- Explain the long tail: why the slowest response sets a synchronous step’s time, and what generation budgets, partial rollouts, separate GPU pools and asynchronous training change.
- Reason about staleness: what samples from older weights do to the gradient, why a staleness bound biases training toward short answers, and how AReaL’s decoupled objective handles it.
- Diagnose engine–trainer mismatch: why two engines computing “the same” model disagree, which disagreements matter, and the fixes (FP32 output layer, batch-invariant kernels, the same sampler mask, TIS and IcePop).
- Describe agent RL infrastructure: sandboxes as a second serving system, and NeMo Gym’s agent / model / resource servers with NeMo RL as the controller.
0.2 Prerequisites and scope
- Prerequisites:
- Lecture 18: the policy gradient, importance ratios, the clip;
- Lectures 5–7: collectives, parallelism;
- Lecture 14: running a fleet;
- decode is memory-bound: Lecture 2’s roofline, which Lecture 22 develops.
- Scope: the systems side of RL post-training: generation, asynchrony, numerics, environments.
- Not in scope: the RL objective itself (Lecture 18); inference engines in depth (Lectures 22–23).
0.3 Section → code map
| Section | Idea | Code in code/lecture19/ |
|---|---|---|
| §1 | RL compute and the loop | – |
| §2–§3 | the long tail, layouts, asynchrony, staleness | rl_sim.py, 01_rl_step_anatomy.py, 02_staleness.py |
| §4 | engine–trainer mismatch, nondeterminism | 03_engine_mismatch.py |
| §5 | sandboxes, NeMo Gym, NeMo RL | 04_gym_and_sandboxes.py |
0.4 What is modelled and what is measured
rl_sim.py is a model of decoding, with stated assumptions:
- log-normal response lengths, median 2,000 tokens, capped at 32K;
- engines of 8 GPUs with 128 sequence slots;
- 20 ms per decode iteration however many sequences are active;
- training at 9 × 10⁻⁵ GPU-seconds per token, an estimate for a 30B-A3B-class model at 40% MFU.
Its numbers show mechanisms and relative sizes, not a real cluster’s seconds. Demos 02–03 run real learning on Lecture 18’s exact toy, and real numerics on Lecture 17’s student model and this CPU’s kernels.
1. RL compute is approaching pre-training compute
What labs have said about RL compute:
| report | RL or post-training compute |
|---|---|
| DeepSeek-R1 (Jan 2025) | RL about 5% of pre-training |
| Grok 4 (Jul 2025) | RL “at pre-training scale” |
| DeepSeek-V3.2 (Dec 2025) | post-training above 10% of pre-training |
| Composer 1.5 (Feb 2026) | post-training above pre-training |
Epoch AI’s early-2025 projection had reasoning-RL compute meeting the pre-training frontier around 2026. Most of that compute is inference. In Moonshot’s production runs, including Kimi K2’s, generating rollouts took 63% to 87% of each RL iteration. At that share, inference efficiency becomes a large part of training cost.
One RL step runs a serving system and a training system:
prompts → inference engine → responses → verifier / sandbox → rewards → trainer → new weights ─┐
(generates rollouts) (scores each one) (updates) │
↑ both compute each token's probability; the two engines disagree │
└──────────────────────────────── weight sync ────────────────────────────────────┘
The inference engine (vLLM, SGLang) and the trainer (Megatron-Core, FSDP) are separate software, often on separate GPUs. Each section below is a problem at one place in this loop:
- the long tail, at the inference engine (§2);
- staleness, at the weight sync (§3);
- disagreement, between the two engines (§4);
- sandboxes, at the verifier (§5).
2. The longest rollout sets the step time
2.1 Why the tail is so expensive
Response lengths in a batch vary by more than ten times. A synchronous step ends only when the slowest response does, and decoding is memory-bound: an engine’s decode iteration costs about the same with 2 sequences in flight as with 128 (Lecture 2’s roofline; Lecture 22). So while the last long responses finish, every GPU runs almost empty. Demo 01 Part A simulates one synchronous, colocated step: 128 prompts × 16 rollouts on 128 GPUs.
| quantity | value |
|---|---|
| response length: median / p90 / max | 1,981 / 6,694 / 32,768 tokens |
| decode slots in use, averaged over generation | 9.4% |
| generation time after 90% of responses finished | 79.6% |
| responses per GPU-hour | 86 |
Moonshot saw the last 10% of requests take up to half of the rollout time. Our tail is longer, because the model has no prefill or memory limits. Part B shows the spread of lengths sets the waste:
| log-normal σ | longest / median | slot occupancy | responses per GPU-hour |
|---|---|---|---|
| 0.3 | 2.9 | 36.0% | 451 |
| 0.6 | 8.6 | 14.2% | 163 |
| 0.9 | 16.5 | 9.4% | 86 |
2.2 A generation budget: partial rollouts
Kimi k1.5 caps each step’s generation budget. Responses that hit the cap are saved and continued in the next step, so a step no longer waits for the longest response. A continued response is then written by more than one version of the weights: the staleness problem of §3. DeepSeek-V4 likewise resumes interrupted responses instead of restarting them.
2.3 Shared GPUs or separate pools
| layout | how it works | strength | cost |
|---|---|---|---|
| colocated (shared GPUs) | all GPUs generate, switch, then all GPUs train | no pool sits idle while the other works; for the same GPU count it can train a bigger model (more GPUs for FSDP) | every step pays to swap memory between the two systems: the inference engine holds NCCL buffers, CUDA graphs and KV cache that must be offloaded before training; poor utilisation with a long tail; inference and training cannot be scaled independently |
| disaggregated (separate pools) | inference GPUs and training GPUs run at once | usually 2–3× faster when paired with asynchrony (NeMo RL’s experience); better for large jobs | new weights must move from the trainer’s layout to the inference engine’s after every update; part of a batch can come from weights one update old |
NeMo RL, in the guest lecture, finds colocated layouts more suitable for fully synchronous RL. Nemotron 3 Nano was trained with colocated, fully on-policy RL (Lecture 20). The weight move is fast but not free: Kimi’s checkpoint engine updates all 1T parameters of K2 in under 30 seconds. GLM-4.5 shares GPUs for reasoning RL and splits them for agent RL, where rollouts are slow.
2.4 What each layout buys (Demo 01 Part C)
On the same 128 GPUs:
| layout | responses per GPU-hour | responses written by >1 version | mean staleness |
|---|---|---|---|
| synchronous, colocated | 86 | 0% | 0 |
| synchronous, separate pools (64 + 64) | 81 | 0% | 0 |
| generation budget 240 s (partial rollouts) | 228 | 2.1% | – |
| generation budget 120 s (partial rollouts) | 431 | 10.6% | – |
| asynchronous, in-flight weight updates (64 + 64) | 482 | 42.3% | 0.58 (max 6) |
- Separating the pools does not help a synchronous step: one pool waits for the other.
- What helps is not waiting for the tail. A budget gives 5×, and full asynchrony 5.6×.
- The price is mixed versions and stale samples.
2.5 Routing: balancing, and faster engines for the long requests
NeMo RL’s guest lecture lists two remedies for the tail:
- dynamic load balancing: queue new requests on engines with less work, and move requests from busy engines to empty ones;
- heterogeneous inference workers: some engines at high tensor parallelism (TP8: better latency) and others at low (TP2: better throughput), with long requests moved to the latency-optimised ones.
Demo 01 Part E puts 2,048 responses on 4 engines × 128 slots:
| assignment | generation time |
|---|---|
| even static split | 799 s |
| dynamic (next request to the first free slot) | 799 s |
| longest 2% to one engine with 2.5× faster decoding | 505 s |
Balancing changed nothing here. The step waits for one 32K-token response, and no scheduler makes a single sequence decode faster. Balancing helps when work is unevenly spread across engines. A tail of single long sequences needs faster engines, and the long requests must be recognised early (our routing used the true lengths, an upper bound). Serving optimisations moved into the rollout engine for the same reason:
- multi-token prediction for speculative decoding: GLM-5 (Lecture 21);
- prefill split from decode: GLM-5;
- shared computation for common multi-turn prefixes: MiniMax, about 40× from tree-structured prefix merging plus asynchronous scheduling.
2.6 Low precision for rollouts
Rollouts can run at serving precision to shorten the tail:
| rollout precision | used by |
|---|---|
| BF16 | the usual training precision |
| FP8 | GLM-4.5 and GLM-5 |
| INT4 / FP4 | Kimi K2 Thinking (INT4), DeepSeek-V4 (FP4), Kimi K3 (MXFP4) |
Kimi K2 Thinking and K3 also train at the rollout’s precision (quantisation-aware training) to keep the two close. The cost is §4’s: an FP8 rollout engine and a BF16 trainer no longer compute the same probabilities.
3. Asynchrony and staleness
3.1 N-step off-policy and in-flight weight updates
If the algorithm can tolerate staleness, generation can run ahead of training. NeMo RL’s terms for this:
- N-step off: the generators have N batches of lead time. Generation no longer blocks training, but the larger N, the more off-policy the training.
- In-flight weight update: new weights are loaded into the engines without waiting for in-progress responses, so one response is written by several versions.
3.2 Staleness falls on the long responses (Demo 01 Part D)
Short responses finish first, so a naive asynchronous batch is biased toward short answers, and the long responses arrive stale:
| max staleness (drop older) | dropped | mean staleness: shortest 90% / longest 10% | mean trained length |
|---|---|---|---|
| none | 0.0% | 0.45 / 1.82 | 2,976 |
| 4 | 0.2% | 0.44 / 1.74 | 2,920 |
| 2 | 1.5% | 0.43 / 1.47 | 2,733 |
| 1 | 6.0% | 0.39 / 0.98 | 2,390 |
A staleness bound drops long responses and shifts what the trainer sees toward short ones. That is why AReaL bounds staleness and corrects the objective, and why Kimi and DeepSeek-V4 resume responses rather than discard them.
3.3 What stale samples do to the gradient, and where to anchor the clip (Demo 02)
Along a real training run on Lecture 18’s toy, the expected update from samples k updates old, compared with the exact gradient at the current weights:
| staleness k | KL(current ‖ behaviour) | cosine, no correction | cosine, importance-weighted |
|---|---|---|---|
| 4 | 0.006 | 0.998 | 1.000 |
| 16 | 0.077 | 0.981 | 1.000 |
| 32 | 0.272 | 0.954 | 1.000 |
The bias is small here, and the importance weight removes it in expectation. Where the PPO clip is anchored matters more. Training with stale batches, 4 updates per batch, accuracy after 25 steps (mean of 3 seeds):
| staleness | clip vs logged behaviour log-probs | recompute π_old now (staleness ignored) | decoupled (AReaL) |
|---|---|---|---|
| 0 | 91.9% | 91.9% | 91.9% |
| 8 | 75.7% | 91.8% | 92.0% |
| 16 | 64.8% | 89.9% | 89.8% |
- Anchored at the stale weights, the clip fires early and stops learning. Standard PPO with the logged log-probs measures the ratio against the behaviour policy.
- AReaL’s decoupled objective fixes it. It weights each sample by how far the policy that generated it is from a recent one, and clips against that recent policy.
- Ignoring staleness also worked in this toy, because with an exact checker even old samples point uphill. AReaL found the plain objective erratic on a real 1.5B model: 23.3 on AIME 2024 at staleness 4, against 42.0 for synchronous training, while the corrected objective stayed near 42 up to ~8 versions. The toy shows the mechanism of the clip, not how fragile a large model’s run is.
4. The inference engine and the trainer disagree
4.1 The fourth policy
Lecture 18 §2.4 listed three policies in one update. At scale there is a fourth: the inference engine’s copy of π_old. Inference engines use different kernels, batch shapes and often lower precision than the trainer, so the same token gets a slightly different probability in each. Training that is nominally on-policy is slightly off-policy, and the errors accumulate over thousands of tokens.
MiniMax traced its mismatch to the output layer. Computing it in FP32 raised the correlation between trainer and engine probabilities from 0.987 to 0.997, and only then did reward rise; ScaleRL found the same change raised the final score from 0.52 to 0.61. NeMo RL tracks this as a log-prob error metric and treats it as a bug detector: it caught, among others, a tied-embeddings bug. The guest lecture’s rule of thumb is to keep it under 1.05. A full fix needs batch-invariant kernels, which cost speed.
4.2 Measured on a real model (Demo 03 Parts A–B)
Lecture 17’s student, trained for 600 steps, is scored on 1,000 responses by an FP32 “trainer” and a BF16-autocast “engine”:
| engine | correlation of p | mean |Δ log p| | mean exp(|Δ log p|) | uncertain tokens (p < 0.5) | confident tokens |
|---|---|---|---|---|---|
| BF16 (output layer in BF16) | 0.999907 | 1.9e-3 | 1.0019 | 1.65e-2 | 8.4e-4 |
| BF16, output layer in FP32 | 0.999925 | 1.2e-3 | 1.0012 | 9.4e-3 | 6.5e-4 |
- The FP32 output layer removes a third of the mismatch, and almost half of it on uncertain tokens.
- The mismatch sits on the uncertain tokens, 20× larger than on confident ones.
- It adds up over a response. Drawing the measured per-token values independently, the spread of the summed log-ratio grows like , and its small bias (BF16 rounds one way slightly more often) grows like . Over 10,000 tokens the whole-response ratio ranges 0.98–11.2 (5%–95%).
Long chains of thought therefore need per-token ratios and caps, not sequence ratios (Lecture 18 §3.8).
4.3 Nondeterminism can collapse a run
The first approach is to make the two engines agree:
- GLM-5 hit an indexer bug. A nondeterministic top-k in its sparse-attention indexer picked different keys at rollout and in training, and entropy dropped sharply within a few RL steps. A deterministic top-k and a frozen indexer fixed it.
- Thinking Machines showed that batch-invariant kernels make the two engines match exactly, so RL becomes truly on-policy.
- DeepSeek-V4 made its kernels give bitwise-identical results regardless of batch size, from pre-training through serving.
- DeepSeek-V3.2 reapplies the sampler’s top-p mask during training, so both sides consider the same set of tokens.
Demo 03 Part D measures both sources on this CPU:
- Kernels are not batch-invariant. The same 64 rows through one linear layer give different results in the last bits when computed as a batch vs one at a time: 0 of 64 rows bitwise equal, largest difference 4 × 10⁻⁶.
- Ties make tiny differences matter. A 10⁻⁶ perturbation changes the top-16 selection of 0.00% of queries with FP32 scores, but 5.4% once scores are rounded to BF16 and ties are common: exactly the GLM-5 failure mode.
4.4 Correcting what disagreement remains
The second approach handles the residual in the loss. Two families exist:
| method | what it does | used by |
|---|---|---|
| TIS (truncated importance sampling) | caps the ratio at C | TIS, OLMo 3, ScaleRL, MiniMax |
| IcePop / masked IS | zeros tokens whose ratio falls outside a band | Ant’s Ring-1T, GLM-5, Kimi K2.5 |
Nemotron 3 Nano’s synchronous GRPO uses masked importance sampling (Lecture 20). DeepSeek-V3.2 masks whole sequences that drifted and had negative advantage. GSPO’s sequence ratio (Lecture 18) also absorbs mismatch.
Demo 03 Part C asks which mismatches matter, on the exact toy with 4 updates per batch:
| engine | correction | accuracy (full sampling) | accuracy (engine’s sampler) | mean exp(|Δ log p|) |
|---|---|---|---|---|
| same numerics | none | 99.6% | 99.6% | 1.000 |
| logits rounded to 2 mantissa bits | none / TIS / IcePop | 99.5% / 99.5% / 99.5% | 99.5% / 99.4% / 99.5% | 1.018 |
| top-p 0.9 sampler, unknown to the trainer | none / TIS / IcePop | 90.1% / 89.8% / 90.1% | 100% | 1.060 |
| top-p 0.9 sampler | same mask in training | 88.9% | 100% | 1.000 |
- Noise averages out. Even coarse rounding barely changes the result.
- A systematic difference does not. Tokens outside the nucleus are never sampled, so training never pushes them down. The policy is fine under the engine’s own sampler, but served with full sampling it is 90%. The trainer’s probabilities are also systematically lower than the engine’s renormalised ones (1.060, above the rule of thumb), so every ratio-based correction sees a fake mismatch.
- The shared mask fixes the ratios, not the accuracy. It brought the metric to 1.000 and did not change accuracy under the engine’s sampler. What it buys is ratios that mean what they say.
Train and serve with the same sampler.
4.5 What recent reports changed, at each place in the loop
| place in the loop | changes |
|---|---|
| the inference engine | partial rollouts; low precision; speculative decoding |
| between engine and trainer | FP32 output layer; deterministic kernels; masking in the loss |
| the weight sync | bounded staleness; a corrected objective; fast weight sync |
| the sandbox | fast start; checkpoint and resume; memory overcommit |
5. Agent RL: sandboxes and environments as servers
5.1 Sandboxes are a second serving system
Every agent task needs its own environment: a container image, the task, and a checker that grades the result. The reports give the scale:
- DeepSeek-V3.2 and GLM-5 each built thousands of them;
- Kimi K3 launched 51 million sandboxes from 1.5 million images.
A sandbox mostly waits. In Kimi K3, waiting on the model took up to 98% of a sandbox’s lifetime. Demo 04 Part C computes a 30-turn task with 20 s of generation and 0.4 s of tools per turn:
| sandbox start-up | lifetime | waiting for the model | starting up |
|---|---|---|---|
| 30 s | 642 s | 93.5% | 4.7% |
| 5 s | 617 s | 97.2% | 0.8% |
| 0.5 s | 612 s | 98.0% | 0.1% |
With 128 tasks × 16 rollouts in flight, 2,048 sandboxes are alive at once: 4.1 TB of memory at 2 GB each, of which ~80 GB is used by running tools at any moment. The costs that matter are those of a serving system, running alongside the inference engine:
- start-up time;
- memory held while idle, hence memory overcommit;
- checkpointing, so a long task can resume.
5.2 NeMo Gym: three kinds of server
The Nemotron 3 Nano report describes NeMo Gym as “based on the abstraction of servers”:
- an agent server implements the rollout loop of an environment, orchestrating the tool and reward calls;
- a model server wraps an inference engine (vLLM) behind a prompt–response API, and preserves the token ids and inference log-probs that RL needs;
- a resource server provides the tools and a verification API that computes the reward from a rollout.
Environments are ready to use and grow by community contribution:
| domain | environment | target |
|---|---|---|
| instruction following | IFEval / IFBench-style constraints | IFEval, IFBench |
| coding | Mini SWE Agent; competitive programming with unit tests | SWE-bench, LiveCodeBench |
| tool use | Workplace Assistant (multi-step) | multi-step tool calling |
| knowledge | equivalence LLM judge for short answers; MCQ with Google search | GPQA, HLE |
| math | math-verify plus an LLM judge | AIME 24/25 |
Demo 04 implements the three servers as Python classes around Lecture 17’s calendar task. One rollout record carries:
- the task, tool calls and observations (filled by the agent), used for replay, debugging and distillation;
- the token ids, log-probs and policy version (filled by the model server), used for importance ratios, staleness limits and mismatch checks;
- the reward (filled by the resource server), used for the advantage.
GRPO through the interface learns what the verifier rewards. After 60 steps: 46% on “check calendars, then book”, 52% on “try hours, recover from errors” (both always succeed), 1% on merely claiming success. The trainer never sees the tools, only records, which is what lets one RL loop train on many environments at once.
5.3 NeMo RL: the controller
NeMo RL is the training-loop controller. It routes rollout collection through NeMo Gym, uses Megatron-Core for training (TP, PP, CP, EP, DP; FP8 or BF16) and vLLM for generation. Between them sits Megatron-Bridge, a bidirectional, parallelism-aware, streaming converter between Hugging Face and Megatron formats. It converts parameter by parameter across many GPUs, so neither model has to be loaded whole on one GPU, and it is what moves the new weights to the inference engine.
Orchestration uses Ray, an abstraction on top of Slurm or Kubernetes (Lecture 14), in the single-controller pattern:
- a driver gives instructions to worker groups: training, inference, environments;
- each group is a set of SPMD workers that the controller shards data across and collects results from;
- uv gives each environment its own isolated Python environment, propagated to Ray workers, so environments with conflicting dependencies coexist.
The same command runs on one node and on many.
6. Summary
-
RL compute now rivals pre-training at some labs, and most of it is inference. One step is a serving system plus a training system, and each scaling problem sits at one place in the loop.
-
The longest response sets a synchronous step’s time. Decoding is memory-bound, so the tail runs nearly empty engines: 9% slot occupancy in our model. Separate pools alone do not help. Not waiting does:
- generation budgets with partial rollouts (5× here);
- fully asynchronous generation with in-flight weight updates (5.6×).
Balancing cannot speed up one long sequence; faster engines for long requests can.
-
Asynchrony makes samples stale, and staleness falls on the long responses. Bounding it biases training toward short answers. Anchoring the clip at stale weights stops learning; AReaL’s decoupled objective (clip against a recent policy, weight by recent/behaviour) keeps it going.
-
The inference engine and the trainer disagree, most on uncertain tokens, and the disagreement adds up over long responses.
- Noise averages out; systematic differences do not: an FP32-vs-BF16 output layer, a sampler mask, nondeterministic top-k.
- Remove them at the source (FP32 head, batch-invariant kernels, the same mask), and correct the rest in the loss (TIS, IcePop).
-
Agent RL adds sandboxes, a second serving system that mostly waits. NeMo Gym separates agents, models and verifiers behind server interfaces, and NeMo RL drives training (Megatron-Core) and generation (vLLM) through a Ray single controller.
7. Common pitfalls
- Benchmarking RL throughput on batches of equal-length responses.
- Separating pools without making the step asynchronous.
- A staleness bound without checking what it drops.
- PPO’s old log-probs taken from a stale behaviour policy without a decoupled objective.
- Not logging the engine’s log-probs next to the trainer’s; no mismatch metric on the dashboard.
- A different sampler (top-p, temperature) in rollouts than the trainer assumes, or than serving uses.
- Low-precision output layers in the rollout engine.
- Nondeterministic top-k or reductions in either engine.
- Holding a full sandbox per rollout without overcommit or fast start.
- Environments wired into the trainer instead of behind an interface.
8. Exercises
- The tail. A batch has 2,047 responses of 2,000 tokens and one of 30,000; one engine with enough slots for all of them, 20 ms per decode iteration. How long is generation, and what is the average slot occupancy? What if the long response is moved to an engine 2.5× faster?
Answer
Generation: 30,000 × 0.02 = 600 s. Slot-seconds used: 2,047 × 40 + 600 = 82,480 out of 2,048 × 600 = 1,228,800: 6.7% occupancy. On the fast engine the long response takes 240 s, so the step’s generation time drops to 240 s (the short ones finish in 40 s).
- Staleness bias. In an asynchronous system, a response’s staleness is roughly (its generation time) / (time per training step). With training steps every 60 s, a 2,000-token response at 20 ms/token and a 20,000-token one: what staleness does each have? With a bound of 2, which is kept?
Answer
40 s → staleness 0 or 1; 400 s → about 6–7. With a bound of 2 the long one is dropped, which is the bias toward short answers.
- Accumulated mismatch. Per-token log-ratios between engine and trainer have mean 1e-4 and standard deviation 7e-3, independently. Over a 10,000-token response, what are the mean and standard deviation of the sequence’s log-ratio? Why does this argue against full sequence ratios?
Answer
Mean 10,000 × 1e-4 = 1.0; std 7e-3 × √10,000 = 0.7. So the sequence ratio is typically e^{1.0 ± 0.7}, i.e. 1.3–5.5, while every token’s ratio is within ~1% of 1. A sequence-level importance weight would be dominated by accumulated noise and bias. Per-token ratios, GSPO’s geometric mean, or caps avoid it.
- Sampler mismatch. The rollout engine samples with top-p 0.9; the trainer computes probabilities with the full softmax. For a token inside the nucleus with full-softmax probability 0.3, where the nucleus holds 90% of the mass, what are π_train and π_rollout? What does a TIS weight do to it?
Answer
π_train = 0.3; π_rollout = 0.3 / 0.9 = 0.333. The ratio is 0.9, so TIS multiplies that token’s gradient by 0.9: every sampled token is down-weighted by the same “fake” mismatch. Applying the same mask in training makes the ratio 1.
- Sandbox memory. 4,096 agent rollouts are in flight; each sandbox holds 4 GB but uses it only while a tool runs (2% of its life). How much memory is reserved, and how much is in use on average? What does that suggest?
Answer
Reserved 16.4 TB; in use ~330 GB on average. Memory overcommit (and checkpoint/suspend of idle sandboxes) can serve the same rollouts with far less memory, which is the serving-system view of sandboxes.
9. The related assignment (concepts only)
The post-training assignment’s RL stage runs on one 8×H100 node, usually colocated and synchronous. This lecture’s lessons:
- measure how much of each step is generation;
- watch the response-length distribution and its maximum;
- log the engine’s log-probs and track a mismatch metric;
- keep the rollout sampler settings identical to what the trainer assumes.
No solutions are given here.
10. Research directions
- Rollout systems for long tails: predicting response length early; migrating sequences between engines; speculative decoding inside RL without bias.
- Off-policy corrections at high staleness: how far asynchrony can go without accuracy loss (an open question in the guest lecture).
- Deterministic, fast kernels: closing the speed gap of batch-invariant inference.
- Sandbox infrastructure: checkpoint and resume, overcommit, start-up at millions of environments.
- Environment portfolios: scaling beyond the 8–20 environments of current open recipes.
11. Further reading
- Kimi k1.5 (arXiv:2501.12599); Kimi K2 (arXiv:2507.20534); Kimi K3 (arXiv:2607.24653); Seer (arXiv:2511.14617).
- AReaL (arXiv:2505.24298); GLM-4.5 (arXiv:2508.06471); GLM-5 (arXiv:2602.15763).
- MiniMax-M1 (arXiv:2506.13585); ScaleRL (arXiv:2510.13786); Yao et al., TIS (2025); Ring-1T / IcePop (arXiv:2510.18855); OLMo 3 (arXiv:2512.13961).
- He et al., Defeating Nondeterminism in LLM Inference (Thinking Machines, 2025); DeepSeek-V3.2 (arXiv:2512.02556); DeepSeek-V4 (arXiv:2606.19348).
- NeMo RL, NeMo Gym, Megatron-Bridge, Megatron-LM (github.com/NVIDIA-NeMo, github.com/NVIDIA/Megatron-LM); verl; Ray.
12. Next lecture
Lecture 20 · Case Study: Post-Training Nemotron 3 Nano. Lectures 16–19 gave the formats, the data, the algorithms and the systems. Lecture 20 follows one real post-training run through all of them:
- the chat template and the SFT data factory;
- multi-environment RLVR with a curriculum;
- GenRM-based RLHF with length control;
- DPO against tool hallucination;
- FP8 quantization and the final evaluation.
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| rollout / inference engine / trainer | 推演 / 推理引擎 / 训练器 |
| long tail / slot occupancy / memory-bound decode | 长尾 / 槽位占用率 / 受内存带宽限制的解码 |
| synchronous / asynchronous RL | 同步 / 异步强化学习 |
| colocated / disaggregated | 共置 / 分离部署 |
| generation budget / partial rollout | 生成预算 / 部分推演 |
| N-step off-policy / in-flight weight update | N 步异策略 / 生成中权重更新 |
| staleness / staleness bound / decoupled objective | 陈旧度 / 陈旧度上限 / 解耦目标 |
| weight sync / checkpoint engine | 权重同步 / 检查点引擎 |
| dynamic load balancing / heterogeneous workers | 动态负载均衡 / 异构推理实例 |
| train–inference mismatch / logprob error | 训练-推理不一致 / 对数概率误差 |
| FP32 output layer (LM head) | FP32 输出层 |
| batch-invariant kernel / nondeterminism | 批次不变内核 / 非确定性 |
| truncated importance sampling (TIS) / IcePop (masked IS) | 截断重要性采样 / 掩码重要性采样 |
| top-p mask / nucleus | top-p 掩码 / 核采样集合 |
| sandbox / start-up / memory overcommit / checkpoint and resume | 沙箱 / 启动 / 内存超售 / 断点续跑 |
| agent server / model server / resource server | 智能体服务器 / 模型服务器 / 资源服务器 |
| single controller / SPMD workers | 单控制器 / SPMD 工作进程 |