* Add MXFP8 Linear Layer * Add MXFP8 Receipe * Add MXFP8 * Refractor, remove constants, cleanup * Remove import from local path * Reformat * Add MXFP8 expert parallel impl to support TorchAO's MXTensor in backward for all2all in MXFP8 * Build torchao from source for py3.12 MXFP8 CUDA kernel Pin torchao to the pytorch/ao git source (rev 02105d4) and build its CUDA kernels from source against the local torch cu128 / cpython-3.12. The PyPI wheel ships the MXFP8 kernel as a cpython-310-only .so that fails to load on prime-rl's Python 3.12, so torchao::mxfp8_quantize was never registered with a CUDA backend and MXFP8 died in backward. Building from source produces a cpython-312 extension (_C_mxfp8.cpython-312-*.so). - no-build-isolation-package += torchao (build against local torch) - extra-build-variables: CUDA_HOME=/usr/local/cuda-12.8, TORCH_CUDA_ARCH_LIST=10.0a (B200/sm_100a), USE_CPP=1 Enables the MXFP8 all-to-all and dense-linear paths (verified on 8xB200). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Relax torchao MXFP8 grouped-GEMM torch-nightly gate torchao's _get_tensor_cls_for_config (added in pytorch/ao#4141, "require torch nightly and cuda 12.8+", Mar 2026) asserts two post-2.11.0 DTensor symbols (_ops.scaled_mm_single_dim_strategy, _dispatch.is_pinned_handler) exist, else raises "install the latest torch nightly". This blanket-blocks all MXFP8 training, but is over-broad for us: prime-rl's EP path pulls expert weights local (.to_local()) before the grouped GEMM, so the DTensor scaled-mm strategy is never hit, and current torch's non-single-dim scaled_mm_strategy covers the rest. Neutralize just that assert (MXFP8 branch only) before quantize_, so enable_grouped_gemm works on our pinned torch 2.11 without a nightly bump. Verified 8xB200 SFT (GLM-0.5B, ep=8, grouped_gemm + a2a): 8/8 steps, all ranks; numerics vs bf16 within mxfp8 range (out ~4.8%, grads ~6-7%) for both mxfp8_rceil and mxfp8_rceil_wgrad_with_hp recipes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Use prebuilt torchao wheel from v0.6.0 release (x86_64) Replace the torchao build-from-source git dependency with the prebuilt cp312 CUDA wheel hosted on the prime-rl v0.6.0 release, matching how deep-ep / deep-gemm / nixl-cu12 are shipped. Avoids requiring the CUDA toolchain at install time on x86_64. - torchao source -> release wheel URL, scoped to platform_machine == 'x86_64' (aarch64 continues to resolve torchao from the default index, untouched) - drop torchao from no-build-isolation-package + the extra-build-variables block - add torchao to the exclude-newer-package trusted-sources list Wheel is H100 (sm90a) + B200 (sm100a), built from pytorch/ao@02105d4, verified in a fresh py3.12 env (mxfp8 op registers, a2a imports). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Sort imports in expert_parallel.py (ruff I001) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Fix comments * Fix alignment of 32 for grouped gemm backward * Apply Samis Suggestions * Add back default ignore patterns * Fix name bug * Reformat with ruff * Config verifier * Fix kernel redirect for > 32 token groups * Ruff reformat * chore: update uv.lock for torchao dependency Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * style: fix import sorting in MXFP8 files Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Move config check to config code * Fix ruff * Move config check to trainer --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
PRIME-RL: Async RL Training at Scale
Overview
PRIME-RL is a framework for large-scale reinforcement learning. It is designed to be easy to use and hackable, yet capable of scaling to 1000+ GPUs. Here is what we think sets it apart:
- Fully asynchronous RL for high-throughput agentic training at scale.
- Performant: built to train 1T+ MoE models on 1000+ GPUs with FSDP2 for training and vLLM for inference, with FP8 inference, PD disaggregation, EP and CP parallelism, and more.
- Native integration with
verifiersenvironments through the Environments Hub, including built-in support for SWE and agentic environments. - End-to-end post-training: SFT, RL training, and evals.
- Multi-node deployment with Slurm and Kubernetes support.
- Multimodal support for VLMs such as Qwen3-VL.
- Hackable, modular, and extensible by design.
- One-line SLURM deployment for frontier models — e.g.
GLM-5FP8 with P/D disaggregation, thellm-drouter, and Mooncake KV offload.
Models support
The trainer works with both Hugging Face and Prime custom ModelForCausalLM out of the box. For selected families (especially large MoE) we also ship highly optimized training code under src/prime_rl/trainer/models/, including expert parallelism (EP) for MoE layers and context parallelism (CP) for long sequences (see the table), and additional kernels like quack-kernels.
With [model] impl = "auto" (the default), the trainer selects that custom stack when the Hugging Face config type is registered.
| Family | Example IDs | MoE | EP | CP |
|---|---|---|---|---|
GLM-5 (glm_moe_dsa) |
zai-org/GLM-5, zai-org/GLM-5-FP8 |
yes | ✅ | ✅ |
Qwen3 MoE (qwen3_moe) |
Qwen/Qwen3-30B-A3B, … |
yes | ✅ | ✅ |
Qwen3.5 MoE (qwen3_5_moe) |
Qwen/Qwen3.5-35B-A3B, … |
yes | ✅ | ✅ |
| Qwen3 / Qwen3.5 VLMs | see advanced.md (qwen3_vl, qwen3_5, qwen3_5_moe) |
MoE only on MoE VLMs | MoE only | ✅ |
Poolside Laguna (laguna) |
poolside/Laguna-XS.2 |
yes | ✅ | ✅ |
MiniMax M2 (minimax_m2) |
MiniMax/MiniMax-M2 |
yes | ✅ | ✅ |
Nemotron H (nemotron_h) |
nvidia/Nemotron-3-Nano-30B-A3B, nvidia/Nemotron-3-Super-120B-A12B, … |
yes | ✅ | ✅ |
Trinity (afmoe) |
arcee-ai/Trinity-Mini, … |
yes | ✅ | ✅ |
GLM-4 · GLM-4.5 MoE · INTELLECT-3 (glm4_moe) |
THUDM/GLM-4-9B-0414, zai-org/GLM-4.5-Air, zai-org/GLM-4.5, PrimeIntellect/INTELLECT-3, … |
yes | ✅ | ✅ |
| GPT-OSS (HF, MoE) | openai/gpt-oss-20b, openai/gpt-oss-120b |
yes | ✅ | ✅ |
| Other HF causal LMs | Qwen3 dense, Mistral, … (impl = "hf") |
varies | ❌ | ✅ |
Setup
We develop and test on NVIDIA RTX 3090/4090/5090, A100, H100, H200, and B200. If your setup fails, please create an issue.
Prerequisites
Currently, you need at least one NVIDIA GPU to use PRIME-RL. If you don't already have access to one, we recommend our compute platform for everything from renting on-demand single GPUs for developing, debugging and small ablations, to reserving 1000+ GPU clusters for production-scale training.
Quick Setup
Set up PRIME-RL in a single command.
curl -sSL https://raw.githubusercontent.com/PrimeIntellect-ai/prime-rl/main/scripts/install.sh | bash
Manual Setup
- Clone the repository
git clone https://github.com/PrimeIntellect-ai/prime-rl.git
cd prime-rl
- Initialize submodules
git submodule update --init -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
- Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env
- Install dependencies from the lock file
uv sync --all-extras
Note
: Environments are opt-in uv workspace members —
uv sync --all-extrasdoes not install them. To train on them, install all withuv sync --all-extras --all-packages, or a subset withuv sync --package prime-rl --package <env>.
4.1. On aarch64 hosts: build flash-attn from source for your GPU
Note
: aarch64 has no prebuilt flash-attn wheel. This step compiles the CUDA extension for your local GPU (~20-30 minutes). Compute capability is auto-detected from
nvidia-smi; override withTORCH_CUDA_ARCH_LIST=9.0(Hopper) /10.0(Blackwell) if needed. NOTE: After this step, you can't runuv sync --all-extrasoruv runas it will uninstall the package, you can avoid it by runninguv sync --inexactoruv run --no-sync.
bash scripts/docker-arm64-post-install.sh
3.1. Optional: Install Flash Attention 3 (on Hopper GPUs only, for flash_attention_3 attention backend)
Note
: This step will take a while, as it builds the Flash Attention 3 extension from source, as it has no wheels prebuilt. NOTE: After this step, you can't run
uv sync --all-extrasoruv runas it will uninstall the package, you can avoid it by runninguv sync --inexactoruv run --no-sync
uv pip install "flash-attn-3 @ git+https://github.com/Dao-AILab/flash-attention.git@main#subdirectory=hopper" --no-build-isolation
Validate your environment setup
- Check that the environment uses Python 3.12
uv run python -V
- Check that
flash-attnis installed
uv run python -c "import flash_attn"
- Check that you can run SFT trainer (this requires 1 GPU)
uv run sft @ configs/debug/sft/train.toml
- Check that you can run the RL trainer (this requires 1 GPU)
uv run trainer @ configs/debug/rl/train.toml
- Check that you can run the inference server (this requires 1 GPU)
uv run inference @ configs/debug/infer.toml
Keep the inference server running in the background for the next steps.
5.1. Check that you can run the orchestrator against the inference server
uv run orchestrator @ configs/debug/orch.toml
5.2. Check that you can run evals against the inference server
uv run eval @ configs/debug/eval.toml
Additional Setup
- If you want to log your runs to W&B, log in
uv run wandb login
# Or set `export WANDB_API_KEY=...`
- If you require gated/ private models or datasets from HuggingFace, log in
uv run hf auth login
# Or set `export HF_TOKEN=...`
Training Examples
We provide end-to-end training examples in the examples directory to highlight features of the framework and guide you through the process of training your own models.
Basic Training: 1 to 8 GPUs
Follow this guide to learn the basics of Prime-RL. You can train your own models on 1 to 8 GPUs. Ideal for getting started and exploring the capabilities of the framework. These guides cover most use cases -- single-turn, multi-turn, tool calling, etc. -- on toy environments and small models.
- Reverse Text: Train
Qwen3-0.6Bto reverse a small chunk of text. Demonstrates tiny-scale single-turn SFT and RL training. Can be trained on a single consumer GPU in a few minutes, and is ideal for getting started. - Wordle: Train
Qwen3-1.7Bto play Wordle. A fun example of multi-turn SFT and RL training. Can be trained on a 2-4 H100 GPUs in a few hours. Ideal for exploring the multi-turn training capabilities of the framework. - Alphabet Sort: Train
Qwen3-4B-Instruct-2507to sort names alphabetically. Demonstrates multi-turn RL training via LoRA without SFT warmup. Can be trained on a single H100 GPU in just over an hour. Ideal for exploring LoRA-based training. - Wiki Search: Train
Qwen3-4B-Instruct-2507to answer trivia questions by searching through a Wikipedia. Demonstrates multi-turn with web search tool use. - Hendrycks Sanity: Run a sanity check experiment on
DeepSeek-R1-Distill-Qwen-1.5Busing a filtered subset of MATH where the model already partially solves 20-80% of problems. Useful for algorithm ablations.
Advanced Training: 32 - 2048 GPUs:
Follow this guide to train large models on hard reasoning and agentic / swe environments. These guides are designed to be run from a Slurm cluster but can also be adapted to k8s deployments.
- Qwen 3 30B - A3B Math: Train
Qwen3-30B-A3Bto solve hard math problems. - Qwen 3 30B - A3B SWE: Train
Qwen3-30B-A3Bto solve hard SWE problems. - Intellect-3.1: Reproduce our
INTELLECT-3.1training run. - MiniMax-M2.5 SWE: Train
MiniMax-M2.5on agentic SWE tasks. - High-throughput GLM-5: Train
GLM-5with PD disaggregation and FP8 inference on SWE. - High-throughput GLM-5 (llm-d): One-line SLURM deployment for
GLM-5FP8 with P/D disaggregation, thellm-drouter, and Mooncake KV offload — the faster way to runGLM-5.
Docs
Check out the docs directory for in-depth guides on how to use PRIME-RL.
- Overview - Architecture, install, and a copy-pasteable end-to-end RL run
- Configuration - TOML composition, CLI overrides, env vars, validation
- Training - RL, SFT, evals, checkpointing, observability, rules of thumb
- Scaling - Single-GPU through multi-node, FSDP/EP/CP, SLURM, benchmarking
- Algorithms - Async/off-policy training, the AIPO loss, advantage and filter plugins, trajectory merging
- Advanced - Custom modeling, multimodal training, LoRA, multi-tenant training
- Development - Test suite, pre-commit hooks, adding a new model
Contributing
We warmly welcome community contributions! We use issues to track bugs, feature requests, and share our internal roadmap. If you encounter bugs, have pain points during development, or have ideas for new features, please open an issue.
Contributions are welcome via PR. Please follow these guidelines:
- Install the pre-commit hooks to ensure your code is formatted correctly.
- Please keep your PR in "Draft" until it is ready for review.
- If your PR resolves an issue, please link the issue in the PR description
- If you can, try running the test suite locally to ensure your changes are working as expected.
Pre-Commit Hooks
Please install the pre-commit hooks to ensure your code is formatted correctly.
uv run pre-commit install
Tests
uv run pytest -v # everything
uv run pytest tests/unit -v # unit only
uv run pytest tests/integration -v # integration only
uv run pytest -v -m "not gpu" # CPU-only (inverse of the gpu marker)
License
This project is licensed under the Apache 2.0 license, as found in the License file.
Citation
If you find our work useful, feel free to cite it using
@misc{primeintellect2025prime-rl,
author = {Prime Intellect},
title = {PRIME-RL},
url = {https://github.com/PrimeIntellect-ai/prime-rl},
year = {2025}
}