verl × RL-Kernel: Zero Train-Rollout Mismatch on DeepSeek-V4 and V4.1
RL-Kernel plugs into verl through its existing extension points, and the rollout and trainer log-probs of DeepSeek-V4-Flash and V4.1-Flash agree bit for bit at every step of 100-step LoRA GRPO runs.

On DeepSeek-V4-Flash (43 layers) and DeepSeek-V4.1-Flash (40 layers), LoRA GRPO runs in verl where every response token’s rollout log-prob is bitwise identical to the trainer’s recompute, at every one of 100 steps, while the adapters change. The kernels come from RL-Kernel ; verl and vLLM are unmodified.
We first explain why the mismatch matters and how RL-Kernel plugs into verl, then what makes DeepSeek-V4 hard to keep batch-invariant, and then follow both models through 100 steps against verl’s existing DeepSeek-V4 paths.
Key takeaways
- Zero mismatch, at full model size. verl’s
training/rollout_logprobs_mismatch_countis 0 at all 100 steps on DeepSeek-V4-Flash (43 layers) and DeepSeek-V4.1-Flash (40 layers), each on one node of 8 × H200. The DeepSeek-V4 LoRA recipe of verl#7483 mismatches on 616k response tokens per step on the same setup. - No change to verl or vLLM. RL-Kernel enters through
model.external_lib(an engine backend) and vLLM’sworker_cls/worker_extension_cls. The example and guide are in verl#9033 . - The kernels are what closes the gap. With batch invariance turned off in our rollout only, 156k to 437k tokens per step mismatch again.
- It costs time per step. A DeepSeek-V4 step takes 296 s against the baseline’s 228 s; the trainer side is faster, generation is slower.

