← notes Training systems

Async RL: train while the rollouts are still running

Move GRPO from a generate-then-train loop to two GPU pools that run at the same time, then bound how stale the data gets and correct the loss for it. How verl fully_async_policy and AReaL do each part.

18 min read 6 interactive

Where a synchronous step spends its time

The walkthrough starts from a real run: GRPO on 16 GPUs (2 × 8 H100), 128 prompts × 8 responses = 1,024 responses per step, max_response_length = 16384. One step takes about 180 s:

PhaseTime per stepShare
Rollout (vLLM generation)~120 s~67%
Actor update (FSDP2 forward, backward, step)~38 s~21%
Ref log-probs, reward, advantage, bookkeeping~22 s~12%

In this setup verl runs a hybrid engine: all 16 GPUs switch between vLLM and FSDP2. Every GPU is always busy, but only with one phase at a time. During the 120 s of generation, no training happens.

Generation dominates for three reasons. Each decode token needs a full forward pass on a growing KV cache, which is fixed cost. The sync design makes the trainer wait for the rollouts. And the responses vary a lot in length: the source’s estimate is a median near 2K tokens (~15 s), a 90th percentile near 8K (~60 s), and a 99th percentile at the 16K cap (~120 s). The one response at the cap gates 1,023 others that finished long ago. This is tail latency.

Async RL removes the barrier. A rollout pool generates continuously, a trainer pool trains continuously on whatever trajectories are ready, and the two meet only to copy new weights from trainer to rollout. Ideally the step time drops from Trollout+TtrainT_\text{rollout} + T_\text{train} to max⁡(Trollout,Ttrain)\max(T_\text{rollout}, T_\text{train}).

Splitting the GPUs can make it slower

The ideal assumes each pool runs as fast as the shared pool did. On fixed hardware it does not. Split 16 GPUs into 8 for rollout and 8 for training: vLLM drops from 8 instances (TP = 2) to 4, so compute-bound generation takes roughly twice as long, ~200–240 s. FSDP2 scales roughly linearly, so the 60 s of training becomes ~100–120 s. The step is now max⁡(240,120)\max(240, 120), which is worse than the 180 s sync baseline.

playground

Drag the split between the two pools

Drag the white handle under the GPU row. Then move α toward 0 or press Sublinear.

Preset
rollout (vLLM) train (FSDP2: ref, reward, advantage, actor)
split R : T
async step
vs sync 180 s
best split at this α
With linear rollout scaling (α = 1) no split of 16 GPUs beats 180 s. If rollout scales sublinearly (8 GPUs take 140 s, not 240 s), an 8 : 8 split gives ~140 s, a ~22% gain. The model is T_rollout = 120·(16/R)^α and T_train = 60·16/T; sync overhead (~0.1–0.3 s) is ignored.

The walkthrough lists the cases where the split wins: rollout scales sublinearly with GPUs (fewer, larger vLLM instances can pack the KV cache better), extra GPUs are available (with 32 GPUs, 16 + 16 gives max⁡(120,60)=120\max(120, 60) = 120 s, but on twice the hardware), or training is bound by I/O rather than compute. Its first recommendation is to measure TrolloutT_\text{rollout} at 8 GPUs before you choose a path. The fourth case is the one that matters most at long response lengths: partial rollout.

The tail, and partial rollout

There is a spectrum between fully on-policy and fully off-policy:

  • One-step-off (staleness 1): batch N+1N+1 generates while batch NN trains. The PPO ratio πθN/πθN−1\pi_{\theta_N}/\pi_{\theta_{N-1}} is exactly what standard PPO expects, so nothing extra is needed. Published gains are 20–40%, but the tail of each batch still gates its step.
  • Fully async (bounded staleness): there is no step at the rollout layer. Samples stream out one at a time, and the trainer pulls whatever is ready. A batch mixes data from several old policies.

