|
| 1 | +# Grouped Relative Policy Optimization (GRPO) |
| 2 | +# >>> python -m apps.grpo.main --config apps/grpo/llama3_8b.yaml |
| 3 | + |
| 4 | +# Global configuration |
| 5 | +group_size: 4 |
| 6 | +local_batch_size: 4 # per-device batch size |
| 7 | +max_req_tokens: 1024 |
| 8 | +max_res_tokens: 2048 |
| 9 | +model: "meta-llama/Meta-Llama-3.1-8B-Instruct" |
| 10 | +off_by_n: 1 # Off by one by default |
| 11 | + |
| 12 | +# Observability configuration |
| 13 | +metric_logging: |
| 14 | + wandb: |
| 15 | + project: grpo-training |
| 16 | + group: grpo_exp_${oc.env:USER} |
| 17 | + logging_mode: global_reduce # global_reduce, per_rank_reduce, per_rank_no_reduce |
| 18 | + console: |
| 19 | + logging_mode: global_reduce |
| 20 | + |
| 21 | +# Dataset configuration |
| 22 | +dataset: |
| 23 | + path: "openai/gsm8k" |
| 24 | + revision: "main" |
| 25 | + data_split: "train" |
| 26 | + streaming: true |
| 27 | + model: ${model} |
| 28 | + |
| 29 | +# Policy configuration |
| 30 | +policy: |
| 31 | + engine_args: # https://docs.vllm.ai/en/v0.10.0/api/vllm/engine/arg_utils.html#vllm.engine.arg_utils.EngineArgs |
| 32 | + model: ${model} |
| 33 | + tensor_parallel_size: 2 |
| 34 | + pipeline_parallel_size: 1 |
| 35 | + enforce_eager: false |
| 36 | + sampling_params: # https://docs.vllm.ai/en/v0.10.0/api/vllm/sampling_params.html#vllm.sampling_params.SamplingParams |
| 37 | + n: ${group_size} |
| 38 | + max_tokens: ${max_res_tokens} |
| 39 | + temperature: 1.0 |
| 40 | + top_p: 1.0 |
| 41 | + |
| 42 | +# Trainer configuration |
| 43 | +trainer: |
| 44 | + model: |
| 45 | + name: llama3 |
| 46 | + flavor: 8B |
| 47 | + hf_assets_path: hf://${model} |
| 48 | + optimizer: |
| 49 | + name: AdamW |
| 50 | + lr: 1e-5 |
| 51 | + eps: 1e-8 |
| 52 | + lr_scheduler: |
| 53 | + warmup_steps: 1 |
| 54 | + training: |
| 55 | + local_batch_size: ${local_batch_size} |
| 56 | + seq_len: ${sum:${max_req_tokens},${max_res_tokens}} # seq_len >= max_req_tokens + max_res_tokens |
| 57 | + max_norm: 1.0 |
| 58 | + steps: 1000000 |
| 59 | + dtype: bfloat16 |
| 60 | + gc_freq: 1 |
| 61 | + compile: |
| 62 | + enable: false |
| 63 | + parallelism: |
| 64 | + data_parallel_replicate_degree: 1 |
| 65 | + data_parallel_shard_degree: -1 |
| 66 | + tensor_parallel_degree: 1 |
| 67 | + pipeline_parallel_degree: 1 |
| 68 | + context_parallel_degree: 1 |
| 69 | + expert_parallel_degree: 1 |
| 70 | + disable_loss_parallel: true |
| 71 | + checkpoint: |
| 72 | + enable: true |
| 73 | + folder: ./checkpoint # The folder to save checkpoints to. |
| 74 | + initial_load_path: hf://${model} # The path to load the initial checkpoint from. Ignored if `folder` exists. |
| 75 | + initial_load_in_hf: true # If true, interpret initial_load_path as a HuggingFace model repo |
| 76 | + last_save_in_hf: true |
| 77 | + interval: 500 |
| 78 | + async_mode: "disabled" |
| 79 | + activation_checkpoint: |
| 80 | + mode: selective |
| 81 | + selective_ac_option: op |
| 82 | + |
| 83 | +# Replay buffer configuration |
| 84 | +replay_buffer: |
| 85 | + batch_size: ${local_batch_size} |
| 86 | + max_policy_age: ${off_by_n} |
| 87 | + # This should match the dp_size of TorchTitan |
| 88 | + # Here it's set explicitly to 2, because we've set |
| 89 | + # 2 GPUs for the trainer and we're using full FSDP. |
| 90 | + dp_size: 2 |
| 91 | + |
| 92 | +# Reference model configuration |
| 93 | +ref_model: |
| 94 | + model: |
| 95 | + name: llama3 |
| 96 | + flavor: 8B |
| 97 | + hf_assets_path: hf://${model} |
| 98 | + training: |
| 99 | + seq_len: ${trainer.training.seq_len} |
| 100 | + dtype: bfloat16 |
| 101 | + gc_freq: 1 |
| 102 | + compile: |
| 103 | + enable: false |
| 104 | + parallelism: |
| 105 | + data_parallel_replicate_degree: 1 |
| 106 | + data_parallel_shard_degree: 1 |
| 107 | + tensor_parallel_degree: 1 |
| 108 | + pipeline_parallel_degree: 1 |
| 109 | + context_parallel_degree: 1 |
| 110 | + expert_parallel_degree: 1 |
| 111 | + checkpoint: |
| 112 | + initial_load_path: hf://${model} |
| 113 | + initial_load_in_hf: true |
| 114 | + |
| 115 | +# All resource allocations |
| 116 | +services: |
| 117 | + policy: |
| 118 | + procs: ${policy.engine_args.tensor_parallel_size} |
| 119 | + num_replicas: 1 |
| 120 | + with_gpus: true |
| 121 | + mesh_name: policy |
| 122 | + ref_model: |
| 123 | + procs: 1 |
| 124 | + num_replicas: 1 |
| 125 | + with_gpus: true |
| 126 | + mesh_name: ref_model |
| 127 | + reward_actor: |
| 128 | + procs: 1 |
| 129 | + num_replicas: 1 |
| 130 | + with_gpus: false |
| 131 | + mesh_name: reward_actor |
| 132 | + |
| 133 | +actors: |
| 134 | + dataset: |
| 135 | + procs: 1 |
| 136 | + with_gpus: false |
| 137 | + mesh_name: dataset |
| 138 | + trainer: |
| 139 | + procs: 2 |
| 140 | + with_gpus: true |
| 141 | + mesh_name: trainer |
| 142 | + replay_buffer: |
| 143 | + procs: 1 |
| 144 | + with_gpus: false |
| 145 | + mesh_name: replay_buffer |
| 146 | + compute_advantages: |
| 147 | + procs: 1 |
| 148 | + with_gpus: false |
| 149 | + mesh_name: compute_advantages |
0 commit comments