Skip to main content
OpenRLHF logo

GitHub Contributors Issues Discussions GitHub pull requests GitHub stars Ask DeepWiki
Open-source / Comprehensive / Lightweight / Easy-to-use


[ English | 中文 | 日本語 ]

OpenRLHF is the first high-performance, production-ready open-source RLHF framework that combines Ray + vLLM distributed architecture with a unified agent-based design paradigm for scalable and extensible reinforcement learning from human feedback.

📚 Learn More: Documentation | Slides | Technical Report | Video

🦋 Recommended: Molt — a lightweight, PyTorch / Hugging Face-native RL framework powered by NVIDIA AutoModel, with fully asynchronous training, multimodal and multi-turn agents, and large-scale MoE support. Get started →

📖 Table of Contents


News

Show News

🏗️ Architecture Foundation: Ray + vLLM Distribution

OpenRLHF is the first RLHF framework built on Ray + vLLM distributed architecture, orchestrating multiple components across GPUs efficiently:

OpenRLHF Architecture (Ray + vLLM)

Core Infrastructure Components

Ray - Distributed Scheduler and Controller
OpenRLHF leverages Ray for efficient distributed scheduling. It separates the Actor, Reward, Reference, and Critic models across different GPUs, enabling scalable training for models up to 70B+ parameters.

Hybrid Engine Scheduling: All models and vLLM engines can share GPU resources—minimizing idle time and maximizing GPU utilization. This allows running full RLHF pipelines on limited hardware.

vLLM - High-Performance Inference Engine
RLHF training spends 80% of the time on sample generation. Powered by vLLM with Auto Tensor Parallelism (AutoTP) and Pipeline Parallelism (PP), OpenRLHF delivers high-throughput, memory-efficient generation.

DeepSpeed - Memory-Efficient Training
Built on DeepSpeed ZeRO-3, deepcompile, AutoTP, and RingAttention. Enables large model training without heavyweight frameworks while working directly with HuggingFace models.

Transformers - Model Interface
Native integration with HuggingFace Transformers for seamless model loading, state management, and fine-tuning of pretrained models.

NCCL / CUDA IPC - High-Speed Communication
Efficient inter-GPU communication for distributed training and inference.


🎯 Design Paradigm: Agent-Based Execution

On top of the Ray distributed architecture, OpenRLHF is the first RLHF framework to implement a unified agent-based paradigm. Every training run—whether standard PPO or complex multi-turn reasoning—follows a consistent agent execution pipeline.

Why Agent-Based?

OpenRLHF unifies generation and training through token-in-token-out agent execution, ensuring perfect consistency, easy single/multi-turn extension, and zero text-level mismatches.

Agent Architecture

                 ┌─────────────────────────────┐
                 │    AgentExecutorBase        │
                 │  (Token-in-Token-out Core)  │
                 └─────────────────────────────┘
                              │
                 ┌────────────┴────────────┐
                 ↓                         ↓
         SingleTurnExecutor        MultiTurnExecutor
                 │                         │
      ┌──────────┴──────────┐   ┌─────────┴──────────┐
      ↓                     ↓   ↓                    ↓
  Standard RLHF      Custom Reward   Multi-Step    External Env
  (One-shot gen)     Function      Reasoning     (OpenAI Agent Server)
      ↓                     ↓           ↓                ↓
      └─────────────────────┴───────────┴────────────────┘
                              │
                    Consistent Token Trajectories
                              │
                    ┌─────────┴─────────┐
                    │  RL Algorithms    │
                    │  (Decoupled)      │
                    │                   │
                    │  PPO, REINFORCE++ │
                    │  GRPO, RLOO, etc. │
                    └───────────────────┘

Core Design Principles

Show core design principles
Principle Description Benefit
Token-in-Token-out All sampling produces token-level trajectories Zero text-level mismatch
Unified Interface Same AgentExecutorBase API for all modes Switch modes with one flag
Algorithm-Agnostic RL algorithms (PPO, REINFORCE++, etc.) are decoupled from agent executors Any algorithm works with any mode
Extensible Plug in custom rewards/environments easily Rapid experimentation
Production-Ready Sync/Async/Hybrid Engine support From research to deployment

Two Execution Modes (Orthogonal to RL Algorithms)

The agent execution mode is independent of the RL algorithm you choose. You can use any algorithm (PPO, REINFORCE++, GRPO, etc.) with any execution mode:

Mode Use Cases Interface Complexity
Single-Turn Standard RLHF, custom reward functions Optional reward_func() ⭐ Default (99% use cases)
Multi-Turn Multi-step reasoning, interactive environments reset() + step() ⭐⭐ Advanced

🚀 State-of-the-Art RL Algorithms

OpenRLHF implements PPO, REINFORCE++, REINFORCE++-baseline, GRPO, RLOO with advanced optimization tricks inspired by practical guides and community best practices.

Key Design: RL algorithms are decoupled from agent execution modes. All algorithms work seamlessly with both single-turn and multi-turn agent executors, running through the unified token-in-token-out pipeline for consistent behavior.

Show algorithm comparison table
Algorithm --algo.advantage.estimator Key Feature Best Use Case
PPO (default) Full critic network Stable training, proven results
REINFORCE++ reinforce PPO tricks without critic Efficient training, less memory
REINFORCE++-baseline reinforce_baseline Mean reward baseline Reasoning tasks (RLVR), robust to reward scales
RLOO rloo Per-token KL + PPO-clip Multi-sample training
GRPO group_norm Group normalization Batch-based training
Dr. GRPO dr_grpo Simplified GRPO Removes local /std norm
FlashREINFORCE flash_reinforce Critic-free single-rollout RL: batch-mean baseline, binary-KL trust region on the vLLM logprobs Async agentic RL with one rollout per prompt (script)

References: Zhihu article | Notion best practices


📋 Comprehensive Features

OpenRLHF provides a complete RLHF pipeline with agent-based flexibility:

🎯 Agent-Based RL Training (Core Innovation)

Show agent-based RL training details

Single-Turn Mode (Default - 99% of use cases)

Multi-Turn Mode (Advanced - Interactive tasks)

  • Multi-step interactions with environment feedback
  • Works with all RL algorithms
  • Custom agent functions (--train.agent_func_path)
  • OpenAI-compatible server: see examples/python/agent_func_openai_server_executor.py for an agent executor that wraps vLLM as a local OpenAI Agent Server
  • Async pipeline (--train.async_enable) for higher throughput: train_reinforce_baseline_ray_agent_async.sh

🎓 Supervised Training & Preference Learning

Show supervised training & preference learning table
Method Script Description
SFT train_sft.sh Supervised fine-tuning with packing
DPO/IPO/cDPO train_dpo_llama.sh Direct preference optimization
Reward Model train_rm.sh Train reward models

⚡ Advanced Capabilities

Show advanced capabilities

Efficiency Optimizations

  • Sample packing (--ds.packing_samples) for all training modes
  • vLLM acceleration (--vllm.num_engines) for fast generation
  • DAPO dynamic filtering (--algo.dynamic_filtering_enable)
    • 🎲 Dynamic Sampling: for each prompt, generate multiple responses and filter them by your reward / agent 0–1 scores signal
      • Enable: --algo.dynamic_filtering_enable
      • Score range: --algo.dynamic_filtering_range 0.0 1.0
      • Requires: --rollout.n_samples_per_prompt > 1 and either --reward.remote_url or --train.agent_func_path
      • Example: ./examples/scripts/train_dapo_ray_hybrid_engine.sh

Scalability

  • DeepSpeed AutoTP for tensor parallelism (see --ds.tensor_parallel_size in training scripts)
  • RingAttention for long context (--ds.ring_attn_size)
  • Multi-node training with SLURM

Model Support

