MCPcopy Create free account
hub / github.com/RL-Align/RL-Kernel

github.com/RL-Align/RL-Kernel @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,486 symbols 5,984 edges 119 files ⚖ Apache-2.0 303 documented · 20% ● updated 4d agov0.1.1 · 2026-11-02★ 467136 open issues

Browse by type

⨍ Functions 1,290◇ Types & classes 193↳ Endpoints 3
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

RL-Kernel logo

RL-Kernel

Building cross-hardware and multi-model RL post-training infrastructure for kernel-level train–inference consistency.

Documentation RL-Align website Slack Follow RL-Align on LinkedIn Follow RL-Kernel on X WeChat WhatsApp Ask DeepWiki CUDA and ROCm supported Apache 2.0 license

Architecture · Current scope · Results · Hardware support · Quick start · Documentation

RL-Kernel is high-performance infrastructure for RL post-training. It provides deterministic operators for consistent numerical computation across rollout and training engines, together with hardware-specific kernels for faster execution and lower memory use in GRPO, PPO, and related workloads.

Today, the end-to-end path covers Qwen3-8B Dense with vime, vLLM, and Megatron-LM. Work on DeepSeek-V4 Flash MoE, Miles, and AReaL is ongoing.

Why RL-Kernel?

Rollout and training engines can produce different log probabilities for the same tokens and model weights because their kernels, batching, and reduction orders differ. Those differences enter the policy ratios and KL terms used by RL algorithms.

  • Exact train–inference consistency: deterministic operators keep rollout and training computations aligned. The published experiment records exact runtime LogP agreement across all 200 training steps.
  • RL operators: deterministic attention, dense FFN, LogP, GRPO and PPO objectives, and collectives cover the numerical boundaries in RL post-training.
  • Performance: fused computation and hardware-specific kernels reduce rollout time, memory use, and synchronization costs.
  • vime integration: vime orchestrates vLLM rollout and Megatron-LM training, with RL-Kernel supplying the operators used by both engines.
  • Hardware: NVIDIA SM90 and AMD gfx942 are supported. Ascend dav_c220 has partial operator coverage. Support for other hardware is in progress.

Repository layout

The directory and ownership guide describes models, contracts, shared operators, hardware backends, rollout/train engines, tests, CI and benchmark locations. See the Dense refactor acceptance checklist for CUDA/ROCm validation. Legacy import and launcher paths remain supported.

Architecture

RL-Kernel sits between execution engines and accelerator backends. Its runtime adapters select the operator implementation for each backend while keeping the same numerical contract across rollout and training.

The architecture below shows how orchestration frameworks, execution engines, RL-Kernel operators, and hardware backends fit together.

RL-Kernel global architecture

Current Scope and Roadmap

The end-to-end paths run Qwen3-8B Dense with vime, and DeepSeek-V4-Flash and DeepSeek-V4.1-Flash MoE with verl (see Quick Start).

Area Current Next
Model Qwen3-8B Dense; DeepSeek-V4-Flash and DeepSeek-V4.1-Flash MoE (LoRA) More MoE models
Orchestration vime, verl Miles and AReaL
Engines vLLM rollout; Megatron-LM training (Qwen3-8B), RL-Kernel's own engine (DeepSeek-V4 / V4.1) More rollout and training engines
Hardware Qwen3-8B: H100 and MI300X; DeepSeek-V4 / V4.1: H200 DeepSeek-V4 / V4.1 on ROCm

Benchmark Highlights

CUDA H100

Qwen3-8B H100 train/rollout mismatch count and maximum absolute LogP difference over 200 steps

Qwen3-8B H100 mean absolute train/rollout LogP difference over 200 steps

Qwen3-8B H100 200-step performance matrix

ROCm MI300X

Qwen3-8B ROCm train/rollout mismatch count and maximum absolute LogP difference over 200 steps

Qwen3-8B ROCm mean absolute train/rollout LogP difference over 200 steps

Qwen3-8B ROCm MI300X 200-step performance matrix

Hardware Support

RL-Kernel currently supports the following hardware targets.

Hardware Architecture Software Status
NVIDIA H100, H200, GH200 SM90 CUDA Supported
AMD Instinct MI300A, MI300X, MI325X gfx942 ROCm Supported
Huawei Ascend dav_c220 dav-2201 CANN 9.1.0 and Ascend C Partial
Moore Threads In development MUSA In progress

The published end-to-end benchmark was run on H100. The ROCm extension and backend checks were verified on MI300X. Ascend support is limited to dav_c220. Support for other hardware models is in progress.

Quick Start

Pick a model; each link goes to its commands.

Model Framework Hardware Result Guide
Qwen3-8B vime: Megatron-LM training, vLLM rollout 8 x H100 (CUDA), 8 x MI300X (ROCm) 0 mismatched tokens over 200 steps Blog
DeepSeek-V4-Flash verl: RL-Kernel engine, vLLM rollout, LoRA 8 x H200 (CUDA) 0 mismatched tokens over 100 steps, 43 layers Blog
DeepSeek-V4.1-Flash verl: RL-Kernel engine, vLLM rollout, LoRA 8 x H200 (CUDA) 0 mismatched tokens over 100 steps, 40 layers Blog

Qwen3-8B with vime

