When Speed Kills Stability: Demystifying RL Collapse from the Training-Inference Mismatch
Why the gap between fast inference and faithful training silently collapses LLM-RL, and how masked importance sampling (MIS) fixes it
Authors: Jiacai Liu*, Yingru Li*†, Yuqian Fu, Jiawei Wang, Qian Liu, Yu Shen†
*Co-first authors. †Corresponding authors. Work done at ByteDance. First published September 17, 2025.
Follow-up paper: Trust Region Masking for Long-Horizon LLM Reinforcement Learning (ICML 2026)
What this post contributes. Fast inference engines and faithful training frameworks compute slightly different probabilities from the same weights. This training-inference mismatch silently turns on-policy RL into off-policy RL, and in reasoning and agentic RL it can collapse a run. The post gives a diagnosis and a fix.
Diagnosis: five findings (§3)
- A metric that warns.
vllm-klmeasures the mismatch, and its spikes come together with the spikes in entropy, perplexity and gradient norm that precede a collapse (§3.1). - The engines disagree on low-probability tokens. The trainer can give a sampled token a probability orders of magnitude below the sampler’s, and the batches where this happens are the ones whose gradients explode (§3.2).
- Out-of-distribution tool responses make it worse. After a tool response the model samples low-probability tokens more often, so multi-turn agentic runs fail first (§3.3).
- Hardware is a first-order variable. With identical code the mismatch ranks H20 < L20 < A100, and a run that collapses on one GPU trains on another (§3.4).
- The mismatch grows during training. Once a run enters a high-mismatch state it stays there; we hypothesize a feedback loop between the optimizer and numerical error (§3.5).
Fix: sequence-level masking (§4). Token-level corrections reweight each token but not the distribution of prefixes, and in our multi-turn tool-use runs they still collapsed. Masked importance sampling (MIS) computes one ratio for the whole response, $\rho(y|x) =$ $\pfsdp(y|x)/\pvllm(y|x)$, and masks the policy loss of every sequence whose ratio exceeds a threshold $C$. Geo-MIS applies the mask, on both sides, to the geometric mean of the per-token ratios, so that one pair of thresholds serves responses of every length $T$:
$$ \begin{gathered} \text{MIS:}\quad \rho(y|x) \gets \rho(y|x)\,\mathbb{I}\{\rho(y|x) \le C\}, \\ \text{Geo-MIS:}\quad \rho_{\mathrm{geo}} = \rho(y|x)^{1/T}, \qquad \rho_{\mathrm{geo}} \gets \rho_{\mathrm{geo}}\,\mathbb{I}\{C_{\text{low}} \le \rho_{\mathrm{geo}} \le C_{\text{high}}\}. \end{gathered} $$On L20 GPUs, MIS trained for more than 700 steps where the uncorrected run collapsed near step 280, raised the peak training reward from 0.56 to 0.64, and matched the uncorrected peak test accuracy (0.70 vs. 0.68; Figure 14, §4.3). Geo-MIS was released in VeRL 0.6.0. Its statistic $-\log\rho_{\mathrm{geo}}$ is a one-sample estimate of the mean per-token KL of the response, the quantity vllm-kl monitors; the follow-up paper, Trust Region Masking (ICML 2026), computes that KL exactly and adds a max-KL criterion (§4.4).
The fix: mask whole responses whose importance ratio leaves the trust region, before they reach the loss (MIS and Geo-MIS, §4).
How to read this post. §1 and §2 state the problem. §3 is the evidence, one finding per subsection. §4 is the method: why the correction must act on the whole sequence, then MIS, then Geo-MIS and its link to Trust Region Masking. §5 lists the engine and hardware settings we tried, with a summary table, and §6 has the takeaways for practitioners. Short on time: read the box above, the figure, §4.3 and §6.
1. The Mystery of the Sudden Collapse
In the rapidly advancing field of reinforcement learning for large language models (LLM-RL), a frustrating pattern of sudden training collapse is emerging. Whether in complex reasoning RL or multi-turn agentic RL, many have observed training runs that, after a period of stable learning, catastrophically fail.
We recently encountered this firsthand while conducting agentic RL experiments for multi-turn tool-integrated reasoning (TIR) on Qwen3 models. This occurred across both on-policy and off-policy variants of the GRPO algorithm on our L20 GPU cluster. Figure 1 shows the reward and gradient norm dynamics of our four crashed experiments on Qwen3-14B-Base. After a period of steady progress, rewards collapse, and in two of the runs the gradient norm explodes as they do. Our initial investigation focused on common culprits:
- We examined the code and confirmed that our agent loop follows a token-in-token-out process.
- We tuned the hyperparameters
beta1andbeta2in the Adam optimizer. - We also applied batch normalization to the advantages to balance the updates.
However, none of these standard fixes worked. Since even the simpler on-policy experiments failed, we suspected the issue was not with the RL algorithm but with a more fundamental part of the training stack. This led us to investigate a critical and increasingly prevalent challenge in modern LLM-RL: the unavoidable gap between highly optimized inference engines and faithful training frameworks.

