---
title: ThunderSyncRL (Reinforcement Learning) | Overview
url: https://www.emergentmind.com/topics/thundersyncrl
type: topic
---

# ThunderSyncRL (Reinforcement Learning) | Overview

ThunderSyncRL is a lossless, readiness-driven training system for agentic reinforcement learning that overlaps rollout, verification, and learner computation without introducing policy staleness. It preserves the semantics of batch-synchronous Group Relative Policy Optimization (GRPO) and on-policy distillation (OPD) while launching gradient computation as soon as the mathematical inputs for an individual trajectory or agentic turn become available. The system separates asynchronous execution from synchronous parameter updates: all contributions for logical update $k$ are evaluated under one fixed policy $\pi_{\theta_k}$, accumulated exactly, globally reduced, clipped, and followed by a single optimizer step and policy publication [2610.05935].

## 1. Motivation and design position

Agentic RL workloads are dominated by long-horizon, heterogeneous trajectories. A language model may generate an action, invoke a tool, wait for sandbox execution, receive an observation, and continue through multiple turns. Rollout duration and reward or teacher-score availability consequently exhibit substantial variability.

Conventional synchronous training follows the sequence

$$
\text{roll out all trajectories}
\rightarrow
\text{obtain all rewards or teacher scores}
\rightarrow
\text{train}
\rightarrow
\text{publish the next policy}.
$$

This preserves a single policy snapshot and a well-defined logical batch, but learner engines remain idle until rollout-side dependencies close. The reported synchronous GRPO/OPD configuration left learner GPUs idle for $49.5\%$ of a step while waiting for rollout and verification.

Fully asynchronous training overlaps rollout and learning across policy versions. Its principal cost is policy staleness: trajectories may be generated by $\pi_{\theta_{k-1}}$ or older policies while the learner updates $\theta_k$. This changes the data distribution and can require importance weighting, clipping, filtering, lag control, or other off-policy corrections.

ThunderSyncRL occupies an intermediate position. Execution is asynchronous, but policy updates remain synchronous. For logical batch $\mathcal B_k$, every trajectory is generated under one fixed policy $\pi_{\theta_k}$, and every learner computation is evaluated at $\theta_k$. The system begins independent learner work as soon as its objective inputs are fixed, while deferring only reductions or normalizations that mathematically require information from the complete logical batch.

The resulting distinction is between **readiness synchronization** and **policy synchronization**. Readiness synchronization determines when a local gradient contribution may be computed; policy synchronization occurs only after the complete logical update has been reduced and applied.

## 2. Readiness-driven execution model

A logical batch contains independently executable objective sources. A source may be a reward-ready GRPO trajectory or a teacher-scored OPD turn. Let source $j$ become ready at time $\tau_j$ and require $p_j$ time to execute. On a single learner lane, the completion recursion is

$$
c_0=0,\qquad
c_j=\max\{\tau_j,c_{j-1}\}+p_j.
$$

If $R_k$ is the time at which all rollout-side dependencies close, $c_n$ is the completion time of learner work, and $P_k$ is the final reduction, optimizer, and publication suffix, ThunderSyncRL has step time

$$
T_k=\max\{R_k,c_n\}+P_k.
$$

Synchronous training instead performs all learner work after rollout completion:

$$
T_{\mathrm{Sync}}
=
R_k+\sum_{j=1}^{n}p_j+P_k.
$$

The scheduler maintains a work-conserving readiness queue subject to memory and per-rank admission limits. Completion order affects execution order, not logical batch membership. Learner engines can therefore process short or early-completing sources while longer tool calls, trajectories, or verification tasks remain active.

Writing $L=\sum_jp_j$, the synchronous duration is

$$
T_{\mathrm{Sync}}=R+L+P.
$$

If $\lambda_K R=[c_n-R]_+$ denotes the learner tail after rollout closure, the ThunderSyncRL duration can be written as

$$
T_{\mathrm{ThunderSyncRL}}
=
R(1+\lambda_K)+P.
$$

The corresponding speedup is

$$
S_{\mathrm{Sync}}
=
\frac{T_{\mathrm{Sync}}}{T_{\mathrm{ThunderSyncRL}}}
=
\frac{1+\rho+\kappa}{1+\lambda_K+\kappa},
\qquad
\rho=\frac{L}{R},
\qquad
\kappa=\frac{P}{R}.
$$

The ideal ceiling is

$$
S_{\mathrm{Sync}}
\leq
\frac{R+L+P}{\max(R,L)+P}
\leq 2.
$$

Thus, the largest gains arise when rollout and learner workloads are comparable, learner work becomes available early, and the final reduction and publication suffix is small. When nearly all learner work is released only at batch completion, or one stage dominates the critical path, the attainable gain approaches the ordinary pipeline limit.

The system uses a policy-version barrier at the logical-update level. Rollout workers execute with policy version $k$; only after all registered sources, deferred computations, global reduction, clipping, and the optimizer step complete is $\theta_{k+1}$ published.

## 3. GRPO gradient streaming

### Batch-synchronous GRPO formulation

For a prompt, GRPO samples a group

$$
\mathcal G=\{1,\ldots,m\}
$$

of $m$ trajectories. Trajectory $i$ has reward $r_i$, action-token set $\mathcal M_i$, and masked policy score

$$
S_i(\theta)
=
\sum_{t\in\mathcal M_i}
w_{i,t}\log \pi_\theta(a_{i,t}\mid x_{i,t}).
$$

Its trajectory score gradient, evaluated at the fixed rollout policy, is

$$
g_i
=
\left.\nabla_\theta S_i(\theta)\right|_{\theta=\theta_k}.
$$

Group-relative normalization uses

$$
\mu_{\mathcal G}
=
\frac{1}{m}\sum_{i\in\mathcal G}r_i,
$$

and

$$
\sigma_{\mathcal G}
=
\sqrt{
\frac{1}{m}
\sum_{i\in\mathcal G}
(r_i-\mu_{\mathcal G})^2
}.
$$

With detached advantages, the group gradient is

$$
g_{\mathcal G}
=
\frac{1}{m}
\sum_{i\in\mathcal G}
\frac{r_i-\mu_{\mathcal G}}
{\sigma_{\mathcal G}+\epsilon}
g_i.
$$

The reference setting uses groups of $m=8$, population rather than unbiased standard deviation, and $\epsilon=10^{-6}$. With 32 prompts and eight trajectories per prompt, one logical update contains 256 trajectories.

### Sufficient-statistics decomposition

The coefficient multiplying $g_i$ cannot be finalized until all group rewards are available. The score gradient $g_i$, however, depends only on trajectory $i$ and the fixed policy $\theta_k$. ThunderSyncRL therefore accumulates two group-level sufficient statistics:

$$
G_{\mathcal G}^{(1)}
=
\sum_{i\in\mathcal G}r_i g_i,
\qquad
G_{\mathcal G}^{(2)}
=
\sum_{i\in\mathcal G}g_i.
$$

The group gradient can be expressed as

$$
g_{\mathcal G}
=
\frac{1}{m}
\frac{
G_{\mathcal G}^{(1)}
-
\mu_{\mathcal G}G_{\mathcal G}^{(2)}
}
{\sigma_{\mathcal G}+\epsilon}.
$$

For each reward-ready trajectory, the learner performs

$$
G_{\mathcal G}^{(1)}
\leftarrow
G_{\mathcal G}^{(1)}+r_i g_i,
$$

$$
G_{\mathcal G}^{(2)}
\leftarrow
G_{\mathcal G}^{(2)}+g_i.
$$

When the final group member arrives, ThunderSyncRL computes $\mu_{\mathcal G}$ and $\sigma_{\mathcal G}$, forms the exact group gradient, and completes deferred backward propagation through shared prefixes or captured boundary states. The logical-batch gradient is then

$$
g_k
=
\sum_{\mathcal G\subset\mathcal B_k}
g_{\mathcal G}.
$$

The equality follows from

$$
G_{\mathcal G}^{(1)}
-
\mu_{\mathcal G}G_{\mathcal G}^{(2)}
=
\sum_i(r_i-\mu_{\mathcal G})g_i.
$$

Consequently, the order in which trajectory gradients are computed does not change the mathematical result. ThunderSyncRL does not estimate group statistics prematurely and does not apply approximate advantages.

### Conditions for losslessness

Lossless equivalence to batch-synchronous GRPO requires:

1. all trajectories in a logical update originate from the same policy $\pi_{\theta_k}$;
2. gradients are evaluated at unchanged parameters $\theta_k$;
3. group membership is fixed;
4. rewards, masks, token weights, and causal contexts are fixed;
5. advantages are detached;
6. accumulation uses the same reduction and normalization convention;
7. only one optimizer step occurs after batch closure;
8. clipping and optimizer-state updates occur after the complete gradient is formed.

