openrlhf-training — Claude Code skill: RLHF training on Ray and vLLM
A skill that hands your agent ready commands for PPO, GRPO, RLOO and DPO runs on models from 7B to 70B+. Useful when training spans several GPUs or nodes.
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf-training -a claude-code
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a claude-codeWhat openrlhf-training does
The skill packages OpenRLHF commands for an agent to run. Three workflows are covered: a full SFT → reward model → PPO pipeline, GRPO without a critic, and DPO without a reward model. Each one comes as a launch line with its flags.
Setup starts in a Docker container built on nvcr.io/nvidia/pytorch:25.02-py3, followed by pip install openrlhf[vllm]. Before that the skill removes packages known to clash: xgboost, transformer_engine, flash_attn, pynvml. The cluster comes up with ray start --head, jobs go out through ray job submit. Running out of GPU memory? Drop --colocate_all_models and give each model its own GPUs.
Troubleshooting is part of the package. A DeepSpeed GPU index error is fixed by exporting RAY_EXPERIMENTAL_NOSET_CUDA_VISIBLE_DEVICES=1. Unstable training points to the Hybrid Engine with --vllm_enable_sleep and --deepspeed_enable_sleep. For single-node work with a simpler API, the skill points at TRL instead.
What it helps with
- run PPO on a 70B model across multiple nodes
- train a reward model on a preference dataset with DPO
- switch from PPO to GRPO and drop the critic model
- bring up a Ray cluster and submit a training job with
ray job submit - diagnose a DeepSpeed GPU index out of range failure
Example prompts for the agent
- show me how to launch PPO training with openrlhf-training on 8 GPUs
- set up GRPO without a critic for Llama-3-8B using the skill
- help me debug an OOM when training a large model in OpenRLHF
How to install openrlhf-training
1Skills CLI (Vercel)
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf-training -a claude-codenpx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a claude-code2Manually: put the files in place
~/.claude/skills/openrlhf/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/openrlhf/
1Skills CLI (Vercel)
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a codex2Manually: put the files in place
.agents/skills/openrlhf/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a cursor2Manually: put the files in place
.cursor/skills/openrlhf/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install Orchestra-Research/AI-Research-SKILLs openrlhf2Manually: put the files in place
.github/skills/openrlhf/SKILL.md1Skills CLI (Vercel)
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a gemini-cli2Platform CLI
gemini skills install https://github.com/Orchestra-Research/AI-Research-SKILLs --path 06-post-training/openrlhfManually: put the files in place
.devin/skills/openrlhf/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about openrlhf-training
How do I install openrlhf-training in Claude?
Run npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf-training -a claude-code. An alternative is npx skills add Orchestra-Research/AI-Research-SKILLs --skill openrlhf -a claude-code. The skill file lands at ~/.claude/skills/openrlhf/SKILL.md.
What does openrlhf-training do?
It gives your agent OpenRLHF commands for PPO, GRPO, RLOO and DPO training. The skill covers the full pipeline, algorithm selection and common failures.
What dependencies does it need?
OpenRLHF, Ray, vLLM, torch, transformers and deepspeed. Installation runs inside a PyTorch Docker container, where conflicting packages are removed first.
Source text
SKILL.md · MIT
---
name: openrlhf-training
description: High-performance RLHF framework with Ray+vLLM acceleration. Use for PPO, GRPO, RLOO, DPO training of large models (7B-70B+). Built on Ray, vLLM, ZeRO-3. 2× faster than DeepSpeedChat with distributed architecture and GPU resource sharing.
version: 1.0.0
author: Orchestra Research
license: MIT
tags: [Post-Training, OpenRLHF, RLHF, PPO, GRPO, RLOO, DPO, Ray, vLLM, Distributed Training, Large Models, ZeRO-3]
dependencies: [openrlhf, ray, vllm, torch, transformers, deepspeed]
---
# OpenRLHF - High-Performance RLHF Training
## Quick start
OpenRLHF is a Ray-based RLHF framework optimized for distributed training with vLLM inference acceleration.
**Installation**:
```bash
# Launch Docker container
docker run --runtime=nvidia -it --rm --shm-size="10g" --cap-add=SYS_ADMIN \
-v $PWD:/openrlhf nvcr.io/nvidia/pytorch:25.02-py3 bash
# Uninstall conflicts
sudo pip uninstall xgboost transformer_engine flash_attn pynvml -y
# Install OpenRLHF with vLLM
pip install openrlhf[vllm]
```
**PPO Training** (Hybrid Engine):
```bash
ray start --head --node-ip-address 0.0.0.0 --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 \
--colocate_all_models \
--vllm_gpu_memory_utilization 0.5 \
--pretrain OpenRLHF/Llama-3-8b-sft-mixture \
--reward_pretrain OpenRLHF/Llama-3-8b-rm-700k \
--save_path ./output/llama3-8b-rlhf \
--micro_train_batch_size 8 --train_batch_size 128 \
--micro_rollout_batch_size 16 --rollout_batch_size 1024 \
--max_epochs 1 --prompt_max_len 1024 --generate_max_len 1024 \
--zero_stage 3 --bf16 \
--actor_learning_rate 5e-7 --critic_learning_rate 9e-6 \
--init_kl_coef 0.01 --normalize_reward \
--gradient_checkpointing --packing_samples \
--vllm_enable_sleep --deepspeed_enable_sleep
```
**GRPO Training** (Group Normalized Policy Optimization):
```bash
# Same command as PPO, but add:
--advantage_estimator group_norm
```
## Common workflows
### Workflow 1: Full RLHF pipeline (SFT → Reward Model → PPO)
**Step 1: Train reward model** (DPO):
```bash
deepspeed --module openrlhf.cli.train_rm \
--save_path ./output/llama3-8b-rm \
--save_steps -1 --logging_steps 1 \
--eval_steps -1 --train_batch_size 256 \
--micro_train_batch_size 1 --pretrain meta-llama/Meta-Llama-3-8B \
--bf16 --max_epochs 1 --max_len 8192 \
--zero_stage 3 --learning_rate 9e-6 \
--dataset OpenRLHF/preference_dataset_mixture2_and_safe_pku \
--apply_chat_template --chosen_key chosen \
--rejected_key rejected --flash_attn --gradient_checkpointing
```
**Step 2: PPO training**:
```bash
ray start --head --node-ip-address 0.0.0.0 --num-gpus 8
ray job submit --address="http://127.0.0.1:8265" \
-- 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 \
--colocate_all_models \
--pretrain OpenRLHF/Llama-3-8b-sft-mixture \
--reward_pretrain ./output/llama3-8b-rm \
--save_path ./output/llama3-8b-ppo \
--micro_train_batch_size 8 --train_batch_size 128 \
--micro_rollout_batch_size 16 --rollout_batch_size 1024 \
--max_epochs 1 --prompt_max_len 1024 --generate_max_len 1024 \
--zero_stage 3 --bf16 \
--actor_learning_rate 5e-7 --critic_learning_rate 9e-6 \
--init_kl_coef 0.01 --normalize_reward \
--vllm_enable_sleep --deepspeed_enable_sleep
```
### Workflow 2: GRPO training (no critic model needed)
Memory-efficient alternative to PPO:
```bash
ray job submit --address="http://127.0.0.1:8265" \
-- python3 -m openrlhf.cli.train_ppo_ray \
--advantage_estimator group_norm \
--ref_num_nodes 1 --ref_num_gpus_per_node 8 \
--reward_num_nodes 1 --reward_num_gpus_per_node 8 \
--actor_num_nodes 1 --actor_num_gpus_per_node 8 \
--vllm_num_engines 4 --vllm_tensor_parallel_size 2 \
--colocate_all_models \
--pretrain OpenRLHF/Llama-3-8b-sft-mixture \
--reward_pretrain OpenRLHF/Llama-3-8b-rm-700k \
--save_path ./output/llama3-8b-grpo \
--micro_train_batch_size 8 --train_batch_size 128 \
--micro_rollout_batch_size 16 --rollout_batch_size 1024 \
--max_epochs 1 --bf16 \
--actor_learning_rate 5e-7 \
--init_kl_coef 0.01 --use_kl_loss --kl_estimator k3 \
--normalize_reward --no_advantage_std_norm
```
**Key GRPO parameters**:
- `--advantage_estimator group_norm` - Enables GRPO
- `--use_kl_loss` - KL loss from GRPO paper
- `--kl_estimator k3` - Loss function (k2 ≈ k1)
- `--no_advantage_std_norm` - Disables std normalization
### Workflow 3: DPO training (preference optimization)
Simpler alternative without reward model:
```bash
deepspeed --module openrlhf.cli.train_dpo \
--save_path ./output/llama3-8b-dpo \
--save_steps -1 --logging_steps 1 \
--eval_steps -1 --train_batch_size 256 \
--micro_train_batch_size 2 --pretrain meta-llama/Meta-Llama-3-8B \
--bf16 --max_epochs 1 --max_len 8192 \
--zero_stage 3 --learning_rate 5e-7 --beta 0.1 \
--dataset OpenRLHF/preference_dataset_mixture2_and_safe_pku \
--apply_chat_template --chosen_key chosen \
--rejected_key rejected --flash_attn --gradient_checkpointing
```
## When to use vs alternatives
**Use OpenRLHF when**:
- Training large models (7B-70B+) with RL
- Need vLLM inference acceleration
- Want distributed architecture with Ray
- Have multi-node GPU cluster
- Need PPO/GRPO/RLOO/DPO in one framework
**Algorithm selection**:
- **PPO**: Maximum control, best for complex rewards
- **GRPO**: Memory-efficient, no critic needed
- **RLOO**: Modified PPO with per-token KL
- **REINFORCE++**: More stable than GRPO, faster than PPO
- **DPO**: Simplest, no reward model needed
**Use alternatives instead**:
- **TRL**: Single-node training, simpler API
- **veRL**: ByteDance's framework for 671B models
- **DeepSpeedChat**: Integrated with DeepSpeed ecosystem
## Common issues
**Issue: GPU OOM with large models**
Disable model colocation:
```bash
# Remove --colocate_all_models flag
# Allocate separate GPUs for each model
--actor_num_gpus_per_node 8 \
--critic_num_gpus_per_node 8 \
--reward_num_gpus_per_node 8 \
--ref_num_gpus_per_node 8
```
**Issue: DeepSpeed GPU index out of range**
Set environment variable:
```bash
export RAY_EXPERIMENTAL_NOSET_CUDA_VISIBLE_DEVICES=1
```
**Issue: Training instability**
Use Hybrid Engine instead of async:
```bash
--colocate_all_models \
--vllm_enable_sleep \
--deepspeed_enable_sleep
```
Adjust KL coefficient:
```bash
--init_kl_coef 0.05 # Increase from 0.01
```
**Issue: Slow generation during PPO**
Enable vLLM acceleration:
```bash
--vllm_num_engines 4 \
--vllm_tensor_parallel_size 2 \
--vllm_gpu_memory_utilization 0.5
```
## Advanced topics
**Hybrid Engine GPU sharing**: See [references/hybrid-engine.md](references/hybrid-engine.md) for vLLM sleep mode, DeepSpeed sleep mode, and optimal node allocation.
**Algorithm comparison**: See [references/algorithm-comparison.md](references/algorithm-comparison.md) for PPO vs GRPO vs RLOO vs REINFORCE++ benchmarks and hyperparameters.
**Multi-node setup**: See [references/multi-node-training.md](references/multi-node-training.md) for Ray cluster configuration and fault tolerance.
**Custom reward functions**: See [references/custom-rewards.md](references/custom-rewards.md) for reinforced fine-tuning and agent RLHF.
## Hardware requirements
- **GPU**: NVIDIA A100/H100 recommended
- **VRAM**:
- 7B model: 8× A100 40GB (Hybrid Engine)
- 70B model: 48× A100 80GB (vLLM:Actor:Critic = 1:1:1)
- **Multi-node**: Ray cluster with InfiniBand recommended
- **Docker**: NVIDIA PyTorch container 25.02+
**Performance**:
- 2× faster than DeepSpeedChat
- vLLM inference acceleration
- Hybrid Engine minimizes GPU idle time
## Resources
- Docs: https://github.com/OpenRLHF/OpenRLHF
- Paper: https://arxiv.org/abs/2405.11143
- Examples: https://github.com/OpenRLHF/OpenRLHF/tree/main/examples
- Discord: Community support
© Orchestra Research · MIT · Orchestra-Research/AI-Research-SKILLs