1024 trajectories (64 prompts × 16 responses) at each training step and use a learning rate of 1e-6. The ppo_mini_batch_size is set to 1024 and 256 for on-policy and off-policy experiments, respectively. The off-policy runs differ in clip-higher, DAPO's upper clip ratio.2. A Fundamental Conflict: The Growing Gap Between Inference and Training
Rollout speed is a core bottleneck in LLM-RL. To reach the throughput it needs, modern inference engines (e.g., vLLM, SGLang, TensorRT-LLM) use aggressive optimizations such as speculative decoding, low-precision computation (INT8/FP8), and specialized, batch-variant CUDA kernels. They maintain sampling fidelity, but their primary objective is throughput, often measured in tokens per second.
Training frameworks (e.g., FSDP, DeepSpeed, Megatron-LM) strike a different balance. They prioritize numerical stability and precision for gradient computation, and often keep master weights and optimizer states in higher-precision formats such as FP32.
This divergence in priorities makes a training-inference mismatch hard to avoid, and the push for faster rollouts is making the gap wider, not smaller. One can enforce identical calculations (e.g., with “batch invariant kernels”), but this costs substantial throughput, which works against the reason for using a high-speed inference engine. The speed-versus-consistency trade-off is at the heart of the problem: it is a persistent challenge rather than a simple engineering fix.
In our stack, this mismatch manifested between our vLLM inference sampler and our FSDP trainer. The actual parameter update was
$$ \mathbb{E}_{x\sim \mathcal{D}}\,\mathbb{E}_{y\sim \pvllm(\cdot|x)}\left[ R(x,y)\, \nabla_{\theta}\log \pfsdp(y|x) \right], $$whereas the theoretical parameter update should be
$$ \mathbb{E}_{x\sim \mathcal{D}}\,\mathbb{E}_{y\sim \pfsdp(\cdot|x)}\left[ R(x,y)\, \nabla_{\theta}\log \pfsdp(y|x) \right]. $$Here $x$ is the prompt sampled from the distribution $\mathcal{D}$, $y$ is the response, $R$ is the reward function, $\theta$ is the parameter of the LLM, and $\pvllm$ and $\pfsdp$ are the policies implemented in the vLLM engine and the FSDP engine, respectively. To investigate this, we first needed a way to measure it.
3. Diagnosis: Five Findings
Setup
Unless otherwise specified, the experiments in Sections 3 to 5 use:
- Framework: VeRL, with the vLLM v1 sampler (AsyncvLLMServer) and an FSDP trainer.
- Model and algorithm: Qwen3-14B-Base trained with GRPO on multi-turn tool-integrated reasoning (TIR).
- Batch and optimizer: 64 prompts × 16 responses = 1024 trajectories per step, learning rate 1e-6,
ppo_mini_batch_size1024 for on-policy and 256 for off-policy runs. - Hardware: L20 GPUs.
Experiments that change the hardware, the model, or the task (single-turn reasoning RL) say so.
3.1 Finding 1: vllm-kl Spikes Come with the Signs of Collapse
One number, vllm-kl, measures the mismatch. Its spikes line up with spikes in entropy, perplexity and gradient norm, and it rises before the reward collapses.
A very straightforward metric for measuring the training-inference mismatch is vllm-kl:
$$ \mathbb{E}_{s\sim d_{\pvllm}}\left[\text{KL}\left(\pvllm(\cdot|s)\,\|\,\pfsdp(\cdot|s)\right)\right] = \mathbb{E}_{s\sim d_{\pvllm},\,a\sim \pvllm(\cdot|s)} \left[\log\left(\frac{\pvllm(a|s)}{\pfsdp(a|s)}\right)\right], $$where $s$ is the context prefix (state), $a$ is the token (action), and $d_\pi$ is the distribution of prefixes visited by policy $\pi$ (defined precisely in §4.1). Our experiments involve tool calls, so the response $y$ may include tool responses; our vllm-kl metric only considers tokens generated by the model itself, and averages over them. The formula above is the plain log-ratio form; the code below uses the K3 estimator, $r - 1 - \log r$ with $r = \pfsdp(a|s)/\pvllm(a|s)$, which has the same expectation, is never negative, and has lower variance. It computes vllm-kl in VeRL, assuming the inference engine’s token probabilities are already available:
K3 estimator for vllm-kl
rollout_log_probs = batch.batch["rollout_log_probs"] # pi_vllm
actor_old_log_probs = batch.batch["old_log_probs"] # pi_fsdp
response_mask = batch.batch["response_mask"]
log_ratio = actor_old_log_probs - rollout_log_probs
vllm_k3_kl_matrix = torch.exp(log_ratio) - log_ratio - 1
vllm_k3_kl = masked_mean(vllm_k3_kl_matrix, response_mask)
Our first clue was that high vllm-kl values were not isolated events. They correlated strongly with other signs of instability.
Entropy and rewards fluctuate with vllm-kl
In many of our experiments, abnormal spikes in vllm-kl coincide with anomalous fluctuations in the entropy of the FSDP policy $\pfsdp$ and in rewards. Figure 2 is an intuitive example: the locations of the entropy spikes almost perfectly match the locations of the vllm-kl spikes. The correlation is less pronounced in the rewards, but a massive vllm-kl spike around step 250 coincided with a low-quality batch and a noticeable dip in reward. When the mismatch is large, both the vLLM policy $\pvllm$ and the FSDP policy $\pfsdp$ enter an unstable region.

vllm-kl, illustrating their correlation during training.FSDP perplexity and gradient norm rise before the collapse
More critically, spikes in vllm-kl coincided with spikes in both the FSDP perplexity (fsdp-ppl) and the gradient norm. In our experiments, the fsdp-ppl of a response $y$ is
where $\mathcal{T}_{\mathcal{M}}(y)$ is the index set of the tokens generated by the model itself in the response $y$. The batch’s fsdp-ppl is the average over all responses in the batch. Figure 3 shows an on-policy and an off-policy version of GRPO. In both, the spikes in vllm-kl line up almost exactly with spikes in fsdp-ppl and the gradient norm. Moreover, vllm-kl rises significantly before the training reward collapses.

vllm-kl.Late in training the policy’s entropy is low (about 0.2 in Figure 2), so its perplexity on its own samples should stay close to 1. In batches with a large mismatch (high vllm-kl), fsdp-ppl instead spiked (to about 1.27 in Figure 3, top). The FSDP engine was assigning very low probabilities to some tokens that the inference engine had sampled, and these were the batches whose gradient norm spiked. This observation helped us pinpoint where mismatches are more likely to occur. As we will see, when these extremely low-FSDP-probability tokens were sampled, their probabilities in the vLLM engine were not nearly as low.
3.2 Finding 2: The Mismatch Concentrates in Low-Probability Tokens
The mismatch is not uniform: it sits in the tokens the sampler considers unlikely.
By analyzing batches with varying levels of vllm-kl, we found a stark pattern. As a token’s inference probability approaches zero, the training probability can become orders of magnitude smaller, making PPL and gradients explode. To make the conclusions as general as possible, we selected batches from various experiments before training collapse, taken at different training steps. Most of them have relatively high vllm-kl, which lets us study mismatch patterns under pronounced conditions; Group 1 serves as a low-mismatch reference. We collected rollout batches in three vllm-kl ranges, with five batches (around 5M tokens) in each group:
- Group 1 (low): each batch has
vllm-kl≤ 1e-3, sampled on H20 GPUs. - Group 2 (medium): each batch has
vllm-klin [1e-3, 2e-2], sampled on L20 GPUs. - Group 3 (high): each batch has
vllm-klin [2e-2, 1e-1], sampled on L20 GPUs.
Group 1 comes from H20 GPUs and Groups 2 and 3 from L20 GPUs, so the level of mismatch and the hardware vary together here. Section 3.4 isolates the effect of the hardware with otherwise identical runs.
Figure 4 shows the relationship between the vLLM output probability $\pvllm(a|s)$ and the mismatch, measured by $\log \pfsdp(a|s) - \log \pvllm(a|s)$, at each level of vllm-kl:



