SuperAPIAI Directory

OpenRLHF

github.com · AI developer platforms

An Easy-to-use, Scalable and High-performance RLHF Framework (70B+ PPO Full Tuning & Iterative DPO & LoRA & RingAttention & RFT).

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

Purpose

OpenRLHF is an open-source framework for Reinforcement Learning from Human Feedback (RLHF) for large language models (and vision-language models), used for alignment and reinforcement training on top of pretrained or fine-tuned models, and can also be used to build reinforcement learning-based agentic language model training pipelines. It is positioned to provide a high-performance, scalable, easy-to-use, and lightweight production-grade training solution.

Architectural Foundation

OpenRLHF is built on a distributed architecture of Ray + vLLM + DeepSpeed:

  • Ray: As the distributed scheduler and controller, it distributes the Actor, Reward, Reference, and Critic models across different GPUs, supporting scaling to 70B+ parameter scales. Hybrid engine scheduling allows all models and the vLLM engine to share GPU resources, reducing idle time.
  • vLLM: A high-performance inference engine. The materials point out that RLHF training spends about 80% of its time on sample generation, and the framework achieves high-throughput generation through vLLM combined with AutoTP (automatic tensor parallelism) and pipeline parallelism (PP); later versions also introduced the Molt backend, which is claimed to be stronger than DeepSpeed and can scale RL training to hundreds of billions of parameters.
  • DeepSpeed: Implements memory-efficient training based on ZeRO-3, deepcompile, AutoTP, RingAttention, etc., and can be used directly with HuggingFace models.
  • Transformers: Natively integrates HuggingFace Transformers for convenient model loading, state management, and fine-tuning.
  • NCCL / CUDA IPC: Used for efficient inter-GPU communication in distributed training and inference.

Design Paradigm: Agent-Based Execution

OpenRLHF is the first RLHF framework to implement a unified agentic paradigm. Whether standard PPO or complex multi-turn reasoning, every training run follows a consistent agent execution pipeline. It unifies generation and training through token-in-token-out agent execution, ensuring consistency, facilitating single-turn/multi-turn extension, and avoiding mismatches at the text level. The agent execution mode is independent of the chosen RL algorithm, so any algorithm can be used with any execution mode.

RL Algorithms

The framework implements PPO, REINFORCE++, REINFORCE++-baseline, GRPO, and RLOO, and incorporates optimization techniques from practical guides and community best practices. The algorithms are decoupled from the agent execution mode, and all run through a unified token-in-token-out pipeline.

Main Capabilities

  • Agentic RL training:
    • Single-turn mode (default, covering about 99% of use cases): each prompt is generated in one pass; supports all RL algorithms; supports custom reward functions (--reward.remote_url); uses a hybrid engine to improve GPU utilization.
    • Multi-turn mode (advanced interactive tasks): multi-step interaction with environment feedback; supports all RL algorithms; custom agent functions via --train.agent_func_path; provides an example of wrapping vLLM as a local OpenAI Agent Server; supports asynchronous pipelines (--train.async_enable) to improve throughput.
  • Supervised training and preference learning: provides workflows such as SFT, reward model training, and RL training; model checkpoints are compatible with HuggingFace and models can be specified via --actor.model_name_or_path, --reward.model_name_or_path, --critic.model_name_or_path; for reward models, it is recommended to set --value_prefix_head to score so that they can be loaded with AutoModelForSequenceClassification.
  • Efficiency optimization: sample packing (--ds.packing_samples), vLLM acceleration (--vllm.num_engines), DeepSpeed AutoTP tensor parallelism (--ds.tensor_parallel_size), RingAttention long context (--ds.ring_attn_size), SLURM multi-machine training, LoRA/QLoRA (--ds.lora.rank, --ds.load_in_4bit), MoE (--actor.aux_loss_coef), FlashAttention (--ds.attn_implementation), HuggingFace chat templates (--data.apply_chat_template).
  • DAPO dynamic filtering/dynamic sampling: --algo.dynamic_filtering_enable, score range --algo.dynamic_filtering_range, requires --rollout.n_samples_per_prompt > 1, and configure --reward.remote_url or --train.agent_func_path.
  • Length control and truncation penalty: DAPO-style overlong penalty (--reward.overlong_buffer_len, --reward.overlong_penalty_factor); ProRL-style truncation penalty (--reward.stop_properly_penalty_coef).
  • Optimizer: default AdamW (--{actor,critic}.optim adam); optional Muon (requires DeepSpeed >= 0.18.2, only 2D weights, embeddings/output heads/1D parameters use aux-AdamW), and because Newton-Schulz produces scale-invariant updates, it is recommended to disable global gradient clipping.
  • Production features: Wandb (--logger.wandb.key) and TensorBoard (--logger.tensorboard_dir) logging; checkpoint resume (--ckpt.load_enable, --ckpt.save_steps); save the best checkpoint according to evaluation metrics (--ckpt.best_metric_key); evaluation datasets (--eval.dataset, --eval.temperature, --eval.n_samples_per_prompt), also supported in asynchronous training; multi-process data loading (--data.dataloader_num_workers, applicable to PPO/SFT/RM/DPO); PPO observability (actor/critic gradient norms and time spent in each stage).
  • Data preparation: supports --data.input_key to specify the input key, --data.apply_chat_template to use the tokenizer chat template, --data.input_template for a custom template, --data.prompt_probs/--data.dataset_probs to mix multiple datasets, and --eval.dataset to specify the evaluation set.
  • Single-turn custom rewards: Python functions can be provided to compute rewards instantly, covering rule-based rewards (length, format, code execution, math verification), external API rewards (judge models, compilers, test suites), and hybrid rewards; --data.label_key can pass dataset fields as labels to reward_func.
  • Multi-turn agents: implement the reset/step methods of AgentInstanceBase; the asynchronous pipeline can configure --train.async_enable, --train.async_queue_size (larger values bias more toward off-policy, default 1), and partial rollout.

Usage

Docker is recommended for painless installation, and installation from source is also supported; vLLM 0.29.0+ is recommended for best performance (the materials mention Dockerfiles and an Nvidia-Docker installation script). After preparing the dataset, you can use the launch scripts in the examples/scripts directory, or directly execute commands for SFT, reward model training, and RL training. The RL training example shows single-turn agent execution (default mode) with a hybrid engine; for reasoning tasks (RLVR), --algo.advantage.estimator reinforce_baseline can be used. In a Ray environment, --runtime-env-json can be used for automatic deployment; if you encounter DeepSpeed GPU device setting issues, you can set export RAY_EXPERIMENTAL_NOSET_CUDA_VISIBLE_DEVICES=1. See the official documentation for more examples.

Applicable scenarios

Large-scale RLHF alignment training, reward model and SFT training, reinforcement training of reasoning models (such as DeepSeek-R1 reproduction), multi-turn interaction and agent tasks, reinforcement fine-tuning based on custom reward functions, and RLHF for multimodal (VLM) image-text input.

Limitations

The materials do not provide specific pricing, fees, or commercial licensing information (not currently available); they do not give precise hardware thresholds and performance numbers for each scale; some commands and example code in the documentation are truncated (such as the asynchronous partial rollout parameter description is incomplete); for actual use, please refer to the official repository and documentation.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools