Skip to main content

Overview

rLLM uses Ray and VERL for distributed training, enabling you to scale experiments across multiple GPUs and nodes. This guide covers configuration, resource allocation, and best practices for distributed training.

Training Architecture

rLLM’s distributed training separates computation into specialized workers:
  • Actor: Runs policy model for generation
  • Critic: Runs value model (for actor-critic methods)
  • Rollout Workers: Execute environment interactions in parallel
  • Trainer: Performs gradient updates
Each component can be independently scaled based on your workload.

Basic Configuration

Single-GPU Training

Default configuration for single-GPU setup:
The script above mirrors cookbooks/math/train.py; for distributed launch see cookbooks/math/train_verl.sh.

Configuration Files

rLLM uses Hydra for configuration management. The default config is at:
From rllm/trainer/config/agent_ppo_trainer.yaml:1.

Scaling Configuration

1

Set batch sizes

Configure batch sizes for throughput:
Or via command line:
2

Configure parallelism

Set the number of parallel tasks:
Higher values increase throughput but require more memory.
3

Set GPU allocation

Configure GPU resources in the base VERL config:
4

Enable multi-node training

For multi-node setups, configure Ray cluster:
Then run training as usual. Ray will distribute workers automatically.

Configuration Overrides

You can override config values in multiple ways:

Python Dictionary

Command Line Arguments

Config List

Ray Resource Management

Monitoring Resources

View Ray dashboard:

Resource Allocation

Control GPU placement:

Memory Management

For large models, enable offloading:
Enabling offloading reduces memory usage but increases training time. Use it only when you run out of GPU memory.

Performance Optimization

Rollout Parallelism

Increase parallel tasks for faster data collection:
Rule of thumb: n_parallel_tasks ≈ batch_size / avg_trajectory_length

Async Rollouts

Enable asynchronous rollout mode:
Async mode overlaps generation and environment execution for better GPU utilization.

Gradient Accumulation

For large batch sizes with limited memory:
Gradient accumulation steps = ppo_mini_batch_size / ppo_micro_batch_size

Model Parallelism

For models that don’t fit on a single GPU:

Common Patterns

Multi-GPU Training (Single Node)

Large Model Training (70B+)

High-Throughput Training

Troubleshooting

Out of Memory (OOM)

  1. Reduce ppo_micro_batch_size
  2. Enable gradient checkpointing: enable_gradient_checkpointing: true
  3. Enable offloading: param_offload: true
  4. Reduce n_parallel_tasks
  5. Use tensor parallelism: tensor_model_parallel_size: 2

Slow Training

  1. Increase n_parallel_tasks for better GPU utilization
  2. Enable async rollouts: mode: async
  3. Increase ppo_micro_batch_size if you have memory
  4. Check Ray dashboard for bottlenecks
  5. Disable offloading if not needed

Ray Connection Issues

Distributed Training Not Working

  1. Ensure all nodes can reach each other
  2. Check firewall settings (Ray uses ports 6379, 8265, 10001)
  3. Verify same Ray version on all nodes
  4. Check Ray dashboard for node status
The from_dict method in your environment and agent classes must be properly implemented for distributed training to work. Ray serializes and deserializes these objects across workers.

Best Practices

  1. Start small: Test on single GPU before scaling
  2. Monitor metrics: Use Ray dashboard and TensorBoard
  3. Profile first: Identify bottlenecks before optimizing
  4. Batch size scaling: Increase batch size with number of GPUs
  5. Checkpoint frequently: Distributed training can be unstable
  6. Test serialization: Ensure from_dict works correctly

Next Steps