* chore: overhaul public configs/ and examples/
Restructure the public configs/ and examples/ trees for clarity.
- examples/: split into basic/ (core-env tutorials) and advanced/
(folder-per-model: qwen3-30b-a3b, glm-4.5-air, glm-5.2, minimax-m2.5,
nemotron-3-super, intellect-3.1), each with a README; drop multinode/
and the example screenshots.
- configs/: add basic/ (small 2-GPU dev mirrors of the core envs, one folder
+ README each, validated at 1 step); rename debug/algorithms -> debug/algo;
move debug/{rl,sft} -> debug/fake/{rl,sft}.toml; remove stale/internal
configs (gsm8k, nemotron_*, hendrycks_math, general_agent, elastic,
debug/v1, debug/{infer,orch,multimodal}.toml, debug/{hendrycks_sanity,moe,multi_env}).
- Remove the k8s/ Helm chart and its docs.
- Repoint README, docs/, nightly tests, and CI to the new paths; lowercase
prime-rl throughout docs and READMEs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore: drop per-model READMEs in examples/advanced
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(k8s): keep Helm chart, refresh reverse-text example configs
Keep the k8s/ Helm chart (undo its removal earlier in this branch) and bring
its reverse-text example back in sync with the current config layout.
The chart invoked examples/reverse_text/rl/{orch,infer,train}.toml — a split
config layout flattened into a single rl.toml months ago (#1859), so the
shipped example had pointed at non-existent files. Add current, validated
orch/infer/train configs under k8s/prime-rl/examples/reverse-text/ (split from
examples/basic/reverse_text/rl.toml), point the chart and docs at them, and
COPY k8s/ into the CUDA image so /app/k8s/... resolves at runtime.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(configs): hyphenate all directory names in configs/, examples/, k8s/
Normalize directory naming to hyphens, matching the model dirs and logical
ids (reverse-text-v1, prime-rl). Renames the env/task dirs that still used
underscores:
examples/basic/{reverse_text,alphabet_sort,wiki_search,hendrycks_sanity}
configs/basic/{reverse_text,alphabet_sort,wiki_search,hendrycks_sanity}
configs/ci/integration/reverse_text{,_lora,_moe,_multi_run,_rl_opd,_rl_sft,_sft,_sft_lora}
to the same names with hyphens, and updates every path reference (README,
docs, skills, nightly + integration test path args, the cpu_tests
config-import check). Python test files/modules and *.toml filenames keep
underscores.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(examples): eval CLI migration, SLURM cleanup, batch sizes, glm-5.2 layout
- Migrate every eval command in examples/basic READMEs from `vf-eval` to the v1
`eval` CLI (pydantic-config): `-b` -> `--client.base-url`, `--max-tokens`/`-t`
-> `--sampling.max-tokens`, `--env-args` -> `--args`, plus `-r 3` (v1 defaults
to 1 rollout; these READMEs report 20x3), `--harness.id null` (these envs train
with the null harness), and `--no-push`. Drop the now-dead vf-eval skip in
tests/unit/test_configs.py.
- Remove all SLURM overlays (slurm_rl.toml, slurm_sft.toml) from examples/basic.
Move the slim-wheel SFT+[slurm] parse fixture to configs/ci/slim_sft.toml and
repoint cpu_tests.yaml; drop the SLURM section from the hendrycks-sanity README
and the SLURM line from the start-run skill.
- Tune basic example batch/group sizes: alphabet-sort 256/16, wordle 512/16
(wiki-search already 512/16).
- Restructure examples/advanced/glm-5.2: inference configs ->
infer/{pd,pd-llmd}.toml, RL configs -> {swe,swe-llmd}.toml; repoint docs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* docs: fix outdated docs/skills/configs surfaced by v1 audit
Swept docs/, skills/, READMEs, and config TOMLs for outdated content (special
focus on v0->v1 drift). Verified every fix against current code.
docs/
- configuration.md: repoint 5 dead Basic example links to examples/basic/<hyphen>;
scope the "each dir has a README" claim to basic (advanced dirs are config-only).
- algorithms.md: opd reference-model field is `teacher` not `model`; renderer names
`glm-5`/`glm-4.5` (were invalid `glm5`/`glm4.5`); rewrite the per-env algorithm
example in the v1 taskset/harness form (was the v0 bare-`id` form).
- development.md: drop invalid `--data.type null` (SFT DataConfig has no such type).
- inference.md: fix "Dissagregation" typo + dead P/D anchor.
- overview.md: token-in route is `/inference/v1/generate`.
skills/
- monitor-run: correct the metric tables to the real
{scope}/{subset}/<metric>/<stat> scheme (num_total_tokens, has_error,
time/wait_for_policy, dispatcher/*); the old seq_len / errored_rollouts /
scheduler/* / generate_completions names never existed.
- install: drop the deep-gemm mention (no such section) from the description.
READMEs
- examples/README.md: basic runs on 1-8 GPUs (not 2); hyphenate env names.
- configs/README.md: drop stale "standalone entrypoint configs"; hyphenate.
- wiki-search: eval inference uses `--model.*` (not `--inference.model.*`) and drops
the auto-derived `enable_auto_tool_choice` flag; "native V1 tools" not "MCP".
- reverse-text: fix dead sft/train.toml path -> sft.toml.
- hyphenate configs/basic/* README headings.
configs/
- qwen3-30b-a3b/tool.toml: move `min_tier` into the taskset (was under a v0
`[...env.args]` block a v1 taskset never reads); group_size alias.
- glm-5.2/swe-llmd.toml: rollouts_per_example -> group_size.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(configs): use prime-qwen3 renderer for reverse-text (was default)
The reverse-text configs run PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT, whose
`-SFT` suffix misses MODEL_RENDERER_MAP's exact-match lookup and so fell back to
the DefaultRenderer. reverse-text is single-turn and always sends a system
prompt ([system, user, assistant]); the prime-qwen3 renderer is token-for-token
identical to the model's apply_chat_template for that shape (verified via
render_ids parity), and unlike the stock qwen3 renderer it does not inject an
empty <think></think> block. Switch the 7 standard + 3 distill reverse-text
configs to prime-qwen3.
Kept `default` where no hand-coded renderer fits (each errors on the model's
tokenizer): hendrycks-sanity (DeepSeek-R1-Distill-Qwen-1.5B), reverse-text-moe
(samsja/mini-glm-moe), intellect-3.1 (INTELLECT-3-Base).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(configs): use prime-qwen3 (not qwen3) for PrimeIntellect Qwen3 configs
The stock `qwen3` renderer injects an empty <think></think> block the
PrimeIntellect Qwen3 template never emits, so it mismatches these models'
apply_chat_template — single-turn for reverse-text, and every multi-turn shape
for wordle (verified via render_ids parity) — corrupting training tokenization.
- configs/basic/wordle/rl.toml: qwen3 + thinking_retention="all" -> prime-qwen3,
matching the tutorial examples/basic/wordle (which already uses prime-qwen3).
- configs/debug/algo/{echo,grpo,max_rl,self_distill,mixed_grpo_opd,opd,opd_lora}.toml
and configs/ci/integration/reverse-text-rl-opd/start.toml: qwen3 -> prime-qwen3
(all run PrimeIntellect/Qwen3-0.6B-Reverse-Text-{SFT,RL}).
prime-qwen3 handles the PI template's think retention natively, so the explicit
thinking_retention="all" is dropped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(k8s): use prime-qwen3 renderer in reverse-text orch config
The k8s reverse-text orchestrator config was split from the reverse-text example
before that example migrated to prime-qwen3, and the renderer migration was
scoped to configs/ and examples/ — so this one kept the stale `default`. Align
it with the source (PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT → prime-qwen3).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(k8s): drop redundant renderer comment in reverse-text orch config
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
13 KiB
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/fake/sft.toml
- Check that you can run the RL trainer (this requires 1 GPU)
uv run trainer @ configs/debug/fake/rl.toml
- Check that you can run the inference server (this requires 1 GPU)
uv run inference --model.name Qwen/Qwen3-0.6B
- Check that the full RL stack (inference + orchestrator + trainer) runs end-to-end (this requires 2 GPUs)
uv run rl @ configs/basic/reverse-text/rl.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 tasks. These guides are designed to be run from a Slurm cluster but can also be adapted to k8s deployments.
- Qwen3-30B-A3B: Train
Qwen3-30B-A3Bon math, SWE, and agentic tool use. - GLM-4.5-Air: Train
GLM-4.5-Airon search, SWE, and terminal tasks. - Nemotron-3-Super: Train the
Nemotron-3-Super-120Bhybrid-Mamba MoE on SWE at 131k context. - MiniMax-M2.5 SWE: Train
MiniMax-M2.5on agentic SWE tasks. - INTELLECT-3.1: Reproduce our
INTELLECT-3.1training run. - High-throughput GLM-5: Large-scale
GLM-5/GLM-5.2inference with P/D disaggregation, thellm-drouter, and FP8.
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}
}