From the three figures we observe that:
- The mismatch tends to be more pronounced when the vLLM probability $\pvllm$ approaches zero, and extreme values of $\log \pfsdp - \log \pvllm$ are more likely there.
- The batches collected on L20 GPUs (groups 2 and 3) show a training-inference mismatch mainly in the form of the FSDP probability $\pfsdp$ being much smaller than the vLLM probability $\pvllm$.
Two caveats in reading these plots. Every token here was sampled by vLLM, so the average of $\log \pvllm - \log \pfsdp$ over the sampled tokens is the KL divergence, which is never negative: some downward shift is expected, and what matters is the size of the tail, which reaches −15 in group 3. And the upper edge of each cloud is the bound $\log \pfsdp - \log \pvllm \le$ $-\log \pvllm$, which widens as $\pvllm \to 0$ by construction.
3.3 Finding 3: Out-of-Distribution Tool Responses Amplify the Mismatch
After a tool response the model samples low-probability tokens more often. The mismatch therefore sits mainly in non-first-round outputs, and more tool calls bring an earlier collapse.
The mismatch is more severe in non-first-round outputs
Finding 2 explains why the problem was so acute in our multi-turn TIR experiments, particularly in non-first-round model outputs. The process works as follows:
- The agent receives a tool response, which is often structured text (e.g., content wrapped in
<python_output>and</python_output>tags) that is OOD compared to its pre-training and SFT data. - Faced with this unfamiliar OOD context, the agent’s policy becomes more uncertain and more likely to sample low-probability tokens in its subsequent turns (also observed in SimpleTIR).
- As we just established, these low-probability tokens are where severe mismatch occurs, creating the conditions for an
fsdp-ppland gradient explosion.
Next, we plot the mismatch in the batches of the three groups of Finding 2 (around 5k trajectories per group), separating first-round model outputs from non-first-round outputs. We use two views:
- Log-ppl scatter plot. The x-axis is the log of the ppl under the vLLM policy $\pvllm$ (
vllm-log-ppl), and the y-axis is the log of the ppl under the FSDP policy $\pfsdp$ (fsdp-log-ppl). - Probability scatter plot. The x-axis is the token probability under $\pvllm$ and the y-axis is the token probability under $\pfsdp$.
Group 3: batches with vllm-kl in [2e-2, 1e-1]

vllm-kl in [2e-2, 1e-1]). Top: log-ppl under vLLM vs. FSDP. Bottom: token probability under vLLM vs. FSDP. Left: first-round outputs. Right: non-first-round outputs.Groups 1 and 2: the same plots at lower mismatch
Group 1: batches with vllm-kl ≤ 1e-3

vllm-kl ≤ 1e-3). Same layout as Group 3.Group 2: batches with vllm-kl in [1e-3, 2e-2]

vllm-kl in [1e-3, 2e-2]), same layout as Group 3.From these plots we observe that:
- The
vllm-log-pplof non-first-round outputs is generally larger than that of first-round outputs: the model samples more low-probability tokens when it faces unfamiliar OOD context. - The mismatch occurs mainly in non-first-round outputs, which show a larger mean absolute difference between the FSDP and vLLM policies, in both log-ppl and token probability, and a lower Pearson correlation.
- As
vllm-klincreases, the mismatch worsens mainly in non-first-round outputs. fsdp-log-pplis consistently abovevllm-log-ppl. Some gap is expected, as noted above, but it is largest for non-first-round outputs, where FSDP assigns much lower probability than vLLM to the sampled tokens.
More tool calls, more training instability
The following experiments also show that OOD tool responses exacerbate the training-inference mismatch and training instability. We ran off-policy GRPO on H20 GPUs with Qwen3-14B-Base as the base model, clip-higher 0.28 and 4 mini-batches, and set the maximum number of tool calls per trajectory (max_tool_turn) to 20 or 100. Figures 5 and 6 show the results: the more tool calls, the earlier the training collapses. Every collapse comes with a gradient explosion and an explosion in vllm-kl.

vllm-kl (right) of off-policy GRPO experiments with different values of max_tool_turn. All experiments ran on H20 GPUs with Qwen3-14B-Base, clip-higher 0.28 and 4 mini-batches.
3.4 Finding 4: Hardware Is a First-Order Variable
The exact same code and model produce drastically different levels of mismatch on different GPUs. To measure this, we ran on-policy algorithms with identical code and hyperparameters, switching only the GPUs used for inference and training. Figure 7 shows the training dynamics on L20, H20 and A100.

vllm-kl (left) and rewards (right) of on-policy GRPO on different GPUs, with the same code and environment.In our experiments, the magnitude of vllm-kl follows H20 < L20 < A100. It is on the order of 5e-4 to 1e-3 on H20, around 1e-3 to 1e-2 on L20, and on A100 it swings between about 1e-3 and 5e-1, with frequent spikes above 1e-1 (that run lasted only about 50 steps). With such a severe mismatch on A100, normal training is not feasible and the reward curve is highly unstable.
The clearest evidence came when we took a failed L20 experiment and resumed it from a checkpoint on H20 GPUs (Figure 8). On H20 the run stayed stable, with a low gradient norm and rewards around 0.6, while the original run on L20 collapsed: the hardware has a first-order effect on the problem.

Two changes on the hardware side reduce the mismatch: moving from L20 to H20, and disabling cascade attention in vLLM on A100. Both are in §5.3.
3.5 Finding 5: The Mismatch Grows During Training
The mismatch is not a fixed property of the stack. Once a run enters a high-mismatch state it keeps producing high-mismatch batches, and we hypothesize a feedback loop between the optimizer and numerical error.
The evidence is our “batch-filter” experiment, which shows that the mismatch is coupled with the training dynamics and the model’s state.
In the batch-filter experiment, at each training step, if the collected batch has a vllm-kl above a threshold, we skip the update on that batch, since such updates are prone to cause collapse. We go straight to the next step and keep collecting data until a batch with vllm-kl below the threshold arrives, and only then update the model.
If the degree of mismatch were entirely independent of the model’s output distribution and the training dynamics, vllm-kl should have the same distribution at every training step. However, Figure 9 shows that once the model entered a certain state, it consistently generated high-mismatch batches, effectively halting training. This, together with the spiraling vllm-kl and fsdp-ppl in other runs (Figure 10), points to a dangerous feedback loop.

