# Reasoning RL systems: asynchronous rollouts and policy lag

> Reasoning RL joins generation, grading, learning, and weight publication. Asynchronous execution overlaps work and introduces policy lag. A runnable scheduling simulation separates elapsed time, accepted batches, and discarded trajectories.

- URL: https://dmxsf.com/en/wiki/post-training/rollout-and-training/
- [DMXSF](https://dmxsf.com/en/about/)
- Intermediate
- Updated: 2026-11-21
- Tags: Reasoning, Reinforcement learning, Systems & hardware

## After this page you will be able to

- Trace a rollout through grading, batching, policy updates, and weight publication.
- Compare colocated, disaggregated synchronous, and asynchronous execution.
- Explain the version conventions for behavior and learner policy probabilities.
- Use a scheduling simulation and slices to inspect lag, discards, and effective training volume.

Reasoning RL generates responses, grades them, and computes gradients. Separate generation and training devices can do this work concurrently. Overlap introduces an algorithmic issue: the learner may receive trajectories from older weights. Compare usable training data, policy lag, memory, and held-out quality together.

*Figure: Asynchrony overlaps sampling and training. Track trajectory versions, queue age, and discard reasons together.*

## Follow one trajectory through the system

In reinforcement learning with verifiable rewards (RLVR), an actor reads a problem and samples a response using its current weights. A verifier or environment produces the reward and outcome. A learner forms batches, estimates advantages, and publishes updated weights. The [NeMo RL lecture from Berkeley Scalable AI](https://scalable-ai.eecs.berkeley.edu/S2026/assets/lecture_slides/lecture_16_2.pdf) shows the boundaries among generation, training, the environment, and weight transfer.

| Stage | Record at least | Common sources of delay |
| --- | --- | --- |
| Generation | Task ID, sampling settings, behavior version, response tokens and masks | Prefill, decoding tails, KV cache |
| Environment and grading | Grader version, final state, reward, failures and timeouts | Tools, multi-turn state, verification |
| Batching | Group ID, availability, discard reason, queue age | Long trajectories and missing group members |
| Update | Model version, loss, sample and token counts | Forward and backward passes, communication, optimizer |
| Weight publication | Versions produced, sent, and active | Shard conversion, transfer, serving reload |

Group-relative methods need to know which responses shared a problem and which ones contributed to group statistics. Timeouts, truncation, and staleness filters can change group size. Decide whether to resample, drop the group, or regroup according to the algorithm. Record the resulting task mix. Keep verifier failures separate from wrong answers unless the reward contract explicitly counts a timeout as failure.

## Colocated, disaggregated synchronous, and asynchronous training

Colocated systems alternate generation and training on the same devices. This simplifies weight consistency and is useful when device capacity is tight. The phases compete for memory, and stragglers can leave devices idle.

A disaggregated system can preserve a synchronization barrier, allowing the actor to wait for the latest weights before generating the next batch. Measure that version first to isolate resource separation and transfer costs. Relaxing barriers allows concurrent work. When generation outruns consumption, trajectories wait longer in queues. Queue limits, waiting for weights, and discarding stale work are ways to control that lag.

## The behavior probability belongs to the actor

Let $\mu$ be the sampling policy and $\pi_\theta$ the policy being updated. If $h_i$ denotes the prompt and response prefix, the ratio for action token $y_i$ is:

$$
r_i(\theta)=\exp\bigl(\log \pi_\theta(y_i\mid h_i)
-\log \mu(y_i\mid h_i)\bigr)
$$

The stored behavior probability must correspond to the distribution that produced the sample. When temperature or truncation is active, check that the probability convention matches the algorithm's assumptions and that templates, token boundaries, and masks align. Recomputing the denominator with current weights hides the old trajectory's origin. Clipping ratios limits some extreme updates. Strong policy drift can still make old data unsuitable. Version lag is inexpensive to track. Also inspect ratio distributions, clipping fractions, and held-out quality because the same version gap can represent different amounts of drift.

Pin the policy version for the trajectory or record the per-step behavior version according to the framework's contract. A long response can otherwise span a weight change with no provenance. Have the generation backend report when weights become active. Sending them and using them are separate events.

With multiple responses per problem, record where rewards are normalized. If four responses first contribute to group statistics and only two survive later filtering, reusing the original advantages or recomputing on the remaining two creates different training objectives. Keep raw trajectories, verification results, and loss-bearing batches distinct in storage. Save the selection rule and its version for reproducibility. Comparing schedules at the same number of usable trajectories is closer to algorithm cost than counting issued generation requests.

## Experiment: time saved and work retained

Simulate six batches with one actor and one learner. Updates take a fixed time and one generation is unusually slow. A version is published at update completion and becomes visible immediately, including at an equal timestamp. Batches enter training in generation order. A batch that exceeds the lag limit at its training turn is dropped. Durations are illustrative. The simulation has no model, device communication, reward, or convergence behavior. It ran with Python 3.12.14 on an Apple M2 Max.

```python
from __future__ import annotations

from bisect import bisect_right
from dataclasses import dataclass

@dataclass(frozen=True)
class Trace:
    elapsed: int
    accepted: int
    dropped: int
    lags: tuple[int, ...]

def simulate(
    durations: list[int],
    update_time: int,
    *,
    overlap: bool,
    max_lag: int,
) -> Trace:
    """Simulate FIFO training with a fixed update time."""
    if update_time <= 0 or max_lag < 0 or min(durations, default=1) <= 0:
        raise ValueError("durations must be positive and max_lag nonnegative")
    actor_free = 0
    publish_times: list[int] = []
    lags = []
    for duration in durations:
        learner_free = publish_times[-1] if publish_times else 0
        start = actor_free if overlap else max(actor_free, learner_free)
        actor_free = start + duration
        train_start = max(actor_free, learner_free)
        actor_version = bisect_right(publish_times, start)
        train_version = bisect_right(publish_times, train_start)
        lag = train_version - actor_version
        lags.append(lag)
        if lag <= max_lag:
            publish_times.append(train_start + update_time)
    accepted = len(publish_times)
    elapsed = max(actor_free, publish_times[-1] if accepted else 0)
    return Trace(elapsed, accepted, len(durations) - accepted, tuple(lags))

durations = [3, 3, 9, 2, 2, 2]
serial = simulate(durations, 6, overlap=False, max_lag=0)
bounded = simulate(durations, 6, overlap=True, max_lag=1)
permissive = simulate(durations, 6, overlap=True, max_lag=9)
assert serial.accepted == permissive.accepted == 6
assert all(lag == 0 for lag in serial.lags)
assert bounded.elapsed < permissive.elapsed < serial.elapsed
assert bounded.dropped > 0 and max(permissive.lags) > 1
for label, trace in zip(
    ('serial', 'bounded', 'permissive'), (serial, bounded, permissive)
):
    print(label, trace.elapsed, trace.accepted, trace.lags)
```

```text
serial 57 6 (0, 0, 0, 0, 0, 0)
bounded 29 4 (0, 1, 2, 0, 1, 2)
permissive 39 6 (0, 1, 2, 1, 2, 3)
```

The widget below draws this replay as a timeline: the top lane is the actor's six generations, the bottom lane the learner's accepted updates, dropped batches marked in red — switch the three modes to see elapsed time, effective batches and the max version gap.

Serial execution consumes every batch at zero lag. Permissive overlap consumes the same six batches sooner, while accepting older data. Bounded overlap ends even earlier and completes fewer updates because it discards work. Report usable batches and usable sample throughput alongside elapsed time. To compare convergence, measure elapsed time or GPU-hours to a fixed held-out quality target.

## Run controlled comparisons before tuning

1. Fix the model, problems, reward, response length limits, and hardware budget. Measure each stage and held-out quality in a synchronous baseline.
2. Separate generation and training while preserving synchronization. Measure peak memory and weight transfer separately.
3. Allow a small amount of overlap. Log staleness, discard rates, and usable tokens by task type and length.
4. Compare quality at the same effective update budget. For a cost comparison, record total GPU-hours to a specified quality.

Generation tokens per second can rise without raising training throughput. Early termination, verifier failures, filters, and retries separate the measurements. Count generated tokens, loss-bearing tokens, and completed updates independently. Break them down by task difficulty or response length to detect systematic discards. To measure length sensitivity, vary the length mix without changing the sampling and grading versions at the same time.

## Summary and exercises

- Measure generation, grading, batching, and updates with a shared trajectory ID.
- Asynchrony trades policy freshness for overlap. Track behavior probabilities and when weights become active.
- Compare usable training volume, held-out quality, and GPU-hours, with discarded work visible.

### Quick self-check

**1. What should travel with a generated trajectory?**

- [x] The actual behavior policy version and sampling log probabilities.
- [ ] Only the newest learner weights.

> Replay needs the distribution that produced the action.

**2. What needs recounting after staleness filtering?**

- [ ] Only the raw generation rate.
- [x] Accepted batches, loss-bearing tokens, and task mix.

> Filtering changes training volume and can change the sample composition.

**3. What does receipt of a weight file guarantee?**

- [x] Check separately when that version is active for generation.
- [ ] Past trajectories automatically came from the new version.

> The version that produced an existing action is fixed.

**4. How should you decide whether overlap reduced training cost?**

- [ ] Compare only the time for a fixed number of generation requests.
- [x] Compare GPU-hours to the same held-out quality target.

> The runs may complete different amounts of effective training.

### Check whether discards change the task mix

Suppose longer problems lose more trajectories to staleness. Specify two diagnostics and a controlled comparison that could test a remedy.

<details>
<summary>Worked answer</summary>

By task type and generation length, record generated batches, accepted batches, and lag distributions. Measure each group's share of loss-bearing tokens. Compare a synchronous baseline with an asynchronous run that uses a shorter queue on the same problem set and budget. Check slice discard rates and held-out quality, and record the time difference.

</details>

## Further reading

- [Berkeley Scalable AI: NeMo RL slides](https://scalable-ai.eecs.berkeley.edu/S2026/assets/lecture_slides/lecture_16_2.pdf) on separated backends and policy lag.
- [Stanford CS336](https://cs336.stanford.edu/#assignments), the reasoning RL assignment.
- [Reasoning RL](https://dmxsf.com/en/wiki/post-training/reasoning-rl/), [inference serving](https://dmxsf.com/en/wiki/inference/serving/), and [continuous batching](https://dmxsf.com/en/wiki/inference/continuous-batching/).

## Companion code

[Reasoning RL systems: rollout and learner scheduling](https://github.com/dmxsf/dmxsf/tree/main/labs/post-training/rollout-and-training): Replay serial and overlapping jobs, and verify policy lag and dropped batches.

- Run it in the companion repository (add --quick for a fast pass): `uv run dmxsf run post-training/rollout-and-training`
- [View the lab script](https://github.com/dmxsf/dmxsf/blob/main/labs/post-training/rollout-and-training/run.py)
- [Lab write-up](https://github.com/dmxsf/dmxsf/blob/main/labs/post-training/rollout-and-training/README.en.md)
- [`rollout_pipeline.py`](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/post_training/rollout_pipeline.py)
- [Find this lab in the catalog](https://dmxsf.com/en/code/#rollout-and-training)

## FAQ

### Does disaggregation imply asynchronous training?

Disaggregation allocates separate devices. A barrier can still require new weights before each batch. Asynchrony lets generation continue across updates and requires tracking lag.

### How can you measure policy lag?

Record the behavior version at sampling and the version at the time the learner uses the trajectory. Track their difference along with ratios that reflect policy drift.

### Is a shorter asynchronous run always better?

Compare accepted updates and held-out quality. A short run can discard more work, so elapsed time alone cannot establish faster convergence.
