{"id":"verl","name":"verl-rl-training","summary":"verl(Volcano Engine RL)を用いて強化学習を用いるLLMのトレーニングガイダンスを提供します。","body":"# verl: Volcano Engine Reinforcement Learning for LLMs\n\nverl is a flexible, efficient, and production-ready RL training library for large language models from ByteDance's Seed team. It implements the HybridFlow framework (EuroSys 2025) and powers models like Doubao-1.5-pro achieving O1-level performance on math benchmarks.\n\n## When to Use verl\n\n**Choose verl when you need:**\n- Production-ready RL training at scale (tested up to 671B parameters)\n- Flexibility to swap backends (FSDP ↔ Megatron-LM ↔ vLLM ↔ SGLang)\n- Support for multiple RL algorithms (PPO, GRPO, RLOO, REINFORCE++, DAPO)\n- Multi-turn rollout with tool calling for agentic workflows\n- Vision-language model RL training\n\n**Consider alternatives when:**\n- You need Megatron-native training → use **slime** or **miles**\n- You want PyTorch-native abstractions with Monarch → use **torchforge**\n- You only need simple SFT/DPO → use **TRL** or **Axolotl**\n\n## Key Features\n\n- **Training backends**: FSDP, FSDP2, Megatron-LM\n- **Rollout engines**: vLLM, SGLang, HuggingFace Transformers\n- **Algorithms**: PPO, GRPO, DAPO, RLOO, ReMax, REINFORCE++, SPIN, SPPO\n- **Models**: Qwen-3, Llama-3.1, DeepSeek, Gemma-2 (0.5B to 671B)\n- **Advanced**: LoRA RL, sequence parallelism, expert parallelism, multi-turn tools\n\n## Installation\n\n```bash\n# Option 1: pip install\npip install verl[vllm]  # or verl[sglang] for SGLang backend\n\n# Option 2: Docker (recommended for production)\ndocker pull verlai/verl:vllm011.latest\n\n# Option 3: From source\ngit clone https://github.com/volcengine/verl.git\ncd verl && pip install -e .[vllm,math]\n```\n\n## Quick Start: GRPO Training\n\n```bash\npython3 -m verl.trainer.main_ppo \\\n    algorithm.adv_estimator=grpo \\\n    data.train_files=~/data/gsm8k/train.parquet \\\n    actor_rollout_ref.model.path=Qwen/Qwen2.5-7B \\\n    actor_rollout_ref.rollout.n=8 \\\n    actor_rollout_ref.actor.use_kl_loss=True \\\n    trainer.n_gpus_per_node=8\n```\n\n## Core Architecture\n\nverl uses a **HybridFlow** programming model separating control flow from computation:\n\n```\n┌─────────────────────────────────────────────────────────┐\n│ Single-Process Controller (Ray)                         │\n│ - Orchestrates: rollout → reward → train → sync        │\n└─────────────────────┬───────────────────────────────────┘\n                      │\n┌─────────────────────▼───────────────────────────────────┐\n│ Multi-Process Workers                                   │\n│ ├── ActorRolloutRefWorker (policy + generation)        │\n│ ├── CriticWorker (value estimation, PPO only)          │\n│ └── RewardManager (model-based or rule-based rewards)  │\n└─────────────────────────────────────────────────────────┘\n```\n\n---\n\n## Workflow 1: Math Reasoning with GRPO\n\nUse this workflow for training reasoning models on math tasks like GSM8K or MATH.\n\n### Prerequisites Checklist\n- [ ] GPU cluster with 8+ GPUs (H100 recommended)\n- [ ] Dataset in parquet format with `prompt` and `reward_model` columns\n- [ ] Base model from HuggingFace Hub\n\n### Step 1: Prepare Dataset\n\n```python\nimport pandas as pd\n\ndata = [\n    {\n        \"prompt\": [{\"role\": \"user\", \"content\": \"What is 15 + 27?\"}],\n        \"reward_model\": {\"ground_truth\": \"42\"}\n    },\n    # ... more examples\n]\ndf = pd.DataFrame(data)\ndf.to_parquet(\"train.parquet\")\n```\n\n### Step 2: Define Reward Function\n\n```python\n# reward_function.py\nimport re\n\ndef compute_reward(responses, ground_truths):\n    rewards = []\n    for response, gt in zip(responses, ground_truths):\n        # Extract answer from response\n        match = re.search(r'\\\\boxed{([^}]+)}', response)\n        if match and match.group(1).strip() == gt.strip():\n            rewards.append(1.0)\n        else:\n            rewards.append(0.0)\n    return rewards\n```\n\n### Step 3: Create Training Config\n\n```yaml\n# config/grpo_math.yaml\nalgorithm:\n  adv_estimator: grpo\n  gamma: 1.0\n  lam: 1.0\n\ndata:\n  train_files: /path/to/train.parquet\n  val_files: /path/to/val.parquet\n  train_batch_size: 256\n  max_prompt_length: 512\n  max_response_length: 2048\n\nactor_rollout_ref:\n  model:\n    path: Qwen/Qwen2.5-7B-Instruct\n  actor:\n    use_kl_loss: true\n    kl_loss_coef: 0.001\n    ppo_mini_batch_size: 64\n  rollout:\n    name: vllm\n    n: 8  # samples per prompt\n    temperature: 0.7\n    top_p: 0.95\n\ntrainer:\n  total_epochs: 3\n  n_gpus_per_node: 8\n  save_freq: 100\n```\n\n### Step 4: Launch Training\n\n```bash\npython3 -m verl.trainer.main_ppo \\\n    --config-path config \\\n    --config-name grpo_math \\\n    trainer.experiment_name=grpo_math_qwen7b\n```\n\n### Step 5: Monitor and Validate\n- [ ] Check WandB/TensorBoard for loss curves\n- [ ] Verify reward is increasing over steps\n- [ ] Run evaluation on held-out test set\n\n---\n\n## Workflow 2: PPO with Critic Model\n\nUse this workflow when you need value-based advantage estimation (GAE).\n\n### Key Differences from GRPO\n- Requires separate critic model\n- Uses Generalized Advantage Estimation (GAE)\n- Better for tasks with dense rewards\n\n### Configuration\n\n```yaml\nalgorithm:\n  adv_estimator: gae  # Use GAE instead of GRPO\n  gamma: 0.99\n  lam: 0.95\n\ncritic:\n  model:\n    path: Qwen/Qwen2.5-7B-Instruct  # Can be same or different from actor\n  ppo_mini_batch_size: 64\n\nactor_rollout_ref:\n  actor:\n    use_kl_loss: true\n    kl_loss_coef: 0.02\n    clip_ratio: 0.2  # PPO clipping\n```\n\n### Launch with Critic\n\n```bash\npython3 -m verl.trainer.main_ppo \\\n    algorithm.adv_estimator=gae \\\n    critic.model.path=Qwen/Qwen2.5-7B-Instruct \\\n    trainer.n_gpus_per_node=8\n```\n\n---\n\n## Workflow 3: Large-Scale Training with Megatron\n\nUse this workflow for models >70B parameters or when you need expert parallelism.\n\n### Prerequisites\n- [ ] Install Megatron-LM bridge: `pip install mbridge`\n- [ ] Convert model to Megatron format\n- [ ] Multi-node cluster with NVLink/InfiniBand\n\n### Configuration for 70B+ Models\n\n```yaml\nactor_rollout_ref:\n  model:\n    path: /path/to/megatron/checkpoint\n    backend: megatron\n  actor:\n    strategy: megatron\n    tensor_model_parallel_size: 8\n    pipeline_model_parallel_size: 2\n  rollout:\n    name: vllm\n    tensor_parallel_size: 8\n```\n\n### Launch Multi-Node\n\n```bash\n# On head node\nray start --head --port=6379\n\n# On worker nodes\nray start --address='head_ip:6379'\n\n# Launch training\npython3 -m verl.trainer.main_ppo \\\n    trainer.nnodes=4 \\\n    trainer.n_gpus_per_node=8\n```\n\n---\n\n## Configuration Reference\n\n### Algorithm Selection\n\n| Algorithm | `adv_estimator` | Use Case |\n|-----------|-----------------|----------|\n| GRPO | `grpo` | Critic-free, math/reasoning |\n| PPO/GAE | `gae` | Dense rewards, value estimation |\n| REINFORCE++ | `reinforce_plus_plus` | Variance reduction |\n| RLOO | `rloo` | Leave-one-out baseline |\n| ReMax | `remax` | Maximum reward baseline |\n| OPO | `opo` | Optimal policy optimization |\n\n### Key Parameters\n\n```yaml\n# Rollout parameters\nactor_rollout_ref.rollout.n: 8              # Samples per prompt\nactor_rollout_ref.rollout.temperature: 0.7  # Sampling temperature\nactor_rollout_ref.rollout.top_p: 0.95       # Nucleus sampling\n\n# Training parameters\nactor_rollout_ref.actor.lr: 1e-6            # Learning rate\nactor_rollout_ref.actor.ppo_mini_batch_size: 64\nactor_rollout_ref.actor.clip_ratio: 0.2     # PPO clip range\n\n# KL control\nactor_rollout_ref.actor.use_kl_loss: true\nactor_rollout_ref.actor.kl_loss_coef: 0.001\nalgorithm.kl_ctrl.target_kl: 0.1            # For adaptive KL control\n```\n\n---\n\n## Common Issues and Solutions\n\n### Issue: OOM During Rollout\n\n**Symptoms**: CUDA out of memory during generation phase\n\n**Solutions**:\n```yaml\n# Reduce batch size\nactor_rollout_ref.rollout.log_prob_micro_batch_size: 4\n\n# Enable gradient checkpointing\nactor_rollout_ref.model.enable_gradient_checkpointing: true\n\n# Use FSDP2 with CPU offloading\nactor_rollout_ref.actor.strategy: fsdp2\nactor_rollout_ref.actor.fsdp_config.offload_policy: true\n```\n\n### Issue: Training Instability\n\n**Symptoms**: Loss spikes, reward collapse\n\n**Solutions**:\n```yaml\n# Reduce learning rate\nactor_rollout_ref.actor.lr: 5e-7\n\n# Increase KL penalty\nactor_rollout_ref.actor.kl_loss_coef: 0.01\n\n# Enable gradient clipping\nactor_rollout_ref.actor.max_grad_norm: 1.0\n```\n\n### Issue: Slow Weight Sync\n\n**Symptoms**: Long pauses between rollout and training\n\n**Solutions**:\n```bash\n# Use FSDP2 for faster resharding\nactor_rollout_ref.actor.strategy=fsdp2\n\n# Enable async weight transfer\ntrainer.async_weight_update=true\n```\n\n### Issue: vLLM Version Mismatch\n\n**Symptoms**: Import errors or generation failures\n\n**Solution**: Use compatible versions:\n```bash\npip install vllm>=0.8.5,<=0.12.0\n# Avoid vLLM 0.7.x (known bugs)\n```\n\n---\n\n## Advanced Topics\n\n### Multi-Turn Tool Calling\n\nSee [references/multi-turn.md](references/multi-turn.md) for agentic workflows with tool use.\n\n### Vision-Language Models\n\n```yaml\nactor_rollout_ref:\n  model:\n    path: Qwen/Qwen2.5-VL-7B-Instruct\n  rollout:\n    name: vllm\n    enable_vision: true\n```\n\n### LoRA Training\n\n```yaml\nactor_rollout_ref:\n  actor:\n    lora:\n      enabled: true\n      r: 16\n      alpha: 32\n      target_modules: [\"q_proj\", \"v_proj\"]\n```\n\n---\n\n## Resources\n\n- **Documentation**: https://verl.readthedocs.io/\n- **Paper**: https://arxiv.org/abs/2409.19256\n- **GitHub**: https://github.com/volcengine/verl\n- **Recipes**: https://github.com/verl-project/verl-recipe (DAPO, GSPO, etc.)\n- **Community**: Slack at verl-project","author":"@Orchestra-Research","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/main/06-post-training/verl","license":"MIT","category":"devops","lang":"en","tokens":2624,"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/api-reference.md","size":6941,"sha256":"727954fb3944142a7c5c3b7078cb203e0a47efb8c2ad373f7df11800e147fe5a"},{"path":"references/troubleshooting.md","size":6792,"sha256":"7cf3f25831ad686151485a753c18faebbf7fcbeb6b2d683156a4514e7d27131c"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":["arxiv.org","verl.readthedocs.io"]}}