Why mismatch matters
The rollout engine samples a token and records its log-prob; the trainer recomputes that log-prob with the same weights. Before any update the two should be equal, so the importance ratio is exactly 1. When they differ, the ratio carries numerical noise that the optimizer cannot tell apart from a real policy change. On a mixture-of-experts model a last-bit difference can also flip a routing decision, and the token then goes through different experts.
verl reports the gap directly: training/rollout_logprobs_mismatch_count counts the
response tokens whose rollout and recomputed FP32 log-probs differ, with no tolerance.
This post is about driving that number to 0 and keeping it there.
How it plugs into verl
Both sides of the run use one set of batch-invariant kernels: the trainer through an engine backend, the rollout through a vLLM model plugin. Nothing in verl or vLLM is patched; everything goes through extension points verl already has.
| Piece | verl extension point |
|---|---|
| Trainer | actor_rollout_ref.model.external_lib imports RL-Kernel’s module in every worker, which registers an rlkernel backend in verl’s EngineRegistry; model_engine=rlkernel selects it, with its config group added through hydra.searchpath. |
| Rollout | rollout.engine_kwargs.vllm.worker_cls / worker_extension_cls give vLLM a worker that runs RL-Kernel’s model code and receives the adapters. vLLM keeps its scheduler, KV cache management and sampling. |
| Weight sync | The rollout loads the frozen base weights from the checkpoint (rollout.load_format=auto); only the BF16 LoRA adapters are synced each step. |
| Check | rollout.calculate_log_probs=True, so verl compares the two log-probs every step. |
The switch is one block of overrides:
"hydra.searchpath=[pkg://rl_engine.integrations.dsv4.verl_config]" \
model_engine=rlkernel \
actor_rollout_ref.model.external_lib=rl_engine.integrations.dsv4.verl_engine \
actor_rollout_ref.actor.rlkernel.lora_rank=16 \
actor_rollout_ref.actor.rlkernel.lora_alpha=32 \
actor_rollout_ref.rollout.load_format=auto \
actor_rollout_ref.rollout.calculate_log_probs=True \
+actor_rollout_ref.rollout.engine_kwargs.vllm.worker_cls=rl_engine.integrations.dsv4.vllm_worker.RlkWorker \
+actor_rollout_ref.rollout.engine_kwargs.vllm.worker_extension_cls=rl_engine.integrations.dsv4.vllm_worker.RlkWorkerExtension
Two details took time to get right:
- The LoRA rank goes in
actor.rlkernel.lora_rank, andmodel.lora_rankstays 0. A nonzeromodel.lora_rankturns on vLLM’s own LoRA in the rollout, which would bypass RL-Kernel’s model code. - The rollout sleeps at level 1. Since verl then sees no LoRA, it asks the rollout for sleep level 2, which drops the base weights; RL-Kernel’s worker keeps level 1 so the base weights survive the training phase and only the adapters move.
How this differs from fsdp_config.batch_invariant
fsdp_config.batch_invariant makes an FSDP actor run vLLM’s batch-invariant
kernels. Here neither side runs vLLM’s kernels: RL-Kernel supplies the attention, MoE,
mHC, quantized linear and log-prob kernels for both, which is what DeepSeek-V4’s
compressed sparse attention, FP4 experts and mHC need.What makes DeepSeek-V4 hard
A kernel is batch-invariant when a token’s result does not depend on what else is in the batch. Most fast kernels are not: they pick split counts, workspaces and tile shapes from the batch, and each choice changes the order of a floating-point sum. DeepSeek-V4 adds several places where that matters:
- mHC mixes four residual streams through a controller GEMM over K = 16,384 per token, followed by Sinkhorn normalization; a batch-dependent split changes every stream.
- Compressed sparse attention selects the top 512 compressed KV entries per query. A tie in the top-k or a different accumulation order changes the result, and a KV entry rounded differently affects every later token that reads it.
- The router is discrete: a last-bit difference in a score can change the sixth expert.
- The MXFP4 routed experts have no batch-invariant fused kernel on Hopper; existing ones assign rows to slots with atomics.
RL-Kernel fixes the order of every sum in the kernel, sizes every workspace from the config rather than the batch, runs prefill and decode through the same code path, and across GPUs only moves bytes (data-parallel attention with expert-parallel MoE, exchanged in a fixed order). Expert parallel 2, 4 and 8 reproduce the bytes of a single GPU. The module-by-module account is in RL-Kernel’s DeepSeek-V4 post .
DeepSeek-V4.1 reuses most of these kernels. It adds MXFP8 dense weights, a single-pass mHC, compressed KV and top-k indices shared across layers, and the Engram n-gram memory; the DeepSeek-V4.1 post covers what changed.
Results
DeepSeek-V4-Flash
Both runs train all 43 layers on one node of 8 × H200 for 100 GRPO steps: DAPO-Math-17k with verl’s DAPO reward, 32 prompts × 16 responses per step, responses up to 4,096 tokens, LoRA rank 16, AIME 2024 with greedy decoding every 10 steps. They share the verl commit, data, reward, batch, optimizer and PPO settings. The baseline is the DeepSeek-V4 LoRA recipe of verl#7483, each side with its own LoRA target set.
| RL-Kernel + verl | verl#7483 recipe | |
|---|---|---|
| Trainer | RL-Kernel engine backend, EP 8 | Megatron, EP 8 |
| Rollout | vLLM + RL-Kernel model plugin, DP 8 / EP 8 | vLLM 0.32 with its own LoRA, DP 8 / EP 8 |
| Mismatched response tokens per step | 0 at all 100 steps | 616k on average (344k to 1.01M) |
| Mean \(\lvert\Delta \log p\rvert\) per response token | 0 | 0.096 |
| AIME 2024, step 0 → 100 | 0.63 → 0.80 | 0.61 → 0.65 |
| Time per step | 296 s | 228 s |
The two runs also differ in how training behaved (Figure 1). The baseline’s 10-step mean reward ranges from about 0.12 to 0.49 and its AIME 2024 accuracy dips to 0.56 at step 40; the RL-Kernel run’s reward stays between about 0.48 and 0.68. These are single runs, and the two LoRA configurations are not identical, so we read this as an observation rather than a controlled result. To isolate the kernels, we also turned batch invariance off in our rollout only and kept everything else: 156k to 437k tokens per step mismatched again.
DeepSeek-V4.1-Flash