vllm-kl (left) and rewards (right). Steps whose batches were filtered out are highlighted in pink. The filter threshold is 0.1.
vllm-kl and fsdp-ppl over training steps in an on-policy experiment. The two curves rise together in a correlated, spiral-like pattern.We hypothesize a two-stage failure cascade:
- Stage 1: increased numerical sensitivity. The RL optimizer moves the weights into regions where
bfloat16rounding matters more.bfloat16keeps only about 8 bits of mantissa, so as activations and logits grow in magnitude their absolute rounding error grows with them, and when logits become nearly tied, small absolute errors change which low-probability tokens are sampled and how likely they look. - Stage 2: kernel-driven error amplification. These initial, tiny
bfloat16quantization errors are fed into the different kernel implementations of vLLM and FSDP. The different calculation orders act as non-linear amplifiers, so small initial deviations snowball into large differences in the final logits.
This creates a vicious feedback loop: mismatch leads to biased and noisy gradients, which may push the parameters further into a numerically sensitive region, which in turn worsens the mismatch at the next iteration, until the system collapses.
4. The Fix: Sequence-Level Correction and Masking
The mismatch follows from the speed-versus-consistency trade-off of §2, and the engine and hardware settings that reduce it are specific to one stack (§5). The fix that carries over is algorithmic: treat the sampler as a behavior policy and correct for it in the loss. This section takes four steps: why the correction has to act on the whole sequence (§4.1), what token-level and sequence-level corrections do in our runs (§4.2), our method, MIS (§4.3), and its length-normalized form, Geo-MIS, with its link to Trust Region Masking (§4.4).
4.1 Why the Correction Must Act on the Whole Sequence
A per-token ratio corrects how likely each token is given its prefix, but not how likely the prefix is. Only the ratio of the whole sequence corrects both.
The training-inference mismatch turns our otherwise on-policy RL problem into an off-policy one: the policy that generates rollouts (the behavior policy, $\pvllm$) differs from the policy being trained (the target policy, $\pfsdp$). One theoretically sound way to correct for this distribution shift is importance sampling (IS). However, the specific form of IS is critical for keeping the gradient unbiased and the training stable.
Inspired by Yao et al. (2025), who first highlighted this implicit off-policy issue caused by the training-inference mismatch, we analyze two forms of IS: the theoretically sound sequence-level IS and the common but biased token-level IS approximation.
Sequence-level importance sampling weights every term by the product over the whole response, 0.61 here. The estimator is unbiased; the price is a weight whose variance grows with length.
The principled estimator: sequence-level IS
The correct, unbiased policy gradient estimator applies a single importance ratio to the entire generated sequence (trajectory) $y$. This re-weights the expectation from the behavior policy to the target policy and yields the true gradient of the objective $J(\theta)$.
Let’s derive the sequence-level IS estimator $g_{\mathrm{seq}}(\theta)$ step by step.
The objective is to maximize the expected reward under the target FSDP policy:
$$ J(\theta) = \mathbb{E}_{x \sim \mathcal{D},\, y \sim \pfsdp(\cdot|x)}[R(x,y)] $$The true policy gradient is therefore:
$$ g(\theta) = \nabla_{\theta} J(\theta) = \mathbb{E}_{x \sim \mathcal{D},\, y \sim \pfsdp(\cdot|x)}\left[R(x,y)\, \nabla_{\theta} \log \pfsdp(y|x)\right] $$Since we can only sample from the vLLM policy, we use importance sampling to change the distribution of the expectation:
$$ g_{\mathrm{seq}}(\theta) = \mathbb{E}_{x \sim \mathcal{D},\, y \sim \pvllm(\cdot|x)}\left[ \frac{\pfsdp(y|x)}{\pvllm(y|x)} \cdot R(x,y) \cdot \nabla_{\theta} \log \pfsdp(y|x) \right] $$
This is essentially the off-policy REINFORCE algorithm (Williams, 1992). In expectation, the estimator equals the standard advantage form of the policy gradient: the importance ratio exactly corrects the expectation, revealing the true on-policy gradient underneath, which can then be refined.
The detailed derivation
Step 1: convert the expectation to its on-policy form. The IS estimator takes its expectation with respect to the behavior policy $\pvllm$. Writing the expectation out as an integral, the behavior policy density cancels:
$$ \begin{aligned} g_{\mathrm{seq}}(\theta) &= \int \left( \frac{\pfsdp(y|x)}{\pvllm(y|x)} \cdot R(x,y) \cdot \nabla_{\theta} \log \pfsdp(y|x) \right) \pvllm(y|x) \,dy \\ &= \int \left( R(x,y) \cdot \nabla_{\theta} \log \pfsdp(y|x) \right) \pfsdp(y|x) \,dy. \end{aligned} $$This leaves the true on-policy gradient, with the expectation now over the target policy $\pfsdp$, so $g_{\mathrm{seq}}(\theta)$ is an unbiased estimator of the true policy gradient:
$$ g(\theta) = \mathbb{E}_{y \sim \pfsdp} \left[ R(x,y) \cdot \nabla_{\theta} \log \pfsdp(y|x) \right]. $$Step 2: decompose into timesteps and apply causality. Working with the on-policy expression, we write the reward as a sum of per-step rewards, $R(x,y) = \sum_{k=0}^{|y|-1} r(s_k, a_k)$ (for an outcome reward, $r$ is nonzero only at the last token), expand the trajectory-level terms and apply causality (an action at step $t$ only affects future rewards). This replaces the total reward $R(x,y)$ with the return-to-go $G_t = \sum_{k=t}^{|y|-1} r(s_k, a_k)$. Writing $\pi_\theta$ for $\pfsdp$ in the rest of this derivation:
$$ g(\theta) = \mathbb{E}_{y \sim \pi_{\theta}} \left[ \sum_{t=0}^{|y|-1} G_t \cdot \nabla_{\theta} \log \pi_{\theta}(a_t|s_t) \right]. $$Step 3: introduce the advantage function. Replacing $G_t$ by its conditional expectation given $(s_t, a_t)$, the action value $Q^{\pi_{\theta}}(s_t, a_t)$, leaves the gradient unchanged (tower property). For variance reduction, we then subtract a state-dependent baseline, the value function $V^{\pi_{\theta}}(s_t)$, whose contribution is zero in expectation. This gives the advantage $A^{\pi_{\theta}}(s_t, a_t) =$ $Q^{\pi_{\theta}}(s_t, a_t) - V^{\pi_{\theta}}(s_t)$:
$$ g(\theta) = \mathbb{E}_{y \sim \pi_{\theta}} \left[ \sum_{t=0}^{|y|-1} A^{\pi_{\theta}}(s_t, a_t) \cdot \nabla_{\theta} \log \pi_{\theta}(a_t|s_t) \right]. $$Step 4: convert to a state-level expectation. Finally, rewrite the expectation over trajectories as an expectation over the state-visitation distribution $d_{\pi_{\theta}}$ induced by the target policy.
(a) Linearity of expectation. Swap the expectation and the sum. We can extend the sum to infinity because terms for timesteps $t$ beyond a trajectory’s length $|y|$ are zero:
$$ g(\theta) = \sum_{t=0}^{\infty} \mathbb{E}_{y \sim \pi_{\theta}} \left[ A^{\pi_{\theta}}(s_t, a_t) \cdot \nabla_{\theta} \log \pi_{\theta}(a_t|s_t) \right]. $$(b) Expand the expectation into an explicit sum over every state $s$ and action $a$, weighted by their joint probability $P(s_t=s, a_t=a) =$ $P(s_t=s) \cdot \pi_{\theta}(a|s)$:
$$ g(\theta) = \sum_{t=0}^{\infty} \sum_{s \in \mathcal{S}} P(s_t=s \mid \pi_{\theta}) \sum_{a \in \mathcal{A}} \pi_{\theta}(a|s) \cdot \left[ A^{\pi_{\theta}}(s, a) \cdot \nabla_{\theta} \log \pi_{\theta}(a|s) \right]. $$(c) Introduce the state occupancy measure. Group all terms related to state $s$:
$$ g(\theta) = \sum_{s \in \mathcal{S}} \left( \sum_{t=0}^{\infty} P(s_t=s \mid \pi_{\theta}) \right) \left( \sum_{a \in \mathcal{A}} \pi_{\theta}(a|s) \cdot \left[ \dots \right] \right). $$The first factor, $\sum_{t=0}^{\infty} P(s_t=s)$, is the state occupancy measure $d_{\pi_{\theta}}(s)$. The second is an expectation over actions, $\mathbb{E}_{a \sim \pi_{\theta}(\cdot|s)}[\dots]$:
$$ g(\theta) = \sum_{s \in \mathcal{S}} d_{\pi_{\theta}}(s) \cdot \mathbb{E}_{a \sim \pi_{\theta}(\cdot|s)} \left[ A^{\pi_{\theta}}(s, a) \cdot \nabla_{\theta} \log \pi_{\theta}(a|s) \right]. $$(d) The final form. A sum over states weighted by the occupancy measure is an expectation over $d_{\pi_{\theta}}$:
$$ g(\theta) = \mathbb{E}_{s \sim d_{\pi_{\theta}}} \left[ \mathbb{E}_{a \sim \pi_{\theta}(\cdot|s)} \left[ A^{\pi_{\theta}}(s,a) \cdot \nabla_{\theta} \log \pi_{\theta}(a|s) \right] \right]. $$This derivation leads to the advantage form of the policy gradient:
$$ g_{\mathrm{seq}}(\theta) = \mathbb{E}_{s \sim d_{\pfsdp}}\, \mathbb{E}_{a \sim \pfsdp(\cdot|s)} \left[ A^{\pfsdp}(s,a) \cdot \nabla_{\theta} \log \pfsdp(a|s) \right]. $$Here $s=(x,y_{\lt t})$ is the state (prefix), $a=y_t$ is the action (token), and $d_{\pfsdp}$ is the state occupancy measure under the target FSDP policy: the probability that a rollout under that policy reaches the prefix $s$. It is the probability of the prompt times the probabilities the policy gives to the model-generated tokens of the prefix.
The formal definition of the occupancy measure
The occupancy measure of a policy $\pi$ is the expected number of times a state $s$ is visited when following $\pi$:
$$ d_{\pi}(s) := \mathbb{E}_{x' \sim \mathcal{D},\, y' \sim \pi(\cdot|x')} \left[ \sum_{t'=0}^{|y'|-1} \mathbb{I}\{ (x', y'_{\lt t'}) = s \} \right]. $$For a prefix $s=(x,y_{\lt t})$ this is the probability of reaching it,
$$ d_{\pi}(s) = \mathcal{D}(x) \cdot \prod_{k=0}^{t-1} \pi(y_k|x,y_{\lt k}). $$Tool-response tokens come from the environment, not the policy, so only model-generated tokens enter this product.
This estimator is unbiased: $g_{\mathrm{seq}}(\theta) = g(\theta)$. For numerical stability, truncated importance sampling (TIS) clips the sequence-level ratio $\rho(y|x) = \pfsdp(y|x)/\pvllm(y|x)$ at a constant $C$. Clipping bounds the variance but brings back a controllable bias: the bias-variance trade-off analyzed in Part 2.
A common biased estimator: token-level IS
A common heuristic, often inspired by algorithms like PPO and used in Yao et al. (2025), applies a per-token importance ratio. It typically has lower variance than the sequence-level ratio, but for autoregressive models it is a biased estimator: it corrects each token’s distribution but not the distribution of prefixes.
The estimator applies the importance ratio inside the sum over timesteps, so $g_{\mathrm{tok}}(\theta)$ is defined as
$$ \mathbb{E}_{x \sim \mathcal{D},\, y \sim \pvllm(\cdot|x)}\left[ R(x,y) \cdot \sum_{t=0}^{|y|-1} \frac{\pfsdp(y_t|x,y_{\lt t})}{\pvllm(y_t|x,y_{\lt t})} \cdot \nabla_{\theta} \log \pfsdp(y_t|x,y_{\lt t}) \right] $$Grouping the terms by state and subtracting a baseline puts it in the same form as the true gradient above:
$$ g_{\mathrm{tok}}(\theta) = \mathbb{E}_{s \sim d_{\pvllm}}\, \mathbb{E}_{a \sim \pfsdp(\cdot|s)} \left[ A^{\pvllm}(s,a) \cdot \nabla_{\theta} \log \pfsdp(a|s) \right] $$The two steps in between
Grouping the terms by state turns the expectation over trajectories into an expectation over the states visited under the vLLM policy. The return $R(x,y)$ of a trajectory sampled by $\pvllm$ is a Monte Carlo estimate of the state-action value $Q^{\pvllm}(s,a)$, so
$$ g_{\mathrm{tok}}(\theta) = \mathbb{E}_{s \sim d_{\pvllm}}\, \mathbb{E}_{a \sim \pvllm(\cdot|s)} \left[ \frac{\pfsdp(a|s)}{\pvllm(a|s)} \cdot Q^{\pvllm}(s,a) \cdot \nabla_{\theta} \log \pfsdp(a|s) \right] $$Subtracting the baseline $V^{\pvllm}(s)$ leaves this unchanged, because
$$ \mathbb{E}_{a \sim \pvllm(\cdot|s)}\Big[\frac{\pfsdp(a|s)}{\pvllm(a|s)} \nabla_{\theta} \log \pfsdp(a|s)\Big] = \mathbb{E}_{a \sim \pfsdp(\cdot|s)}\big[\nabla_{\theta} \log \pfsdp(a|s)\big] = 0, $$and it turns $Q^{\pvllm}$ into the advantage $A^{\pvllm}$. Using the per-token ratio to change the expectation over actions from $\pvllm$ to $\pfsdp$ gives the form above.
This form reveals the gradient bias of token-level IS. $g_\text{tok}(\theta)$ approximates the true gradient well when $\pvllm$ stays within a trust region of $\pfsdp$, so that $d_{\pvllm}\approx d_{\pfsdp}$ and $A^{\pvllm}\approx A^{\pfsdp}$. Part 1 bounds the bias by $O(T^2 D_{TV}^{\max})$; it becomes harmful when the mismatch is large or uncontrolled.
The source of bias in token-level IS
Comparing $g_{\mathrm{tok}}(\theta)$ with the true gradient $g_{\mathrm{seq}}(\theta)$ reveals two distinct errors that make the token-level estimator biased.
Source 1: state occupancy mismatch. A sound off-policy correction must account for two distribution shifts: the action probabilities and the state visitation probabilities. The token-level method only corrects the first.
- True gradient ($g_{\mathrm{seq}}$): the expectation is over states visited under the correct target FSDP distribution, $\mathbb{E}_{s \sim d_{\pfsdp}}$.
- Flawed gradient ($g_{\mathrm{tok}}$): the expectation is over states visited under the incorrect behavior vLLM distribution, $\mathbb{E}_{s \sim d_{\pvllm}}$.
This implicitly assumes the state occupancy ratio $d_{\pfsdp}(s) / d_{\pvllm}(s)$ is 1. For a prefix $s=(x,y_{\lt t})$ that ratio is a product of per-token ratios,
$$ \frac{d_{\pfsdp}(s)}{d_{\pvllm}(s)} = \prod_{k=0}^{t-1} \frac{\pfsdp(y_k|x,y_{\lt k})}{\pvllm(y_k|x,y_{\lt k})}, $$so it compounds with the length of the prefix and drifts away from 1 even when every per-token ratio is close to 1. By ignoring it, $g_{\mathrm{tok}}(\theta)$ introduces a bias that grows with the length of the response.
Source 2: mismatched reward signal. The token-level gradient weights the update with a reward signal from the wrong policy.
- True gradient ($g_{\mathrm{seq}}$): the update is scaled by the advantage of the target FSDP policy, $A^{\pfsdp}$, the expected future reward under that policy.
- Flawed gradient ($g_{\mathrm{tok}}$): the update is scaled by the advantage of the behavior vLLM policy, $A^{\pvllm}$.
The gradient for the target policy is scaled by a reward signal that belongs to the behavior policy. Because both the state distribution and the reward signal are mismatched, the token-level gradient is biased, and the bias grows with the mismatch and with the length of the response.
4.2 Token-Level and Sequence-Level Corrections in Practice
Importance sampling of either kind prevents the gradient explosion. In multi-turn tool use the token-level run still collapses, while the sequence-level run survives but plateaus.
Our analysis predicts that token-level corrections become unstable when the mismatch is large, while sequence-level corrections are more robust. Pure sequence-level IS has exponential variance, so we test truncated and masked variants. With the per-token ratio $\rho_t =$ $\pfsdp(y_t|x,y_{\lt t})/\pvllm(y_t|x,y_{\lt t})$ and the sequence ratio $\rho = \prod_t \rho_t$, both over model-generated tokens:
- Token-TIS weights each token by $\min(\rho_t, C)$.
- Seq-TIS weights the whole sequence by $\min(\rho, C)$.
- Token-MIS weights each token by $\rho_t\,\mathbb{I}\{\rho_t \le C\}$.
- Seq-MIS, or simply MIS, weights the whole sequence by $\rho\,\mathbb{I}\{\rho \le C\}$ (§4.3).
IS prevents gradient explosion, but token-level IS still fails. We resumed a crashed L20 experiment from step 200 with token-level TIS and with sequence-level TIS ($C=2$). As Figure 11 shows, both prevent the gradient explosion seen in the vanilla run, but the token-level TIS run still collapses: its reward falls to zero by about step 240, without a gradient spike. The sequence-level TIS run stays stable through the end of the run, about step 280; Figure 13 follows Seq-TIS for longer.

