Zero-mismatch LoRA GRPO with verl on DeepSeek-V4 / V4.1¶
RL-Kernel runs both sides of a verl GRPO run on the same batch-invariant kernels: the
actor (a verl engine backend, rlkernel) and the rollout's model code (a vLLM plugin).
Each sampled token's rollout log-prob is then bit-identical to the actor's recompute, at
every step, while the LoRA adapters change. verl and vLLM stay unmodified: RL-Kernel plugs
in through extension points verl already has.
Requirements¶
- verl pinned to
8c047f4d24f333c9106feefa527f711679878ddc, a commit of verl #7483. verl's main does not load DeepSeek-V4.1 yet (nodeepseek_v41config fallback, no V4.1 prompt builder); #7483 adds both. The commit is no longer on #7483's branch: fetch it by SHA (git fetch https://github.com/verl-project/verl.git 8c047f4d...). The same guide and an example script on the verl side, with the full pinned set: RL-Align/verl PR 8 (docs/advance/rl_kernel_zero_mismatch.md,examples/tuning/lora/run_deepseek_v4_rlkernel.sh,VERL_ROOTselects the pinned checkout). - vLLM: the fork
ISEEKYAN/vllm@1a6542cfor DeepSeek-V4, vLLM main3f86db3for V4.1. - RL-Kernel installed with
pip install -e .(itsvllm.general_pluginsentry point loads the rollout plugin in every vLLM process) and its_Cextension built. - Hopper (SM90).
scripts/verl_e2e_lora/setup.sh rlkernelbuilds the full environment.
Turning it on¶
Add these to verl's main_ppo command (<family> is dsv4 or dsv41, after the
checkpoint's architectures):
export RL_KERNEL_DSV4_ROLLOUT=1 RL_KERNEL_DSV4_LORA=$RANK,$ALPHA # dsv4
export RL_KERNEL_DSV41_ROLLOUT=1 # dsv41
python3 -m verl.trainer.main_ppo \
"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=$RANK \
actor_rollout_ref.actor.rlkernel.lora_alpha=$ALPHA \
actor_rollout_ref.rollout.name=vllm \
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 \
... # data, reward, batch and optimizer settings as usual
| Setting | Why |
|---|---|
hydra.searchpath, model_engine=rlkernel |
The rlkernel engine's config group (actor.rlkernel.*). |
model.external_lib |
Every worker imports the module, which registers the rlkernel backend in verl's EngineRegistry. |
actor.rlkernel.lora_rank / lora_alpha |
The adapters live in RL-Kernel. Leave verl's model.lora_rank at 0, or verl 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, verl's default. |
rollout.calculate_log_probs=True |
The rollout returns its log-probs, which verl compares with the actor's. |
worker_cls / worker_extension_cls |
The vLLM worker that runs RL-Kernel's model and receives the adapters. It keeps sleep level 1, so the base weights survive the training phase. |
RL_KERNEL_DSV4_LORA (DSv4) |
Reserves the adapters at load, which the rollout's CUDA graphs need. |
DeepSeek-V4.1 also needs actor_rollout_ref.rollout.enable_prefix_caching=False and
actor_rollout_ref.actor.rlkernel.max_model_len equal to rollout.max_model_len.
DeepSeek's tokenizers ship no chat template: verl renders the prompts with its DeepSeek
encoder (+data.continuous_token.enable=True
+data.continuous_token.model_family=deepseekv4 or deepseekv41). This is independent of
RL-Kernel.
The launcher sets all of this, picking the family from the checkpoint:
Its header lists the knobs: parallelism (ACTOR_EP, ROLLOUT_DP), GRAPH=1 for CUDA
graphs in the rollout, RECOMPUTE=1 for activation recompute, and BI=0 (DSv4 only), the
ablation with the rollout's batch invariance off.
Checking it¶
verl logs training/rollout_logprobs_mismatch_count every step: the response tokens whose
rollout and recomputed FP32 log-probs differ. It is 0 at every step when the setup is right.
A nonzero count at step 1 means a kernel or configuration difference; one that starts later
means the adapter sync.
Results¶
8 x H200, 100 steps each, the DAPO math reward:
| Run | Mismatched tokens per step |
|---|---|
| RL-Kernel, DeepSeek-V4-Flash (43 layers) | 0 at every step |
| verl #7483, DeepSeek-V4-Flash (43 layers) | 616k on average |
| RL-Kernel, DeepSeek-V4.1-Flash (40 layers) | 0 at every step |
| verl with NeMo Automodel, DeepSeek-V4.1-Flash (8-layer cut) | 523k on average |
The design documents (docs/architecture/dsv4-design.md section 10,
docs/architecture/dsv41-design.md section 10.1) have the setup, timing and curves.