Partial rollout is the fully async feature that removes the tail. When new weights arrive, a long rollout that is still generating is interrupted, and then it continues from where it stopped, now under the new weights. Its tokens span more than one policy version. The 120 s tail no longer blocks anything, and the source puts the effective rollout time at ~60–80 s, where 90% of the samples are done. Its conclusion: the published 2–3× gains are almost all at long response lengths, and the tail kill does most of the work, not the plain overlap.

verl names four modes for its async trainer. The widget below runs three of them on the same two pools: (a) staleness_threshold = 0, an on-policy pipeline; (c) staleness > 0 without partial rollout, where each sync waits for in-flight rollouts; (d) staleness > 0 with partial rollout, where a sync interrupts them.

playground

48 rollout slots and one trainer, three modes

Switch the mode. Hover a bar to see when a rollout started and which versions it spans. Change the train time.

Mode

one rollout (shade flips at each policy version) trainer update weight sync
time per update
speed-up vs Sync
trainer idle
rollout slots idle
Simulated, toy numbers: response times follow the source's median 15 s, p90 60 s, cap 120 s. In Sync the trainer idles while the slots drain the tail. In Partial nothing waits for the tail, and the trainer becomes the limit. Each slot decodes at a fixed speed here, which overstates the gain; verl reports 2.35–2.67× end to end.

Move the train-time slider to 180 s and the async gain shrinks: the trainer is the slow side and no overlap can help it. This is why verl reports two dials, trainer/idle_ratio and rollouter/idle_ratio. If the rollouter idles and the trainer does not, move GPUs to the trainer, and the reverse.

Four moving parts

Every async framework has the same parts. A rollout producer runs the inference engine. A buffer holds finished trajectories. A trainer pulls them, computes the loss and steps the optimiser. A weight synchroniser copies new weights to the inference pool and bumps the policy version, an integer that counts weight pushes. A fifth concern, the staleness controller, throttles the producer. Staleness is the number of versions a trajectory lags behind the trainer.

The two frameworks put the buffer in different places, and that one choice decides how they apply backpressure:

  • verl runs four Ray actors. The rollouter pushes each finished sample into a separate MessageQueue actor, a bounded deque. The trainer pulls require_batches × ppo_mini_batch_size samples per local update. When a push overflows the queue, it drops the oldest sample.
  • AReaL runs an SPMD trainer that talks to remote SGLang or vLLM servers over HTTP. The buffer is two deques inside the trainer’s WorkflowExecutor. A producer thread asks the StalenessManager for capacity before it submits a rollout, and parks on a condition variable when there is none. Nothing is ever dropped.

animation

Samples through the pipeline: verl vs AReaL

Press Play, or Step one event at a time. Switch the design and compare the dropped and parked counters.

Design

policy version
generated
dropped
slots parked
mean lag
The same toy pipeline in both designs, with a trainer slower than the rollouts. verl keeps generating and its queue drops the oldest sample (red); AReaL's gate parks the producer, so slots sit empty instead. A dot is a finished sample, labelled with the version that started it.

Neither choice is wrong. verl can waste inference compute on a sample that it later drops, but both pools stay busy and tolerate a speed mismatch. AReaL never wastes a finished generation, but a tight bound can starve the trainer or idle the inference servers.

Bounding staleness: a proportion or a version lag

The two staleness knobs bound different quantities.

verl: a proportion of a sync window. The trainer pushes weights every trigger_parameter_sync_step local updates. The rollouter pauses once it has started too many samples since the last sync:

max_required_samples=required_samples×(1+staleness_threshold)×trigger_parameter_sync_step\text{max\_required\_samples} = \text{required\_samples} \times (1 + \text{staleness\_threshold}) \times \text{trigger\_parameter\_sync\_step}

The counter staleness_samples resets after each sync. With threshold 0.5 the rollouter may run 50% past one full window. The version lag of any one sample is an outcome of how fast the rollouter ran, so verl also measures it after the fact from trajectory_param_versions. The docs recommend keeping the threshold below 1; threshold 1 with a fast rollouter is roughly one-step-off.