Token-level TIS in reasoning RL. Token-level TIS fails in our complex TIR experiments, but it can prevent collapse in simpler reasoning RL, where the mismatch is smaller. In on-policy GRPO and RLOO experiments (Figure 12), token-level TIS prevented the collapse and let training run much longer, but it brought little or no gain in peak test accuracy: none for GRPO or for Qwen3-14B with RLOO, and a small gain for Qwen3-8B with RLOO. Accuracy plateaued and tended to sag late in training, likely because of the remaining gradient bias.


TIS prolongs training but can still be unstable. We ran an on-policy TIR experiment from scratch on L20 GPUs with sequence-level TIS ($C=2$). As Figure 13 shows, it prevented a complete collapse, but the reward kept fluctuating after reaching a plateau, and test performance did not exceed the peak the vanilla run reached before it crashed.

4.3 Our Method: Masked Importance Sampling (MIS)
To improve on TIS, we propose masked importance sampling (MIS): keep the sequence-level ratio, but mask the policy loss of every sequence whose ratio exceeds the threshold $C$, i.e. $\rho(y|x) \gets \rho(y|x)\, \mathbb{I}\{\rho(y|x) \le C\}$. TIS keeps such a sequence with its weight capped at $C$; MIS removes it from the update. The result is an upper-sided hard trust region at the level of the sequence.
Which tail the mask cuts. The mask removes sequences on which the trainer is far more likely than the sampler ($\rho > C$). The pathology of §3.2 is the opposite tail, $\rho \ll 1$, where the trainer assigns far lower probability; there the importance weight itself shrinks the sequence’s contribution toward zero. The geometric form, Geo-MIS, is two-sided and length-normalized: it keeps a sequence only when $C_{\text{low}} \le \rho^{1/T} \le C_{\text{high}}$, which removes the low tail outright as well.
Geo-MIS applies the mask to the per-token geometric mean, on both sides. Responses of very different lengths with the same per-token drift get the same verdict.
MIS in practice. The ratio is a product over hundreds of tokens, so compute it in log space, over model-generated tokens only (tool-response tokens are excluded, as in vllm-kl):
The trainer’s log-probabilities come from the forward pass before the update (old_log_probs), so the weight carries no gradient. A minimal sketch, in the style of the K3 snippet above:
log_ratio = old_log_probs - rollout_log_probs # log pi_fsdp - log pi_vllm, per token
seq_log_ratio = (log_ratio * response_mask).sum(dim=-1) # log rho(y|x), model tokens only
keep = seq_log_ratio <= math.log(C) # MIS: mask sequences with rho > C
seq_weight = torch.exp(seq_log_ratio.clamp(max=math.log(C))) * keep # in [0, C]; masked -> 0
pg_loss = pg_loss * seq_weight.unsqueeze(-1) # scale each sequence's per-token loss
Results. As Figure 14 shows, on L20 GPUs MIS trained for more than 700 steps where the uncorrected run collapsed near step 280. It raised the peak training reward from about 0.56 to 0.64 and matched the uncorrected run’s peak test accuracy (0.70 vs. 0.68), well above Seq-TIS (about 0.61). It was not free of instability: its reward dipped to about 0.37 near step 440 before recovering. The length-invariant geometric form is given in §4.4 and developed further in Part 3.