Optimizers

  • AdamW (default): --{actor,critic}.optim adam --{actor,critic}.adam.lr 2e-6
  • Muon (via DeepSpeed ≥ 0.18.2, 2D weights only; embeddings / head / 1-D params use aux-AdamW): --{actor,critic}.optim muon --{actor,critic}.muon.lr 1e-4 --{actor,critic}.muon.momentum 0.95. Newton-Schulz produces scale-invariant updates, so disable global grad clipping with --{actor,critic}.max_norm 0 (the Adam default 1.0 would clip away the Muon update).

Reward Shaping

  • DAPO-style overlong penalty for length control (--reward.overlong_buffer_len, --reward.overlong_penalty_factor) — soft-penalize responses that exceed max_new_tokens - overlong_buffer_len
  • ProRL-style truncation penalty (--reward.stop_properly_penalty_coef) — for samples with finish_reason='length': coef ∈ [0, 1] multiplicatively scales the reward; coef < 0 sets the reward to that fixed value (e.g. -0.5)

Production Features

  • Wandb (--logger.wandb.key) and TensorBoard (--logger.tensorboard_dir) logging
  • Checkpoint recovery (--ckpt.load_enable, --ckpt.save_steps)
  • Best-checkpoint saving on eval metrics (--ckpt.best_metric_key)
  • Evaluation datasets (--eval.dataset, --eval.temperature, --eval.n_samples_per_prompt) — supported in async training
  • Multi-process data loading (--data.dataloader_num_workers, available for PPO/SFT/RM/DPO)
  • PPO observability: actor/critic grad-norm and per-phase timing (timing/make_experience, timing/ppo_train, timing/broadcast, timing/generation, timing/step_total)

🎬 Quick Start

Installation

Recommended: Use Docker for hassle-free setup

# 1. Launch Docker container
docker run --runtime=nvidia -it --rm --shm-size="10g" --cap-add=SYS_ADMIN \
  -e PIP_BREAK_SYSTEM_PACKAGES=1 -v $PWD:/openrlhf pytorch/pytorch:2.14.0-cuda13.0-cudnn9-devel bash

# 2. Install OpenRLHF (choose one)
pip install openrlhf                    # Basic
pip install openrlhf[vllm]              # + vLLM 0.34.0 (recommended)
pip install openrlhf[vllm_latest]       # + Latest vLLM
pip install openrlhf[vllm,ring,liger]   # + All optimizations

FlashAttention 2 comes as a prebuilt kernel that transformers downloads from the Hugging Face Hub on first use (about 1 GB), so nothing is compiled. RingAttention, clusters without internet access, and hosts whose NVIDIA driver is older than 580 need the image built from the Dockerfile instead, docker build -t openrlhf dockerfile: it carries the FlashAttention 2 package itself and the CUDA forward-compatibility libraries.

Alternative: Install from source

git clone https://github.com/OpenRLHF/OpenRLHF.git
cd OpenRLHF
pip install -e .

Prepare Datasets

OpenRLHF provides flexible data processing methods:

Key Parameters:

  • --data.input_key: Specify JSON key name for input data
  • --data.apply_chat_template: Use HuggingFace tokenizer's chat template
  • --data.input_template: Custom template string (alternative to chat template)
  • --data.prompt_probs / --data.dataset_probs: Mix multiple datasets (e.g., 0.1,0.4,0.5)
  • --eval.dataset: Specify evaluation dataset path

Chat Template Example:

dataset = [{"input_key": [
  {"role": "user", "content": "Hello, how are you?"},
  {"role": "assistant", "content": "I'm doing great. How can I help you today?"},
  {"role": "user", "content": "I'd like to show off how chat templating works!"},
]}]

tokenizer.apply_chat_template(dataset[0]["input_key"], tokenize=False)
# Output: "<s>[INST] Hello, how are you? [/INST]I'm doing great...</s> [INST] I'd like to show off... [/INST]"

Supervised Fine-tuning

OpenRLHF's model checkpoint is fully compatible with HuggingFace models. You can specify the model name or path using --actor.model_name_or_path {name or path}, --reward.model_name_or_path {name or path} and --critic.model_name_or_path {name or path}. We have provided some pre-trained checkpoints and datasets on HuggingFace OpenRLHF.

Then you can use the startup scripts we provide in the examples/scripts directory, or start the training using the following commands.

SFT command
deepspeed --module openrlhf.cli.train_sft \
   --data.max_len 4096 \
   --data.dataset Open-Orca/OpenOrca \
   --data.input_key question \
   --data.output_key response \
   --data.input_template $'User: {}\nAssistant: ' \
   --train.batch_size 256 \
   --train.micro_batch_size 2 \
   --data.max_samples 500000 \
   --model.model_name_or_path meta-llama/Meta-Llama-3-8B \
   --ckpt.output_dir ./checkpoint/llama3-8b-sft \
   --ckpt.save_steps -1 \
   --logger.logging_steps 1 \
   --eval.steps -1 \
   --ds.zero_stage 2 \
   --train.max_epochs 1 \
   --ds.packing_samples \
   --ds.param_dtype bf16 \
   --adam.lr 5e-6 \
   --model.gradient_checkpointing_enable \
   --logger.wandb.key {wandb_token}

# Additional options:
# --data.apply_chat_template                # Use HF tokenizer chat template
# --ds.ring_attn_size 2                      # Enable RingAttention (install ring_flash_attn first)
# --data.multiturn                          # Multi-turn fine-tuning loss
# --model.pretrain_mode_enable                      # Continued pre-training mode

Reward Model Training

Reward model training command
deepspeed --module openrlhf.cli.train_rm \
   --ckpt.output_dir ./checkpoint/llama3-8b-rm \
   --ckpt.save_steps -1 \
   --logger.logging_steps 1 \
   --eval.steps -1 \
   --train.batch_size 256 \
   --train.micro_batch_size 1 \
   --model.model_name_or_path OpenRLHF/Llama-3-8b-sft-mixture \
   --ds.param_dtype bf16 \
   --train.max_epochs 1 \
   --data.max_len 8192 \
   --ds.zero_stage 3 \
   --adam.lr 9e-6 \
   --data.dataset OpenRLHF/preference_dataset_mixture2_and_safe_pku \
   --data.apply_chat_template \
   --data.chosen_key chosen \
   --data.rejected_key rejected \
   --ds.packing_samples \
   --model.gradient_checkpointing_enable \
   --logger.wandb.key {wandb_token}

It is recommended to set the --ds.value_head_prefix option of the Reward Model to score, so that we can load the model using AutoModelForSequenceClassification:

reward_model = AutoModelForSequenceClassification.from_pretrained(
              reward_model_path,
              num_labels=1,
              torch_dtype=torch.bfloat16,
              attn_implementation="flash_attention_2",
              use_cache=False,
          )
inputs = xxxx (Left Padding Input Tokens)
reward = reward_model.model(*inputs).last_hidden_state
reward = reward_model.score(reward)[:, -1]

RL Training: PPO/REINFORCE++ with Ray and vLLM

All RL training in OpenRLHF runs through the agent execution pipeline. The following example shows single-turn agent execution (default mode) with Hybrid Engine for optimal performance:

# launch the master node of ray in container
ray start --head --node-ip-address 0.0.0.0 --num-gpus 8

# if you want to launch ray on more nodes, use
ray start --address {MASTER-NODE-ADDRESS}:6379  --num-gpus 8