AReaL: a version lag. The knob max_head_offpolicyness = kk is an integer, and the capacity gate is

capacity=min⁡(max_concurrent−running,  (k+v+1) B−(accepted+running))\text{capacity} = \min\big(\text{max\_concurrent} - \text{running},\; (k + v + 1)\,B - (\text{accepted} + \text{running})\big)

where vv is the current version and BB is consumer_batch_size. The trainer consumes BB samples per version, so at most (k+1)B(k+1)B samples are outstanding. With k=0k = 0 this is synchronous RL, which AReaL’s docs call about 2× slower and useful for debugging.

playground

Two staleness knobs on one toy pipeline

Move each knob from 0 upward. Then make the rollout pool slower or faster than the trainer.

verl (partial_rollout on) AReaL
Simulated. At 0 both knobs give a synchronous run with every sample at lag 0. Raising them cuts the time per update and moves samples to lag 1–2. When the rollout pool outruns the trainer, verl drops a share of finished samples while AReaL parks slots.

A limit of the toy, not a claim about AReaL: the toy’s trainer takes samples in the order they finish, so a rollout that started early and ran long can be trained at lag k+1k + 1. The source describes AReaL’s bound as a per-sample version guarantee, and the toy’s ordering is the reason it differs here.

verl’s own staleness ablation (Qwen2.5-Math-7B, DAPO, 28K max response, 400 steps): threshold 0 took 1 d 1 h 53 m, threshold 0.5 took 17 h 22 m. Larger staleness gave larger gains, but response-length instability appeared later in training. Smaller require_batches means purer streaming and smaller bubbles, though require_batches = 4 gave the best wall-clock in their setup.

Correcting the loss for stale data

GRPO’s clipped objective uses the ratio ρt=πθ(at∣st)/πold(at∣st)\rho_t = \pi_\theta(a_t \mid s_t) / \pi_\text{old}(a_t \mid s_t), and it assumes that πold\pi_\text{old} is the behaviour policy, the one that actually sampled ata_t. In sync training, the actor’s own forward pass after rollout gives πold\pi_\text{old}. In fully async training, a batch holds samples from θ8\theta_8, θ9\theta_9 and θ10\theta_{10}. A recompute at the current weights gives the wrong denominator for all but the newest, and the gradient is biased. Reported symptoms: rollout log-perplexity above 2.0, spikes in PG loss and gradient norm, oscillating response length, drifting KL, and eventually collapse.

The fix is cheap. When vLLM samples a token it already has the distribution, so it records the log-prob of that token, the rollout log-probs. The buffer carries them with the tokens. Each sample brings its own denominator, and the trainer never holds θ8\theta_8 or θ9\theta_9.

Three losses use these numbers differently:

  • Bypass (verl’s default, bypass_mode=True): use the rollout log-probs directly as old_log_prob, so ρ=πθ/πbehave\rho = \pi_\theta / \pi_\text{behave}, and clip it as usual. One forward pass is saved. A single ratio does two jobs.
  • Decoupled PPO (AReaL, use_decoupled_loss): three policies. The trainer recomputes a recent proximal policy πprox\pi_\text{prox} at train time and anchors the trust region there (formula below; it follows AReaL’s code, because the two source documents write it in different forms).
  • verl with bypass_mode=False recomputes old_log_prob with the training engine and applies Rollout Importance Sampling. For this it restores a CPU snapshot of the parameters from the first local step of the sync window. verl’s docs say that in mode (d) this approximates AReaL’s decoupled PPO.
L=max⁡ ⁣(−A^ r,  −A^ clip(r,1−ϵ,1+ϵ))⋅w,r=πθπprox,w=πproxπbehave\mathcal{L} = \max\!\big(-\hat A\, r,\; -\hat A\,\text{clip}(r, 1-\epsilon, 1+\epsilon)\big)\cdot w, \qquad r = \frac{\pi_\theta}{\pi_\text{prox}},\quad w = \frac{\pi_\text{prox}}{\pi_\text{behave}}

