OpenRLHF/OpenRLHF
An Easy-to-use, Scalable and High-performance Agentic RL Framework based on Ray (PPO & DAPO & REINFORCE++ & VLM & TIS & vLLM & Ray & Async RL)
OpenRLHF is an open-source framework for Reinforcement Learning from Human Feedback (RLHF) — the technique used to fine-tune large language models (LLMs) so they produce responses that align with human preferences. It's designed to be fast, scalable, and production-ready, and it's the first RLHF framework built on a combination of Ray (for distributed scheduling) and vLLM (for high-speed inference).
Core Architecture
- Ray orchestrates the training across multiple GPUs, separating the different model components (actor, reward, reference, critic) to handle models with 70B+ parameters.
- vLLM accelerates the sample generation step, which typically takes 80% of RLHF training time.
- DeepSpeed provides memory-efficient training (ZeRO-3) and other optimizations.
- HuggingFace Transformers is used for model loading and fine-tuning.
Design Paradigm: Agent-Based Execution
OpenRLHF uses a unified agent-based design where every training run follows the same token-in-token-out pipeline. This means all sampling produces token-level trajectories, ensuring consistency and easy extension to single-turn or multi-turn tasks. The framework has two execution modes:
- Single-Turn (default): one-shot generation per prompt, used for standard RLHF and custom reward functions.
- Multi-Turn: for interactive environments, multi-step reasoning, and external environments (via an OpenAI-compatible server).
These modes are independent of the RL algorithm — you can use any algorithm with either mode.
Supported RL Algorithms
OpenRLHF implements several state-of-the-art algorithms, all decoupled from the execution mode:
- PPO (default): full critic network, stable training.
- REINFORCE++ and REINFORCE++-baseline: PPO tricks without a critic, efficient and robust.
- GRPO and Dr. GRPO: group-based normalization.
- RLOO: multi-sample training with per-token KL.
- FlashREINFORCE: critic-free, single-rollout asynchronous RL.
Key Features
- Complete RLHF pipeline: Supervised Fine-Tuning (SFT), Reward Model training, and RL training.
- Preference optimization: DPO, IPO, cDPO.
- Vision-Language Models (VLMs): supports training with image inputs, including multi-turn image feedback.
- Efficiency optimizations: sample packing, vLLM acceleration, dynamic filtering (DAPO), and hybrid engine scheduling to maximize GPU utilization.
- Scalability: multi-node training (SLURM), tensor parallelism, RingAttention for long contexts.
- Model support: LoRA/QLoRA, Mixture of Experts (MoE), FlashAttention, HuggingFace chat templates.
- Production features: logging (Wandb, TensorBoard), checkpoint recovery, evaluation datasets, and observability metrics.
Getting Started
Installation is straightforward via Docker (recommended) or pip:
pip install openrlhf[vllm] # includes vLLM
Or from source:
git clone https://github.com/OpenRLHF/OpenRLHF.git
cd OpenRLHF
pip install -e .
The README provides example scripts for various training scenarios (SFT, DPO, PPO, etc.) and links to documentation and a technical report.
In short, OpenRLHF is a powerful, flexible framework that makes RLHF training faster and easier, with a design that scales from small experiments to large production models.
Related
- Dispatch
- Project
- Project
- Project