Token-level MIS vs. sequence-level MIS. Finally, we compared token-level and sequence-level MIS. Figure 15 shows that both keep the gradient norm small, but the token-level MIS run still collapses: its reward falls from about 0.4 to below 0.2 by step 160, while the sequence-level run keeps improving through step 400. In our long-horizon tool-use runs, only the sequence-level correction was reliable.

4.4 Geo-MIS and Trust Region Masking
Geo-MIS masks on the per-token geometric mean of the ratio. This makes the trust region independent of length and turns it into a bound on an estimate of the mean per-token KL. Trust Region Masking computes that KL exactly and adds a maximum. This section is analysis: the experiments above use the product form of §4.3.
Why the product form needs a length correction. $\log\rho(y|x) = \sum_t \log\rho_t$ is a sum over the $T$ model-generated tokens of the response, so it scales with length. A per-token log-ratio of $0.01$ gives $\rho = e^{1} \approx 2.7$ at $T = 100$ and $\rho = e^{10} \approx 22{,}000$ at $T = 1000$. A fixed threshold $C$ therefore tests long responses far more strictly than short ones, whatever their per-token quality.
Geo-MIS. Take the geometric mean of the per-token ratios and mask on both sides:
$$ \begin{gathered} \rho_{\mathrm{geo}}(y|x) = \rho(y|x)^{1/T} = \exp\Big(\frac{1}{T}\sum_{t \in \mathcal{T}_{\mathcal{M}}(y)} \log\rho_t\Big), \qquad T = |\mathcal{T}_{\mathcal{M}}(y)|, \\ \rho_{\mathrm{geo}}(y|x) \gets \rho_{\mathrm{geo}}(y|x)\,\mathbb{I}\{C_{\text{low}} \le \rho_{\mathrm{geo}}(y|x) \le C_{\text{high}}\}. \end{gathered} $$If every token has ratio $r$, then $\rho_{\mathrm{geo}} = r$ at any length. This is the form released in VeRL 0.6.0 (rollout_is_level="geometric", rollout_is_mode="mask"), where $C_{\text{low}}$ defaults to $1/C_{\text{high}}$. Part 3 calls the mask Geo-Mask and current VeRL calls it Geo-RS; both also apply it without a weight, or with per-token weights in place of $\rho_{\mathrm{geo}}$. With seq_log_ratio from the MIS sketch above, the lines after it become:
n_tokens = response_mask.sum(dim=-1).clamp(min=1) # T: model tokens per response
geo_log_ratio = seq_log_ratio / n_tokens # log rho_geo: mean per-token log-ratio
keep = (geo_log_ratio >= math.log(C_low)) & (geo_log_ratio <= math.log(C_high))
seq_weight = torch.exp(geo_log_ratio) * keep # Geo-MIS weight; masked -> 0
pg_loss = pg_loss * seq_weight.unsqueeze(-1)
Step 1: $-\log\rho_{\mathrm{geo}}$ is a one-sample estimate of the mean KL. Write $D_t =$ $\mathrm{KL}\big(\pvllm(\cdot|x,y_{\lt t})\,\|$ $\pfsdp(\cdot|x,y_{\lt t})\big)$ for the KL divergence from the sampler to the trainer at the context of token $t$. The token $y_t$ was drawn from $\pvllm$, so by the definition of the KL divergence
$$ \mathbb{E}_{y_t \sim \pvllm(\cdot|x,y_{\lt t})}\big[-\log\rho_t\big] = \sum_{v} \pvllm(v|x,y_{\lt t}) \log\frac{\pvllm(v|x,y_{\lt t})}{\pfsdp(v|x,y_{\lt t})} = D_t \;\ge\; 0 . $$Averaging over the response splits $-\log\rho_{\mathrm{geo}}$ into the mean KL along it and zero-mean sampling noise:
$$ -\log\rho_{\mathrm{geo}}(y|x) = \frac{1}{T}\sum_{t}\big(-\log\rho_t\big) = \underbrace{\frac{1}{T}\sum_{t} D_t}_{\text{mean KL along } y} + \underbrace{\frac{1}{T}\sum_{t}\xi_t}_{\text{sampling noise}}, $$where $\xi_t = -\log\rho_t - D_t$ has mean zero given the context $(x, y_{\lt t})$.
This is vllm-kl in its plain log-ratio form (§3.1), computed on one response instead of a batch. The product form is the same statement about the total: the expectation of $-\log\rho(y|x)$ under the sampler is the KL divergence between the two engines’ distributions over whole responses, which by the chain rule is the sum of the expected token-level KLs and so grows with $T$. MIS thresholds an estimate of that total, and Geo-MIS an estimate of its per-token mean.
Step 2: the band is a trust region on that estimate. Taking logarithms,
$$ C_{\text{low}} \le \rho_{\mathrm{geo}} \le C_{\text{high}} \iff -\log C_{\text{high}} \;\le\; -\log\rho_{\mathrm{geo}} \;\le\; \log\frac{1}{C_{\text{low}}} . $$The right-hand inequality caps the estimated mean KL at $\log(1/C_{\text{low}})$ nats per token. It is the side that removes the low-probability tail of §3.2. The left-hand inequality exists because a one-sample estimate of a non-negative quantity can be negative; it removes responses on which the trainer is far more confident than the sampler, the tail that the product-form mask $\rho \le C$ cuts. With $C_{\text{low}} = 1/C_{\text{high}}$ the band reads $|\log\rho_{\mathrm{geo}}| \le \log C_{\text{high}}$. For example, $C_{\text{high}} = 1.001$ allows about $10^{-3}$ nats per token, the scale of vllm-kl in our H20 batches (Group 1 in §3.2).
Step 3: Trust Region Masking computes the same quantity exactly, and adds a maximum. Trust Region Masking (TRM, ICML 2026) stores the sampler’s logits at rollout time, so $D_t$ is computed over the full vocabulary in the training forward pass instead of being estimated from the one sampled token. It masks a sequence with two criteria:
$$ \frac{1}{T}\sum_{t} D_t \le \delta_{\mathrm{avg}} \quad \text{(mean KL)}, \qquad\qquad \max_{t} D_t \le \delta \quad \text{(max KL)}. $$- The mean-KL criterion is the exact version of Geo-MIS. The noise term of Step 1 is gone and the statistic is non-negative, so a single threshold replaces the two-sided band, with $\delta_{\mathrm{avg}}$ in the role of $\log(1/C_{\text{low}})$. Like Geo-MIS, it does not reject long responses more often than short ones.
- The max-KL criterion is what the guarantee needs. The paper’s error bounds depend on the largest token-level KL over all contexts, and a mean cannot control it: a response whose mean KL is below $\delta_{\mathrm{avg}}$ can still contain one token with a KL as large as $T\delta_{\mathrm{avg}}$. A maximum, in turn, rejects long responses more often. In practice the paper combines the two: the maximum catches single-token outliers and the mean limits accumulated drift.
- Without stored logits, TRM falls back to sample-based estimators. For the mean it uses $k_3(\rho_t) = \rho_t - 1 - \log\rho_t$, which is non-negative and unbiased for $D_t$ (the estimator behind
vllm-klin §3.1), and for the maximum a symmetric function of $\log\rho_t$. Geo-MIS is the mean criterion with the $k_1$ estimator, $-\log\rho_t$, in place of $k_3$. - The weights differ. Inside an accepted sequence TRM weights each token by its own ratio $\rho_t$, where Geo-MIS weights the whole sequence by $\rho_{\mathrm{geo}}$.
Many small deviations. No single token stands out, so the max criterion passes; the mean catches the accumulated drift.
| Method | Statistic for one response | Kept when | Weight if kept |
|---|---|---|---|
| MIS (this post) | $\log\rho = \sum_t \log\rho_t$; $-\log\rho$ estimates the total KL | $\rho \le C$ | $\rho$ |
| Geo-MIS (VeRL 0.6.0) | $\log\rho_{\mathrm{geo}} = \frac{1}{T}\sum_t \log\rho_t$; $-\log\rho_{\mathrm{geo}}$ estimates the mean KL | $C_{\text{low}} \le \rho_{\mathrm{geo}} \le C_{\text{high}}$ | $\rho_{\mathrm{geo}}$ |
| TRM, mean KL | $\frac{1}{T}\sum_t D_t$, exact | at most $\delta_{\mathrm{avg}}$ | $\rho_t$ per token |
| TRM, max KL | $\max_t D_t$, exact | at most $\delta$ | $\rho_t$ per token |
5. Other Things We Tried: Engine and Hardware Settings
Before correcting for the mismatch in the loss, we tried to remove it at its source. The table summarizes the six changes; the details follow.
| What we changed | Setting | What happened | Verdict |
|---|---|---|---|
FP32 lm_head in vLLM | L20, resumed at step 200 | vllm-kl still exploded and the run collapsed | Did not help |
| Chunked prefill off | L20, resumed at step 200 | vllm-kl spiked to about 1.4; rewards fell to near zero | Did not help |
enforce_eager, free_cache_engine | H100, Qwen3-4B-Base, reasoning RL | No effect, but vllm-kl stayed at or below 1e-3 in every run | Inconclusive at low mismatch |
Sampling top-p 0.98 to 0.999 | L20, 100 steps | Fewer vllm-kl spikes, slower reward growth | A diagnostic, not a fix |
| H20 instead of L20 | From scratch | Much smaller mismatch; trained stably for much longer | Helped |
| Cascade attention off | A100 | vllm-kl from about 3e-2–1e-1 down to about 1e-3 | Helped on A100 |
Top-p sampling is a diagnostic rather than a fix: it confirms that low-probability tokens drive the mismatch, but it slows learning. Changing GPUs or attention kernels helps only where they are the source of the mismatch. None of these replaces the correction of §4.
5.1 Sampler Settings That Did Not Help
Use an FP32 LM head
Inspired by the MiniMax-M1 technical report and the blog post Your Efficient RL Framework Secretly Brings You Off-Policy RL Training, we patched vLLM to cast lm_head to fp32. In our experiments, the mismatch persisted after the patch and training still collapsed. Figure 16 shows a failed on-policy run on L20 with a bf16 lm_head in vLLM, and a run resumed from its step-200 checkpoint with an fp32 lm_head. Both ultimately collapsed, and the fp32 run still showed a vllm-kl explosion.