The clip works against a recent policy, so it stays near 1 however stale the sample is. The staleness enters only through ww, and AReaL’s rejection_sampling masks or clamps ww for tokens or sequences whose πprox/πbehave\pi_\text{prox}/\pi_\text{behave} diverges too far.

The widget uses the source’s numeric example. The context is "2 + 2 = " and the sampled token is "4". Under θ8\theta_8 the token had log-prob −3.0 (p = 0.05); under θ10\theta_{10} it has −0.05 (p = 0.95). The advantage is +1.

playground

One stale token, three losses

Drag the three handles. Try π_θ moving away from π_prox, a negative advantage, and Mask instead of Clamp.

Advantage Â
AReaL rejection

With the default values, bypass computes a ratio of 19.1, the clip fires, and this token gives no gradient: the clip eats the importance-sampling signal. Recompute only ignores who sampled the token. Decoupled keeps the clip near 1 against π_prox and applies the staleness weight separately, bounded here by a toy limit.

Clipping is still needed even with exact behaviour log-probs, for three reasons. Unbiased does not mean bounded variance: a token with πbehave=0.0001\pi_\text{behave} = 0.0001 and πθ=0.1\pi_\theta = 0.1 has ρ=1000\rho = 1000 and dominates a 1,024-token batch. The clip is also a trust region that limits the size of one update. And stored log-probs can hit numerical edge cases (−30, or −inf in low precision) that give ρ\rho of 10510^5 or more. Decoupled PPO splits these jobs: ww handles the direction, the clip on rr handles the size. With staleness 1, bypass is enough; as staleness grows, the source’s advice is to move to Token-TIS, then Seq-TIS, then Seq-MIS in verl, or to the decoupled loss.

Moving the weights

Both frameworks end in an NCCL broadcast from one trainer rank to every inference rank. The plumbing differs.

verl uses a checkpoint-engine modelled on Moonshot’s. It builds one collective group of size rollout_world_size + 1. Trainer rank 0 is the source, the other trainer ranks get rank −1 and skip the broadcast, and rollout ranks are 1 to N. The trainer streams full tensors into fixed-size byte buckets and broadcasts them with a double buffer, so bucket k+1k+1 fills while bucket kk is in flight. Tensor metadata travels separately over ZMQ PUB/SUB. Measured sync times on H20:

ModelTrainer × rollout ranksSync time
Qwen2.5-Math-7B4 × 40.02 s
Qwen3-30B-A3B16 × 164.38 s
Qwen3-235B-A22B64 × 6423.70 s

AReaL creates a second NCCL process group through a fresh TCP rendezvous. Before each broadcast, the trainer tells the servers over HTTP what to expect (param_specs: names, shapes, dtypes), then runs dist.broadcast(src=0). With FSDP2 it rebuilds each full parameter with DTensor.full_tensor(), an all-gather. With Megatron it gathers expert-parallel shards with dist.all_gather. Because this logic lives in each engine, AReaL can also remap parameter names for Qwen-VL and Gemma3, which matters if you train a VLM. A disk-reload path exists for debugging.

verl and AReaL side by side

diagram

Pick a concern, compare the two mechanisms

Click a tab.

The single biggest difference is the buffer: verl externalises it and over-produces then drops; AReaL keeps it in-process and refuses to start a rollout once the version budget is spent. File and line anchors are from the source's checkouts; re-grep if the code moved.

The reported numbers, for scale: verl, up to 2.35–2.67× end to end at 128 GPUs (64 : 64) on Qwen2.5-Math-7B with comparable accuracy, and ~1.7× for a 30B MoE at a skewed 96 : 32 split. AReaL, 2.57× at 7B at matched accuracy. Both are long-response math settings, where the tail is longest.