Zero-mismatch RL on DeepSeek-V4 & DeepSeek-V4.1 with RL-Kernel
Last updated: 12/04/2026.
RL-Kernel runs both sides of a GRPO run on the same
batch-invariant kernels: the actor as a verl engine backend (rlkernel) and the rollout’s
model code as a vLLM plugin. Every sampled token’s rollout log-prob is then bit-identical to
the actor’s recompute, at every step, while the LoRA adapters train. verl and vLLM need no
change: RL-Kernel plugs in through model.external_lib (an EngineRegistry backend) and
vLLM’s worker classes.
Supported: DeepSeek-V4-Flash and DeepSeek-V4.1-Flash, LoRA, Hopper (SM90). The example script is
examples/tuning/lora/run_deepseek_v4_rlkernel.sh.
Pinned versions
The example is tested with this set; run it with these commits. verl’s main does not yet
load DeepSeek-V4.1 (transformers does not know deepseek_v41, and its tokenizer ships no chat
template); verl-project/verl#7483 adds both, so verl is pinned to a commit of that PR.
Component |
Commit |
|---|---|
verl |
|
RL-Kernel |
|
vLLM, DeepSeek-V4 |
|
vLLM, DeepSeek-V4.1 |
|
DeepGEMM |
|
FlashMLA |
|
git clone https://github.com/verl-project/verl.git verl-pinned
git -C verl-pinned fetch origin 8c047f4d24f333c9106feefa527f711679878ddc
git -C verl-pinned checkout 8c047f4d24f333c9106feefa527f711679878ddc
export VERL_ROOT=$PWD/verl-pinned
Environment:
DeepSeek-V4: RL-Kernel’s
scripts/verl_e2e_lora/setup.sh rlkernelbuilds it (torch 2.13, the vLLM fork, DeepGEMM, FlashMLA, RL-Kernel with its CUDA extension) from a lock file. vLLM’sds4_bi_topklibrary (DS4_BI_TOPK_LIB) is built by the same script.DeepSeek-V4.1: the same environment with torch 2.14.0, vLLM
3f86db3built from source, DeepGEMM and FlashMLA rebuilt against torch 2.14, flash-attn removed (built for torch 2.13), and RL-Kernel’s extension rebuilt.RL-Kernel installed with
pip install -e .: itsvllm.general_pluginsentry point loads the rollout plugin in every vLLM process.Hopper (SM90) GPUs.
Turning it on
MODEL_PATH=/models/DeepSeek-V4-Flash DATA=/data/dapo \
bash examples/tuning/lora/run_deepseek_v4_rlkernel.sh
The script picks the family from the checkpoint’s architectures. The RL-Kernel part is
these overrides (<family> is dsv4 or dsv41):
"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.<family>.vllm_worker.RlkWorker \
+actor_rollout_ref.rollout.engine_kwargs.vllm.worker_extension_cls=rl_engine.integrations.<family>.vllm_worker.RlkWorkerExtension
Setting |
Why |
|---|---|
|
The |
|
Every worker imports it, which registers the |
|
The adapters live in RL-Kernel. Keep |
|
The rollout loads the frozen base weights from the checkpoint; only the BF16 adapters are synced. The plugin refuses |
|
The rollout returns its log-probs for the comparison. |
|
The vLLM worker that runs RL-Kernel’s model and receives the adapters. It sleeps at level 1, so the base weights survive the training phase. |
Environment variables, set by the script:
DeepSeek-V4:
RL_KERNEL_DSV4_ROLLOUT=1;RL_KERNEL_DSV4_LORA=rank,alpha(adapters reserved at load, for the rollout’s CUDA graphs);VLLM_BATCH_INVARIANT=1andVLLM_DS4_DECODE_KERNEL=sparse.DeepSeek-V4.1:
RL_KERNEL_DSV41_ROLLOUT=1, plusrollout.enable_prefix_caching=Falseandactor.rlkernel.max_model_lenequal torollout.max_model_len.The full model at expert parallel 8:
RL_KERNEL_DSV4_PERSIST_W8=0.
DeepSeek’s tokenizers ship no chat template. The script renders prompts with verl’s DeepSeek
encoder (data.continuous_token), which does not depend on RL-Kernel.
Checking it
training/rollout_logprobs_mismatch_count counts the response tokens whose rollout and
recomputed FP32 log-probs differ. With this setup it is 0 at every step. A nonzero count at
step 1 points to a kernel or configuration difference; one that starts later points to the
adapter sync.
Results
8 x H200, 100 steps each, DAPO-Math-17k with the DAPO reward:
Run |
Mismatched tokens per step |
|---|---|
RL-Kernel, DeepSeek-V4-Flash (43 layers) |
0 at every step |
RL-Kernel, DeepSeek-V4.1-Flash (40 layers) |
0 at every step |