lm_head in the vLLM engine. Left: vllm-kl. Right: training rewards. We resumed training with an fp32 lm_head (green) from step 200 of the failed run with a bf16 lm_head (red).Disable chunked prefill
We also resumed training from step 200 of the failed bf16 lm_head run above with chunked prefill disabled, to see whether it would resolve the crash. It did not prevent a severe crash: vllm-kl still spiked to about 1.4 near step 220, and rewards fell to near zero around step 237, as the original run’s did, before partly recovering by the end of the run at about step 257 (Figure 17).

vllm-kl. Right: training rewards.Toggle enforce_eager and free_cache_engine
VeRL’s official DAPO recipe mentions that enabling CUDA graphs (enforce_eager=False) may degrade model performance. To see whether it affects the training-inference mismatch, we ran an ablation on the vLLM hyperparameter enforce_eager together with free_cache_engine, in reasoning RL: on-policy GRPO on H100 GPUs with Qwen3-4B-Base, over all four combinations of the two flags set to True or False, evaluated on AIME24. Figure 18 shows that neither flag has a significant effect on the training-inference mismatch or on test performance. In these runs vllm-kl stayed at or below about 1e-3 in every setting, though, so this ablation could not detect an effect at the mismatch levels where collapse occurs.

enforce_eager (E) and free_cache_engine (F). Left: vllm-kl. Right: accuracy on AIME24.5.2 Top-p Sampling: A Diagnostic
Low-probability tokens under the vLLM policy are where the mismatch is most severe. To test this directly, we ran on-policy GRPO on L20 GPUs with the vLLM sampling top-p set to 0.98, 0.99 and 0.999, without importance sampling. A smaller top-p removes the rarest tokens at sampling time, and Figure 19 confirms that it reduces the vllm-kl spikes. But truncation is itself a mismatch: the sampler now draws from a top-p-truncated distribution while the trainer optimizes the full $\pfsdp$, and vllm-kl, computed from the logged log-probabilities, need not reflect this shift. Without an IS correction this adds bias, and in Figure 19 the reward rises more slowly as top-p decreases. None of these 100-step runs collapsed, so we read top-p as evidence about where the mismatch comes from rather than as a fix.