ray job submit --address="http://127.0.0.1:8265" \
   --runtime-env-json='{"working_dir": "/openrlhf"}' \
   -- python3 -m openrlhf.cli.train_ppo_ray \
   --ref.num_nodes 1 \
   --ref.num_gpus_per_node 8 \
   --reward.num_nodes 1 \
   --reward.num_gpus_per_node 8 \
   --critic.num_nodes 1 \
   --critic.num_gpus_per_node 8 \
   --actor.num_nodes 1 \
   --actor.num_gpus_per_node 8 \
   --vllm.num_engines 4 \
   --vllm.tensor_parallel_size 2 \
   --train.colocate_all \
   --vllm.gpu_memory_utilization 0.5 \
   --actor.model_name_or_path OpenRLHF/Llama-3-8b-sft-mixture \
   --reward.model_name_or_path OpenRLHF/Llama-3-8b-rm-700k \
   --ckpt.output_dir /openrlhf/examples/test_scripts/final/llama3-8b-rlhf \
   --ckpt.path /openrlhf/examples/test_scripts/ckpt/llama3-8b-rlhf \
   --ckpt.save_hf \
   --train.batch_size 128 \
   --rollout.batch_size 1024 \
   --train.dynamic_batch_enable \
   --rollout.n_samples_per_prompt 1 \
   --train.max_epochs 1 \
   --data.max_len 2048 \
   --data.max_samples 100000 \
   --ds.zero_stage 3 \
   --ds.param_dtype bf16 \
   --actor.adam.lr 5e-7 \
   --critic.adam.lr 9e-6 \
   --algo.kl.init_coef 0.01 \
   --data.prompt_dataset OpenRLHF/prompt-collection-v0.1 \
   --data.input_key context_messages \
   --data.apply_chat_template \
   --reward.normalize_enable \
   --actor.gradient_checkpointing_enable \
   --ds.packing_samples \
   --vllm.enforce_eager \
   --vllm.enable_sleep \
   --ds.enable_sleep \
   --logger.wandb.key {wandb_token}

# Algorithm Variants (all use single-turn agent execution):
# --algo.advantage.estimator reinforce        # REINFORCE++
# --algo.advantage.estimator rloo             # RLOO
# --algo.advantage.estimator reinforce_baseline  # REINFORCE++-baseline (best for RLVR)
# --algo.advantage.estimator group_norm       # GRPO
# --algo.advantage.estimator dr_grpo          # Dr. GRPO
# --algo.advantage.estimator flash_reinforce  # FlashREINFORCE (single rollout: --rollout.n_samples_per_prompt 1)

# Advanced Options:
# --algo.kl.init_coef 0                                    # No reference model
# --reward.remote_url http://host:5000/get_reward         # HTTP reward model
# --rollout.n_samples_per_prompt 4                            # Multiple samples per prompt
# --rollout.vllm_generate_batch_size 2048                     # Oversample at generation (> rollout_batch_size); requires --train.async_enable
# --algo.advantage.is_correction_level token                    # vLLM importance sampling correction for off-policy rollouts: token | seq (per-sequence mean)
# --algo.advantage.is_correction_mode mask                      # Out-of-band treatment: mask (ICEPOP / seq-mask-tis) | clip (TIS, token level only)
# --algo.advantage.is_correction_gating ratio                   # Gated statistic: ratio (the IS weight) | binary_kl | tv (trust region on the sampled token)
# --algo.advantage.is_correction_threshold 0.5 5.0              # [low, high] band on the gated statistic; a single value is an upper bound only
# --actor.loss_agg_mode seq-mean-token-mean                     # Policy-loss aggregation: token-mean (default) | seq-mean-token-mean (every sequence weighs the same)
# --ckpt.best_metric_key eval_default_pass1                # Save best checkpoint by eval metric (empty = auto-detect first pass1, 'none' = disable)
# --actor.policy_loss_type gspo                             # Use GSPO policy loss variant (vs default 'ppo')

📚 More Examples: See examples/scripts and Documentation


🎯 Single-Turn Agent: Reinforced Fine-tuning with Custom Rewards

The single-turn agent execution (default mode) supports custom reward functions—perfect for reinforced fine-tuning without a trained reward model. Instead of using a pre-trained reward model, you provide a Python function that computes rewards on-the-fly.

Ideal for:

  • Rule-based rewards (length, format, code execution, math verification)
  • External API rewards (judge models, compilers, test suites)
  • Hybrid rewards (combining multiple signals)

Example: Custom Reward Function

# reward_func.py
import torch

