{"id":"openrlhf","name":"openrlhf-training","summary":"Ray+vLLMアクセラレーションを備えた高性能RLHFフレームワーク。大規模モデル(7B-70B+)のPPO、GRPO、RLOO、DPOトレーニングに使用されます。","body":"# OpenRLHF - High-Performance RLHF Training\n\n## Quick start\n\nOpenRLHF is a Ray-based RLHF framework optimized for distributed training with vLLM inference acceleration.\n\n**Installation**:\n```bash\n# Launch Docker container\ndocker run --runtime=nvidia -it --rm --shm-size=\"10g\" --cap-add=SYS_ADMIN \\\n  -v $PWD:/openrlhf nvcr.io/nvidia/pytorch:25.02-py3 bash\n\n# Uninstall conflicts\nsudo pip uninstall xgboost transformer_engine flash_attn pynvml -y\n\n# Install OpenRLHF with vLLM\npip install openrlhf[vllm]\n```\n\n**PPO Training** (Hybrid Engine):\n```bash\nray start --head --node-ip-address 0.0.0.0 --num-gpus 8\n\nray job submit --address=\"http://127.0.0.1:8265\" \\\n  --runtime-env-json='{\"working_dir\": \"/openrlhf\"}' \\\n  -- python3 -m openrlhf.cli.train_ppo_ray \\\n  --ref_num_nodes 1 --ref_num_gpus_per_node 8 \\\n  --reward_num_nodes 1 --reward_num_gpus_per_node 8 \\\n  --critic_num_nodes 1 --critic_num_gpus_per_node 8 \\\n  --actor_num_nodes 1 --actor_num_gpus_per_node 8 \\\n  --vllm_num_engines 4 --vllm_tensor_parallel_size 2 \\\n  --colocate_all_models \\\n  --vllm_gpu_memory_utilization 0.5 \\\n  --pretrain OpenRLHF/Llama-3-8b-sft-mixture \\\n  --reward_pretrain OpenRLHF/Llama-3-8b-rm-700k \\\n  --save_path ./output/llama3-8b-rlhf \\\n  --micro_train_batch_size 8 --train_batch_size 128 \\\n  --micro_rollout_batch_size 16 --rollout_batch_size 1024 \\\n  --max_epochs 1 --prompt_max_len 1024 --generate_max_len 1024 \\\n  --zero_stage 3 --bf16 \\\n  --actor_learning_rate 5e-7 --critic_learning_rate 9e-6 \\\n  --init_kl_coef 0.01 --normalize_reward \\\n  --gradient_checkpointing --packing_samples \\\n  --vllm_enable_sleep --deepspeed_enable_sleep\n```\n\n**GRPO Training** (Group Normalized Policy Optimization):\n```bash\n# Same command as PPO, but add:\n--advantage_estimator group_norm\n```\n\n## Common workflows\n\n### Workflow 1: Full RLHF pipeline (SFT → Reward Model → PPO)\n\n**Step 1: Train reward model** (DPO):\n```bash\ndeepspeed --module openrlhf.cli.train_rm \\\n  --save_path ./output/llama3-8b-rm \\\n  --save_steps -1 --logging_steps 1 \\\n  --eval_steps -1 --train_batch_size 256 \\\n  --micro_train_batch_size 1 --pretrain meta-llama/Meta-Llama-3-8B \\\n  --bf16 --max_epochs 1 --max_len 8192 \\\n  --zero_stage 3 --learning_rate 9e-6 \\\n  --dataset OpenRLHF/preference_dataset_mixture2_and_safe_pku \\\n  --apply_chat_template --chosen_key chosen \\\n  --rejected_key rejected --flash_attn --gradient_checkpointing\n```\n\n**Step 2: PPO training**:\n```bash\nray start --head --node-ip-address 0.0.0.0 --num-gpus 8\n\nray job submit --address=\"http://127.0.0.1:8265\" \\\n  -- python3 -m openrlhf.cli.train_ppo_ray \\\n  --ref_num_nodes 1 --ref_num_gpus_per_node 8 \\\n  --reward_num_nodes 1 --reward_num_gpus_per_node 8 \\\n  --critic_num_nodes 1 --critic_num_gpus_per_node 8 \\\n  --actor_num_nodes 1 --actor_num_gpus_per_node 8 \\\n  --vllm_num_engines 4 --vllm_tensor_parallel_size 2 \\\n  --colocate_all_models \\\n  --pretrain OpenRLHF/Llama-3-8b-sft-mixture \\\n  --reward_pretrain ./output/llama3-8b-rm \\\n  --save_path ./output/llama3-8b-ppo \\\n  --micro_train_batch_size 8 --train_batch_size 128 \\\n  --micro_rollout_batch_size 16 --rollout_batch_size 1024 \\\n  --max_epochs 1 --prompt_max_len 1024 --generate_max_len 1024 \\\n  --zero_stage 3 --bf16 \\\n  --actor_learning_rate 5e-7 --critic_learning_rate 9e-6 \\\n  --init_kl_coef 0.01 --normalize_reward \\\n  --vllm_enable_sleep --deepspeed_enable_sleep\n```\n\n### Workflow 2: GRPO training (no critic model needed)\n\nMemory-efficient alternative to PPO:\n\n```bash\nray job submit --address=\"http://127.0.0.1:8265\" \\\n  -- python3 -m openrlhf.cli.train_ppo_ray \\\n  --advantage_estimator group_norm \\\n  --ref_num_nodes 1 --ref_num_gpus_per_node 8 \\\n  --reward_num_nodes 1 --reward_num_gpus_per_node 8 \\\n  --actor_num_nodes 1 --actor_num_gpus_per_node 8 \\\n  --vllm_num_engines 4 --vllm_tensor_parallel_size 2 \\\n  --colocate_all_models \\\n  --pretrain OpenRLHF/Llama-3-8b-sft-mixture \\\n  --reward_pretrain OpenRLHF/Llama-3-8b-rm-700k \\\n  --save_path ./output/llama3-8b-grpo \\\n  --micro_train_batch_size 8 --train_batch_size 128 \\\n  --micro_rollout_batch_size 16 --rollout_batch_size 1024 \\\n  --max_epochs 1 --bf16 \\\n  --actor_learning_rate 5e-7 \\\n  --init_kl_coef 0.01 --use_kl_loss --kl_estimator k3 \\\n  --normalize_reward --no_advantage_std_norm\n```\n\n**Key GRPO parameters**:\n- `--advantage_estimator group_norm` - Enables GRPO\n- `--use_kl_loss` - KL loss from GRPO paper\n- `--kl_estimator k3` - Loss function (k2 ≈ k1)\n- `--no_advantage_std_norm` - Disables std normalization\n\n### Workflow 3: DPO training (preference optimization)\n\nSimpler alternative without reward model:\n\n```bash\ndeepspeed --module openrlhf.cli.train_dpo \\\n  --save_path ./output/llama3-8b-dpo \\\n  --save_steps -1 --logging_steps 1 \\\n  --eval_steps -1 --train_batch_size 256 \\\n  --micro_train_batch_size 2 --pretrain meta-llama/Meta-Llama-3-8B \\\n  --bf16 --max_epochs 1 --max_len 8192 \\\n  --zero_stage 3 --learning_rate 5e-7 --beta 0.1 \\\n  --dataset OpenRLHF/preference_dataset_mixture2_and_safe_pku \\\n  --apply_chat_template --chosen_key chosen \\\n  --rejected_key rejected --flash_attn --gradient_checkpointing\n```\n\n## When to use vs alternatives\n\n**Use OpenRLHF when**:\n- Training large models (7B-70B+) with RL\n- Need vLLM inference acceleration\n- Want distributed architecture with Ray\n- Have multi-node GPU cluster\n- Need PPO/GRPO/RLOO/DPO in one framework\n\n**Algorithm selection**:\n- **PPO**: Maximum control, best for complex rewards\n- **GRPO**: Memory-efficient, no critic needed\n- **RLOO**: Modified PPO with per-token KL\n- **REINFORCE++**: More stable than GRPO, faster than PPO\n- **DPO**: Simplest, no reward model needed\n\n**Use alternatives instead**:\n- **TRL**: Single-node training, simpler API\n- **veRL**: ByteDance's framework for 671B models\n- **DeepSpeedChat**: Integrated with DeepSpeed ecosystem\n\n## Common issues\n\n**Issue: GPU OOM with large models**\n\nDisable model colocation:\n```bash\n# Remove --colocate_all_models flag\n# Allocate separate GPUs for each model\n--actor_num_gpus_per_node 8 \\\n--critic_num_gpus_per_node 8 \\\n--reward_num_gpus_per_node 8 \\\n--ref_num_gpus_per_node 8\n```\n\n**Issue: DeepSpeed GPU index out of range**\n\nSet environment variable:\n```bash\nexport RAY_EXPERIMENTAL_NOSET_CUDA_VISIBLE_DEVICES=1\n```\n\n**Issue: Training instability**\n\nUse Hybrid Engine instead of async:\n```bash\n--colocate_all_models \\\n--vllm_enable_sleep \\\n--deepspeed_enable_sleep\n```\n\nAdjust KL coefficient:\n```bash\n--init_kl_coef 0.05  # Increase from 0.01\n```\n\n**Issue: Slow generation during PPO**\n\nEnable vLLM acceleration:\n```bash\n--vllm_num_engines 4 \\\n--vllm_tensor_parallel_size 2 \\\n--vllm_gpu_memory_utilization 0.5\n```\n\n## Advanced topics\n\n**Hybrid Engine GPU sharing**: See [references/hybrid-engine.md](references/hybrid-engine.md) for vLLM sleep mode, DeepSpeed sleep mode, and optimal node allocation.\n\n**Algorithm comparison**: See [references/algorithm-comparison.md](references/algorithm-comparison.md) for PPO vs GRPO vs RLOO vs REINFORCE++ benchmarks and hyperparameters.\n\n**Multi-node setup**: See [references/multi-node-training.md](references/multi-node-training.md) for Ray cluster configuration and fault tolerance.\n\n**Custom reward functions**: See [references/custom-rewards.md](references/custom-rewards.md) for reinforced fine-tuning and agent RLHF.\n\n## Hardware requirements\n\n- **GPU**: NVIDIA A100/H100 recommended\n- **VRAM**:\n  - 7B model: 8× A100 40GB (Hybrid Engine)\n  - 70B model: 48× A100 80GB (vLLM:Actor:Critic = 1:1:1)\n- **Multi-node**: Ray cluster with InfiniBand recommended\n- **Docker**: NVIDIA PyTorch container 25.02+\n\n**Performance**:\n- 2× faster than DeepSpeedChat\n- vLLM inference acceleration\n- Hybrid Engine minimizes GPU idle time\n\n## Resources\n\n- Docs: https://github.com/OpenRLHF/OpenRLHF\n- Paper: https://arxiv.org/abs/2405.11143\n- Examples: https://github.com/OpenRLHF/OpenRLHF/tree/main/examples\n- Discord: Community support","author":"@Orchestra-Research","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/main/06-post-training/openrlhf","license":"MIT","category":"devops","lang":"en","tokens":2376,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/algorithm-comparison.md","size":9783,"sha256":"422092fcee7e6343e78239e97f41fff34ca22990c9cc65d95343b9d861655342"},{"path":"references/custom-rewards.md","size":15865,"sha256":"2409844debc1f2c4a084f33b14e1fcb7ed0d652d65ef62e2bfce0739c34e0665"},{"path":"references/hybrid-engine.md","size":7266,"sha256":"6e992f67a2392c297dfa57632319bbb6549b6df4f129f61e2811297f86ae3e48"},{"path":"references/multi-node-training.md","size":11099,"sha256":"0f051f0db1260d8df6d01371fa90de8fa00d9dae7cef407f03d5b39efc5653b7"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["arxiv.org","docs.ray.io","docs.vllm.ai","www.deepspeed.ai"]}}