Systems & Infrastructure
RL & Post-Training Infrastructure
AdvancedPost-training used to be a short coda to pre-training. Now reinforcement learning, agent environments and distillation take a real share of a frontier model's compute, and they load a cluster differently: part inference engine, part trainer, plus thousands of sandboxes. This page covers how it runs at scale.
Why post-training became an infrastructure problem
For DeepSeek-V3.2, the RL budget alone was more than 10% of the pre-training cost. The ScaleRL study of how RL scales spent more than 400,000 GPU-hours, including a single run of 100,000 GPU-hours. MiniMax ran full RL for MiniMax-M1 on 512 H800 GPUs for about three weeks, at a rental cost of $534,700. At that size, post-training is a cluster workload with its own bottlenecks. A spare node won't do.
RL compute, DeepSeek-V3.2
>10%
of the pre-training cost
One RL scaling study
400K+
GPU-hours (ScaleRL)
GPUs generating
64 of 80
in one ScaleRL run on GB200
OPD vs RL compute
~10x less
Qwen3, for a higher score
The 2026 recipe in three stages
The open reports from DeepSeek, NVIDIA and Zhipu all describe the same shape. The classic then sequence on the Training & Fine-tuning page is still there, but the RL part has split into specialists and a merge step.
STAGE 1
Specialists
Separate expert models for math, code, agents, search, chat and more. Each starts from a shared base and is trained with SFT, then RL.
STAGE 2
RLVR & agentic RL
RL with verifiable rewards (tests pass, answer matches) plus long multi-turn agent tasks run in sandboxes with real tools.
STAGE 3
On-policy distillation
One student model learns from the specialist teachers on its own samples, merging their skills into a single model.
DeepSeek-V3.2 shows the scale of the inputs: its agentic RL used more than 1,800 synthesized environments and 85,000 complex prompts, with real web search APIs, coding tools and Jupyter notebooks as tools.
The RL loop: generate, score, update, sync
Every RL post-training system runs the same loop. The policy generates answers (rollouts), something scores them, the trainer updates the policy toward the better answers, and the new weights go back to the generators. Unlike pre-training, generation here is pure inference, so an RL cluster is part serving engine ( or ) and part trainer. The Hugging Face survey of 16 open-source RL libraries found that every one of them runs inference and training on separate GPUs, joined by a rollout buffer and asynchronous weight transfer.
One RL step, station by station
Click a station or use play. Each pass around the loop is one training step, and large runs do thousands.
after Sync, the loop starts again at Prompts with the new weights
1. Pick prompts and environments
A batch of tasks is drawn from a pool: math problems with known answers, coding tasks with unit tests, or agentic tasks that need a sandbox with tools. Many recipes filter out prompts the model always or never solves, because they carry no learning signal.
- Busy hardware
- CPU / data loader
- What moves
- Prompt IDs, environment configs
Synchronous vs asynchronous RL
In synchronous RL, each step waits for every rollout to finish, then the generators wait for training. The problem is the long tail: one very long reasoning trace holds up a batch of short ones, and at scale that straggler effect can idle hundreds of GPUs. Asynchronous RL lets generators run ahead into a buffer while the trainer consumes finished rollouts. The price is staleness: some rollouts come from a policy a step or two old.
Three generators, one trainer, the same rollouts
Illustrative durationsEach orange block is one rollout, labeled with the weight version it was generated with (v0, v1 and so on). A training step needs 3 finished rollouts. Rollout lengths are identical in every mode. Only the scheduling changes.
Schedule
Train steps done
3
in 20 time units
Generators busy
47%
share of generator time
Trainer busy
24%
share of trainer time
Max staleness
0 ver.
always on-policy
Synchronous: every generator waits for the slowest rollout in the batch, then sits idle through training and the weight sync. Training data always comes from the current policy, but much of the cluster spends the step waiting.
How libraries keep staleness in check
| Approach | What it does | Examples |
|---|---|---|
| Cap the age | Drop or hold back rollouts more than N policy versions old | NeMo RL max_trajectory_age_steps, SkyRL max_staleness_steps, PRIME-RL max_off_policy_steps, TorchForge max_policy_age |
| Correct for it | Reweight tokens by how likely the current policy is to produce them (importance sampling), with a cap | slime and verl use truncated importance sampling; AReaL caps the weight at 5.0 |
| Limit the queue | A shallow rollout buffer can only hold so many old samples | Tunix and verifiers-rl |
The survey sees a trend toward hybrids: a depth bound plus optional importance-sampling correction. In production the bound is tight. Nemotron 3 Ultra ran one-step off-policy RL, and the ScaleRL recipe allows 8 steps of off-policyness with PipelineRL, which mainly bought compute efficiency. It didn't raise the final score much. When a sync lands mid-rollout, libraries differ: PipelineRL swaps weights between forward passes without interrupting sequences, SkyRL and slime abort and resume from the generated prefix, verl saves partial tokens and resumes after the sync, and AReaL lets in-flight sequences finish first.
Why rollouts dominate step time
Generation is -bound: tokens come out one at a time, and reasoning rollouts run to tens of thousands of tokens. The for all those long sequences also caps how many fit on a GPU at once (see the KV Cache page). Training on the same tokens is one parallel forward and backward pass. So one ScaleRL run on 80 GB200 GPUs gave 64 to generation and only 16 to training.
How long does one step's generation take?
EstimateUses the per-H100 throughputs from the Hugging Face survey (about 6,300 tokens/s for a 7B model, 1,200 for a 32B model) and assumes generation scales linearly with GPUs.
Policy model
Tokens to generate
16.4M
per training step
Generation time
28 min
per step, before the long tail
GPU-hours
3.8
of generation per step
The survey's anchors: 512 rollouts of 2K tokens on a 7B model take about 3 minutes on one H100; 512 of 32K on a 32B model take about 3.7 hours, or about 28 minutes on 8 GPUs. Real steps take longer, because each step waits for its longest rollouts.
Serving tricks carry straight over. Nemotron 3 Ultra used its head for speculative decoding during rollouts: with 5 drafted tokens, mean rollout-generation time per step was 1.46x faster, with most of the gain in the long tail. GLM-5's rollouts used FP8, MTP and prefill-decode disaggregation to cut tail latency, and DeepSeek-V4's wave-based expert scheduling gives up to 1.96x speedups on latency-sensitive work such as RL rollouts.
Weight sync: moving the model every step
After every update the generators need the new weights. For a large model that means hundreds of gigabytes or more per step over on the GPU fabric. Typical costs from the Hugging Face survey:
| Method | Cost | How |
|---|---|---|
| NCCL broadcast | ~100-500 ms | The common default: trainer GPUs broadcast new weights to the inference engines. |
| NCCL with bucketing (verl) | ~20 ms | Weights are packed into large buffers and sent in a few big transfers. |
| Swap between forward passes (PipelineRL) | ~1-10 ms | New weights land between decode steps; sequences in flight are never interrupted. |
| Kimi K2 via checkpoint-engine | ~16-17 s | A trillion-parameter model updated across 256 H20 GPUs. |
| LoRA adapter only (rank 32) | ~50 MB | Sub-millisecond, because only the adapter moves. |
Why LoRA fits RL so well
Thinking Machines' "LoRA Without Regret" found that matches full fine-tuning in RL even at rank 1, because a policy-gradient update carries only a few bits of information per episode. Their recipe: apply it to all layers, especially the MLP and mixture-of-experts layers, at roughly 10x the full fine-tuning learning rate. For infrastructure that means an adapter of tens of megabytes to sync instead of the full model, a trainer only slightly larger than the sampler, and many adapters served from one inference engine.
Correctness matters as much as speed. For its model, DeepSeek-V3.2 replays the expert routing recorded during sampling when training ("Keep Routing") and applies the sampler's top-p/top-k mask to the trainer ("Keep Sampling Mask"), so the policy being trained matches the one that generated. The survey found that none of the 16 libraries it reviewed implemented these yet.
The GRPO family in one table
Most open RL recipes start from and change how the loss is clipped, normalized or averaged. In ScaleRL's tests the choice of loss moved the final score ceiling (CISPO and GSPO beat DAPO), and computing the LM head in FP32 lifted the ceiling from about 0.52 to 0.61.
| Method | From | What it changes, in plain English |
|---|---|---|
| GRPO | DeepSeek (DeepSeekMath) | Drops PPO's value network. Each prompt gets a group of answers, and each answer is scored against the group's average reward. Less memory, one model fewer to train. |
| DAPO | ByteDance Seed, Tsinghua AIR | Four fixes on top of GRPO: a higher upper clip so rare tokens can grow (no entropy collapse), dynamic sampling that skips all-right or all-wrong groups, a token-level loss so long answers count fully, and a softer penalty for overlong answers. |
| Dr. GRPO | Sea AI Lab, NUS | Removes two normalizations (dividing by answer length and by the group's reward spread) that biased GRPO toward ever-longer wrong answers. |
| GSPO | Qwen team | Computes the importance ratio and clipping per whole sequence instead of per token. The goal is stable RL on mixture-of-experts models. |
| CISPO | MiniMax (MiniMax-M1) | Clips the importance-sampling weight instead of clipping the token update, so every token still contributes a gradient. It is the loss in the ScaleRL recipe. |
DAPO reached 50 points on AIME 2024 with a Qwen2.5-32B base model in half the training steps that DeepSeek-R1-Zero-Qwen-32B needed to reach 47.
Environments and sandboxes
Agentic RL needs somewhere for the model to act: a repository to patch and test, a terminal, a browser or a search API. Each rollout gets its own isolated sandbox, so a step can need thousands at once. GLM-5's software-engineering RL alone used more than 10,000 verifiable environments across thousands of repositories, behind an orchestrator running more than 1,000 concurrent rollouts. There are now dedicated products for building environments:
NVIDIA
Open-source library for building RL environments and running rollouts at scale. Resource servers set up and tear down the sandboxes, APIs and databases each rollout needs; it can also pull in environments from other formats, including OpenEnv and Verifiers, and plugs into NeMo RL.
Meta PyTorch and Hugging Face
An open spec and hub for agentic environments, launched October 2025: sandboxed environments with step, reset and close methods, runnable locally in Docker, with integrations into TorchForge, TRL, verl, SkyRL and Unsloth.
Prime Intellect
A community registry of environments packaged as Python modules that follow the Verifiers spec, usable both for RL training (with PRIME-RL) and for evaluation.
DeepSeek's DSec: hundreds of thousands of sandboxes
In production a single DSec cluster manages hundreds of thousands of concurrent sandbox instances. It is built on DeepSeek's file system and offers four execution substrates behind one Python SDK:
Function call
The lightest option, for simple tool calls
Container
Read-only image layers (EROFS) on 3FS
microVM (Firecracker)
Shared read-only base on 3FS plus a local copy-on-write layer
Full VM (QEMU)
The heaviest option, a whole virtual machine
Where RL runs actually fail
Most failures observed in Nemotron 3 Ultra's RL runs on GB200 were not in the trainer. The fixes NVIDIA lists as future work point the same way: restart generation workers or sandboxes individually, move sandboxes and tool calling onto their own infrastructure, and checkpoint in-flight rollouts and their KV cache.
- 56% Generation engine failures and timeouts
- 36% Sandbox and tool calling
- 8% Other software issues
Startup is its own problem at this scale. In the same report, Ray startup at 3,000+ GPUs took 25-49 minutes until actor registrations were cut and the control store tuned, and overall launch time fell from over 30 minutes to 10.
The data side of RL
Pre-training storage is mostly a story of streaming tokens in and writing checkpoints out (see Data Pipeline). RL adds several new flows, and the 2026 reports describe each one:
Teacher weights
DeepSeek-V4 distills from more than ten teachers, too many to keep resident. Teacher weights sit in centralized distributed storage and are loaded on demand, sharded ZeRO-style, with loading and offloading run asynchronously off the critical path.
Sandbox images and snapshots
DSec keeps container layers and microVM base images on 3FS and adds chainable snapshots for millisecond-scale resumption. Nemotron 3 Ultra's 44 GB container image normally unpacked in 2-3 minutes, but some nodes stalled for 12+ minutes under shared-storage load.
Rollout logs
DeepSeek-V4's rollout service appends every generated token to a per-request write-ahead log and saves the KV cache of unfinished requests on preemption, so it resumes instead of regenerating. Each sandbox also keeps an ordered trajectory log that is replayed on resume.
Million-token rollout data
For million-token RL, DeepSeek-V4 splits rollout data into light metadata (loaded first, for global shuffling and packing) and heavy per-token fields, which stream through a shared-memory loader and are freed after each mini-batch.
Checkpoints and caches
In Nemotron 3 Ultra's RL runs, synchronous checkpoint saves blocked training for about 60 seconds; asynchronous saves cut the exposed time to under a second. Cached JIT compilation cut a 49-minute cold start at 1K+ GPUs to 0.4 minutes.
DeepSeek also explains why it keeps rollout state instead of restarting interrupted requests: regenerating unfinished rollouts from scratch introduces a length bias, because shorter responses are more likely to survive an interruption.
On-policy distillation
RL gives the model one reward per rollout: a single right or wrong at the end. On-policy distillation (OPD) keeps the part of RL that matters most, training on the student's own samples, and swaps the sparse reward for a dense one: a teacher model grades every token, and the student minimizes the reverse KL divergence from the teacher. It needs no reward function, only a teacher that is already good at the task. In Thinking Machines' own reasoning experiment, OPD used 9-30x less compute than extending off-policy distillation, and the post cites the Qwen3 report's head-to-head with RL below.
Qwen3: the same starting checkpoint, two ways to finish
Both runs start from a checkpoint trained by off-policy distillation that scores 55.0% on AIME'24.
Show compute as
Post-training compute
AIME'24 score
Grey = the shared 55.0% starting point; colored = the gain. Axis runs 0-100%.
Compute ratio
~10x less
OPD vs RL GPU-hours
Score gap
+6.8 pts
OPD above RL
GPU-hours saved
16,120
by distilling instead
On-policy distillation only works if a stronger teacher already exists. RL is how a teacher's skills are found in the first place, and distillation is the cheap way to pass them on.
How the 2026 models merge their specialists
Domain experts (math, coding, agents, instruction following) are each trained with SFT and GRPO, then one student learns from more than ten teachers with full-vocabulary logit distillation. Only the teachers' last hidden states are cached; logits are rebuilt through each teacher's head, with one head on the GPU at a time.
Multi-teacher on-policy distillation (MOPD) from more than ten specialists, covering software engineering, search, terminal use, safety, chat, STEM, competitive coding and more. It runs as an asynchronous pipeline in two rounds, with generations up to 192K tokens.
SFT, then reasoning RL, agentic RL and general RL in sequence. A final cross-stage on-policy distillation uses each earlier stage's checkpoint as a teacher to win back skills that later RL stages eroded.
The infrastructure is the same loop as RL - student rollouts on an inference engine, then scoring, then an update. The difference is the scorer, which is now one or more large teacher models running forward passes. DeepSeek-V4 streams teacher weights from storage and keeps only one teacher head on a GPU at a time for this reason.
Open-source RL libraries
In the Hugging Face survey of 16 open-source RL libraries, Ray is the most common orchestrator (8 of 16) and NCCL broadcast the most common weight transfer. LoRA support is uneven, and support for mixture-of-experts models with expert parallelism increasingly sets libraries apart. Here are the eight that come up most often:
verl
ByteDance Seed + community
- Open-source version of the HybridFlow paper, orchestrated with Ray
- Trains with FSDP/FSDP2 or Megatron; generates with vLLM or SGLang
- Bucketed NCCL weight sync; DAPO's reference recipe runs on it
slime
THUDM (GLM team)
- Megatron for training, SGLang for rollouts, Ray orchestration
- The RL framework behind GLM-4.5 through GLM-5
- Multi-turn agentic and fully async rollout examples
NeMo RL
NVIDIA
- Ray-based; vLLM, SGLang or Megatron generation
- Trains with DTensor or Megatron-Bridge; drops samples past a max age
- Ran Nemotron 3 Ultra's one-step off-policy async RL
PRIME-RL
Prime Intellect
- Plain Python (asyncio, filesystem / ZMQ) rather than Ray
- FSDP2 training; weight sync over the filesystem or NCCL
- Pairs with the Verifiers spec and the Environments Hub
SkyRL
NovaSky
- Ray plus native Python; vLLM or SGLang generation
- FSDP/FSDP2 or Megatron-Bridge training
- Aborts stale rollouts and resumes them from the generated prefix
AReaL
inclusionAI (Ant Group)
- Native asyncio, with pluggable Ray or Slurm
- FSDP2, Megatron or Archon training backends
- Bounds off-policyness; in-flight rollouts finish before a sync
OpenRLHF
OpenRLHF community
- Ray for scheduling, vLLM for generation, DeepSpeed ZeRO for training
- PPO, REINFORCE++, GRPO, RLOO, Dr. GRPO and more
- Async pipeline with partial rollouts, or a colocated hybrid engine
TRL
Hugging Face
- GRPOTrainer runs one synchronous training step at a time
- Uses vLLM in server or colocate mode for generation
- An async trainer is in development
Sources
- Hugging Face - Keep the Tokens Flowing: lessons from 16 open-source RL libraries ↗
- Thinking Machines - On-Policy Distillation ↗
- Thinking Machines - LoRA Without Regret ↗
- The Art of Scaling RL Compute for LLMs (ScaleRL, arXiv 2510.13786) ↗
- DeepSeek-V3.2 (arXiv 2512.02556) ↗
- DeepSeek-V4 (arXiv 2606.19348) ↗
- Nemotron 3 Ultra (arXiv 2606.15007) ↗
- GLM-5 (arXiv 2602.15763) ↗
- MiniMax-M1 / CISPO (arXiv 2506.13585) ↗
- DeepSeekMath / GRPO (arXiv 2402.03300) ↗
- DAPO (arXiv 2503.14476) ↗
- Dr. GRPO (arXiv 2503.20783) ↗
- GSPO (arXiv 2507.18071) ↗
- OpenEnv (Hugging Face blog) ↗
- NVIDIA NeMo Gym docs ↗
- Prime Intellect Environments Hub ↗
- verl ↗
- slime ↗
- OpenRLHF ↗
The sync/async timeline uses illustrative durations, and the rollout-time calculator is an estimate built on the survey's throughput figures. GPU-hour, score and failure figures are as published.