diff --git a/config/_2_sokoban.yaml b/config/_2_sokoban.yaml new file mode 100644 index 0000000000000000000000000000000000000000..81065977b9ed568f3c3337d9bb5c1b3d70b35ba4 --- /dev/null +++ b/config/_2_sokoban.yaml @@ -0,0 +1,9 @@ +defaults: + - base + +hydra: + searchpath: + - pkg://verl.trainer.config + +trainer: + experiment_name: sokoban-main diff --git a/config/_4_countdown.yaml b/config/_4_countdown.yaml new file mode 100644 index 0000000000000000000000000000000000000000..65825a2bb9386a35cc4961504ba4a43f6352dd73 --- /dev/null +++ b/config/_4_countdown.yaml @@ -0,0 +1,22 @@ +defaults: + - base + +hydra: + searchpath: + - pkg://verl.trainer.config + +trainer: + experiment_name: countdown + + +agent_proxy: + max_turn: 1 + max_actions_per_turn: 1 + +es_manager: + train: + env_configs: + tags: ["Countdown"] + val: + env_configs: + tags: ["Countdown"] diff --git a/config/_6_webshop.yaml b/config/_6_webshop.yaml new file mode 100644 index 0000000000000000000000000000000000000000..df3fd98991eaac77f1fa292c66733e4d48cc2502 --- /dev/null +++ b/config/_6_webshop.yaml @@ -0,0 +1,31 @@ +defaults: + - base + +hydra: + searchpath: + - pkg://verl.trainer.config + +micro_batch_size_per_gpu: 4 +ppo_mini_batch_size: 32 +model_path: Qwen/Qwen2.5-3B-Instruct + +trainer: + experiment_name: webshop + + +agent_proxy: + max_turn: 9 + max_actions_per_turn: 1 + +actor_rollout_ref: + rollout: + max_model_len: 15000 + max_num_batched_tokens: 15000 + +es_manager: + train: + env_configs: + tags: ["WebShop"] + val: + env_configs: + tags: ["WebShop"] diff --git a/config/_7_lean.yaml b/config/_7_lean.yaml new file mode 100644 index 0000000000000000000000000000000000000000..12f38be011df3970ea359a133a44d0a5659503a0 --- /dev/null +++ b/config/_7_lean.yaml @@ -0,0 +1,31 @@ +defaults: + - base + +hydra: + searchpath: + - pkg://verl.trainer.config + +system: + CUDA_VISIBLE_DEVICES: "0,1,2,3" + +trainer: + experiment_name: lean + n_gpus_per_node: 4 + +agent_proxy: + max_turn: 15 + max_actions_per_turn: 4 + max_context_window: 5 + +actor_rollout_ref: + rollout: + max_model_len: 8096 + response_length: 512 + +es_manager: + train: + env_configs: + tags: ["Lean"] + val: + env_configs: + tags: ["Lean"] diff --git a/config/_8_sudoku.yaml b/config/_8_sudoku.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b038ee4a17127cea99d4959de9f7d6d00cd13084 --- /dev/null +++ b/config/_8_sudoku.yaml @@ -0,0 +1,23 @@ +defaults: + - base + +hydra: + searchpath: + - pkg://verl.trainer.config + +trainer: + experiment_name: sudoku-main + +es_manager: + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: ["SimpleSudoku"] + n_groups: [8] + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: ["SimpleSudoku"] + n_groups: [32] diff --git a/config/base.yaml b/config/base.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d4aba026cab88872026b4ff7eb2d817324e00ff1 --- /dev/null +++ b/config/base.yaml @@ -0,0 +1,179 @@ +defaults: + - ppo_trainer + - envs + +system: + CUDA_VISIBLE_DEVICES: "0,1,2,3,4,5,6,7" + +seed: + train: 10000 + val: 123 + +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: +enable_response_mask: True # Enabling response mask could improve stability of rollout/old_log_prob, as P(st|history) are no longer calculated in loss here. See https://docs.google.com/document/d/1bg7obeiKTExuHHBl5uOiSpec5uLDZ2Tgvxy6li5pHX4/edit?usp=sharing for more details. +grpo_advantage_length_weight: False # if you do not enable this and critic/advantage_estimator is GRPO, and the critic/advantages/mean is too low, then you can try enabling this to encourage reasoning and forbid collapse + +lora: + rank: 0 + alpha: 64 + target_modules: all-linear + +actor_rollout_ref: + model: + path: ${model_path} + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + actor: + ppo_mini_batch_size: ${ppo_mini_batch_size} # by default, ppo_mini_batch_size = train_batch_size / 4 + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_ref: True + entropy_coeff: 0.001 + use_kl_loss: False + kl_loss_coef: 0.000 + kl_loss_type: kl + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: "none" # "none", "linear", "sqrt" + # Loss aggregation mode: "token-mean" (default), "seq-mean-token-mean" (GRPO), "seq-mean-token-sum" (Dr. GRPO) + loss_agg_mode: "token-mean" + optim: + betas: [0.9, 0.999] + lr: 1e-6 + ref: + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + rollout: + name: vllm + load_format: auto # load from huggingface instead of dummy (random init) + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + tensor_model_parallel_size: 1 + max_model_len: 16384 + prompt_length: 1 # useless. Just put it here + response_length: 400 # single-turn response length + gpu_memory_utilization: 0.7 + max_num_batched_tokens: 16384 # set only when enable_chunked_prefill is true + temperature: 1 + rollout_filter_value: 1.0 + rollout_filter_strategy: top_p # top_p, top_k, top_k_abs, min_p + rollout_filter_type: largest # smallest or largest + rollout_filter_include_zero: True # whether to include groups with 0 score in the filtering + rollout_filter_top_p_prob_mode: linear # top_p mode: score-sum linear rule or original softmax + rollout_filter_selection_eps: 0.01 # linear top_p uses threshold = top_p * sum(scores) - eps + rollout_filter_empty_stop_steps: 5 # early stop after this many consecutive training steps with 0 kept samples + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + enforce_eager: True # for small models, set both enforce_eager and free_cache_engine to False to make rollout faster + free_cache_engine: True + val_kwargs: + do_sample: True + temperature: 0.5 + +critic: + ppo_mini_batch_size: ${ppo_mini_batch_size} # by default, ppo_mini_batch_size = train_batch_size / 4 + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + model: + path: ${model_path} + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + optim: + betas: [0.9, 0.999] + lr: 1e-5 + +data: + max_prompt_length: null + max_response_length: null + train_batch_size: null + +algorithm: + gamma: 1.0 + lam: 1.0 + high_level_gamma: 0.95 + adv_estimator: gae # "gae" for PPO, "grpo" for GRPO/Dr.GRPO + bi_level_gae: False + zero_task_advantage: False # if True, zero out advantages to remove task-driven policy gradient + # Dr. GRPO: set to False to use (R - mean) instead of (R - mean) / std + norm_adv_by_std_in_grpo: True + # Soft advantage reweighting: scale advantages by (group_std / max_group_std) + # This down-weights low reward variance prompts instead of hard filtering + soft_advantage_reweight: False + kl_penalty: kl # how to estimate kl divergence + kl_ctrl: + type: fixed + kl_coef: 0.000 + +trainer: + project_name: ragen + experiment_name: test + local_log_dir: "results/" + save_freq: -1 + total_training_steps: 200 + validation_steps: 1 # validation instances = validation_steps * val_env_groups * group_size + val_before_train: True + n_gpus_per_node: 8 + test_freq: 10 + generations_to_log_to_wandb: + val: 20 + logger: [ 'console', 'wandb' ] + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + log_group_rv_table: False + gradient_analysis_mode: False + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: False + gradient_analysis_only: False + exit_after_gradient_analysis: False + +agent_proxy: + context_window_mode: "full" # "full" | "limited_multi_turn" | "single_turn" + max_context_window: -1 # k value: -1 for full history, 1 for no history (like without_history) + batch_adjust_mode: copy # "copy" to duplicate samples, "delete" to remove samples when batch size is not divisible + max_turn: 10 + action_sep: "||" + max_actions_per_turn: 1 # how many actions can be output at most in a single turn + use_turn_scores: False # important to GAE when applying token-level rewards to token-level advantages. If False, will take the sum of scores as the reward for the last turn. + enable_think: True # False -> no think RL + reward_normalization: + grouping: "state" # state / batch / inductive + method: "identity" # asym_clip / identity / mean_std + +# Collapse detection for diagnosing template collapse vs entropy collapse +collapse_detection: + compute_freq: 5 # Compute every N steps + micro_batch_size: 128 # Micro batch size for cross-scoring + first_turn_enabled: true # Compute first-turn metrics + multi_turn_enabled: true # Enable multi-turn sampling for MI computation + num_samples: 64 # N or all + +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + # under the same group, the env config and env seed are ensured to be equal + group_size: 16 + env_configs: + tags: ["CoordSokoban"] + n_groups: [8] # If not set, all env names divide nums equally. Under the same group, the env config and env seed (prompt) are equal in each generation + val: + env_groups: 512 + group_size: 1 # should be set to 1 because when val temperature is set to 0 and group size > 1, there will be repetitive prompts which leads to same trajectory. + + env_configs: + tags: ["CoordSokoban"] + n_groups: [512] # TODO: If not set, all env names divide nums equally. Under the same group, the env config and env seed (prompt) are equal in each generation + +ctx_manager: + generation: # go to vllm + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/config/stream.yaml b/config/stream.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a424736897f80f2d60700104b41a20145e5d89cd --- /dev/null +++ b/config/stream.yaml @@ -0,0 +1,18 @@ +defaults: + - base + +hydra: + searchpath: + - pkg://verl.trainer.config + +trainer: + experiment_name: sokoban-main + + +es_manager: + val: + env_groups: 1 + group_size: 1 # should be set to 1 because when val temperature is set to 0 and group size > 1, there will be repetitive prompts which leads to same trajectory. + env_configs: + tags: ["SimpleSokoban"] + n_groups: [1] # TODO: If not set, all env names divide nums equally. Under the same group, the env config and env seed (prompt) are equal in each generation diff --git a/config/webshop_full.yaml b/config/webshop_full.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5432289a42546f73330bf1761e6b57a92498be83 --- /dev/null +++ b/config/webshop_full.yaml @@ -0,0 +1,27 @@ +defaults: + - base + +micro_batch_size_per_gpu: 4 +ppo_mini_batch_size: 32 +model_path: Qwen/Qwen2.5-3B-Instruct + +trainer: + experiment_name: webshop_full + + +agent_proxy: + max_turn: 15 + max_actions_per_turn: 1 + +actor_rollout_ref: + rollout: + max_model_len: 15000 + max_num_batched_tokens: 15000 + +es_manager: + train: + env_configs: + tags: ["WebShopFull"] + val: + env_configs: + tags: ["WebShopFull"] diff --git a/docs/experiment_deepcoder.md b/docs/experiment_deepcoder.md new file mode 100644 index 0000000000000000000000000000000000000000..88e8ec4ec6f6663d04674eff1c698ee3ca815271 --- /dev/null +++ b/docs/experiment_deepcoder.md @@ -0,0 +1,121 @@ +# DeepCoder Experiment Runs + +## Command Snippets Overview + +| Condition | Purpose | Variables | +|--------|---------|-----------| +| `GRPO top-p 1.0` | Full-retention baseline under linear top-p filtering | `rollout_filter_strategy=top_p`, `rollout_filter_value=1`, `rollout_filter_include_zero=True` | +| `GRPO top-p 0.9` | Stronger reward-variance filtering with adaptive retention | `rollout_filter_strategy=top_p`, `rollout_filter_value=0.9`, `rollout_filter_include_zero=False` | +| `GRPO top-k 0.25` | Fixed-budget filtering that keeps the top 25% of train groups | `rollout_filter_strategy=top_k`, `rollout_filter_value=0.25`, `rollout_filter_include_zero=True` | + +All three command snippets run DeepCoder with `Qwen/Qwen2.5-Coder-7B`, `GRPO`, and single-turn code generation. + +--- + +## 1. Top-p 1.0 (`Qwen/Qwen2.5-Coder-7B-200-GRPO-top-p-1`) + +Uses linear top-p filtering with `rollout_filter_value=1`. + +Goal: +- Establish a full-retention baseline while keeping the same reward-variance ranking machinery as the filtered runs + +Key Details: +- Filtering uses `top_p`, `largest`, `reward_variance`, and `rollout_filter_top_p_prob_mode=linear` +- `rollout_filter_value=1` with `rollout_filter_include_zero=True` keeps the full train-group pool under linear top-p selection, so this is the closest thing to a no-filter baseline in `deepcoder_lines` +- `actor_rollout_ref.actor.use_ref=False` and `actor_rollout_ref.actor.use_kl_loss=False` remove reference-policy KL from training +- The run budget is `200` training steps with checkpoints every `20` steps + +Source: +- `docs/deepcoder_lines`, lines `1-89` + +Outputs: +- W&B project: `deepcoder_RAGEN_final_3` +- Run name: `Qwen/Qwen2.5-Coder-7B-200-GRPO-top-p-1` + +--- + +## 2. Top-p 0.9 (`Qwen/Qwen2.5-Coder-7B-200-GRPO-top-p-0.9`) + +Uses the same linear top-p filter, but keeps only the highest-variance groups whose score mass reaches `0.9`. + +Goal: +- Increase reward-variance filtering strength while keeping the rest of the GRPO setup fixed + +Key Details: +- Filtering again uses `top_p`, `largest`, `reward_variance`, and `rollout_filter_top_p_prob_mode=linear` +- `rollout_filter_value=0.9` makes retention adaptive: the number of kept groups depends on how reward variance is distributed across the `16` train groups +- `rollout_filter_include_zero=False` excludes zero-variance groups from selection +- Because `rollout_filter_type=largest`, the filter prioritizes groups with the highest within-group reward variance + +Source: +- `docs/deepcoder_lines`, lines `93-181` + +Outputs: +- W&B project: `deepcoder_RAGEN_final_3` +- Run name: `Qwen/Qwen2.5-Coder-7B-200-GRPO-top-p-0.9` + +--- + +## 3. Top-k 0.25 (`Qwen/Qwen2.5-Coder-7B-200-GRPO-top-k-0.25`) + +Switches from adaptive top-p filtering to fixed-fraction top-k filtering. + +Goal: +- Compare adaptive top-p filtering against a fixed keep-top-25% regime + +Key Details: +- `rollout_filter_strategy=top_k` with `rollout_filter_value=0.25` keeps `int(0.25 * 16) = 4` train groups per step +- With `es_manager.train.group_size=8`, this corresponds to at most `32` kept rollouts per training step after filtering +- `rollout_filter_include_zero=True` means zero-variance groups are still part of the ranking pool, but only the top `4` groups survive +- `rollout_filter_type=largest` means those `4` groups are chosen by highest reward variance + +Source: +- `docs/deepcoder_lines`, lines `185-273` + +Outputs: +- W&B project: `deepcoder_RAGEN_final_3` +- Run name: `Qwen/Qwen2.5-Coder-7B-200-GRPO-top-k-0.25` + +--- + +## Common Notes + +- Source format: + - `docs/deepcoder_lines` is a collection of three standalone bash snippets, not a parameterized sweep script + - The file defines both `USE_GRPO` and `USE_PPO`, but all three `python train.py` commands actually expand `$USE_GRPO` +- Shared setup across all three conditions: + - Config: `_10_deepcoder` + - Model: `Qwen/Qwen2.5-Coder-7B` + - `algorithm.adv_estimator=grpo` + - `agent_proxy.reward_normalization.method=identity` + - `trainer.total_training_steps=200` + - `ppo_mini_batch_size=32` + - `micro_batch_size_per_gpu=1` + - `es_manager.train.env_groups=16`, `es_manager.train.group_size=8` + - `es_manager.val.env_groups=256`, `es_manager.val.group_size=1` + - `trainer.n_gpus_per_node=8` + - `system.CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7"` + - `actor_rollout_ref.rollout.tensor_model_parallel_size=4` + - `agent_proxy.max_turn=1` + - `actor_rollout_ref.actor.use_ref=False` + - `actor_rollout_ref.rollout.rollout_filter_type=largest` + - `actor_rollout_ref.rollout.rollout_filter_metric=reward_variance` by default from `config/base.yaml` + - `actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=linear` + - `actor_rollout_ref.rollout.rollout_filter_empty_stop_steps=0` + - `actor_rollout_ref.rollout.max_model_len=10000` + - `actor_rollout_ref.rollout.max_num_batched_tokens=10000` + - `actor_rollout_ref.rollout.response_length=4000` + - `agent_proxy.fail_on_prompt_too_long=True` + - `lora.rank=0`, `lora.alpha=64`, `lora.target_modules=all-linear` + - `actor_rollout_ref.rollout.gpu_memory_utilization=0.6` + - `trainer.save_freq=20` + - `trainer.validation_steps=1` + - `trainer.val_before_train=True` + - `trainer.test_freq=10` + - `collapse_detection.first_turn_enabled=False` + - `collapse_detection.multi_turn_enabled=False` + - `trainer.resume_mode=disable` +- Logging and artifacts: + - Default local log dir remains `results/` + - Default logger remains `['console', 'wandb']` + - Checkpoints are saved every `20` steps diff --git a/docs/experiment_main_table.md b/docs/experiment_main_table.md new file mode 100644 index 0000000000000000000000000000000000000000..95c4d3a2c1d8507b423a281dda23a727856f974f --- /dev/null +++ b/docs/experiment_main_table.md @@ -0,0 +1,122 @@ +# Main Table Runs + +This doc covers the experiment scripts for the main performance table. + +## Scripts Overview + +| Script | Purpose | Variables | +|--------|---------|-----------| +| `run_main_table_diff_algo.sh` | Compare algorithms | PPO, DAPO, GRPO, DrGRPO; `filter`/`nofilter` | +| `run_main_table_diff_size.sh` | Compare model sizes | 0.5B, 1.5B, 3B, 7B; `filter`/`nofilter` | +| `run_main_table_diff_model.sh` | Compare model types | Instruct, Reasoning; `filter`/`nofilter` | + +All scripts run experiments across 5 tasks (sokoban, frozenlake, webshop, metamathqa, countdown) with filter/nofilter settings. + +--- + +## 1. Different Algorithms (`run_main_table_diff_algo.sh`) + +Compares PPO/DAPO/GRPO/DrGRPO using Qwen2.5-3B. + +```bash +bash scripts/runs/run_main_table_diff_algo.sh --steps 400 +``` + +Options: +- `--steps` (default: `400`) +- `--tasks` (comma list; default: `sokoban,frozenlake,webshop,metamathqa,countdown`) +- `--algos` (comma list; default: `PPO,DAPO,GRPO,DrGRPO`) +- `--gpus` (comma list; auto-detect if omitted) +- `--gpus-per-exp` (default: `1`) +- `--cooldown` (seconds; default: `30`) +- `--gpu-memory-utilization` (default: `0.3`) +- `--filters` (comma list; `filter`, `nofilter`, or `all`; default: `all`) + +Examples: +```bash +# Run one `filter` and one `nofilter` PPO experiment on 4xH100 each +bash scripts/runs/run_main_table_diff_algo.sh --steps 400 --tasks sokoban --gpus-per-exp 4 --gpu-memory-utilization 0.3 --filters all --gpus 0,1,2,3,4,5,6,7 --algos PPO +``` + +Outputs: +- Per-task logs: `logs/diff_algo__Qwen2.5-3B/` +- Summary log: `logs/diff_algo_Qwen2.5-3B.log` + +--- + +## 2. Different Model Sizes (`run_main_table_diff_size.sh`) + +Compares Qwen2.5 models of different sizes using PPO. + +```bash +bash scripts/runs/run_main_table_diff_size.sh --steps 400 +``` + +Options: +- `--steps` (default: `400`) +- `--tasks` (comma list; default: `sokoban,frozenlake,webshop,metamathqa,countdown`) +- `--models` (comma list; default: `Qwen2.5-0.5B,Qwen2.5-1.5B,Qwen2.5-3B,Qwen2.5-7B`) +- `--gpus` (comma list; auto-detect if omitted) +- `--gpus-per-exp` (default: `1`) +- `--cooldown` (seconds; default: `30`) +- `--gpu-memory-utilization` (default: `0.3`) +- `--filters` (comma list; `filter`, `nofilter`, or `all`; default: `all`) + +Examples: +```bash +# Run a single 1.5B/filter experiment on 4xH100 +bash scripts/runs/run_main_table_diff_size.sh --steps 400 --tasks sokoban --gpus-per-exp 4 --gpu-memory-utilization 0.3 --filters filter --gpus 0,1,2,3 --models Qwen2.5-1.5B + +# Quick test with smallest model +bash scripts/runs/run_main_table_diff_size.sh --steps 5 --models Qwen2.5-0.5B --tasks sokoban +``` + +Outputs: +- Per-task logs: `logs/diff_size_/` +- Summary log: `logs/diff_size_PPO.log` + +--- + +## 3. Different Model Types (`run_main_table_diff_model.sh`) + +Compares different model types (Instruct, Reasoning) using PPO. + +```bash +bash scripts/runs/run_main_table_diff_model.sh --steps 400 +``` + +Options: +- `--steps` (default: `400`) +- `--tasks` (comma list; default: `sokoban,frozenlake,webshop,metamathqa,countdown`) +- `--models` (comma list; default: `Qwen2.5-3B-Instruct`) +- `--gpus` (comma list; auto-detect if omitted) +- `--gpus-per-exp` (default: `1`) +- `--cooldown` (seconds; default: `30`) +- `--gpu-memory-utilization` (default: `0.3`) +- `--filters` (comma list; `filter`, `nofilter`, or `all`; default: `all`) + +Examples: +```bash +# Run one `filter` and one `nofilter` Llama-3.2-3B-Instruct experiment on 4xH100 each +bash scripts/runs/run_main_table_diff_model.sh --steps 400 --tasks sokoban --gpus-per-exp 4 --gpu-memory-utilization 0.5 --filters all --gpus 0,1,2,3,4,5,6,7 --models=meta-llama/Llama-3.2-3B-Instruct +``` + +Outputs: +- Per-task logs: `logs/diff_model_/` +- Summary log: `logs/diff_model_PPO.log` + +--- + +## Common Notes + +- Effective rollout filter config for main-table runs: + - `rollout_filter_strategy=top_p` + - `rollout_filter_top_p_prob_mode=softmax` + - `rollout_filter_type=largest` + - `rollout_filter_metric=reward_variance` + - `rollout_filter_include_zero=True` +- Filter mode mapping: + - `filter`: `top_p=0.9`, `include_zero=True` + - `nofilter`: `top_p=1.0`, `include_zero=True` +- Because `include_zero=True`, `nofilter` (`top_p=1.0`) keeps all groups; it does not disable the filter code path, but it is effectively "no filtering" for the batch +- You can run a single experiment on `4xH100` by setting `--gpus-per-exp 4` and passing a 4-GPU list, or run one `filter` and one `nofilter` experiment in parallel by passing an 8-GPU list diff --git a/docs/experiment_search.md b/docs/experiment_search.md new file mode 100644 index 0000000000000000000000000000000000000000..ea8f7a43a0dbfc449696989846b14f3fe5b16d51 --- /dev/null +++ b/docs/experiment_search.md @@ -0,0 +1,163 @@ +# Search Environment Experiments + +This doc covers the experiment scripts for the Search (HotpotQA + Dense Retrieval) environment. + +## Overview + +All experiments use: +- **Task**: SearchQA (HotpotQA multi-hop QA with Wikipedia dense retrieval) +- **Model**: `Qwen/Qwen2.5-3B-Instruct` +- **Algorithm**: PPO (`algorithm.adv_estimator=gae`) +- **Config**: `_9_search` + +The sweep compares three rollout filtering strategies while keeping all other hyperparameters fixed. + +| Experiment | Filter Strategy | Filter Value | Effective Batch | Description | +|-----------|----------------|-------------|----------------|-------------| +| No Filter | `top_p` | `1.0` | 128 | Baseline: all rollout groups kept | +| TopK 0.25 | `top_k` | `0.25` | 32 | Keep top 25% groups by reward variance | +| TopP 0.9 | `top_p` | `0.9` | ~115 | Keep groups covering 90% cumulative reward variance | + +--- + +## Prerequisites + +### 1. Prepare data + +```bash +# HotpotQA train/val parquet +python scripts/prepare_search_data.py + +# Wikipedia corpus + FAISS index (~74GB) +python scripts/download_search_index.py +``` + +### 2. Start retrieval server + +The retrieval server provides dense retrieval over ~21M Wikipedia passages using E5-base-v2 + FAISS. + +```bash +python scripts/retrieval/server.py \ + --data_dir ./search_data/prebuilt_indices \ + --port 8000 --host 127.0.0.1 \ + --device cuda:0 --gpu_memory_limit_mb 6144 +``` + +**Important**: We recommend running the retrieval server on a **dedicated GPU** not used by training, or on CPU. Sharing a GPU with vLLM rollout and training causes CUDA OOM errors due to memory contention between processes. + +--- + +## Experiment Scripts + +All experiments use `scripts/runs/run_search_benchmark.sh`. + +### Experiment 1: PPO + No Filter (baseline) + +No filtering — all rollout groups are used for training. + +```bash +bash scripts/runs/run_search_benchmark.sh \ + --algos PPO \ + --filter-strategy top_p --filter-value 1.0 \ + --gpus 0,1,2,3,4,5,6,7 --gpus-per-exp 8 \ + --micro-batch 4 --mini-batch 64 \ + --gpu-memory-utilization 0.65 \ + --save-freq 20 --steps 200 \ + --retrieval-port 8000 +``` + +### Experiment 2: PPO + TopK=0.25 + +Keep only the top 25% of rollout groups ranked by reward variance. + +```bash +bash scripts/runs/run_search_benchmark.sh \ + --algos PPO \ + --filter-strategy top_k --filter-value 0.25 \ + --gpus 0,1,2,3,4,5,6,7 --gpus-per-exp 8 \ + --micro-batch 4 --mini-batch 32 \ + --gpu-memory-utilization 0.65 \ + --save-freq 20 --steps 200 \ + --retrieval-port 8000 +``` + +Note: `mini-batch` is reduced to 32 because effective batch after filtering is `16 groups * 8 group_size * 0.25 = 32`. The `ppo_mini_batch_size` must not exceed this value. + +### Experiment 3: PPO + TopP=0.9 + +Keep rollout groups covering the top 90% cumulative reward variance (softmax-weighted). + +```bash +bash scripts/runs/run_search_benchmark.sh \ + --algos PPO \ + --filter-strategy top_p --filter-value 0.9 \ + --gpus 0,1,2,3,4,5,6,7 --gpus-per-exp 8 \ + --micro-batch 4 --mini-batch 64 \ + --gpu-memory-utilization 0.65 \ + --save-freq 20 --steps 200 \ + --retrieval-port 8000 +``` + +--- + +## W&B Runs + +Project: [`cuhksz-gc/ragen_search_benchmark`](https://wandb.ai/cuhksz-gc/ragen_search_benchmark) + +| Experiment | Run ID | Link | +|-----------|--------|------| +| PPO + No Filter | `2sbt8952` | [wandb](https://wandb.ai/cuhksz-gc/ragen_search_benchmark/runs/2sbt8952) | +| PPO + TopK=0.25 | `2h5c7kbb` | [wandb](https://wandb.ai/cuhksz-gc/ragen_search_benchmark/runs/2h5c7kbb) | +| PPO + TopP=0.9 | `tbgx0lpt` | [wandb](https://wandb.ai/cuhksz-gc/ragen_search_benchmark/runs/tbgx0lpt) | + +--- + +## Shared Config + +```yaml +# config/_9_search.yaml overrides +micro_batch_size_per_gpu: 4 +ppo_mini_batch_size: 32-64 # depends on filter setting + +agent_proxy: + max_turn: 5 + max_actions_per_turn: 1 + +actor_rollout_ref: + rollout: + max_model_len: 5000 # TopK=0.25 experiment used 4000 + max_num_batched_tokens: 5000 # TopK=0.25 experiment used 4000 + gpu_memory_utilization: 0.65 + temperature: 1 + actor: + use_kl_loss: False + kl_loss_coef: 0.001 + entropy_coeff: 0.001 + loss_agg_mode: token-mean + filter_loss_scaling: none + +es_manager: + train: + env_groups: 16 + group_size: 8 # 16 * 8 = 128 rollouts per step + val: + env_groups: 256 + +collapse_detection: + compute_freq: 999 # effectively disabled + +trainer: + total_training_steps: 200 + save_freq: 20 + val_before_train: True + logger: ['console', 'wandb'] +``` + +--- + +## Common Notes + +- **Retrieval server GPU deployment**: Place the E5 retrieval server on a **dedicated GPU** not used by training. Co-locating with training on the same GPU causes CUDA OOM due to memory contention between vLLM, training, and the E5 server process. Do not use CPU mode — during rollout, hundreds of environments issue concurrent retrieval requests (256 env groups can produce 1000+ requests), and CPU cannot keep up. +- **mini-batch size adjustment**: When using aggressive filtering (e.g., `top_k=0.25`), reduce `ppo_mini_batch_size` so it does not exceed `env_groups * group_size * filter_value`. Otherwise training fails with an assertion error. +- **max_model_len**: Default is 5000 (in `_9_search.yaml`). The TopK=0.25 experiment used 4000 to save KV cache memory; the No Filter and TopP=0.9 experiments use the default 5000. +- **Checkpoint size**: Each checkpoint is ~35GB (model + optimizer, 8 FSDP shards). With `save_freq=20` and 200 steps, expect 10 checkpoints (~350GB). Monitor disk usage and delete old checkpoints as needed. diff --git a/docs/guide_filtering_and_loss_scaling.md b/docs/guide_filtering_and_loss_scaling.md new file mode 100644 index 0000000000000000000000000000000000000000..3d18433dcb7d2874d73992ca17fe691b84393d35 --- /dev/null +++ b/docs/guide_filtering_and_loss_scaling.md @@ -0,0 +1,157 @@ +# Filtering Strategies and Loss Scaling in RAGEN + +## Overview +This document details the advanced filtering strategies and the loss scaling mechanism implemented to stabilize Reinforcement Learning (RL) training, particularly when using aggressive filtering techniques in the GRPO/PPO loop. + +Note: the short guide for the current `top_p`, `top_k`, and no-filter variants lives in [guide_rollout_filtering.md](./guide_rollout_filtering.md). + +## 1. Rolling Filter Strategies (`rollout_filter_strategy`) +We have implemented three strategies to filter rollout groups based on their rewards/scores. + +### `top_p` (Nucleus Sampling) +- **Description**: Selects the smallest set of groups whose **cumulative probability** (derived from the softmax of scores) exceeds the threshold `value`. +- **Configuration**: + ```yaml + actor_rollout_ref: + rollout: + rollout_filter_strategy: top_p + rollout_filter_value: 0.5 # Keep top cumulative 50% probability mass + ``` +- **Behavior**: + - Scores are converted to logits (negated if `rollout_filter_type: smallest`). + - Softmax is applied to get probabilities. + - Groups are sorted by probability. + - Groups are selected until the cumulative sum $\ge$ `value`. + - **Constraint**: Always keeps at least one group. + +### `top_k` +- **Description**: Selects the top fraction `value` (e.g., 0.5 for 50%) of groups. +- **Configuration**: + ```yaml + actor_rollout_ref: + rollout: + rollout_filter_strategy: top_k + rollout_filter_value: 0.5 # Keep top 50% groups + ``` + +### `top_k_abs` +- **Description**: Selects specifically the top `k` groups with the highest (or lowest) scores. +- **Configuration**: + ```yaml + actor_rollout_ref: + rollout: + rollout_filter_strategy: top_k_abs + rollout_filter_value: 4 # Keep top 4 groups + ``` +- **Behavior**: A simple sorting and slicing operation. Useful for guaranteeing a fixed batch size of "good" examples. + + +### `min_p` +- **Description**: Selects groups whose score is at least a fraction `value` of the maximum score in the batch. +- **Behavior**: + - **`largest`**: Keeps groups where $\text{score} \ge \text{max\_score} \cdot \text{value}$. + - **`smallest`**: Keeps groups where $\text{score} \le \text{min\_score} / \text{value}$. +- **Configuration**: + ```yaml + actor_rollout_ref: + rollout: + rollout_filter_strategy: min_p + rollout_filter_value: 0.8 # Keep groups with score >= 0.8 * max_score + ``` + +### Other Parameters +- **`rollout_filter_metric`**: `reward_variance` (default), `reward`, `reward_sum`, `entropy`, `entropy_variance`, or `length`. +- **`rollout_filter_type`**: `largest` (default) or `smallest`. Determines if we want high or low scores. +- **`rollout_filter_include_zero`**: If `True`, groups with zero score are candidates for filtering. If `False`, they are excluded or handled differently depending on the specific logic (often used to ensure we don't train on complete failures). + +--- + +## 2. Filter Loss Scaling (`filter_loss_scaling`) +Aggressive filtering (e.g., `top_p=0.2`) can result in keeping only a small fraction of the generated prompts. This can lead to high variance in gradients. To mitigate this, we implemented loss scaling. + +### Concept +We scale the PPO policy loss (and potentially KL/entropy components depending on the implementation) by a factor derived from the **kept ratio**: +$$ \text{ratio} = \frac{N_{\text{kept}}}{N_{\text{total}}} $$ + +### Configuration +Controlled via `actor_rollout_ref.actor.filter_loss_scaling`: + +1. **`none`** (Default): No scaling. + $$ \mathcal{L}_{\text{final}} = \mathcal{L}_{\text{ppo}} $$ + +2. **`linear`**: Scales linearly with the kept ratio. + $$ \mathcal{L}_{\text{final}} = \mathcal{L}_{\text{ppo}} \times \text{ratio} $$ + - *Intuition*: If we only keep 10% of the data, we scale the update down by 10% to prevent over-fitting to this small subset. + +3. **`sqrt`**: Scales by the square root of the kept ratio. + $$ \mathcal{L}_{\text{final}} = \mathcal{L}_{\text{ppo}} \times \sqrt{\text{ratio}} $$ + - *Intuition*: A milder dampening than linear. + +### Implementation Details +- **Trainer**: The kept ratio is calculated in `ragen/trainer/agent_trainer.py`. +- **Loss Scaling**: The scaling is applied directly to the **advantages** in `ragen/trainer/agent_trainer.py` (after `compute_advantage`). + ```python + if filter_loss_scaling == "linear": + batch.batch["advantages"] *= filter_kept_ratio + ``` + This effectively scales the policy gradient updates. + +--- + +## 3. Reward Variance Early Stopping +To prevent training on collapsed or uninformative rollout groups, we implemented an early stopping mechanism based on reward variance. + +### Concept +The trainer monitors the reward standard deviation (`rollout/in_group_reward_std`) at the successful training-step level. + +1. **Baseline Generation**: During the first 10 successful training steps, the trainer calculates the average reward variance ($V_{base}$). +2. **Monitoring**: A sliding window of the last 10 successful training steps is maintained (starts after baseline is ready). +3. **Stopping Condition**: If all 10 consecutive step variances are less than 10% of $V_{base}$, training is stopped. + $$ \forall i \in \{1 \dots 10\}: V_i < 0.1 \times V_{base} \implies \text{Stop Training} $$ + +### Implementation +- **Baseline**: Average of `rollout/in_group_reward_std` for `global_steps` 1-10. +- **Sliding Window**: Uses a `collections.deque(maxlen=10)` to track the most recent successful training steps. +- **Metric**: Logs `early_stopped/reward_variance_collapse: 1.0` when triggered. + +### 2. Success-Based Early Stopping +To prevent wasting compute on environments where the model is failing to learn, we implemented an early stopping mechanism based on validation success rates. + +- **Condition**: If the success rate for a specific environment (e.g., `val-env/CoordSokoban/success`) remains below **1% (0.01)** for **5 consecutive** validation steps, the training is stopped. +- **Metric**: Logs `early_stopped/low_validation_success: 1.0` when triggered. + +--- + +A unified script `scripts/runs/run_filtering_final.sh` is provided to run the validated set of filtering experiments. + +### Usage +```bash +# Run experiments across available GPUs (e.g., 2 GPUs per experiment) +bash scripts/runs/run_filtering_final.sh 2 +``` + +### Features +- **PPO Focused**: All experiments in this suite use the PPO algorithm. +- **400 Steps**: Standardized training length. +- **Auto-Scheduling**: Automatically detects available GPUs and distributes experiments. +- **Metric Coverage**: Covers `reward_variance`, `entropy`, `entropy_variance`, and `length`. +- **Automatic Skip**: Tracks progress in `filter_final_donelist.txt` to avoid redundant runs. + +--- + +## 5. Code References +- **Filtering Logic**: `ragen/trainer/rollout_filter.py` +- **Trainer Integration**: `ragen/trainer/agent_trainer.py` +- **Early Stopping Logic**: `RayAgentTrainer` in `ragen/trainer/agent_trainer.py` +- **Loss Scaling Implementation**: `verl/verl/workers/actor/dp_actor.py` (specifically `DataParallelPPOActor.update_policy`) +- **Configuration**: `config/base.yaml` and `verl/verl/workers/config/actor.py` + +--- + +## 6. Troubleshooting + +### `AssertionError: old_log_probs` Collision +If you use `rollout_filter_metric=entropy`, you might encounter an `AssertionError` during the `batch.union` operation in `agent_trainer.py`. + +- **Cause**: The `EntropyRolloutFilter` recomputes log probabilities to calculate entropy and returns them in the `DataProto`. The trainer also recomputes log probabilities for the PPO update. `DataProto.union` rejects keys that already exist if they are not the exact same tensor instance. +- **Resolution**: The filter has been updated to only include the `entropys` key and prune the redundant `old_log_probs` before unioning with the main batch. diff --git a/gradient_analysis/plot_icml_steps.py b/gradient_analysis/plot_icml_steps.py new file mode 100644 index 0000000000000000000000000000000000000000..c5520e501860fc9cbd9317c9b5703cb9d3bb0b8a --- /dev/null +++ b/gradient_analysis/plot_icml_steps.py @@ -0,0 +1,199 @@ +import os +import json +import argparse +from typing import Dict, List, Tuple + +import numpy as np +import matplotlib.pyplot as plt + + +def _load_metrics(path: str) -> Dict: + with open(path, "r") as f: + return json.load(f) + + +def _bucket_sort_key(bucket: str) -> Tuple[int, int, str]: + if bucket.startswith("bucket_"): + suffix = bucket.split("_", 1)[1] + if suffix.isdigit(): + return (0, int(suffix), bucket) + return (1, 0, bucket) + + +def _extract_buckets(metrics: Dict) -> List[str]: + buckets = set() + for k in metrics.keys(): + if k.startswith("grad_norm/bucket_"): + parts = k.split("/") + if len(parts) >= 2: + buckets.add(parts[1]) + return sorted(buckets, key=_bucket_sort_key) + + +def _rv_stats(metrics: Dict, buckets: List[str]) -> Tuple[List[float], List[float], List[float]]: + means, mins, maxs = [], [], [] + for b in buckets: + means.append(float(metrics.get(f"grad_norm/{b}/reward_std_mean", 0.0))) + mins.append(float(metrics.get(f"grad_norm/{b}/reward_std_min", 0.0))) + maxs.append(float(metrics.get(f"grad_norm/{b}/reward_std_max", 0.0))) + return means, mins, maxs + + +def _grad_series(metrics: Dict, buckets: List[str]) -> Tuple[List[float], List[float], List[float]]: + task = [] + kl = [] + ent = [] + for b in buckets: + task.append(float(metrics.get(f"grad_norm/{b}/task", 0.0))) + kl.append(float(metrics.get(f"grad_norm/{b}/kl", 0.0))) + ent.append(float(metrics.get(f"grad_norm/{b}/entropy", 0.0))) + return task, kl, ent + + +def _default_step_dir(mode: str, step: str) -> str: + base_dir = os.path.dirname(__file__) + return os.path.join(base_dir, "data", mode, step) + + +def main() -> None: + parser = argparse.ArgumentParser(description="ICML paper plots: step 0/20/40 grid.") + parser.add_argument("--mode", choices=["grpo", "ppo"], default="grpo", help="Which dataset to plot") + parser.add_argument("--step0-dir", default=None, help="Directory with metrics json for step 0") + parser.add_argument("--step20-dir", default=None, help="Directory with metrics json for step 20") + parser.add_argument("--step40-dir", default=None, help="Directory with metrics json for step 40") + parser.add_argument("--out", default="icml_step0_20_40_grid.png", help="Output PNG path") + args = parser.parse_args() + + step0_dir = args.step0_dir or _default_step_dir(args.mode, "step0") + step20_dir = args.step20_dir or _default_step_dir(args.mode, "step20") + step40_dir = args.step40_dir or _default_step_dir(args.mode, "step40") + + metrics0 = _load_metrics(os.path.join(step0_dir, "metrics.json")) + metrics20 = _load_metrics(os.path.join(step20_dir, "metrics.json")) + metrics40 = _load_metrics(os.path.join(step40_dir, "metrics.json")) + + buckets = _extract_buckets(metrics20) + buckets = [b for b in buckets if b in _extract_buckets(metrics40)] + buckets = [b for b in buckets if b in _extract_buckets(metrics0)] + labels = [b.replace("_", " ") for b in buckets] + + rv20_means, rv20_mins, rv20_maxs = _rv_stats(metrics20, buckets) + rv40_means, rv40_mins, rv40_maxs = _rv_stats(metrics40, buckets) + task20, kl20, ent20 = _grad_series(metrics20, buckets) + task40, kl40, ent40 = _grad_series(metrics40, buckets) + reg20 = [k + e for k, e in zip(kl20, ent20)] + reg40 = [k + e for k, e in zip(kl40, ent40)] + rv0_means, rv0_mins, rv0_maxs = _rv_stats(metrics0, buckets) + task0, kl0, ent0 = _grad_series(metrics0, buckets) + reg0 = [k + e for k, e in zip(kl0, ent0)] + + fig, axes = plt.subplots(3, 3, figsize=(16, 12), sharex="col") + color_rv = "#1f78b4" + color_task = "#e67e22" + color_reg = "#16a085" + + positions = np.arange(len(buckets)) + box_width = 0.35 + def _draw_interval_mean(ax, x, vmin, vmax, vmean, color): + if vmax < vmin: + vmin, vmax = vmax, vmin + yerr = [[max(0.0, vmean - vmin)], [max(0.0, vmax - vmean)]] + ax.errorbar( + [x], + [vmean], + yerr=yerr, + fmt="o", + color=color, + markersize=5, + capsize=4, + linewidth=1.2, + ) + + # rows: step0 (if provided), step20, step40 + steps = [ + ("Step 0", rv0_means, rv0_mins, rv0_maxs, task0, reg0), + ("Step 20", rv20_means, rv20_mins, rv20_maxs, task20, reg20), + ("Step 40", rv40_means, rv40_mins, rv40_maxs, task40, reg40), + ] + + col_titles = [ + "Reward Variance by bucket", + "Task gradient norm vs Reward Variance", + "Regularizer gradient norm (KL+Entropy) vs RV", + ] + col_captions = [ + "RV quantile buckets. (Q1 -> Q6)", + "Bucket RV (log scale).", + "Bucket RV (log scale).", + ] + + for r, (step_name, rv_means, rv_mins, rv_maxs, task, reg) in enumerate(steps): + # (a) RV per bucket interval + mean + ax = axes[r][0] + for i, x in enumerate(positions): + _draw_interval_mean( + ax, + x, + rv_mins[i], + rv_maxs[i], + rv_means[i], + color=color_rv, + ) + ax.set_yscale("log") + ax.grid(axis="y", linestyle="--", alpha=0.15, linewidth=0.8) + ax.set_ylabel(f"{step_name}\nReward Variance (Std)") + if r == 0: + ax.set_title("(a) " + col_titles[0], fontweight="bold") + ax.set_xticks(positions) + ax.set_xticklabels(labels if r == len(steps) - 1 else []) + + # (b) Task vs RV + ax = axes[r][1] + ax.plot(rv_means, task, linestyle="-", marker="o", color=color_task, markersize=5) + ax.set_xscale("log") + ax.grid(axis="y", linestyle="--", alpha=0.15, linewidth=0.8) + ax.set_ylabel(f"{step_name}\nTask grad norm") + if r == 0: + ax.set_title("(b) " + col_titles[1], fontweight="bold") + # if r == len(steps) - 1: + # ax.set_xlabel("RV mean") + + # (c) Reg vs RV + ax = axes[r][2] + ax.plot(rv_means, reg, linestyle="-", marker="o", color=color_reg, markersize=5) + ax.set_xscale("log") + ax.set_ylim(0.0, 0.1) + ax.grid(axis="y", linestyle="--", alpha=0.15, linewidth=0.8) + ax.set_ylabel(f"{step_name}\nKL+Entropy grad norm") + if r == 0: + ax.set_title("(c) " + col_titles[2], fontweight="bold") + # if r == len(steps) - 1: + # ax.set_xlabel("RV mean") + + # style spines + for row in axes: + for a in row: + a.spines["top"].set_visible(False) + a.spines["right"].set_visible(False) + + # captions under each column + for c, caption in enumerate(col_captions): + ax = axes[-1][c] + ax.text( + 0.5, + -0.15, + caption, + transform=ax.transAxes, + ha="center", + va="top", + fontsize=10, + fontweight="bold", + ) + + plt.tight_layout() + plt.savefig(args.out, dpi=300) + print(f"Saved figure to {os.path.abspath(args.out)}") + + +if __name__ == "__main__": + main() diff --git a/outputs/2026-04-30/13-11-58/.hydra/hydra.yaml b/outputs/2026-04-30/13-11-58/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ad89a7e1bca0f5020e8a26605ab3bbbad01e9ecf --- /dev/null +++ b/outputs/2026-04-30/13-11-58/.hydra/hydra.yaml @@ -0,0 +1,175 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-04-30/13-11-58 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-11/10-46-20/.hydra/config.yaml b/outputs/2026-05-11/10-46-20/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1645c5136e5815e67c68040021e8f14a8e6f0924 --- /dev/null +++ b/outputs/2026-05-11/10-46-20/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.8 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 8192 + max_model_len: 3600 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 600 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: 100 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 5 + action_sep: '||' + max_actions_per_turn: 2 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - CoordSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - CoordSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-11/10-46-20/.hydra/hydra.yaml b/outputs/2026-05-11/10-46-20/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f623eaf6f5f23cceaa8855dce74e0ecb723a78a3 --- /dev/null +++ b/outputs/2026-05-11/10-46-20/.hydra/hydra.yaml @@ -0,0 +1,175 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-11/10-46-20 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-11/10-52-37/train.log b/outputs/2026-05-11/10-52-37/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-11/11-35-35/.hydra/hydra.yaml b/outputs/2026-05-11/11-35-35/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9cc2e1047ac2b8f7729625bb5f117ab2fdaad507 --- /dev/null +++ b/outputs/2026-05-11/11-35-35/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-11/11-35-35 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-11/11-35-35/.hydra/overrides.yaml b/outputs/2026-05-11/11-35-35/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c6e59a837113d3e5eb3a559fa51b4a89af6c6547 --- /dev/null +++ b/outputs/2026-05-11/11-35-35/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft diff --git a/outputs/2026-05-11/11-38-43/.hydra/config.yaml b/outputs/2026-05-11/11-38-43/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..78461768045a711b0683791d956bdb335b042adf --- /dev/null +++ b/outputs/2026-05-11/11-38-43/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.8 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 8192 + max_model_len: 3600 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 5 + action_sep: '||' + max_actions_per_turn: 2 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-11/14-33-26/.hydra/config.yaml b/outputs/2026-05-11/14-33-26/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6c8ba1c6cafdf00debe9c667f3ff8ac435c37fe2 --- /dev/null +++ b/outputs/2026-05-11/14-33-26/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.8 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 8192 + max_model_len: 3600 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 1.0 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen_rlvtr_3b + experiment_name: sokoban1_3b_rft_second + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 5 + action_sep: '||' + max_actions_per_turn: 2 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-11/14-33-26/train.log b/outputs/2026-05-11/14-33-26/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-11/17-12-08/.hydra/overrides.yaml b/outputs/2026-05-11/17-12-08/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6cb0835e0864629c86f4b92bcbf7e5c162ac0c3c --- /dev/null +++ b/outputs/2026-05-11/17-12-08/.hydra/overrides.yaml @@ -0,0 +1,6 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/wanghy/LLaMA-Factory/saves/qwen3/full/sft/qwen2.5_3B_it_sokoban_box1_rft +- trainer.save_freq=1000 +- trainer.default_local_dir=/mnt/general/wanghy/RAGEN_v2/saves/qwen3b_it_sokoban1_rft_rl diff --git a/outputs/2026-05-11/19-32-33/train.log b/outputs/2026-05-11/19-32-33/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-12/09-55-39/.hydra/config.yaml b/outputs/2026-05-12/09-55-39/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..45ea5ab9f82c3b9a8114a136d53ef7f026fd3742 --- /dev/null +++ b/outputs/2026-05-12/09-55-39/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.8 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-12/09-55-39/.hydra/hydra.yaml b/outputs/2026-05-12/09-55-39/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ec2ea410e7aa35bc752996c0ec173f34180f74d0 --- /dev/null +++ b/outputs/2026-05-12/09-55-39/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-12/09-55-39 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-12/09-55-39/.hydra/overrides.yaml b/outputs/2026-05-12/09-55-39/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-12/09-55-39/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-12/15-16-37/.hydra/config.yaml b/outputs/2026-05-12/15-16-37/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ad845f7866aa176e9dae3a46a8bf5daeee04acfc --- /dev/null +++ b/outputs/2026-05-12/15-16-37/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-13/10-39-50/.hydra/config.yaml b/outputs/2026-05-13/10-39-50/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ad845f7866aa176e9dae3a46a8bf5daeee04acfc --- /dev/null +++ b/outputs/2026-05-13/10-39-50/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-13/10-39-50/.hydra/hydra.yaml b/outputs/2026-05-13/10-39-50/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..63dc73f5eec29c350e27aec3fb4bfa24d4a377ef --- /dev/null +++ b/outputs/2026-05-13/10-39-50/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-13/10-39-50 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-13/10-39-50/train.log b/outputs/2026-05-13/10-39-50/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-15/14-05-31/.hydra/config.yaml b/outputs/2026-05-15/14-05-31/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb357f194ba5c07181376c85a6cbbbcf81d9f07b --- /dev/null +++ b/outputs/2026-05-15/14-05-31/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sudoku-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 8 + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 32 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-15/14-05-31/.hydra/hydra.yaml b/outputs/2026-05-15/14-05-31/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..153bf9159a61533ab7c372c201a582a10bc86580 --- /dev/null +++ b/outputs/2026-05-15/14-05-31/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-15/14-05-31 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-15/14-05-31/.hydra/overrides.yaml b/outputs/2026-05-15/14-05-31/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-15/14-05-31/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-15/14-05-31/train.log b/outputs/2026-05-15/14-05-31/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-15/14-11-35/.hydra/config.yaml b/outputs/2026-05-15/14-11-35/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..32db1dc95e1111c408cd9c5910c81cb99234de73 --- /dev/null +++ b/outputs/2026-05-15/14-11-35/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sudoku-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 8 + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 32 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-15/14-11-35/.hydra/hydra.yaml b/outputs/2026-05-15/14-11-35/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a9279dc6066c2201aa6bd16d4780a2de0cc71320 --- /dev/null +++ b/outputs/2026-05-15/14-11-35/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-15/14-11-35 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-15/14-11-35/.hydra/overrides.yaml b/outputs/2026-05-15/14-11-35/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-15/14-11-35/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-15/14-56-09/.hydra/config.yaml b/outputs/2026-05-15/14-56-09/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1ff68099c456b261c7c3a399d850147f4834ccda --- /dev/null +++ b/outputs/2026-05-15/14-56-09/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 400 + project_name: ragen + experiment_name: sudoku-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 8 + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 32 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-15/14-56-09/.hydra/hydra.yaml b/outputs/2026-05-15/14-56-09/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2f3a24daaa3498a57df02e52ed111d371b00faea --- /dev/null +++ b/outputs/2026-05-15/14-56-09/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=400 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=400 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-15/14-56-09 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-15/14-56-09/.hydra/overrides.yaml b/outputs/2026-05-15/14-56-09/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..22eaa25345a4f254a49569abc10e9bdd3ae2a00c --- /dev/null +++ b/outputs/2026-05-15/14-56-09/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=400 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-15/14-56-09/train.log b/outputs/2026-05-15/14-56-09/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-15/15-01-19/.hydra/config.yaml b/outputs/2026-05-15/15-01-19/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1ff68099c456b261c7c3a399d850147f4834ccda --- /dev/null +++ b/outputs/2026-05-15/15-01-19/.hydra/config.yaml @@ -0,0 +1,989 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 400 + project_name: ragen + experiment_name: sudoku-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 8 + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 32 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-15/15-01-19/.hydra/hydra.yaml b/outputs/2026-05-15/15-01-19/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..218b9c55058a52978afc4502d31b9e482299e2b3 --- /dev/null +++ b/outputs/2026-05-15/15-01-19/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=400 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=400 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-15/15-01-19 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-15/15-01-19/.hydra/overrides.yaml b/outputs/2026-05-15/15-01-19/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..22eaa25345a4f254a49569abc10e9bdd3ae2a00c --- /dev/null +++ b/outputs/2026-05-15/15-01-19/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=400 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-15/15-01-19/train.log b/outputs/2026-05-15/15-01-19/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-22/21-57-02/.hydra/config.yaml b/outputs/2026-05-22/21-57-02/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4cd53856ddade0697e57100c2631099e712437d3 --- /dev/null +++ b/outputs/2026-05-22/21-57-02/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-22/21-57-02/.hydra/hydra.yaml b/outputs/2026-05-22/21-57-02/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f9b54fbbcad60d99968bd38e260596cff262ef0a --- /dev/null +++ b/outputs/2026-05-22/21-57-02/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-22/21-57-02 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-22/21-57-02/.hydra/overrides.yaml b/outputs/2026-05-22/21-57-02/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..74df9f6d7c64ffa32b88f0913af33dc3c7be63e7 --- /dev/null +++ b/outputs/2026-05-22/21-57-02/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct diff --git a/outputs/2026-05-22/21-57-02/train.log b/outputs/2026-05-22/21-57-02/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-22/22-09-48/.hydra/config.yaml b/outputs/2026-05-22/22-09-48/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b280ffb1d50261e1fc99c3c9f861ddfba19950af --- /dev/null +++ b/outputs/2026-05-22/22-09-48/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-22/22-09-48/.hydra/hydra.yaml b/outputs/2026-05-22/22-09-48/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ffe2a0dc88f712a52fe3fc10649e5f8a00030fa1 --- /dev/null +++ b/outputs/2026-05-22/22-09-48/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-22/22-09-48 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-22/22-09-48/.hydra/overrides.yaml b/outputs/2026-05-22/22-09-48/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..74df9f6d7c64ffa32b88f0913af33dc3c7be63e7 --- /dev/null +++ b/outputs/2026-05-22/22-09-48/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct diff --git a/outputs/2026-05-22/22-09-48/train.log b/outputs/2026-05-22/22-09-48/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-25/12-00-18/.hydra/config.yaml b/outputs/2026-05-25/12-00-18/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b280ffb1d50261e1fc99c3c9f861ddfba19950af --- /dev/null +++ b/outputs/2026-05-25/12-00-18/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-25/12-00-18/.hydra/hydra.yaml b/outputs/2026-05-25/12-00-18/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6908769fa67f51a8ca2cb4ea8768446c201a5a4f --- /dev/null +++ b/outputs/2026-05-25/12-00-18/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-25/12-00-18 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-25/12-00-18/.hydra/overrides.yaml b/outputs/2026-05-25/12-00-18/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..74df9f6d7c64ffa32b88f0913af33dc3c7be63e7 --- /dev/null +++ b/outputs/2026-05-25/12-00-18/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct diff --git a/outputs/2026-05-25/12-00-18/train.log b/outputs/2026-05-25/12-00-18/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-26/12-39-46/.hydra/config.yaml b/outputs/2026-05-26/12-39-46/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ec53efd388f52a095d55a8c11ddc200e8abfe863 --- /dev/null +++ b/outputs/2026-05-26/12-39-46/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-26/12-39-46/.hydra/hydra.yaml b/outputs/2026-05-26/12-39-46/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1541696d9e2cb3aa2a28654ffc0175d863228234 --- /dev/null +++ b/outputs/2026-05-26/12-39-46/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-26/12-39-46 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-26/12-39-46/.hydra/overrides.yaml b/outputs/2026-05-26/12-39-46/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-26/12-39-46/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-26/12-39-46/train.log b/outputs/2026-05-26/12-39-46/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-26/18-23-18/.hydra/config.yaml b/outputs/2026-05-26/18-23-18/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ec53efd388f52a095d55a8c11ddc200e8abfe863 --- /dev/null +++ b/outputs/2026-05-26/18-23-18/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-26/18-23-18/.hydra/hydra.yaml b/outputs/2026-05-26/18-23-18/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..985fa02b2a955a5dc659dda5836521ffc029e9af --- /dev/null +++ b/outputs/2026-05-26/18-23-18/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-26/18-23-18 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-26/18-23-18/.hydra/overrides.yaml b/outputs/2026-05-26/18-23-18/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-26/18-23-18/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-26/18-23-18/train.log b/outputs/2026-05-26/18-23-18/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-26/19-01-07/.hydra/config.yaml b/outputs/2026-05-26/19-01-07/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ec53efd388f52a095d55a8c11ddc200e8abfe863 --- /dev/null +++ b/outputs/2026-05-26/19-01-07/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-26/19-01-07/.hydra/hydra.yaml b/outputs/2026-05-26/19-01-07/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fc5a02bf978acdd0607fc5fe407e113c9f5055fd --- /dev/null +++ b/outputs/2026-05-26/19-01-07/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-26/19-01-07 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-26/19-01-07/.hydra/overrides.yaml b/outputs/2026-05-26/19-01-07/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-26/19-01-07/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-26/19-01-07/train.log b/outputs/2026-05-26/19-01-07/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-26/19-08-19/.hydra/config.yaml b/outputs/2026-05-26/19-08-19/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c962629566f06b2f07db6b0d92c86c3332a0134d --- /dev/null +++ b/outputs/2026-05-26/19-08-19/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban-main + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 15 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-26/19-08-19/.hydra/hydra.yaml b/outputs/2026-05-26/19-08-19/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b57ae444ccec472007bd57f681b3d9a90235f0c --- /dev/null +++ b/outputs/2026-05-26/19-08-19/.hydra/hydra.yaml @@ -0,0 +1,177 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-26/19-08-19 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-26/19-08-19/.hydra/overrides.yaml b/outputs/2026-05-26/19-08-19/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb3eeebef70487cf0044172d360edeb4a67ab65 --- /dev/null +++ b/outputs/2026-05-26/19-08-19/.hydra/overrides.yaml @@ -0,0 +1,4 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct diff --git a/outputs/2026-05-26/19-08-19/train.log b/outputs/2026-05-26/19-08-19/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-27/16-43-22/.hydra/hydra.yaml b/outputs/2026-05-27/16-43-22/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4fca4e385637adede5020c0948d57d143922fd37 --- /dev/null +++ b/outputs/2026-05-27/16-43-22/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct + - trainer.experiment_name=frozenlake_slippery_7b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct,trainer.experiment_name=frozenlake_slippery_7b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-27/16-43-22 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-27/16-43-22/.hydra/overrides.yaml b/outputs/2026-05-27/16-43-22/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0039d484bd9b268ef1a7a46fa23fe923d6d45c24 --- /dev/null +++ b/outputs/2026-05-27/16-43-22/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +- trainer.experiment_name=frozenlake_slippery_7b_abstraction diff --git a/outputs/2026-05-27/16-43-22/train.log b/outputs/2026-05-27/16-43-22/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-28/09-57-28/.hydra/config.yaml b/outputs/2026-05-28/09-57-28/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ee488f5ee0f5529a9961b4fd21eb739b7cac9918 --- /dev/null +++ b/outputs/2026-05-28/09-57-28/.hydra/config.yaml @@ -0,0 +1,1003 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban2_7b_abstraction + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 20 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + or 1,2,3 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 15 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-28/09-57-28/.hydra/hydra.yaml b/outputs/2026-05-28/09-57-28/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3a77ce29ad54e4b9ec032029f56ad551a37f9f78 --- /dev/null +++ b/outputs/2026-05-28/09-57-28/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct + - trainer.experiment_name=sokoban2_7b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct,trainer.experiment_name=sokoban2_7b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-28/09-57-28 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-28/09-57-28/.hydra/overrides.yaml b/outputs/2026-05-28/09-57-28/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7124bb588851e4c85436ef4f42c431e32741db95 --- /dev/null +++ b/outputs/2026-05-28/09-57-28/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +- trainer.experiment_name=sokoban2_7b_abstraction diff --git a/outputs/2026-05-28/13-21-29/.hydra/config.yaml b/outputs/2026-05-28/13-21-29/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dec276bfc575766f95fd17a37d815be3958f21c2 --- /dev/null +++ b/outputs/2026-05-28/13-21-29/.hydra/config.yaml @@ -0,0 +1,1048 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sudoku_3b_abstraction + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 20 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are a careful 4x4 Sudoku solver. Use these reusable abstractions + when reasoning: + + 1. In , explain the constraint logic behind the move, not just the final + placement. Mention which row, column, or 2x2 box makes the move safe or forced. + + 2. Treat each move as a constraint-preserving placement: place a number only + if it does not already appear in the same row, column, or 2x2 box. + + 3. First look for highly forced cells. If an empty cell has only one legal candidate + after checking its row, column, and box, fill it immediately and explain why + other numbers are excluded. + + 4. If no cell is obviously forced, scan each row, column, and 2x2 box for missing + numbers. If a missing number can go in only one empty position within that unit, + place it there and state that unit-level reason. + + 5. Prefer moves that reduce uncertainty and create new forced cells for the + next turn. A good move should make the remaining puzzle more constrained, not + more ambiguous. + + 6. Solve incrementally: choose exactly one placement, explain it briefly in + , then output that one move in . + + 7. Never modify bracketed initial cells or already-filled cells. Only place + numbers into dots. + + 8. Avoid exploratory guesses when a forced move exists. In this environment, + reliable progress usually comes from constraint propagation rather than trial-and-error. + + 9. If a previous move was invalid or the board did not change, do not repeat + the same placement. Recompute legal candidates and explain the corrected constraint-consistent + choice. + + 10. Use row, column, and box agreement as confidence: the strongest placements + are those supported by multiple constraints at once. + + 11. Keep concise but meaningful: identify the target cell, list or compare + its legal candidates, and give the decisive constraint. + + 12. Output only the required XML-like format and choose valid Sudoku placements. + + + You are solving a Sudoku puzzle. Fill in the grid so that every row, column, + and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + + Always output: [brief constraint-based reasoning] + [one placement] + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 20 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 8 + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 32 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-28/13-21-29/.hydra/hydra.yaml b/outputs/2026-05-28/13-21-29/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0d131d70ca14fde3716cee4c3cbcdcbf6f96df3c --- /dev/null +++ b/outputs/2026-05-28/13-21-29/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + - trainer.experiment_name=sudoku_3b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.experiment_name=sudoku_3b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-28/13-21-29 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-28/13-21-29/.hydra/overrides.yaml b/outputs/2026-05-28/13-21-29/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ecdf778f70ddea2027ad9c25f2a7da8ee8898757 --- /dev/null +++ b/outputs/2026-05-28/13-21-29/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +- trainer.experiment_name=sudoku_3b_abstraction diff --git a/outputs/2026-05-28/13-21-29/train.log b/outputs/2026-05-28/13-21-29/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-28/15-41-43/.hydra/config.yaml b/outputs/2026-05-28/15-41-43/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..581353ec86f31170e49885377362970e3047ca84 --- /dev/null +++ b/outputs/2026-05-28/15-41-43/.hydra/config.yaml @@ -0,0 +1,1048 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sokoban2_7b_abstraction + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 20 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are a careful 4x4 Sudoku solver. Use these reusable abstractions + when reasoning: + + 1. In , explain the constraint logic behind the move, not just the final + placement. Mention which row, column, or 2x2 box makes the move safe or forced. + + 2. Treat each move as a constraint-preserving placement: place a number only + if it does not already appear in the same row, column, or 2x2 box. + + 3. First look for highly forced cells. If an empty cell has only one legal candidate + after checking its row, column, and box, fill it immediately and explain why + other numbers are excluded. + + 4. If no cell is obviously forced, scan each row, column, and 2x2 box for missing + numbers. If a missing number can go in only one empty position within that unit, + place it there and state that unit-level reason. + + 5. Prefer moves that reduce uncertainty and create new forced cells for the + next turn. A good move should make the remaining puzzle more constrained, not + more ambiguous. + + 6. Solve incrementally: choose exactly one placement, explain it briefly in + , then output that one move in . + + 7. Never modify bracketed initial cells or already-filled cells. Only place + numbers into dots. + + 8. Avoid exploratory guesses when a forced move exists. In this environment, + reliable progress usually comes from constraint propagation rather than trial-and-error. + + 9. If a previous move was invalid or the board did not change, do not repeat + the same placement. Recompute legal candidates and explain the corrected constraint-consistent + choice. + + 10. Use row, column, and box agreement as confidence: the strongest placements + are those supported by multiple constraints at once. + + 11. Keep concise but meaningful: identify the target cell, list or compare + its legal candidates, and give the decisive constraint. + + 12. Output only the required XML-like format and choose valid Sudoku placements. + + + You are solving a Sudoku puzzle. Fill in the grid so that every row, column, + and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + + Always output: [brief constraint-based reasoning] + [one placement] + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 20 + action_sep: '||' + max_actions_per_turn: 1 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 8 + val: + env_groups: 512 + group_size: 1 + env_configs: + tags: + - SimpleSokoban + n_groups: + - 512 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-05-28/15-41-43/.hydra/hydra.yaml b/outputs/2026-05-28/15-41-43/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cbab8af1f79402bfe5d8ab5f71408dc4c72232a3 --- /dev/null +++ b/outputs/2026-05-28/15-41-43/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct + - trainer.experiment_name=sokoban2_7b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct,trainer.experiment_name=sokoban2_7b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _2_sokoban + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-05-28/15-41-43 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-05-28/15-41-43/.hydra/overrides.yaml b/outputs/2026-05-28/15-41-43/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7124bb588851e4c85436ef4f42c431e32741db95 --- /dev/null +++ b/outputs/2026-05-28/15-41-43/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +- trainer.experiment_name=sokoban2_7b_abstraction diff --git a/outputs/2026-05-28/15-41-43/train.log b/outputs/2026-05-28/15-41-43/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-29/09-48-36/.hydra/overrides.yaml b/outputs/2026-05-29/09-48-36/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ecdf778f70ddea2027ad9c25f2a7da8ee8898757 --- /dev/null +++ b/outputs/2026-05-29/09-48-36/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +- trainer.experiment_name=sudoku_3b_abstraction diff --git a/outputs/2026-05-29/09-48-36/train.log b/outputs/2026-05-29/09-48-36/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-05-29/11-22-49/.hydra/overrides.yaml b/outputs/2026-05-29/11-22-49/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7124bb588851e4c85436ef4f42c431e32741db95 --- /dev/null +++ b/outputs/2026-05-29/11-22-49/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-7B-Instruct +- trainer.experiment_name=sokoban2_7b_abstraction diff --git a/outputs/2026-05-29/17-37-33/.hydra/overrides.yaml b/outputs/2026-05-29/17-37-33/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ecdf778f70ddea2027ad9c25f2a7da8ee8898757 --- /dev/null +++ b/outputs/2026-05-29/17-37-33/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +- trainer.experiment_name=sudoku_3b_abstraction diff --git a/outputs/2026-05-29/17-37-33/train.log b/outputs/2026-05-29/17-37-33/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-06-01/11-58-22/.hydra/hydra.yaml b/outputs/2026-06-01/11-58-22/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..11bf3c3931ffc3960df902d30623a1bcdea1e908 --- /dev/null +++ b/outputs/2026-06-01/11-58-22/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct + - trainer.experiment_name=sudoku_3b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct,trainer.experiment_name=sudoku_3b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-06-01/11-58-22 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-06-01/11-58-22/.hydra/overrides.yaml b/outputs/2026-06-01/11-58-22/.hydra/overrides.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ecdf778f70ddea2027ad9c25f2a7da8ee8898757 --- /dev/null +++ b/outputs/2026-06-01/11-58-22/.hydra/overrides.yaml @@ -0,0 +1,5 @@ +- actor_rollout_ref.rollout.rollout_filter_strategy=top_p +- actor_rollout_ref.rollout.rollout_filter_value=0.9 +- trainer.total_training_steps=1000 +- model_path=/mnt/general/share/model/Qwen/Qwen2.5-3B-Instruct +- trainer.experiment_name=sudoku_3b_abstraction diff --git a/outputs/2026-06-01/11-59-20/.hydra/hydra.yaml b/outputs/2026-06-01/11-59-20/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0a17091e505fa6765491e740b541147945e331bc --- /dev/null +++ b/outputs/2026-06-01/11-59-20/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-1.5B-Instruct + - trainer.experiment_name=sudoku_1.5b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-1.5B-Instruct,trainer.experiment_name=sudoku_1.5b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-06-01/11-59-20 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-06-01/12-04-20/.hydra/hydra.yaml b/outputs/2026-06-01/12-04-20/.hydra/hydra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..90e39eec363df4082cd9312b60218a785a1248a2 --- /dev/null +++ b/outputs/2026-06-01/12-04-20/.hydra/hydra.yaml @@ -0,0 +1,178 @@ +hydra: + run: + dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} + sweep: + dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} + subdir: ${hydra.job.num} + launcher: + _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher + sweeper: + _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper + max_batch_size: null + params: null + help: + app_name: ${hydra.job.name} + header: '${hydra.help.app_name} is powered by Hydra. + + ' + footer: 'Powered by Hydra (https://hydra.cc) + + Use --hydra-help to view Hydra specific help + + ' + template: '${hydra.help.header} + + == Configuration groups == + + Compose your configuration from those groups (group=option) + + + $APP_CONFIG_GROUPS + + + == Config == + + Override anything in the config (foo.bar=value) + + + $CONFIG + + + ${hydra.help.footer} + + ' + hydra_help: + template: 'Hydra (${hydra.runtime.version}) + + See https://hydra.cc for more info. + + + == Flags == + + $FLAGS_HELP + + + == Configuration groups == + + Compose your configuration from those groups (For example, append hydra/job_logging=disabled + to command line) + + + $HYDRA_CONFIG_GROUPS + + + Use ''--cfg hydra'' to Show the Hydra config. + + ' + hydra_help: ??? + hydra_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][HYDRA] %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + root: + level: INFO + handlers: + - console + loggers: + logging_example: + level: DEBUG + disable_existing_loggers: false + job_logging: + version: 1 + formatters: + simple: + format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' + handlers: + console: + class: logging.StreamHandler + formatter: simple + stream: ext://sys.stdout + file: + class: logging.FileHandler + formatter: simple + filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log + root: + level: INFO + handlers: + - console + - file + disable_existing_loggers: false + env: {} + mode: RUN + searchpath: + - pkg://verl.trainer.config + callbacks: {} + output_subdir: .hydra + overrides: + hydra: + - hydra.mode=RUN + task: + - actor_rollout_ref.rollout.rollout_filter_strategy=top_p + - actor_rollout_ref.rollout.rollout_filter_value=0.9 + - trainer.total_training_steps=1000 + - model_path=/mnt/general/share/model/Qwen/Qwen2.5-0.5B-Instruct + - trainer.experiment_name=sudoku_0.5b_abstraction + job: + name: train + chdir: null + override_dirname: actor_rollout_ref.rollout.rollout_filter_strategy=top_p,actor_rollout_ref.rollout.rollout_filter_value=0.9,model_path=/mnt/general/share/model/Qwen/Qwen2.5-0.5B-Instruct,trainer.experiment_name=sudoku_0.5b_abstraction,trainer.total_training_steps=1000 + id: ??? + num: ??? + config_name: _8_sudoku + env_set: {} + env_copy: [] + config: + override_dirname: + kv_sep: '=' + item_sep: ',' + exclude_keys: [] + runtime: + version: 1.3.2 + version_base: '1.3' + cwd: /mnt/general/wanghy/RAGEN_v2 + config_sources: + - path: hydra.conf + schema: pkg + provider: hydra + - path: /mnt/general/wanghy/RAGEN_v2/config + schema: file + provider: main + - path: /mnt/general/wanghy/RAGEN_v2/verl/verl/trainer/config + schema: file + provider: command-line + - path: verl.trainer.config + schema: pkg + provider: hydra.searchpath in main + - path: '' + schema: structured + provider: schema + output_dir: /mnt/general/wanghy/RAGEN_v2/outputs/2026-06-01/12-04-20 + choices: + reward_model: dp_reward_model + critic: dp_critic + critic/../engine@critic.model.fsdp_config: fsdp + critic/../optim@critic.optim: fsdp + model@actor_rollout_ref.model: hf_model + rollout@actor_rollout_ref.rollout: rollout + ref@actor_rollout_ref.ref: dp_ref + ref/../engine@actor_rollout_ref.ref.fsdp_config: fsdp + data: legacy_data + actor@actor_rollout_ref.actor: dp_actor + actor/../engine@actor_rollout_ref.actor.fsdp_config: fsdp + actor/../optim@actor_rollout_ref.actor.optim: fsdp + hydra/env: default + hydra/callbacks: null + hydra/job_logging: default + hydra/hydra_logging: default + hydra/hydra_help: default + hydra/help: default + hydra/sweeper: basic + hydra/launcher: basic + hydra/output: default + verbose: false diff --git a/outputs/2026-06-01/14-32-01/train.log b/outputs/2026-06-01/14-32-01/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/outputs/2026-06-01/14-32-03/.hydra/config.yaml b/outputs/2026-06-01/14-32-03/.hydra/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..25948e984ed91bfacc2161a4bb029654bc65e58d --- /dev/null +++ b/outputs/2026-06-01/14-32-03/.hydra/config.yaml @@ -0,0 +1,1048 @@ +actor_rollout_ref: + actor: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-06 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + _target_: verl.workers.config.FSDPActorConfig + strategy: fsdp + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: false + ppo_max_token_len_per_gpu: 16384 + clip_ratio: 0.2 + clip_ratio_low: 0.2 + clip_ratio_high: 0.28 + freeze_vision_tower: false + policy_loss: + _target_: verl.workers.config.PolicyLossConfig + loss_mode: vanilla + clip_cov_ratio: 0.0002 + clip_cov_lb: 1.0 + clip_cov_ub: 5.0 + kl_cov_ratio: 0.0002 + ppo_kl_coef: 0.1 + clip_ratio_c: 3.0 + loss_agg_mode: token-mean + entropy_coeff: 0.001 + tis_imp_ratio_cap: -1 + use_kl_loss: false + use_torch_compile: true + kl_loss_coef: 0.0 + kl_loss_type: kl + ppo_epochs: 1 + shuffle: false + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + use_fused_kernels: ${oc.select:actor_rollout_ref.model.use_fused_kernels,false} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + grad_clip: 1.0 + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + use_remove_padding: ${oc.select:actor_rollout_ref.model.use_remove_padding,false} + use_ref: true + grpo_advantage_length_weight: ${grpo_advantage_length_weight} + filter_loss_scaling: none + ref: + strategy: ${actor_rollout_ref.actor.strategy} + use_torch_compile: ${oc.select:actor_rollout_ref.actor.use_torch_compile,true} + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + model: null + ulysses_sequence_parallel_size: ${oc.select:actor_rollout_ref.actor.ulysses_sequence_parallel_size,1} + entropy_from_logits_with_chunking: false + entropy_checkpointing: false + rollout: + _target_: verl.workers.config.RolloutConfig + name: vllm + mode: sync + temperature: 1 + top_k: -1 + top_p: 1 + prompt_length: 1 + response_length: 400 + dtype: bfloat16 + gpu_memory_utilization: 0.7 + ignore_eos: false + enforce_eager: true + cudagraph_capture_sizes: null + free_cache_engine: true + tensor_model_parallel_size: 1 + data_parallel_size: 1 + expert_parallel_size: 1 + max_num_batched_tokens: 16384 + max_model_len: 16384 + max_num_seqs: 1024 + enable_chunked_prefill: true + enable_prefix_caching: true + load_format: auto + log_prob_micro_batch_size: null + log_prob_micro_batch_size_per_gpu: ${log_prob_micro_batch_size_per_gpu} + log_prob_use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + log_prob_max_token_len_per_gpu: ${oc.select:actor_rollout_ref.actor.ppo_max_token_len_per_gpu,16384} + disable_log_stats: true + do_sample: true + 'n': 1 + over_sample_rate: 0 + multi_stage_wake_up: false + engine_kwargs: + vllm: {} + sglang: {} + val_kwargs: + _target_: verl.workers.config.SamplingConfig + top_k: -1 + top_p: 1.0 + temperature: 0.5 + 'n': 1 + do_sample: true + multi_turn: + _target_: verl.workers.config.MultiTurnConfig + enable: false + max_assistant_turns: null + tool_config_path: null + max_user_turns: null + max_parallel_calls: 1 + max_tool_response_length: 256 + tool_response_truncate_side: middle + interaction_config_path: null + use_inference_chat_template: false + tokenization_sanity_check_mode: strict + format: hermes + num_repeat_rollouts: null + calculate_log_probs: false + agent: + _target_: verl.workers.config.AgentLoopConfig + num_workers: 8 + agent_loop_config_path: null + custom_async_server: + _target_: verl.workers.config.CustomAsyncServerConfig + path: null + name: null + update_weights_bucket_megabytes: 512 + trace: + _target_: verl.workers.config.TraceConfig + backend: null + token2text: false + skip_rollout: false + skip_dump_dir: /tmp/rollout_dump + skip_tokenizer_init: true + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: ${oc.select:actor_rollout_ref.actor.profiler.enable,false} + all_ranks: ${oc.select:actor_rollout_ref.actor.profiler.all_ranks,false} + ranks: ${oc.select:actor_rollout_ref.actor.profiler.ranks,[]} + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + layered_summon: false + rollout_filter_value: 0.9 + rollout_filter_strategy: top_p + rollout_filter_type: largest + rollout_filter_include_zero: true + rollout_filter_top_p_prob_mode: linear + rollout_filter_selection_eps: 0.01 + rollout_filter_empty_stop_steps: 5 + rollout_filter_metric: reward_variance + gradient_analysis_num_buckets: 6 + gradient_analysis_bucket_mode: quantile + model: + _target_: verl.workers.config.HFModelConfig + path: ${model_path} + hf_config_path: null + tokenizer_path: null + use_shm: false + trust_remote_code: false + custom_chat_template: null + external_lib: null + override_config: {} + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + exclude_modules: null + use_liger: false + use_fused_kernels: false + fused_kernel_options: + impl_backend: torch + hybrid_engine: true + nccl_timeout: 600 +data: + tokenizer: null + use_shm: false + train_files: ~/data/rlhf/gsm8k/train.parquet + val_files: ~/data/rlhf/gsm8k/test.parquet + prompt_key: prompt + reward_fn_key: data_source + max_prompt_length: null + max_response_length: null + train_batch_size: null + val_batch_size: null + return_raw_input_ids: false + return_raw_chat: false + return_full_prompt: false + shuffle: true + dataloader_num_workers: 8 + validation_shuffle: false + filter_overlong_prompts: false + filter_overlong_prompts_workers: 1 + truncation: error + image_key: images + video_key: videos + trust_remote_code: false + custom_cls: + path: null + name: null + return_multi_modal_inputs: true + sampler: + class_path: null + class_name: null + datagen: + path: null + name: null + apply_chat_template_kwargs: {} +critic: + optim: + _target_: verl.workers.config.FSDPOptimizerConfig + lr: 1.0e-05 + lr_warmup_steps_ratio: 0.0 + total_training_steps: -1 + weight_decay: 0.01 + lr_warmup_steps: -1 + betas: + - 0.9 + - 0.999 + clip_grad: 1.0 + min_lr_ratio: 0.0 + num_cycles: 0.5 + warmup_style: constant + model: + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + optimizer_offload: false + offload_policy: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + model_dtype: fp32 + use_orig_params: false + ulysses_sequence_parallel_size: 1 + entropy_from_logits_with_chunking: false + use_torch_compile: true + entropy_checkpointing: false + forward_only: false + strategy: fsdp + path: ${model_path} + tokenizer_path: ${oc.select:actor_rollout_ref.model.path,"~/models/deepseek-llm-7b-chat"} + override_config: {} + external_lib: ${oc.select:actor_rollout_ref.model.external_lib,null} + trust_remote_code: ${oc.select:actor_rollout_ref.model.trust_remote_code,false} + _target_: verl.workers.config.FSDPCriticModelCfg + use_shm: false + enable_gradient_checkpointing: true + enable_activation_offload: false + use_remove_padding: false + lora_rank: ${lora.rank} + lora_alpha: ${lora.alpha} + target_modules: ${lora.target_modules} + _target_: verl.workers.config.FSDPCriticConfig + rollout_n: ${oc.select:actor_rollout_ref.rollout.n,1} + strategy: fsdp + enable: null + ppo_mini_batch_size: ${ppo_mini_batch_size} + ppo_micro_batch_size: null + ppo_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} + use_dynamic_bsz: ${oc.select:actor_rollout_ref.actor.use_dynamic_bsz,false} + ppo_max_token_len_per_gpu: 32768 + forward_max_token_len_per_gpu: ${.ppo_max_token_len_per_gpu} + ppo_epochs: ${oc.select:actor_rollout_ref.actor.ppo_epochs,1} + shuffle: ${oc.select:actor_rollout_ref.actor.shuffle,false} + cliprange_value: 0.5 + loss_agg_mode: ${oc.select:actor_rollout_ref.actor.loss_agg_mode,token-mean} + checkpoint: + _target_: verl.trainer.config.CheckpointConfig + save_contents: + - model + - optimizer + - extra + load_contents: ${.save_contents} + async_save: false + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: ${oc.select:global_profiler.global_tool_config.nsys.discrete} + npu: + _target_: verl.utils.profiler.config.NPUToolConfig + contents: [] + level: level1 + analysis: true + discrete: false + torch: + _target_: verl.utils.profiler.config.TorchProfilerToolConfig + step_start: 0 + step_end: null + torch_memory: + _target_: verl.utils.profiler.config.TorchMemoryToolConfig + trace_alloc_max_entries: ${oc.select:global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries,100000} + stack_depth: ${oc.select:global_profiler.global_tool_config.torch_memory.stack_depth,32} + forward_micro_batch_size: ${oc.select:.ppo_micro_batch_size,null} + forward_micro_batch_size_per_gpu: ${oc.select:.ppo_micro_batch_size_per_gpu,null} + ulysses_sequence_parallel_size: 1 + grad_clip: 1.0 +reward_model: + enable: false + enable_resource_pool: false + n_gpus_per_node: 0 + nnodes: 0 + strategy: fsdp + model: + input_tokenizer: ${actor_rollout_ref.model.path} + path: ~/models/FsfairX-LLaMA3-RM-v0.1 + external_lib: ${actor_rollout_ref.model.external_lib} + trust_remote_code: false + use_shm: false + use_remove_padding: false + use_fused_kernels: ${actor_rollout_ref.model.use_fused_kernels} + fsdp_config: + _target_: verl.workers.config.FSDPEngineConfig + wrap_policy: + min_num_params: 0 + param_offload: false + reshard_after_forward: true + fsdp_size: -1 + forward_prefetch: false + micro_batch_size: null + micro_batch_size_per_gpu: null + max_length: null + use_dynamic_bsz: ${critic.use_dynamic_bsz} + forward_max_token_len_per_gpu: ${critic.forward_max_token_len_per_gpu} + reward_manager: naive + launch_reward_fn_async: false + sandbox_fusion: + url: null + max_concurrent: 64 + memory_limit_mb: 1024 + profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: ${oc.select:global_profiler.tool,null} + enable: false + all_ranks: false + ranks: [] + save_path: ${oc.select:global_profiler.save_path,null} + tool_config: ${oc.select:actor_rollout_ref.actor.profiler.tool_config,null} + ulysses_sequence_parallel_size: 1 +custom_reward_function: + path: null + name: compute_score +algorithm: + _target_: verl.trainer.config.AlgoConfig + gamma: 1.0 + lam: 1.0 + adv_estimator: gae + norm_adv_by_std_in_grpo: true + use_kl_in_reward: false + kl_penalty: kl + kl_ctrl: + _target_: verl.trainer.config.KLControlConfig + type: fixed + kl_coef: 0.0 + horizon: 10000 + target_kl: 0.1 + use_pf_ppo: false + pf_ppo: + reweight_method: pow + weight_pow: 2.0 + high_level_gamma: 0.95 + bi_level_gae: false + zero_task_advantage: false + soft_advantage_reweight: false +trainer: + balance_batch: true + total_epochs: 30 + total_training_steps: 1000 + project_name: ragen + experiment_name: sudoku_1.5b_abstraction + logger: + - console + - wandb + log_val_generations: 0 + rollout_data_dir: null + validation_data_dir: null + nnodes: 1 + n_gpus_per_node: 8 + save_freq: -1 + esi_redundant_time: 0 + resume_mode: auto + resume_from_path: null + val_before_train: true + val_only: false + test_freq: 10 + critic_warmup: 0 + default_hdfs_dir: null + del_local_ckpt_after_load: false + default_local_dir: checkpoints/${trainer.project_name}/${trainer.experiment_name} + max_actor_ckpt_to_keep: 1 + max_critic_ckpt_to_keep: 1 + ray_wait_register_center_timeout: 300 + device: cuda + use_legacy_worker_impl: auto + local_log_dir: results/ + validation_steps: 1 + generations_to_log_to_wandb: + val: 20 + log_group_rv_table: false + gradient_analysis_mode: false + gradient_analysis_every: 50 + gradient_analysis_env_groups: null + gradient_analysis_group_size: null + gradient_analysis_log_prefilter: false + gradient_analysis_only: false + exit_after_gradient_analysis: false +global_profiler: + _target_: verl.utils.profiler.ProfilerConfig + tool: null + steps: null + profile_continuous_steps: false + save_path: outputs/profile + global_tool_config: + nsys: + _target_: verl.utils.profiler.config.NsightToolConfig + discrete: false + controller_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + worker_nsight_options: + trace: cuda,nvtx,cublas,ucx + cuda-memory-usage: 'true' + cuda-graph-trace: graph + capture-range: cudaProfilerApi + capture-range-end: null + kill: none + torch_memory: + trace_alloc_max_entries: 100000 + stack_depth: 32 + context: all + stacks: all + kw_args: {} +ray_kwargs: + ray_init: + num_cpus: null + timeline_json_file: null +custom_envs: + SimpleSokoban: + env_type: sokoban + max_actions_per_traj: 20 + env_instruction: "You are a careful Sokoban solver. Use these reusable abstractions\ + \ when reasoning:\n1. First compare the box position with the target position;\ + \ the useful push directions are usually the directions that reduce their row/column\ + \ distance.\n2. Before pushing, move the player to the square opposite the intended\ + \ push direction. A move that only repositions the player can be useful if it\ + \ sets up the next push.\n3. Never push a box into a wall, corner, or narrow\ + \ dead end unless that square is the target or clearly on the only path to the\ + \ target.\n4. Prefer short plans that move the single box steadily toward the\ + \ target; avoid wandering moves that do not improve player position or box position.\n\ + 5. If the box and target are aligned in the same row or column, try to keep\ + \ the box on that line and push along it.\n6. If they are not aligned, first\ + \ push to fix one coordinate, then reposition and push to fix the other coordinate.\n\ + 7. Check that after each push, the player can still reach the next required\ + \ pushing side of the box.\n8. Output only the required XML-like format and\ + \ choose valid Sokoban actions.\n\nYou are the player and you need to push all\ + \ boxes to targets. \nWhen you are right next to a box, you can push it by moving\ + \ in the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box. \nThe answer should be a sequence of actions, like Right\ + \ || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 2 + max_steps: 100 + LargerSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 8 + dim_y: 8 + num_boxes: 2 + max_steps: 100 + search_depth: 10 + SokobanDifferentGridVocab: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. \nYou are the player and\ + \ you need to push all boxes to targets. \nWhen you are right next to a box,\ + \ you can push it by moving in the same direction. \nYou cannot push a box through\ + \ a wall, and you cannot pull a box. \nThe answer should be a sequence of actions,\ + \ like Right || Right || Up\n" + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + search_depth: 30 + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + grid_lookup: + 0: W + 1: . + 2: G + 3: C + 4: B + 5: A + 6: '@' + grid_vocab: + W: wall + .: empty + G: target + C: box on target + B: box + A: player + '@': player on target + CoordSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: "You are solving the Sokoban puzzle. You are the player and you\ + \ need to push all boxes to targets.\nYou are provided with a symbol grid and\ + \ the zero-indexed coordinates of the player, each box, and each target. \n\ + Coordinates range from the top-left corner (0, 0) to the bottom-right corner\ + \ (5, 5). \nWhen you are exactly next to a box, you can push it by moving in\ + \ the same direction. \nYou cannot push a box through a wall, and you cannot\ + \ pull a box.\nThe answer should be a sequence of actions, like Right\ + \ || Right || Up.\n" + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + observation_format: grid_coord + VisualSimpleSokoban: + env_type: sokoban + max_actions_per_traj: 10 + env_instruction: You are solving the Sokoban puzzle. You are the player and you + need to push all boxes to targets. When you are right next to a box, you can + push it by moving in the same direction. You cannot push a box through a wall, + and you cannot pull a box. The answer should be a sequence of actions, like + Right || Right || Up + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + dim_x: 6 + dim_y: 6 + num_boxes: 1 + max_steps: 100 + render_mode: rgb_array + Alfworld: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_in_distribution + AlfworldOOD: + env_type: alfworld + max_actions_per_traj: 50 + parallel_friendly: false + max_workers: 1 + env_instruction: 'You are an expert agent in the ALFRED Embodied Environment. + + Complete household tasks by navigating and interacting with objects. + + + You should first reason step-by-step about the current situation. This reasoning + process MUST be enclosed within tags. + + Once you''ve finished your reasoning, you should choose an admissible action + for current step and present it within ... tags. + + ' + max_tokens: 512 + env_config: + eval_dataset: eval_out_of_distribution + Countdown: + env_type: countdown + max_actions_per_traj: 1 + env_instruction: 'You are solving the Countdown puzzle. You should use the num + list to create an equation that equals the target. Example answer format: + To find an equation using [3, 5, 2] to get 4. Let''s check 2 + 5 = 7, 7 - 3 + = 4. So the answer is 2 + 5 - 3 = 4. 2 + 5 - 3' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: null + Bandit: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: train + BanditTest: + env_type: bandit + max_actions_per_traj: 1 + env_instruction: '' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + split: test + DeepCoder: + env_type: deepcoder + max_actions_per_traj: 1 + env_instruction: 'You are solving a coding task. Provide a complete Python function + solution only. Format: ...' + max_tokens: 8000 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 1 + FrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. Forbid the whole and + go to the target. You may move to the unintended direction due to the slippery + ice. Example answer format: To forbid the hole and go to the target, + I should go left then go up.Left || Up' + max_tokens: 100 + parallel_friendly: false + max_workers: 32 + env_config: + success_rate: 0.8 + CoordFrozenLake: + env_type: frozen_lake + max_actions_per_traj: 10 + env_instruction: 'You are solving the FrozenLake puzzle. The observation includes + both a symbol grid and zero-indexed coordinates for the start, goal, player, + and any holes. + + Coordinates range from the top-left corner (0, 0) to the bottom-right corner + (5, 5). + + Beware that the ice is slippery, so the agent might slide and end up in an unintended + tile. + + Respond with a sequence of actions such as Left || Up || Up. + + ' + max_tokens: 120 + parallel_friendly: false + max_workers: 32 + env_config: + observation_format: grid_coord + success_rate: 0.8 + MetamathQA: + env_type: metamathqa + max_actions_per_traj: 1 + env_instruction: 'You are solving Math problems. ' + max_tokens: 100 + env_config: null + WebShopFull: + env_type: webshop + max_actions_per_traj: 15 + env_instruction: You are an expert autonomous agent operating in the WebShop e‑commerce + environment. + max_tokens: 200 + env_config: + dataset: full + WebShop: + env_type: webshop + max_actions_per_traj: 9 + env_instruction: 'You are browsing an online shop. Based on the instruction, buy + a product that close to the production description. You need to search, read + the search results, pick a product, choose the size and color and buy. You should + only choose action from the available actions list provided later. Example + process: I need a gingko light and 20x20 pillow cover that is hand painted. + First search[gingko light 20x20 pillow cover hand painted], answer format: search[blanket + with fleece throw]. Valid answer is search[] or click[].' + max_tokens: 200 + env_config: + dataset: small + Lean: + env_type: lean + max_actions_per_traj: 30 + env_instruction: You are a Lean theorem prover. Given a Lean theorem statement, + propose a sequence of tactics that completes the proof. Think step by step about + which tactics to apply next. Provide tactics separated by '||', for example + intro || simp || rfl. + max_tokens: 512 + parallel_friendly: true + max_workers: 32 + env_config: null + SimpleSudoku: + env_type: sudoku + max_actions_per_traj: 20 + env_instruction: 'You are a careful 4x4 Sudoku solver. Use these reusable abstractions + when reasoning: + + 1. In , explain the constraint logic behind the move, not just the final + placement. Mention which row, column, or 2x2 box makes the move safe or forced. + + 2. Treat each move as a constraint-preserving placement: place a number only + if it does not already appear in the same row, column, or 2x2 box. + + 3. First look for highly forced cells. If an empty cell has only one legal candidate + after checking its row, column, and box, fill it immediately and explain why + other numbers are excluded. + + 4. If no cell is obviously forced, scan each row, column, and 2x2 box for missing + numbers. If a missing number can go in only one empty position within that unit, + place it there and state that unit-level reason. + + 5. Prefer moves that reduce uncertainty and create new forced cells for the + next turn. A good move should make the remaining puzzle more constrained, not + more ambiguous. + + 6. Solve incrementally: choose exactly one placement, explain it briefly in + , then output that one move in . + + 7. Never modify bracketed initial cells or already-filled cells. Only place + numbers into dots. + + 8. Avoid exploratory guesses when a forced move exists. In this environment, + reliable progress usually comes from constraint propagation rather than trial-and-error. + + 9. If a previous move was invalid or the board did not change, do not repeat + the same placement. Recompute legal candidates and explain the corrected constraint-consistent + choice. + + 10. Use row, column, and box agreement as confidence: the strongest placements + are those supported by multiple constraints at once. + + 11. Keep concise but meaningful: identify the target cell, list or compare + its legal candidates, and give the decisive constraint. + + 12. Output only the required XML-like format and choose valid Sudoku placements. + + + You are solving a Sudoku puzzle. Fill in the grid so that every row, column, + and 2x2 box contains the numbers 1-4 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 1 at row 2 col 3 + + Always output: [brief constraint-based reasoning] + [one placement] + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 4 + difficulty: easy + render_format: with_feedback + show_conflicts: false + show_valid_numbers: false + max_steps: 20 + MediumSudoku: + env_type: sudoku + max_actions_per_traj: 30 + env_instruction: 'You are solving a Sudoku puzzle. Fill in the grid so that every + row, column, and 3x3 box contains the numbers 1-9 without repetition. + + Initial cells are shown in [brackets] and cannot be modified. Empty cells are + shown as dots (.). + + Place numbers one at a time using the format: place 5 at row 2 col 3 + or 2,3,5 + + The environment will provide feedback on valid/invalid moves and show conflicts + if any occur. + + ' + max_tokens: 150 + parallel_friendly: false + max_workers: 32 + env_config: + grid_size: 9 + difficulty: medium + render_format: with_feedback + show_conflicts: true + show_valid_numbers: true + max_steps: 81 + SearchQA: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + SearchQAMock: + env_type: search + max_actions_per_traj: 10 + env_instruction: "You are a search agent answering questions by searching for\ + \ information.\nUse search[your query] to find relevant documents, and finish[your\ + \ answer] to submit your final answer.\n\nYou should first reason step-by-step\ + \ about the current situation. This reasoning process MUST be enclosed within\ + \ tags.\nThen provide your action within ...\ + \ tags.\n\nExamples:\n I need to find information about Ben Platt's\ + \ father.search[Ben Platt father parent]\n Based\ + \ on the search results, Ben Platt's father is Henry Platt.finish[Henry\ + \ Platt]\n" + max_tokens: 300 + parallel_friendly: true + max_workers: 32 + env_config: + max_steps: 10 + max_search_results: 5 + mock_mode: true + game_2048: + env_type: game_2048 + max_actions_per_traj: 700 + env_instruction: 'You are playing the 2048 game on a 4x4 grid. Merge equal tiles + by sliding Up, Right, Down, or Left. + + If a move is invalid (no tiles move), a small penalty is applied. Respond with + a single action. + + Example: Up + + ' + max_tokens: 8192 + env_config: null + rubikscube: + env_type: rubikscube + max_actions_per_traj: 20 + env_instruction: 'You are solving a 2x2 Rubik''s Cube (Pocket Cube). The goal + is to restore the cube so that each of the faces consists of a single, unique + color. + + Available actions use standard Singmaster notation for face rotations: U, U'', + D, D'', L, L'', R, R'', F, F'', B, B''. + + - Faces: U (Up), D (Down), L (Left), R (Right), F (Front), B (Back). + + - Modifiers: A letter alone means 90° clockwise (e.g., ''R''). A letter with + prime ('') means 90° counter-clockwise (e.g., "R''"). + + Respond with a sequence of actions separated by "||". + + Example: U + + ' + max_tokens: 96 + env_config: + scramble_depth: 1 + max_steps: 20 + render_mode: text +system: + CUDA_VISIBLE_DEVICES: 0,1,2,3,4,5,6,7 +seed: + train: 10000 + val: 123 +micro_batch_size_per_gpu: 1 +log_prob_micro_batch_size_per_gpu: ${micro_batch_size_per_gpu} +ppo_mini_batch_size: 32 +model_path: /mnt/general/share/model/Qwen/Qwen2.5-1.5B-Instruct +enable_response_mask: true +grpo_advantage_length_weight: false +lora: + rank: 0 + alpha: 64 + target_modules: all-linear +agent_proxy: + context_window_mode: full + max_context_window: -1 + batch_adjust_mode: copy + max_turn: 20 + action_sep: '||' + max_actions_per_turn: 3 + use_turn_scores: false + enable_think: true + reward_normalization: + grouping: state + method: identity +collapse_detection: + compute_freq: 5 + micro_batch_size: 128 + first_turn_enabled: true + multi_turn_enabled: true + num_samples: 64 +es_manager: + format_penalty: -0.1 + train: + env_groups: 8 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 8 + val: + env_groups: 32 + group_size: 16 + env_configs: + tags: + - SimpleSudoku + n_groups: + - 32 +ctx_manager: + generation: + gen_config: + response_length: ${actor_rollout_ref.rollout.response_length} + temperature: ${actor_rollout_ref.rollout.temperature} + top_p: ${actor_rollout_ref.rollout.top_p} + top_k: ${actor_rollout_ref.rollout.top_k} + kwargs: null diff --git a/outputs/2026-06-02/11-04-27/train.log b/outputs/2026-06-02/11-04-27/train.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/verl/docs/sglang_multiturn/search_tool_example.rst b/verl/docs/sglang_multiturn/search_tool_example.rst new file mode 100644 index 0000000000000000000000000000000000000000..cbbdeb0d08e6102a00a85bd5544c345bb086969f --- /dev/null +++ b/verl/docs/sglang_multiturn/search_tool_example.rst @@ -0,0 +1,264 @@ +======================= +Search Tool Integration +======================= + +Last updated: 05/30/2025. + +Introduction +------------ +- We have added a search tool calling function to Multi-Turn RL, enabling the model to initiate retrieval requests during Actor rollout and directly use retrieval results for training. **We support using a local dense retriever as the retrieval tool, as well as integrating with your own local retrieval engine.** + + + +Quick Reproduction +------------------ + +Create a New Docker Container +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: bash + + docker run \ + -it \ + --shm-size 32g \ + --gpus all \ + -v {Huggingface-Cache-Path}:/root/.cache \ + --ipc=host \ + --network=host \ + --privileged \ + --name sglang_{your-name} \ + lmsysorg/sglang:dev \ + /bin/zsh + +If you need to restart after exiting the container: + +.. code:: bash + + docker start -i sglang_{your-name} + +Update Python and Configure the Virtual Environment using uv +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: bash + + apt update + apt install -y python3.10 python3.10-venv + + # Create a virtual environment + python3 -m venv ~/.python/verl-multiturn-rollout + + # Activate the virtual environment + source ~/.python/verl-multiturn-rollout/bin/activate + + # Install uv + python3 -m pip install uv + +Install verl Upstream +~~~~~~~~~~~~~~~~~~~~~ + +.. code:: bash + + cd ~ + git clone https://github.com/volcengine/verl.git + cd verl + + # Install verl + python3 -m uv pip install . + python3 -m uv pip install -r ./requirements_sglang.txt + + # Manually install flash-attn + python3 -m uv pip install wheel + python3 -m uv pip install packaging + python3 -m uv pip install flash-attn --no-build-isolation --no-deps + +Set Up a Local Retrieval Engine +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you are using your own local retrieval service, you can skip this +step. We chose the local dense retriever provided in the search-R1 +example; detailed instructions are in the `searchR1 +docs `__. +In brief: + +- The GPU version offers higher accuracy and speed; each GPU uses about + 5–7 GB of memory. +- The CPU version can be used for simple testing but has lower + retrieval precision, which will degrade training performance. See the + `retriever + documentation `__ + in search-R1 for details. +- Recommend using Conda to install faiss-gpu=1.8.0; venv may cause errors. + +**Note**: To start both the training process and the local retrieval +service, we launch two separate Python environments. The training uses +uv in the verl-multiturn-rollout environment, while the retriever uses +conda to install ``faiss-gpu``. + +.. code:: bash + + # Download the Miniconda installer script + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh + + # Install to $HOME/miniconda3 in batch mode + bash ~/miniconda.sh -b -p $HOME/miniconda3 + + # Activate conda (only in the current shell) + eval "$($HOME/miniconda3/bin/conda shell.bash hook)" + + # (Optional) Add conda to your default shell startup + conda init + + # Reload shell config + source ~/.bashrc + + # Create and activate the retriever environment with Python 3.10 + conda create -n retriever python=3.10 -y + conda activate retriever + + # Install PyTorch (with GPU support) and related libraries + conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.1 -c pytorch -c nvidia -y + + # Install other Python packages + pip install transformers datasets pyserini huggingface_hub + + # Install the GPU version of faiss + conda install faiss-gpu=1.8.0 -c pytorch -c nvidia -y + + # Install the API service framework + pip install uvicorn fastapi + +Download the Indexing and Corpus +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The local retrieval files are large—prepare sufficient disk space. +Downloading is about 60–70 GB, and uncompressed takes about 132 GB: + +.. code:: bash + + conda activate retriever + + save_path=/the/path/to/save + python examples/sglang_multiturn/search_r1_like/local_dense_retriever/download.py --save_path $save_path + cat $save_path/part_* > $save_path/e5_Flat.index + gzip -d $save_path/wiki-18.jsonl.gz + +Start the Local flat e5 Retrieval Server +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +1. The first startup will download models and load the index. +2. Apart from the download, startup takes about 1–2 minutes. +3. After startup, each GPU uses about 5–7 GB of memory, leaving the rest + for multi-turn RL training. + +.. code:: bash + + conda activate retriever + + index_file=$save_path/e5_Flat.index + corpus_file=$save_path/wiki-18.jsonl + retriever_name=e5 + retriever_path=intfloat/e5-base-v2 + + python examples/sglang_multiturn/search_r1_like/local_dense_retriever/retrieval_server.py \ + --index_path $index_file \ + --corpus_path $corpus_file \ + --topk 3 \ + --retriever_name $retriever_name \ + --retriever_model $retriever_path \ + --faiss_gpu + +Set Up WANDB_API_KEY +~~~~~~~~~~~~~~~~~~~~ + +.. code:: bash + + export WANDB_API_KEY={YOUR_WANDB_API_KEY} + + # Define a timestamp function + function now() { + date '+%Y-%m-%d-%H-%M' + } + +**Preprocess the Dataset** +~~~~~~~~~~~~~~~~~~~~~~~~~~ + + **Note:** The following data processing and training commands must be + run in the verl-multiturn-rollout environment. + +.. code:: bash + + python3 examples/data_preprocess/preprocess_search_r1_dataset.py + +Testing on 8 x H20 +~~~~~~~~~~~~~~~~~~ + +.. code:: bash + + # Ensure the now() function is defined + # Create a logs directory + mkdir -p logs + + # Set GPUs and run with a suitable log path + export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 + + nohup bash examples/sglang_multiturn/search_r1_like/run_qwen2.5-3b_instruct_search_multiturn.sh \ + trainer.experiment_name=qwen2.5-3b-it_rm-searchR1-like-sgl-multiturn-$(now) \ + > logs/searchR1-like$(now).log 2>&1 & + +Custom Search Configuration +--------------------------- + +To enable multi-turn reasoning, set the following fields in your config: + +.. code:: yaml + + actor_rollout_ref: + rollout: + name: "sglang" + multi_turn: + enable: True + +You must specify ``retrieval_service_url`` in ``examples/sglang_multiturn/config/tool_config/search_tool_config.yaml``, and properly configure concurrency. For more details on concurrency, refer to the Sandbox Fusion example: + +.. code:: yaml + + tools: + - class_name: verl.tools.search_tool.SearchTool + config: + retrieval_service_url: http://127.0.0.1:8000/retrieve + num_workers: 120 + rate_limit: 120 + timeout: 30 + +The retriever input/output formats are as follows. If your service +parameters match, only modify ``retrieval_service_url``. You can also +customize in ``search_r1_like_utils.py``. + +.. code:: python + + Input format: + { + "queries": ["What is Python?", "Tell me about neural networks."], + "topk": 3, + "return_scores": true + } + + Output format (when return_scores=True, similarity scores are returned): + { + "result": [ + [ # Results for each query + { + "document": doc, "score": score + }, + # ... more documents + ], + # ... results for other queries + ] + } + +Notes +----- + +1. The total training time is about 27 hours; meanwhile, the validation + dataset is very large (51 k), and each validation takes about 6000 s. + (Therefore, ``val_before_train=False`` by default) diff --git a/verl/examples/data_preprocess/dapo_multiturn_w_tool.py b/verl/examples/data_preprocess/dapo_multiturn_w_tool.py new file mode 100644 index 0000000000000000000000000000000000000000..aab356f41bf38e789a31f1ee879ce9beb8b0aa40 --- /dev/null +++ b/verl/examples/data_preprocess/dapo_multiturn_w_tool.py @@ -0,0 +1,79 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright 2023-2024 SGLang Team +# Copyright 2025 ModelBest Inc. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Preprocess the DAPO-Math-17k dataset to multiturn format +""" + +import argparse +import os + +import datasets + +from verl.utils.hdfs_io import copy, makedirs + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--local_dir", default=None, help="The save directory for the preprocessed dataset.") + parser.add_argument("--hdfs_dir", default=None) + parser.add_argument("--local_dataset_path", default=None, help="The local path to the raw dataset, if it exists.") + parser.add_argument( + "--local_save_dir", default="~/data/retool_dapo", help="The save directory for the preprocessed dataset." + ) + + args = parser.parse_args() + local_dataset_path = args.local_dataset_path + + data_path = "BytedTsinghua-SIA/DAPO-Math-17k" + + if local_dataset_path is not None: + dataset = datasets.load_dataset(local_dataset_path, "default") + else: + dataset = datasets.load_dataset(data_path, "default") + + train_dataset = dataset["train"] + + # add a row to each data item that represents a unique id + def make_map_fn(split): + def process_fn(example, idx): + orig_extra_info = example.pop("extra_info") + extra_info = orig_extra_info.copy() + extra_info["need_tools_kwargs"] = True + extra_info["tools_kwargs"] = { + "code_interpreter": { + "create_kwargs": { + "ground_truth": example["reward_model"]["ground_truth"], + }, + }, + } + example["extra_info"] = extra_info + return example + + return process_fn + + train_dataset = train_dataset.map(function=make_map_fn("train"), with_indices=True) + + hdfs_dir = args.hdfs_dir + local_save_dir = args.local_dir + if local_save_dir is not None: + print("Warning: Argument 'local_dir' is deprecated. Please use 'local_save_dir' instead.") + else: + local_save_dir = args.local_save_dir + + train_dataset.to_parquet(os.path.join(local_save_dir, "train.parquet")) + + if hdfs_dir is not None: + makedirs(hdfs_dir) + copy(src=local_save_dir, dst=hdfs_dir) diff --git a/verl/examples/data_preprocess/full_hh_rlhf.py b/verl/examples/data_preprocess/full_hh_rlhf.py new file mode 100644 index 0000000000000000000000000000000000000000..4e8a148df1e322f476cedffe4eadc5ae6ee9b6f1 --- /dev/null +++ b/verl/examples/data_preprocess/full_hh_rlhf.py @@ -0,0 +1,161 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +- Preprocess data and split the training set into 75% for training RM and 25% for validting RM. +- All the training data is used to train SFT and RL. +- Both chosen and rejected is used to train SFT +""" + +import argparse +import os + +import pandas as pd +from datasets import load_dataset +from tqdm.auto import tqdm + +from verl.utils.fs import copy, makedirs + + +def generate_sft_dataset(target_hdfs_path_dir, local_dir="~/data/full_hh_rlh/sft", local_dataset_path=None): + if local_dataset_path is not None: + dataset = load_dataset(local_dataset_path) + else: + dataset = load_dataset("Dahoas/full-hh-rlhf") + output = {"prompt": [], "response": []} + for data in tqdm(dataset["train"]): + # add chosen + output["prompt"].append(data["prompt"]) + output["response"].append(data["chosen"]) + + # add rejection + output["prompt"].append(data["prompt"]) + output["response"].append(data["rejected"]) + + df = pd.DataFrame(output) + + local_dir = os.path.expanduser(local_dir) + os.makedirs(local_dir, exist_ok=True) + + local_path = os.path.join(local_dir, "train.parquet") + + df.to_parquet(path=local_path) + + if target_hdfs_path_dir is not None: + hdfs_dir = target_hdfs_path_dir + "/" + "train.parquet" + makedirs(hdfs_dir) + + copy(local_path, hdfs_dir) + + +def generate_rm_dataset(target_hdfs_path_dir, local_dir="~/data/full_hh_rlh/rm", local_dataset_path=None): + if local_dataset_path is not None: + train_dataset = load_dataset(local_dataset_path, split="train[:75%]") + test_dataset = load_dataset(local_dataset_path, split="train[-25%:]") + else: + train_dataset = load_dataset("Dahoas/full-hh-rlhf", split="train[:75%]") + test_dataset = load_dataset("Dahoas/full-hh-rlhf", split="train[-25%:]") + + local_dir = os.path.expanduser(local_dir) + os.makedirs(local_dir, exist_ok=True) + + for dataset, name in zip([train_dataset, test_dataset], ["train", "test"], strict=True): + output = {"prompt": [], "chosen": [], "rejected": []} + for data in tqdm(dataset): + # add chosen + output["prompt"].append(data["prompt"]) + output["chosen"].append(data["chosen"]) + output["rejected"].append(data["rejected"]) + + df = pd.DataFrame(output) + + local_path = os.path.join(local_dir, name + ".parquet") + + df.to_parquet(path=local_path) + + if target_hdfs_path_dir is not None: + hdfs_dir = target_hdfs_path_dir + "/" + name + ".parquet" + makedirs(hdfs_dir) + + copy(local_path, hdfs_dir) + + +def generate_rl_dataset(target_hdfs_path_dir, local_dir="~/data/full_hh_rlhf/rl", local_dataset_path=None): + if local_dataset_path is not None: + dataset = load_dataset(local_dataset_path) + else: + dataset = load_dataset("Dahoas/full-hh-rlhf") + train_dataset = dataset["train"] + + data_source = "Dahoas/full-hh-rlhf" + + # add a row to each data item that represents a unique id + def make_map_fn(split): + def process_fn(example, idx): + prompt = example.pop("prompt") + response = example.pop("response") + + data = { + "data_source": data_source, + "prompt": [{"role": "user", "content": prompt}], + "ability": "alignment", + "reward_model": { + "style": "model", + "ground_truth": response, # should not be used + }, + "extra_info": {"split": split, "index": idx}, + } + return data + + return process_fn + + train_dataset = train_dataset.map(function=make_map_fn("train"), with_indices=True) + local_dir = os.path.expanduser(local_dir) + local_path = os.path.join(local_dir, "train.parquet") + train_dataset.to_parquet(local_path) + + if target_hdfs_path_dir is not None: + hdfs_dir = target_hdfs_path_dir + "/" + "train.parquet" + makedirs(hdfs_dir) + + copy(local_path, hdfs_dir) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--split", type=str, choices=["sft", "rm", "rl"], required=True) + parser.add_argument("--local_dir", default=None, help="The save directory for the preprocessed dataset.") + parser.add_argument("--hdfs_dir", type=str, required=False, default=None) + parser.add_argument("--local_dataset_path", default=None, help="The local path to the raw dataset, if it exists.") + parser.add_argument( + "--local_save_dir", + type=str, + default="~/data/full_hh_rlhf", + help="The save directory for the preprocessed dataset.", + ) + + args = parser.parse_args() + local_save_dir = args.local_dir + if local_save_dir is not None: + print("Warning: Argument 'local_dir' is deprecated. Please use 'local_save_dir' instead.") + else: + local_save_dir = args.local_save_dir + + if args.split == "sft": + generate_sft_dataset(args.hdfs_dir, os.path.join(local_save_dir, args.split), args.local_dataset_path) + elif args.split == "rm": + generate_rm_dataset(args.hdfs_dir, os.path.join(local_save_dir, args.split), args.local_dataset_path) + elif args.split == "rl": + generate_rl_dataset(args.hdfs_dir, os.path.join(local_save_dir, args.split), args.local_dataset_path) + else: + raise NotImplementedError diff --git a/verl/examples/data_preprocess/gsm8k_multiturn_sft.py b/verl/examples/data_preprocess/gsm8k_multiturn_sft.py new file mode 100644 index 0000000000000000000000000000000000000000..4589362f933aa95493fdd98ce965eb810180c98a --- /dev/null +++ b/verl/examples/data_preprocess/gsm8k_multiturn_sft.py @@ -0,0 +1,102 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Preprocess the GSM8k dataset to parquet format +""" + +import argparse +import os +import re + +import datasets + +from verl.utils.hdfs_io import copy, makedirs + + +def extract_solution(solution_str): + solution = re.search("#### (\\-?[0-9\\.\\,]+)", solution_str) + assert solution is not None + final_solution = solution.group(0) + final_solution = final_solution.split("#### ")[1].replace(",", "") + return final_solution + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--local_dir", default=None) + parser.add_argument("--local_dataset_path", default=None, help="The local path to the raw dataset, if it exists.") + parser.add_argument( + "--local_save_dir", default="~/data/gsm8k_sft", help="The save directory for the preprocessed dataset." + ) + parser.add_argument("--hdfs_dir", default=None) + + args = parser.parse_args() + local_dataset_path = args.local_dataset_path + + data_source = "openai/gsm8k" + + if local_dataset_path is not None: + dataset = datasets.load_dataset(local_dataset_path, "main") + else: + dataset = datasets.load_dataset(data_source, "main") + + train_dataset = dataset["train"] + test_dataset = dataset["test"] + + instruction_following = 'Let\'s think step by step and output the final answer after "####".' + + # add a row to each data item that represents a unique id + def make_map_fn(split): + def process_fn(example, idx): + question_raw = example.pop("question") + + question = question_raw + " " + instruction_following + + answer_raw = example.pop("answer") + data = { + "messages": [ + { + "role": "user", + "content": question, + }, + { + "role": "assistant", + "content": answer_raw, + }, + ], + } + return data + + return process_fn + + train_dataset = train_dataset.map(function=make_map_fn("train"), with_indices=True) + test_dataset = test_dataset.map(function=make_map_fn("test"), with_indices=True) + + hdfs_dir = args.hdfs_dir + + local_save_dir = args.local_dir + if local_save_dir is not None: + print("Warning: Argument 'local_dir' is deprecated. Please use 'local_save_dir' instead.") + else: + local_save_dir = args.local_save_dir + + local_save_dir = os.path.expanduser(local_save_dir) + + train_dataset.to_parquet(os.path.join(local_save_dir, "train.parquet")) + test_dataset.to_parquet(os.path.join(local_save_dir, "test.parquet")) + + if hdfs_dir is not None: + makedirs(hdfs_dir) + + copy(src=local_save_dir, dst=hdfs_dir) diff --git a/verl/examples/data_preprocess/gsm8k_multiturn_w_tool.py b/verl/examples/data_preprocess/gsm8k_multiturn_w_tool.py new file mode 100644 index 0000000000000000000000000000000000000000..083550ad7f160a5caac97d85ee33164b0437119d --- /dev/null +++ b/verl/examples/data_preprocess/gsm8k_multiturn_w_tool.py @@ -0,0 +1,129 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright 2023-2024 SGLang Team +# Copyright 2025 ModelBest Inc. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Preprocess the GSM8k dataset to parquet format +""" + +import argparse +import os +import re + +import datasets + +from verl.utils.hdfs_io import copy, makedirs + + +def extract_solution(solution_str): + solution = re.search("#### (\\-?[0-9\\.\\,]+)", solution_str) + assert solution is not None + final_solution = solution.group(0) + final_solution = final_solution.split("#### ")[1].replace(",", "") + return final_solution + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--local_dir", default=None, help="The save directory for the preprocessed dataset.") + parser.add_argument("--hdfs_dir", default=None) + parser.add_argument("--local_dataset_path", default=None, help="The local path to the raw dataset, if it exists.") + parser.add_argument( + "--local_save_dir", default="~/data/gsm8k", help="The save directory for the preprocessed dataset." + ) + + args = parser.parse_args() + local_dataset_path = args.local_dataset_path + + data_source = "openai/gsm8k" + + if local_dataset_path is not None: + dataset = datasets.load_dataset(local_dataset_path, "main") + else: + dataset = datasets.load_dataset(data_source, "main") + + train_dataset = dataset["train"] + test_dataset = dataset["test"] + + instruction_following = "Let's think step by step and output the final answer after `####`." + + # add a row to each data item that represents a unique id + def make_map_fn(split): + def process_fn(example, idx): + question_raw = example.pop("question") + + question = question_raw + " " + instruction_following + + answer_raw = example.pop("answer") + solution = extract_solution(answer_raw) + data = { + "data_source": data_source, + "prompt": [ + { + "role": "system", + "content": ( + "You are a math expert. You are given a question and you need to solve it step by step. " + "Reasoning step by step before any tool call. " + "You should use the `calc_gsm8k_reward` tool after step by step solving the question, " + "before generate final answer at least once and refine your answer if necessary. " + "Put your final answer in the format of `#### `." + ), + }, + { + "role": "user", + "content": question, + }, + ], + "ability": "math", + "reward_model": {"style": "rule", "ground_truth": solution}, + "extra_info": { + "split": split, + "index": idx, + "answer": answer_raw, + "question": question_raw, + "need_tools_kwargs": True, + "tools_kwargs": { + "calc_gsm8k_reward": { + "create_kwargs": {"ground_truth": solution}, + # "execute_kwargs": {}, + # "calc_reward_kwargs": {}, + # "release_kwargs": {}, + }, + }, + "interaction_kwargs": { + "query": question, + "ground_truth": solution, + }, + }, + } + return data + + return process_fn + + train_dataset = train_dataset.map(function=make_map_fn("train"), with_indices=True) + test_dataset = test_dataset.map(function=make_map_fn("test"), with_indices=True) + + hdfs_dir = args.hdfs_dir + local_save_dir = args.local_dir + if local_save_dir is not None: + print("Warning: Argument 'local_dir' is deprecated. Please use 'local_save_dir' instead.") + else: + local_save_dir = args.local_save_dir + + train_dataset.to_parquet(os.path.join(local_save_dir, "train.parquet")) + test_dataset.to_parquet(os.path.join(local_save_dir, "test.parquet")) + + if hdfs_dir is not None: + makedirs(hdfs_dir) + copy(src=local_save_dir, dst=hdfs_dir) diff --git a/verl/examples/data_preprocess/math_dataset.py b/verl/examples/data_preprocess/math_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..b23a032fb1207a47dcd1bc77194a7c1a124aad55 --- /dev/null +++ b/verl/examples/data_preprocess/math_dataset.py @@ -0,0 +1,106 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Preprocess the MATH-lighteval dataset to parquet format +""" + +import argparse +import json +import os + +import datasets + +from verl.utils.hdfs_io import copy, makedirs +from verl.utils.reward_score.math_reward import last_boxed_only_string, remove_boxed + + +def extract_solution(solution_str): + return remove_boxed(last_boxed_only_string(solution_str)) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--local_dir", default=None) + parser.add_argument("--hdfs_dir", default=None) + parser.add_argument("--local_dataset_path", default=None, help="The local path to the raw dataset, if it exists.") + parser.add_argument( + "--local_save_dir", default="~/data/math", help="The save directory for the preprocessed dataset." + ) + + args = parser.parse_args() + local_dataset_path = args.local_dataset_path + + # 'lighteval/MATH' is no longer available on huggingface. + # Use mirror repo: DigitalLearningGmbH/MATH-lighteval + data_source = "DigitalLearningGmbH/MATH-lighteval" + print(f"Loading the {data_source} dataset from huggingface...", flush=True) + if local_dataset_path is not None: + dataset = datasets.load_dataset( + local_dataset_path, + ) + else: + dataset = datasets.load_dataset( + data_source, + ) + + train_dataset = dataset["train"] + test_dataset = dataset["test"] + + instruction_following = "Let's think step by step and output the final answer within \\boxed{}." + + # add a row to each data item that represents a unique id + def make_map_fn(split): + def process_fn(example, idx): + question = example.pop("problem") + + question = question + " " + instruction_following + + answer = example.pop("solution") + solution = extract_solution(answer) + data = { + "data_source": data_source, + "prompt": [{"role": "user", "content": question}], + "ability": "math", + "reward_model": {"style": "rule", "ground_truth": solution}, + "extra_info": {"split": split, "index": idx}, + } + return data + + return process_fn + + train_dataset = train_dataset.map(function=make_map_fn("train"), with_indices=True) + test_dataset = test_dataset.map(function=make_map_fn("test"), with_indices=True) + + local_save_dir = args.local_dir + if local_save_dir is not None: + print("Warning: Argument 'local_dir' is deprecated. Please use 'local_save_dir' instead.") + else: + local_save_dir = args.local_save_dir + + local_dir = os.path.expanduser(local_save_dir) + hdfs_dir = args.hdfs_dir + + train_dataset.to_parquet(os.path.join(local_dir, "train.parquet")) + test_dataset.to_parquet(os.path.join(local_dir, "test.parquet")) + # Save one example as JSON for reference + example = train_dataset[0] + with open(os.path.join(local_dir, "train_example.json"), "w") as f: + json.dump(example, f, indent=2) + example = test_dataset[0] + with open(os.path.join(local_dir, "test_example.json"), "w") as f: + json.dump(example, f, indent=2) + if hdfs_dir is not None: + makedirs(hdfs_dir) + + copy(src=local_dir, dst=hdfs_dir) diff --git a/verl/examples/data_preprocess/multiturn.py b/verl/examples/data_preprocess/multiturn.py new file mode 100644 index 0000000000000000000000000000000000000000..4bf0192b817d3acfc41f7e4a74a4a891d3ae61d6 --- /dev/null +++ b/verl/examples/data_preprocess/multiturn.py @@ -0,0 +1,125 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Create a simple multi-turn dataset for testing +""" + +import argparse +import os + +import pandas as pd + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--local_dir", default="~/data/multiturn") + parser.add_argument("--hdfs_dir", default=None) + args = parser.parse_args() + + # Create example conversations + conversations = [] + + # Conversation 1 + conversations.append( + { + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "What is the capital of France?"}, + {"role": "assistant", "content": "The capital of France is Paris."}, + {"role": "user", "content": "And what about Germany?"}, + {"role": "assistant", "content": "The capital of Germany is Berlin."}, + ] + } + ) + + # Conversation 2 + conversations.append( + { + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Can you explain quantum computing?"}, + { + "role": "assistant", + "content": "Quantum computing is a type of computing that uses quantum-mechanical phenomena, " + "such as superposition and entanglement, to perform operations on data.", + }, + {"role": "user", "content": "How is it different from classical computing?"}, + { + "role": "assistant", + "content": "Classical computing uses bits that are either 0 or 1, while quantum computing uses " + "quantum bits or qubits that can exist in multiple states simultaneously due to superposition.", + }, + ] + } + ) + + # Conversation 3 + conversations.append( + { + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Write a simple Python function to calculate factorial."}, + { + "role": "assistant", + "content": ( + "```python\ndef factorial(n):\n if n == 0 or n == 1:\n return 1\n else:\n " + "return n * factorial(n-1)\n```\n\nThis is a recursive function to calculate the " + "factorial of a number." + ), + }, + {"role": "user", "content": "Can you make it iterative instead?"}, + { + "role": "assistant", + "content": ( + "```python\ndef factorial(n):\n result = 1\n for i in range(1, n+1):\n " + "result *= i\n return result\n```\n\nThis is an iterative version of the factorial function." + ), + }, + ] + } + ) + + # Create train and test datasets + train_data = conversations[:2] # First 2 conversations for training + test_data = conversations[2:] # Last conversation for testing + + # Create output directory + local_dir = os.path.expanduser(args.local_dir) + os.makedirs(local_dir, exist_ok=True) + + # Save to parquet files + train_df = pd.DataFrame(train_data) + test_df = pd.DataFrame(test_data) + + train_df.to_parquet(os.path.join(local_dir, "train.parquet")) + test_df.to_parquet(os.path.join(local_dir, "test.parquet")) + + # Handle HDFS if specified + if args.hdfs_dir is not None: + try: + from verl.utils.hdfs_io import copy, makedirs + + makedirs(args.hdfs_dir) + copy(src=local_dir, dst=args.hdfs_dir) + except ImportError: + print("Warning: HDFS support not available. Skipping HDFS copy.") + + # Print statistics + print(f"Train dataset size: {len(train_df)}") + print(f"Test dataset size: {len(test_df)}") + print(f"Data saved to {local_dir}") + + +if __name__ == "__main__": + main() diff --git a/verl/examples/data_preprocess/preprocess_search_r1_dataset.py b/verl/examples/data_preprocess/preprocess_search_r1_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..a0c10d59b9c006ae7234ce21f7bdb25562259b23 --- /dev/null +++ b/verl/examples/data_preprocess/preprocess_search_r1_dataset.py @@ -0,0 +1,178 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright 2023-2024 SGLang Team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import logging +import os +import tempfile + +import pandas as pd +from huggingface_hub import hf_hub_download +from huggingface_hub.utils import EntryNotFoundError + +from verl.utils.hdfs_io import copy, makedirs + +# Setup logging +logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") +logger = logging.getLogger(__name__) + +# Configuration constants +DEFAULT_SYSTEM_CONTENT = "You are a helpful and harmless assistant." +DEFAULT_USER_CONTENT_PREFIX = ( + "Answer the given question. You must conduct reasoning inside and " + "first every time you get new information. After reasoning, if you find you lack " + "some knowledge, you can call a search engine by query " + "and it will return the top searched results between and " + ". You can search as many times as your want. If you find no " + "further external knowledge needed, you can directly provide the answer inside " + " and , without detailed illustrations. For example, " + " Beijing . Question: " +) + + +def process_single_row(row, current_split_name, row_index): + """ + Process a single row of data for SearchR1-like format. + + Args: + row: DataFrame row containing the original data + current_split_name: Name of the current split (train/test) + row_index: Index of the row in the DataFrame + + Returns: + pd.Series: Processed row data in the required format + """ + question = row.get("question", "") + + # Build prompt structure + user_content = user_content_prefix.rstrip("\n") + question + prompt = [{"role": "system", "content": system_content}, {"role": "user", "content": user_content}] + + # Extract ground truth from reward_model or fallback to golden_answers + reward_model_data = row.get("reward_model") + if isinstance(reward_model_data, dict) and "ground_truth" in reward_model_data: + ground_truth = reward_model_data.get("ground_truth") + else: + ground_truth = row.get("golden_answers", []) + + # Process data source + data_source_tagged = "searchR1_" + str(row.get("data_source", "")) + + # Build tools kwargs structure + tools_kwargs = { + "search": { + "create_kwargs": {"ground_truth": ground_truth, "question": question, "data_source": data_source_tagged} + } + } + + # Build complete extra_info structure + extra_info = { + "index": row_index, + "need_tools_kwargs": True, + "question": question, + "split": current_split_name, + "tools_kwargs": tools_kwargs, + } + + return pd.Series( + { + "data_source": data_source_tagged, + "prompt": prompt, + "ability": row.get("ability"), + "reward_model": reward_model_data, + "extra_info": extra_info, + "metadata": row.get("metadata"), + } + ) + + +def main(): + local_save_dir = os.path.expanduser(args.local_dir) + os.makedirs(local_save_dir, exist_ok=True) + + processed_files = [] + + # Download and process files using temporary directory + with tempfile.TemporaryDirectory() as tmp_download_dir: + for split in ["train", "test"]: + parquet_filename = f"{split}.parquet" + logger.info(f"Processing {split} split...") + + try: + # Download Parquet file from HuggingFace + logger.info(f"Downloading {parquet_filename} from {args.hf_repo_id}") + local_parquet_filepath = hf_hub_download( + repo_id=args.hf_repo_id, + filename=parquet_filename, + repo_type="dataset", + local_dir=tmp_download_dir, + local_dir_use_symlinks=False, + ) + + # Load and process Parquet file + df_raw = pd.read_parquet(local_parquet_filepath) + logger.info(f"Loaded {len(df_raw)} rows from {parquet_filename}") + + def apply_process_row(row, split_name=split): + return process_single_row(row, current_split_name=split_name, row_index=row.name) + + df_processed = df_raw.apply(apply_process_row, axis=1) + + # Save processed DataFrame + output_file_path = os.path.join(local_save_dir, f"{split}.parquet") + df_processed.to_parquet(output_file_path, index=False) + logger.info(f"Saved {len(df_processed)} processed rows to {output_file_path}") + processed_files.append(output_file_path) + + except EntryNotFoundError: + logger.warning(f"{parquet_filename} not found in repository {args.hf_repo_id}") + except Exception as e: + logger.error(f"Error processing {split} split: {e}") + + if not processed_files: + logger.warning("No data was processed or saved") + return + + logger.info(f"Successfully processed {len(processed_files)} files to {local_save_dir}") + + # Copy to HDFS if specified + if args.hdfs_dir: + try: + makedirs(args.hdfs_dir) + copy(src=local_save_dir, dst=args.hdfs_dir) + logger.info(f"Successfully copied files to HDFS: {args.hdfs_dir}") + except Exception as e: + logger.error(f"Error copying files to HDFS: {e}") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Download Search-R1 from HuggingFace, process, and save to Parquet.") + parser.add_argument( + "--hf_repo_id", default="PeterJinGo/nq_hotpotqa_train", help="HuggingFace dataset repository ID." + ) + parser.add_argument( + "--local_dir", + default="~/data/searchR1_processed_direct", + help="Local directory to save the processed Parquet files.", + ) + parser.add_argument("--hdfs_dir", default=None, help="Optional HDFS directory to copy the Parquet files to.") + + args = parser.parse_args() + + # System and user content configuration + system_content = DEFAULT_SYSTEM_CONTENT + user_content_prefix = DEFAULT_USER_CONTENT_PREFIX + + main() diff --git a/verl/examples/generation/run_deepseek_v2_lite_math.sh b/verl/examples/generation/run_deepseek_v2_lite_math.sh new file mode 100644 index 0000000000000000000000000000000000000000..0c5a74b1f489f5aa38da8273f73f8b4e65a24b9a --- /dev/null +++ b/verl/examples/generation/run_deepseek_v2_lite_math.sh @@ -0,0 +1,22 @@ +set -x + +data_path=$HOME/data/gsm8k/test.parquet +save_path=$HOME/data/gsm8k/deepseek_v2_lite_gen_test.parquet +model_path=deepseek-ai/deepseek-llm-7b-chat + +python3 -m verl.trainer.main_generation \ + trainer.nnodes=1 \ + trainer.n_gpus_per_node=8 \ + data.path=$data_path \ + data.prompt_key=prompt \ + data.n_samples=1 \ + data.output_path=$save_path \ + model.path=$model_path \ + +model.trust_remote_code=True \ + rollout.temperature=1.0 \ + rollout.top_k=50 \ + rollout.top_p=0.7 \ + rollout.prompt_length=2048 \ + rollout.response_length=1024 \ + rollout.tensor_model_parallel_size=2 \ + rollout.gpu_memory_utilization=0.8 diff --git a/verl/examples/gmpo_trainer/test_dapo_7b_math.sh b/verl/examples/gmpo_trainer/test_dapo_7b_math.sh new file mode 100644 index 0000000000000000000000000000000000000000..a355c859b80d05754836fa87314289986ebfef67 --- /dev/null +++ b/verl/examples/gmpo_trainer/test_dapo_7b_math.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env bash +set -xeuo pipefail + +project_name='DAPO' +exp_name='DAPO-Qwen2.5-7b-MATH-0527a1' + +adv_estimator=grpo + +use_kl_in_reward=False +kl_coef=0.0 +use_kl_loss=False +kl_loss_coef=0.0 + +clip_ratio_low=0.4 +clip_ratio_high=0.4 + +max_prompt_length=$((1024 * 2)) +max_response_length=$((1024 * 8)) +enable_overlong_buffer=True +overlong_buffer_len=$((1024 * 4)) +overlong_penalty_factor=1.0 + +loss_agg_mode="token-mean" + +train_prompt_bsz=512 +n_resp_per_prompt=16 +train_prompt_mini_bsz=32 + +# Ray +# RAY_ADDRESS=${RAY_ADDRESS:-"http://localhost:8265"} +# WORKING_DIR=${WORKING_DIR:-"${PWD}"} +# RUNTIME_ENV=${RUNTIME_ENV:-"${WORKING_DIR}/verl/trainer/runtime_env.yaml"} +NNODES=${NNODES:-8} +NGPUS_PER_NODE=${NGPUS_PER_NODE:-8} +# Paths +RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"} +# very important! please modify the max_position_embeddings in config.json to 32768 after downloading from huggingface +MODEL_PATH=${MODEL_PATH:-"${RAY_DATA_HOME}/models/Qwen2.5-Math-7B"} +CKPTS_DIR=${CKPTS_DIR:-"${RAY_DATA_HOME}/ckpts/${project_name}/${exp_name}"} +TRAIN_FILE=${TRAIN_FILE:-"${RAY_DATA_HOME}/data/dapo-math-17k.parquet"} +TEST_FILE=${TEST_FILE:-"${RAY_DATA_HOME}/data/aime-2024.parquet"} + +# Algorithm +temperature=1.0 +top_p=1.0 +top_k=-1 # 0 for HF rollout, -1 for vLLM rollout +val_top_p=0.7 + +# Performance Related Parameter +sp_size=4 +use_dynamic_bsz=True +actor_ppo_max_token_len=$(((max_prompt_length + max_response_length) * 2)) +infer_ppo_max_token_len=$(((max_prompt_length + max_response_length) * 3)) +offload=True +gen_tp=4 +fsdp_size=32 + +loss_mode=geo_mean + +# export WANDB_MODE=offline +save_contents="['model', 'optimizer', 'extra']" +# save_contents="['hf_model']" + +# reference run wandb: https://wandb.ai/verl-org/DAPO%20Reproduction%20on%20verl/runs/ow47vvon?nw=nwusertongyuxuan361 + +python3 -m verl.trainer.main_ppo \ + data.train_files="${TRAIN_FILE}" \ + data.val_files="${TEST_FILE}" \ + data.prompt_key=prompt \ + data.truncation='left' \ + data.max_prompt_length=${max_prompt_length} \ + data.max_response_length=${max_response_length} \ + data.train_batch_size=${train_prompt_bsz} \ + actor_rollout_ref.rollout.n=${n_resp_per_prompt} \ + algorithm.adv_estimator=${adv_estimator} \ + algorithm.use_kl_in_reward=${use_kl_in_reward} \ + algorithm.kl_ctrl.kl_coef=${kl_coef} \ + actor_rollout_ref.actor.use_kl_loss=${use_kl_loss} \ + actor_rollout_ref.actor.kl_loss_coef=${kl_loss_coef} \ + actor_rollout_ref.actor.policy_loss.loss_mode=${loss_mode} \ + actor_rollout_ref.actor.clip_ratio_low=${clip_ratio_low} \ + actor_rollout_ref.actor.clip_ratio_high=${clip_ratio_high} \ + actor_rollout_ref.model.use_remove_padding=True \ + +actor_rollout_ref.model.override_config.max_position_embeddings=32768 \ + actor_rollout_ref.actor.use_dynamic_bsz=${use_dynamic_bsz} \ + actor_rollout_ref.ref.log_prob_use_dynamic_bsz=${use_dynamic_bsz} \ + actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=${use_dynamic_bsz} \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=${actor_ppo_max_token_len} \ + actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \ + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=${infer_ppo_max_token_len} \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.model.path="${MODEL_PATH}" \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.optim.lr_warmup_steps=10 \ + actor_rollout_ref.actor.optim.weight_decay=0.1 \ + actor_rollout_ref.actor.ppo_mini_batch_size=${train_prompt_mini_bsz} \ + actor_rollout_ref.actor.fsdp_config.param_offload=${offload} \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=${offload} \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.actor.grad_clip=1.0 \ + actor_rollout_ref.actor.loss_agg_mode=${loss_agg_mode} \ + actor_rollout_ref.actor.ulysses_sequence_parallel_size=${sp_size} \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.80 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \ + actor_rollout_ref.rollout.enable_chunked_prefill=True \ + actor_rollout_ref.rollout.max_num_batched_tokens=$((max_prompt_length + max_response_length)) \ + actor_rollout_ref.rollout.temperature=${temperature} \ + actor_rollout_ref.rollout.top_p=${top_p} \ + actor_rollout_ref.rollout.top_k=${top_k} \ + actor_rollout_ref.rollout.val_kwargs.temperature=${temperature} \ + actor_rollout_ref.rollout.val_kwargs.top_p=${val_top_p} \ + actor_rollout_ref.rollout.val_kwargs.top_k=${top_k} \ + actor_rollout_ref.rollout.val_kwargs.do_sample=True \ + actor_rollout_ref.rollout.val_kwargs.n=1 \ + actor_rollout_ref.ref.fsdp_config.param_offload=${offload} \ + actor_rollout_ref.ref.ulysses_sequence_parallel_size=${sp_size} \ + actor_rollout_ref.actor.fsdp_config.fsdp_size=${fsdp_size} \ + actor_rollout_ref.actor.checkpoint.save_contents="${save_contents}" \ + reward_model.reward_manager=dapo \ + +reward_model.reward_kwargs.overlong_buffer_cfg.enable=${enable_overlong_buffer} \ + +reward_model.reward_kwargs.overlong_buffer_cfg.len=${overlong_buffer_len} \ + +reward_model.reward_kwargs.overlong_buffer_cfg.penalty_factor=${overlong_penalty_factor} \ + +reward_model.reward_kwargs.overlong_buffer_cfg.log=False \ + +reward_model.reward_kwargs.max_resp_len=${max_response_length} \ + trainer.logger='["console","wandb"]' \ + trainer.project_name="${project_name}" \ + trainer.experiment_name="${exp_name}" \ + trainer.n_gpus_per_node="${NGPUS_PER_NODE}" \ + trainer.nnodes="${NNODES}" \ + trainer.val_before_train=True \ + trainer.test_freq=10 \ + trainer.save_freq=10 \ + trainer.total_epochs=10 \ + trainer.total_training_steps=200 \ + trainer.default_local_dir="${CKPTS_DIR}" \ + trainer.resume_mode=auto \ + trainer.log_val_generations=10 diff --git a/verl/examples/gpg_trainer/run_qwen2-7b_math.sh b/verl/examples/gpg_trainer/run_qwen2-7b_math.sh new file mode 100644 index 0000000000000000000000000000000000000000..1454bf2947bb49d6f61d0e8fe26f375c093d405c --- /dev/null +++ b/verl/examples/gpg_trainer/run_qwen2-7b_math.sh @@ -0,0 +1,52 @@ +set -x + +# If you are using vllm<=0.6.3, you might need to set the following environment variable to avoid bugs: +# export VLLM_ATTENTION_BACKEND=XFORMERS + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gpg \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.actor.policy_loss.loss_mode=gpg \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_gpg_example_gsm8k_math' \ + trainer.experiment_name='qwen2_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/README.md b/verl/examples/grpo_trainer/README.md new file mode 100644 index 0000000000000000000000000000000000000000..28338348b2d5bbabc69fd83b31afdae045a2b29b --- /dev/null +++ b/verl/examples/grpo_trainer/README.md @@ -0,0 +1,69 @@ +# Group Relative Policy Optimization (GRPO) + +In reinforcement learning, classic algorithms like PPO rely on a "critic" model to estimate the value of actions, guiding the learning process. However, training this critic model can be resource-intensive. + +GRPO simplifies this process by eliminating the need for a separate critic model. Instead, it operates as follows: +- Group Sampling: For a given problem, the model generates multiple possible solutions, forming a "group" of outputs. +- Reward Assignment: Each solution is evaluated and assigned a reward based on its correctness or quality. +- Baseline Calculation: The average reward of the group serves as a baseline. +- Policy Update: The model updates its parameters by comparing each solution's reward to the group baseline, reinforcing better-than-average solutions and discouraging worse-than-average ones. + +This approach reduces computational overhead by avoiding the training of a separate value estimation model, making the learning process more efficient. For more details, refer to the original paper [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models](https://arxiv.org/pdf/2402.03300) + +## Key Components + +- No Value Function (Critic-less): unlike PPO, GRPO does not train a separate value network (critic) +- Group Sampling (Grouped Rollouts): instead of evaluating one rollout per input, GRPO generates multiple completions (responses) from the current policy for each prompt. This set of completions is referred to as a group. +- Relative Rewards: within each group, completions are scored (e.g., based on correctness), and rewards are normalized relative to the group. + +## Configuration + +Note that all configs containing `micro_batch_size` are used to configure the maximum sample or token count per forward or backward pass to avoid GPU OOMs, whose value should not change algorithmic/convergence behavior. + +Despite that many configurations start with the `ppo_` prefix, they work across different RL algorithms in verl, as the GRPO training loop is similar to that of PPO (without critic). + +![image](https://github.com/user-attachments/assets/16aebad1-0da6-4eb3-806d-54a74e712c2d) + +- `actor_rollout.ref.rollout.n`: For each prompt, sample n times. Default to 1. For GRPO, please set it to a value larger than 1 for group sampling. + +- `data.train_batch_size`: The global batch size of prompts used to generate a set of sampled trajectories/rollouts. The number of responses/trajectories is `data.train_batch_size * actor_rollout.ref.rollout.n` + +- `actor_rollout_ref.actor.ppo_mini_batch_size`: The set of sampled trajectories is split into multiple mini-batches with batch_size=ppo_mini_batch_size for PPO actor updates. The ppo_mini_batch_size is a global size across all workers. + +- `actor_rollout_ref.actor.ppo_epochs`: Number of epochs for GRPO updates on one set of sampled trajectories for actor + +- `actor_rollout_ref.actor.clip_ratio`: The GRPO clip range. Default to 0.2 + +- `algorithm.adv_estimator`: Default is gae. Please set it to grpo instead + +- `actor_rollout_ref.actor.loss_agg_mode`: Default is "token-mean". Options include "token-mean", "seq-mean-token-sum", "seq-mean-token-mean". The original GRPO paper takes the sample-level loss (seq-mean-token-mean), which may be unstable in long-CoT scenarios. All GRPO example scripts provided in verl uses the default configuration "token-mean" for loss aggregation instead. + +Instead of adding KL penalty in the reward, GRPO regularizes by directly adding the KL divergence between the trained policy and the reference policy to the loss: + +- `actor_rollout_ref.actor.use_kl_loss`: To use kl loss in the actor. When used, we are not applying KL in the reward function. Default is False. Please set it to True for GRPO. + +- `actor_rollout_ref.actor.kl_loss_coef`: The coefficient of kl loss. Default is 0.001. + +- `actor_rollout_ref.actor.kl_loss_type`: Support kl(k1), abs, mse(k2), low_var_kl(k3) and full. Appending "+" in the end (e.g., 'k1+' and 'k3+') would apply straight through to employ k2 for unbiased gradient estimation, regardless of the kl value estimation (see https://github.com/volcengine/verl/pull/2953#issuecomment-3162113848 for more details). How to calculate the kl divergence between actor and reference policy. See this blog post for detailed analysis: http://joschu.net/blog/kl-approx.html + +## Advanced Extensions + +### DrGRPO + +The work [Understanding R1-Zero-Like Training: A Critical Perspective](https://arxiv.org/pdf/2503.20783) claims there's optimization bias in GRPO, that leads to artificially longer responses, especially for incorrect outputs. This inefficiency stems from the way GRPO calculates advantages using group-based reward normalization, which can inadvertently favor longer, less accurate responses. Instead, DrGRPO aggregates token-level losses by normalizing with a global constant to eliminate length bias. + +Configure the following to enable DrGRPO, with all other parameters the same as GRPO's: + +- `actor_rollout_ref.actor.loss_agg_mode`: "seq-mean-token-sum-norm", which turns off seq-dim averaging +- `actor_rollout_ref.actor.use_kl_loss`: Please set it to False for DrGRPO +- `algorithm.norm_adv_by_std_in_grpo`: False, which turns off standard deviation norm + +## Reference Example + +Qwen2.5 GRPO training log and commands: [link](https://github.com/eric-haibin-lin/verl-data/blob/experiments/gsm8k/qwen2-7b-fsdp2.log) + +```bash +bash examples/grpo_trainer/run_qwen3-8b.sh +``` + +For more reference performance, please see https://verl.readthedocs.io/en/latest/algo/baseline.html diff --git a/verl/examples/grpo_trainer/run_deepseek7b_llm.sh b/verl/examples/grpo_trainer/run_deepseek7b_llm.sh new file mode 100644 index 0000000000000000000000000000000000000000..af9204ab1ccc4c6784eab178f849d7a2882a27e5 --- /dev/null +++ b/verl/examples/grpo_trainer/run_deepseek7b_llm.sh @@ -0,0 +1,40 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=80 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=160 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=160 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger=console \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='deepseek_llm_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_deepseek7b_llm_math.sh b/verl/examples/grpo_trainer/run_deepseek7b_llm_math.sh new file mode 100644 index 0000000000000000000000000000000000000000..198e6f4ae71e89fa1559facdabe3e3f8dd7ac4d7 --- /dev/null +++ b/verl/examples/grpo_trainer/run_deepseek7b_llm_math.sh @@ -0,0 +1,49 @@ +set -x + + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=40 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=40 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=40 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k_math' \ + trainer.experiment_name='deepseek_llm_7b_function_rm_math' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_deepseek7b_llm_seq_balance.sh b/verl/examples/grpo_trainer/run_deepseek7b_llm_seq_balance.sh new file mode 100644 index 0000000000000000000000000000000000000000..72cd4445a8edc7a70686cea8b96c7b3066b88f36 --- /dev/null +++ b/verl/examples/grpo_trainer/run_deepseek7b_llm_seq_balance.sh @@ -0,0 +1,39 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='deepseek_llm_7b_function_rm_seq_packing' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_glm41v_9b.sh b/verl/examples/grpo_trainer/run_glm41v_9b.sh new file mode 100644 index 0000000000000000000000000000000000000000..a845bcc244f79ae7301a04c0e010a2586d528166 --- /dev/null +++ b/verl/examples/grpo_trainer/run_glm41v_9b.sh @@ -0,0 +1,46 @@ +set -x +ENGINE=${1:-vllm} + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/geo3k/train.parquet \ + data.val_files=$HOME/data/geo3k/test.parquet \ + data.train_batch_size=512 \ + data.max_prompt_length=1024 \ + data.max_response_length=2048 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.image_key=images \ + actor_rollout_ref.model.path=zai-org/GLM-4.1V-9B-Thinking \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.01 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=$ENGINE \ + +actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.enable_chunked_prefill=False \ + actor_rollout_ref.rollout.enforce_eager=False \ + actor_rollout_ref.rollout.free_cache_engine=True \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_geo3k' \ + trainer.experiment_name='glm41v_9b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_gptoss_20b.sh b/verl/examples/grpo_trainer/run_gptoss_20b.sh new file mode 100644 index 0000000000000000000000000000000000000000..4de21659d8cac021a20dd7ffd4520598d2b6d31c --- /dev/null +++ b/verl/examples/grpo_trainer/run_gptoss_20b.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# install flashinfer +cd $HOME +git clone https://github.com/flashinfer-ai/flashinfer.git --recursive +cd flashinfer +python -m pip install -v . + +# install sglang +cd $HOME +git fetch origin pull/9379/head:fix_weight_loading +cd $HOME/sglang +git checkout fix_weight_loading +pip install --upgrade pip +pip install -e "python[all]" + +pip install peft +pip install transformers -U +pip install https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.3/flash_attn-2.8.3+cu12torch2.8cxx11abiTRUE-cp311-cp311-linux_x86_64.whl +pip install numpy==1.26.4 + + +cat > get_model.py << EOF +import torch +from transformers import AutoModelForCausalLM, AutoTokenizer, Mxfp4Config + +model_id = "openai/gpt-oss-20b" +output_dir = "$HOME/models/gpt-oss-20b-bf16" + +quantization_config = Mxfp4Config(dequantize=True) +model_kwargs = dict( + attn_implementation="eager", + torch_dtype=torch.bfloat16, + quantization_config=quantization_config, + use_cache=False, + device_map="auto", +) + +model = AutoModelForCausalLM.from_pretrained(model_id, **model_kwargs) + +# Patch config with custom attribute before saving +model.config.attn_implementation = "eager" + +model.save_pretrained(output_dir) +tokenizer = AutoTokenizer.from_pretrained(model_id) +tokenizer.save_pretrained(output_dir) +EOF + +python get_model.py + + + +model_dir=$HOME/models/gpt-oss-20b-bf16 +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files="$gsm8k_train_path" \ + data.val_files="$gsm8k_test_path" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=${model_dir} \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + +actor_rollout_ref.actor.fsdp_config.model_dtype=bfloat16 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=sglang \ + actor_rollout_ref.rollout.engine_kwargs.sglang.attention_backend=triton \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.rollout.load_format=safetensors \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k_math' \ + trainer.experiment_name='oai_oss_20b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=50 \ + trainer.test_freq=10 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_minicpmo2_6.sh b/verl/examples/grpo_trainer/run_minicpmo2_6.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1daab99a9fb16e6698ad8a7a22d7ea64e091281 --- /dev/null +++ b/verl/examples/grpo_trainer/run_minicpmo2_6.sh @@ -0,0 +1,49 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/geo3k/train.parquet \ + data.val_files=$HOME/data/geo3k/test.parquet \ + data.train_batch_size=128 \ + data.max_prompt_length=1024 \ + data.max_response_length=2048 \ + data.filter_overlong_prompts=False \ + data.truncation='error' \ + data.image_key=images \ + data.trust_remote_code=True \ + data.custom_cls.path=recipe/minicpmo/rl_dataset.py \ + data.custom_cls.name=RLHFDataset \ + actor_rollout_ref.model.path=openbmb/MiniCPM-o-2_6 \ + actor_rollout_ref.model.trust_remote_code=True \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=32 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.use_dynamic_bsz=False \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.fsdp_config.use_orig_params=True \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.enable_chunked_prefill=False \ + actor_rollout_ref.rollout.enforce_eager=False \ + actor_rollout_ref.rollout.free_cache_engine=False \ + actor_rollout_ref.rollout.n=8 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.kl_ctrl.kl_coef=0.001 \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_geo3k' \ + trainer.experiment_name='minicpmo2_6_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2-7b.sh b/verl/examples/grpo_trainer/run_qwen2-7b.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba3c64a6ad5202e5ac7734e94dbeaba7a8ae2aff --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2-7b.sh @@ -0,0 +1,41 @@ +set -x + + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=40 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=40 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=40 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen2_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2-7b_math.sh b/verl/examples/grpo_trainer/run_qwen2-7b_math.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4e6ec408ff3518ee1a41240a9ea1bb2e92e5179 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2-7b_math.sh @@ -0,0 +1,49 @@ +set -x + + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k_math' \ + trainer.experiment_name='qwen2_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2-7b_math_megatron.sh b/verl/examples/grpo_trainer/run_qwen2-7b_math_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..2a29ccd077a423d7ba71023de1c47a5b6956fbae --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2-7b_math_megatron.sh @@ -0,0 +1,61 @@ +set -x + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +rollout_mode="sync" +if [ "$rollout_mode" = "async" ]; then + export VLLM_USE_V1=1 + return_raw_chat="True" +fi + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +USE_FUSED_KERNELS=True + +python3 -m verl.trainer.main_ppo --config-path=config \ + --config-name='ppo_megatron_trainer.yaml'\ + algorithm.adv_estimator=grpo \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.return_raw_chat=$return_raw_chat \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.model.use_fused_kernels=$USE_FUSED_KERNELS \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.mode=$rollout_mode \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k_math' \ + trainer.experiment_name='qwen2_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2-7b_seq_balance.sh b/verl/examples/grpo_trainer/run_qwen2-7b_seq_balance.sh new file mode 100644 index 0000000000000000000000000000000000000000..fdc1ef606d7ee1a96fa14da2940afa3366b36029 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2-7b_seq_balance.sh @@ -0,0 +1,52 @@ +set -x + + +# For async rollout mode, dataset should return raw chat. +rollout_mode="async" +rollout_name="sglang" # sglang or vllm +if [ "$rollout_mode" = "async" ]; then + export VLLM_USE_V1=1 + return_raw_chat="True" +fi + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.return_raw_chat=$return_raw_chat \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=$rollout_name \ + actor_rollout_ref.rollout.mode=$rollout_mode \ + actor_rollout_ref.rollout.multi_turn.format=hermes \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen2_7b_function_rm_kl1e-3' \ + trainer.val_before_train=False \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2-7b_seq_balance_math_megatron.sh b/verl/examples/grpo_trainer/run_qwen2-7b_seq_balance_math_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbcb83ffb8aa160b6f89e1ead725248fb951ed0f --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2-7b_seq_balance_math_megatron.sh @@ -0,0 +1,57 @@ +set -x + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +offload=True + +python3 -m verl.trainer.main_ppo --config-path=config \ + --config-name='ppo_megatron_trainer.yaml'\ + algorithm.adv_estimator=grpo \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=12000 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.actor.megatron.param_offload=${offload} \ + actor_rollout_ref.actor.megatron.optimizer_offload=${offload} \ + actor_rollout_ref.actor.megatron.grad_offload=${offload} \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.param_offload=${offload} \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k_math' \ + trainer.experiment_name='qwen2_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2-7b_sgl_megatron.sh b/verl/examples/grpo_trainer/run_qwen2-7b_sgl_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..5dc4ec87fa75512d24f76e2875b60efc3ffb9090 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2-7b_sgl_megatron.sh @@ -0,0 +1,47 @@ +set -x + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo --config-path=config \ + --config-name='ppo_megatron_trainer.yaml'\ + algorithm.adv_estimator=grpo \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.virtual_pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=4 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=sglang \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen2_7b_function_rm_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_qwen2_5-7b_math_megatron_diff_tp.sh b/verl/examples/grpo_trainer/run_qwen2_5-7b_math_megatron_diff_tp.sh new file mode 100644 index 0000000000000000000000000000000000000000..e7053d1dd73f8eb7b0f1410408a37ec18cb198e8 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2_5-7b_math_megatron_diff_tp.sh @@ -0,0 +1,50 @@ +set -x + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo --config-path=config \ + --config-name='ppo_megatron_trainer.yaml'\ + algorithm.adv_estimator=grpo \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k_math' \ + trainer.experiment_name='qwen2_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2_5_7b_grpo_discrete_prof_npu.sh b/verl/examples/grpo_trainer/run_qwen2_5_7b_grpo_discrete_prof_npu.sh new file mode 100644 index 0000000000000000000000000000000000000000..27ab478da2868b249c7d146d6895340b86647bf0 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2_5_7b_grpo_discrete_prof_npu.sh @@ -0,0 +1,72 @@ +set -x + +# profiling configuration +PROFILE_STEPS="[2,4]" +PROFILE_RANKS_ALL=False +DISCRETE=True +PROFILE_RANKS="[1,2]" + +# profiling NPU options +SAVE_PATH="$HOME/profile_data" +LEVEL="level1" +CONTENTS=['npu','cpu'] +ANALYSIS=True + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=32 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-7B-Instruct \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.model.use_remove_padding=False \ + actor_rollout_ref.actor.optim.lr=5e-8 \ + actor_rollout_ref.actor.ppo_mini_batch_size=2 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.profiler.enable=True \ + actor_rollout_ref.actor.profiler.ranks=$PROFILE_RANKS \ + actor_rollout_ref.actor.profiler.all_ranks=$PROFILE_RANKS_ALL \ + actor_rollout_ref.actor.profiler.tool_config.npu.discrete=$DISCRETE \ + actor_rollout_ref.actor.profiler.tool_config.npu.contents=$CONTENTS \ + actor_rollout_ref.actor.profiler.tool_config.npu.level=$LEVEL \ + actor_rollout_ref.actor.profiler.tool_config.npu.analysis=$ANALYSIS \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.3 \ + actor_rollout_ref.rollout.n=4 \ + actor_rollout_ref.rollout.enable_chunked_prefill=False \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + actor_rollout_ref.ref.profiler.enable=True \ + actor_rollout_ref.ref.profiler.ranks=$PROFILE_RANKS \ + actor_rollout_ref.ref.profiler.all_ranks=$PROFILE_RANKS_ALL \ + actor_rollout_ref.ref.profiler.tool_config.npu.discrete=$DISCRETE \ + actor_rollout_ref.ref.profiler.tool_config.npu.contents=$CONTENTS \ + actor_rollout_ref.ref.profiler.tool_config.npu.level=$LEVEL \ + actor_rollout_ref.ref.profiler.tool_config.npu.analysis=$ANALYSIS \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger=console \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen2_5_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=5 \ + trainer.device=npu \ + global_profiler.tool=npu \ + global_profiler.steps=$PROFILE_STEPS \ + global_profiler.save_path=$SAVE_PATH + $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_qwen2_5_7b_grpo_e2e_prof_npu.sh b/verl/examples/grpo_trainer/run_qwen2_5_7b_grpo_e2e_prof_npu.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ac6dfe94452b6d9235de672ca7afbb6805ad0d5 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2_5_7b_grpo_e2e_prof_npu.sh @@ -0,0 +1,69 @@ +set -x + +# profiling configuration +PROFILE_STEPS="[2,4]" +PROFILE_RANKS_ALL=True +DISCRETE=False + +# profiling NPU options +SAVE_PATH="$HOME/profile_data" +LEVEL="level1" +CONTENTS=['npu','cpu'] +ANALYSIS=True + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=32 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=5e-8 \ + actor_rollout_ref.model.use_remove_padding=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=2 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=1 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.profiler.enable=True \ + actor_rollout_ref.actor.profiler.all_ranks=$PROFILE_RANKS_ALL \ + actor_rollout_ref.actor.profiler.tool_config.npu.discrete=$DISCRETE \ + actor_rollout_ref.actor.profiler.tool_config.npu.contents=$CONTENTS \ + actor_rollout_ref.actor.profiler.tool_config.npu.level=$LEVEL \ + actor_rollout_ref.actor.profiler.tool_config.npu.analysis=$ANALYSIS \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.3 \ + actor_rollout_ref.rollout.n=4 \ + actor_rollout_ref.rollout.enable_chunked_prefill=False \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + actor_rollout_ref.ref.profiler.enable=True \ + actor_rollout_ref.ref.profiler.all_ranks=$PROFILE_RANKS_ALL \ + actor_rollout_ref.ref.profiler.tool_config.npu.discrete=$DISCRETE \ + actor_rollout_ref.ref.profiler.tool_config.npu.contents=$CONTENTS \ + actor_rollout_ref.ref.profiler.tool_config.npu.level=$LEVEL \ + actor_rollout_ref.ref.profiler.tool_config.npu.analysis=$ANALYSIS \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger=console \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen2_5_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=5 \ + trainer.device=npu \ + global_profiler.tool=npu \ + global_profiler.steps=$PROFILE_STEPS \ + global_profiler.save_path=$SAVE_PATH + $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_qwen2_5_vl-7b-megatron.sh b/verl/examples/grpo_trainer/run_qwen2_5_vl-7b-megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..632bdc8fa1e097092416338a81426fcb661d8946 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2_5_vl-7b-megatron.sh @@ -0,0 +1,88 @@ +set -x +ENGINE=${1:-vllm} +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +HF_MODEL_PATH=Qwen/Qwen2.5-VL-7B-Instruct +DIST_CKPT_PATH=${DIST_CKPT_PATH} + +# convert HF model to meagatron format offlinely +# python scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH + + +# megatron tuning guide: +# 1. recommend to offload all states by setting ALL_OFFLOAD=True +# 2. enable dynamic batch size by setting actor_rollout_ref.actor.use_dynamic_bsz=True ref.log_prob_use_dynamic_bsz=True rollout.log_prob_use_dynamic_bsz=True +# 3. set ppo_max_token_len_per_gpu and log_prob_max_token_len_per_gpu as large as possible for better MFU (limited by GPU memory). assure ppo_max_token_len_per_gpu > max_prompt_length+max_response_length, if sequence length is too long, you can increase the TP/PP size +# 4. if memory is very limited, enable full recompute, but the mfu will be 30% lower +# full recompute settings: +# +actor_rollout_ref.actor.megatron.override_transformer_config.recompute_method=uniform \ +# +actor_rollout_ref.actor.megatron.override_transformer_config.recompute_granularity=full \ +# +actor_rollout_ref.actor.megatron.override_transformer_config.recompute_num_layers=1 \ + +ALL_OFFLOAD=${ALL_OFFLOAD:-True} +COMMON_PARAM_OFFLOAD=${COMMON_PARAM_OFFLOAD:-$ALL_OFFLOAD} +COMMON_GRAD_OFFLOAD=${COMMON_GRAD_OFFLOAD:-$ALL_OFFLOAD} +COMMON_OPTIMIZER_OFFLOAD=${COMMON_OPTIMIZER_OFFLOAD:-$ALL_OFFLOAD} + +ACTOR_PARAM_OFFLOAD=${ACTOR_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} +ACTOR_GRAD_OFFLOAD=${ACTOR_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD} +ACTOR_OPTIMIZER_OFFLOAD=${ACTOR_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD} +REF_PARAM_OFFLOAD=${REF_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} + + +train_path=$HOME/data/geo3k/train.parquet +test_path=$HOME/data/geo3k/test.parquet + +python3 -m verl.trainer.main_ppo --config-path=config \ + --config-name='ppo_megatron_trainer.yaml'\ + algorithm.adv_estimator=grpo \ + data.train_files="$train_path" \ + data.val_files="$test_path" \ + data.train_batch_size=512 \ + data.max_prompt_length=1024 \ + data.max_response_length=2048 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=$HF_MODEL_PATH \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=1 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.01 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=1 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=5120 \ + actor_rollout_ref.ref.log_prob_use_dynamic_bsz=True \ + actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=20480 \ + actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True \ + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=20480 \ + actor_rollout_ref.rollout.name=$ENGINE \ + +actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=1 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.use_dist_checkpointing=True \ + actor_rollout_ref.ref.megatron.use_dist_checkpointing=True \ + actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + actor_rollout_ref.actor.megatron.param_offload=${ACTOR_PARAM_OFFLOAD} \ + actor_rollout_ref.actor.megatron.optimizer_offload=${ACTOR_OPTIMIZER_OFFLOAD} \ + actor_rollout_ref.actor.megatron.grad_offload=${ACTOR_GRAD_OFFLOAD} \ + actor_rollout_ref.ref.megatron.param_offload=${REF_PARAM_OFFLOAD} \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_geo3k' \ + trainer.experiment_name='qwen2_5_vl_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_qwen2_5_vl-7b.sh b/verl/examples/grpo_trainer/run_qwen2_5_vl-7b.sh new file mode 100644 index 0000000000000000000000000000000000000000..b64ec094118bfece1ee081326f82bd0813b835c6 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2_5_vl-7b.sh @@ -0,0 +1,47 @@ +set -x +ENGINE=${1:-vllm} + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/geo3k/train.parquet \ + data.val_files=$HOME/data/geo3k/test.parquet \ + data.train_batch_size=512 \ + data.max_prompt_length=1024 \ + data.max_response_length=2048 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.image_key=images \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.use_fused_kernels=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.01 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=$ENGINE \ + +actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.enable_chunked_prefill=False \ + actor_rollout_ref.rollout.enforce_eager=False \ + actor_rollout_ref.rollout.free_cache_engine=True \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_geo3k' \ + trainer.experiment_name='qwen2_5_vl_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen2_5_vl-7b_freeze_vision.sh b/verl/examples/grpo_trainer/run_qwen2_5_vl-7b_freeze_vision.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f51d568744e0a7bb240b0ae2eaa6bf703493110 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen2_5_vl-7b_freeze_vision.sh @@ -0,0 +1,47 @@ +set -x +ENGINE=${1:-vllm} + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/geo3k/train.parquet \ + data.val_files=$HOME/data/geo3k/test.parquet \ + data.train_batch_size=512 \ + data.max_prompt_length=1024 \ + data.max_response_length=2048 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.image_key=images \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-VL-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.freeze_vision_tower=True \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.01 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=$ENGINE \ + +actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.enable_chunked_prefill=False \ + actor_rollout_ref.rollout.enforce_eager=False \ + actor_rollout_ref.rollout.free_cache_engine=True \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_geo3k' \ + trainer.experiment_name='qwen2_5_vl_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/grpo_trainer/run_qwen3-32b_npu.sh b/verl/examples/grpo_trainer/run_qwen3-32b_npu.sh new file mode 100644 index 0000000000000000000000000000000000000000..0ee01c43d1aa4529584569185403d9ad26c49277 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen3-32b_npu.sh @@ -0,0 +1,59 @@ +set -x + +project_name='GRPO-Qwen3' +exp_name='GRPO-Qwen3-32b-npu' +gen_tp=4 +RAY_DATA_HOME=${RAY_DATA_HOME:-"${HOME}/verl"} +MODEL_PATH=${MODEL_PATH:-"${RAY_DATA_HOME}/models/Qwen3-32B"} +TRAIN_FILE=${TRAIN_FILE:-"${RAY_DATA_HOME}/data/gsm8k/train.parquet"} +TEST_FILE=${TEST_FILE:-"${RAY_DATA_HOME}/data/gsm8k/test.parquet"} + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files="${TRAIN_FILE}" \ + data.val_files="${TEST_FILE}" \ + data.train_batch_size=1024 \ + data.max_prompt_length=2048 \ + data.max_response_length=2048 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.shuffle=False \ + actor_rollout_ref.model.path=${MODEL_PATH} \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ulysses_sequence_parallel_size=4 \ + +actor_rollout_ref.actor.fsdp_config.mixed_precision.param_dtype=bf16 \ + +actor_rollout_ref.actor.fsdp_config.mixed_precision.reduce_dtype=bf16 \ + +actor_rollout_ref.actor.fsdp_config.mixed_precision.buffer_dtype=fp32 \ + actor_rollout_ref.actor.ppo_mini_batch_size=64 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=8 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=True \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=${gen_tp} \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \ + actor_rollout_ref.rollout.n=4 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + actor_rollout_ref.actor.use_torch_compile=False \ + actor_rollout_ref.ref.use_torch_compile=False \ + actor_rollout_ref.rollout.enable_chunked_prefill=True \ + actor_rollout_ref.rollout.max_num_batched_tokens=32768 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger=['console','tensorboard'] \ + trainer.project_name="${project_name}" \ + trainer.experiment_name="${exp_name}" \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=4 \ + trainer.resume_from_path=checkpoints/ \ + trainer.save_freq=500 \ + trainer.test_freq=50 \ + trainer.total_epochs=50 \ + trainer.device=npu $@ \ No newline at end of file diff --git a/verl/examples/grpo_trainer/run_qwen3-8b.sh b/verl/examples/grpo_trainer/run_qwen3-8b.sh new file mode 100644 index 0000000000000000000000000000000000000000..a99b432d6abe46a7c62f69e47398ef99b10aa5c2 --- /dev/null +++ b/verl/examples/grpo_trainer/run_qwen3-8b.sh @@ -0,0 +1,43 @@ +# Tested successfully on the hiyouga/verl:ngc-th2.6.0-cu126-vllm0.8.4-flashinfer0.2.2-cxx11abi0 image. +# It outperforms the Qwen2 7B base model by two percentage points on the test set of GSM8K. + +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=grpo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen3-8B \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen3_8b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ \ No newline at end of file diff --git a/verl/examples/ppo_trainer/README.md b/verl/examples/ppo_trainer/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7b7261c5dd1a372f9883eeae7c540bec096d09b4 --- /dev/null +++ b/verl/examples/ppo_trainer/README.md @@ -0,0 +1,103 @@ +# Proximal Policy Optimization (PPO) + +Proximal Policy Optimization (PPO) is a family of policy gradient methods for reinforcement learning, proposed by OpenAI in 2017. PPO strikes a balance between simplicity, stability, and performance, making it one of the most widely used algorithms in modern RL applications, including large-scale language model fine-tuning. + +Traditional policy gradient methods like REINFORCE or Vanilla Policy Gradient suffer from: + +- High variance and sample inefficiency. +- Instability due to large policy updates. + +PPO addresses this problem using a clipped surrogate objective that avoids overly large updates without requiring second-order derivatives. + +For more technical details regarding PPO, we suggest reading the introduction in the [OpenAI spinning up tutorial](https://spinningup.openai.com/en/latest/algorithms/ppo.html), and the paper [Proximal Policy Optimization Algorithms](https://arxiv.org/abs/1707.06347). + +## Key Components + +- Actor-Critic Architecture: PPO requires both an actor model (policy) and a critic model (value function). This differs from other algorithms like GRPO and RLOO that don't require a critic model. + +- Generalized Advantage Estimation (GAE): PPO uses GAE for computing advantage values, which helps reduce variance in policy gradient estimates while maintaining low bias. + +- Clipped Surrogate Objective: The core of PPO is implemented through the clipped surrogate objective function that limits policy updates. + +## Configuration + +Note that all configs containing `micro_batch_size` are used to configure the maximum sample or token count per forward or backward pass to avoid GPU OOMs, whose value should not change algorithmic/convergence behavior. + +Most critic configs are similar to those of actors. Note that the critic model is omitted from the figure below. + +![image](https://github.com/user-attachments/assets/16aebad1-0da6-4eb3-806d-54a74e712c2d) + +- `data.train_batch_size`: The global batch size of prompts used to generate a set of sampled trajectories/rollouts. The number of responses/trajectories is `data.train_batch_size * actor_rollout.ref.rollout.n` + +- `actor_rollout_ref.actor.ppo_mini_batch_size`: The set of sampled trajectories is split into multiple mini-batches with batch_size=ppo_mini_batch_size for PPO actor updates. The ppo_mini_batch_size is a global size across all workers + +- `actor_rollout_ref.critic.ppo_mini_batch_size`: The set of sampled trajectories is split into multiple mini-batches with batch_size=ppo_mini_batch_size for PPO critic updates. The ppo_mini_batch_size is a global size across all workers + +- `actor_rollout_ref.actor.clip_ratio`: The PPO clip range. Default to 0.2 + +- `actor_rollout_ref.actor.ppo_epochs`: Number of epochs for PPO updates on one set of sampled trajectories for actor + +- `critic.ppo_epochs`: Number of epochs for PPO updates on one set of sampled trajectories for critic. Defaults to `actor_rollout_ref.actor.ppo_epochs` + +- `algorithm.gamma`: discount factor + +- `algorithm.lam`: The lambda term that trades off between bias and variance in the GAE estimator + +- `algorithm.adv_estimator`: Support gae, grpo, reinforce_plus_plus, reinforce_plus_plus_baseline, rloo, rloo_vectorized + +## Advanced Extensions + +### KL Divergence Control + +Options to prevent the policy from diverging too far from a reference policy. Two mechanisms are available: KL reward penalty and KL loss. For more technical details, see [Training language models to follow instructions with human feedback](https://arxiv.org/abs/2203.02155) + +Options to use KL loss for KL divergence control: + +- `actor_rollout_ref.actor.use_kl_loss`: to use kl loss in the actor. When used, we are not applying KL in the reward function. Default is False + +- `actor_rollout_ref.actor.kl_loss_coef`: The coefficient of kl loss. Default is 0.001. + +- `actor_rollout_ref.actor.kl_loss_type`: Support kl(k1), abs, mse(k2), low_var_kl(k3) and full. Appending "+" in the end (e.g., 'k1+' and 'k3+') would apply straight through to employ k2 for unbiased gradient estimation, regardless of the kl value estimation (see https://github.com/volcengine/verl/pull/2953#issuecomment-3162113848 for more details). How to calculate the kl divergence between actor and reference policy. See this blog post for detailed analysis: http://joschu.net/blog/kl-approx.html + +Options to use KL penalty in the reward: + +- `algorithm.use_kl_in_reward`: Whether to enable in-reward kl penalty. Default is False. + +- `algorithm.kl_penalty`: Support kl(k1), abs, mse(k2), low_var_kl(k3) and full. This defines the way to calculate the kl divergence between actor and reference policy. For specific options, refer to `kl_penalty` in core_algos.py. See this blog post for detailed analysis: http://joschu.net/blog/kl-approx.html + +- `algorithm.kl_ctrl.kl_coef`: The (initial) coefficient of in-reward kl_penalty. Default is 0.001. +- `algorithm.kl_ctrl.type`: 'fixed' for FixedKLController and 'adaptive' for AdaptiveKLController. +- `algorithm.kl_ctrl.horizon`: See source code of AdaptiveKLController for details. +- `algorithm.kl_ctrl.target_kl`: See source code of AdaptiveKLController for details. + +### Dual-clip PPO + +The Dual-Clip PPO introduces a approach by applying a lower bound to the policy ratio when the advantage is less than zero, when multiplied by a large raito, does not exceed a specified lower bound. + +![image](https://github.com/user-attachments/assets/fc232181-d8b0-4307-8dd2-4dc0a4c1c139) + +- `actor_rollout_ref.actor.clip_ratio_c`: lower bound of the value for Dual-clip PPO, defaults to 3.0 + +## Reference Example + +Qwen2.5 training log and commands: [link](https://github.com/eric-haibin-lin/verl-data/blob/experiments/gsm8k/Qwen2.5-0.5B-bsz256_2-prompt1024-resp512-0.567.log) + +```bash +bash run_gemma.sh + trainer.n_gpus_per_node=1 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=1 \ + trainer.logger=console \ + critic.model.path=Qwen/Qwen2.5-0.5B-Instruct \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-0.5B-Instruct \ + data.train_batch_size=256 \ + actor_rollout_ref.actor.ppo_mini_batch_size=64 \ + actor_rollout_ref.actor.ppo_micro_batch_size=2 \ + critic.ppo_micro_batch_size=2 +``` + +Reference performance with verl v0.2: + +| Model | Method | Score | Link | +|-------------------------------|------------------|-------|------------------------------------------------------------------------------------------------| +| Qwen/Qwen2.5-0.5B-Instruct | pretrained model | 36.4 | [Qwen Blog](https://qwenlm.github.io/blog/qwen2.5-llm/) | +| Qwen/Qwen2.5-0.5B-Instruct | PPO | 56.7 | [PPO Command and Logs](https://github.com/eric-haibin-lin/verl-data/blob/experiments/gsm8k/Qwen2.5-0.5B-bsz256_2-prompt1024-resp512-0.567.log) | diff --git a/verl/examples/ppo_trainer/run_deepseek7b_llm.sh b/verl/examples/ppo_trainer/run_deepseek7b_llm.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a93a75b4035cd21caa8c8b123ec1397b649de62 --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek7b_llm.sh @@ -0,0 +1,42 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=32 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='deepseek_llm_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=1 \ + trainer.use_legacy_worker_impl=auto \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek7b_llm_modelscope.sh b/verl/examples/ppo_trainer/run_deepseek7b_llm_modelscope.sh new file mode 100644 index 0000000000000000000000000000000000000000..eb6dc79234a14152eb8583e58096e4d4fd8f0d04 --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek7b_llm_modelscope.sh @@ -0,0 +1,42 @@ +set -x + +VERL_USE_MODELSCOPE=True \ +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=32 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='deepseek_llm_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=1 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek7b_llm_pfppo.sh b/verl/examples/ppo_trainer/run_deepseek7b_llm_pfppo.sh new file mode 100644 index 0000000000000000000000000000000000000000..312c6b50b78272e1b0af06fa1b49fcf88f00639b --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek7b_llm_pfppo.sh @@ -0,0 +1,45 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + algorithm.use_pf_ppo=True \ + algorithm.pf_ppo.reweight_method=pow \ # ["pow", "max_min", "max_random"] + algorithm.pf_ppo.weight_pow=2.0 \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + actor_rollout_ref.rollout.n=5 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=32 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='deepseek_llm_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=1 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek7b_llm_sandbox_fusion.sh b/verl/examples/ppo_trainer/run_deepseek7b_llm_sandbox_fusion.sh new file mode 100644 index 0000000000000000000000000000000000000000..69ee7b8bd76518dcb19aaca7d798d4a99a77e784 --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek7b_llm_sandbox_fusion.sh @@ -0,0 +1,44 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + reward_model.sandbox_fusion.url='https://xxxxxxxxx.apigateway-cn-beijing.volceapi.com/run_code' \ + reward_model.sandbox_fusion.max_concurrent=128 \ + reward_model.reward_manager=prime \ + algorithm.adv_estimator=gae \ + data.train_files=$HOME/data/Eurus-2-RL-Data/train.parquet \ + data.val_files=$HOME/data/Eurus-2-RL-Data/validation.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=32 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_sandbox_fusion' \ + trainer.experiment_name='deepseek_llm_7b_function_sandbox_fusion' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=1 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek7b_llm_sp2.sh b/verl/examples/ppo_trainer/run_deepseek7b_llm_sp2.sh new file mode 100644 index 0000000000000000000000000000000000000000..3cb8a852b5ffd3eea40781b421157d699434408b --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek7b_llm_sp2.sh @@ -0,0 +1,43 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.actor.ulysses_sequence_parallel_size=2 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=64 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + critic.optim.lr=1e-5 \ + critic.ulysses_sequence_parallel_size=2 \ + critic.model.use_remove_padding=True \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=64 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='deepseek_llm_7b_function_rm_sp2' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek_full_hh_rlhf.sh b/verl/examples/ppo_trainer/run_deepseek_full_hh_rlhf.sh new file mode 100644 index 0000000000000000000000000000000000000000..2944de647c47e2ce6d74d0da09cb613ffabfbf6c --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek_full_hh_rlhf.sh @@ -0,0 +1,41 @@ +set -x + +train_files=$HOME/data/full_hh_rlhf/rl/train.parquet +test_files=$HOME/data/full_hh_rlhf/rl/train.parquet # no use + +python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=512 \ + data.max_prompt_length=128 \ + data.max_response_length=128 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + critic.optim.lr=1e-5 \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.ppo_micro_batch_size_per_gpu=4 \ + reward_model.enable=True \ + reward_model.megatron.tensor_model_parallel_size=4 \ + reward_model.model.path=deepseek-ai/deepseek-llm-7b-chat \ + reward_model.micro_batch_size_per_gpu=4 \ + reward_model.param_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_megatron_full_hh_rlhf_examples' \ + trainer.experiment_name='deepseek_llm_7b_model_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=100 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron.sh b/verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..a128aabf30abb87553b31e217c09d8f4166acb43 --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron.sh @@ -0,0 +1,49 @@ +set -x + +# Example runnable on H20 * 8 + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + critic.optim.lr=1e-5 \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.ppo_micro_batch_size_per_gpu=4 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_ppo_gsm8k_math_examples' \ + trainer.experiment_name='deepseek_llm_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=100 $@ diff --git a/verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron_nsys.sh b/verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron_nsys.sh new file mode 100644 index 0000000000000000000000000000000000000000..e467c3a5c3f97dad99e2345870239e99970f8a70 --- /dev/null +++ b/verl/examples/ppo_trainer/run_deepseek_math_gsm8k_megatron_nsys.sh @@ -0,0 +1,65 @@ +set -x + +# Example runnable on H20 * 8 + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files=${train_files:-"$gsm8k_train_path"} +test_files=${test_files:-"$gsm8k_test_path"} + +# Nsight profiling configuration +PROFILE_STEPS="[1]" # or [] or null +PROFILE_RANKS_ALL=False # or True +PROFILE_RANKS=[0,4] +DISCRETE=True # or True + +python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=256 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=deepseek-ai/deepseek-llm-7b-chat \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=64 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.actor.profiler.enable=True \ + actor_rollout_ref.actor.profiler.ranks=$PROFILE_RANKS \ + actor_rollout_ref.actor.profiler.all_ranks=$PROFILE_RANKS_ALL \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + critic.optim.lr=1e-5 \ + critic.model.path=deepseek-ai/deepseek-llm-7b-chat \ + critic.ppo_micro_batch_size_per_gpu=4 \ + critic.profiler.enable=True \ + critic.profiler.ranks=$PROFILE_RANKS \ + critic.profiler.all_ranks=$PROFILE_RANKS_ALL \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_ppo_gsm8k_math_examples' \ + trainer.experiment_name='deepseek_llm_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=-1 \ + trainer.total_epochs=100 \ + trainer.total_training_steps=1 \ + global_profiler.tool=nsys \ + global_profiler.steps=$PROFILE_STEPS \ + global_profiler.global_tool_config.nsys.discrete=$DISCRETE $@ diff --git a/verl/examples/ppo_trainer/run_gemma.sh b/verl/examples/ppo_trainer/run_gemma.sh new file mode 100644 index 0000000000000000000000000000000000000000..b015275c13496ae2514db6c756114d76897c7f71 --- /dev/null +++ b/verl/examples/ppo_trainer/run_gemma.sh @@ -0,0 +1,40 @@ +set -x + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=512 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=google/gemma-2-2b-it \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=False \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=False \ + critic.model.path=google/gemma-2-2b-it \ + critic.model.enable_gradient_checkpointing=False \ + critic.ppo_micro_batch_size_per_gpu=4 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example' \ + trainer.experiment_name='gemma2b_function_rm' \ + trainer.n_gpus_per_node=2 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=10 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_moonlight16b_a3b_gsm8k_megatron.sh b/verl/examples/ppo_trainer/run_moonlight16b_a3b_gsm8k_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e1d40576f0a4b8fb97cb5e23260c5c3020c902b --- /dev/null +++ b/verl/examples/ppo_trainer/run_moonlight16b_a3b_gsm8k_megatron.sh @@ -0,0 +1,106 @@ +set -x + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + + +# 0. download the model +huggingface-cli download moonshotai/Moonlight-16B-A3B-Instruct + +# 1. convert the model to mcore format +# change the HF_MODEL_PATH and DIST_CKPT_PATH to your own path +HF_MODEL_PATH=/data/models/moonshotai/Moonlight-16B-A3B-Instruct +DIST_CKPT_PATH=/data/mcore_ckpt/Moonlight-16B-A3B-Instruct +python scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH + + +# 2. run the script +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +train_files=$gsm8k_train_path +test_files=$gsm8k_test_path + +ALL_OFFLOAD=${ALL_OFFLOAD:-False} +COMMON_PARAM_OFFLOAD=${COMMON_PARAM_OFFLOAD:-$ALL_OFFLOAD} +COMMON_GRAD_OFFLOAD=${COMMON_GRAD_OFFLOAD:-$ALL_OFFLOAD} +COMMON_OPTIMIZER_OFFLOAD=${COMMON_OPTIMIZER_OFFLOAD:-$ALL_OFFLOAD} + +ACTOR_PARAM_OFFLOAD=${ACTOR_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} +ACTOR_GRAD_OFFLOAD=${ACTOR_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD} +ACTOR_OPTIMIZER_OFFLOAD=${ACTOR_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD} +REF_PARAM_OFFLOAD=${REF_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} +CRITIC_PARAM_OFFLOAD=${CRITIC_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} +CRITIC_GRAD_OFFLOAD=${CRITIC_GRAD_OFFLOAD:-$COMMON_GRAD_OFFLOAD} +CRITIC_OPTIMIZER_OFFLOAD=${CRITIC_OPTIMIZER_OFFLOAD:-$COMMON_OPTIMIZER_OFFLOAD} +RM_PARAM_OFFLOAD=${RM_PARAM_OFFLOAD:-$COMMON_PARAM_OFFLOAD} + + +NODES=4 +PP=2 +TP=8 +EP=8 +ETP=1 +VLLM_TP=4 + +# RAY_ADDRESS='auto' ray job submit --working-dir . -- +python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.trust_remote_code=True \ + actor_rollout_ref.model.path=$LLM \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \ + critic.optim.lr=1e-5 \ + critic.model.path=$LLM \ + critic.ppo_micro_batch_size_per_gpu=4 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_megatron_gsm8k_examples' \ + trainer.experiment_name='moonlight_16b_a3b_instruct_1node' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=$NODES \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + actor_rollout_ref.model.trust_remote_code=True \ + critic.model.trust_remote_code=True \ + +actor_rollout_ref.actor.megatron.override_transformer_config.num_layers_in_last_pipeline_stage=13 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=$VLLM_TP \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=$PP \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=$PP \ + critic.megatron.pipeline_model_parallel_size=$PP \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=$TP \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=$TP \ + critic.megatron.tensor_model_parallel_size=$TP \ + actor_rollout_ref.actor.megatron.expert_model_parallel_size=$EP \ + actor_rollout_ref.ref.megatron.expert_model_parallel_size=$EP \ + critic.megatron.expert_model_parallel_size=$EP \ + actor_rollout_ref.actor.megatron.expert_tensor_parallel_size=$ETP \ + actor_rollout_ref.ref.megatron.expert_tensor_parallel_size=$ETP \ + critic.megatron.expert_tensor_parallel_size=$ETP \ + actor_rollout_ref.actor.megatron.param_offload=${ACTOR_PARAM_OFFLOAD} \ + actor_rollout_ref.actor.megatron.optimizer_offload=${ACTOR_OPTIMIZER_OFFLOAD} \ + actor_rollout_ref.actor.megatron.grad_offload=${ACTOR_GRAD_OFFLOAD} \ + actor_rollout_ref.ref.megatron.param_offload=${REF_PARAM_OFFLOAD} \ + critic.megatron.param_offload=${CRITIC_PARAM_OFFLOAD} \ + critic.megatron.optimizer_offload=${CRITIC_OPTIMIZER_OFFLOAD} \ + critic.megatron.grad_offload=${CRITIC_GRAD_OFFLOAD} \ + actor_rollout_ref.actor.megatron.use_dist_checkpointing=True \ + actor_rollout_ref.ref.megatron.use_dist_checkpointing=True \ + critic.megatron.use_dist_checkpointing=True \ + actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + critic.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + trainer.val_before_train=False \ + trainer.total_epochs=100 $@ + \ No newline at end of file diff --git a/verl/examples/ppo_trainer/run_qwen1.5_moe_a2.7b-gsm8k_megatron.sh b/verl/examples/ppo_trainer/run_qwen1.5_moe_a2.7b-gsm8k_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..b82ea1d4373d33df10e604d92392f6b16780f3db --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen1.5_moe_a2.7b-gsm8k_megatron.sh @@ -0,0 +1,73 @@ +set -x + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +# 0. download the model +#huggingface-cli download Qwen/Qwen1.5-MoE-A2.7B-Chat + +# 1. convert the model to mcore format +# change the HF_MODEL_PATH and DIST_CKPT_PATH to your own path +HF_MODEL_PATH=/data/models/Qwen/Qwen1.5-MoE-A2.7B-Chat +DIST_CKPT_PATH=/data/mcore_ckpt/Qwen1.5-MoE-A2.7B-Chat +python scripts/converter_hf_to_mcore.py --hf_model_path $HF_MODEL_PATH --output_path $DIST_CKPT_PATH + +# 2. run the script +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +train_files=$gsm8k_train_path +test_files=$gsm8k_test_path + +NODES=4 +PP=2 +TP=4 +CP=1 +VLLM_TP=4 + +# RAY_ADDRESS='auto' ray job submit --working-dir . -- +python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=$HF_MODEL_PATH \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=$TP \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=$PP \ + actor_rollout_ref.actor.megatron.context_parallel_size=$CP \ + actor_rollout_ref.actor.megatron.use_dist_checkpointing=True \ + actor_rollout_ref.actor.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=$TP \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=$PP \ + actor_rollout_ref.ref.megatron.context_parallel_size=$CP \ + actor_rollout_ref.ref.megatron.use_dist_checkpointing=True \ + actor_rollout_ref.ref.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=2 \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=$VLLM_TP \ + critic.optim.lr=1e-5 \ + critic.model.path=$HF_MODEL_PATH \ + critic.ppo_micro_batch_size_per_gpu=4 \ + critic.megatron.tensor_model_parallel_size=$TP \ + critic.megatron.pipeline_model_parallel_size=$PP \ + critic.megatron.context_parallel_size=$CP \ + critic.megatron.use_dist_checkpointing=True \ + critic.megatron.dist_checkpointing_path=$DIST_CKPT_PATH \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_megatron_gsm8k_examples' \ + trainer.experiment_name='qwen1.5_moe_nochat' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=$NODES \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=100 $@ + \ No newline at end of file diff --git a/verl/examples/ppo_trainer/run_qwen2-7b_math_gsm8k_megatron.sh b/verl/examples/ppo_trainer/run_qwen2-7b_math_gsm8k_megatron.sh new file mode 100644 index 0000000000000000000000000000000000000000..934d6e19b4edd9b4001a7a6afcff59d99646eccf --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen2-7b_math_gsm8k_megatron.sh @@ -0,0 +1,47 @@ +set -x + +export CUDA_DEVICE_MAX_CONNECTIONS=1 # For megatron communication/computation overlapping + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo --config-path=./config --config-name='ppo_megatron_trainer'\ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.actor.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.actor.megatron.tensor_model_parallel_size=2 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=4 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=4 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.4 \ + actor_rollout_ref.ref.megatron.pipeline_model_parallel_size=2 \ + actor_rollout_ref.ref.megatron.tensor_model_parallel_size=2 \ + critic.optim.lr=1e-5 \ + critic.model.path=Qwen/Qwen2-7B-Instruct \ + critic.ppo_micro_batch_size_per_gpu=4 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_ppo_gsm8k_math_examples' \ + trainer.experiment_name='qwen2_7b_megatron' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=100 $@ diff --git a/verl/examples/ppo_trainer/run_qwen2-7b_rm.sh b/verl/examples/ppo_trainer/run_qwen2-7b_rm.sh new file mode 100644 index 0000000000000000000000000000000000000000..57b7bd7524b17114233f7ed1b82939f79366dbcd --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen2-7b_rm.sh @@ -0,0 +1,71 @@ +# Discliamer: the model used in the script is only for academic purpose. +set -x + +# Data preparation scripts are available in ``examples/data_preprocess``. +# Example usage: +# +# python3 examples/data_preprocess/math_dataset.py --local_dir ~/data/math +# python3 examples/data_preprocess/gsm8k.py --local_save_dir ~/data/gsm8k + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + + +# prepare model ckpt +huggingface-cli download Qwen/Qwen2-7B-Instruct --local-dir $HOME/models/Qwen2-7B-Instruct & +huggingface-cli download sfairXC/FsfairX-LLaMA3-RM-v0.1 --local-dir $HOME/models/FsfairX-LLaMA3-RM-v0.1 & +wait + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=512 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path="$HOME/models/Qwen2-7B-Instruct" \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.optim.lr_warmup_steps_ratio=0.1 \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=1 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.optim.lr_warmup_steps_ratio=0.05 \ + critic.model.path="$HOME/models/Qwen2-7B-Instruct" \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=32 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + reward_model.enable=True \ + reward_model.model.path="$HOME/models/FsfairX-LLaMA3-RM-v0.1" \ + reward_model.model.use_remove_padding=True \ + reward_model.model.fsdp_config.param_offload=True \ + reward_model.micro_batch_size_per_gpu=32 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example' \ + trainer.val_before_train=False \ + trainer.experiment_name='Qwen2-7B-Instruct_hybrid_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance.sh b/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0ddc01e75eafa1c9003a6a415622d44688f79d9 --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance.sh @@ -0,0 +1,60 @@ +set -x + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=4096 \ + data.max_prompt_length=4096 \ + data.max_response_length=4096 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=512 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \ + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=Qwen/Qwen2-7B-Instruct \ + critic.model.enable_gradient_checkpointing=True \ + critic.use_dynamic_bsz=True \ + critic.ppo_max_token_len_per_gpu=98304 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + reward_model.enable=True \ + reward_model.model.path=sfairXC/FsfairX-LLaMA3-RM-v0.1\ + reward_model.model.use_remove_padding=True \ + reward_model.model.fsdp_config.param_offload=True \ + reward_model.micro_batch_size_per_gpu=32 \ + reward_model.use_dynamic_bsz=True \ + reward_model.forward_max_token_len_per_gpu=98304 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='qwen2-7b_hybrid_rm_bsz8k_p4k_r4k_seq_packing' \ + trainer.n_gpus_per_node=8 \ + trainer.val_before_train=False \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_fused_kernels.sh b/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_fused_kernels.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e0a335efe20465fe19b9c1784d0e1e360af405c --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_fused_kernels.sh @@ -0,0 +1,64 @@ +set -x + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +FUSED_KERNEL_BACKEND=triton # or 'torch' for torch backend + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=4096 \ + data.max_prompt_length=4096 \ + data.max_response_length=4096 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.use_fused_kernels=True \ + actor_rollout_ref.model.fused_kernel_options.impl_backend=$FUSED_KERNEL_BACKEND \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=512 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \ + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=Qwen/Qwen2-7B-Instruct \ + critic.model.enable_gradient_checkpointing=True \ + critic.use_dynamic_bsz=True \ + critic.ppo_max_token_len_per_gpu=98304 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + reward_model.enable=True \ + reward_model.model.path=sfairXC/FsfairX-LLaMA3-RM-v0.1\ + reward_model.model.use_remove_padding=True \ + reward_model.model.fsdp_config.param_offload=True \ + reward_model.micro_batch_size_per_gpu=32 \ + reward_model.use_dynamic_bsz=True \ + reward_model.forward_max_token_len_per_gpu=98304 \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='qwen2-7b_hybrid_rm_bsz8k_p4k_r4k_seq_packing_fused_kernel' \ + trainer.n_gpus_per_node=8 \ + trainer.val_before_train=False \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_nsys.sh b/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_nsys.sh new file mode 100644 index 0000000000000000000000000000000000000000..0acfe43e8628d9b86b3c1e6b45ae6c91684a6bc2 --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen2-7b_rm_seq_balance_nsys.sh @@ -0,0 +1,81 @@ +set -x + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files=${train_files:-"$gsm8k_train_path"} +test_files=${test_files:-"$gsm8k_test_path"} + +PROFILE_STEPS="[1,2,5]" # or [] or null +PROFILE_RANKS_ALL=False # or True +PROFILE_RANKS=[0,4] +DISCRETE=True # or True + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=4096 \ + data.max_prompt_length=4096 \ + data.max_response_length=4096 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=512 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=2 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=12000 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.actor.profiler.enable=True \ + actor_rollout_ref.actor.profiler.ranks=$PROFILE_RANKS \ + actor_rollout_ref.actor.profiler.all_ranks=$PROFILE_RANKS_ALL \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \ + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=Qwen/Qwen2-7B-Instruct \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_micro_batch_size_per_gpu=2 \ + critic.use_dynamic_bsz=True \ + critic.ppo_max_token_len_per_gpu=98304 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + critic.profiler.enable=True \ + critic.profiler.ranks=$PROFILE_RANKS \ + critic.profiler.all_ranks=$PROFILE_RANKS_ALL \ + reward_model.enable=True \ + reward_model.model.path=sfairXC/FsfairX-LLaMA3-RM-v0.1\ + reward_model.model.use_remove_padding=True \ + reward_model.model.fsdp_config.param_offload=True \ + reward_model.micro_batch_size_per_gpu=32 \ + reward_model.use_dynamic_bsz=True \ + reward_model.forward_max_token_len_per_gpu=98304 \ + reward_model.profiler.enable=True \ + reward_model.profiler.ranks=$PROFILE_RANKS \ + reward_model.profiler.all_ranks=$PROFILE_RANKS_ALL \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='qwen2-7b_hybrid_rm_bsz8k_p4k_r4k_seq_packing' \ + trainer.n_gpus_per_node=8 \ + trainer.val_before_train=False \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=-1 \ + trainer.total_epochs=15 \ + trainer.total_training_steps=6 \ + global_profiler.profile_continuous_steps=True \ + global_profiler.tool=nsys \ + global_profiler.steps=$PROFILE_STEPS \ + global_profiler.global_tool_config.nsys.discrete=$DISCRETE $@ diff --git a/verl/examples/ppo_trainer/run_qwen2-7b_sglang_seq_balance.sh b/verl/examples/ppo_trainer/run_qwen2-7b_sglang_seq_balance.sh new file mode 100644 index 0000000000000000000000000000000000000000..5108e8b5dd92f53d6c822528d3be50983c6044ff --- /dev/null +++ b/verl/examples/ppo_trainer/run_qwen2-7b_sglang_seq_balance.sh @@ -0,0 +1,51 @@ +set -x + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=gae \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=4096 \ + data.max_prompt_length=4096 \ + data.max_response_length=4096 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=512 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=sglang \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \ + actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=24000 \ + critic.optim.lr=1e-5 \ + critic.model.use_remove_padding=True \ + critic.model.path=Qwen/Qwen2-7B-Instruct \ + critic.model.enable_gradient_checkpointing=True \ + critic.ppo_max_token_len_per_gpu=98304 \ + critic.model.fsdp_config.param_offload=False \ + critic.model.fsdp_config.optimizer_offload=False \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_example_gsm8k' \ + trainer.experiment_name='qwen2-7b_function_rm_bsz8k_p4k_r4k_seq_packing' \ + trainer.n_gpus_per_node=8 \ + trainer.val_before_train=False \ + trainer.nnodes=1 \ + trainer.save_freq=20 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/ray/tutorial.ipynb b/verl/examples/ray/tutorial.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..ca176af0f7940f705281de7ce707d1fa27238c02 --- /dev/null +++ b/verl/examples/ray/tutorial.ipynb @@ -0,0 +1,963 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0ddc582b", + "metadata": {}, + "source": [ + "# VeRL Ray API Tutorial" + ] + }, + { + "cell_type": "markdown", + "id": "71fe3b94", + "metadata": {}, + "source": [ + "## Chapter 1: Ray Basics" + ] + }, + { + "cell_type": "code", + "execution_count": 144, + "id": "1347d381", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import os" + ] + }, + { + "cell_type": "code", + "execution_count": 145, + "id": "e75b9d44", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import warnings\n", + "\n", + "import ray\n", + "import torch\n", + "\n", + "warnings.filterwarnings(\"ignore\")" + ] + }, + { + "cell_type": "code", + "execution_count": 146, + "id": "2e90ae00", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2024-11-01 17:27:19,132\tINFO worker.py:1752 -- Started a local Ray instance.\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9cc9d2ccbdfb48918c8fd6cd13a0807a", + "version_major": 2, + "version_minor": 0 + }, + "text/html": [ + "
\n", + "
\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Python version:3.9.2
Ray version:2.10.0
\n", + "\n", + "
\n", + "
\n" + ], + "text/plain": [ + "RayContext(dashboard_url='', python_version='3.9.2', ray_version='2.10.0', ray_commit='09abba26b5bf2707639bb637c208d062a47b46f6')" + ] + }, + "execution_count": 146, + "metadata": {}, + "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[36m(GPUAccumulator pid=224400)\u001b[0m rank 0, value: tensor([1.], device='cuda:0')\n", + "\u001b[36m(GPUAccumulator pid=225234)\u001b[0m rank 2, value: tensor([3.], device='cuda:0')\n", + "\u001b[36m(GPUAccumulator pid=225607)\u001b[0m rank 0, value: tensor([2.], device='cuda:0')\n", + "\u001b[36m(GPUAccumulator pid=226423)\u001b[0m rank 1, value: tensor([3.], device='cuda:0')\n", + "\u001b[36m(GPUAccumulator pid=226857)\u001b[0m rank 3, value: tensor([6.], device='cuda:0')\n", + "\u001b[36m(GPUAccumulatorDecorator pid=227475)\u001b[0m 10\n", + "\u001b[36m(GPUAccumulatorDecorator pid=227475)\u001b[0m rank 0, value: tensor([10.], device='cuda:0')\n", + "\u001b[36m(GPUAccumulatorDecorator pid=227655)\u001b[0m rank 1, value: tensor([11.], device='cuda:0')\n" + ] + } + ], + "source": [ + "# Build a local ray cluster. The head node and worker node are on this machine\n", + "ray.init()" + ] + }, + { + "cell_type": "markdown", + "id": "a127e4e4", + "metadata": {}, + "source": [ + "Implement an Accumulator class." + ] + }, + { + "cell_type": "code", + "execution_count": 147, + "id": "20e7b9a3", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "@ray.remote\n", + "class Accumulator:\n", + " def __init__(self):\n", + " self.value = 0\n", + "\n", + " def add(self, x):\n", + " self.value += x\n", + "\n", + " def get_value(self):\n", + " return self.value" + ] + }, + { + "cell_type": "code", + "execution_count": 148, + "id": "3b80098c", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Instantiate an accumulator. Accumulator can be viewed as a process, acting as an RPC service.\n", + "accumulator = Accumulator.remote()" + ] + }, + { + "cell_type": "code", + "execution_count": 149, + "id": "b14b1009", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n" + ] + } + ], + "source": [ + "value_ref = accumulator.get_value.remote() # Check the current value. Note that this function returns immediately and does not actually wait for the remote execution to complete.\n", + "# Get the value\n", + "value = ray.get(value_ref)\n", + "print(value)" + ] + }, + { + "cell_type": "code", + "execution_count": 150, + "id": "513a84b3", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + } + ], + "source": [ + "# Accumulate, then check the result.\n", + "accumulator.add.remote(10) # Similarly, the 'add' here will return immediately.\n", + "new_value = ray.get(accumulator.get_value.remote())\n", + "print(new_value)" + ] + }, + { + "cell_type": "markdown", + "id": "3c332fe0", + "metadata": {}, + "source": [ + "## Chapter 2: Resource Pool and RayWorkerGroup\n", + "In the previous example, it was a simple single-process worker. \n", + "In this example, we implement a worker with a GPU and form a RayWorkerGroup. Within this RayWorkerGroup, we implement a simple operation of an accumulator." + ] + }, + { + "cell_type": "code", + "execution_count": 151, + "id": "04229afb", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "from verl.single_controller.base import Worker\n", + "from verl.single_controller.ray.base import RayClassWithInitArgs, RayResourcePool, RayWorkerGroup, merge_resource_pool" + ] + }, + { + "cell_type": "code", + "execution_count": 152, + "id": "0d0dbd58", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "resource_pool = RayResourcePool([4], use_gpu=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 153, + "id": "68f6838a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "@ray.remote\n", + "class GPUAccumulator(Worker):\n", + " def __init__(self) -> None:\n", + " super().__init__()\n", + " # The initial value of each rank is the same as the rank\n", + " self.value = torch.zeros(size=(1,), device=\"cuda\") + self.rank\n", + "\n", + " def add(self, x):\n", + " self.value += x\n", + " print(f\"rank {self.rank}, value: {self.value}\")\n", + " return self.value.cpu()" + ] + }, + { + "cell_type": "code", + "execution_count": 154, + "id": "23aad8fe", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[tensor([1.]), tensor([2.]), tensor([3.]), tensor([4.])]\n" + ] + } + ], + "source": [ + "# Each worker's initial value is its rank, and then each rank's value is incremented by 1, so the values obtained on each rank are [1, 2, 3, 4]\n", + "class_with_args = RayClassWithInitArgs(cls=GPUAccumulator)\n", + "worker_group = RayWorkerGroup(resource_pool, class_with_args)\n", + "print(worker_group.execute_all_sync(\"add\", x=[1, 1, 1, 1]))" + ] + }, + { + "cell_type": "markdown", + "id": "e6705284", + "metadata": {}, + "source": [ + "The principle of parameter passing: The input parameter is a list of length world_size, where each element in the list is dispatched respectively to each worker in the RayWorkerGroup. \n", + "The return parameter is also a list, corresponding to the return value of each worker." + ] + }, + { + "cell_type": "markdown", + "id": "d25c2412", + "metadata": {}, + "source": [ + "### GPU Resource Sharing" + ] + }, + { + "cell_type": "markdown", + "id": "f74f6d24", + "metadata": {}, + "source": [ + "RayWorkerGroups mapped to the same resource pool share the GPU. In this example, we implement three resource pools: the first occupies 4 GPUs, the second also occupies 4 GPUs, and the last occupies all 8 GPUs. Among them, the first resource pool reuses the resource pool mentioned above." + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "id": "49f9c06f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Create a new resource pool and then merge the newly created resource pool with the previous one.\n", + "resource_pool_1 = RayResourcePool([4], use_gpu=True, name_prefix=\"a\")\n", + "resource_pool_merge = merge_resource_pool(resource_pool, resource_pool_1)" + ] + }, + { + "cell_type": "code", + "execution_count": 156, + "id": "05c2e305", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Establish a RayWorkerGroup on the newly created resource pool.\n", + "worker_group_1 = RayWorkerGroup(resource_pool_1, class_with_args)\n", + "worker_group_merge = RayWorkerGroup(resource_pool_merge, class_with_args)" + ] + }, + { + "cell_type": "code", + "execution_count": 157, + "id": "6b9b13f4", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[tensor([2.]), tensor([3.]), tensor([4.]), tensor([5.])]\n" + ] + } + ], + "source": [ + "# Run 'add' on the second set of 4 GPUs; the result should be [2, 3, 4, 5].\n", + "output_1 = worker_group_1.execute_all_sync(\"add\", x=[2, 2, 2, 2])\n", + "print(output_1)" + ] + }, + { + "cell_type": "code", + "execution_count": 158, + "id": "d856d030", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[tensor([3.]), tensor([4.]), tensor([5.]), tensor([6.]), tensor([7.]), tensor([8.]), tensor([9.]), tensor([10.])]\n" + ] + } + ], + "source": [ + "# Run 'add' on the merged set of 8 GPUs; the result should be [3, 4, 5, 6, 7, 8, 9, 10].\n", + "output_merge = worker_group_merge.execute_all_sync(\"add\", x=[3, 3, 3, 3, 3, 3, 3, 3])\n", + "print(output_merge)" + ] + }, + { + "cell_type": "code", + "execution_count": 159, + "id": "33a4628c", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4 4 8\n" + ] + } + ], + "source": [ + "print(worker_group.world_size, worker_group_1.world_size, worker_group_merge.world_size)" + ] + }, + { + "cell_type": "markdown", + "id": "3df19d13", + "metadata": {}, + "source": [ + "## Chapter 3: Data Dispatch, Execution and Collection" + ] + }, + { + "cell_type": "markdown", + "id": "acb22d9d", + "metadata": {}, + "source": [ + "In the above example, we used the `execute_all_sync` function in the RayWorkerGroup to dispatch data from the driver to each worker. This is very inconvenient for coding. \n", + "In this chapter, we use the form of function decorators to allow RayWorkerGroup to directly call functions written in the Worker, and to greatly simplify parameter passing." + ] + }, + { + "cell_type": "code", + "execution_count": 160, + "id": "35237432", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "from verl.single_controller.base.decorator import Dispatch, Execute, register" + ] + }, + { + "cell_type": "code", + "execution_count": 161, + "id": "88b8ba3b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "@ray.remote\n", + "class GPUAccumulatorDecorator(Worker):\n", + " def __init__(self) -> None:\n", + " super().__init__()\n", + " # The initial value of each rank is the same as the rank\n", + " self.value = torch.zeros(size=(1,), device=\"cuda\") + self.rank\n", + "\n", + " # map from a single input to all the worker\n", + " @register(Dispatch.ONE_TO_ALL)\n", + " def add(self, x):\n", + " print(x)\n", + " self.value = self.value + x\n", + " print(f\"rank {self.rank}, value: {self.value}\")\n", + " return self.value.cpu()" + ] + }, + { + "cell_type": "code", + "execution_count": 162, + "id": "eddaa043", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "class_with_args = RayClassWithInitArgs(cls=GPUAccumulatorDecorator)\n", + "gpu_accumulator_decorator = RayWorkerGroup(resource_pool_merge, class_with_args)" + ] + }, + { + "cell_type": "code", + "execution_count": 163, + "id": "10087c91", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[tensor([10.]), tensor([11.]), tensor([12.]), tensor([13.]), tensor([14.]), tensor([15.]), tensor([16.]), tensor([17.])]\n" + ] + } + ], + "source": [ + "# As we can see, 10 is automatically dispatched to each Worker in this RayWorkerGroup.\n", + "print(gpu_accumulator_decorator.add(x=10))" + ] + }, + { + "cell_type": "markdown", + "id": "540ee6ad", + "metadata": {}, + "source": [ + "### Custom Dispatch, Collection\n", + "Users can customize `dispatch` and `collection` function. You only need to write the `dispatch_fn` and `collect_fn` functions yourself. We also support executing RPC only on rank_zero, with specific examples provided below." + ] + }, + { + "cell_type": "code", + "execution_count": 164, + "id": "8e041270", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "from verl.single_controller.base.decorator import Dispatch, collect_all_to_all, register" + ] + }, + { + "cell_type": "code", + "execution_count": 165, + "id": "43b5be31", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def two_to_all_dispatch_fn(worker_group, *args, **kwargs):\n", + " \"\"\"\n", + " Assume the input is a list of 2. Duplicate the input interleaved and pass to each worker.\n", + " \"\"\"\n", + " for arg in args:\n", + " assert len(arg) == 2\n", + " for i in range(worker_group.world_size - 2):\n", + " arg.append(arg[i % 2])\n", + " for k, v in kwargs.items():\n", + " assert len(v) == 2\n", + " for i in range(worker_group.world_size - 2):\n", + " v.append(v[i % 2])\n", + " return args, kwargs\n", + "\n", + "\n", + "@ray.remote\n", + "class TestActor(Worker):\n", + " # TODO: pass *args and **kwargs is bug prone and not very convincing\n", + " def __init__(self, x) -> None:\n", + " super().__init__()\n", + " self._x = x\n", + "\n", + " def foo(self, y):\n", + " return self._x + y\n", + "\n", + " @register(dispatch_mode=Dispatch.ALL_TO_ALL, execute_mode=Execute.RANK_ZERO)\n", + " def foo_rank_zero(self, x, y):\n", + " return self._x + y + x\n", + "\n", + " @register(dispatch_mode={\"dispatch_fn\": two_to_all_dispatch_fn, \"collect_fn\": collect_all_to_all})\n", + " def foo_custom(self, x, y):\n", + " return self._x + y + x" + ] + }, + { + "cell_type": "code", + "execution_count": 166, + "id": "83ec6609", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "class_with_args = RayClassWithInitArgs(cls=TestActor, x=2)\n", + "worker_group = RayWorkerGroup(resource_pool, class_with_args)" + ] + }, + { + "cell_type": "code", + "execution_count": 167, + "id": "62c58d8a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "output_ref = worker_group.foo_custom(x=[1, 2], y=[5, 6])\n", + "assert output_ref == [8, 10, 8, 10]\n", + "\n", + "output_ref = worker_group.foo_rank_zero(x=1, y=2)\n", + "assert output_ref == 5" + ] + }, + { + "cell_type": "code", + "execution_count": 168, + "id": "14689353", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + } + ], + "source": [ + "print(gpu_accumulator_decorator.world_size)" + ] + }, + { + "cell_type": "code", + "execution_count": 169, + "id": "2c80bbf4", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Shutdown ray cluster\n", + "ray.shutdown()" + ] + }, + { + "cell_type": "markdown", + "id": "a5c8151c", + "metadata": {}, + "source": [ + "## Chapter 4: NVMegatronRayWorkerGroup" + ] + }, + { + "cell_type": "markdown", + "id": "cd5680e9", + "metadata": {}, + "source": [ + "Due to the Ray issue, we can only support max_colocate_count=1 in RayResourcePool for now. \n", + "This means that each GPU can only have one process.\n", + "We can support max_colocate > 1 when applying this pull request: https://github.com/ray-project/ray/pull/44385" + ] + }, + { + "cell_type": "markdown", + "id": "92724419", + "metadata": {}, + "source": [ + "Therefore, we need to restart the ray and initialize a new resource_pool to demonstrate the **NVMegatronRayWorkerGroup**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9b038538", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Build a local ray cluster. The head node and worker node are on this machine\n", + "ray.init()" + ] + }, + { + "cell_type": "markdown", + "id": "ebfd8798", + "metadata": {}, + "source": [ + "Finally, we implement a `NVMegatronRayWorkerGroup`, within which we create a Megatron and then run a tensor parallel (tp) split Llama mlp layer. Here, we use a complex dispatch mode, `Megatron_COMPUTE`. This dispatch mode assumes that user passes the data partitioned by DP dimension. The data is dispatched to all tp/pp ranks within the same dp group, and ultimately only collects output data from tp=0 and the last pp. In this way, for users that only write code on the driver, the Megatron behind the RPC becomes transparent." + ] + }, + { + "cell_type": "code", + "execution_count": 171, + "id": "5a032154", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/opt/tiger/Megatron-LM\n", + "/opt/tiger/Megatron-LM/megatron/__init__.py\n" + ] + } + ], + "source": [ + "import sys\n", + "\n", + "current_pythonpath = os.environ.get(\"PYTHONPATH\", \"\")\n", + "\n", + "new_path = \"/opt/tiger/Megatron-LM\"\n", + "\n", + "new_pythonpath = f\"{new_path}:{current_pythonpath}\" if current_pythonpath else new_path\n", + "\n", + "os.environ[\"PYTHONPATH\"] = new_pythonpath\n", + "\n", + "print(new_path)\n", + "sys.path.append(new_path)\n", + "\n", + "import megatron\n", + "\n", + "print(megatron.__file__)" + ] + }, + { + "cell_type": "code", + "execution_count": 172, + "id": "8c84cd5a", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "from megatron.core import parallel_state as mpu\n", + "from omegaconf import OmegaConf\n", + "\n", + "from verl.single_controller.base.decorator import Dispatch, Execute, register\n", + "from verl.single_controller.base.megatron.worker import MegatronWorker\n", + "from verl.single_controller.ray.base import RayClassWithInitArgs, RayResourcePool, RayWorkerGroup\n", + "from verl.single_controller.ray.megatron import NVMegatronRayWorkerGroup" + ] + }, + { + "cell_type": "code", + "execution_count": 173, + "id": "1b1debcc", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "resource_pool = RayResourcePool([4], use_gpu=True, max_colocate_count=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 174, + "id": "bccbe081", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "@ray.remote\n", + "class MLPLayerWorker(MegatronWorker):\n", + " def __init__(self):\n", + " super().__init__()\n", + " rank = int(os.environ[\"LOCAL_RANK\"])\n", + " torch.distributed.init_process_group(backend=\"nccl\")\n", + " torch.cuda.set_device(rank)\n", + "\n", + " mpu.initialize_model_parallel(\n", + " tensor_model_parallel_size=4,\n", + " pipeline_model_parallel_size=1,\n", + " virtual_pipeline_model_parallel_size=None,\n", + " pipeline_model_parallel_split_rank=None,\n", + " use_sharp=False,\n", + " context_parallel_size=1,\n", + " expert_model_parallel_size=1,\n", + " nccl_communicator_config_path=None,\n", + " )\n", + " from megatron.core import tensor_parallel\n", + "\n", + " tensor_parallel.model_parallel_cuda_manual_seed(10)\n", + "\n", + " @register(Dispatch.ONE_TO_ALL)\n", + " def init_model(self, config):\n", + " from omegaconf import OmegaConf\n", + "\n", + " from verl.models.llama.megatron.layers import ParallelLlamaMLP\n", + " from verl.utils.megatron_utils import init_model_parallel_config\n", + "\n", + " megatron_config = OmegaConf.create(\n", + " {\n", + " \"sequence_parallel\": False,\n", + " \"param_dtype\": \"fp32\",\n", + " \"tensor_model_parallel_size\": mpu.get_tensor_model_parallel_world_size(),\n", + " \"pipeline_model_parallel_rank\": mpu.get_pipeline_model_parallel_rank(),\n", + " \"pipeline_model_parallel_size\": mpu.get_pipeline_model_parallel_world_size(),\n", + " \"virtual_pipeline_model_parallel_rank\": mpu.get_virtual_pipeline_model_parallel_rank(),\n", + " \"virtual_pipeline_model_parallel_size\": mpu.get_virtual_pipeline_model_parallel_world_size(),\n", + " }\n", + " )\n", + "\n", + " megatron_config = init_model_parallel_config(megatron_config)\n", + " self.parallel_layer = ParallelLlamaMLP(config=config, megatron_config=megatron_config)\n", + "\n", + " @register(Dispatch.ONE_TO_ALL)\n", + " def get_weights(self):\n", + " output = {}\n", + " for key, val in self.parallel_layer.named_parameters():\n", + " output[key] = val\n", + " return output\n", + "\n", + " @register(Dispatch.MEGATRON_COMPUTE)\n", + " def run_layer(self, x):\n", + " x = x.to(\"cuda\")\n", + " y = self.parallel_layer(x)\n", + " return y" + ] + }, + { + "cell_type": "code", + "execution_count": 175, + "id": "a655271d", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "layer_cls = RayClassWithInitArgs(cls=MLPLayerWorker)\n", + "layer_worker_group = NVMegatronRayWorkerGroup(\n", + " resource_pool=resource_pool,\n", + " ray_cls_with_init=layer_cls,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 176, + "id": "f105ebee", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4 4 1 1\n" + ] + } + ], + "source": [ + "print(layer_worker_group.world_size, layer_worker_group.tp_size, layer_worker_group.pp_size, layer_worker_group.dp_size)" + ] + }, + { + "cell_type": "code", + "execution_count": 177, + "id": "38655091", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "ffn_hidden_size = 11008\n", + "batch_size = 16\n", + "seq_len = 2048\n", + "hidden_size = 4096\n", + "\n", + "config = OmegaConf.create(\n", + " {\n", + " \"hidden_size\": hidden_size,\n", + " \"intermediate_size\": ffn_hidden_size,\n", + " \"hidden_act\": \"silu\",\n", + " \"pretraining_tp\": 1,\n", + " \"tp\": layer_worker_group.tp_size,\n", + " }\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 178, + "id": "a026efca", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "x = torch.rand(size=(seq_len, batch_size, hidden_size), dtype=torch.float32)" + ] + }, + { + "cell_type": "code", + "execution_count": 179, + "id": "f5fcaf13", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[None, None, None, None]" + ] + }, + "execution_count": 179, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "layer_worker_group.init_model(config)" + ] + }, + { + "cell_type": "code", + "execution_count": 180, + "id": "3f5cc9b4", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "torch.Size([2048, 16, 4096])\n" + ] + } + ], + "source": [ + "output = layer_worker_group.run_layer(\n", + " [x]\n", + ") # This must be a list of size 1, ensuring that the input equals the data parallel (dp).\n", + "print(output[0].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 181, + "id": "49792210", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Shutdown ray cluster\n", + "ray.shutdown()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf_baseline.sh b/verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf_baseline.sh new file mode 100644 index 0000000000000000000000000000000000000000..fb827168a19aa2e929fc3af7b2e3c87b22c52295 --- /dev/null +++ b/verl/examples/reinforce_plus_plus_trainer/run_qwen2-7b_math_rf_baseline.sh @@ -0,0 +1,49 @@ +set -x + + +gsm8k_train_path=$HOME/data/gsm8k/train.parquet +gsm8k_test_path=$HOME/data/gsm8k/test.parquet +math_train_path=$HOME/data/math/train.parquet +math_test_path=$HOME/data/math/test.parquet + +train_files="['$gsm8k_train_path', '$math_train_path']" +test_files="['$gsm8k_test_path', '$math_test_path']" + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=reinforce_plus_plus_baseline \ + data.train_files="$train_files" \ + data.val_files="$test_files" \ + data.train_batch_size=1024 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=3e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=1024 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=mse \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=8 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=True \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_grpo_example_gsm8k' \ + trainer.experiment_name='qwen2_7b_function_rm' \ + trainer.n_gpus_per_node=16 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/remax_trainer/run_qwen2.5-3b_seq_balance.sh b/verl/examples/remax_trainer/run_qwen2.5-3b_seq_balance.sh new file mode 100644 index 0000000000000000000000000000000000000000..feebe8a847594671fe7c8a9d2468c52eaaf33cac --- /dev/null +++ b/verl/examples/remax_trainer/run_qwen2.5-3b_seq_balance.sh @@ -0,0 +1,43 @@ +set -x + +export HF_DATASETS_OFFLINE=1 +export TRANSFORMERS_OFFLINE=1 + + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=remax \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=512 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-3B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=128 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=30000 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \ + actor_rollout_ref.rollout.n=4 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=True \ + algorithm.kl_penalty=kl \ + algorithm.kl_ctrl.kl_coef=0.001 \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_remax_example_gsm8k' \ + trainer.experiment_name='qwen2.5_3b_function_rm_kl1e-3' \ + trainer.val_before_train=False \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=5 $@ diff --git a/verl/examples/remax_trainer/run_qwen2.5-7b_seq_balance.sh b/verl/examples/remax_trainer/run_qwen2.5-7b_seq_balance.sh new file mode 100644 index 0000000000000000000000000000000000000000..8734eb351319f88417c767aad670052ee4b113a4 --- /dev/null +++ b/verl/examples/remax_trainer/run_qwen2.5-7b_seq_balance.sh @@ -0,0 +1,43 @@ +set -x + +export HF_DATASETS_OFFLINE=1 +export TRANSFORMERS_OFFLINE=1 + + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=remax \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.use_dynamic_bsz=True \ + actor_rollout_ref.actor.ppo_max_token_len_per_gpu=24000 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.8 \ + actor_rollout_ref.rollout.n=4 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=True \ + algorithm.kl_penalty=kl \ + algorithm.kl_ctrl.kl_coef=0.001 \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_remax_example_gsm8k' \ + trainer.experiment_name='qwen2.5_7b_function_rm_kl1e-3' \ + trainer.val_before_train=False \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=10 $@ diff --git a/verl/examples/rloo_trainer/run_qwen2-7b.sh b/verl/examples/rloo_trainer/run_qwen2-7b.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc9b6e29fdebd0245f7ecf6cf42d9b369e8fa1db --- /dev/null +++ b/verl/examples/rloo_trainer/run_qwen2-7b.sh @@ -0,0 +1,40 @@ +set -x + + +python3 -m verl.trainer.main_ppo \ + algorithm.adv_estimator=rloo \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.train_batch_size=1024 \ + data.max_prompt_length=512 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + actor_rollout_ref.model.path=Qwen/Qwen2-7B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=80 \ + actor_rollout_ref.actor.use_kl_loss=False \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=160 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=vllm \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \ + actor_rollout_ref.rollout.n=5 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=160 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=True \ + algorithm.kl_penalty=kl \ + algorithm.kl_ctrl.kl_coef=0.001 \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='verl_rloo_example_gsm8k' \ + trainer.experiment_name='qwen2_7b_function_rm' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=5 \ + trainer.total_epochs=15 $@ diff --git a/verl/examples/sft/gsm8k/run_deepseek_6b7.sh b/verl/examples/sft/gsm8k/run_deepseek_6b7.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a067f05d50b5a4bf86c444be09a610e9afc35cd --- /dev/null +++ b/verl/examples/sft/gsm8k/run_deepseek_6b7.sh @@ -0,0 +1,28 @@ +set -x + +if [ "$#" -lt 2 ]; then + echo "Usage: run_deepseek_6b7.sh [other_configs...]" + exit 1 +fi + +nproc_per_node=$1 +save_path=$2 + +# Shift the arguments so $@ refers to the rest +shift 2 + +torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \ + -m verl.trainer.fsdp_sft_trainer \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.prompt_key=extra_info \ + data.response_key=extra_info \ + data.prompt_dict_keys=['question'] \ + +data.response_dict_keys=['answer'] \ + data.micro_batch_size_per_gpu=4 \ + model.partial_pretrain=deepseek-ai/deepseek-coder-6.7b-instruct \ + trainer.default_local_dir=$save_path \ + trainer.project_name=gsm8k-sft \ + trainer.experiment_name=gsm8k-sft-deepseek-coder-6.7b-instruct \ + trainer.total_epochs=4 \ + trainer.logger='["console","wandb"]' $@ \ No newline at end of file diff --git a/verl/examples/sft/gsm8k/run_gemma_7b.sh b/verl/examples/sft/gsm8k/run_gemma_7b.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe2bc3a6f39ba7a1534bb9052d739b1ca01ced15 --- /dev/null +++ b/verl/examples/sft/gsm8k/run_gemma_7b.sh @@ -0,0 +1,28 @@ +set -x + +if [ "$#" -lt 2 ]; then + echo "Usage: run_gemma_7b.sh [other_configs...]" + exit 1 +fi + +nproc_per_node=$1 +save_path=$2 + +# Shift the arguments so $@ refers to the rest +shift 2 + +torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \ + -m verl.trainer.fsdp_sft_trainer \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.prompt_key=extra_info \ + data.response_key=extra_info \ + data.prompt_dict_keys=['question'] \ + data.response_dict_keys=['answer'] \ + data.micro_batch_size_per_gpu=4 \ + model.partial_pretrain=google/gemma-1.1-7b-it \ + trainer.default_local_dir=$save_path \ + trainer.project_name=gsm8k-sft \ + trainer.experiment_name=gsm8k-sft-gemma-1.1-7b-it \ + trainer.total_epochs=4 \ + trainer.logger='["console","wandb"]' $@ diff --git a/verl/examples/sft/gsm8k/run_qwen_05_peft.sh b/verl/examples/sft/gsm8k/run_qwen_05_peft.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a7d445580780135c4a1a9c6c045181cce9f21ac --- /dev/null +++ b/verl/examples/sft/gsm8k/run_qwen_05_peft.sh @@ -0,0 +1,37 @@ +# Tested with 2 & 4 GPUs + +set -x + +if [ "$#" -lt 2 ]; then + echo "Usage: run_qwen_05_peft.sh [other_configs...]" + exit 1 +fi + +nproc_per_node=$1 +save_path=$2 + +# Shift the arguments so $@ refers to the rest +shift 2 + +torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \ + -m verl.trainer.fsdp_sft_trainer \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.prompt_key=extra_info \ + data.response_key=extra_info \ + optim.lr=1e-4 \ + data.prompt_dict_keys=['question'] \ + +data.response_dict_keys=['answer'] \ + data.micro_batch_size_per_gpu=4 \ + model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \ + trainer.default_local_dir=$save_path \ + trainer.project_name=gsm8k-sft \ + trainer.experiment_name=gsm8k-sft-qwen-2.5-0.5b-instruct \ + trainer.logger=console \ + trainer.total_epochs=1 $@ \ + model.lora_rank=32\ + model.lora_alpha=16 \ + model.target_modules=all-linear + + # Or you can do this: + # model.target_modules=[q_proj,v_proj] \ diff --git a/verl/examples/sft/gsm8k/run_qwen_05_sp2.sh b/verl/examples/sft/gsm8k/run_qwen_05_sp2.sh new file mode 100644 index 0000000000000000000000000000000000000000..7210a5a403822d6b6e4ea724004f295fde5aeb6b --- /dev/null +++ b/verl/examples/sft/gsm8k/run_qwen_05_sp2.sh @@ -0,0 +1,31 @@ +set -x + +if [ "$#" -lt 2 ]; then + echo "Usage: run_qwen_05_sp2.sh [other_configs...]" + exit 1 +fi + +nproc_per_node=$1 +save_path=$2 + +# Shift the arguments so $@ refers to the rest +shift 2 + +torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \ + -m verl.trainer.fsdp_sft_trainer \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.prompt_key=extra_info \ + data.response_key=extra_info \ + optim.lr=1e-4 \ + data.prompt_dict_keys=['question'] \ + +data.response_dict_keys=['answer'] \ + data.micro_batch_size=4 \ + model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \ + trainer.default_local_dir=$save_path \ + trainer.project_name=gsm8k-sft \ + trainer.experiment_name=gsm8k-sft-qwen-2.5-0.5b-instruct-sp2 \ + trainer.logger=console \ + trainer.total_training_steps=1 $@ \ + ulysses_sequence_parallel_size=2 \ + use_remove_padding=true diff --git a/verl/examples/sft/gsm8k/run_seed_oss_36b_sft.sh b/verl/examples/sft/gsm8k/run_seed_oss_36b_sft.sh new file mode 100644 index 0000000000000000000000000000000000000000..35c1d6c6d34f8a070691a1ba5155ff2e4fee7dea --- /dev/null +++ b/verl/examples/sft/gsm8k/run_seed_oss_36b_sft.sh @@ -0,0 +1,31 @@ +set -x + +if [ "$#" -lt 2 ]; then + echo "Usage: run_seed_oss_36b_sft.sh [other_configs...]" + exit 1 +fi + +nproc_per_node=$1 +save_path=$2 + +# Shift the arguments so $@ refers to the rest +shift 2 + +torchrun --standalone --nnodes=1 --nproc_per_node=$nproc_per_node \ + -m verl.trainer.fsdp_sft_trainer \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + data.prompt_key=extra_info \ + data.response_key=extra_info \ + optim.lr=1e-4 \ + data.prompt_dict_keys=['question'] \ + +data.response_dict_keys=['answer'] \ + data.micro_batch_size=4 \ + model.partial_pretrain=ByteDance-Seed/Seed-OSS-36B-Base \ + trainer.default_local_dir=$save_path \ + trainer.project_name=gsm8k-sft \ + trainer.experiment_name=gsm8k-sft-seed-oss-36b \ + trainer.logger=console \ + trainer.total_training_steps=1 \ + ulysses_sequence_parallel_size=2 \ + use_remove_padding=true $@ diff --git a/verl/examples/sft/multiturn/run_qwen_05_sp2.sh b/verl/examples/sft/multiturn/run_qwen_05_sp2.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e1fc47e9c54eedadc74120ec1fb51ccf85669bc --- /dev/null +++ b/verl/examples/sft/multiturn/run_qwen_05_sp2.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -x + +if [ "$#" -lt 2 ]; then + echo "Usage: run_qwen_05_sp2.sh [other_configs...]" + exit 1 +fi + +nproc_per_node=$1 +save_path=$2 + +# Shift the arguments so $@ refers to the rest +shift 2 + +torchrun --nnodes=1 --nproc_per_node=$nproc_per_node \ + -m verl.trainer.fsdp_sft_trainer \ + data.train_files=$HOME/data/multiturn/train.parquet \ + data.val_files=$HOME/data/multiturn/test.parquet \ + data.multiturn.enable=true \ + data.multiturn.messages_key=messages \ + data.micro_batch_size=4 \ + model.partial_pretrain=Qwen/Qwen2.5-0.5B-Instruct \ + trainer.default_local_dir=$save_path \ + trainer.project_name=multiturn-sft \ + trainer.experiment_name=multiturn-sft-qwen-2.5-0.5b-instruct-sp2 \ + trainer.logger=console \ + trainer.total_training_steps=1 $@ \ + ulysses_sequence_parallel_size=2 \ + use_remove_padding=true \ No newline at end of file diff --git a/verl/examples/sglang_multiturn/run_qwen0.5b_gsm8k_multiturn_curriculum.sh b/verl/examples/sglang_multiturn/run_qwen0.5b_gsm8k_multiturn_curriculum.sh new file mode 100644 index 0000000000000000000000000000000000000000..d67a76e48fe12f3463cbc0c870c3fec3511ab7c8 --- /dev/null +++ b/verl/examples/sglang_multiturn/run_qwen0.5b_gsm8k_multiturn_curriculum.sh @@ -0,0 +1,56 @@ +# run on 8xH100 +# make sure your current working directory is the root of the project + +set -x + +ulimit -n 65535 + +PROJECT_DIR="$(pwd)" +CONFIG_PATH="$PROJECT_DIR/examples/sglang_multiturn/config" + +python3 -m verl.trainer.main_ppo \ + --config-path="$CONFIG_PATH" \ + --config-name='gsm8k_multiturn_grpo' \ + algorithm.adv_estimator=grpo \ + data.sampler.class_name="RandomCurriculumSampler" \ + data.sampler.class_path="pkg://tests.utils.dataset.test_create_rl_sampler_on_cpu" \ + data.dataloader_num_workers=0 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.train_batch_size=256 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-0.5B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=sglang \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.5 \ + actor_rollout_ref.rollout.n=16 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='gsm8k_async_rl' \ + trainer.experiment_name='qwen3-4b_function_rm-gsm8k-sgl-multi-w-tool-verify-n16' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=20 \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + actor_rollout_ref.rollout.multi_turn.tool_config_path="$PROJECT_DIR/examples/sglang_multiturn/config/tool_config/gsm8k_tool_config.yaml" \ + trainer.total_epochs=15 $@ + diff --git a/verl/examples/sglang_multiturn/run_qwen2.5-0.5b_gsm8k_multiturn_w_interaction.sh b/verl/examples/sglang_multiturn/run_qwen2.5-0.5b_gsm8k_multiturn_w_interaction.sh new file mode 100644 index 0000000000000000000000000000000000000000..b94f094174a8afc19702ea5365c8f61186b27346 --- /dev/null +++ b/verl/examples/sglang_multiturn/run_qwen2.5-0.5b_gsm8k_multiturn_w_interaction.sh @@ -0,0 +1,58 @@ +# run on 8xH100 +# make sure your current working directory is the root of the project + +set -x + +ulimit -n 65535 + +PROJECT_DIR="$(pwd)" +CONFIG_PATH="$PROJECT_DIR/examples/sglang_multiturn/config" +TRAIN_BATCH_SIZE=${TRAIN_BATCH_SIZE:-512} +MICRO_BATCH_SIZE=${MICRO_BATCH_SIZE:-8} +OFFLOAD=${OFFLOAD:-False} + +python3 -m verl.trainer.main_ppo \ + --config-path="$CONFIG_PATH" \ + --config-name='gsm8k_multiturn_grpo_w_interaction' \ + algorithm.adv_estimator=grpo \ + data.train_batch_size=$TRAIN_BATCH_SIZE \ + data.max_prompt_length=1024 \ + data.max_response_length=$((1024 * 3)) \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-0.5B-Instruct \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + +actor_rollout_ref.model.enable_activation_offloading=True \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.actor.ppo_mini_batch_size=$TRAIN_BATCH_SIZE \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=$MICRO_BATCH_SIZE \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.actor.fsdp_config.param_offload=$OFFLOAD \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=$OFFLOAD \ + actor_rollout_ref.actor.fsdp_config.model_dtype=bfloat16 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=$MICRO_BATCH_SIZE \ + actor_rollout_ref.rollout.tensor_model_parallel_size=2 \ + actor_rollout_ref.rollout.name=sglang \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.7 \ + actor_rollout_ref.rollout.n=8 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=$MICRO_BATCH_SIZE \ + actor_rollout_ref.ref.fsdp_config.param_offload=$OFFLOAD \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='gsm8k_async_rl' \ + trainer.experiment_name='qwen2.5-0.5b_function_rm-gsm8k-sgl-multi-w-interaction-n8' \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=20 \ + data.train_files=$HOME/data/gsm8k_verl_sgl_multi_turn_w_interaction/train.parquet \ + data.val_files=$HOME/data/gsm8k_verl_sgl_multi_turn_w_interaction/test.parquet \ + actor_rollout_ref.rollout.multi_turn.interaction_config_path="$PROJECT_DIR/examples/sglang_multiturn/config/interaction_config/gsm8k_interaction_config.yaml" \ + trainer.total_epochs=15 $@ + diff --git a/verl/examples/sglang_multiturn/run_qwen2.5-3b_gsm8k_multiturn.sh b/verl/examples/sglang_multiturn/run_qwen2.5-3b_gsm8k_multiturn.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c3dd6a451510b7bd3dab1fea608fe067022f44c --- /dev/null +++ b/verl/examples/sglang_multiturn/run_qwen2.5-3b_gsm8k_multiturn.sh @@ -0,0 +1,68 @@ +# run on 8xH100 +# make sure your current working directory is the root of the project + +set -x + +ulimit -n 65535 + +PROJECT_DIR="$(pwd)" +CONFIG_PATH="$PROJECT_DIR/examples/sglang_multiturn/config" + +function now() { + date '+%d-%H-%M' +} + +EXPERIMENT_NAME="qwen2.5-3b_baseline_$(now)" + +python3 -m verl.trainer.main_ppo \ + --config-path="$CONFIG_PATH" \ + --config-name='gsm8k_multiturn_grpo' \ + algorithm.adv_estimator=grpo \ + data.train_batch_size=256 \ + data.max_prompt_length=1024 \ + data.max_response_length=1024 \ + data.filter_overlong_prompts=True \ + data.truncation='error' \ + data.return_raw_chat=True \ + actor_rollout_ref.model.path=Qwen/Qwen2.5-3B-Instruct \ + actor_rollout_ref.actor.optim.lr=1e-6 \ + actor_rollout_ref.model.use_remove_padding=True \ + actor_rollout_ref.actor.ppo_mini_batch_size=256 \ + actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.actor.use_kl_loss=True \ + actor_rollout_ref.actor.kl_loss_coef=0.001 \ + actor_rollout_ref.actor.kl_loss_type=low_var_kl \ + actor_rollout_ref.actor.entropy_coeff=0 \ + actor_rollout_ref.model.enable_gradient_checkpointing=True \ + actor_rollout_ref.actor.fsdp_config.param_offload=False \ + actor_rollout_ref.actor.fsdp_config.optimizer_offload=False \ + global_profiler.tool=torch_memory \ + global_profiler.save_path=./mem_snapshots \ + global_profiler.global_tool_config.torch_memory.trace_alloc_max_entries=100000 \ + global_profiler.global_tool_config.torch_memory.stack_depth=32 \ + actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.rollout.tensor_model_parallel_size=1 \ + actor_rollout_ref.rollout.name=sglang \ + actor_rollout_ref.rollout.gpu_memory_utilization=0.85 \ + actor_rollout_ref.rollout.multi_stage_wake_up=True \ + actor_rollout_ref.rollout.n=16 \ + actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=32 \ + actor_rollout_ref.ref.fsdp_config.param_offload=True \ + actor_rollout_ref.rollout.over_sample_rate=0.1 \ + actor_rollout_ref.rollout.mode=sync \ + algorithm.use_kl_in_reward=False \ + trainer.critic_warmup=0 \ + trainer.logger='["console","wandb"]' \ + trainer.project_name='multi-turn-grpo-qwen2.5-3b-sglang' \ + trainer.experiment_name=$EXPERIMENT_NAME \ + trainer.n_gpus_per_node=8 \ + trainer.nnodes=1 \ + trainer.save_freq=-1 \ + trainer.test_freq=20 \ + trainer.val_before_train=True \ + data.train_files=$HOME/data/gsm8k/train.parquet \ + data.val_files=$HOME/data/gsm8k/test.parquet \ + actor_rollout_ref.rollout.multi_turn.tool_config_path="$PROJECT_DIR/examples/sglang_multiturn/config/tool_config/gsm8k_tool_config.yaml" \ + trainer.total_epochs=15 \ + actor_rollout_ref.rollout.update_weights_bucket_megabytes=512 $@ + diff --git a/verl/verl/utils/__pycache__/model.cpython-310.pyc b/verl/verl/utils/__pycache__/model.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..96d40ae4f5914d21f3fb107c1f49ea3a15987643 Binary files /dev/null and b/verl/verl/utils/__pycache__/model.cpython-310.pyc differ diff --git a/verl/verl/utils/dataset/dataset_utils.py b/verl/verl/utils/dataset/dataset_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..7354a0c896d3910d2539b1453a372a0ad1b0dad7 --- /dev/null +++ b/verl/verl/utils/dataset/dataset_utils.py @@ -0,0 +1,70 @@ +# Copyright 2025 Bytedance Ltd. and/or its affiliates + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from enum import Enum + +import torch + + +class DatasetPadMode(str, Enum): + """Padding mode for dataset""" + + RIGHT = "right" + LEFT_RIGHT = "left_right" + NO_PADDING = "no_padding" + + +class SFTTensorCollator: + """ + A custom collate_fn that handles batching of sequences. + 1. for variable-length sequences, convert them into NestedTensors. + 2. for fixed-length sequences, use default_collate. + """ + + def __init__(self, pad_mode: DatasetPadMode = DatasetPadMode.LEFT_RIGHT): + self.pad_mode = pad_mode + + def __call__(self, batch: list[dict[str, any]]) -> dict[str, any]: + if self.pad_mode == DatasetPadMode.NO_PADDING: + return self.collate_variable_batch(batch) + elif self.pad_mode in [DatasetPadMode.RIGHT, DatasetPadMode.LEFT_RIGHT]: + from torch.utils.data import default_collate + + return default_collate(batch) + else: + raise NotImplementedError(f"pad_mode {self.pad_mode} not implemented") + + def collate_variable_batch(self, batch: list[dict[str, any]]) -> dict[str, any]: + """ + Collates a list of samples into a single batch. + + Args: + batch: A list of dictionary samples from the dataset. + + Returns: + A dictionary representing the batched data, with variable-length + sequences converted to NestedTensors. + """ + + final_batch = {} + + tensor_keys = [key for key in batch[0].keys() if isinstance(batch[0][key], torch.Tensor)] + + # Handle tensor values by creating a NestedTensor. + for key in tensor_keys: + tensors = [item[key] for item in batch] + final_batch[key] = torch.nested.as_nested_tensor(tensors, layout=torch.jagged) + + return final_batch diff --git a/verl/verl/utils/dataset/sft_dataset.py b/verl/verl/utils/dataset/sft_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..3bd4d7513151b655b1def47559f250041f3f42f5 --- /dev/null +++ b/verl/verl/utils/dataset/sft_dataset.py @@ -0,0 +1,186 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +SFT dataset +- We assume user pass a single parquet file. +- We load all the data into the memory. +Each parquet file contains +""" + +import pandas as pd +import torch +from omegaconf.listconfig import ListConfig +from torch.utils.data import Dataset +from transformers import PreTrainedTokenizer + +from verl.utils import hf_tokenizer +from verl.utils.fs import copy_to_local +from verl.utils.model import compute_position_id_with_mask + + +class SFTDataset(Dataset): + """ + This is an in-memory SFTDataset + + Arguments: + config (OmegaConf): the data config + """ + + def __init__(self, parquet_files: str | ListConfig, tokenizer, config): + prompt_key = config.get("prompt_key", "prompt") + prompt_dict_keys = config.get("prompt_dict_keys", None) + response_key = config.get("response_key", "response") + response_dict_keys = config.get("response_dict_keys", None) + max_length = config.get("max_length", 1024) + truncation = config.get("truncation", "error") + use_shm = config.get("use_shm", False) + self.apply_chat_template_kwargs = config.get("apply_chat_template_kwargs", {}) + + assert truncation in ["error", "left", "right"] + self.truncation = truncation + self.use_shm = use_shm + + if not isinstance(parquet_files, ListConfig): + parquet_files = [parquet_files] + + self.parquet_files = parquet_files + if isinstance(tokenizer, str): + tokenizer = hf_tokenizer(tokenizer) + self.tokenizer: PreTrainedTokenizer = tokenizer + + self.prompt_key = prompt_key if isinstance(prompt_key, tuple | list) else [prompt_key] + self.response_key = response_key if isinstance(response_key, tuple | list) else [response_key] + self.prompt_dict_keys = prompt_dict_keys if prompt_dict_keys else [] + self.response_dict_keys = response_dict_keys if response_dict_keys else [] + + self.max_length = max_length + + self._download() + self._read_files_and_tokenize() + + def _download(self): + for i, parquet_file in enumerate(self.parquet_files): + self.parquet_files[i] = copy_to_local(parquet_file, verbose=True, use_shm=self.use_shm) + + def _read_files_and_tokenize(self): + def series_to_item(ls): + import numpy + import pandas + + while isinstance(ls, pandas.core.series.Series | numpy.ndarray) and len(ls) == 1: + ls = ls[0] + return ls + + dataframes = [] + for parquet_file in self.parquet_files: + # read parquet files and cache + dataframe = pd.read_parquet(parquet_file) + dataframes.append(dataframe) + self.dataframe = pd.concat(dataframes) + self.prompts = self.dataframe[self.prompt_key] + for key in self.prompt_dict_keys: + # type(x): pandas.core.series.Series + # type(x[0]): numpy.ndarray + # type(x[0][0]): dict + try: + self.prompts = self.prompts.apply(lambda x: series_to_item(x)[key], axis=1) # noqa: B023 + except Exception: + print(f"self.prompts={self.prompts}") + raise + if isinstance(self.prompts, pd.DataFrame): + self.prompts = self.prompts.squeeze() + self.prompts = self.prompts.tolist() + self.responses = self.dataframe[self.response_key] + for key in self.response_dict_keys: + try: + self.responses = self.responses.apply(lambda x: series_to_item(x)[key], axis=1) # noqa: B023 + except Exception: + print(f"self.responses={self.responses}") + raise + if isinstance(self.responses, pd.DataFrame): + self.responses = self.responses.squeeze() + self.responses = self.responses.tolist() + + def __len__(self): + return len(self.prompts) + + def __getitem__(self, item): + tokenizer = self.tokenizer + + prompt = self.prompts[item] + response = self.responses[item] + + # apply chat template + prompt_chat = [{"role": "user", "content": prompt}] + + # string + prompt_chat_str = tokenizer.apply_chat_template( + prompt_chat, add_generation_prompt=True, tokenize=False, **self.apply_chat_template_kwargs + ) + response_chat_str = response + tokenizer.eos_token + + # tokenize + prompt_ids_output = tokenizer(prompt_chat_str, return_tensors="pt", add_special_tokens=False) + prompt_ids = prompt_ids_output["input_ids"][0] + prompt_attention_mask = prompt_ids_output["attention_mask"][0] + + response_ids_output = tokenizer(response_chat_str, return_tensors="pt", add_special_tokens=False) + response_ids = response_ids_output["input_ids"][0] + response_attention_mask = response_ids_output["attention_mask"][0] + + prompt_length = prompt_ids.shape[0] + response_length = response_ids.shape[0] + + input_ids = torch.cat((prompt_ids, response_ids), dim=-1) + attention_mask = torch.cat((prompt_attention_mask, response_attention_mask), dim=-1) + + # padding to max length + sequence_length = input_ids.shape[0] + if sequence_length < self.max_length: + padded_input_ids = ( + torch.ones(size=(self.max_length - sequence_length,), dtype=input_ids.dtype) + * self.tokenizer.pad_token_id + ) + padded_attention_mask = torch.zeros(size=(self.max_length - sequence_length,), dtype=attention_mask.dtype) + + input_ids = torch.cat((input_ids, padded_input_ids)) + attention_mask = torch.cat((attention_mask, padded_attention_mask)) + elif sequence_length > self.max_length: + if self.truncation == "left": + # actually, left truncation may not be reasonable + input_ids = input_ids[-self.max_length :] + attention_mask = attention_mask[-self.max_length :] + elif self.truncation == "right": + input_ids = input_ids[: self.max_length] + attention_mask = attention_mask[: self.max_length] + elif self.truncation == "error": + raise NotImplementedError(f"{sequence_length=} is larger than {self.max_length=}") + else: + raise NotImplementedError(f"Unknown truncation method {self.truncation}") + + position_ids = compute_position_id_with_mask(attention_mask) + + loss_mask = attention_mask.clone() + if prompt_length > 1: + # mask out prompt for SFT. + loss_mask[: min(prompt_length, loss_mask.size(0)) - 1] = 0 + # mask out the last token in response + loss_mask[min(prompt_length + response_length, loss_mask.size(0)) - 1] = 0 + + return { + "input_ids": input_ids, + "attention_mask": attention_mask, + "position_ids": position_ids, + "loss_mask": loss_mask, + } diff --git a/verl/verl/utils/debug/__init__.py b/verl/verl/utils/debug/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..eb67df1b772039488b2448759ffd5c64a4c7768f --- /dev/null +++ b/verl/verl/utils/debug/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# APIs kept for backward compatibility purpose +# For new features please develop in verl/utils/profiler/ +from ..profiler import * # noqa diff --git a/verl/verl/utils/experimental/torch_functional.py b/verl/verl/utils/experimental/torch_functional.py new file mode 100644 index 0000000000000000000000000000000000000000..0b4ce5c61740f5424f062ab597db715368956dde --- /dev/null +++ b/verl/verl/utils/experimental/torch_functional.py @@ -0,0 +1,216 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Optional + +import torch + + +def _fused_linear_for_ppo_fwd( + hidden_states: torch.FloatTensor, + vocab_weights: torch.FloatTensor, + input_ids: torch.LongTensor, + temperature: float = 1.0, +) -> tuple[torch.FloatTensor, torch.FloatTensor]: + logits = (hidden_states @ vocab_weights.t()) / temperature + orig_dtype = logits.dtype + logits = logits.to(torch.float32) + + # Slower but more numerically stable to do log_softmax than probs.log() + probs = logits.softmax(dim=-1) + log_probs = logits.log_softmax(dim=-1) + + token_log_probs = log_probs.gather(-1, input_ids.unsqueeze(-1)).squeeze(-1) + entropy = torch.logsumexp(logits, dim=-1) - torch.sum(probs * logits, dim=-1) + + return token_log_probs.to(orig_dtype), entropy.to(orig_dtype) + + +def _fused_linear_for_ppo_bwd( + dlog_probs: Optional[torch.FloatTensor], + dentropy: Optional[torch.FloatTensor], + hidden_states: torch.FloatTensor, + vocab_weights: torch.FloatTensor, + input_ids: torch.LongTensor, + temperature: float = 1.0, +) -> tuple[torch.FloatTensor, torch.FloatTensor]: + logits = (hidden_states @ vocab_weights.t()) / temperature + orig_dtype = logits.dtype + logits = logits.to(torch.float32) + + probs = logits.softmax(dim=-1) + + dlogits = 0 + + # Gradient from log_probs + if dlog_probs is not None: + one_hot_input = torch.zeros_like(logits).scatter_(-1, input_ids.unsqueeze(-1), 1) + dlogits += dlog_probs.to(torch.float32).unsqueeze(-1) * (one_hot_input - probs) + + # Gradient from entropy + if dentropy is not None: + log_probs = logits.log_softmax(dim=-1) + entropy = torch.logsumexp(logits, dim=-1) - torch.sum(probs * logits, dim=-1) + dlogits += probs * (log_probs + entropy.unsqueeze(-1)) * (-dentropy.unsqueeze(-1)) + + dlogits = dlogits.to(orig_dtype) / temperature + + dhidden_states = dlogits @ vocab_weights + dvocab_weights = dlogits.t() @ hidden_states + + return dhidden_states, dvocab_weights + + +class FusedLinearForPPOFunction(torch.autograd.Function): + @staticmethod + def forward( + ctx, + hidden_states: torch.FloatTensor, + vocab_weights: torch.FloatTensor, + input_ids: torch.LongTensor, + temperature: float = 1.0, + chunk_size: int = 512, + ) -> tuple[torch.FloatTensor, torch.FloatTensor]: + ctx.set_materialize_grads(False) + + # Cast to a 2D tensor of the shape [T, D] for ease of working + orig_ndim = hidden_states.ndim + assert orig_ndim in (2, 3), f"Invalid hidden_states shape, received {hidden_states.shape}" + + orig_batch_size = -1 + if orig_ndim == 3: + assert input_ids.ndim == 2, f"input_ids shape doesn't match, {hidden_states.shape} {input_ids.shape}" + orig_batch_size = hidden_states.shape[0] + hidden_states = hidden_states.flatten(0, 1) + input_ids = input_ids.flatten(0, 1) + + T = hidden_states.shape[0] + + # Allocate memory for outputs + output_requires_grad = hidden_states.requires_grad or vocab_weights.requires_grad + log_probs = hidden_states.new_zeros(T, requires_grad=output_requires_grad) + entropy = hidden_states.new_zeros(T, requires_grad=output_requires_grad) + + # Perform forward one chunk at a time + for chunk_start in range(0, T, chunk_size): + chunk_end = min(chunk_start + chunk_size, T) + + chunk_log_probs, chunk_entropy = _fused_linear_for_ppo_fwd( + hidden_states=hidden_states[chunk_start:chunk_end], + vocab_weights=vocab_weights, + input_ids=input_ids[chunk_start:chunk_end], + temperature=temperature, + ) + log_probs[chunk_start:chunk_end] = chunk_log_probs + entropy[chunk_start:chunk_end] = chunk_entropy + + # Cast the output back to the original input dimension + if orig_ndim == 3: + log_probs = log_probs.view(orig_batch_size, -1) + entropy = entropy.view(orig_batch_size, -1) + + ctx.save_for_backward(hidden_states, vocab_weights, input_ids) + ctx.orig_batch_size = orig_batch_size + ctx.orig_ndim = orig_ndim + ctx.temperature = temperature + ctx.chunk_size = chunk_size + + return log_probs, entropy + + @staticmethod + def backward(ctx, dlog_probs: Optional[torch.FloatTensor], dentropy: Optional[torch.FloatTensor]): + assert dlog_probs is not None or dentropy is not None + + hidden_states, vocab_weights, input_ids = ctx.saved_tensors + orig_batch_size = ctx.orig_batch_size + orig_ndim = ctx.orig_ndim + temperature = ctx.temperature + chunk_size = ctx.chunk_size + + # Here orig_ndim refers to the orig_ndim of hidden_states + if orig_ndim == 3: + if dlog_probs is not None: + dlog_probs = dlog_probs.flatten() + if dentropy is not None: + dentropy = dentropy.flatten() + + T = hidden_states.shape[0] + + # Allocate memory for outputs + dhidden_states = None + if hidden_states.requires_grad: + dhidden_states = torch.zeros_like(hidden_states) + dvocab_weights = None + if vocab_weights.requires_grad: + dvocab_weights = torch.zeros_like(vocab_weights) + + # Perform backward one chunk at a time + for chunk_start in range(0, T, chunk_size): + chunk_end = min(chunk_start + chunk_size, T) + chunk_dlog_probs = None + if dlog_probs is not None: + chunk_dlog_probs = dlog_probs[chunk_start:chunk_end] + chunk_dentropy = None + if dentropy is not None: + chunk_dentropy = dentropy[chunk_start:chunk_end] + + h, v = _fused_linear_for_ppo_bwd( + dlog_probs=chunk_dlog_probs, + dentropy=chunk_dentropy, + hidden_states=hidden_states[chunk_start:chunk_end], + vocab_weights=vocab_weights, + input_ids=input_ids[chunk_start:chunk_end], + temperature=temperature, + ) + + if hidden_states.requires_grad: + dhidden_states[chunk_start:chunk_end] += h + if vocab_weights.requires_grad: + dvocab_weights += v + + # Cast the output back to the original input dimension + if orig_ndim == 3 and hidden_states.requires_grad: + hidden_size = hidden_states.shape[-1] + dhidden_states = dhidden_states.view(orig_batch_size, -1, hidden_size) + + return ( + dhidden_states, # hidden_states + dvocab_weights, # vocab_weights + None, # input_ids + None, # temperature + None, # chunk_size + ) + + +class FusedLinearForPPO(torch.nn.Module): + def __init__(self, chunk_size: int = 512): + super().__init__() + + self.chunk_size = chunk_size + + def forward( + self, + hidden_states: torch.FloatTensor, + vocab_weights: torch.FloatTensor, + input_ids: torch.LongTensor, + temperature: float = 1.0, + ) -> tuple[torch.FloatTensor, torch.FloatTensor]: + input_ids = input_ids.to(torch.int64) + return FusedLinearForPPOFunction.apply( + hidden_states, + vocab_weights, + input_ids, + temperature, + self.chunk_size, + ) diff --git a/verl/verl/utils/kernel/__init__.py b/verl/verl/utils/kernel/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e32d583d35d90e2ed0562f94a8d25123d69a1298 --- /dev/null +++ b/verl/verl/utils/kernel/__init__.py @@ -0,0 +1,31 @@ +# +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/verl/verl/utils/kernel/linear_cross_entropy.py b/verl/verl/utils/kernel/linear_cross_entropy.py new file mode 100644 index 0000000000000000000000000000000000000000..84191d748f7e95368e7b29b684e73e11c865ee62 --- /dev/null +++ b/verl/verl/utils/kernel/linear_cross_entropy.py @@ -0,0 +1,119 @@ +# +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import typing + +import torch +import torch.distributed as dist + + +class LinearCrossEntropy(torch.autograd.Function): + @staticmethod + def forward( + ctx, + hidden: torch.Tensor, + weight: torch.Tensor, + labels: torch.Tensor, + temperature: typing.Optional[float] = 1.0, + reduction: typing.Optional[str] = "none", + dist_process_group: typing.Optional[dist.ProcessGroup] = None, + ) -> list[torch.Tensor]: + """_summary_ + + Args: + ctx (_type_): _description_ + hidden (torch.Tensor): (batch_size, num_tokens, hidden_size) -> (batch_size * num_tokens, hidden_size) + weight (torch.Tensor): (vocab_size, hidden_size) + labels (torch.Tensor): (batch_size, num_tokens) -> (batch_size * num_tokens, ) + temperature (typing.Optional[float], optional): _description_. Defaults to 1.0. + reduction (typing.Optional[str], optional): _description_. Defaults to "none". + dist_process_group (typing.Optional[dist.ProcessGroup], optional): _description_. Defaults to None. + + Returns: + typing.List[torch.Tensor]: _description_ + """ + + assert isinstance(temperature, float), f"temperature must be a float, but got {type(temperature)}" + assert isinstance(reduction, str), f"reduction must be a str, but got {type(reduction)}" + with torch.cuda.nvtx.range("LinearCrossEntropy-forward"): + from . import kernels + + REDUCTION = kernels.get_entropy_reduction_enum_number(reduction.lower()) + + original_hidden_shape = hidden.shape + if len(hidden.shape) != 2: + hidden = hidden.view(-1, hidden.shape[-1]) # (batch_size * num_tokens, hidden_size) + if len(labels.shape) != 1: + labels = labels.view(-1) + + logprobs, entropy, _maximum, _accumulate, _entropy_b = kernels.efficient_entropy_forward( + hidden, weight, labels, REDUCTION, temperature, dist_process_group + ) + + ctx.save_for_backward(hidden, weight, labels, _maximum, _accumulate, _entropy_b) + ctx.original_hidden_shape = original_hidden_shape + ctx.REDUCTION = REDUCTION + ctx.dist_process_group = dist_process_group + ctx.should_return_fp32_grad = False + ctx.temperature = temperature + return logprobs, entropy + + @staticmethod + def backward(ctx, dlogprobs: torch.Tensor, dentropy: torch.Tensor) -> list[torch.Tensor]: + from . import kernels + + with torch.cuda.nvtx.range("LinearCrossEntropy-backward"): + (hidden, weight, labels, _maximum, _accumulate, _entropy_b) = ctx.saved_tensors + REDUCTION = ctx.REDUCTION + dist_process_group = ctx.dist_process_group + should_return_fp32_grad = ctx.should_return_fp32_grad + temperature = ctx.temperature + + d_hidden, d_weight = kernels.efficient_entropy_backward( + dlogprobs, + dentropy, + hidden, + weight, + labels, + _maximum, + _accumulate, + _entropy_b, + REDUCTION, + should_return_fp32_grad, + temperature, + dist_process_group, + ) + d_hidden = d_hidden.view(ctx.original_hidden_shape) + + return (d_hidden, d_weight, None, None, None, None) + + +linear_cross_entropy = LinearCrossEntropy.apply diff --git a/verl/verl/utils/logger/__init__.py b/verl/verl/utils/logger/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e3184368bd587551fc130fd8defae7a4140e2f42 --- /dev/null +++ b/verl/verl/utils/logger/__init__.py @@ -0,0 +1,32 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from .aggregate_logger import ( + DecoratorLoggerBase, + LocalLogger, + log_with_rank, + print_rank_0, + print_with_rank, + print_with_rank_and_timer, +) + +__all__ = [ + "LocalLogger", + "DecoratorLoggerBase", + "print_rank_0", + "print_with_rank", + "print_with_rank_and_timer", + "log_with_rank", +] diff --git a/verl/verl/utils/megatron/__init__.py b/verl/verl/utils/megatron/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce90c5eb352d85c59105c0dc85b5f1dd576f095 --- /dev/null +++ b/verl/verl/utils/megatron/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/verl/verl/utils/megatron/dist_checkpointing.py b/verl/verl/utils/megatron/dist_checkpointing.py new file mode 100644 index 0000000000000000000000000000000000000000..d95752a453a7c5a95b12093e087a3d8b08007011 --- /dev/null +++ b/verl/verl/utils/megatron/dist_checkpointing.py @@ -0,0 +1,56 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from megatron.core import dist_checkpointing, mpu +from megatron.core.dist_checkpointing.serialization import ( + get_default_load_sharded_strategy, + get_default_save_sharded_strategy, +) +from megatron.core.dist_checkpointing.strategies.fully_parallel import ( + FullyParallelLoadStrategyWrapper, + FullyParallelSaveStrategyWrapper, +) + + +def save_dist_checkpointing(sharded_state_dict, ckpt_path, async_save=False): + validate_sharding_integrity = True + # Get checkpointing strategies + save_strategy = get_default_save_sharded_strategy("torch_dist") + save_strategy = FullyParallelSaveStrategyWrapper( + save_strategy, mpu.get_data_parallel_group(with_context_parallel=True) + ) + + # Save model sharded state dicts + async_save_request = dist_checkpointing.save( + sharded_state_dict, + ckpt_path, + sharded_strategy=save_strategy, + async_sharded_save=async_save, + validate_access_integrity=validate_sharding_integrity, + ) + + return async_save_request + + +def load_dist_checkpointing(sharded_state_dict, ckpt_dir): + # Get checkpointing strategies + load_strategy = get_default_load_sharded_strategy(ckpt_dir) + load_strategy = FullyParallelLoadStrategyWrapper( + load_strategy, mpu.get_data_parallel_group(with_context_parallel=True) + ) + + # Load model sharded state dicts + state_dict = dist_checkpointing.load(sharded_state_dict, ckpt_dir, sharded_strategy=load_strategy) + + return state_dict diff --git a/verl/verl/utils/megatron/memory.py b/verl/verl/utils/megatron/memory.py new file mode 100644 index 0000000000000000000000000000000000000000..bc62d427ea57e83a4b99862364bb4c7af3bc6d6d --- /dev/null +++ b/verl/verl/utils/megatron/memory.py @@ -0,0 +1,38 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import torch + +from verl.utils.device import get_device_id + + +class MemoryBuffer: + def __init__(self, numel, numel_padded, dtype): + self.numel = numel + self.numel_padded = numel_padded + self.dtype = dtype + self.data = torch.zeros(self.numel_padded, dtype=self.dtype, device=get_device_id(), requires_grad=False) + + def zero(self): + """Reset the buffer to zero.""" + self.data.zero_() + + def get(self, shape, start_index): + """Return a tensor with the input `shape` as a view into the + 1-D data starting at `start_index`.""" + end_index = start_index + shape.numel() + assert end_index <= self.numel, "requested tensor is out of the buffer range." + buffer_tensor = self.data[start_index:end_index] + buffer_tensor = buffer_tensor.view(shape) + return buffer_tensor diff --git a/verl/verl/utils/megatron/pipeline_parallel.py b/verl/verl/utils/megatron/pipeline_parallel.py new file mode 100644 index 0000000000000000000000000000000000000000..50ba697362550eb410ccb1d5f55789232bc85531 --- /dev/null +++ b/verl/verl/utils/megatron/pipeline_parallel.py @@ -0,0 +1,71 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import torch +from megatron.core import parallel_state as mpu + +from .sequence_parallel import pad_to_sequence_parallel + + +def compute_transformers_input_shapes(batches, meta_info): + from flash_attn.bert_padding import unpad_input # flash 2 is a must for Megatron + + # pre-compute input shapes for each micro-batch at each pp stage + input_shapes = [] + for model_inputs in batches: + input_ids = model_inputs["input_ids"] + attention_mask = model_inputs["attention_mask"] + input_ids_rmpad = unpad_input(input_ids.unsqueeze(dim=-1), attention_mask)[0] # (total_nnz, 1) + if meta_info["sequence_parallel"]: + input_ids_rmpad = pad_to_sequence_parallel(input_ids_rmpad) + # compute shapes for model_inputs + input_shapes.append( + torch.Size( + [ + input_ids_rmpad.shape[0] // mpu.get_tensor_model_parallel_world_size(), + 1, + meta_info["hidden_size"], + ] + ) + ) + else: + # compute shapes for model_inputs + input_shapes.append(torch.Size([input_ids_rmpad.shape[0], 1, meta_info["hidden_size"]])) + return input_shapes + + +def make_batch_generator(batches, vpp_size): + """ + Creates a batch generator suitable for Megatron pipeline parallelism, + handling virtual pipeline parallelism (VPP). + + If VPP is used (vpp_size > 1), it duplicates the batch iterator for each + virtual pipeline stage. Otherwise, it returns a single iterator. + + Args: + batches: An iterable (e.g., list) of micro-batches. + vpp_size (int): The virtual pipeline model parallel size. + + Returns: + An iterator or a list of iterators over the micro-batches. + """ + if vpp_size > 1: + # has vpp + batch_generator = [batches] * vpp_size # number of vpp chunks + batch_generator = [iter(b) for b in batch_generator] + else: + # no vpp + batch_generator = iter(batches) + return batch_generator diff --git a/verl/verl/utils/megatron/tensor_parallel.py b/verl/verl/utils/megatron/tensor_parallel.py new file mode 100644 index 0000000000000000000000000000000000000000..d4a99b9d8a79d588fcd4acdec27d8e3fd5da553a --- /dev/null +++ b/verl/verl/utils/megatron/tensor_parallel.py @@ -0,0 +1,186 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Utilities for using tensor_parallel in megatron +""" + +from typing import TYPE_CHECKING + +import torch +import torch.distributed as dist +from megatron.core import parallel_state as mpu +from torch.nn import init + +if TYPE_CHECKING: + from megatron.core import ModelParallelConfig + + +def update_kwargs_with_config(dictionary: dict, config: "ModelParallelConfig"): + dictionary["config"] = config + return dictionary + + +def get_default_kwargs_for_model_parallel_config(): + model_parallel_config_kwargs = { + "params_dtype": torch.float32, + "use_cpu_initialization": False, + "perform_initialization": True, + "gradient_accumulation_fusion": False, + "sequence_parallel": False, + } + return model_parallel_config_kwargs + + +def get_default_model_parallel_config(): + from megatron.core import ModelParallelConfig + + return ModelParallelConfig(**get_default_kwargs_for_model_parallel_config()) + + +def get_common_default_kwargs_for_parallel_linear(): + default_model_parallel_config = get_default_model_parallel_config() + common_default_kwargs = { + "init_method": init.xavier_normal_, + "stride": 1, + "keep_master_weight_for_test": False, + "config": default_model_parallel_config, + } + return common_default_kwargs + + +def get_default_kwargs_for_column_parallel_linear(): + from megatron.core import ModelParallelConfig + + model_parallel_config_kwargs = get_default_kwargs_for_model_parallel_config() + column_parallel_config_kwargs = { + "async_tensor_model_parallel_allreduce": False, + } + model_parallel_config_kwargs.update(column_parallel_config_kwargs) + column_default_kwargs = { + "config": ModelParallelConfig(**model_parallel_config_kwargs), + } + common_default_kwargs = get_common_default_kwargs_for_parallel_linear() + common_default_kwargs.update(column_default_kwargs) + return common_default_kwargs + + +def get_default_kwargs_for_row_parallel_linear(): + common_default_kwargs = get_common_default_kwargs_for_parallel_linear() + return common_default_kwargs + + +def get_default_kwargs_for_parallel_embedding(): + from megatron.core import ModelParallelConfig + + model_parallel_config_kwargs = get_default_kwargs_for_model_parallel_config() + embedding_default_kwargs = { + "init_method": init.xavier_normal_, + "config": ModelParallelConfig(**model_parallel_config_kwargs), + } + return embedding_default_kwargs + + +def is_tensor_parallel_param(param): + return hasattr(param, "tensor_model_parallel") and param.tensor_model_parallel + + +def get_tensor_parallel_partition_dim(param): + assert is_tensor_parallel_param(param) + return param.partition_dim + + +def get_tensor_parallel_partition_stride(param): + assert is_tensor_parallel_param(param) + return param.partition_stride + + +class _VocabParallelEntropy(torch.autograd.Function): + @staticmethod + def forward(ctx, vocab_parallel_logits: torch.Tensor) -> torch.Tensor: + @torch.compile(dynamic=True) + def mul_reduce(a, b): + return (a * b).sum(dim=-1, keepdim=True) + + logits_max = vocab_parallel_logits.max(dim=-1, keepdim=True).values + dist.all_reduce(logits_max, op=dist.ReduceOp.MAX, group=mpu.get_tensor_model_parallel_group()) + normalized_vocab_parallel_logits = vocab_parallel_logits - logits_max + normalized_exp_logits = normalized_vocab_parallel_logits.exp_() + normalized_sum_exp_logits = normalized_exp_logits.sum(dim=-1, keepdim=True) + dist.all_reduce(normalized_sum_exp_logits, group=mpu.get_tensor_model_parallel_group()) + softmax_logits = normalized_exp_logits.div_(normalized_sum_exp_logits) + sum_softmax_times_logits = mul_reduce(softmax_logits, vocab_parallel_logits) + dist.all_reduce(sum_softmax_times_logits, group=mpu.get_tensor_model_parallel_group()) + entropy = logits_max + normalized_sum_exp_logits.log() - sum_softmax_times_logits + ctx.save_for_backward(vocab_parallel_logits, softmax_logits, sum_softmax_times_logits) + return entropy.squeeze(dim=-1) + + @staticmethod + def backward(ctx, grad_output: torch.Tensor) -> torch.Tensor: + vocab_parallel_logits, softmax_logits, sum_softmax_times_logits = ctx.saved_tensors + # reuse softmax_logits as grad + vocab_parallel_logits.sub_(sum_softmax_times_logits) + softmax_logits.mul_(vocab_parallel_logits) + softmax_logits.mul_(grad_output.unsqueeze(dim=-1)) + # recover vocab_parallel_logits + vocab_parallel_logits.add_(sum_softmax_times_logits) + softmax_logits.mul_(-1) + return softmax_logits + + +def vocab_parallel_entropy(vocab_parallel_logits: torch.Tensor) -> torch.Tensor: + """Compute entropy when the logits are sharded in tp ranks + + Args: + vocab_parallel_logits: (total_nnz, vocab_size // tp_size) + + Returns: (total_nnz,) + + """ + return _VocabParallelEntropy.apply(vocab_parallel_logits) + + +def vocab_parallel_log_probs_from_logits(logits, labels): + """TODO(zhangchi.usc1992): We may change the implementation later""" + from megatron.core import tensor_parallel + + return -tensor_parallel.vocab_parallel_cross_entropy(vocab_parallel_logits=logits, target=labels) + + +def vocab_parallel_log_probs_from_logits_response_rmpad(input_ids, attention_mask, logits_rmpad, response_length): + """Similar to log_probs_from_logits_response_rmpad, but the logits_rmpad is now spliited across tensor parallel + region. + This will further reduce the peak memory usage during training + + Args: + input_ids: [batch_size, seqlen] + attention_mask: [batch_size, seqlen] + logits_rmpad: [total_nnz, vocab_size // tp_size] + response_length: int + + """ + from flash_attn.bert_padding import pad_input, unpad_input + + batch_size, seqlen = input_ids.shape + input_ids_rmpad, indices, *_ = unpad_input(input_ids.unsqueeze(-1), attention_mask=attention_mask) + input_ids_rmpad = input_ids_rmpad.squeeze(-1) + input_ids_rmpad_rolled = torch.roll(input_ids_rmpad, shifts=-1, dims=0) + full_log_probs_rmpad = vocab_parallel_log_probs_from_logits( + logits=logits_rmpad, labels=input_ids_rmpad_rolled + ) # (total_nnz,) + full_output = pad_input( + hidden_states=full_log_probs_rmpad.unsqueeze(-1), indices=indices, batch=batch_size, seqlen=seqlen + ) + output = full_output.squeeze(-1)[:, -response_length - 1 : -1] # [batch_size, response_length] + return output diff --git a/verl/verl/utils/metric/__init__.py b/verl/verl/utils/metric/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1e19d3f79993100febf879936b9314659b8d7789 --- /dev/null +++ b/verl/verl/utils/metric/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2025 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .utils import reduce_metrics + +__all__ = ["reduce_metrics"] diff --git a/verl/verl/utils/metric/utils.py b/verl/verl/utils/metric/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..f9e7cd511f854e05eecd2b8b11f710efa3aba6ce --- /dev/null +++ b/verl/verl/utils/metric/utils.py @@ -0,0 +1,54 @@ +# Copyright 2025 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Metrics utils. +""" + +from typing import Any + +import numpy as np + + +def reduce_metrics(metrics: dict[str, list[Any]]) -> dict[str, Any]: + """ + Reduces a dictionary of metric lists by computing the mean, max, or min of each list. + The reduce operation is determined by the key name: + - If the key contains "max", np.max is used + - If the key contains "min", np.min is used + - Otherwise, np.mean is used + + Args: + metrics: A dictionary mapping metric names to lists of metric values. + + Returns: + A dictionary with the same keys but with each list replaced by its reduced value. + + Example: + >>> metrics = { + ... "loss": [1.0, 2.0, 3.0], + ... "accuracy": [0.8, 0.9, 0.7], + ... "max_reward": [5.0, 8.0, 6.0], + ... "min_error": [0.1, 0.05, 0.2] + ... } + >>> reduce_metrics(metrics) + {"loss": 2.0, "accuracy": 0.8, "max_reward": 8.0, "min_error": 0.05} + """ + for key, val in metrics.items(): + if "max" in key: + metrics[key] = np.max(val) + elif "min" in key: + metrics[key] = np.min(val) + else: + metrics[key] = np.mean(val) + return metrics diff --git a/verl/verl/utils/profiler/__init__.py b/verl/verl/utils/profiler/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..73edb01a02cbb55136d553890892ca00e6e9a3ca --- /dev/null +++ b/verl/verl/utils/profiler/__init__.py @@ -0,0 +1,40 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ..device import is_npu_available +from ..import_utils import is_nvtx_available +from .performance import GPUMemoryLogger, log_gpu_memory_usage, simple_timer +from .profile import DistProfiler, DistProfilerExtension, ProfilerConfig + +# Select marker implementations by availability, but keep DistProfiler as our dispatcher +if is_nvtx_available(): + from .nvtx_profile import mark_annotate, mark_end_range, mark_start_range, marked_timer +elif is_npu_available: + from .mstx_profile import mark_annotate, mark_end_range, mark_start_range, marked_timer +else: + from .performance import marked_timer + from .profile import mark_annotate, mark_end_range, mark_start_range + +__all__ = [ + "GPUMemoryLogger", + "log_gpu_memory_usage", + "mark_start_range", + "mark_end_range", + "mark_annotate", + "DistProfiler", + "DistProfilerExtension", + "ProfilerConfig", + "simple_timer", + "marked_timer", +] diff --git a/verl/verl/utils/profiler/config.py b/verl/verl/utils/profiler/config.py new file mode 100644 index 0000000000000000000000000000000000000000..33bd3f24251a5b24a983c6723c71383132402dc7 --- /dev/null +++ b/verl/verl/utils/profiler/config.py @@ -0,0 +1,156 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import warnings +from dataclasses import dataclass, field +from typing import Any, Optional + +from omegaconf import MISSING + +from verl.base_config import BaseConfig + + +@dataclass +class NsightToolConfig(BaseConfig): + """Nsight tool config.""" + + "True for each task has its own database, False for all tasks in one training step share one database." + discrete: bool = False + + def __post_init__(self) -> None: + pass + + +@dataclass +class TorchProfilerToolConfig(BaseConfig): + """Torch profiler tool config. + + Args: + step_start (int): Start step in update_policy. + step_end (int): End step. + """ + + step_start: int = -1 + step_end: int = -1 + + def __post_init__(self) -> None: + """config validation logics go here""" + warnings.warn("Torch profiler tool config is not fully supported now.", stacklevel=1) + assert isinstance(self.step_start, int), f"Profiler step_start must be of type int, got {type(self.step_start)}" + + +@dataclass +class TorchMemoryToolConfig(BaseConfig): + """Torch memory profiler tool config. + + Args: + trace_alloc_max_entries (int): Maximum number of memory allocation entries to track. + stack_depth (int): Stack trace depth for memory allocations. + """ + + trace_alloc_max_entries: int = 100_000 + stack_depth: int = 32 + + def __post_init__(self) -> None: + """config validation logics go here""" + assert isinstance(self.trace_alloc_max_entries, int), ( + f"trace_alloc_max_entries must be int, got {type(self.trace_alloc_max_entries)}" + ) + assert isinstance(self.stack_depth, int), f"stack_depth must be int, got {type(self.stack_depth)}" + assert self.trace_alloc_max_entries > 0, ( + f"trace_alloc_max_entries must be positive, got {self.trace_alloc_max_entries}" + ) + assert self.stack_depth > 0, f"stack_depth must be positive, got {self.stack_depth}" + + +@dataclass +class NPUToolConfig(NsightToolConfig): + """NPU profiler too; config.""" + + # options: npu, cpu, memory, shapes, module, stack + contents: list[str] = field(default_factory=list) + + # Collection level, optional values: level_none, level0, level1, level2. + level: str = "level1" + + # Whether to automatically parse the data. + analysis: bool = False + + def __post_init__(self) -> None: + """config validation logics go here""" + assert isinstance(self.contents, list), f"Profiler contents must be of type list, got {type(self.contents)}" + assert isinstance(self.level, str), f"Profiler level must be of type str, got {type(self.level)}" + assert isinstance(self.analysis, bool), f"Profiler analysis must be of type bool, got {type(self.analysis)}" + for content in self.contents: + assert content in ["npu", "cpu", "memory", "shapes", "module", "stack"], ( + f"Profiler contents only supports npu, cpu, memory, shapes, module, stack, but gets {content}" + ) + assert self.level in ["level_none", "level0", "level1", "level2"], ( + f"Profiler level only supports level0, 1, 2, and level_none, but gets {self.level}" + ) + + +@dataclass +class ProfilerConfig(BaseConfig): + """Worker profiler config. + + The inheritance from BaseConfig provides omegaconf.DictConfig-like interface for a dataclass config. + + Args: + discrete (bool): True for each task has its own database, False for all tasks in one training step + share one database. + all_ranks (bool): Whether to profile all ranks. + ranks (list[int]): The ranks that will be profiled. Defaults to []. + global_tool_config (Any): Global tool configuration for all profiling tools. + """ + + tool: Optional[str] = MISSING + enable: bool = False + all_ranks: bool = False + ranks: list[int] = field(default_factory=list) + save_path: Optional[str] = MISSING + tool_config: Any = MISSING # Just a placeholder, will use configs above directly + global_tool_config: Optional[Any] = None # Global tool configuration for all profiling tools + + def union(self, other: "ProfilerConfig") -> "ProfilerConfig": + assert self.tool == other.tool, f"Cannot union ProfilerConfig with different tools: {self.tool} vs {other.tool}" + return ProfilerConfig( + tool=self.tool, + enable=self.enable or other.enable, + all_ranks=self.all_ranks or other.all_ranks, + ranks=list(set(self.ranks or []) | set(other.ranks or [])), + save_path=self.save_path, + tool_config=self.tool_config, + global_tool_config=self.global_tool_config or other.global_tool_config, + ) + + def intersect(self, other: "ProfilerConfig") -> "ProfilerConfig": + assert self.tool == other.tool, ( + f"Cannot intersect ProfilerConfig with different tools: {self.tool} vs {other.tool}" + ) + return ProfilerConfig( + tool=self.tool, + enable=self.enable and other.enable, + all_ranks=self.all_ranks and other.all_ranks, + ranks=list(set(self.ranks or []) & set(other.ranks or [])), + save_path=self.save_path, + tool_config=self.tool_config, + global_tool_config=self.global_tool_config if self.global_tool_config else other.global_tool_config, + ) + + def __post_init__(self) -> None: + """config validation logics go here""" + assert isinstance(self.ranks, set | list | tuple), ( + f"Profiler ranks must be of type list, got {type(self.ranks)}" + ) diff --git a/verl/verl/utils/profiler/empty_annotations.py b/verl/verl/utils/profiler/empty_annotations.py new file mode 100644 index 0000000000000000000000000000000000000000..ed18dd359b7e0329a2d22e3981ab73da523e641e --- /dev/null +++ b/verl/verl/utils/profiler/empty_annotations.py @@ -0,0 +1,40 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Callable, Optional + + +def mark_start_range( + message: Optional[str] = None, + color: Optional[str] = None, + domain: Optional[str] = None, + category: Optional[str] = None, +) -> None: + pass + + +def mark_end_range(range_id: str) -> None: + pass + + +def mark_annotate( + message: Optional[str] = None, + color: Optional[str] = None, + domain: Optional[str] = None, + category: Optional[str] = None, +) -> Callable: + def decorator(func): + return func + + return decorator diff --git a/verl/verl/utils/profiler/performance.py b/verl/verl/utils/profiler/performance.py new file mode 100644 index 0000000000000000000000000000000000000000..d0bd408c9cb127bf5148cfd82eefddd8887eb282 --- /dev/null +++ b/verl/verl/utils/profiler/performance.py @@ -0,0 +1,240 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import datetime +import inspect +import logging +from contextlib import contextmanager +from typing import Any, Optional + +import torch +import torch.distributed as dist +from codetiming import Timer + +from verl.utils.device import get_device_id, get_torch_device +from verl.utils.logger import DecoratorLoggerBase + + +def _get_current_mem_info(unit: str = "GB", precision: int = 2) -> tuple[str]: + """Get current memory usage. + + Note that CPU device memory info is always 0. + + Args: + unit (str, optional): The unit of memory measurement. Defaults to "GB". + precision (int, optional): The number of decimal places to round memory values. Defaults to 2. + + Returns: + tuple[str]: A tuple containing memory allocated, memory reserved, memory used, and memory total + in the specified unit. + """ + assert unit in ["GB", "MB", "KB"] + device = get_torch_device() + # torch.cpu.memory_allocated() does not exist + if device == torch.cpu: + return "0.00", "0.00", "0.00", "0.00" + + divisor = 1024**3 if unit == "GB" else 1024**2 if unit == "MB" else 1024 + mem_allocated = get_torch_device().memory_allocated() + mem_reserved = get_torch_device().memory_reserved() + # use get_torch_device().mem_get_info to profile device memory + # since vllm's sleep mode works below pytorch + # see https://github.com/vllm-project/vllm/pull/11743#issuecomment-2754338119 + mem_free, mem_total = get_torch_device().mem_get_info() + mem_used = mem_total - mem_free + mem_allocated = f"{mem_allocated / divisor:.{precision}f}" + mem_reserved = f"{mem_reserved / divisor:.{precision}f}" + mem_used = f"{mem_used / divisor:.{precision}f}" + mem_total = f"{mem_total / divisor:.{precision}f}" + return mem_allocated, mem_reserved, mem_used, mem_total + + +def log_gpu_memory_usage(head: str, logger: logging.Logger = None, level=logging.DEBUG, rank: int = 0): + """Log GPU memory usage information. + + Args: + head (str): A descriptive header for the memory usage log message. + logger (logging.Logger, optional): Logger instance to use for logging. If None, prints to stdout. + level: Logging level to use. Defaults to logging.DEBUG. + rank (int): The rank of the process to log memory for. Defaults to 0. + """ + if (not dist.is_initialized()) or (rank is None) or (dist.get_rank() == rank): + mem_allocated, mem_reserved, mem_used, mem_total = _get_current_mem_info() + message = ( + f"{head}, memory allocated (GB): {mem_allocated}, memory reserved (GB): {mem_reserved}, " + f"device memory used/total (GB): {mem_used}/{mem_total}" + ) + + if logger is None: + print(message) + else: + logger.log(msg=message, level=level) + + +class GPUMemoryLogger(DecoratorLoggerBase): + """A decorator class to log GPU memory usage. + + Example: + >>> from verl.utils.profiler.performance import GPUMemoryLogger + >>> @GPUMemoryLogger(role="actor") + >>> def update_actor(self, batch): + ... # real actor update logics + ... return + """ + + def __init__(self, role: str, logger: logging.Logger = None, level=logging.DEBUG, log_only_rank_0: bool = True): + if dist.is_initialized() and dist.get_world_size() > 1: + rank = dist.get_rank() + else: + rank = 0 + super().__init__(role, logger, level, rank, log_only_rank_0) + + def __call__(self, decorated_function: callable): + def f(*args, **kwargs): + return self.log(decorated_function, *args, **kwargs) + + return f + + def log(self, func, *args, **kwargs): + name = func.__name__ + mem_allocated, mem_reserved, mem_used, mem_total = _get_current_mem_info() + message = ( + f"Before {name}, memory allocated (GB): {mem_allocated}, memory reserved (GB): {mem_reserved}, " + f"device memory used/total (GB): {mem_used}/{mem_total}" + ) + self.logging_function(message) + + output = func(*args, **kwargs) + + mem_allocated, mem_reserved, mem_used, mem_total = _get_current_mem_info() + message = ( + f"After {name}, memory allocated (GB): {mem_allocated}, memory reserved (GB): {mem_reserved}, " + f"device memory used/total (GB): {mem_used}/{mem_total}" + ) + + self.logging_function(message) + return output + + +def log_print(ctn: Any): + current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + + frame = inspect.currentframe().f_back + function_name = frame.f_code.co_name + line_number = frame.f_lineno + file_name = frame.f_code.co_filename.split("/")[-1] + print(f"[{current_time}-{file_name}:{line_number}:{function_name}]: {ctn}") + + +def _timer(name: str, timing_raw: dict[str, float]): + """Inner function that handles the core timing logic. + + Args: + name (str): The name/identifier for this timing measurement. + timing_raw (Dict[str, float]): Dictionary to store timing information. + """ + with Timer(name=name, logger=None) as timer: + yield + if name not in timing_raw: + timing_raw[name] = 0 + timing_raw[name] += timer.last + + +@contextmanager +def simple_timer(name: str, timing_raw: dict[str, float]): + """Context manager for basic timing without NVTX markers. + + This utility function measures the execution time of code within its context + and accumulates the timing information in the provided dictionary. + + Args: + name (str): The name/identifier for this timing measurement. + timing_raw (Dict[str, float]): Dictionary to store timing information. + + Yields: + None: This is a context manager that yields control back to the code block. + """ + yield from _timer(name, timing_raw) + + +@contextmanager +def marked_timer( + name: str, + timing_raw: dict[str, float], + color: str = None, + domain: Optional[str] = None, + category: Optional[str] = None, +): + """Context manager for timing with platform markers. + + This utility function measures the execution time of code within its context, + accumulates the timing information, and adds platform markers for profiling. + This function is a default implementation when hardware profiler is not available. + + Args: + name (str): The name/identifier for this timing measurement. + timing_raw (Dict[str, float]): Dictionary to store timing information. + color (Optional[str]): Color for the marker. Defaults to None. + domain (Optional[str]): Domain for the marker. Defaults to None. + category (Optional[str]): Category for the marker. Defaults to None. + + Yields: + None: This is a context manager that yields control back to the code block. + """ + yield from _timer(name, timing_raw) + + +def reduce_timing( + timing_raw: dict[str, float], reduce_op: torch.distributed.ReduceOp = torch.distributed.ReduceOp.AVG +) -> dict[str, float]: + """Reduce timing information across all processes. + + This function uses distributed communication to gather and sum the timing + information from all processes in a distributed environment. + + Args: + timing_raw (Dict[str, float]): Dictionary containing timing information. + + Returns: + Dict[str, float]: Reduced timing information. + """ + if not dist.is_initialized(): + return timing_raw + + key_list, timing_list = [], [] + for key in sorted(timing_raw.keys()): + key_list.append(key) + timing_list.append(timing_raw[key]) + timing_list = torch.tensor(timing_list, dtype=torch.float32, device=get_device_id()) + torch.distributed.all_reduce(timing_list, op=reduce_op) + timing_list = [tensor.item() for tensor in timing_list.to("cpu")] + timing_generate = {key_list[i]: timing_list[i] for i in range(len(key_list))} + return timing_generate + + +def topk_reduce_ratio_min_max(timing: float, k: int = 10) -> tuple[float, float, float]: + """Calculate topk items take-up ratio, and min/max timing across all ranks.""" + if not dist.is_initialized(): + return -1.0, -1.0, -1.0 + + world_size = dist.get_world_size() + timing_tensor = torch.tensor(timing, dtype=torch.float32, device=get_device_id()) + tensor_list = [torch.zeros(1, dtype=torch.float32, device=get_device_id()) for _ in range(world_size)] + torch.distributed.all_gather(tensor_list, timing_tensor) + tensor_stack = torch.stack(tensor_list) + timing_min = tensor_stack.min().cpu().item() + timing_max = tensor_stack.max().cpu().item() + top_k_percentile = torch.quantile(tensor_stack, 1 - k / 100) + tail_ratio = torch.mean((tensor_stack > top_k_percentile).float()).cpu().item() + return tail_ratio, timing_min, timing_max diff --git a/verl/verl/utils/profiler/profile.py b/verl/verl/utils/profiler/profile.py new file mode 100644 index 0000000000000000000000000000000000000000..a5aabcbc8ef1f7a37c9be3a94ea6bc34c4f0392b --- /dev/null +++ b/verl/verl/utils/profiler/profile.py @@ -0,0 +1,371 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import functools +import os +from typing import Callable, Optional + +import torch +import torch.distributed + +from ..memory_utils import MemorySnapshotSampler, enable_memory_visualize +from .config import ProfilerConfig, TorchMemoryToolConfig, TorchProfilerToolConfig + + +class Profiler: + """A PyTorch profiler wrapper class for collecting performance metrics. + + TODO(haibin.lin): this should implement the DistProfiler interface, and the config should be unified. + + This profiler provides a convenient interface for profiling PyTorch operations, + with support for: + + - CPU and CUDA activity profiling + - Configurable profiling schedule (wait/warmup/active steps) + - Multi-rank profiling support + - Chrome trace export + + Args: + config: Configuration object containing profiling parameters + """ + + def __init__(self, config: ProfilerConfig, tool_config: Optional[TorchProfilerToolConfig] = None): + # note : if we do not set use_profile, it will be set as None, so that all function will be skip + if not config: + config = ProfilerConfig(ranks=[], enable=False) + if not tool_config: + assert not config.enable, "tool_config must be provided when profiler is enabled" + self.prof = None + self.saved = False + self.enable = config.enable + if not config.enable: + return + self.config = config + self.tool_config = tool_config + self.rank = torch.distributed.get_rank() + # we need to validate the config before using the profiler + self._validate() + if self.rank in self.config.profile_ranks: + print(f"[Profiler] Profiler init for rank {self.rank}") + + self.prof = torch.profiler.profile( + activities=[ + torch.profiler.ProfilerActivity.CPU, + torch.profiler.ProfilerActivity.CUDA, + ], + schedule=torch.profiler.schedule( + wait=max(self.tool_config.step_start - 1, 0), + warmup=1 if self.tool_config.step_start > 0 else 0, + active=self.tool_config.step_end - self.tool_config.step_start, + repeat=1, + ), + record_shapes=True, + with_stack=True, + ) + + def _validate(self): + if self.enable: + if self.config.profile_ranks is None: + print("[WARNING] Profile ranks is not set, default to rank 0") + self.config.profile_ranks = [0] + assert self.tool_config.step_start >= 0, "[ERROR] Profile step start must be greater than 0" + assert self.tool_config.step_end >= 0, "[ERROR] Profile step end must be greater than 0" + assert self.tool_config.step_start < self.tool_config.step_end, ( + "[ERROR] Profile step start must be less than step end" + ) + + def check(self): + return self.prof is not None and self.enable + + def start(self): + if self.check(): + print(f"[Profiler] started for rank {self.rank}") + self.prof.start() + + def step(self): + if self.check(): + self.prof.step() + + def stop(self): + if self.check(): + print(f"[Profiler] stopped for rank {self.rank}") + self.prof.stop() + + def save(self): + if self.prof is not None and not self.saved: + if not os.path.exists(self.config.save_path): + os.makedirs(self.config.save_path) + save_file_name = f"/prof_start_{self.config.step_start}_end_{self.config.step_end}_rank_{self.rank}.json" + print(f"[Profiler] Saving trace to {self.config.save_path + save_file_name}") + self.prof.export_chrome_trace(self.config.save_path + save_file_name) + self.enable = False + self.saved = True + + def stop_and_save(self): + if self.check(): + self.stop() + self.save() + + def stop_trace(self): + if self.check(): + print(f"[Profiler] Trace stopped for rank {self.rank}") + self.enable = False + + +def mark_start_range( + message: Optional[str] = None, + color: Optional[str] = None, + domain: Optional[str] = None, + category: Optional[str] = None, +) -> None: + """Start a profiling range marker (no-op implementation). + + Args: + message (Optional[str]): Message to associate with the range marker. + color (Optional[str]): Color for the marker visualization. + domain (Optional[str]): Domain for the marker. + category (Optional[str]): Category for the marker. + """ + pass + + +def mark_end_range(range_id: str) -> None: + """End a profiling range marker (no-op implementation). + + Args: + range_id (str): Identifier of the range to end. + """ + pass + + +def mark_annotate( + message: Optional[str] = None, + color: Optional[str] = None, + domain: Optional[str] = None, + category: Optional[str] = None, +) -> Callable: + """Decorator to annotate a function with profiling markers (no-op implementation). + + Args: + message (Optional[str]): Message to associate with the annotation. + color (Optional[str]): Color for the marker visualization. + domain (Optional[str]): Domain for the marker. + category (Optional[str]): Category for the marker. + + Returns: + Callable: Decorator function that returns the original function unchanged. + """ + + def decorator(func): + return func + + return decorator + + +class DistProfiler: + """A dispatcher that delegates to specific profilers based on config.tool. + + Supported tools: + - nsys: NsightSystemsProfiler + - npu: NPUProfiler (Ascend) + - torch: PyTorch torch.profiler wrapper + - torch_memory: Torch CUDA memory snapshot dump + """ + + def __init__( + self, rank: int, config: Optional[ProfilerConfig] = None, tool_config: Optional[object] = None, **kwargs + ): + # Default config + if not config: + config = ProfilerConfig(ranks=[], enable=False) + + self._impl = None + self._tool = getattr(config, "tool", None) + + # Normalize rank selection + self._this_rank = False + if config.all_ranks: + self._this_rank = True + elif config.ranks: + self._this_rank = rank in config.ranks + else: + # default rank 0 if enabled but ranks unspecified + self._this_rank = (rank == 0) if config.enable else False + + # Lazy import to avoid circular deps + if self._tool == "nsys": + from .nvtx_profile import NsightSystemsProfiler as _Nsight + + self._impl = _Nsight(rank=rank, config=config, tool_config=tool_config, **kwargs) + elif self._tool == "npu": + from .mstx_profile import NPUProfiler as _Npu + + self._impl = _Npu(rank=rank, config=config, tool_config=tool_config, **kwargs) + elif self._tool == "torch": + # Use the torch profiler wrapper defined above + self._impl = Profiler(config=config, tool_config=tool_config) + elif self._tool == "torch_memory": + self._impl = TorchMemoryProfiler(rank=rank, config=config, tool_config=tool_config) + else: + # Fallback to a no-op impl + self._impl = _NoOpProfiler() + + def start(self, **kwargs): + return getattr(self._impl, "start", lambda **_: None)(**kwargs) + + def stop(self): + return getattr(self._impl, "stop", lambda: None)() + + @classmethod + def annotate( + cls, + message: Optional[str] = None, + color: Optional[str] = None, + domain: Optional[str] = None, + category: Optional[str] = None, + **kwargs_outer, + ) -> Callable: + def decorator(func): + @functools.wraps(func) + def wrapper(self_instance, *args, **kwargs_inner): + profiler = getattr(self_instance, "profiler", None) + if not profiler: + return func(self_instance, *args, **kwargs_inner) + + impl = profiler._impl + if hasattr(impl, "annotate"): + try: + actual_decorator = impl.annotate( + message=message, color=color, domain=domain, category=category, **kwargs_outer + ) + + return actual_decorator(func)(self_instance, *args, **kwargs_inner) + except Exception: + return func(self_instance, *args, **kwargs_inner) + return func(self_instance, *args, **kwargs_inner) + + return wrapper + + return decorator + + +class _NoOpProfiler: + def start(self, **kwargs): + return + + def stop(self): + return + + +class TorchMemoryProfiler: + """Profiler that dumps CUDA memory snapshots at step boundaries. + + Behavior: + - On first construction (per process), enable memory history recording if CUDA is available + - On start(step=X), remember sub_dir for this step + - On stop(), dump a memory snapshot into config.save_path under the remembered sub_dir + """ + + _memory_history_enabled: bool = False + + def __init__( + self, rank: int, config: Optional[ProfilerConfig], tool_config: Optional[TorchMemoryToolConfig] = None + ): + # Always respond to explicit start/stop calls for torch_memory tool, + # regardless of per-role enable flag, to align with global step control. + self.enable = True + if not config: + config = ProfilerConfig(ranks=[]) + self.config = config + self.rank = rank + self.this_step = False + self.sub_dir = None + self.sampler = MemorySnapshotSampler() + + # Get parameters from tool_config, with fallback to defaults + if tool_config: + trace_alloc_max_entries = tool_config.trace_alloc_max_entries + stack_depth = tool_config.stack_depth + else: + trace_alloc_max_entries = 100_000 + stack_depth = 32 + + # Best-effort enable memory history once + if not TorchMemoryProfiler._memory_history_enabled: + try: + enable_memory_visualize(trace_alloc_max_entries=trace_alloc_max_entries, stack_depth=stack_depth) + except Exception: + # silently ignore if not supported + pass + TorchMemoryProfiler._memory_history_enabled = True + + def start(self, **kwargs): + if not self.enable: + return + if not self._should_profile_this_rank(): + return + profile_step = kwargs.get("profile_step", None) + # Keep ranks aligned under same folder name + self.sub_dir = f"step{profile_step}" if profile_step is not None else None + self.this_step = True + + def stop(self): + if not self.enable or not self.this_step: + return + self.this_step = False + if not self._should_profile_this_rank(): + return + out_dir = self.config.save_path or "outputs/profile" + tag = "torch_memory" + # Dump snapshot; all ranks write into same sub_dir + try: + self.sampler.dump_memory_snapshot(out_dir=out_dir, tag=tag, sub_dir=self.sub_dir) + except Exception: + pass + + def _should_profile_this_rank(self) -> bool: + if self.config.all_ranks: + return True + if self.config.ranks: + return self.rank in self.config.ranks + # default rank 0 + return self.rank == 0 + + +class DistProfilerExtension: + """An extension class for DistProfiler that provides distributed profiling capabilities. + + It is intended for workers in verl that single controller invokes. + + This class wraps a DistProfiler instance and provides methods to start/stop profiling + that can be dispatched across multiple ranks in a distributed training environment. + + Args: + profiler (DistProfiler): The base distributed profiler instance to extend + """ + + def __init__(self, profiler: DistProfiler): + self.profiler = profiler + + from verl.single_controller.base.decorator import Dispatch, register + + @register(dispatch_mode=Dispatch.ONE_TO_ALL) + def start_profile(self, **kwargs) -> None: + """Start profiling for the current rank in the current training step.""" + self.profiler.start(**kwargs) + + @register(dispatch_mode=Dispatch.ONE_TO_ALL) + def stop_profile(self) -> None: + """Stop profiling for the current rank in the current training step.""" + self.profiler.stop() diff --git a/verl/verl/utils/rendezvous/__init__.py b/verl/verl/utils/rendezvous/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce90c5eb352d85c59105c0dc85b5f1dd576f095 --- /dev/null +++ b/verl/verl/utils/rendezvous/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/verl/verl/utils/rendezvous/ray_backend.py b/verl/verl/utils/rendezvous/ray_backend.py new file mode 100644 index 0000000000000000000000000000000000000000..d9911815d5b54fcb5364e0e2a760c0aa5c6fc2d0 --- /dev/null +++ b/verl/verl/utils/rendezvous/ray_backend.py @@ -0,0 +1,73 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import time + +import ray +from cupy.cuda.nccl import NcclCommunicator, get_unique_id +from ray.util import list_named_actors + + +@ray.remote +class NCCLIDStore: + def __init__(self, nccl_id): + self._nccl_id = nccl_id + + def get(self): + return self._nccl_id + + +def get_nccl_id_store_by_name(name): + all_actors = list_named_actors(all_namespaces=True) + matched_actors = [actor for actor in all_actors if actor.get("name", None) == name] + if len(matched_actors) == 1: + actor = matched_actors[0] + return ray.get_actor(**actor) + elif len(matched_actors) > 1: + logging.warning("multiple actors with same name found: %s", matched_actors) + elif len(matched_actors) == 0: + logging.info("failed to get any actor named %s", name) + return None + + +def create_nccl_communicator_in_ray( + rank: int, world_size: int, group_name: str, max_retries: int = 100, interval_s: int = 5 +): + if rank == 0: + nccl_id = get_unique_id() + nccl_id_store = NCCLIDStore.options(name=group_name).remote(nccl_id) + + assert ray.get(nccl_id_store.get.remote()) == nccl_id + communicator = NcclCommunicator( + ndev=world_size, + commId=nccl_id, + rank=0, + ) + return communicator + else: + for i in range(max_retries): + nccl_id_store = get_nccl_id_store_by_name(group_name) + if nccl_id_store is not None: + logging.info("nccl_id_store %s got", group_name) + nccl_id = ray.get(nccl_id_store.get.remote()) + logging.info("nccl id for %s got: %s", group_name, nccl_id) + communicator = NcclCommunicator( + ndev=world_size, + commId=nccl_id, + rank=rank, + ) + return communicator + logging.info("failed to get nccl_id for %d time, sleep for %d seconds", i + 1, interval_s) + time.sleep(interval_s) diff --git a/verl/verl/utils/reward_score/geo3k.py b/verl/verl/utils/reward_score/geo3k.py new file mode 100644 index 0000000000000000000000000000000000000000..8a8508758a63ef929ad76385f5929985c41f2929 --- /dev/null +++ b/verl/verl/utils/reward_score/geo3k.py @@ -0,0 +1,36 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import re + +from mathruler.grader import extract_boxed_content, grade_answer + + +def format_reward(predict_str: str) -> float: + pattern = re.compile(r".*.*\\boxed\{.*\}.*", re.DOTALL) + match_result = re.fullmatch(pattern, predict_str) + return 1.0 if match_result else 0.0 + + +def acc_reward(predict_str: str, ground_truth: str, use_boxed: bool = True) -> float: + if use_boxed: + answer = extract_boxed_content(predict_str) + else: + answer = predict_str + return 1.0 if grade_answer(answer, ground_truth) else 0.0 + + +def compute_score(predict_str: str, ground_truth: str, use_boxed: bool = True, format_score: float = 0.1) -> float: + return (1.0 - format_score) * acc_reward(predict_str, ground_truth, use_boxed) + format_score * format_reward( + predict_str + ) diff --git a/verl/verl/utils/reward_score/gsm8k.py b/verl/verl/utils/reward_score/gsm8k.py new file mode 100644 index 0000000000000000000000000000000000000000..98a8c24dc8c66922ec0518ee31072691db81d4e5 --- /dev/null +++ b/verl/verl/utils/reward_score/gsm8k.py @@ -0,0 +1,72 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re + +_SOLUTION_CLIP_CHARS = 300 + + +def extract_solution(solution_str, method="strict"): + assert method in ["strict", "flexible"] + + # Optimization: Regular expression matching on very long strings can be slow. + # For math problems, the final answer is usually at the end. + # We only match on the last 300 characters, which is a safe approximation for 300 tokens. + if len(solution_str) > _SOLUTION_CLIP_CHARS: + solution_str = solution_str[-_SOLUTION_CLIP_CHARS:] + + if method == "strict": + # this also tests the formatting of the model + solutions = re.findall("#### (\\-?[0-9\\.\\,]+)", solution_str) + if len(solutions) == 0: + final_answer = None + else: + # take the last solution + final_answer = solutions[-1].replace(",", "").replace("$", "") + elif method == "flexible": + answer = re.findall("(\\-?[0-9\\.\\,]+)", solution_str) + final_answer = None + if len(answer) == 0: + # no reward is there is no answer + pass + else: + invalid_str = ["", "."] + # find the last number that is not '.' + for final_answer in reversed(answer): + if final_answer not in invalid_str: + break + return final_answer + + +def compute_score(solution_str, ground_truth, method="strict", format_score=0.0, score=1.0): + """The scoring function for GSM8k. + + Reference: Trung, Luong, et al. "Reft: Reasoning with reinforced fine-tuning." Proceedings of the 62nd Annual + Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 2024. + + Args: + solution_str: the solution text + ground_truth: the ground truth + method: the method to extract the solution, choices are 'strict' and 'flexible' + format_score: the score for the format + score: the score for the correct answer + """ + answer = extract_solution(solution_str=solution_str, method=method) + if answer is None: + return 0 + else: + if answer == ground_truth: + return score + else: + return format_score diff --git a/verl/verl/utils/reward_score/math_batch.py b/verl/verl/utils/reward_score/math_batch.py new file mode 100644 index 0000000000000000000000000000000000000000..20b38e1bb146973b56e48cc0de78516fa7acacd6 --- /dev/null +++ b/verl/verl/utils/reward_score/math_batch.py @@ -0,0 +1,26 @@ +# Copyright 2025 Individual Contributor: Mert Unsal +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .math_reward import compute_score + + +def compute_score_batched(data_sources, solution_strs, ground_truths, extra_infos): + """ + This is a demonstration of how the batched reward function should look like. + Typically, you want to use batched reward to speed up the process with parallelization + """ + return [ + compute_score(solution_str, ground_truth) + for solution_str, ground_truth in zip(solution_strs, ground_truths, strict=True) + ] diff --git a/verl/verl/utils/reward_score/math_dapo.py b/verl/verl/utils/reward_score/math_dapo.py new file mode 100644 index 0000000000000000000000000000000000000000..940500fd59ea115d7d1d366b093f36105a997626 --- /dev/null +++ b/verl/verl/utils/reward_score/math_dapo.py @@ -0,0 +1,272 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Adapted from https://github.com/EleutherAI/lm-evaluation-harness/blob/main/lm_eval/tasks/hendrycks_math/utils.py + +import re +from typing import Optional + + +def last_boxed_only_string(string: str) -> Optional[str]: + """Extract the last LaTeX boxed expression from a string. + + Args: + string: Input string containing LaTeX code + + Returns: + The last boxed expression or None if not found + """ + idx = string.rfind("\\boxed{") + if idx < 0: + return None + + i = idx + right_brace_idx = None + num_left_braces_open = 0 + + while i < len(string): + if string[i] == "{": + num_left_braces_open += 1 + if string[i] == "}": + num_left_braces_open -= 1 + if num_left_braces_open == 0: + right_brace_idx = i + break + i += 1 + + return string[idx : right_brace_idx + 1] if right_brace_idx is not None else None + + +def remove_boxed(s: str) -> str: + """Remove the LaTeX boxed command from a string. + + Args: + s: String with format "\\boxed{content}" + + Returns: + The content inside the boxed command + """ + left = "\\boxed{" + assert s[: len(left)] == left, f"box error: {s}" + assert s[-1] == "}", f"box error: {s}" + return s[len(left) : -1] + + +# Constants for normalization +SUBSTITUTIONS = [ + ("an ", ""), + ("a ", ""), + (".$", "$"), + ("\\$", ""), + (r"\ ", ""), + (" ", ""), + ("mbox", "text"), + (",\\text{and}", ","), + ("\\text{and}", ","), + ("\\text{m}", "\\text{}"), +] + +REMOVED_EXPRESSIONS = [ + "square", + "ways", + "integers", + "dollars", + "mph", + "inches", + "hours", + "km", + "units", + "\\ldots", + "sue", + "points", + "feet", + "minutes", + "digits", + "cents", + "degrees", + "cm", + "gm", + "pounds", + "meters", + "meals", + "edges", + "students", + "childrentickets", + "multiples", + "\\text{s}", + "\\text{.}", + "\\text{\ns}", + "\\text{}^2", + "\\text{}^3", + "\\text{\n}", + "\\text{}", + r"\mathrm{th}", + r"^\circ", + r"^{\circ}", + r"\;", + r",\!", + "{,}", + '"', + "\\dots", +] + + +def normalize_final_answer(final_answer: str) -> str: + """Normalize a final answer to a quantitative reasoning question. + + Args: + final_answer: The answer string to normalize + + Returns: + Normalized answer string + """ + final_answer = final_answer.split("=")[-1] + + # Apply substitutions and removals + for before, after in SUBSTITUTIONS: + final_answer = final_answer.replace(before, after) + for expr in REMOVED_EXPRESSIONS: + final_answer = final_answer.replace(expr, "") + + # Extract and normalize LaTeX math + final_answer = re.sub(r"(.*?)(\$)(.*?)(\$)(.*)", "$\\3$", final_answer) + final_answer = re.sub(r"(\\text\{)(.*?)(\})", "\\2", final_answer) + final_answer = re.sub(r"(\\textbf\{)(.*?)(\})", "\\2", final_answer) + final_answer = re.sub(r"(\\overline\{)(.*?)(\})", "\\2", final_answer) + final_answer = re.sub(r"(\\boxed\{)(.*)(\})", "\\2", final_answer) + + # Normalize shorthand TeX: + # \fracab -> \frac{a}{b} + # \frac{abc}{bef} -> \frac{abc}{bef} + # \fracabc -> \frac{a}{b}c + # \sqrta -> \sqrt{a} + # \sqrtab -> sqrt{a}b + final_answer = re.sub(r"(frac)([^{])(.)", "frac{\\2}{\\3}", final_answer) + final_answer = re.sub(r"(sqrt)([^{])", "sqrt{\\2}", final_answer) + final_answer = final_answer.replace("$", "") + + # Normalize numbers + if final_answer.replace(",", "").isdigit(): + final_answer = final_answer.replace(",", "") + + return final_answer.strip() + + +def is_correct_minerva( + solution_str: str, gt: str, gt_need_extract: bool = False, answer_pattern: str = r"(?i)Answer\s*:\s*([^\n]+)" +) -> tuple[bool, str]: + """Check if the solution is correct according to Minerva criteria. + + Args: + solution_str: The solution string to check + gt: The ground truth answer + gt_need_extract: Whether the ground truth needs extraction + answer_pattern: Regex pattern to extract the answer + + Returns: + Tuple of (is_correct, normalized_prediction) + """ + # Extract answer from solution + match = re.findall(answer_pattern, solution_str) + extracted_answer = match[-1] if match else "[INVALID]" + pred = normalize_final_answer(extracted_answer) + + # Process ground truth + if gt_need_extract: + gt = normalize_final_answer(remove_boxed(last_boxed_only_string(gt))) + else: + gt = normalize_final_answer(gt) + + return (pred == gt), pred + + +def is_correct_strict_box( + pred: str, gt: str, pause_tokens_index: Optional[list[int]] = None +) -> tuple[int, Optional[str]]: + """Check if the prediction is correct using strict boxed answer criteria. + + Args: + pred: The prediction string + gt: The ground truth answer + pause_tokens_index: Indices of pause tokens + + Returns: + Tuple of (score, extracted_prediction) + """ + # Extract the relevant part of the prediction + if pause_tokens_index is not None: + assert len(pause_tokens_index) == 4 + pred = pred[pause_tokens_index[-1] - 100 :] + else: + pred = pred[-100:] + + # Extract and check the boxed answer + boxed_pred = last_boxed_only_string(pred) + extracted_pred = remove_boxed(boxed_pred) if boxed_pred is not None else None + + return 1 if (extracted_pred == gt) else -1, extracted_pred + + +def verify( + solution_str: str, answer: str, strict_box_verify: bool = False, pause_tokens_index: Optional[list[int]] = None +) -> bool: + """Verify if the solution is correct. + + Args: + solution_str: The solution string to verify + answer: The ground truth answer + strict_box_verify: Whether to use strict box verification + pause_tokens_index: Indices of pause tokens + + Returns: + True if the solution is correct, False otherwise + """ + if strict_box_verify: + correct, pred = is_correct_strict_box(solution_str, answer, pause_tokens_index) + return correct == 1, pred + + correct, pred = is_correct_minerva(solution_str, answer) + return correct, pred + + +def compute_score( + solution_str: str, + ground_truth: str, + strict_box_verify: bool = False, + pause_tokens_index: Optional[list[int]] = None, +) -> float: + """Compute the reward score for a solution. + + Args: + solution_str: The solution string + ground_truth: The ground truth answer + strict_box_verify: Whether to use strict box verification + pause_tokens_index: Indices of pause tokens + + Returns: + Reward score (1.0 for correct, -1.0 for incorrect) + """ + # Limit solution length for efficiency + solution_str = solution_str[-300:] # The longest answer in MATH-500 has 159 characters + + # Verify the solution + correct, pred = verify(solution_str, ground_truth, strict_box_verify, pause_tokens_index) + + reward = 1.0 if correct else -1.0 + acc = correct + + return { + "score": reward, + "acc": acc, + "pred": pred, + } diff --git a/verl/verl/utils/reward_score/math_reward.py b/verl/verl/utils/reward_score/math_reward.py new file mode 100644 index 0000000000000000000000000000000000000000..3fff7bc0400b0376217699f60b28e4a22b9285ac --- /dev/null +++ b/verl/verl/utils/reward_score/math_reward.py @@ -0,0 +1,224 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Adapted from https://github.com/EleutherAI/lm-evaluation-harness/blob/main/lm_eval/tasks/hendrycks_math/utils.py + + +def compute_score(solution_str, ground_truth) -> float: + retval = 0.0 + try: + string_in_last_boxed = last_boxed_only_string(solution_str) + if string_in_last_boxed is not None: + answer = remove_boxed(string_in_last_boxed) + if is_equiv(answer, ground_truth): + retval = 1.0 + except Exception as e: + print(e) + + return retval + + +# string normalization from https://github.com/EleutherAI/lm-evaluation-harness/blob/master/lm_eval/tasks/hendrycks_math.py +def is_equiv(str1, str2, verbose=False): + if str1 is None and str2 is None: + print("WARNING: Both None") + return True + if str1 is None or str2 is None: + return False + + try: + ss1 = strip_string(str1) + ss2 = strip_string(str2) + if verbose: + print(ss1, ss2) + return ss1 == ss2 + except Exception: + return str1 == str2 + + +def remove_boxed(s): + if "\\boxed " in s: + left = "\\boxed " + assert s[: len(left)] == left + return s[len(left) :] + + left = "\\boxed{" + + assert s[: len(left)] == left + assert s[-1] == "}" + + return s[len(left) : -1] + + +def last_boxed_only_string(string): + idx = string.rfind("\\boxed") + if "\\boxed " in string: + return "\\boxed " + string.split("\\boxed ")[-1].split("$")[0] + if idx < 0: + idx = string.rfind("\\fbox") + if idx < 0: + return None + + i = idx + right_brace_idx = None + num_left_braces_open = 0 + while i < len(string): + if string[i] == "{": + num_left_braces_open += 1 + if string[i] == "}": + num_left_braces_open -= 1 + if num_left_braces_open == 0: + right_brace_idx = i + break + i += 1 + + retval = None if right_brace_idx is None else string[idx : right_brace_idx + 1] + + return retval + + +def fix_fracs(string): + substrs = string.split("\\frac") + new_str = substrs[0] + if len(substrs) > 1: + substrs = substrs[1:] + for substr in substrs: + new_str += "\\frac" + if substr[0] == "{": + new_str += substr + else: + try: + assert len(substr) >= 2 + except: # noqa: E722 + return string + a = substr[0] + b = substr[1] + if b != "{": + if len(substr) > 2: + post_substr = substr[2:] + new_str += "{" + a + "}{" + b + "}" + post_substr + else: + new_str += "{" + a + "}{" + b + "}" + else: + if len(substr) > 2: + post_substr = substr[2:] + new_str += "{" + a + "}" + b + post_substr + else: + new_str += "{" + a + "}" + b + string = new_str + return string + + +def fix_a_slash_b(string): + if len(string.split("/")) != 2: + return string + a = string.split("/")[0] + b = string.split("/")[1] + try: + a = int(a) + b = int(b) + assert string == "{}/{}".format(a, b) + new_string = "\\frac{" + str(a) + "}{" + str(b) + "}" + return new_string + except: # noqa: E722 + return string + + +def remove_right_units(string): + # "\\text{ " only ever occurs (at least in the val set) when describing units + if "\\text{ " in string: + splits = string.split("\\text{ ") + assert len(splits) == 2 + return splits[0] + else: + return string + + +def fix_sqrt(string): + if "\\sqrt" not in string: + return string + splits = string.split("\\sqrt") + new_string = splits[0] + for split in splits[1:]: + if split[0] != "{": + a = split[0] + new_substr = "\\sqrt{" + a + "}" + split[1:] + else: + new_substr = "\\sqrt" + split + new_string += new_substr + return new_string + + +def strip_string(string): + # linebreaks + string = string.replace("\n", "") + + # remove inverse spaces + string = string.replace("\\!", "") + + # replace \\ with \ + string = string.replace("\\\\", "\\") + + # replace tfrac and dfrac with frac + string = string.replace("tfrac", "frac") + string = string.replace("dfrac", "frac") + + # remove \left and \right + string = string.replace("\\left", "") + string = string.replace("\\right", "") + + # Remove circ (degrees) + string = string.replace("^{\\circ}", "") + string = string.replace("^\\circ", "") + + # remove dollar signs + string = string.replace("\\$", "") + + # remove units (on the right) + string = remove_right_units(string) + + # remove percentage + string = string.replace("\\%", "") + string = string.replace("\%", "") # noqa: W605 + + # " 0." equivalent to " ." and "{0." equivalent to "{." Alternatively, add "0" if "." is the start of the string + string = string.replace(" .", " 0.") + string = string.replace("{.", "{0.") + # if empty, return empty string + if len(string) == 0: + return string + if string[0] == ".": + string = "0" + string + + # to consider: get rid of e.g. "k = " or "q = " at beginning + if len(string.split("=")) == 2 and len(string.split("=")[0]) <= 2: + string = string.split("=")[1] + + # fix sqrt3 --> sqrt{3} + string = fix_sqrt(string) + + # remove spaces + string = string.replace(" ", "") + + # \frac1b or \frac12 --> \frac{1}{b} and \frac{1}{2}, etc. Even works with \frac1{72} (but not \frac{72}1). + # Also does a/b --> \\frac{a}{b} + string = fix_fracs(string) + + # manually change 0.5 --> \frac{1}{2} + if string == "0.5": + string = "\\frac{1}{2}" + + # NOTE: X/Y changed to \frac{X}{Y} in dataset, but in simple cases fix in case the model output is X/Y + string = fix_a_slash_b(string) + + return string diff --git a/verl/verl/utils/reward_score/math_verify.py b/verl/verl/utils/reward_score/math_verify.py new file mode 100644 index 0000000000000000000000000000000000000000..c1ce7c1a483eaf07316afa7d8b7b8becb1bdc51b --- /dev/null +++ b/verl/verl/utils/reward_score/math_verify.py @@ -0,0 +1,39 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +try: + from math_verify.errors import TimeoutException + from math_verify.metric import math_metric + from math_verify.parser import ExprExtractionConfig, LatexExtractionConfig +except ImportError: + print("To use Math-Verify, please install it first by running `pip install math-verify`.") + + +def compute_score(model_output: str, ground_truth: str, timeout_score: float = 0) -> bool: + verify_func = math_metric( + gold_extraction_target=(LatexExtractionConfig(),), + pred_extraction_target=(ExprExtractionConfig(), LatexExtractionConfig()), + ) + ret_score = 0.0 + + # Wrap the ground truth in \boxed{} format for verification + ground_truth_boxed = "\\boxed{" + ground_truth + "}" + try: + ret_score, _ = verify_func([ground_truth_boxed], [model_output]) + except Exception: + pass + except TimeoutException: + ret_score = timeout_score + + return ret_score diff --git a/verl/verl/utils/reward_score/prime_math/__init__.py b/verl/verl/utils/reward_score/prime_math/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..04fd146fc5c3a29dcbe776de15ef555de05249a3 --- /dev/null +++ b/verl/verl/utils/reward_score/prime_math/__init__.py @@ -0,0 +1,411 @@ +# Copyright 2024 PRIME team and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Answer checker API that uses sympy to simplify expressions and check for equality. + +Call grade_answer(given_answer: str, ground_truth: str). + +FROM: https://github.com/openai/prm800k/blob/main/prm800k/grading/grader.py +""" + +import contextlib +import math +import re + +import sympy +from pylatexenc import latex2text +from sympy.parsing import sympy_parser + +from verl.utils.py_functional import timeout_limit + +from . import math_normalize +from .grader import math_equal + +# import math_normalize +# from grader import math_equal + +# sympy might hang -- we don't care about trying to be lenient in these cases +BAD_SUBSTRINGS = ["^{", "^("] +BAD_REGEXES = ["\^[0-9]+\^", "\^[0-9][0-9]+"] +TUPLE_CHARS = "()[]" + + +def _sympy_parse(expr: str): + """Parses an expression with sympy.""" + py_expr = expr.replace("^", "**") + return sympy_parser.parse_expr( + py_expr, + transformations=(sympy_parser.standard_transformations + (sympy_parser.implicit_multiplication_application,)), + ) + + +def _parse_latex(expr: str) -> str: + """Attempts to parse latex to an expression sympy can read.""" + expr = expr.replace("\\tfrac", "\\frac") + expr = expr.replace("\\dfrac", "\\frac") + expr = expr.replace("\\frac", " \\frac") # Play nice with mixed numbers. + expr = latex2text.LatexNodes2Text().latex_to_text(expr) + + # Replace the specific characters that this parser uses. + expr = expr.replace("√", "sqrt") + expr = expr.replace("π", "pi") + expr = expr.replace("∞", "inf") + expr = expr.replace("∪", "U") + expr = expr.replace("·", "*") + expr = expr.replace("×", "*") + + return expr.strip() + + +def _is_float(num: str) -> bool: + try: + float(num) + return True + except ValueError: + return False + + +def _is_int(x: float) -> bool: + try: + return abs(x - int(round(x))) <= 1e-7 + except Exception: + return False + + +def _is_frac(expr: str) -> bool: + return bool(re.search(r"^-?[0-9]+.?/0*[1-9][0-9]*.?$", expr)) + + +def _str_is_int(x: str) -> bool: + try: + x = _strip_properly_formatted_commas(x) + x = float(x) + return abs(x - int(round(x))) <= 1e-7 + except Exception: + return False + + +def _str_to_int(x: str) -> bool: + x = x.replace(",", "") + x = float(x) + return int(x) + + +def _inject_implicit_mixed_number(step: str): + """ + Automatically make a mixed number evalable + e.g. 7 3/4 => 7+3/4 + """ + p1 = re.compile("([0-9]) +([0-9])") + step = p1.sub("\\1+\\2", step) ## implicit mults + return step + + +def _strip_properly_formatted_commas(expr: str): + # We want to be careful because we don't want to strip tuple commas + p1 = re.compile("(\d)(,)(\d\d\d)($|\D)") + while True: + next_expr = p1.sub("\\1\\3\\4", expr) + if next_expr == expr: + break + expr = next_expr + return next_expr + + +def _normalize(expr: str) -> str: + """Normalize answer expressions.""" + if expr is None: + return None + + # Remove enclosing `\text{}`. + m = re.search("^\\\\text\{(?P.+?)\}$", expr) + if m is not None: + expr = m.group("text") + + expr = expr.replace("\\%", "%") + expr = expr.replace("\\$", "$") + expr = expr.replace("$", "") + expr = expr.replace("%", "") + expr = expr.replace(" or ", " , ") + expr = expr.replace(" and ", " , ") + + expr = expr.replace("million", "*10^6") + expr = expr.replace("billion", "*10^9") + expr = expr.replace("trillion", "*10^12") + + for unit in [ + "degree", + "cm", + "centimeter", + "meter", + "mile", + "second", + "minute", + "hour", + "day", + "week", + "month", + "year", + "foot", + "feet", + "inch", + "yard", + "liter", + ]: + expr = re.sub(f"{unit}(es)?(s)? *(\^[0-9]+)?", "", expr) + expr = re.sub("\^ *\\\\circ", "", expr) + + if len(expr) > 0 and expr[0] == "{" and expr[-1] == "}": + expr = expr[1:-1] + + expr = re.sub(",\\\\! *", "", expr) + if _is_float(expr) and _is_int(float(expr)): + expr = str(int(round(float(expr)))) + if "\\" in expr: + with contextlib.suppress(Exception): + expr = _parse_latex(expr) + + # edge case with mixed numbers and negative signs + expr = re.sub("- *", "-", expr) + + expr = _inject_implicit_mixed_number(expr) + + # don't be case sensitive for text answers + expr = expr.lower() + + if _str_is_int(expr): + expr = str(_str_to_int(expr)) + + return expr + + +def count_unknown_letters_in_expr(expr: str): + expr = expr.replace("sqrt", "") + expr = expr.replace("frac", "") + letters_in_expr = set([x for x in expr if x.isalpha()]) + return len(letters_in_expr) + + +def should_allow_eval(expr: str): + # we don't want to try parsing unknown text or functions of more than two variables + if count_unknown_letters_in_expr(expr) > 2: + return False + + for bad_string in BAD_SUBSTRINGS: + if bad_string in expr: + return False + + return all(re.search(bad_regex, expr) is None for bad_regex in BAD_REGEXES) + + +@timeout_limit(seconds=10) +def are_equal_under_sympy(ground_truth_normalized: str, given_normalized: str): + are_equal = False + try: + expr = f"({ground_truth_normalized})-({given_normalized})" + if should_allow_eval(expr): + sympy_diff = _sympy_parse(expr) + simplified = sympy.simplify(sympy_diff) + if simplified == 0: + are_equal = True + except Exception: + pass + return are_equal + + +def split_tuple(expr: str): + """ + Split the elements in a tuple/interval, while handling well-formatted commas in large numbers + """ + expr = _strip_properly_formatted_commas(expr) + if len(expr) == 0: + return [] + if ( + len(expr) > 2 + and expr[0] in TUPLE_CHARS + and expr[-1] in TUPLE_CHARS + and all([ch not in expr[1:-1] for ch in TUPLE_CHARS]) + ): + elems = [elem.strip() for elem in expr[1:-1].split(",")] + else: + elems = [expr] + return elems + + +def grade_answer(given_answer: str, ground_truth: str) -> bool: + """ + The answer will be considered correct if: + (a) it normalizes to the same string as the ground truth answer + OR + (b) sympy can simplify the difference between the expressions to 0 + """ + if given_answer is None: + return False + + ground_truth_normalized_mathd = math_normalize.normalize_answer(ground_truth) + given_answer_normalized_mathd = math_normalize.normalize_answer(given_answer) + + # be at least as lenient as mathd + if ground_truth_normalized_mathd == given_answer_normalized_mathd: + return True + + ground_truth_normalized = _normalize(ground_truth) + given_normalized = _normalize(given_answer) + + if ground_truth_normalized is None: + return False + + if ground_truth_normalized == given_normalized: + return True + + if len(given_normalized) == 0: + return False + + ground_truth_elems = split_tuple(ground_truth_normalized) + given_elems = split_tuple(given_normalized) + + if ( + len(ground_truth_elems) > 1 + and (ground_truth_normalized[0] != given_normalized[0] or ground_truth_normalized[-1] != given_normalized[-1]) + or len(ground_truth_elems) != len(given_elems) + ): + is_correct = False + else: + for ground_truth_elem, given_elem in zip(ground_truth_elems, given_elems, strict=True): + if _is_frac(ground_truth_elem) and _is_frac(given_elem): + # if fractions aren't reduced, then shouldn't be marked as correct + # so, we don't want to allow sympy.simplify in this case + is_correct = ground_truth_elem == given_elem + elif _str_is_int(ground_truth_elem) != _str_is_int(given_elem): + # if the ground truth answer is an integer, we require the given answer to be a strict match + # (no sympy.simplify) + is_correct = False + else: + try: + is_correct = are_equal_under_sympy(ground_truth_elem, given_elem) + except Exception as e: + # if there's an error, we'll just say it's not correct + is_correct = False + print(f"Error: {e} from are_equal_under_sympy, {ground_truth_elem}, {given_elem}") + if not is_correct: + break + + return is_correct + + +def remove_boxed(s): + left = "\\boxed{" + try: + assert s[: len(left)] == left + assert s[-1] == "}" + return s[len(left) : -1] + except Exception: + return None + + +def _last_boxed_only_string(string): + idx = string.rfind("\\boxed") + if idx < 0: + idx = string.rfind("\\fbox") + if idx < 0: + return None + + i = idx + left_brace_idx = None + right_brace_idx = None + num_left_braces_open = 0 + while i < len(string): + if string[i] == "{": + num_left_braces_open += 1 + if left_brace_idx is None: + left_brace_idx = i + elif string[i] == "}": + num_left_braces_open -= 1 + if num_left_braces_open == 0: + right_brace_idx = i + break + + i += 1 + + if left_brace_idx is None or right_brace_idx is None: + return None + + return string[left_brace_idx + 1 : right_brace_idx].strip() + + +def match_answer(response): + is_matched = False + for ans_marker in ["answer:", "answer is", "answers are"]: + ans_idx = response.lower().rfind(ans_marker) + if ans_idx != -1: + is_matched = True + response = response[ans_idx + len(ans_marker) :].strip() + if response.endswith("\n"): + response = response[:-2] + + for ans_marker in ["is answer", "is the answer", "are answers", "are the answers"]: + ans_idx = response.lower().rfind(ans_marker) + if ans_idx != -1: + is_matched = True + response = response[:ans_idx].strip() + if response.endswith("\n"): + response = response[:-2] + + # Find boxed + ans_boxed = _last_boxed_only_string(response) + if ans_boxed: + is_matched = True + response = ans_boxed + + if ". " in response: + dot_idx = response.lower().rfind(". ") + if dot_idx != -1: + response = response[:dot_idx].strip() + + for ans_marker in ["be ", "is ", "are ", "=", ": ", "get ", "be\n", "is\n", "are\n", ":\n", "get\n"]: + ans_idx = response.lower().rfind(ans_marker) + if ans_idx != -1: + is_matched = True + response = response[ans_idx + len(ans_marker) :].strip() + if response.endswith("\n"): + response = response[:-2] + + is_matched = is_matched if any([c.isdigit() for c in response]) else False # answer must have a digit + # Grade + return is_matched, response + + +def compute_score(model_output: str, ground_truth: str) -> bool: + model_output = str(model_output) + ground_truth = str(ground_truth) + + is_matched, extracted_model_output = match_answer(model_output) + format_correctness = "Step 2:" in model_output and "\\box" in model_output + + # grade simple algebra questions. if succeeded, return; otherwise, proceed to more complex grading + if grade_answer(extracted_model_output, ground_truth): + return True, True, extracted_model_output + + try: + if "\pi" in extracted_model_output or "\pi" in ground_truth: + equivs = [] + for pi in [math.pi, 3.14]: + equivs.append(math_equal(extracted_model_output, ground_truth, timeout=True, pi=pi)) + is_correct = any(equivs) + else: + is_correct = math_equal(extracted_model_output, ground_truth, timeout=True) + except Exception: + is_correct = False + + return is_correct, format_correctness, extracted_model_output diff --git a/verl/verl/utils/reward_score/prime_math/grader.py b/verl/verl/utils/reward_score/prime_math/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..d060584d6a24316cef2f9da57a63f5d1809d50cc --- /dev/null +++ b/verl/verl/utils/reward_score/prime_math/grader.py @@ -0,0 +1,384 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Copyright (c) Microsoft Corporation. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE + +# Copyright (c) 2023 OpenAI +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Copyright (c) 2021 Dan Hendrycks +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Copyright 2024 PRIME team and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +This logic is largely copied from the Hendrycks' MATH release (math_equivalence), and borrowed from: +- https://github.com/microsoft/ToRA/blob/main/src/eval/grader.py +- https://github.com/microsoft/ProphetNet/tree/master/CRITIC +- https://github.com/openai/prm800k +""" + +import contextlib +import math +import re +from math import isclose + +# sympy related +from sympy import N, simplify +from sympy.parsing.latex import parse_latex +from sympy.parsing.sympy_parser import parse_expr + +# verl related +from verl.utils.py_functional import timeout_limit + + +def is_digit(s): + try: + if "{,}" in str(s): + num = float(str(s).replace("{,}", "")) + return True, num + + num = float(str(s).replace(",", "")) + return True, num + except ValueError: + return False, None + + +def normalize(answer, pi) -> str: + # checking if answer is $ and removing $ in that case to compare + if isinstance(answer, str) and bool(re.match(r"\$\d+(\.\d+)?", answer)): + return answer[1:] + + # checking if answer is % or \\% and removing % + if isinstance(answer, str) and ( + bool(re.match(r"^\d+(\.\d+)?%$", answer)) or bool(re.match(r"^\d+(\.\d+)?\\%$", answer)) + ): + return answer.replace("\\%", "").replace("%", "") + + # handle base + answer = handle_base(answer) + + # handle pi + answer = handle_pi(answer, pi) + + return answer + + +def handle_base(x) -> str: + if isinstance(x, str) and "_" in x: + # Due to base + x = x.split("_")[0] + x = float(x) + return int(x) + return x + + +def handle_pi(string, pi): + if isinstance(string, str) and "\pi" in string: + # Find the first occurrence of "\pi" + idx = string.find("\pi") + + # Iterate over the string and find all occurrences of "\pi" with a valid previous character + while idx != -1: + if idx > 0 and string[idx - 1].isdigit(): + # Replace "\pi" with "*math.pi" if the previous character is a digit + string = string[:idx] + f"*{pi}" + string[idx + 3 :] + else: + # Replace "\pi" with "1*math.pi" if the previous character is not a digit + string = string[:idx] + f"1*{pi}" + string[idx + 3 :] + + # Find the next occurrence of "\pi" + idx = string.find("\pi", idx + 1) + + # Evaluate the expression using eval() function + with contextlib.suppress(Exception): + string = eval(string) + + return string + + +def math_equal( + prediction: bool | float | str, + reference: float | str, + include_percentage: bool = True, + tolerance: float = 1e-4, + timeout: float = 10.0, + pi: float = math.pi, +) -> bool: + """ + Exact match of math if and only if: + 1. numerical equal: both can convert to float and are equal + 2. symbolic equal: both can convert to sympy expression and are equal + """ + + prediction = normalize(prediction, pi) + reference = normalize(reference, pi) + + if isinstance(prediction, str) and len(prediction) > 1000: # handling weird corner-cases + prediction = prediction[:1000] + + # 0. string comparison + if isinstance(prediction, str) and isinstance(reference, str): + if prediction.strip().lower() == reference.strip().lower(): + return True + if prediction.replace(" ", "") == reference.replace(" ", ""): + return True + + try: # 1. numerical equal + if is_digit(prediction)[0] and is_digit(reference)[0]: + prediction = is_digit(prediction)[1] + reference = is_digit(reference)[1] + # number questions + gt_result = [reference / 100, reference, reference * 100] if include_percentage else [reference] + for item in gt_result: + try: + if isclose(item, prediction, rel_tol=tolerance): + return True + except Exception: + continue + return False + except Exception: + pass + + if not prediction and prediction not in [0, False]: + return False + + # 2. symbolic equal + reference = str(reference).strip() + prediction = str(prediction).strip() + + ## deal with [], (), {} + prediction = format_intervals(prediction) + + pred_str, ref_str = prediction, reference + if (prediction.startswith("[") and prediction.endswith("]") and not reference.startswith("(")) or ( + prediction.startswith("(") and prediction.endswith(")") and not reference.startswith("[") + ): + pred_str = pred_str.strip("[]()") + ref_str = ref_str.strip("[]()") + for s in ["{", "}", "(", ")"]: + ref_str = ref_str.replace(s, "") + pred_str = pred_str.replace(s, "") + if pred_str == ref_str: + return True + + ## [a, b] vs. [c, d], return a==c and b==d + if ( + prediction + and reference + and prediction[0] in "([" + and prediction[-1] in ")]" + and prediction[0] == reference[0] + and prediction[-1] == reference[-1] + ): + pred_parts = prediction[1:-1].split(",") + ref_parts = reference[1:-1].split(",") + if len(pred_parts) == len(ref_parts) and all( + [ + math_equal(pred_pt, ref_pt, include_percentage, tolerance) + for pred_pt, ref_pt in zip(pred_parts, ref_parts, strict=True) + ] + ): + return True + + if "," in prediction and "," in reference: + pred_parts = [item.strip() for item in prediction.split(",")] + ref_parts = [item.strip() for item in reference.split(",")] + + if len(pred_parts) == len(ref_parts): + return bool( + all( + [ + math_equal(pred_parts[i], ref_parts[i], include_percentage, tolerance) + for i in range(len(pred_parts)) + ] + ) + ) + + # if we have point == tuple of values + if prediction.startswith("Point") and reference[0] == "(" and reference[-1] == ")": + pred_parts = prediction[prediction.find("(") + 1 : -1].split(",") + ref_parts = reference[1:-1].split(",") + if len(pred_parts) == len(ref_parts) and all( + [ + math_equal(pred_pt, ref_pt, include_percentage, tolerance) + for pred_pt, ref_pt in zip(pred_parts, ref_parts, strict=False) + ] + ): + return True + + # if reference is a matrix + if "\begin{pmatrix}" in reference and prediction.startswith("Matrix"): + try: + pred_matrix = parse_expr(prediction) + ref_matrix_items = reference.split()[1:-1:2] + if len(pred_matrix) == len(ref_matrix_items) and all( + [ + math_equal(pred, ref, include_percentage, tolerance) + for ref, pred in zip(ref_matrix_items, pred_matrix, strict=False) + ] + ): + return True + except Exception: + pass + elif "\begin{pmatrix}" in reference and prediction.startswith("[") and prediction.endswith("]"): + if isinstance(eval(prediction), list): + try: + pred_matrix = eval(prediction) + # ref_matrix_items = reference.split()[1:-1:2] + ref_matrix_items = ( + reference.lstrip("\\begin{pmatrix}") # noqa: B005 + .lstrip("\begin{pmatrix}") + .rstrip("\\end{pmatrix}") + .rstrip("\end{pmatrix}") + ) # noqa: B005 + ref_matrix_items = ref_matrix_items.split("\\") + ref_matrix_items = [row.split("&") if "&" in row else row for row in ref_matrix_items] + if len(pred_matrix) == len(ref_matrix_items) and all( + [ + math_equal(pred, ref, include_percentage, tolerance) + for ref, pred in zip(ref_matrix_items, pred_matrix, strict=False) + ] + ): + return True + except Exception: + pass + + return symbolic_equal(prediction, reference, tolerance, timeout) + + +def symbolic_equal(a, b, tolerance, timeout=10.0): + def _parse(s): + for f in [parse_expr, parse_latex]: + try: + with timeout_limit(seconds=timeout): + return f(s) + except TimeoutError: + print(f"Parsing timed out for {s}") + continue + except Exception: + continue + return s + + a = _parse(a) + b = _parse(b) + + try: + with timeout_limit(seconds=timeout): + if simplify(a - b) == 0: + return True + except TimeoutError: + print(f"Simplification timed out for {a} - {b}") + pass + except Exception: + pass + + try: + with timeout_limit(seconds=timeout): + if isclose(N(a), N(b), rel_tol=tolerance): + return True + except TimeoutError: + print(f"Numerical evaluation timed out for {a}, {b}") + pass + except Exception: + pass + return False + + +def format_intervals(prediction): + patterns = { + "Interval(": r"^Interval\((.*)\)$", + "Interval.Ropen(": r"^Interval\.Ropen\((.*)\)$", + "Interval.Lopen(": r"^Interval\.Lopen\((.*)\)$", + "Interval.open(": r"^Interval\.open\((.*)\)$", + } + + for key, pattern in patterns.items(): + match = re.match(pattern, prediction) + if match: + inner_content = match.group(1) + + if key == "Interval(": # Intarval(a, b) == [a, b] + return f"[{inner_content}]" + elif key == "Interval.Ropen(": # Intarval.Ropen(a, b) == [a, b) + return f"[{inner_content})" + elif key == "Interval.Lopen(": # Intarval.Lopen(a, b) == (a, b] + return f"({inner_content}]" + elif key == "Interval.open(": # Intarval.open(a, b) == (a, b) + return f"({inner_content})" + + return prediction diff --git a/verl/verl/utils/reward_score/prime_math/math_normalize.py b/verl/verl/utils/reward_score/prime_math/math_normalize.py new file mode 100644 index 0000000000000000000000000000000000000000..74d94cc41cd7cca3c3e3051751c56f9140a775fa --- /dev/null +++ b/verl/verl/utils/reward_score/prime_math/math_normalize.py @@ -0,0 +1,192 @@ +# Copyright 2024 PRIME team and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Copyright (c) 2021 Dan Hendrycks +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +""" +This logic is largely copied from the Hendrycks' MATH release (math_equivalence). + +From: https://github.com/openai/prm800k/blob/main/prm800k/grading/math_normalize.py +""" + +import re +from typing import Optional + + +def normalize_answer(answer: Optional[str]) -> Optional[str]: + if answer is None: + return None + answer = answer.strip() + try: + # Remove enclosing `\text{}`. + m = re.search("^\\\\text\{(?P.+?)\}$", answer) + if m is not None: + answer = m.group("text").strip() + return _strip_string(answer) + except: # noqa: E722 + return answer + + +def _fix_fracs(string): + substrs = string.split("\\frac") + new_str = substrs[0] + if len(substrs) > 1: + substrs = substrs[1:] + for substr in substrs: + new_str += "\\frac" + if substr[0] == "{": + new_str += substr + else: + try: + assert len(substr) >= 2 + except: # noqa: E722 + return string + a = substr[0] + b = substr[1] + if b != "{": + if len(substr) > 2: + post_substr = substr[2:] + new_str += "{" + a + "}{" + b + "}" + post_substr + else: + new_str += "{" + a + "}{" + b + "}" + else: + if len(substr) > 2: + post_substr = substr[2:] + new_str += "{" + a + "}" + b + post_substr + else: + new_str += "{" + a + "}" + b + string = new_str + return string + + +def _fix_a_slash_b(string): + if len(string.split("/")) != 2: + return string + a = string.split("/")[0] + b = string.split("/")[1] + try: + a = int(a) + b = int(b) + assert string == "{}/{}".format(a, b) + new_string = "\\frac{" + str(a) + "}{" + str(b) + "}" + return new_string + except: # noqa: E722 + return string + + +def _remove_right_units(string): + # "\\text{ " only ever occurs (at least in the val set) when describing units + if "\\text{ " in string: + splits = string.split("\\text{ ") + assert len(splits) == 2 + return splits[0] + else: + return string + + +def _fix_sqrt(string): + if "\\sqrt" not in string: + return string + splits = string.split("\\sqrt") + new_string = splits[0] + for split in splits[1:]: + if split[0] != "{": + a = split[0] + new_substr = "\\sqrt{" + a + "}" + split[1:] + else: + new_substr = "\\sqrt" + split + new_string += new_substr + return new_string + + +def _strip_string(string): + # linebreaks + string = string.replace("\n", "") + + # remove inverse spaces + string = string.replace("\\!", "") + + # replace \\ with \ + string = string.replace("\\\\", "\\") + + # replace tfrac and dfrac with frac + string = string.replace("tfrac", "frac") + string = string.replace("dfrac", "frac") + + # remove \left and \right + string = string.replace("\\left", "") + string = string.replace("\\right", "") + + # Remove circ (degrees) + string = string.replace("^{\\circ}", "") + string = string.replace("^\\circ", "") + + # remove dollar signs + string = string.replace("\\$", "") + + # remove units (on the right) + string = _remove_right_units(string) + + # remove percentage + string = string.replace("\\%", "") + string = string.replace("\%", "") + + # " 0." equivalent to " ." and "{0." equivalent to "{." Alternatively, add "0" if "." is the start of the string + string = string.replace(" .", " 0.") + string = string.replace("{.", "{0.") + # if empty, return empty string + if len(string) == 0: + return string + if string[0] == ".": + string = "0" + string + + # to consider: get rid of e.g. "k = " or "q = " at beginning + if len(string.split("=")) == 2 and len(string.split("=")[0]) <= 2: + string = string.split("=")[1] + + # fix sqrt3 --> sqrt{3} + string = _fix_sqrt(string) + + # remove spaces + string = string.replace(" ", "") + + # \frac1b or \frac12 --> \frac{1}{b} and \frac{1}{2}, etc. Even works with \frac1{72} (but not \frac{72}1). + # Also does a/b --> \\frac{a}{b} + string = _fix_fracs(string) + + # manually change 0.5 --> \frac{1}{2} + if string == "0.5": + string = "\\frac{1}{2}" + + # NOTE: X/Y changed to \frac{X}{Y} in dataset, but in simple cases fix in case the model output is X/Y + string = _fix_a_slash_b(string) + + return string diff --git a/verl/verl/utils/reward_score/sandbox_fusion/utils.py b/verl/verl/utils/reward_score/sandbox_fusion/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..7b6c27952e0cd1aadd6d798a572ecb6d38bc2ec2 --- /dev/null +++ b/verl/verl/utils/reward_score/sandbox_fusion/utils.py @@ -0,0 +1,578 @@ +# Copyright 2025 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import concurrent.futures # <-- Import concurrent.futures +import json +import logging +import os +import threading +import time +import traceback +import uuid +from typing import Any, Optional + +import requests + +DEFAULT_TIMEOUT = 10 # Default compile and run timeout +MAX_RETRIES = 3 +INITIAL_RETRY_DELAY = 1 +API_TIMEOUT = 10 + +logger = logging.getLogger(__name__) + +# Define supported languages list (optional, for documentation or validation) +SUPPORTED_LANGUAGES = [ + "python", + "cpp", + "nodejs", + "go", + "go_test", + "java", + "php", + "csharp", + "bash", + "typescript", + "sql", + "rust", + "cuda", + "lua", + "R", + "perl", + "D_ut", + "ruby", + "scala", + "julia", + "pytest", + "junit", + "kotlin_script", + "jest", + "verilog", + "python_gpu", + "lean", + "swift", + "racket", +] + + +def call_sandbox_api( + sandbox_fusion_url: str, + code: str, + stdin: Optional[str], + compile_timeout: int, + run_timeout: int, + memory_limit_mb: int, + language: str = "python", +) -> tuple[Optional[dict[str, Any]], Optional[str]]: # <-- Remove request_id parameter + """ + Calls the remote sandbox API to execute code with retry logic for Gateway Timeout, + using increasing delay between retries. Logs internal calls with a unique ID. + + Args: + sandbox_fusion_url: The URL of the sandbox fusion API. + code: The code string to execute. + stdin: The standard input string. + compile_timeout: Compile timeout in seconds. + run_timeout: Run timeout in seconds. + language: The programming language of the code (e.g., "python", "cpp", "java"). Defaults to "python". + + Returns: + A tuple (response_json, error_message). + If successful, response_json is the API's returned JSON object, error_message is None. + If failed after retries, response_json is None, error_message contains the error information. + """ + request_id = str(uuid.uuid4()) # <-- Generate request_id internally + log_prefix = f"[Request ID: {request_id}] " # <-- Create log prefix + + if language not in SUPPORTED_LANGUAGES: + error_msg = f"{log_prefix}Unsupported language: {language}" + logger.error(error_msg) + return None, error_msg + + payload = json.dumps( + { + "compile_timeout": compile_timeout, + "run_timeout": run_timeout, + "code": code, + "stdin": stdin, + "memory_limit_MB": memory_limit_mb, + "language": language, # Use the passed language parameter + "files": {}, + "fetch_files": [], + } + ) + headers = {"Content-Type": "application/json", "Accept": "application/json"} + # Calculate a reasonable request timeout based on compile/run timeouts plus a buffer + request_timeout = compile_timeout + run_timeout + API_TIMEOUT + + last_error = None # Store the last error encountered + + for attempt in range(MAX_RETRIES): + try: + logger.info( + f"{log_prefix}Attempt {attempt + 1}/{MAX_RETRIES}: Calling sandbox API at {sandbox_fusion_url}" + ) # <-- Use internal log_prefix + response = requests.post( + sandbox_fusion_url, + headers=headers, + data=payload, + timeout=request_timeout, # Use the calculated timeout + ) + + # Check for Gateway Timeout (504) specifically for retrying + if response.status_code == 504: + last_error = ( + f"{log_prefix}API Request Error: Gateway Timeout (504) on attempt " + f"{attempt + 1}/{MAX_RETRIES}" + ) # <-- Use internal log_prefix + logger.warning(last_error) + if attempt < MAX_RETRIES - 1: # Don't sleep after the last attempt + # Calculate increasing delay (e.g., 1s, 2s, 4s, ...) or (1s, 2s, 3s, ...) + # Simple linear increase: delay = INITIAL_RETRY_DELAY * (attempt + 1) + # Exponential backoff: delay = INITIAL_RETRY_DELAY * (2 ** attempt) + delay = INITIAL_RETRY_DELAY * (attempt + 1) # Using linear increase for simplicity + logger.info(f"{log_prefix}Retrying after {delay} seconds...") # <-- Use internal log_prefix + time.sleep(delay) + continue # Go to the next retry attempt + + # Check for other HTTP errors (e.g., 4xx, other 5xx) + response.raise_for_status() + + # If successful (status code 2xx) + logger.info( + f"{log_prefix}Sandbox API call successful on attempt {attempt + 1}" + ) # <-- Use internal log_prefix + return response.json(), None + + except requests.exceptions.RequestException as e: + last_error = f"{log_prefix}API Request Error: {e}" # <-- Use internal log_prefix + break # Exit retry loop on non-504 request errors + except json.JSONDecodeError as e: + raw_response_text = response.text if "response" in locals() else "N/A" + last_error = f"{log_prefix}API Response JSON Decode Error: {e}" # <-- Use internal log_prefix + break # Exit retry loop on JSON decode errors + except Exception as e: + last_error = f"{log_prefix}Unexpected Error: {e}" # <-- Use internal log_prefix + break # Exit retry loop on other unexpected errors + + # If loop finishes without returning success, return the last recorded error + logger.error(f"{log_prefix}Sandbox API call failed. Last error: {last_error}") # <-- Use internal log_prefix + # Return the error message without the prefix, as the caller doesn't need the internal ID + # Ensure API call failure returns error message, leading to -1 in check_correctness + return None, last_error.replace(log_prefix, "API Call Failed: ") if last_error else "API Call Failed after retries" + + +def _process_single_case( + case_index: int, + stdin_data: Any, + expected_output: Any, + sandbox_fusion_url: str, + generation: str, + timeout: int, + memory_limit_mb: int, + language: str, + concurrent_semaphore: Optional[threading.Semaphore] = None, + fn_name: Optional[str] = None, +) -> tuple[int, dict[str, Any]]: + """Helper function to process a single test case.""" + api_response = None + error_msg = None + logger.info(f"Processing test case {case_index + 1}.") + + current_generation_code = generation + + if fn_name and language == "python": + # Wrapper assumes stdin_data is a JSON string for function arguments. + wrapper_code = f""" +import traceback +from string import * +from re import * +from datetime import * +from collections import * +from heapq import * +from bisect import * +from copy import * +from math import * +from random import * +from statistics import * +from itertools import * +from functools import * +from operator import * +from io import * +from sys import * +from json import * +from builtins import * +from typing import * +import string +import re +import datetime +import collections +import heapq +import bisect +import copy +import math +import random +import statistics +import itertools +import functools +import operator +import io +import sys +import json + +# === User's Original Code START === +{generation} +# === User's Original Code END === + +_SANDBOX_FN_NAME = "{fn_name}" + +def _execute_user_function(): + # --- Input Parsing --- + _raw_input_str = sys.stdin.read() + _args = [] + if _raw_input_str.strip(): # If there's input + try: + _args = [json.loads(line) for line in _raw_input_str.split('\\n')] + except json.JSONDecodeError as _je: + sys.stderr.write(f"WrapperError: Invalid JSON input for '{{_SANDBOX_FN_NAME}}': {{_je}}\\nInput was: " + f"{{_raw_input_str[:200]}}\\n") + return None, True # result, error_occurred + + # --- Function Location and Execution --- + try: + _target_callable = None + # Try global scope first + if _SANDBOX_FN_NAME in globals(): + _target_callable = globals()[_SANDBOX_FN_NAME] + # Else, if 'Solution' class exists, try to get its method + elif 'Solution' in globals(): + _Solution_class = globals()['Solution'] + # Attempt to instantiate and get method. + # Errors (e.g., Solution not a class, instantiation fails, method missing) + # will be caught by the broad except block below. + _solution_instance = _Solution_class() + _target_callable = getattr(_solution_instance, _SANDBOX_FN_NAME) + + if not _target_callable: + sys.stderr.write(f"WrapperError: Function or method '{{_SANDBOX_FN_NAME}}' not found.\\n") + return None, True # result, error_occurred + + _fn_result = _target_callable(*_args) + return _fn_result, False # result, no_error + except Exception: # Catches errors from Solution instantiation, getattr, or function call + sys.stderr.write(f"Error during setup or execution of '{{_SANDBOX_FN_NAME}}':\\n{{traceback.format_exc()}}\\n") + return None, True # result, error_occurred + +if __name__ == '__main__': + _result, _error_occurred = _execute_user_function() + + if not _error_occurred: + # Serialize result to stdout + if isinstance(_result, (dict, list, tuple)) or _result is None or isinstance(_result, bool): + print(json.dumps(_result)) + elif isinstance(_result, (int, float, str)): + print(str(_result)) # Ensure string conversion for print + else: + # For other types, default to string representation. + print(str(_result)) + # Optional: To explicitly exit with an error code if the sandbox relies on it + # else: + # sys.exit(1) +""" + current_generation_code = wrapper_code + + stdin = None if stdin_data is None else str(stdin_data) + try: + if concurrent_semaphore: + # logger.debug(f"Case {case_index + 1}: Attempting to acquire semaphore.") + with concurrent_semaphore: + # logger.debug(f"Case {case_index + 1}: Semaphore acquired. Calling API.") + api_response, error_msg = call_sandbox_api( + sandbox_fusion_url=sandbox_fusion_url, + code=current_generation_code, + stdin=stdin, + compile_timeout=timeout, + run_timeout=timeout, + memory_limit_mb=memory_limit_mb, + language=language, + ) + # logger.debug(f"Case {case_index + 1}: Semaphore released.") + else: + api_response, error_msg = call_sandbox_api( + sandbox_fusion_url=sandbox_fusion_url, + code=current_generation_code, + stdin=stdin, + compile_timeout=timeout, + run_timeout=timeout, + memory_limit_mb=memory_limit_mb, + language=language, + ) + except Exception as e: + error_msg = f"API Request Exception during check_correctness for case {case_index + 1}: {e}" + logger.error(f"Case {case_index + 1}: {error_msg}") + traceback.print_exc() + + metadata = { + "case_index": case_index, + "input": stdin, + "expected_output": str(expected_output) if expected_output else None, + "api_request_error": error_msg, + "api_response": None, + "status": "unknown", + "stdout": None, + "stderr": None, + "exit_code": None, + "duration": None, + "compile_duration": None, + "compile_stderr": None, + "api_status": None, + "compile_status": None, + "run_status": None, + } + result_status = -1 # Default error: API request error or unknown sandbox error + + if error_msg: + metadata["status"] = "api_error" + result_status = -1 # API request itself failed (includes timeout after retries) + logger.error(f"Case {case_index}: API error occurred: {error_msg}") + # Log code and input only on error for brevity + generation_to_log = generation[:200] + "..." if len(generation) > 200 else generation + logger.error(f"Case {case_index}: code: {generation_to_log}") + logger.error(f"Case {case_index}: input: {stdin}") + elif api_response: + # --- Add debug logging --- + logger.debug(f"Case {case_index}: API Response: {api_response}") + metadata["api_response"] = api_response + metadata["api_status"] = api_response.get("status") + compile_result = api_response.get("compile_result") + run_result = api_response.get("run_result") + + # Extract compile information + if compile_result: + metadata["compile_status"] = compile_result.get("status") + metadata["compile_duration"] = compile_result.get("execution_time") + metadata["compile_stderr"] = compile_result.get("stderr") + + # Extract run information + if run_result: + metadata["run_status"] = run_result.get("status") + metadata["stdout"] = run_result.get("stdout") + metadata["stderr"] = run_result.get("stderr") # stderr during runtime + metadata["exit_code"] = run_result.get("return_code") + metadata["duration"] = run_result.get("execution_time") + + # --- Determine status based on API response --- + api_status = metadata["api_status"] + + if api_status == "SandboxError": + metadata["status"] = "sandbox_error" + result_status = -1 # Internal sandbox error + elif api_status == "Failed": + # --- Add debug logging --- + logger.debug(f"API returned Failed status. Response: {api_response}") + logger.debug(f"Compile Result: {compile_result}") + logger.debug(f"Run Result: {run_result}") + # --- Check the logic here --- + # Compile failed or timed out + is_compile_error = compile_result and ( + metadata["compile_status"] in ["Error", "TimeLimitExceeded"] + or (metadata["compile_status"] == "Finished" and compile_result.get("return_code") != 0) + ) + if is_compile_error: + # Differentiate between compile_error and compile_timeout based on specific status + if metadata["compile_status"] == "TimeLimitExceeded": + metadata["status"] = "compile_timeout" + else: # Includes Error and Finished but return_code != 0 cases + metadata["status"] = "compile_error" + result_status = -4 + # Run failed or timed out + elif run_result: + # Modified condition: Check for TimeLimitExceeded OR (Finished with non-zero exit code) OR Error status + is_runtime_error = ( + metadata["run_status"] == "TimeLimitExceeded" + or metadata["run_status"] == "Error" + or (metadata["run_status"] == "Finished" and run_result.get("return_code") != 0) + ) + if is_runtime_error: + if metadata["run_status"] == "TimeLimitExceeded": + metadata["status"] = "timeout" # Runtime timeout + result_status = -3 + else: # Includes Error and Finished with non-zero return_code + metadata["status"] = "runtime_error" + result_status = -2 + else: + # Other Failed status with run_result, classify as unknown failure + logger.warning(f"Unknown run_status '{metadata['run_status']}' or state within Failed API status.") + metadata["status"] = "unknown_failure" + result_status = -1 # Default to -1 + else: + # Status is Failed but neither a clear compile error nor run_result exists + logger.warning("API status Failed but cannot determine specific error type (compile/run).") + metadata["status"] = "unknown_failure_state" + result_status = -1 # Default to -1 + elif api_status == "Success": + # Run completed successfully, now check the answer + if run_result and metadata["run_status"] == "Finished": + actual_output = metadata["stdout"] if metadata["stdout"] is not None else "" + # Note: Output might contain trailing newlines, need normalization + if expected_output is None or str(actual_output).rstrip("\n") == str(expected_output).rstrip("\n"): + result_status = True + metadata["status"] = "success" + else: + result_status = False + metadata["status"] = "wrong_answer" + else: + # Status is Success but run_result status is not Finished, this is unexpected + metadata["status"] = "unexpected_success_state" + result_status = -1 # Classify as unknown error + else: + # API returned an unknown top-level status + logger.warning(f"Unknown API status received: {api_status}") + metadata["status"] = f"unknown_api_status_{api_status}" + result_status = -1 # Default to -1 + else: # api_response is None and no error_msg (Should not happen with current call_sandbox_api logic) + metadata["status"] = "unknown_api_state" + result_status = -1 + logger.error(f"Case {case_index}: Unknown API state (no response and no error message).") + return result_status, metadata + + +def check_correctness( + sandbox_fusion_url: str, + in_outs: Optional[dict], + generation: str, + timeout: int = DEFAULT_TIMEOUT, + memory_limit_mb: int = 1024, + language: str = "python", + concurrent_semaphore: Optional[threading.Semaphore] = None, +) -> tuple[list[Any], list[dict[str, Any]]]: + """ + Checks the correctness of code generation using the remote sandbox API, + processing test cases concurrently. + + Args: + sandbox_fusion_url: The URL of the sandbox fusion API. + in_outs: Dictionary containing "inputs" and "outputs" lists. + generation: The generated code string. + timeout: Timeout for each test case (compile and run share this timeout). + language: The programming language of the code. + + Returns: + A tuple (results, metadata_list). + results: A list containing the test result for each input/output pair + (True/False/-1 api/sandbox err, -2 runtime err, -3 timeout, -4 compile err). + Results are ordered corresponding to the inputs. + metadata_list: A list containing metadata dictionaries for each test case, + ordered corresponding to the inputs. + """ + logger.info("Starting correctness check for generation.") + + if not in_outs or "inputs" not in in_outs or "outputs" not in in_outs: + logger.warning("Invalid in_outs format provided.") + return [-1], [{"error": "Invalid input/output data"}] + + inputs = in_outs["inputs"] + expected_outputs = in_outs["outputs"] + fn_name = in_outs.get("fn_name") + num_cases = len(inputs) + assert_cases = in_outs.get("assert_case", [""] * num_cases) # Default to empty strings if not provided + results = [None] * num_cases # Initialize with placeholders + metadata_list = [None] * num_cases # Initialize with placeholders + + if num_cases == 0: + logger.warning("Empty inputs provided.") + return [], [] + + if len(inputs) != len(expected_outputs): + logger.warning(f"Mismatch between number of inputs ({len(inputs)}) and outputs ({len(expected_outputs)}).") + # Return error based on the number of inputs provided + return [-1] * num_cases, [{"error": "Input/output count mismatch", "case_index": i} for i in range(num_cases)] + + # If assert_cases is provided, it overrides inputs and outputs + if len(assert_cases) != num_cases: + logger.warning( + f"Mismatch between number of assert cases ({len(assert_cases)}) and inputs/outputs ({num_cases})." + ) + return [-1] * num_cases, [{"error": "Input/output count mismatch", "case_index": i} for i in range(num_cases)] + + first_compile_error_index = -1 + + # max_workers is limited by sandbox_fusion_max_concurrent from concurrent_semaphore + with concurrent.futures.ThreadPoolExecutor(max_workers=max(32, os.cpu_count() * 5)) as executor: + # Submit all tasks, passing the concurrent_semaphore to _process_single_case + future_to_index = { + executor.submit( + _process_single_case, + i, + stdin_data, + expected_outputs[i], + sandbox_fusion_url, + generation + "\n\n" + assert_cases[i], # Append assert case to generation + timeout, + memory_limit_mb, + language, + concurrent_semaphore, + fn_name, + ): i + for i, stdin_data in enumerate(inputs) + } + + # Process results as they complete + for future in concurrent.futures.as_completed(future_to_index): + index = future_to_index[future] + try: + result_status, metadata = future.result() + results[index] = result_status + metadata_list[index] = metadata + + # Check for compile error (-4) + if result_status == -4: + if first_compile_error_index == -1 or index < first_compile_error_index: + first_compile_error_index = index + # Optimization: could potentially cancel futures for index > first_compile_error_index + # However, cancellation is not guaranteed. Post-processing is safer. + + except Exception as exc: + logger.error(f"Test case {index} generated an exception: {exc}") + traceback.print_exc() + results[index] = -1 # Mark as API/internal error + metadata_list[index] = { + "case_index": index, + "input": str(inputs[index]), + "expected_output": str(expected_outputs[index]) if expected_outputs[index] else None, + "api_request_error": f"Internal execution error: {exc}", + "status": "internal_error", + } + + # Post-processing for compile errors + if first_compile_error_index != -1: + logger.warning( + f"Compile error detected in case {first_compile_error_index}. Marking subsequent cases as compile errors." + ) + for i in range(first_compile_error_index + 1, num_cases): + # Only update if not already processed (though it should be None or have a result) + if results[i] != -4: # Avoid overwriting if it somehow already got -4 + results[i] = -4 + # Update or create metadata for skipped cases due to compile error + if metadata_list[i] is None: # If future failed before returning metadata + metadata_list[i] = { + "case_index": i, + "input": str(inputs[i]), + "expected_output": str(expected_outputs[i]) if expected_outputs[i] else None, + "api_request_error": None, + "status": "compile_error_skipped", # Indicate skipped due to prior compile error + } + else: # If future completed but result is overridden + metadata_list[i]["status"] = "compile_error_skipped" + + logger.info(f"Correctness check finished. Results: {results}") + return results, metadata_list diff --git a/verl/verl/utils/reward_score/search_r1_like_qa_em.py b/verl/verl/utils/reward_score/search_r1_like_qa_em.py new file mode 100644 index 0000000000000000000000000000000000000000..56782fcb34329ba23a77881237c8a58478098a13 --- /dev/null +++ b/verl/verl/utils/reward_score/search_r1_like_qa_em.py @@ -0,0 +1,156 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# Copyright 2023-2024 SGLang Team +# Copyright 2025 Search-R1 Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Adapted from https://github.com/PeterGriffinJin/Search-R1/blob/main/verl/utils/reward_score/qa_em.py + +import random +import re +import string + + +def normalize_answer(s): + def remove_articles(text): + return re.sub(r"\b(a|an|the)\b", " ", text) + + def white_space_fix(text): + return " ".join(text.split()) + + def remove_punc(text): + exclude = set(string.punctuation) + return "".join(ch for ch in text if ch not in exclude) + + def lower(text): + return text.lower() + + return white_space_fix(remove_articles(remove_punc(lower(s)))) + + +def em_check(prediction, golden_answers): + if isinstance(golden_answers, str): + golden_answers = [golden_answers] + normalized_prediction = normalize_answer(prediction) + score = 0 + for golden_answer in golden_answers: + golden_answer = normalize_answer(golden_answer) + if golden_answer == normalized_prediction: + score = 1 + break + return score + + +def subem_check(prediction, golden_answers): + if isinstance(golden_answers, str): + golden_answers = [golden_answers] + normalized_prediction = normalize_answer(prediction) + score = 0 + for golden_answer in golden_answers: + golden_answer = normalize_answer(golden_answer) + if golden_answer in normalized_prediction: + score = 1 + break + return score + + +def extract_solution(solution_str): + """Extract the equation from the solution string.""" + # Remove everything before the first "Assistant:" + # if "Assistant:" in solution_str: + # solution_str = solution_str.split("Assistant:", 1)[1] + # elif "<|im_start|>assistant" in solution_str: + # solution_str = solution_str.split("<|im_start|>assistant", 1)[1] + # else: + # return None + # solution_str = solution_str.split('\n')[-1] + + answer_pattern = r"(.*?)" + match = re.finditer(answer_pattern, solution_str, re.DOTALL) + matches = list(match) + + # If there are 0 matches, return None + if len(matches) < 1: + return None + + # If there are 2 or more matches, return the last one + return matches[-1].group(1).strip() + + +def count_answer_tags(text): + opening_tags = text.count("") + closing_tags = text.count("") + + return opening_tags, closing_tags + + +def compute_score(solution_str, ground_truth, method="strict", format_score=0.0, score=1.0): + """The scoring function for exact match (EM). + + Args: + solution_str: the solution text + ground_truth: the ground truth + method: the method to extract the solution, choices are 'strict' and 'flexible' + format_score: the score for the format + score: the score for the correct answer + """ + answer = extract_solution(solution_str=solution_str) + open_count, close_count = count_answer_tags(solution_str) + do_print = random.randint(1, 64) == 1 + + if do_print: + print("--------------------------------") + print(f"Golden answers: {ground_truth['target']}") + if answer is not None: + print(f"Extracted answer is not None: {answer}") + else: + print("Extracted answer: None!") + print(f"Solution string: {solution_str}") + + if answer is None: + return 0 + else: + if em_check(answer, ground_truth["target"]): + if open_count > 10 or close_count > 10: # prevent output a lot of
+ score = score / 4 + return score + return score + else: + return format_score + + +def compute_score_subem(solution_str, ground_truth, method="strict", format_score=0.0, score=1.0): + """The scoring function for substring exact match (EM). + + Args: + solution_str: the solution text + ground_truth: the ground truth + method: the method to extract the solution, choices are 'strict' and 'flexible' + format_score: the score for the format + score: the score for the correct answer + """ + answer = extract_solution(solution_str=solution_str) + do_print = random.randint(1, 64) == 1 + + if do_print: + print("--------------------------------") + print(f"Golden answers: {ground_truth['target']}") + print(f"Extracted answer: {answer}") + print(f"Solution string: {solution_str}") + + if answer is None: + return 0 + else: + if subem_check(answer, ground_truth["target"]): + return score + else: + return format_score diff --git a/verl/verl/utils/vllm/__init__.py b/verl/verl/utils/vllm/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..00aa7bdb642484b5c3ac65b6cf1e839a427c7bf1 --- /dev/null +++ b/verl/verl/utils/vllm/__init__.py @@ -0,0 +1,26 @@ +# Copyright 2025 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .utils import TensorLoRARequest, VLLMHijack, is_version_ge + +# The contents of vllm/patch.py should not be imported here, because the contents of +# patch.py should be imported after the vllm LLM instance is created. Therefore, +# wait until you actually start using it before importing the contents of +# patch.py separately. + +__all__ = [ + "TensorLoRARequest", + "VLLMHijack", + "is_version_ge", +] diff --git a/verl/verl/utils/vllm/utils.py b/verl/verl/utils/vllm/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..acf24398077a8c8e8634f8ee9acad4847738a8e6 --- /dev/null +++ b/verl/verl/utils/vllm/utils.py @@ -0,0 +1,122 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from msgspec import field +from packaging import version as vs +from vllm.lora.models import LoRAModel +from vllm.lora.request import LoRARequest +from vllm.lora.utils import get_adapter_absolute_path +from vllm.lora.worker_manager import LRUCacheWorkerLoRAManager + +from verl.third_party.vllm import get_version + + +class TensorLoRARequest(LoRARequest): + peft_config: dict = field(default=None) + lora_tensors: dict = field(default=None) + + +class VLLMHijack: + @staticmethod + def hijack(): + def hijack__load_adapter(self, lora_request: TensorLoRARequest) -> LoRAModel: + """ + based on vllm.lora.worker_manager.WorkerLoRAManager._load_adapter, support load adapter with lora tensors + + Reason: + VLLM does not support adding LoRA from tensors directly. It only supports adding LoRA via file paths. + To synchronize the LoRA tensors of the actor model, we need to find a workaround to enable VLLM to + load memory-based LoRA tensors. + """ + try: + supported_lora_modules = self._adapter_manager.supported_lora_modules + packed_modules_mapping = self._adapter_manager.packed_modules_mapping + expected_lora_modules: list[str] = [] + for module in supported_lora_modules: + if module in packed_modules_mapping: + expected_lora_modules.extend(packed_modules_mapping[module]) + else: + expected_lora_modules.append(module) + + expected_lora_modules = list(set(expected_lora_modules)) + + lora_tensors = None + from vllm.lora.peft_helper import PEFTHelper + + if isinstance(lora_request, TensorLoRARequest): + peft_config = lora_request.peft_config + lora_tensors = lora_request.lora_tensors + peft_helper = PEFTHelper.from_dict(peft_config) + else: + lora_path = get_adapter_absolute_path(lora_request.lora_path) + + peft_helper = PEFTHelper.from_local_dir(lora_path, self.max_position_embeddings) + + # Validates the LoRA configuration against requirements before + # loading weights, throwing an exception if validation fails. + peft_helper.validate_legal(self.lora_config) + + # For some models like Qwen2VL, we need to use hf_to_vllm_mapper + # to ensure correct loading of lora weights. + model = self._adapter_manager.model + hf_to_vllm_mapper = None + if hasattr(model, "hf_to_vllm_mapper") and model.hf_to_vllm_mapper is not None: + hf_to_vllm_mapper = model.hf_to_vllm_mapper + + if isinstance(lora_request, TensorLoRARequest): + lora = self._lora_model_cls.from_lora_tensors( + lora_model_id=lora_request.lora_int_id, + tensors=lora_tensors, + peft_helper=peft_helper, + device="cpu", + dtype=self.lora_config.lora_dtype, + embeddings=None, + target_embedding_padding=self.vocab_size + self.lora_config.lora_extra_vocab_size, + embedding_modules=self.embedding_modules, + embedding_padding_modules=self.embedding_padding_modules, + weights_mapper=hf_to_vllm_mapper, + ) + else: + lora = self._lora_model_cls.from_local_checkpoint( + lora_path, + expected_lora_modules, + peft_helper=peft_helper, + lora_model_id=lora_request.lora_int_id, + device="cpu", + dtype=self.lora_config.lora_dtype, + target_embedding_padding=self.vocab_size + self.lora_config.lora_extra_vocab_size, + embedding_modules=self.embedding_modules, + embedding_padding_modules=self.embedding_padding_modules, + weights_mapper=hf_to_vllm_mapper, + ) + except Exception as e: + raise e + + if lora.extra_vocab_size > self.lora_config.lora_extra_vocab_size: + raise ValueError( + f"LoRA added vocab size {lora.extra_vocab_size} is greater than lora_extra_vocab_size " + f"{self.lora_config.lora_extra_vocab_size}." + ) + return lora + + def do_hijack(target_cls, target_method_name, hooking_method): + setattr(target_cls, target_method_name, hooking_method) + + do_hijack(LRUCacheWorkerLoRAManager, "_load_adapter", hijack__load_adapter) + + +def is_version_ge(pkg: str = "vllm", minver: str = "0.7.3"): + """check if the package version is greater than or equal to the minimum version""" + return vs.parse(get_version(pkg)) >= vs.parse(minver) diff --git a/verl/verl/workers/__init__.py b/verl/verl/workers/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce90c5eb352d85c59105c0dc85b5f1dd576f095 --- /dev/null +++ b/verl/verl/workers/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Bytedance Ltd. and/or its affiliates +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License.