Use a compatible vime environment on an eight-GPU H100 or MI300X node. Clone the project and follow the installation guide for your CUDA or ROCm build:

git clone https://github.com/RL-Align/RL-Kernel.git

cd RL-Kernel

Complete the one-time CUDA setup or ROCm setup. Save the backend, Python, framework, model and data paths in .rlk-profile.json or select a profile with RLK_REPRO_PROFILE. No launcher edits are needed. Both backends then use the same command:

./rlk run --tp 4 --rollout-tp 4 --temperature 0.7 --top-p 0.95 \
  --lr 5e-7 --kl-coef 0.01 --max-response-len 6912 --max-tokens-per-gpu 4096 --steps 200

Training TP and rollout TP are independent: choose 1, 2, 4 or 8. Training CP defaults to 8 / TP; set --cp explicitly if needed. run waits, validates train/rollout LogP, and defaults to consistency mode without rollout-logprob reuse. Add --mode native for a native comparison, or replace run with plan to inspect the command without launching a job.

On ROCm, this command selects Triton chunked Attention and sparse top-p logprob/monitoring-entropy scoring. Training logprobs are independently recomputed and validation requires bitwise agreement with rollout. Apply the updated ROCm companion patches and rebuild the extension when updating. With the supplied ROCm profile, a three-step check measured 58.29 s/step versus native's 57.40 s (+1.55%), with zero raw-bit logprob mismatches. Use --steps 3 for that short check; timing depends on generated lengths and the environment, and the native execution-record limitation is documented below. See ROCm performance reproduction for the full comparison command, measurements and validation limits.

On CUDA, rollout CP and top-k are configurable too; this short check performs two real updates and validates their artifacts:

./rlk verify --tp 1 --rollout-tp 1 --rollout-cp 8 --temperature 0.7 --top-p 0.95 --top-k -1

Rollout TP × CP must divide eight. CUDA accepts top-k -1 (disabled) or a positive integer, and temperature 0 for greedy sampling. ROCm currently requires top-k -1 and positive temperature. ROCm rollout CP > 1 remains unvalidated, and verify is CUDA-only. See the CUDA/ROCm support table and measured H100 results for exact coverage.

DeepSeek-V4-Flash with verl

Hopper GPUs (H100 or H200); the full model needs 8 x H200. Setup builds vLLM from source and downloads a checkpoint of about 160 GB, so allow 3 to 4 hours the first time.

git clone https://github.com/RL-Align/RL-Kernel && cd RL-Kernel
cd scripts/verl_e2e_lora

bash setup.sh rlkernel               # environment: RL-Kernel, vLLM, verl, DeepGEMM, FlashMLA
bash setup.sh data                   # checkpoint and DAPO-Math-17k

bash run.sh gate                     # 2 GPUs: byte-for-byte check of rollout, actor and training forward
bash run.sh rlkernel                 # 8 GPUs: 20 GRPO steps on the full 43 layers

scripts/verl_e2e_lora/README.md has every knob, and the verl guide the overrides for your own verl command.

DeepSeek-V4.1-Flash with verl

The DeepSeek-V4 requirements, plus about 196 GB of host memory per node for the Engram tables. MODEL_FAMILY=dsv41 selects a separate environment (torch 2.14, vLLM main) and the V4.1 release.

git clone https://github.com/RL-Align/RL-Kernel && cd RL-Kernel
cd scripts/verl_e2e_lora

MODEL_FAMILY=dsv41 bash setup.sh rlkernel   # environment for DeepSeek-V4.1 (vLLM main)
MODEL_FAMILY=dsv41 bash setup.sh data       # checkpoint and DAPO-Math-17k

bash experiments.sh D41G                    # 8 GPUs: the 100-step run

RL-Kernel's extension is built inside the checkout for one torch version: to run both DeepSeek-V4 and V4.1, use one checkout for each.

Community and Contributions

Join us on Slack or WeChat, and open an issue for bugs and feature requests. We hold a weekly developer meeting on Google Meet, Saturdays 21:00–22:00 Beijing time (UTC+8) — see the community page. Contributions to kernels, framework integrations, hardware adaptation, and benchmarks are welcome. See the contributing guide.

Acknowledgments

RL-Kernel builds on the work of the open-source AI infrastructure community, including vime, vLLM, Megatron-LM, and FlashInfer. We thank their contributors and everyone helping bring RL-Kernel to new accelerators.

Licensed under the Apache License 2.0.

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 788
Method 502
Class 193
Route 3

Languages

Python100%
C++1%

Modules by API surface

rl_engine/executors/bridge.py150 symbols
tests/test_weight_sync_bridge.py73 symbols
rl_engine/executors/training_contract.py46 symbols
tests/test_deepspeed_training_worker.py43 symbols
rl_engine/executors/deepspeed_trainer.py42 symbols
tests/test_ray_actor_manager.py41 symbols
tests/test_linear_logp.py37 symbols
benchmarks/profiler.py37 symbols
rl_engine/executors/ray_actor_manager.py35 symbols
rl_engine/executors/stateless_executor.py34 symbols
tests/test_stateless_executor.py31 symbols
rl_engine/kernels/ops/cuda/loss/logp.py29 symbols

For agents

$ claude mcp add RL-Kernel \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page