def reward_func(queries, prompts, labels):
    """
    Compute custom rewards for generated responses.
    
    Args:
        queries: List[str] - Full text (prompt + response)
        prompts: List[str] - Original prompts only
        labels: List[str] - Ground truth labels (from --label_key)
    
    Returns:
        dict with:
            - rewards: Tensor for advantage calculation
            - scores: Tensor for dynamic filtering (0-1 range)
            - extra_logs: Dict for wandb logging
    """
    batch_size = len(queries)
    
    # Example: Random rewards (replace with your logic)
    # Real examples: code execution, math verification, format checking
    reward = torch.randint(0, 2, (batch_size,)).float()

    return {
        "rewards": reward,           # Used in RL advantage calculation
        "scores": reward,            # Used for dynamic filtering (--dynamic_filtering)
        "extra_logs": {              # Logged to wandb
            "custom_metric": reward.mean().item(),
        },
    }

Usage

ray job submit --address="http://127.0.0.1:8265" \
  --runtime-env-json='{"working_dir": "/openrlhf"}' \
  -- python3 -m openrlhf.cli.train_ppo_ray \
  --actor.model_name_or_path meta-llama/Meta-Llama-3-8B \
  --train.dynamic_batch_enable \
  --reward.remote_url /path/to/reward_func.py \
  --data.label_key answer \
  --data.prompt_dataset your_prompt_dataset \
  ... # other training args

Key Parameter: --data.label_key answer passes the "answer" field from your dataset to reward_func as labels.

📖 Full Example: examples/scripts/train_ppo_with_reward_fn.sh


🤖 Multi-Turn Agent: Complex Environment Interactions

For tasks requiring multi-step interactions (reasoning chains, coding with feedback, game playing), OpenRLHF provides the Multi-Turn Agent Execution mode.

Building Custom Multi-Turn Agents

Implement AgentInstanceBase with reset/step methods:

# agent_func.py
import random
from typing import Any, Dict

import torch
from openrlhf.utils.agent import AgentInstanceBase, MultiTurnAgentExecutor


# A simple n-step random environment
class AgentInstance(AgentInstanceBase):
    async def __init__(self, *args, **kwargs):
        self.step_idx = 0
        self.max_steps = random.randint(1, 3)  # 1-3 steps

    async def reset(self, states: dict, **kwargs):
        return {"observation": states["observation"]}  # Return original text observation

    async def step(self, states: dict, **kwargs) -> Dict[str, Any]:
        print(f"step_idx: {self.step_idx}, max_steps: {self.max_steps}")

        observation_text = states["observation_text"]
        action_text = states["action_text"]
        label = states["label"]

        # Check if episode is done
        done = self.step_idx >= self.max_steps
        reward = torch.randint(0, 2, (1,)).float() if done else torch.tensor(0)

        # Generate environment feedback based on whether episode is done
        environment_feedback = (
            "\n\nHuman: [CORRECT]\n</s>"
            if done
            else "\n\nHuman: [INCORRECT]\nPlease analyze the issues and try again.\n</s>\n\nAssistant: "
        )

        self.step_idx += 1

        return {
            "rewards": reward,  # Rewards for advantage calculation
            "scores": reward,  # Scores for dynamic filtering (0-1 reward)
            "environment_feedback": environment_feedback,  # Environment feedback text
            "done": done,  # Boolean indicating if the episode is complete
            "sampling_params": states.get("sampling_params", None),  # Parameters for vLLM sampling in next step
            "extra_logs": {"dummy_scores": reward},  # Additional logging information
        }


class AgentExecutor(MultiTurnAgentExecutor):
    def __init__(self):
        super().__init__(AgentInstance)

Then launch with:

ray job submit --address="http://127.0.0.1:8265" \
  --runtime-env-json='{"working_dir": "/openrlhf"}' \
  -- python3 -m openrlhf.cli.train_ppo_ray \
  ...
  --train.dynamic_batch_enable \
  --train.agent_func_path /path/to/agent_func.py \
  --train.async_enable  # Optional: enable async pipeline