Zero-variance groups remain in the batch but contribute zero policy gradient under the stated stabilization convention.

## 4. OPD gradient streaming

On-policy distillation generates trajectories with a student policy while a frozen teacher scores the student’s sampled action tokens. Agentic execution has the form

$$
\text{student action}
\rightarrow
\text{tool call}
\rightarrow
\text{sandbox execution}
\rightarrow
\text{observation}
\rightarrow
\text{next turn}.
$$

For turn $j$, let $\mathcal M_j$ denote its scored action tokens. The detached teacher-student log-probability difference is

$$
A_{j,t}
=
\operatorname{sg}
\left[
\log \pi_T(a_{j,t}\mid x_{j,t})
-
\log \pi_{\theta_k}(a_{j,t}\mid x_{j,t})
\right].
$$

The turn contribution is

$$
g_j
=
\sum_{t\in\mathcal M_j}
A_{j,t}
\left.
\nabla_\theta
\log \pi_\theta(a_{j,t}\mid x_{j,t})
\right|_{\theta=\theta_k}.
$$

The batch OPD direction is token-normalized:

$$
g_k
=
\frac{1}{N_k}
\sum_{j\in\mathcal U_k}g_j,
\qquad
N_k
=
\sum_{j\in\mathcal U_k}|\mathcal M_j|.
$$

Once a turn’s sampled tokens and causal context are complete, the frozen teacher can score them and ThunderSyncRL can begin the student backward pass. That backward computation overlaps with sandbox execution of the current turn, generation of later turns, rollout of other trajectories, and teacher scoring of other turns.

Because $N_k$ is unknown until logical-batch closure, ThunderSyncRL accumulates unnormalized contributions and token counts:

$$
\widehat g_k
=
\frac{\sum_jg_j}{\sum_j|\mathcal M_j|}.
$$

This is equivalent to forming the batch token-mean loss first and differentiating it because the denominator is independent of $\theta$. Deferred state-adjoint propagation through earlier shared context is completed before the optimizer barrier.

Unlike GRPO, OPD has no group reward normalization. This makes turn-level streaming more direct: teacher-scored turns constitute independently executable objective sources once their causal histories are fixed.

## 5. System architecture and synchronization barriers

ThunderSyncRL comprises several cooperating subsystems:

- **Rollout workers** run vLLM with policy version $k$ and generate trajectories or agentic turns.
- **Environment and tool workers** execute shell commands, sandbox calls, and other external operations.
- **Reward or teacher-scoring workers** produce GRPO rewards or OPD token scores.
- **A readiness queue** carries trajectory, turn, reward, and scoring-completion events.
- **Learner engines** consume ready sources and accumulate gradients.
- **A logical-batch barrier** waits for registered trajectories, groups, and deferred backward work.
- **A distributed reduction stage** performs global gradient reduction, objective-specific normalization, clipping, and one optimizer step.
- **A policy-publication stage** publishes the new version, invalidates policy-dependent caches, and waits for rollout acknowledgements before the next logical update.

The reference system uses four learner GPUs. GRPO uses four additional rollout GPUs; OPD uses two rollout GPUs and two teacher GPUs. Gradients and some GRPO statistics are accumulated in FP32 host memory. An admission cap limits the number of simultaneously open groups to control memory.

The principal synchronization barrier is therefore not the start of learner computation. It is the point at which the system must guarantee that all contributions required for the exact logical update are present. Earlier execution remains asynchronous, but the optimizer step and policy publication remain globally ordered.

ThunderSyncRL can also reuse shared-prefix computation. Branch-specific continuations are processed independently, while boundary adjoints are accumulated and propagated through shared prefixes once all relevant contributions are available. This reduces redundant learner work in agentic trajectories with common context.

The method is not equivalent to asynchronous optimization. It does not apply optimizer updates as individual trajectories or turns arrive. It does not change the active policy while a logical batch is being accumulated, and it does not rely on stale trajectories to hide learner latency.

## 6. Evaluation, performance, and limitations

### Experimental configuration

The principal experiments use:

- students Qwen-3.8-27B and GLM-4.7-Flash-31B;
- SWE-smith and SETA-Env training data;
- SWE-bench Verified with 500 tasks;
- Terminal Bench 4.0 with 66 tasks;
- one node with eight NVIDIA B200 GPUs, with Qwen experiments also on eight H200 GPUs;
- GRPO batches of 32 prompts and eight trajectories per prompt, totaling 256 trajectories;
- OPD batches of 32 prompts and four trajectories per prompt, totaling 128 trajectories;
- a maximum of 300 turns and 1,024 generated tokens per turn;
- AdamW with learning rate $10^{-6}$;
- one optimizer step per batch;
- global norm clipping of $1.0$;
- seeds 42, 43, and 44.

The comparison includes:

- **Sync**, which waits for the complete rollout batch before learning;
- **Async**, with approximately one-update policy lag;
- **Fully Async**, in which rollout weights may change while trajectories remain in flight.

### Reported results

On SWE-bench Verified, ThunderSyncRL reached the same pass@3 target as synchronous training up to $1.9\times$ faster under both GRPO and OPD. For GRPO, a $74.01\%$ target was reached at:

$$
121.3\ \text{GPU-hours}
$$

for ThunderSyncRL compared with

$$
233.5\ \text{GPU-hours}
$$

for Sync.

On Terminal Bench 4.0, the reported speedups were $1.8\times$ for GRPO and $1.9\times$ for OPD.

At a fixed 128-GPU-hour budget, ThunderSyncRL exceeded Async by the following margins:

| Evaluation | GRPO | OPD |
|---|---:|---:|
| SWE-bench Verified | $+2.47$ points | $+1.27$ points |
| Terminal Bench 4.0 | $+1.52$ points | $+2.02$ points |

Measured Qwen/B200 step times were approximately:

- GRPO: Sync, $1296.4$ seconds; ThunderSyncRL, $687.7$ seconds; speedup $1.91\times$.
- OPD: Sync, $1314.7$ seconds; ThunderSyncRL, $685.7$ seconds; speedup $1.94\times$.

Rollout and verification required approximately 650–660 seconds in both configurations. Sync then added approximately 646–656 seconds of learner work, whereas ThunderSyncRL left only a small final learner tail.

For Qwen on H200, speedups were $1.63\times$ for GRPO and $1.67\times$ for OPD. For GLM, whose learner was relatively short and rollout-bound, speedups were $1.64\times$ and $1.63\times$. LoRA preserved the ordering but reduced available learner work, producing Qwen speedups of $1.69\times$ and $1.71\times$.

Exact-update replay experiments on B200 and H200 found that streamed and synchronous gradients matched coordinate by coordinate in FP32, with relative errors of $5.1\times10^{-7}$ for GRPO and $1.1\times10^{-6}$ for OPD on B200. Across ten updates, the FP32 parameter gap remained below $6\times10^{-5}$.

### Limitations

ThunderSyncRL applies when an objective can be decomposed into ready local contributions plus delayed sufficient statistics. Direct application becomes difficult when:

- a source depends on future trajectories or a global statistic that cannot be represented compactly;
- rewards or teacher scores can change after learner computation begins;
- the policy changes before all gradients for the logical batch are finalized;
- gradients are clipped or normalized independently per source;
- optimizer steps occur before batch closure;
- exact bitwise equality requires a particular floating-point reduction order;
- memory pressure delays readiness work;
- shared-prefix or recurrent-state dependencies require future information;
- variable denominators are applied before their final values are known.

Losslessness should be distinguished from bitwise identity. Mathematical equality follows from the sufficient-statistics decomposition, but finite-precision accumulation, distributed reduction order, BF16 arithmetic, and kernel choices can produce small numerical differences. The reported replay experiments found these differences far below ordinary BF16-versus-FP32 variation.

The principal systems trade-off is memory. Early backward execution requires live gradient accumulators, deferred adjoints, and GRPO group statistics. The benefit is largest when rollout and learner workloads are comparable, trajectories are heterogeneous, and objective dependencies resolve early, as in turn-level OPD. If one stage dominates or most work becomes ready only at batch completion, the performance advantage approaches the pipeline ceiling.

ThunderSyncRL therefore does not remove the logical synchronization requirement of policy optimization. It relocates synchronization to the mathematically necessary boundary: local computation begins at readiness, while normalization, reduction, clipping, optimizer state transition, and policy publication remain ordered. This dependency-aware separation provides a middle ground between rigid batch barriers and stale asynchronous RL.

Source: https://www.emergentmind.com/topics/thundersyncrl