top-p: on-policy GRPO with top-p of 0.98, 0.99 and 0.999. A smaller top-p generally gives a smaller vllm-kl and slower reward growth. Left: vllm-kl. Right: training rewards.5.3 Hardware and Kernels
Finding 4 (§3.4) says that the hardware sets the size of the mismatch. Two changes on that side helped.
Use another GPU series
After finding that the training–inference mismatch on H20 GPUs was much smaller than on L20 GPUs, we moved all our TIR experiments to H20, which greatly reduced training crashes. Figure 20 shows two on-policy GRPO runs trained from scratch with identical configurations on L20 and H20. The H20 run trained stably for much longer and performed better.

Disable cascade attention in vLLM
Following this flash-attention pull request, we set disable_cascade_attn=True when initializing the vLLM engine, and found that it greatly reduces the training-inference mismatch on A100 GPUs. We ran two on-policy GRPO experiments with Qwen3-14B-Base on A100 GPUs, with disable_cascade_attn set to True and False. As Figure 21 shows, disabling cascade attention brought vllm-kl down from about 3e-2–1e-1 to around 1e-3. With cascade attention enabled, the training reward stayed near 0.01 from the first step, so the rollouts were effectively broken from the start rather than degrading over training; with it disabled, training proceeded normally.

vllm-kl. Right: training rewards.6. Conclusion and Key Takeaways for Practitioners
The training-inference mismatch is not a niche bug. It follows from the pursuit of throughput, and it matters most in reasoning and agentic RL. The findings are listed in the box at the top; this is what they mean in practice.
- Expect some mismatch. Fast inference kernels and training kernels differ for good reasons. Bitwise-consistent training and inference is possible, but it costs throughput, so most stacks will keep some mismatch.
- Monitor it.
vllm-klis an early warning. Track it together with perplexity and gradient norm, and watch multi-turn tool-use runs first: out-of-distribution tool responses raise the share of low-probability tokens, where the two engines disagree most. - Validate on your target hardware. The same code can collapse on one GPU series and train much longer on another.
- Correct at the sequence level, and prefer masking. In our multi-turn tool-use runs token-level corrections still collapsed; in simpler reasoning RL they prevented collapse but gave little or no gain in peak accuracy. Among the corrections we tried on L20, MIS trained longest and reached the highest reward. What we recommend today is a length-normalized sequence mask: Geo-MIS (DeepSeek-V3.2 uses a closely related mask), or Trust Region Masking when the sampler’s logits are stored (§4.4).
We hypothesize that the mismatch between inference engines (e.g., vLLM) and training frameworks (e.g., Megatron-LM) will also be a significant issue for Mixture-of-Experts (MoE) RL, a direction for future work.