Configuration Options

Async Pipeline (for higher throughput):

  • Enable: --train.async_enable
  • Buffer size: --train.async_queue_size 1 (larger = more off-policy, default 1)
  • Partial rollout: --train.partial_rollout_enable — uses vLLM pause/resume for weight sync instead of locking, allowing generation to overlap with training. In-flight samples may contain tokens from both old and new weights.

Training Modes:

  • Synchronous: Default, better stability
  • Asynchronous: Higher throughput, may affect convergence
  • Hybrid Engine: Best GPU utilization with --train.colocate_all (remove --train.async_enable)

📚 Examples:

OpenAI-Compatible Agent Server

For multi-turn agents that need an OpenAI-compatible chat API (e.g., integrating external tool-use frameworks), agent_func_openai_server_executor.py wraps vLLM as a local /v1/chat/completions server while collecting token-level traces for RL training.

  • Exposes standard OpenAI endpoints (/v1/chat/completions, /v1/models, /tokenize)
  • Automatically collects token IDs and logprobs per session for RL training
  • Delta-tokenization reuses prefix tokens across multi-turn calls
  • Override run_agent() to plug in your own multi-turn workflow
python3 -m openrlhf.cli.train_ppo_ray \
  --train.agent_func_path examples/python/agent_func_openai_server_executor.py \
  ... # other training args

🔧 Advanced Topics

LoRA: Merging Adapters

When using LoRA/QLoRA, OpenRLHF saves only the adapter weights. To deploy or continue training, merge the adapter with the base model:

python -m openrlhf.cli.lora_combiner \
    --model_path meta-llama/Meta-Llama-3-8B \
    --lora_path ./checkpoint/llama3-8b-rm \
    --output_path ./checkpoint/llama-3-8b-rm-combined \
    --is_rm \
    --ds.param_dtype bf16

Performance Tuning Guide

Optimize OpenRLHF for your hardware and workload with these recommendations:

🎯 Execution Modes: Throughput vs. Stability

Pick the execution mode based on your priority — OpenRLHF gives you a clear tradeoff knob:

Mode Flags Characteristics When to Use
Hybrid Engine (colocated) --train.colocate_all
--vllm.enable_sleep
--ds.enable_sleep
Most stable — strictly on-policy, every rollout uses the latest weights. Serial generate→train cycle. Research, sensitive RL algorithms, reproducibility, recipe validation
Async Training --train.async_enable
--train.async_queue_size N
Highest throughput — generation and training run in parallel. Tune off-policyness via --train.async_queue_size (larger = more off-policy). Production throughput when convergence is already validated
Async + Partial Rollout --train.async_enable
--train.partial_rollout_enable
Maximum overlap — vLLM pause/resume instead of locking, in-flight samples may mix old/new weights. Most aggressive off-policy. Pushing async throughput further; pair with --algo.advantage.is_correction_level token

⚡ Other Speed Optimizations

Optimization Flag When to Use
Sample Packing --ds.packing_samples Always (especially training)
Dynamic Batch --train.dynamic_batch_enable Variable sequence lengths
DeepCompile --ds.deepcompile PyTorch 2.0+
Overlap Comm --ds.overlap_comm Sufficient GPU memory
Prefix Caching vLLM config n_samples_per_prompt > 1
Oversampling --rollout.vllm_generate_batch_size > --rollout.batch_size Async mode, to amortize generation cost / feed dynamic filtering

💾 Memory Management

When you have enough memory:

  • ✅ Disable --ds.adam_offload
  • ✅ Enable --ds.overlap_comm
  • ✅ Use --train.colocate_critic_reward and --train.colocate_actor_ref

When hitting OOM:

  • ❌ Disable all --colocate_* options
  • ✅ Reduce batch sizes
  • ✅ Enable gradient checkpointing

🎮 Batch Size Tuning

  1. Generation Phase: Maximize --rollout.micro_batch_size, minimize vLLM TP size
  2. Training Phase: Maximize --train.micro_batch_size, enable --ds.packing_samples

