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

8c047f4d24f333c9106feefa527f711679878ddc (verl-project/verl#7483)

RL-Kernel

81e7314698afb15fbc0a579fbab7db6df2e10796 (RL-Align/RL-Kernel main)

vLLM, DeepSeek-V4

ISEEKYAN/vllm@1a6542cdebbaabbf9972c358de8d6baa54e46b0c, torch 2.13, CUDA 13.0

vLLM, DeepSeek-V4.1

vllm-project/vllm@3f86db3b2df84dc2e4d10b81da43afad132d66c6, torch 2.14, CUDA 13.0

DeepGEMM

e21c821f39a2056d68067a466c64ddc942200106

FlashMLA

a8f794d1251cbfd88a5011445dd5582289c727e4

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 rlkernel builds it (torch 2.13, the vLLM fork, DeepGEMM, FlashMLA, RL-Kernel with its CUDA extension) from a lock file. vLLM’s ds4_bi_topk library (DS4_BI_TOPK_LIB) is built by the same script.

  • DeepSeek-V4.1: the same environment with torch 2.14.0, vLLM 3f86db3 built 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 .: its vllm.general_plugins entry 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

hydra.searchpath, model_engine=rlkernel

The rlkernel engine’s config group (actor.rlkernel.*).

model.external_lib

Every worker imports it, which registers the rlkernel backend.

actor.rlkernel.lora_rank / lora_alpha

The adapters live in RL-Kernel. Keep model.lora_rank at 0: a nonzero value turns on vLLM’s own LoRA in the rollout.

rollout.load_format=auto

The rollout loads the frozen base weights from the checkpoint; only the BF16 adapters are synced. The plugin refuses dummy.

rollout.calculate_log_probs=True

The rollout returns its log-probs for the comparison.

worker_cls / worker_extension_cls

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=1 and VLLM_DS4_DECODE_KERNEL=sparse.

  • DeepSeek-V4.1: RL_KERNEL_DSV41_ROLLOUT=1, plus rollout.enable_prefix_caching=False and actor.rlkernel.max_model_len equal to rollout.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