Trainer ranks pull batches: every rank requests step N when it is ready to train it, and the orchestrator sends N only once every trainer rank asked. So the trainer only ever holds the batch it is training on, and the last step the orchestrator sent is always the one the trainer is on. - zmq: one ROUTER in the orchestrator, one DEALER per trainer rank (from #4066). The orchestrator replies to each rank on the connection it asked on, so there's no slow-joiner race, no READY barrier and no `hwm`. `ROUTER_MANDATORY` raises on a vanished rank instead of dropping. - Every trainer rank counts, not one per data rank: requests carry rank, world size, data rank and step. A request for any other step raises, since it means the two sides resumed from different steps. - filesystem: each rank drops `step_N/rank_R.request` holding the world size, and the orchestrator renames the step's files into place once all are there. - `send` blocks until the step went out and returns the hand-off seconds, logged as `time/send_batch`. The wait before it is now `time/wait_for_policy` (same key, measured at the send instead of while the dispatcher is paused). Encoding happens before the wait. - The ship-time policy-version hold is removed: it was a proxy for "trainer is ready", which the request now says directly. The dispatch gate and off-policy filter still bound rollout staleness. Tested on telus (3x H200: 2 trainer ranks + 1 inference, reverse-text, 20 steps, `commit-4b3319f3a` + this patch): - zmq: finished, mean step 4.14s (steps 2-20), `time/send_batch` mean 0.6ms / max 6ms - filesystem: finished, both ranks wrote their request marker each step - resume from step 15 (zmq): continued to step 20 Linear: RES-1384
4.7 KiB
Overview
prime-rl is a framework for large-scale, asynchronous reinforcement learning of large language models. It is designed to be easy to use and hackable, yet capable of training 1T+-parameter MoE models on 1000+ GPU clusters.
Architecture
A prime-rl RL run is three cooperating processes:
- Inference — vLLM-backed server (or fleet) holding the current policy. The orchestrator drives rollouts through the token-in
/inference/v1/generateroute via therendererspackage (OpenAI-compatible chat/completions routes are also exposed for external clients). We are trying to stay up-to-date with the latest vLLM features, you can read more about the supported features and deployment options in the dedicated inference documentation. - Orchestrator — Lightweight CPU process that owns the data plane across many
verifierstraining and eval environments. Each env runs in an isolated subprocess with a variable-size pool of env workers for scalability. The orchestrator drives multi-turn rollouts against the inference fleet (tool use, browsers, sandboxes, long horizons) without re-tokenizing across turns, computes advantages, packs the rollouts into training batches, and relays new weights from trainer to inference. - Trainer — FSDP2 process group that consumes packed rollouts and steps the optimizer. We ship optimized custom modeling code for many MoE / dense / VLM families that unlocks advanced trainer parallelism — expert parallelism (EP, with DeepEP kernels) and context parallelism (CP) for long-sequence training — plus selective activation checkpointing, FP8 training on Hopper+, and LoRA. You can read more in the dedicated training documentation.
The three processes communicate through configurable transports — by default the trainer↔orchestrator rollout link uses ZMQ (each trainer rank requests a step before the orchestrator sends it, so the trainer only ever holds the batch it is training on), and weight broadcast uses NCCL for synchronous in-memory transfer (falling back to filesystem when LoRA is enabled or no inference server is configured). Swap the rollout link to the local filesystem (rollout_transport.type = "filesystem") if you want rollouts persisted to disk. See Scaling for the deployment options.
Installation
curl -sSL https://raw.githubusercontent.com/PrimeIntellect-ai/prime-rl/main/scripts/install.sh | bash
The script clones the repo, initializes the verifiers / renderers / prime-envs submodules, installs uv, and runs uv sync --all-extras. For manual setup, or troubleshooting, see the README.
You need at least one NVIDIA GPU (RTX 3090/4090/5090, A100, H100, H200, or B200). Single-GPU runs are supported for debugging; production RL is typically 1× inference node + 1+ trainer nodes.
Quick Run
Train an SFT-warmed Qwen3-0.6B on the reverse-text task — the env is bundled with the verifiers submodule so no separate install is needed. This config ships in the repo and runs on two GPUs (one for inference, one for the trainer):
uv run rl @ examples/basic/reverse-text/rl.toml
The rl entrypoint reads examples/basic/reverse-text/rl.toml, splits it into per-process sub-configs, picks GPU 0 for inference and GPU 1 for the trainer, launches all three processes, and tees their stdout into the run directory at outputs/<run_name>/logs/{trainer,orchestrator,inference}.log (run.name auto-generates as <envs>--<model>--<short-id>; pass --run.name <name> for a predictable path). Within a minute the trainer should log step 1 and a reward sample; after 20 steps the run completes with a final DCP checkpoint at outputs/<run_name>/checkpoints/step_20.
Documentation
- Configuration — TOML composition, CLI overrides, dry-run.
- Training — Launch and observe RL and SFT runs.
- Inference — vLLM-backed server (or fleet) holding the current policy.
- Scaling — Single-GPU through multi-node clusters via FSDP / EP / CP and SLURM.
- Algorithms — Async semantics, loss / advantage / filter plugins, trajectory merging.
- Advanced — Custom modeling, multimodal, LoRA, P/D inference.
- Development — Test suite, pre-commit hooks, adding a new model.