All 40 layers on 8 × H200, 100 GRPO steps, DAPO-Math-17k, 32 prompts × 8 responses, responses up to 2,048 tokens, LoRA rank 16, decode CUDA graphs in the rollout (Figure 2).
| RL-Kernel + verl | verl with NeMo Automodel | |
|---|---|---|
| Model that fits on 8 × H200 | all 40 layers | first 8 layers only |
| Mismatched response tokens per step | 0 at all 100 steps | 523k on average (8-layer cut) |
| Time per step | 175 s | not comparable |
verl’s native DeepSeek-V4.1 path dequantizes the routed experts to BF16 (about 1,087 GB for 40 layers), so only an 8-layer cut fits, and that cut cannot generate a valid response. We take only its mismatch count from it, as a reference.
Try it
The example is examples/tuning/lora/run_deepseek_v4_rlkernel.sh from
verl#9033
; it picks V4 or V4.1 from
the checkpoint.
VERL_ROOT=/path/to/verl-pinned MODEL_PATH=/models/DeepSeek-V4-Flash DATA=/data/dapo \
bash examples/tuning/lora/run_deepseek_v4_rlkernel.sh
Pinned versions
8c047f4d of that pull
request, which VERL_ROOT puts first on PYTHONPATH. The guide
(docs/advance/rl_kernel_zero_mismatch.md in verl#9033) lists the full tested set and
how to build the environment.Limitations and what’s next
- Hopper only, one node. The kernels target SM90; every result here is from one node of 8 × H200. Other architectures need their own validation.
- Rollout speed. A DeepSeek-V4 step takes 1.3× the baseline’s time. The trainer side is faster; generation is 1.77× slower per token, of which batch invariance accounts for 12 to 14% and RL-Kernel’s rollout stack for the rest.
- One parallel layout. Data-parallel attention with expert-parallel MoE; tensor and context parallelism inside attention are not supported yet.
- LoRA only. Base weights stay frozen and all routed experts share one adapter. Per-expert adapters and full-parameter training are next.
Related work
- DeepSeek-V4-Flash RL on AMD MI355X with verl , on this blog. The same model in verl on ROCm, with the training engine’s quantization matched to an FP8 rollout; the pull request behind it, verl#8505 , makes the log-probs bitwise equal with batch-invariance patches to vLLM and Megatron.
- verl#8403 : bitwise train and inference log-probs for DeepSeek-V4.1 LoRA with Megatron Lite and vLLM’s batch-invariant mode, on SM100 (GB200).
- VeXact and its paper, Diagnosing Training-Inference Mismatch in LLM Reinforcement Learning : a bitwise-aligned rollout engine for VeOmni FSDP in verl, for dense models and MoE models such as Qwen3-MoE and DeepSeek-V3.
- verl#8026
: the batch-invariant actor
forward for FSDP (
fsdp_config.batch_invariant). - No More Train-Inference Mismatch: Bitwise Consistent On-Policy Reinforcement Learning with vLLM and TorchTitan , vLLM and TorchTitan teams, November 2025.
- Defeating Nondeterminism in LLM Inference , Thinking Machines Lab, 2025. Batch invariance as the cause of run-to-run differences in inference.
- DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence , DeepSeek-AI, 2026. Section 3.3 describes DeepSeek’s own batch-invariant and deterministic kernels.
- RL-Kernel × vime × AMD: Bitwise Consistency Between Training and Rollout : RL-Kernel’s earlier work on Qwen3-8B, with the background on reduction order and rounding boundaries.
Acknowledgments
This work builds on verl , vLLM , DeepGEMM and FlashMLA, all used unmodified, and on the DeepSeek-V4 support in verl#7483.
Core contributors
Kai-Jie Lin , Vensen Mu(EmbeddedLLM) , Jian Zhang , Jiajie Li , Xiaosong Ma , Huihong Lu , Ryan Huang , Hsiu-I Liao , Loring Ni , Bignonia7 , Yizheng Jiao , nodeeeeee , why1te , Junyifannnn , carsontung666 , Yang Liu , quan-yi-ai , AlanX-Yan , bitborne , Endeavor-19 , Yuteng-Chen .