📖 More Details: Performance Tuning Documentation

Companies and Organizations using OpenRLHF

  • Google
  • ByteDance
  • Tencent
  • Alibaba
  • Baidu
  • China Telecom
  • Vivo
  • Allen AI
  • NexusFlow
  • Jülich Supercomputing Centre (JSC)
  • Berkeley Starling Team
  • M-A-P
  • ...

Join Us

How to Join?

  1. Email us at janhu9527@gmail.com or join GitHub Organization. Please include the following details:
    • Your name
    • Your GitHub username
    • Your areas of interest
    • Your skills and experience related to NLP and/or AI
  2. You can also join us through the official GitHub OpenRLHF ↗ project page. Just create an issue about your interest to contribute and we will get back to you.

What can you do?

  1. Join the team and participate in the development of the OpenRLHF project.
  2. Contribute to the project by submitting pull requests.
  3. Help improve documentation, fix bugs, or create new features.
  4. Share the project and help us grow the community.

Sponsor Us

Your sponsorship can help us maintain and improve OpenRLHF. If you find this project useful, please consider sponsoring us. You can sponsor us on Open Collective ↗.

Starchart

Star History Chart

Contributors

A big thank you to all our contributors! If you want to contribute, feel free to make a pull request or create an issue.

References & Acknowledgements

We would like to express our gratitude to the following projects and organizations for their contributions to the field of AI and NLP:

Our project would also like to thank ColossalChat and DeepSpeedChat. In the early stages of the project, we referred to their code design. Our project would like to thank Netmind.AI for the GPU support of developing ring attention.

(2024/7) Our GitHub organization has changed from OpenLLMAI to OpenRLHF.

Citation

OpenRLHF

@article{hu2024openrlhf,
  title={OpenRLHF: An Easy-to-use, Scalable and High-performance RLHF Framework},
  author={Jian Hu and Xibin Wu and Zilin Zhu and Xianyu and Weixun Wang and Dehao Zhang and Yu Cao},
  journal={arXiv preprint arXiv:2405.11143},
  year={2024}
}

REINFORCE++-baseline

@article{hu2026reinforce++,
  title={Reinforce++: A simple and efficient approach for aligning large language models},
  author={Hu, Jian},
  journal={arXiv preprint arXiv:2501.03262},
  year={2026}
}

OpenRLHF © 2026 OpenRLHF. All Rights Reserved.

Metadata

Release files for openrlhf 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for openrlhf 0.12.0
File Interpreter ABI Platform Actions
openrlhf-0.12.0-cp312-cp312-manylinux1_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.5+ x86-64 Details for openrlhf-0.12.0-cp312-cp312-manylinux1_x86_64.whl
openrlhf-0.12.0-cp311-cp311-manylinux1_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.5+ x86-64 Details for openrlhf-0.12.0-cp311-cp311-manylinux1_x86_64.whl

Total release size: 417.8 kB

Release files / openrlhf-0.12.0-cp312-cp312-manylinux1_x86_64.whl

Download URL openrlhf-0.12.0-cp312-cp312-manylinux1_x86_64.whl
Size 208.9 kB
Tags CPython 3.12 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d6a4628127115c621108a6f6b6df084b8b0a8d3a2154ceeb586de828408ef50a
BLAKE2b-256 checksum
How to use checksums
cacd71859e77ed310deff1e8afdadc71260545712ab3b37eaeed1309ea1737dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / openrlhf-0.12.0-cp311-cp311-manylinux1_x86_64.whl

Download URL openrlhf-0.12.0-cp311-cp311-manylinux1_x86_64.whl
Size 208.9 kB
Tags CPython 3.11 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
c7ffed125c4cce936ce0cbbfc15466f1531dc000b70df0d5f2c8829fc9942c49
BLAKE2b-256 checksum
How to use checksums
d099616f6c7591dacd84c6a666aebda67bf685828c4e4460ffdff634a61c95e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Security for openrlhf 0.12.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page