Harryis commited on
Commit
638be87
·
verified ·
1 Parent(s): bc3dbfd

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/generation_config.json +14 -0
  2. saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt +0 -0
  3. saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/model.safetensors.index.json +443 -0
  4. saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/special_tokens_map.json +31 -0
  5. saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/tokenizer_config.json +208 -0
  6. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/chat_template.jinja +54 -0
  7. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/config.json +66 -0
  8. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt +0 -0
  9. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/vocab.json +0 -0
  10. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt +0 -0
  11. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/model.safetensors.index.json +443 -0
  12. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/special_tokens_map.json +31 -0
  13. saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/tokenizer_config.json +208 -0
  14. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/added_tokens.json +24 -0
  15. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/chat_template.jinja +54 -0
  16. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/config.json +66 -0
  17. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/generation_config.json +14 -0
  18. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt +0 -0
  19. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/special_tokens_map.json +31 -0
  20. saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/tokenizer_config.json +208 -0
  21. saves_hf/qwen2.5_3B_it_sokoban2_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/chat_template.jinja +54 -0
  22. scripts/eval_qwen_sokoban.sh +69 -0
  23. scripts/reward_diagnosis/plot_reward_matrix.py +302 -0
  24. scripts/runs/README_webshop_small_combos.md +71 -0
  25. scripts/runs/run_entropy_sweep.sh +463 -0
  26. scripts/runs/run_filtering_final.sh +144 -0
  27. scripts/runs/run_frozen_lake_slipper_rate_sweep.sh +527 -0
  28. scripts/runs/run_kl_sweep.sh +467 -0
  29. scripts/runs/run_main_table_diff_algo.sh +546 -0
  30. scripts/runs/run_main_table_diff_model.sh +541 -0
  31. scripts/runs/run_main_table_diff_size.sh +524 -0
  32. scripts/runs/run_search_benchmark.sh +542 -0
  33. scripts/runs/run_sokoban_ppo_filter_grad_analysis.sh +205 -0
  34. scripts/runs/run_sokoban_ppo_filter_grad_analysis_probe_ckpt.sh +244 -0
  35. scripts/runs/run_top_p_sweep.sh +446 -0
  36. scripts/runs/run_webshop_release_combos.sh +565 -0
  37. scripts/runs/run_webshop_small_combos.sh +563 -0
  38. scripts/setup_ragen.md +47 -0
  39. scripts/visualize.py +692 -0
  40. tests/env/test_sokoban_render.py +41 -0
  41. tests/es_manager/test_seed_iteration.py +34 -0
  42. tests/llm_agent/test_context_window.py +84 -0
  43. verl/.gemini/config.yaml +10 -0
  44. verl/.github/CODEOWNERS +30 -0
  45. verl/.github/ISSUE_TEMPLATE/bug-report.yml +65 -0
  46. verl/.github/ISSUE_TEMPLATE/config.yml +2 -0
  47. verl/.github/ISSUE_TEMPLATE/feature-request.yml +32 -0
  48. verl/.github/PULL_REQUEST_TEMPLATE.md +40 -0
  49. verl/.github/dependabot.yml +9 -0
  50. verl/.github/workflows/.deprecate/e2e_eval_aime24.yml +147 -0
saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "repetition_penalty": 1.05,
10
+ "temperature": 0.7,
11
+ "top_k": 20,
12
+ "top_p": 0.8,
13
+ "transformers_version": "4.57.3"
14
+ }
saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/model.safetensors.index.json ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 3397103616,
4
+ "total_size": 6794207232
5
+ },
6
+ "weight_map": {
7
+ "lm_head.weight": "model-00002-of-00002.safetensors",
8
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
12
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
20
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
26
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
29
+ "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
30
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
32
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00002.safetensors",
34
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
36
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
39
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
42
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.10.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
44
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
47
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
51
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
53
+ "model.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
54
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
56
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
60
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
61
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
63
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
66
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.12.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
68
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
71
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
73
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.13.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
75
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.13.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
78
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
79
+ "model.layers.13.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
80
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
84
+ "model.layers.14.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
85
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
87
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
90
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
91
+ "model.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
92
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
99
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.15.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
102
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
104
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
109
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
111
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
113
+ "model.layers.16.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
114
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
116
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.17.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
120
+ "model.layers.17.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
121
+ "model.layers.17.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
122
+ "model.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
123
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
124
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
126
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
128
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.18.input_layernorm.weight": "model-00002-of-00002.safetensors",
130
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
133
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.18.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
135
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
138
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.18.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
140
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
145
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.19.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
147
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.19.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
150
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
152
+ "model.layers.19.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
153
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
155
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
157
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
159
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
161
+ "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
162
+ "model.layers.2.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
163
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
164
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
167
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
168
+ "model.layers.20.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
169
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.20.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
171
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
173
+ "model.layers.20.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
174
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.20.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
176
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
177
+ "model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.21.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
179
+ "model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
180
+ "model.layers.21.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
181
+ "model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
182
+ "model.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
183
+ "model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
184
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
185
+ "model.layers.21.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
186
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
188
+ "model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
189
+ "model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
190
+ "model.layers.22.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
191
+ "model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
192
+ "model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
193
+ "model.layers.22.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.22.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
195
+ "model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
196
+ "model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.22.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
198
+ "model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.22.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
200
+ "model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
201
+ "model.layers.23.input_layernorm.weight": "model-00001-of-00002.safetensors",
202
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
203
+ "model.layers.23.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.23.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
205
+ "model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
206
+ "model.layers.23.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
207
+ "model.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
208
+ "model.layers.23.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
209
+ "model.layers.23.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
210
+ "model.layers.23.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
211
+ "model.layers.23.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
212
+ "model.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
213
+ "model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
214
+ "model.layers.24.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
215
+ "model.layers.24.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
216
+ "model.layers.24.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
217
+ "model.layers.24.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
218
+ "model.layers.24.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
219
+ "model.layers.24.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
220
+ "model.layers.24.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
221
+ "model.layers.24.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
222
+ "model.layers.24.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
223
+ "model.layers.24.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
224
+ "model.layers.24.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
225
+ "model.layers.25.input_layernorm.weight": "model-00001-of-00002.safetensors",
226
+ "model.layers.25.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
227
+ "model.layers.25.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
228
+ "model.layers.25.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
229
+ "model.layers.25.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
230
+ "model.layers.25.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
231
+ "model.layers.25.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
232
+ "model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
233
+ "model.layers.25.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
234
+ "model.layers.25.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
235
+ "model.layers.25.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
236
+ "model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
237
+ "model.layers.26.input_layernorm.weight": "model-00001-of-00002.safetensors",
238
+ "model.layers.26.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
239
+ "model.layers.26.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
240
+ "model.layers.26.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
241
+ "model.layers.26.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
242
+ "model.layers.26.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
243
+ "model.layers.26.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
244
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
245
+ "model.layers.26.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
246
+ "model.layers.26.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
247
+ "model.layers.26.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
248
+ "model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
249
+ "model.layers.27.input_layernorm.weight": "model-00001-of-00002.safetensors",
250
+ "model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
251
+ "model.layers.27.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
252
+ "model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
253
+ "model.layers.27.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.27.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
255
+ "model.layers.27.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
256
+ "model.layers.27.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
257
+ "model.layers.27.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
258
+ "model.layers.27.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
259
+ "model.layers.27.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
260
+ "model.layers.27.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
261
+ "model.layers.28.input_layernorm.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.28.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.28.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.28.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.layers.28.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.28.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
267
+ "model.layers.28.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
268
+ "model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
269
+ "model.layers.28.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
270
+ "model.layers.28.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.28.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
272
+ "model.layers.28.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
273
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
274
+ "model.layers.29.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
275
+ "model.layers.29.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
276
+ "model.layers.29.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
277
+ "model.layers.29.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
278
+ "model.layers.29.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
279
+ "model.layers.29.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
280
+ "model.layers.29.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
281
+ "model.layers.29.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
282
+ "model.layers.29.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
283
+ "model.layers.29.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
284
+ "model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
285
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
286
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
287
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
288
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
289
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
290
+ "model.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
291
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
292
+ "model.layers.3.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
293
+ "model.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
294
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
295
+ "model.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
296
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
297
+ "model.layers.30.input_layernorm.weight": "model-00001-of-00002.safetensors",
298
+ "model.layers.30.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
299
+ "model.layers.30.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
300
+ "model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
301
+ "model.layers.30.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
302
+ "model.layers.30.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
303
+ "model.layers.30.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
304
+ "model.layers.30.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
305
+ "model.layers.30.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
306
+ "model.layers.30.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
307
+ "model.layers.30.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
308
+ "model.layers.30.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
309
+ "model.layers.31.input_layernorm.weight": "model-00001-of-00002.safetensors",
310
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
311
+ "model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
312
+ "model.layers.31.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
313
+ "model.layers.31.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
314
+ "model.layers.31.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
315
+ "model.layers.31.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
316
+ "model.layers.31.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
317
+ "model.layers.31.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
318
+ "model.layers.31.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
319
+ "model.layers.31.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
320
+ "model.layers.31.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
321
+ "model.layers.32.input_layernorm.weight": "model-00001-of-00002.safetensors",
322
+ "model.layers.32.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
323
+ "model.layers.32.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
324
+ "model.layers.32.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
325
+ "model.layers.32.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
326
+ "model.layers.32.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
327
+ "model.layers.32.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
328
+ "model.layers.32.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
329
+ "model.layers.32.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
330
+ "model.layers.32.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
331
+ "model.layers.32.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
332
+ "model.layers.32.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
333
+ "model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
334
+ "model.layers.33.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
335
+ "model.layers.33.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
336
+ "model.layers.33.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
337
+ "model.layers.33.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
338
+ "model.layers.33.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
339
+ "model.layers.33.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.33.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.33.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
342
+ "model.layers.33.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
343
+ "model.layers.33.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
344
+ "model.layers.33.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
345
+ "model.layers.34.input_layernorm.weight": "model-00001-of-00002.safetensors",
346
+ "model.layers.34.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
347
+ "model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
348
+ "model.layers.34.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.layers.34.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
350
+ "model.layers.34.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
351
+ "model.layers.34.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
352
+ "model.layers.34.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
353
+ "model.layers.34.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
354
+ "model.layers.34.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
355
+ "model.layers.34.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
356
+ "model.layers.34.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
357
+ "model.layers.35.input_layernorm.weight": "model-00001-of-00002.safetensors",
358
+ "model.layers.35.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
359
+ "model.layers.35.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
360
+ "model.layers.35.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
361
+ "model.layers.35.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
362
+ "model.layers.35.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
363
+ "model.layers.35.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
364
+ "model.layers.35.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
365
+ "model.layers.35.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
366
+ "model.layers.35.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
367
+ "model.layers.35.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
368
+ "model.layers.35.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
369
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
370
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
371
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
372
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
373
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
374
+ "model.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
375
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
376
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
377
+ "model.layers.4.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
378
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
379
+ "model.layers.4.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
380
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
381
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
382
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
383
+ "model.layers.5.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
384
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
385
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
386
+ "model.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
387
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
388
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
389
+ "model.layers.5.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
390
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
391
+ "model.layers.5.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
392
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
393
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
394
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
395
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
396
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
397
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
398
+ "model.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
399
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
400
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
401
+ "model.layers.6.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
402
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
403
+ "model.layers.6.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
404
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
405
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
406
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
407
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
408
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
409
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
410
+ "model.layers.7.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
411
+ "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
412
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
413
+ "model.layers.7.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
414
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
415
+ "model.layers.7.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
416
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
417
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
418
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
419
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
420
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
421
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
422
+ "model.layers.8.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
423
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
424
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
425
+ "model.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
426
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
427
+ "model.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
428
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
429
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
430
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
431
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
432
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
433
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
434
+ "model.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
435
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
436
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
437
+ "model.layers.9.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
438
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
439
+ "model.layers.9.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
440
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
441
+ "model.norm.weight": "model-00001-of-00002.safetensors"
442
+ }
443
+ }
saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
saves_hf/qwen2.5_3B_it_rubikscube3_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/tokenizer_config.json ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|im_end|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "padding_side": "right",
205
+ "split_special_tokens": false,
206
+ "tokenizer_class": "Qwen2Tokenizer",
207
+ "unk_token": null
208
+ }
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/config.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 151645,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 2048,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 11008,
12
+ "layer_types": [
13
+ "full_attention",
14
+ "full_attention",
15
+ "full_attention",
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention"
49
+ ],
50
+ "max_position_embeddings": 32768,
51
+ "max_window_layers": 70,
52
+ "model_type": "qwen2",
53
+ "num_attention_heads": 16,
54
+ "num_hidden_layers": 36,
55
+ "num_key_value_heads": 2,
56
+ "pad_token_id": 151643,
57
+ "rms_norm_eps": 1e-06,
58
+ "rope_scaling": null,
59
+ "rope_theta": 1000000.0,
60
+ "sliding_window": null,
61
+ "tie_word_embeddings": true,
62
+ "transformers_version": "4.57.3",
63
+ "use_cache": false,
64
+ "use_sliding_window": false,
65
+ "vocab_size": 151936
66
+ }
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/model.safetensors.index.json ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 3397103616,
4
+ "total_size": 6794207232
5
+ },
6
+ "weight_map": {
7
+ "lm_head.weight": "model-00001-of-00002.safetensors",
8
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.input_layernorm.weight": "model-00002-of-00002.safetensors",
10
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
12
+ "model.layers.0.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
13
+ "model.layers.0.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
14
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
18
+ "model.layers.0.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
19
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
20
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.1.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
30
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
31
+ "model.layers.1.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
32
+ "model.layers.1.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
33
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
36
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
39
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
41
+ "model.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
42
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
43
+ "model.layers.10.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
44
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
45
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
47
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
49
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
51
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
53
+ "model.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
54
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
56
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
58
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
59
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
61
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
62
+ "model.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
63
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
64
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
66
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
67
+ "model.layers.12.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
68
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
69
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
73
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.13.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
75
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
76
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.13.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
78
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.13.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
80
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
83
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
86
+ "model.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
87
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
90
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
91
+ "model.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
92
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
97
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
99
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.15.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
102
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
103
+ "model.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
104
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
108
+ "model.layers.16.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
109
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
111
+ "model.layers.16.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
112
+ "model.layers.16.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
113
+ "model.layers.16.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
114
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
116
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
119
+ "model.layers.17.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
120
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
121
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
123
+ "model.layers.17.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
124
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
126
+ "model.layers.17.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
127
+ "model.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
128
+ "model.layers.17.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
129
+ "model.layers.18.input_layernorm.weight": "model-00002-of-00002.safetensors",
130
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.18.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
133
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.18.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
135
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.18.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
137
+ "model.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
138
+ "model.layers.18.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
139
+ "model.layers.18.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
140
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
141
+ "model.layers.19.input_layernorm.weight": "model-00002-of-00002.safetensors",
142
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
145
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
146
+ "model.layers.19.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
147
+ "model.layers.19.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
148
+ "model.layers.19.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
149
+ "model.layers.19.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
150
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
152
+ "model.layers.19.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
153
+ "model.layers.2.input_layernorm.weight": "model-00002-of-00002.safetensors",
154
+ "model.layers.2.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
155
+ "model.layers.2.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
156
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
157
+ "model.layers.2.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
158
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
159
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
161
+ "model.layers.2.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
162
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
163
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
164
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.20.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
167
+ "model.layers.20.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
168
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
169
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.20.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
171
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.20.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
173
+ "model.layers.20.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
174
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.20.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
176
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
177
+ "model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
179
+ "model.layers.21.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
180
+ "model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
181
+ "model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
183
+ "model.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
184
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
185
+ "model.layers.21.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
186
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
188
+ "model.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
189
+ "model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
190
+ "model.layers.22.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
191
+ "model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
192
+ "model.layers.22.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
193
+ "model.layers.22.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.22.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
195
+ "model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
196
+ "model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.22.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
198
+ "model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.22.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
200
+ "model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
201
+ "model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
202
+ "model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
203
+ "model.layers.23.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
205
+ "model.layers.23.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
206
+ "model.layers.23.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
207
+ "model.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
208
+ "model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
209
+ "model.layers.23.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
210
+ "model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
211
+ "model.layers.23.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
212
+ "model.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
213
+ "model.layers.24.input_layernorm.weight": "model-00001-of-00002.safetensors",
214
+ "model.layers.24.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
215
+ "model.layers.24.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
216
+ "model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
217
+ "model.layers.24.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
218
+ "model.layers.24.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
219
+ "model.layers.24.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
220
+ "model.layers.24.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
221
+ "model.layers.24.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
222
+ "model.layers.24.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
223
+ "model.layers.24.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
224
+ "model.layers.24.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
225
+ "model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
226
+ "model.layers.25.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
227
+ "model.layers.25.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
228
+ "model.layers.25.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
229
+ "model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
230
+ "model.layers.25.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
231
+ "model.layers.25.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
232
+ "model.layers.25.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
233
+ "model.layers.25.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
234
+ "model.layers.25.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
235
+ "model.layers.25.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
236
+ "model.layers.25.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
237
+ "model.layers.26.input_layernorm.weight": "model-00001-of-00002.safetensors",
238
+ "model.layers.26.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
239
+ "model.layers.26.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
240
+ "model.layers.26.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
241
+ "model.layers.26.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
242
+ "model.layers.26.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
243
+ "model.layers.26.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
244
+ "model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
245
+ "model.layers.26.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
246
+ "model.layers.26.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
247
+ "model.layers.26.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
248
+ "model.layers.26.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
249
+ "model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
250
+ "model.layers.27.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
251
+ "model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
252
+ "model.layers.27.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
253
+ "model.layers.27.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.27.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
255
+ "model.layers.27.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
256
+ "model.layers.27.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
257
+ "model.layers.27.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
258
+ "model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
259
+ "model.layers.27.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
260
+ "model.layers.27.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
261
+ "model.layers.28.input_layernorm.weight": "model-00001-of-00002.safetensors",
262
+ "model.layers.28.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.28.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
264
+ "model.layers.28.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.layers.28.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.28.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
267
+ "model.layers.28.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
268
+ "model.layers.28.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
269
+ "model.layers.28.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
270
+ "model.layers.28.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.28.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
272
+ "model.layers.28.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
273
+ "model.layers.29.input_layernorm.weight": "model-00001-of-00002.safetensors",
274
+ "model.layers.29.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
275
+ "model.layers.29.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
276
+ "model.layers.29.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
277
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
278
+ "model.layers.29.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
279
+ "model.layers.29.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
280
+ "model.layers.29.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
281
+ "model.layers.29.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
282
+ "model.layers.29.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
283
+ "model.layers.29.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
284
+ "model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
285
+ "model.layers.3.input_layernorm.weight": "model-00002-of-00002.safetensors",
286
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
287
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
288
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
289
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
290
+ "model.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
291
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
292
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
293
+ "model.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
294
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
295
+ "model.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
296
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
297
+ "model.layers.30.input_layernorm.weight": "model-00001-of-00002.safetensors",
298
+ "model.layers.30.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
299
+ "model.layers.30.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
300
+ "model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
301
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
302
+ "model.layers.30.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
303
+ "model.layers.30.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
304
+ "model.layers.30.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
305
+ "model.layers.30.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
306
+ "model.layers.30.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
307
+ "model.layers.30.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
308
+ "model.layers.30.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
309
+ "model.layers.31.input_layernorm.weight": "model-00001-of-00002.safetensors",
310
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
311
+ "model.layers.31.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
312
+ "model.layers.31.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
313
+ "model.layers.31.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
314
+ "model.layers.31.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
315
+ "model.layers.31.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
316
+ "model.layers.31.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
317
+ "model.layers.31.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
318
+ "model.layers.31.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
319
+ "model.layers.31.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
320
+ "model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
321
+ "model.layers.32.input_layernorm.weight": "model-00001-of-00002.safetensors",
322
+ "model.layers.32.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
323
+ "model.layers.32.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
324
+ "model.layers.32.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
325
+ "model.layers.32.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
326
+ "model.layers.32.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
327
+ "model.layers.32.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
328
+ "model.layers.32.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
329
+ "model.layers.32.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
330
+ "model.layers.32.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
331
+ "model.layers.32.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
332
+ "model.layers.32.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
333
+ "model.layers.33.input_layernorm.weight": "model-00001-of-00002.safetensors",
334
+ "model.layers.33.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
335
+ "model.layers.33.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
336
+ "model.layers.33.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
337
+ "model.layers.33.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
338
+ "model.layers.33.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
339
+ "model.layers.33.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.33.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.33.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
342
+ "model.layers.33.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
343
+ "model.layers.33.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
344
+ "model.layers.33.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
345
+ "model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
346
+ "model.layers.34.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
347
+ "model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
348
+ "model.layers.34.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.layers.34.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
350
+ "model.layers.34.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
351
+ "model.layers.34.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
352
+ "model.layers.34.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
353
+ "model.layers.34.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
354
+ "model.layers.34.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
355
+ "model.layers.34.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
356
+ "model.layers.34.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
357
+ "model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
358
+ "model.layers.35.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
359
+ "model.layers.35.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
360
+ "model.layers.35.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
361
+ "model.layers.35.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
362
+ "model.layers.35.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
363
+ "model.layers.35.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
364
+ "model.layers.35.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
365
+ "model.layers.35.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
366
+ "model.layers.35.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
367
+ "model.layers.35.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
368
+ "model.layers.35.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
369
+ "model.layers.4.input_layernorm.weight": "model-00002-of-00002.safetensors",
370
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
371
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
372
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
373
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
374
+ "model.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
375
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
376
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
377
+ "model.layers.4.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
378
+ "model.layers.4.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
379
+ "model.layers.4.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
380
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
381
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
382
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
383
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
384
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
385
+ "model.layers.5.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
386
+ "model.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
387
+ "model.layers.5.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
388
+ "model.layers.5.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
389
+ "model.layers.5.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
390
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
391
+ "model.layers.5.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
392
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
393
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
394
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
395
+ "model.layers.6.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
396
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
397
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
398
+ "model.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
399
+ "model.layers.6.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
400
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
401
+ "model.layers.6.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
402
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
403
+ "model.layers.6.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
404
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
405
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
406
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
407
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
408
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
409
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
410
+ "model.layers.7.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
411
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
412
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
413
+ "model.layers.7.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
414
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
415
+ "model.layers.7.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
416
+ "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
417
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
418
+ "model.layers.8.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
419
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
420
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
421
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
422
+ "model.layers.8.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
423
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
424
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
425
+ "model.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
426
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
427
+ "model.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
428
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
429
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
430
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
431
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
432
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
433
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
434
+ "model.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
435
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
436
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
437
+ "model.layers.9.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
438
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
439
+ "model.layers.9.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
440
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
441
+ "model.norm.weight": "model-00001-of-00002.safetensors"
442
+ }
443
+ }
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
saves_hf/qwen2.5_3B_it_sokoban1_withthink_sas_rl/global_step_200/qwen2.5_3b_actor_hf/tokenizer_config.json ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|im_end|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "padding_side": "right",
205
+ "split_special_tokens": false,
206
+ "tokenizer_class": "Qwen2Tokenizer",
207
+ "unk_token": null
208
+ }
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/config.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 151645,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 2048,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 11008,
12
+ "layer_types": [
13
+ "full_attention",
14
+ "full_attention",
15
+ "full_attention",
16
+ "full_attention",
17
+ "full_attention",
18
+ "full_attention",
19
+ "full_attention",
20
+ "full_attention",
21
+ "full_attention",
22
+ "full_attention",
23
+ "full_attention",
24
+ "full_attention",
25
+ "full_attention",
26
+ "full_attention",
27
+ "full_attention",
28
+ "full_attention",
29
+ "full_attention",
30
+ "full_attention",
31
+ "full_attention",
32
+ "full_attention",
33
+ "full_attention",
34
+ "full_attention",
35
+ "full_attention",
36
+ "full_attention",
37
+ "full_attention",
38
+ "full_attention",
39
+ "full_attention",
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention"
49
+ ],
50
+ "max_position_embeddings": 32768,
51
+ "max_window_layers": 70,
52
+ "model_type": "qwen2",
53
+ "num_attention_heads": 16,
54
+ "num_hidden_layers": 36,
55
+ "num_key_value_heads": 2,
56
+ "pad_token_id": 151643,
57
+ "rms_norm_eps": 1e-06,
58
+ "rope_scaling": null,
59
+ "rope_theta": 1000000.0,
60
+ "sliding_window": null,
61
+ "tie_word_embeddings": true,
62
+ "transformers_version": "4.57.3",
63
+ "use_cache": false,
64
+ "use_sliding_window": false,
65
+ "vocab_size": 151936
66
+ }
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "repetition_penalty": 1.05,
10
+ "temperature": 0.7,
11
+ "top_k": 20,
12
+ "top_p": 0.8,
13
+ "transformers_version": "4.57.3"
14
+ }
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
saves_hf/qwen2.5_3B_it_sokoban2_withthink_fulltraj_sa_rl/global_step_200/qwen2.5_3b_actor_hf/tokenizer_config.json ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "clean_up_tokenization_spaces": false,
199
+ "eos_token": "<|im_end|>",
200
+ "errors": "replace",
201
+ "extra_special_tokens": {},
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "padding_side": "right",
205
+ "split_special_tokens": false,
206
+ "tokenizer_class": "Qwen2Tokenizer",
207
+ "unk_token": null
208
+ }
saves_hf/qwen2.5_3B_it_sokoban2_withthink_sa_rl/global_step_200/qwen2.5_3b_actor_hf/chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
scripts/eval_qwen_sokoban.sh ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Evaluate Qwen model on Sokoban environment
3
+ #
4
+ # Usage:
5
+ # bash scripts/eval_qwen_sokoban.sh <model_version> [num_trajectories] [gpu_id]
6
+ #
7
+ # Examples:
8
+ # bash scripts/eval_qwen_sokoban.sh 3B 128 0
9
+ # bash scripts/eval_qwen_sokoban.sh 7B 256 1
10
+ # bash scripts/eval_qwen_sokoban.sh 14B 128 0,1
11
+
12
+ set -e
13
+
14
+ # Parse arguments
15
+ MODEL_VERSION=${1:-"14B"}
16
+ NUM_TRAJECTORIES=${2:-128}
17
+ GPU_ID=${3:-"0"}
18
+
19
+ # Calculate env_groups and group_size
20
+ # Strategy: Use group_size=16 (common default), calculate groups accordingly
21
+ GROUP_SIZE=16
22
+ ENV_GROUPS=$((NUM_TRAJECTORIES / GROUP_SIZE))
23
+
24
+ if [ $((NUM_TRAJECTORIES % GROUP_SIZE)) -ne 0 ]; then
25
+ echo "Warning: NUM_TRAJECTORIES ($NUM_TRAJECTORIES) is not divisible by GROUP_SIZE ($GROUP_SIZE)"
26
+ echo "Rounding up to $((ENV_GROUPS * GROUP_SIZE)) trajectories"
27
+ ENV_GROUPS=$(( (NUM_TRAJECTORIES + GROUP_SIZE - 1) / GROUP_SIZE ))
28
+ fi
29
+
30
+ ACTUAL_TRAJECTORIES=$((ENV_GROUPS * GROUP_SIZE))
31
+
32
+ # Model configuration
33
+ MODEL_PATH="Qwen/Qwen2.5-${MODEL_VERSION}-Instruct"
34
+ OUTPUT_DIR="outputs"
35
+ OUTPUT_FILE="${OUTPUT_DIR}/qwen-${MODEL_VERSION}-sokoban-${ACTUAL_TRAJECTORIES}.jsonl"
36
+
37
+ # Create output directory
38
+ mkdir -p ${OUTPUT_DIR}
39
+
40
+ echo "=========================================="
41
+ echo "RAGEN Evaluation Configuration"
42
+ echo "=========================================="
43
+ echo "Model: ${MODEL_PATH}"
44
+ echo "Environment: Sokoban (CoordSokoban)"
45
+ echo "Trajectories: ${ACTUAL_TRAJECTORIES} (${ENV_GROUPS} groups × ${GROUP_SIZE} size)"
46
+ echo "GPU: ${GPU_ID}"
47
+ echo "Output: ${OUTPUT_FILE}"
48
+ echo "=========================================="
49
+ echo ""
50
+
51
+ # Run evaluation
52
+ python -m ragen.llm_agent.agent_proxy \
53
+ --config-name eval \
54
+ system.CUDA_VISIBLE_DEVICES="${GPU_ID}" \
55
+ model_path="${MODEL_PATH}" \
56
+ es_manager.val.env_groups=${ENV_GROUPS} \
57
+ es_manager.val.group_size=${GROUP_SIZE} \
58
+ es_manager.val.env_configs.tags=["CoordSokoban"] \
59
+ es_manager.val.env_configs.n_groups=[${ENV_GROUPS}] \
60
+ output.dir="${OUTPUT_DIR}" \
61
+ output.filename="qwen-${MODEL_VERSION}-sokoban-${ACTUAL_TRAJECTORIES}.jsonl" \
62
+ output.format=jsonl \
63
+ output.append_timestamp=false
64
+
65
+ echo ""
66
+ echo "=========================================="
67
+ echo "Evaluation completed!"
68
+ echo "Results saved to: ${OUTPUT_FILE}"
69
+ echo "=========================================="
scripts/reward_diagnosis/plot_reward_matrix.py ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Plot the reward triangular matrix from multi-rollout inference results.
4
+
5
+ Reads the JSON output from run_inference.py and generates a heatmap where:
6
+ - Each row = one prompt, rollout rewards sorted high-to-low within the row
7
+ - Rows sorted by mean reward descending (easy on top, hard on bottom)
8
+ - Color: reward value (0 = red, 1 = green)
9
+ - Region labels and RV annotations on the right margin
10
+ - Classification: Easy (mean >= threshold), Hard (mean <= threshold), Mixed (in between)
11
+
12
+ The resulting upper-triangular shape shows:
13
+ - Top rows: easy prompts (all green) — too easy, no RL signal
14
+ - Middle rows: mixed prompts (left green, right red) — learnable
15
+ - Bottom rows: hard prompts (all red) — too hard or broken
16
+
17
+ Usage:
18
+ python scripts/reward_diagnosis/plot_reward_matrix.py \
19
+ --input logs/inference_results.json \
20
+ --output logs/reward_matrix.png
21
+ """
22
+
23
+ import argparse
24
+ import json
25
+ import sys
26
+ from pathlib import Path
27
+
28
+ import numpy as np
29
+
30
+ try:
31
+ import matplotlib
32
+ matplotlib.use("Agg")
33
+ import matplotlib.pyplot as plt
34
+ import matplotlib.gridspec as gridspec
35
+ from matplotlib.colors import LinearSegmentedColormap
36
+ from matplotlib.patches import FancyBboxPatch
37
+ except ImportError:
38
+ print("matplotlib is required: pip install matplotlib")
39
+ sys.exit(1)
40
+
41
+
42
+ def main():
43
+ parser = argparse.ArgumentParser(description="Plot reward triangular matrix")
44
+ parser.add_argument("--input", required=True, help="Path to inference JSON from run_inference.py")
45
+ parser.add_argument("--output", default=None, help="Output image path (default: <input_stem>_matrix.png)")
46
+ parser.add_argument("--max_prompts", type=int, default=100, help="Max prompts to display")
47
+ parser.add_argument("--easy_threshold", type=float, default=0.8,
48
+ help="Mean reward >= this is classified as Easy")
49
+ parser.add_argument("--hard_threshold", type=float, default=0.2,
50
+ help="Mean reward <= this is classified as Hard")
51
+ parser.add_argument("--dpi", type=int, default=200)
52
+ args = parser.parse_args()
53
+
54
+ # Load data
55
+ with open(args.input) as f:
56
+ data = json.load(f)
57
+
58
+ config = data["config"]
59
+ prompts = data["prompts"]
60
+ summary = data["summary"]
61
+ n_rollouts = config["rollouts_per_prompt"]
62
+
63
+ # Build matrix: each row = sorted rewards (descending) for one prompt
64
+ reward_rows = []
65
+ rv_values = []
66
+
67
+ for p in prompts:
68
+ rewards = sorted(p["rewards"], reverse=True)
69
+ reward_rows.append(rewards)
70
+ rv_values.append(p["reward_variance"])
71
+
72
+ # Sort by mean reward descending (easy on top, hard on bottom → upper triangle)
73
+ mean_rewards = [np.mean(row) for row in reward_rows]
74
+ sort_idx = np.argsort(mean_rewards)[::-1]
75
+ reward_rows = [reward_rows[i] for i in sort_idx]
76
+ rv_values = [rv_values[i] for i in sort_idx]
77
+ mean_rewards = [mean_rewards[i] for i in sort_idx]
78
+
79
+ # Truncate for display
80
+ n_display = min(len(reward_rows), args.max_prompts)
81
+ reward_rows = reward_rows[:n_display]
82
+ rv_values = rv_values[:n_display]
83
+
84
+ matrix = np.array(reward_rows)
85
+
86
+ # Classify by mean reward thresholds
87
+ n_easy = sum(1 for m in mean_rewards if m >= args.easy_threshold)
88
+ n_hard = sum(1 for m in mean_rewards if m <= args.hard_threshold)
89
+ n_mixed = n_display - n_easy - n_hard
90
+ n_other = 0
91
+
92
+ # ── Figure layout ──
93
+ fig_w = 10
94
+ fig_h = max(5, n_display * 0.18 + 2.5)
95
+ fig = plt.figure(figsize=(fig_w, fig_h), facecolor="#fafafa")
96
+
97
+ gs = gridspec.GridSpec(
98
+ 2, 2,
99
+ width_ratios=[1, 0.04],
100
+ height_ratios=[1, 0.08],
101
+ hspace=0.35, wspace=0.08,
102
+ left=0.08, right=0.85, top=0.88, bottom=0.08,
103
+ )
104
+ ax_main = fig.add_subplot(gs[0, 0])
105
+ ax_cbar = fig.add_subplot(gs[0, 1])
106
+ ax_summary = fig.add_subplot(gs[1, :])
107
+
108
+ # ── Colormap ──
109
+ cmap = LinearSegmentedColormap.from_list(
110
+ "reward",
111
+ [
112
+ (0.0, "#c62828"), # deep red
113
+ (0.15, "#e53935"), # red
114
+ (0.35, "#ff8f00"), # amber
115
+ (0.50, "#fdd835"), # yellow
116
+ (0.65, "#7cb342"), # light green
117
+ (0.85, "#388e3c"), # green
118
+ (1.0, "#1b5e20"), # deep green
119
+ ],
120
+ )
121
+
122
+ # ── Main heatmap ──
123
+ im = ax_main.imshow(
124
+ matrix, aspect="auto", cmap=cmap, vmin=0, vmax=1,
125
+ interpolation="nearest",
126
+ )
127
+
128
+ # Cell value annotations (only if matrix is small enough)
129
+ if n_display <= 40 and n_rollouts <= 16:
130
+ for i in range(n_display):
131
+ for j in range(n_rollouts):
132
+ val = matrix[i, j]
133
+ color = "white" if val < 0.4 or val > 0.8 else "black"
134
+ ax_main.text(j, i, f"{val:.1f}", ha="center", va="center",
135
+ fontsize=6, color=color, fontweight="bold")
136
+
137
+ # X axis
138
+ ax_main.set_xlabel("Rollouts (sorted high → low)", fontsize=10, labelpad=8)
139
+ ax_main.set_xticks(range(n_rollouts))
140
+ ax_main.set_xticklabels([str(i + 1) for i in range(n_rollouts)], fontsize=8)
141
+ ax_main.xaxis.set_ticks_position("bottom")
142
+
143
+ # Y axis
144
+ ax_main.set_ylabel("Prompts (sorted by mean reward ↓)", fontsize=10, labelpad=8)
145
+ if n_display <= 50:
146
+ ax_main.set_yticks(range(n_display))
147
+ ax_main.set_yticklabels(range(1, n_display + 1), fontsize=6)
148
+ else:
149
+ step = max(1, n_display // 25)
150
+ ticks = list(range(0, n_display, step))
151
+ ax_main.set_yticks(ticks)
152
+ ax_main.set_yticklabels([i + 1 for i in ticks], fontsize=7)
153
+
154
+ # ── Region brackets on the right ──
155
+ region_x = n_rollouts - 0.5 + 0.6 # just outside the matrix
156
+ bracket_style = dict(fontsize=8, va="center", ha="left", fontweight="bold")
157
+
158
+ # RV labels on the right of each row
159
+ for i in range(n_display):
160
+ rv_color = "#1565c0" if args.hard_threshold < mean_rewards[i] < args.easy_threshold else (
161
+ "#2e7d32" if mean_rewards[i] >= args.easy_threshold else "#c62828")
162
+ ax_main.text(
163
+ n_rollouts - 0.5 + 0.3, i, f"{rv_values[i]:.3f}",
164
+ fontsize=5, va="center", ha="left", color=rv_color,
165
+ clip_on=False,
166
+ )
167
+
168
+ # Region label header
169
+ ax_main.text(
170
+ n_rollouts - 0.5 + 0.3, -0.8, "RV",
171
+ fontsize=6, va="center", ha="left", color="#424242",
172
+ fontweight="bold", clip_on=False,
173
+ )
174
+
175
+ # Divider lines between regions
176
+ # Find boundaries: mixed (0.2 < mean < 0.8), easy (mean >= 0.8), hard (mean <= 0.2)
177
+ # Since sorted by RV desc, regions may not be contiguous, so draw lines at transitions
178
+ for i in range(n_display - 1):
179
+ cat_i = "mixed" if args.hard_threshold < mean_rewards[i] < args.easy_threshold else ("easy" if mean_rewards[i] >= args.easy_threshold else "hard")
180
+ cat_next = "mixed" if args.hard_threshold < mean_rewards[i+1] < args.easy_threshold else ("easy" if mean_rewards[i+1] >= args.easy_threshold else "hard")
181
+ if cat_i != cat_next:
182
+ ax_main.axhline(y=i + 0.5, color="#455a64", linewidth=1.0, linestyle="--", alpha=0.5)
183
+
184
+ # Grid lines
185
+ ax_main.set_xticks([x - 0.5 for x in range(1, n_rollouts)], minor=True)
186
+ ax_main.set_yticks([y - 0.5 for y in range(1, n_display)], minor=True)
187
+ ax_main.grid(which="minor", color="#e0e0e0", linewidth=0.3)
188
+ ax_main.tick_params(which="minor", length=0)
189
+
190
+ # ── Colorbar ──
191
+ cbar = fig.colorbar(im, cax=ax_cbar)
192
+ cbar.set_label("Reward", fontsize=9, labelpad=8)
193
+ cbar.ax.tick_params(labelsize=8)
194
+
195
+ # ── Title ──
196
+ model_short = config["model"].split("/")[-1]
197
+ fig.suptitle(
198
+ f"Reward Matrix — {model_short}",
199
+ fontsize=14, fontweight="bold", y=0.96,
200
+ )
201
+ ax_main.set_title(
202
+ f"{n_display} prompts × {n_rollouts} rollouts | temp = {config['temperature']}",
203
+ fontsize=10, color="#616161", pad=10,
204
+ )
205
+
206
+ # ── Summary bar at bottom ──
207
+ ax_summary.set_xlim(0, 1)
208
+ ax_summary.set_ylim(0, 1)
209
+ ax_summary.axis("off")
210
+
211
+ # Stacked bar showing proportions
212
+ bar_y, bar_h = 0.55, 0.35
213
+ segments = []
214
+ if n_mixed > 0:
215
+ segments.append((n_mixed / n_display, "#1565c0", f"Mixed: {n_mixed} ({n_mixed/n_display*100:.0f}%)"))
216
+ if n_other > 0:
217
+ segments.append((n_other / n_display, "#78909c", f"Other: {n_other}"))
218
+ if n_easy > 0:
219
+ segments.append((n_easy / n_display, "#43a047", f"Easy: {n_easy} ({n_easy/n_display*100:.0f}%)"))
220
+ if n_hard > 0:
221
+ segments.append((n_hard / n_display, "#e53935", f"Hard: {n_hard} ({n_hard/n_display*100:.0f}%)"))
222
+
223
+ x_pos = 0.05
224
+ bar_total_w = 0.6
225
+ for frac, color, label in segments:
226
+ w = frac * bar_total_w
227
+ rect = FancyBboxPatch(
228
+ (x_pos, bar_y), w, bar_h,
229
+ boxstyle="round,pad=0.01", facecolor=color, edgecolor="white", linewidth=1.5,
230
+ )
231
+ ax_summary.add_patch(rect)
232
+ if w > 0.05:
233
+ ax_summary.text(x_pos + w / 2, bar_y + bar_h / 2, label,
234
+ ha="center", va="center", fontsize=7, color="white", fontweight="bold")
235
+ x_pos += w
236
+
237
+ # Diagnosis text
238
+ mean_rv_mixed = np.mean([rv for rv in rv_values if rv > 0]) if n_mixed > 0 else 0
239
+ diag_x = 0.72
240
+ ax_summary.text(diag_x, 0.85, f"Mean reward: {summary['mean_reward']:.3f}",
241
+ fontsize=8, color="#424242", transform=ax_summary.transAxes)
242
+ ax_summary.text(diag_x, 0.55, f"Mean RV (mixed): {mean_rv_mixed:.4f}",
243
+ fontsize=8, color="#424242", transform=ax_summary.transAxes)
244
+
245
+ mixed_pct = n_mixed / max(n_display, 1) * 100
246
+ if mixed_pct >= 20:
247
+ verdict = "✓ Good RL signal"
248
+ verdict_color = "#2e7d32"
249
+ elif mixed_pct >= 10:
250
+ verdict = "~ Weak RL signal"
251
+ verdict_color = "#f57f17"
252
+ else:
253
+ verdict = "✗ Poor RL signal"
254
+ verdict_color = "#c62828"
255
+ ax_summary.text(diag_x, 0.2, verdict,
256
+ fontsize=9, color=verdict_color, fontweight="bold", transform=ax_summary.transAxes)
257
+
258
+ # ── Save ──
259
+ if args.output is None:
260
+ output_path = Path(args.input).with_name(Path(args.input).stem + "_matrix.png")
261
+ else:
262
+ output_path = Path(args.output)
263
+ output_path.parent.mkdir(parents=True, exist_ok=True)
264
+
265
+ fig.savefig(output_path, dpi=args.dpi, bbox_inches="tight", facecolor=fig.get_facecolor())
266
+ plt.close(fig)
267
+ print(f"Saved reward matrix to {output_path}")
268
+
269
+ # Text summary
270
+ print(f"\n{'=' * 60}")
271
+ print(f"REWARD MATRIX SUMMARY")
272
+ print(f"{'=' * 60}")
273
+ print(f"Model: {config['model']}")
274
+ print(f"Prompts: {n_display}")
275
+ print(f"Rollouts/prompt: {n_rollouts}")
276
+ print(f"Temperature: {config['temperature']}")
277
+ print()
278
+ print(f"Mixed (RV > 0): {n_mixed:4d} ({n_mixed/n_display*100:5.1f}%) <- RL can learn from these")
279
+ print(f"All correct: {n_easy:4d} ({n_easy/n_display*100:5.1f}%) <- too easy, no signal")
280
+ print(f"All wrong: {n_hard:4d} ({n_hard/n_display*100:5.1f}%) <- too hard or broken")
281
+ print()
282
+ print(f"Mean RV (mixed only): {mean_rv_mixed:.4f}")
283
+ print(f"Overall mean reward: {summary['mean_reward']:.4f}")
284
+ print()
285
+
286
+ if n_hard / max(n_display, 1) > 0.5:
287
+ print("DIAGNOSIS: >50% prompts are all-wrong.")
288
+ print(" -> Check: Is the environment set up correctly?")
289
+ print(" -> Check: Does the model understand the expected action format?")
290
+ elif n_easy / max(n_display, 1) > 0.5:
291
+ print("DIAGNOSIS: >50% prompts are all-correct.")
292
+ print(" -> Task may be too easy. Consider harder subset or lower temperature.")
293
+ elif n_mixed / max(n_display, 1) < 0.2:
294
+ print("DIAGNOSIS: <20% prompts have mixed rewards. Weak RL signal.")
295
+ print(" -> Adjust temperature, check environment setup, or use different data.")
296
+ else:
297
+ print(f"DIAGNOSIS: Good RL signal. {n_mixed/n_display*100:.0f}% prompts are learnable.")
298
+ print(" -> Proceed to training.")
299
+
300
+
301
+ if __name__ == "__main__":
302
+ main()
scripts/runs/README_webshop_small_combos.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Webshop Small Combos — Running Guide
2
+
3
+ ## Combos
4
+
5
+ The script defines 4 model×algorithm combinations:
6
+
7
+ | Combo | Model | Algorithm |
8
+ |-------|-------|-----------|
9
+ | 1 | Qwen2.5-3B-Instruct | PPO |
10
+ | 2 | Qwen2.5-3B-Instruct | GRPO |
11
+ | 3 | Qwen2.5-7B-Instruct | PPO |
12
+ | 4 | Llama-3.2-3B-Instruct | PPO |
13
+
14
+ Use `--combos` to select which ones to run (1-indexed, comma-separated). Default: all.
15
+
16
+ ## Filter Modes
17
+
18
+ - `--filters filter` → top_p=0.9 (rollout filtering enabled)
19
+ - `--filters nofilter` → top_p=1.0 (no filtering)
20
+ - `--filters all` → runs both (default)
21
+
22
+ ## Multi-GPU for One Experiment
23
+
24
+ Use `--gpus-per-exp N` to assign multiple GPUs to a single experiment. The GPUs listed in `--gpus` are split into groups of N.
25
+
26
+ Example: 2 GPUs per experiment on GPUs 0-3:
27
+ ```bash
28
+ bash scripts/runs/run_webshop_small_combos.sh --gpus 0,1,2,3 --gpus-per-exp 2 --combos 3
29
+ # Creates 2 slots: [0,1] and [2,3]
30
+ ```
31
+
32
+ ## Example: Running All Experiments (8 GPUs)
33
+
34
+ Run these in separate terminals (disjoint GPUs, safe to run in parallel):
35
+
36
+ ```bash
37
+ # Terminal 1 — 7B filter (GPUs 0,1)
38
+ bash scripts/runs/run_webshop_small_combos.sh --steps 200 --gpus 0,1 --gpus-per-exp 2 --filters filter --combos 3
39
+
40
+ # Terminal 2 — 7B nofilter (GPUs 2,3)
41
+ bash scripts/runs/run_webshop_small_combos.sh --steps 200 --gpus 2,3 --gpus-per-exp 2 --filters nofilter --combos 3
42
+
43
+ # Terminal 3 — 3B Qwen PPO nofilter (GPU 4)
44
+ bash scripts/runs/run_webshop_small_combos.sh --steps 200 --gpus 4 --filters nofilter --combos 1
45
+
46
+ # Terminal 4 — 3B Qwen GRPO nofilter (GPU 5)
47
+ bash scripts/runs/run_webshop_small_combos.sh --steps 200 --gpus 5 --filters nofilter --combos 2
48
+
49
+ # Terminal 5 — 3B Llama PPO nofilter (GPU 6)
50
+ bash scripts/runs/run_webshop_small_combos.sh --steps 200 --gpus 6 --filters nofilter --combos 4
51
+ ```
52
+
53
+ ## Key Parameters
54
+
55
+ | Flag | Default | Description |
56
+ |------|---------|-------------|
57
+ | `--steps N` | 100 | Training steps |
58
+ | `--gpus LIST` | auto-detect | Comma-separated GPU IDs |
59
+ | `--gpus-per-exp N` | 1 | GPUs per experiment |
60
+ | `--combos LIST` | all | Which combos to run (1-4) |
61
+ | `--filters LIST` | all | filter, nofilter, or all |
62
+ | `--save-freq N` | 100 | Checkpoint save frequency |
63
+ | `--cooldown N` | 30 | Seconds between runs on same GPU slot |
64
+ | `--gpu-memory-utilization V` | 0.3 | vLLM rollout GPU memory fraction |
65
+
66
+ ## Output
67
+
68
+ - Logs: `logs/webshop_small_combos/<name>.log`
69
+ - Results: `logs/webshop_small_combos/<name>.result`
70
+ - Checkpoints: `model_saving/webshop_small_combos/<model>/<algo>/<filter>/<name>/`
71
+ - Wandb project: `main_webshop`
scripts/runs/run_entropy_sweep.sh ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Entropy coefficient sweep for sokoban + GAE, keeping KL loss fixed and top_p filtering.
3
+ set -euo pipefail
4
+
5
+ # Defaults
6
+ STEPS=400
7
+ MODEL_NAME="Qwen2.5-3B"
8
+ MODEL_PATH="Qwen/${MODEL_NAME}"
9
+ PROJECT_NAME="ragen_release_entropy_sweep"
10
+ CONFIG_NAME="_2_sokoban"
11
+ SAVE_FREQ=-1
12
+ ENTROPY_VALUES="0,0.001,0.003,0.01,0.03,0.1"
13
+ ROLL_FILTER_INCLUDE_ZERO="True"
14
+ GPUS=()
15
+ GPUS_PROVIDED=false
16
+ GPUS_PER_EXP=1
17
+ COOLDOWN_SECONDS=0
18
+ GPU_MEMORY_UTILIZATION=0.5
19
+ RAY_NUM_CPUS=16
20
+
21
+ usage() {
22
+ cat <<'EOF'
23
+ Usage: $0 [options]
24
+ Options:
25
+ --steps N Training steps (default: 400)
26
+ --entropy-values LIST Comma-separated entropy_coeff values (default: 0,0.001,0.003,0.01,0.03,0.1)
27
+ --rollout_filter_include_zero BOOL Whether rollout_filter_include_zero (default: True)
28
+ --gpus LIST Comma-separated GPU IDs
29
+ --gpus-per-exp N GPUs per experiment (default: 1)
30
+ --ray-num-cpus N Max CPUs per task for ray.init (default: 16)
31
+ --gpu-memory-utilization V GPU memory utilization for rollouts (default: 0.5)
32
+ --save-freq N Checkpoint save frequency (default: -1)
33
+ -h, --help Show this help
34
+ EOF
35
+ exit 0
36
+ }
37
+
38
+ parse_bool() {
39
+ local val="${1,,}"
40
+ case "$val" in
41
+ true|1|yes|y) echo "True" ;;
42
+ false|0|no|n) echo "False" ;;
43
+ *)
44
+ echo "Error: expected boolean, got '$1'" >&2
45
+ exit 1
46
+ ;;
47
+ esac
48
+ }
49
+
50
+ while [ $# -gt 0 ]; do
51
+ case "$1" in
52
+ --steps) STEPS="$2"; shift 2 ;;
53
+ --steps=*) STEPS="${1#*=}"; shift ;;
54
+ --entropy-values) ENTROPY_VALUES="$2"; shift 2 ;;
55
+ --entropy-values=*) ENTROPY_VALUES="${1#*=}"; shift ;;
56
+ --rollout_filter_include_zero) ROLL_FILTER_INCLUDE_ZERO=$(parse_bool "$2"); shift 2 ;;
57
+ --rollout_filter_include_zero=*) ROLL_FILTER_INCLUDE_ZERO=$(parse_bool "${1#*=}"); shift ;;
58
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
59
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
60
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
61
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
62
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
63
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
64
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
65
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
66
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
67
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
68
+ -h|--help) usage ;;
69
+ *) echo "Unknown argument: $1"; usage ;;
70
+ esac
71
+ done
72
+
73
+ if [ "$GPUS_PROVIDED" = false ]; then
74
+ if command -v nvidia-smi >/dev/null 2>&1; then
75
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
76
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
77
+ GPUS=()
78
+ for ((i=0; i<GPU_COUNT; i++)); do
79
+ GPUS+=("$i")
80
+ done
81
+ fi
82
+ fi
83
+ if [ ${#GPUS[@]} -eq 0 ]; then
84
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
85
+ GPUS=(0 1 2 3 4 5 6 7)
86
+ fi
87
+ fi
88
+
89
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
90
+ echo "Error: --gpus-per-exp must be a positive integer"
91
+ exit 1
92
+ fi
93
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
94
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
95
+ exit 1
96
+ fi
97
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
98
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
99
+ exit 1
100
+ fi
101
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
102
+ echo "Error: --ray-num-cpus must be a positive integer"
103
+ exit 1
104
+ fi
105
+
106
+ GPU_GROUPS=()
107
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
108
+ group="${GPUS[$i]}"
109
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
110
+ group+=",${GPUS[$((i+j))]}"
111
+ done
112
+ GPU_GROUPS+=("$group")
113
+ done
114
+ NUM_SLOTS=${#GPU_GROUPS[@]}
115
+
116
+ short_gpu_name() {
117
+ local name="$1"
118
+ local cleaned
119
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
120
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
121
+ echo "${BASH_REMATCH[1]}"
122
+ return
123
+ fi
124
+ echo "${cleaned%% *}"
125
+ }
126
+
127
+ declare -A GPU_LABELS
128
+ get_gpu_label() {
129
+ local gpu_id="$1"
130
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
131
+ echo "${GPU_LABELS[$gpu_id]}"
132
+ return
133
+ fi
134
+ local name=""
135
+ if command -v nvidia-smi >/dev/null 2>&1; then
136
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
137
+ fi
138
+ if [ -z "$name" ]; then
139
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
140
+ echo "${GPU_LABELS[$gpu_id]}"
141
+ return
142
+ fi
143
+ local short
144
+ short=$(short_gpu_name "$name")
145
+ GPU_LABELS[$gpu_id]="1x${short}"
146
+ echo "${GPU_LABELS[$gpu_id]}"
147
+ }
148
+
149
+ get_gpu_model_label() {
150
+ local models=()
151
+ local id label model
152
+ for id in "${GPUS[@]}"; do
153
+ label=$(get_gpu_label "$id")
154
+ model="${label#1x}"
155
+ models+=("$model")
156
+ done
157
+ local unique_models=()
158
+ local m found
159
+ for m in "${models[@]}"; do
160
+ found=false
161
+ for u in "${unique_models[@]}"; do
162
+ if [ "$u" = "$m" ]; then
163
+ found=true
164
+ break
165
+ fi
166
+ done
167
+ if [ "$found" = false ]; then
168
+ unique_models+=("$m")
169
+ fi
170
+ done
171
+ if [ ${#unique_models[@]} -eq 1 ]; then
172
+ echo "${unique_models[0]}"
173
+ else
174
+ echo "mixed"
175
+ fi
176
+ }
177
+
178
+ get_gpu_label_for_list() {
179
+ local gpu_list="$1"
180
+ IFS=',' read -r -a ids <<< "$gpu_list"
181
+ local count=${#ids[@]}
182
+ if [ "$count" -eq 0 ]; then
183
+ echo "0xGPU"
184
+ return
185
+ fi
186
+ local first_model
187
+ first_model="$(get_gpu_label "${ids[0]}")"
188
+ first_model="${first_model#1x}"
189
+ local id model
190
+ for id in "${ids[@]:1}"; do
191
+ model="$(get_gpu_label "$id")"
192
+ model="${model#1x}"
193
+ if [ "$model" != "$first_model" ]; then
194
+ echo "${count}xmixed"
195
+ return
196
+ fi
197
+ done
198
+ echo "${count}x${first_model}"
199
+ }
200
+
201
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
202
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
203
+ LOG_FILE="logs/entropy_sweep_${MODEL_NAME}.log"
204
+ RESULT_ROOT="logs/entropy_sweep_${MODEL_NAME}"
205
+ CHECKPOINT_ROOT="model_saving/entropy_sweep_${MODEL_NAME}"
206
+
207
+ mkdir -p logs
208
+ mkdir -p "$RESULT_ROOT"
209
+ mkdir -p "$CHECKPOINT_ROOT"
210
+
211
+ echo "=== Entropy Sweep Runner (${MODEL_NAME}): $(date) ===" | tee "$LOG_FILE"
212
+ echo "Values: ${ENTROPY_VALUES} | Steps: ${STEPS} | GPUs per exp: ${GPU_LOG_LABEL}" | tee -a "$LOG_FILE"
213
+ echo "Groups: ${GPU_GROUPS[*]} | GPU memory util: ${GPU_MEMORY_UTILIZATION} | ray_num_cpus: ${RAY_NUM_CPUS} | save_freq: ${SAVE_FREQ}" | tee -a "$LOG_FILE"
214
+
215
+ parse_values() {
216
+ IFS=',' read -r -a raw <<< "$1"
217
+ VALUES=()
218
+ for token in "${raw[@]}"; do
219
+ token="${token// /}"
220
+ if [ -n "$token" ]; then
221
+ VALUES+=("$token")
222
+ fi
223
+ done
224
+ if [ ${#VALUES[@]} -eq 0 ]; then
225
+ echo "Error: no entries provided for value list" >&2
226
+ exit 1
227
+ fi
228
+ }
229
+
230
+ parse_values "$ENTROPY_VALUES"
231
+ EXPERIMENTS=("${VALUES[@]}")
232
+
233
+ run_experiment() {
234
+ local value="$1"
235
+ local gpu_list="$2"
236
+ local safe_label="${value//./}"
237
+ safe_label="${safe_label,,}"
238
+ local filter_tag="nofilter"
239
+ if [ "${ROLL_FILTER_INCLUDE_ZERO}" = "False" ]; then
240
+ filter_tag="filter_zero"
241
+ fi
242
+
243
+ local name="sokoban_entropy_sweep_${filter_tag}_${safe_label}-${MODEL_NAME}"
244
+ local task_dir="${RESULT_ROOT}/${filter_tag}/${safe_label}"
245
+ local log_path="${task_dir}/${name}.log"
246
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${safe_label}/${name}"
247
+ local gpus_per_exp
248
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
249
+ gpus_per_exp=${#gpu_ids[@]}
250
+
251
+ mkdir -p "$task_dir"
252
+ mkdir -p "$checkpoint_dir"
253
+
254
+ START=$(date +%s)
255
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$CONFIG_NAME" \
256
+ model_path="${MODEL_PATH}" \
257
+ trainer.project_name="${PROJECT_NAME}" \
258
+ trainer.experiment_name="${name}" \
259
+ trainer.total_training_steps="${STEPS}" \
260
+ trainer.save_freq="${SAVE_FREQ}" \
261
+ trainer.default_local_dir="${checkpoint_dir}" \
262
+ trainer.logger="['console','wandb']" \
263
+ trainer.val_before_train=True \
264
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
265
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
266
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
267
+ algorithm.adv_estimator=gae \
268
+ actor_rollout_ref.actor.use_kl_loss=False \
269
+ actor_rollout_ref.actor.kl_loss_coef=0 \
270
+ actor_rollout_ref.actor.entropy_coeff="${value}" \
271
+ actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
272
+ actor_rollout_ref.actor.filter_loss_scaling=none \
273
+ actor_rollout_ref.actor.ppo_mini_batch_size=32 \
274
+ actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
275
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 \
276
+ critic.ppo_mini_batch_size=32 \
277
+ critic.ppo_micro_batch_size_per_gpu=4 \
278
+ ppo_mini_batch_size=32 \
279
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
280
+ actor_rollout_ref.rollout.rollout_filter_strategy=top_p \
281
+ actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax \
282
+ actor_rollout_ref.rollout.rollout_filter_value=1 \
283
+ actor_rollout_ref.rollout.rollout_filter_include_zero=${ROLL_FILTER_INCLUDE_ZERO} \
284
+ actor_rollout_ref.rollout.rollout_filter_type=largest \
285
+ actor_rollout_ref.rollout.gpu_memory_utilization="${GPU_MEMORY_UTILIZATION}" \
286
+ actor_rollout_ref.rollout.rollout_filter_metric=reward_variance \
287
+ es_manager.train.env_groups=8 \
288
+ es_manager.train.group_size=16 \
289
+ es_manager.train.env_configs.n_groups='[8]' \
290
+ es_manager.val.env_groups=512 \
291
+ es_manager.val.group_size=1 \
292
+ es_manager.val.env_configs.n_groups='[512]' \
293
+ 2>&1 | tee "$log_path"
294
+ EXIT_CODE=${PIPESTATUS[0]}
295
+
296
+ END=$(date +%s)
297
+ TOTAL_TIME=$((END - START))
298
+
299
+ timing_values=()
300
+ mapfile -t timing_values < <(
301
+ python - "$log_path" <<'PY'
302
+ import re
303
+ import sys
304
+ from pathlib import Path
305
+
306
+ def last(pattern, text):
307
+ matches = re.findall(pattern, text)
308
+ return matches[-1] if matches else ""
309
+
310
+ try:
311
+ text = Path(sys.argv[1]).read_text(errors="ignore")
312
+ except Exception:
313
+ text = ""
314
+
315
+ patterns = [
316
+ r"timing_s/train_total[:\s]+([\d.]+)",
317
+ r"timing_s/eval_total[:\s]+([\d.]+)",
318
+ r"timing_s/total[:\s]+([\d.]+)",
319
+ ]
320
+
321
+ for pattern in patterns:
322
+ print(last(pattern, text))
323
+ PY
324
+ )
325
+
326
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
327
+ EVAL_TIME_RAW="${timing_values[1]:-}"
328
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
329
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
330
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
331
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
332
+
333
+ local status="success"
334
+ local error_line=""
335
+ if [ $EXIT_CODE -ne 0 ]; then
336
+ status="fail"
337
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
338
+ fi
339
+
340
+ local gpu_label
341
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
342
+ local summary_line="entropy=${value} | filter=${filter_tag} | include_zero=${ROLL_FILTER_INCLUDE_ZERO} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
343
+ echo "${summary_line}" > "${task_dir}/${name}.result"
344
+ echo "${summary_line}" | tee -a "$LOG_FILE"
345
+ if [ "$status" = "fail" ]; then
346
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
347
+ fi
348
+ }
349
+
350
+ EXPERIMENT_COUNT=${#EXPERIMENTS[@]}
351
+ if [ $EXPERIMENT_COUNT -eq 0 ]; then
352
+ echo "No experiments to run" >&2
353
+ exit 1
354
+ fi
355
+
356
+ QUEUE_FILE=$(mktemp -t ragen_entropy_queue.XXXXXX)
357
+ echo 0 > "$QUEUE_FILE"
358
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
359
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
360
+ USE_FLOCK=false
361
+ MAIN_PID=$$
362
+
363
+ cleanup_queue() {
364
+ if [ "$MAIN_PID" != "$$" ]; then
365
+ return
366
+ fi
367
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
368
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
369
+ }
370
+ trap cleanup_queue EXIT
371
+
372
+ if command -v flock >/dev/null 2>&1; then
373
+ USE_FLOCK=true
374
+ fi
375
+
376
+ next_experiment_index() {
377
+ local idx
378
+ if [ "$USE_FLOCK" = true ]; then
379
+ flock -x "$QUEUE_LOCK_FD"
380
+ idx=$(cat "$QUEUE_FILE")
381
+ if [ -z "$idx" ]; then
382
+ idx=0
383
+ fi
384
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
385
+ flock -u "$QUEUE_LOCK_FD"
386
+ echo -1
387
+ return
388
+ fi
389
+ echo $((idx + 1)) > "$QUEUE_FILE"
390
+ flock -u "$QUEUE_LOCK_FD"
391
+ echo "$idx"
392
+ return
393
+ fi
394
+
395
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
396
+ sleep 0.05
397
+ done
398
+ idx=$(cat "$QUEUE_FILE")
399
+ if [ -z "$idx" ]; then
400
+ idx=0
401
+ fi
402
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
403
+ rmdir "$QUEUE_LOCK_DIR"
404
+ echo -1
405
+ return
406
+ fi
407
+ echo $((idx + 1)) > "$QUEUE_FILE"
408
+ rmdir "$QUEUE_LOCK_DIR"
409
+ echo "$idx"
410
+ }
411
+
412
+ run_queue_for_slot() {
413
+ local gpu_list="$1"
414
+ if [ "$USE_FLOCK" = true ]; then
415
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
416
+ fi
417
+ while true; do
418
+ local idx
419
+ idx=$(next_experiment_index)
420
+ if [ "$idx" -lt 0 ]; then
421
+ break
422
+ fi
423
+ local value="${EXPERIMENTS[$idx]}"
424
+ run_experiment "$value" "$gpu_list" || true
425
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
426
+ sleep "$COOLDOWN_SECONDS"
427
+ fi
428
+ done
429
+ if [ "$USE_FLOCK" = true ]; then
430
+ exec {QUEUE_LOCK_FD}>&-
431
+ fi
432
+ }
433
+
434
+ pids=()
435
+ for idx in "${!GPU_GROUPS[@]}"; do
436
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
437
+ pids+=("$!")
438
+ done
439
+
440
+ for pid in "${pids[@]}"; do
441
+ wait "$pid"
442
+ done
443
+
444
+ {
445
+ echo ""
446
+ echo "=== Entropy Sweep Summary ==="
447
+ echo "Project: ${PROJECT_NAME} | Steps: ${STEPS} | GPU per exp: ${GPU_LOG_LABEL}"
448
+ for value in "${EXPERIMENTS[@]}"; do
449
+ safe_label="${value//./}"
450
+ safe_label="${safe_label,,}"
451
+ filter_tag="nofilter"
452
+ if [ "${ROLL_FILTER_INCLUDE_ZERO}" = "False" ]; then
453
+ filter_tag="filter_zero"
454
+ fi
455
+ name="sokoban_entropy_sweep_${filter_tag}_${safe_label}-${MODEL_NAME}"
456
+ task_dir="${RESULT_ROOT}/${filter_tag}/${safe_label}"
457
+ if [ -f "${task_dir}/${name}.result" ]; then
458
+ cat "${task_dir}/${name}.result"
459
+ else
460
+ echo "entropy=${value} | status=missing"
461
+ fi
462
+ done
463
+ } | tee -a "$LOG_FILE"
scripts/runs/run_filtering_final.sh ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # usage: bash scripts/runs/run_filtering_final.sh [gpus_per_exp]
5
+ GPUS_PER_EXP="${1:-2}"
6
+
7
+ # -----------------------
8
+ # GPU AUTO-DETECTION
9
+ # -----------------------
10
+ detect_gpus() {
11
+ if command -v nvidia-smi >/dev/null 2>&1; then
12
+ nvidia-smi -L 2>/dev/null | grep -c '^GPU ' || true
13
+ else
14
+ echo 0
15
+ fi
16
+ }
17
+
18
+ TOTAL_GPUS=$(detect_gpus)
19
+ if [ "$TOTAL_GPUS" -eq 0 ]; then
20
+ echo "ERROR: No GPUs detected via nvidia-smi." >&2
21
+ exit 1
22
+ fi
23
+ echo "INFO: Detected $TOTAL_GPUS GPUs."
24
+
25
+ # -----------------------
26
+ # Parallel GPU Management
27
+ # -----------------------
28
+ GPU_POOL_FIFO="/tmp/gpu_pool_$$"
29
+ mkfifo "$GPU_POOL_FIFO"
30
+ exec 3<>"$GPU_POOL_FIFO"
31
+ rm "$GPU_POOL_FIFO"
32
+
33
+ for ((i=0; i<TOTAL_GPUS; i++)); do
34
+ echo "$i" >&3
35
+ done
36
+
37
+ # -----------------------
38
+ # Experiment List
39
+ # -----------------------
40
+ # Format: "ALGO METRIC STRATEGY VALUE TYPE INCLUDE_ZERO EXP_SUFFIX"
41
+ EXPS=(
42
+ # Reward Variance - topP
43
+ "ppo reward_variance top_p 1.0 largest False rv_tp1.0"
44
+ "ppo reward_variance top_p 0.95 largest False rv_tp0.95"
45
+ "ppo reward_variance top_p 0.9 largest False rv_tp0.9"
46
+ "ppo reward_variance top_p 0.5 largest False rv_tp0.5"
47
+
48
+ # Reward Variance - minP
49
+ "ppo reward_variance min_p 0.1 largest False rv_mp0.1"
50
+ "ppo reward_variance min_p 0.05 largest False rv_mp0.05"
51
+ "ppo reward_variance min_p 0.2 largest False rv_mp0.2"
52
+
53
+ # Reward Variance - topK (Fractional)
54
+ "ppo reward_variance top_k 0.25 smallest False rv_tk0.25_rev"
55
+ "ppo reward_variance top_k 0.5 smallest False rv_tk0.5_rev"
56
+ "ppo reward_variance top_k 0.25 largest False rv_tk0.25"
57
+ "ppo reward_variance top_k 0.5 largest False rv_tk0.5"
58
+
59
+ # Entropy
60
+ "ppo entropy top_p 0.9 largest False ent_tp0.9"
61
+
62
+ # Entropy Variance
63
+ "ppo entropy_variance top_p 0.9 largest False entv_tp0.9"
64
+
65
+ # Length
66
+ "ppo length top_p 0.9 largest False len_tp0.9"
67
+ "ppo length top_p 0.9 smallest False len_tp0.9_rev"
68
+ )
69
+
70
+ # -----------------------
71
+ # Setup
72
+ # -----------------------
73
+ ENV="_2_sokoban"
74
+ OUTPUT_DIR="/mnt/permanent/xjin/20260126_filters_final"
75
+ mkdir -p "$OUTPUT_DIR"
76
+ DONE_LIST="filter_final_donelist.txt"
77
+ touch "$DONE_LIST"
78
+
79
+ COMMON_FLAGS_BASE="trainer.total_training_steps=400 micro_batch_size_per_gpu=4 ppo_mini_batch_size=32 trainer.save_freq=-1 \
80
+ trainer.project_name=filtering_final \
81
+ algorithm.kl_ctrl.kl_coef=0.001 actor_rollout_ref.actor.kl_loss_coef=0.001 \
82
+ es_manager.train.env_groups=8 es_manager.train.group_size=16 es_manager.train.env_configs.n_groups=[8]"
83
+
84
+ echo "========================================"
85
+ echo "Starting Final Filtering Experiments"
86
+ echo "Pool: $TOTAL_GPUS GPUs | Per-Exp: $GPUS_PER_EXP"
87
+ echo "Output: $OUTPUT_DIR"
88
+ echo "========================================"
89
+
90
+ # -----------------------
91
+ # Execution Loop
92
+ # -----------------------
93
+ for exp_str in "${EXPS[@]}"; do
94
+ read -r alg metric strategy value ftype inc_zero suffix <<< "$exp_str"
95
+
96
+ exp_name="soko_3b_${alg}_${suffix}"
97
+
98
+ if grep -q "^${exp_name}$" "$DONE_LIST"; then
99
+ echo "Skipping ${exp_name} (Already Done)"
100
+ continue
101
+ fi
102
+
103
+ # Acquire GPUs
104
+ allocated_gpus=()
105
+ for ((i=0; i<GPUS_PER_EXP; i++)); do
106
+ read -u 3 gid
107
+ allocated_gpus+=("$gid")
108
+ done
109
+ gpu_csv=$(IFS=,; echo "${allocated_gpus[*]}")
110
+
111
+ (
112
+ echo "Running: $exp_name on GPUs $gpu_csv"
113
+
114
+ alg_flag="algorithm.adv_estimator=grpo"
115
+ [ "$alg" == "ppo" ] && alg_flag="algorithm.adv_estimator=gae"
116
+
117
+ if CUDA_VISIBLE_DEVICES="$gpu_csv" python train.py --config-name "$ENV" \
118
+ trainer.experiment_name="${exp_name}" \
119
+ actor_rollout_ref.rollout.rollout_filter_metric="${metric}" \
120
+ actor_rollout_ref.rollout.rollout_filter_strategy="${strategy}" \
121
+ actor_rollout_ref.rollout.rollout_filter_value="${value}" \
122
+ actor_rollout_ref.rollout.rollout_filter_type="${ftype}" \
123
+ actor_rollout_ref.rollout.rollout_filter_include_zero="${inc_zero}" \
124
+ trainer.n_gpus_per_node="${GPUS_PER_EXP}" \
125
+ system.CUDA_VISIBLE_DEVICES="\"${gpu_csv}\"" \
126
+ $alg_flag \
127
+ $COMMON_FLAGS_BASE \
128
+ trainer.default_local_dir="${OUTPUT_DIR}/${exp_name}"; then
129
+
130
+ echo "$exp_name" >> "$DONE_LIST"
131
+ else
132
+ echo "ERROR: $exp_name failed on GPUs $gpu_csv." >&2
133
+ fi
134
+
135
+ # Release GPUs
136
+ for gid in "${allocated_gpus[@]}"; do
137
+ echo "$gid" >&3
138
+ done
139
+ ) &
140
+ done
141
+
142
+ wait
143
+ exec 3>&-
144
+ echo "All requested experiments completed."
scripts/runs/run_frozen_lake_slipper_rate_sweep.sh ADDED
@@ -0,0 +1,527 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # FrozenLake slipper_rate sweep with fixed KL/Entropy and filter vs no-filter baselines.
3
+ set -euo pipefail
4
+
5
+ # Defaults
6
+ STEPS=400
7
+ MODEL_NAME="Qwen2.5-3B"
8
+ MODEL_PATH="Qwen/${MODEL_NAME}"
9
+ PROJECT_NAME="ragen_release_frozenlake_slipper_rate_sweep"
10
+ CONFIG_NAME="_3_frozen_lake"
11
+ SAVE_FREQ=-1
12
+ SLIPPER_RATES="100,50,20,10,5,2,0"
13
+ FILTER_MODES="filter,nofilter"
14
+ FILTER_TOP_P="0.9"
15
+ NOFILTER_TOP_P="1.0"
16
+ GPUS=()
17
+ GPUS_PROVIDED=false
18
+ GPUS_PER_EXP=1
19
+ COOLDOWN_SECONDS=30
20
+ GPU_MEMORY_UTILIZATION=0.5
21
+ RAY_NUM_CPUS=16
22
+ declare -A GPU_LABELS
23
+
24
+ usage() {
25
+ cat <<'EOF'
26
+ Usage: $0 [options]
27
+ Options:
28
+ --steps N Training steps (default: 400)
29
+ --slipper-rate LIST Comma-separated slipper rates. Supports:
30
+ percentages (100,50,20,10,5,2,0),
31
+ ratios (1.0,0.5,0.2...), and '%' suffix.
32
+ --filter-modes LIST Comma-separated modes: filter,nofilter (default: both)
33
+ --filter-top-p V top-p for filter mode (default: 0.9)
34
+ --nofilter-top-p V top-p for nofilter mode (default: 1.0)
35
+ --gpus LIST Comma-separated GPU IDs (auto-detected if omitted)
36
+ --gpus-per-exp N GPUs per experiment (default: 1)
37
+ --ray-num-cpus N Max CPUs per task for ray.init (default: 16)
38
+ --cooldown SECONDS Cooldown between runs on same GPU group (default: 30)
39
+ --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.5)
40
+ --save-freq N Checkpoint save frequency (default: -1)
41
+ -h, --help Show this help message
42
+ EOF
43
+ exit 0
44
+ }
45
+
46
+ while [ $# -gt 0 ]; do
47
+ case "$1" in
48
+ --steps) STEPS="$2"; shift 2 ;;
49
+ --steps=*) STEPS="${1#*=}"; shift ;;
50
+ --slipper-rate) SLIPPER_RATES="$2"; shift 2 ;;
51
+ --slipper-rate=*) SLIPPER_RATES="${1#*=}"; shift ;;
52
+ --filter-modes) FILTER_MODES="$2"; shift 2 ;;
53
+ --filter-modes=*) FILTER_MODES="${1#*=}"; shift ;;
54
+ --filter-top-p) FILTER_TOP_P="$2"; shift 2 ;;
55
+ --filter-top-p=*) FILTER_TOP_P="${1#*=}"; shift ;;
56
+ --nofilter-top-p) NOFILTER_TOP_P="$2"; shift 2 ;;
57
+ --nofilter-top-p=*) NOFILTER_TOP_P="${1#*=}"; shift ;;
58
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
59
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
60
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
61
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
62
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
63
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
64
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
65
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
66
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
67
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
68
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
69
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
70
+ -h|--help) usage ;;
71
+ *) echo "Unknown argument: $1"; usage ;;
72
+ esac
73
+ done
74
+
75
+ if [ "$GPUS_PROVIDED" = false ]; then
76
+ if command -v nvidia-smi >/dev/null 2>&1; then
77
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
78
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
79
+ GPUS=()
80
+ for ((i=0; i<GPU_COUNT; i++)); do
81
+ GPUS+=("$i")
82
+ done
83
+ fi
84
+ fi
85
+ if [ ${#GPUS[@]} -eq 0 ]; then
86
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
87
+ GPUS=(0 1 2 3 4 5 6 7)
88
+ fi
89
+ fi
90
+
91
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
92
+ echo "Error: --gpus-per-exp must be a positive integer"
93
+ exit 1
94
+ fi
95
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
96
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
97
+ exit 1
98
+ fi
99
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
100
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
101
+ exit 1
102
+ fi
103
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
104
+ echo "Error: --ray-num-cpus must be a positive integer"
105
+ exit 1
106
+ fi
107
+
108
+ GPU_GROUPS=()
109
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
110
+ group="${GPUS[$i]}"
111
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
112
+ group+=",${GPUS[$((i+j))]}"
113
+ done
114
+ GPU_GROUPS+=("$group")
115
+ done
116
+
117
+ short_gpu_name() {
118
+ local name="$1"
119
+ local cleaned
120
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
121
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
122
+ echo "${BASH_REMATCH[1]}"
123
+ return
124
+ fi
125
+ echo "${cleaned%% *}"
126
+ }
127
+
128
+ get_gpu_label() {
129
+ local gpu_id="$1"
130
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
131
+ echo "${GPU_LABELS[$gpu_id]}"
132
+ return
133
+ fi
134
+ local name=""
135
+ if command -v nvidia-smi >/dev/null 2>&1; then
136
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
137
+ fi
138
+ if [ -z "$name" ]; then
139
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
140
+ echo "${GPU_LABELS[$gpu_id]}"
141
+ return
142
+ fi
143
+ local short
144
+ short=$(short_gpu_name "$name")
145
+ GPU_LABELS[$gpu_id]="1x${short}"
146
+ echo "${GPU_LABELS[$gpu_id]}"
147
+ }
148
+
149
+ get_gpu_label_for_list() {
150
+ local gpu_list="$1"
151
+ IFS=',' read -r -a ids <<< "$gpu_list"
152
+ local count=${#ids[@]}
153
+ if [ "$count" -eq 0 ]; then
154
+ echo "0xGPU"
155
+ return
156
+ fi
157
+ local first_model
158
+ first_model="$(get_gpu_label "${ids[0]}")"
159
+ first_model="${first_model#1x}"
160
+ local id model
161
+ for id in "${ids[@]:1}"; do
162
+ model="$(get_gpu_label "$id")"
163
+ model="${model#1x}"
164
+ if [ "$model" != "$first_model" ]; then
165
+ echo "${count}xmixed"
166
+ return
167
+ fi
168
+ done
169
+ echo "${count}x${first_model}"
170
+ }
171
+
172
+ normalize_slipper_rate() {
173
+ local raw="$1"
174
+ local val="${raw// /}"
175
+ val="${val%%%}"
176
+ python - "$val" <<'PY'
177
+ import sys
178
+
179
+ token = sys.argv[1].strip()
180
+ if not token:
181
+ print("ERR:empty")
182
+ raise SystemExit(0)
183
+ try:
184
+ x = float(token)
185
+ except Exception:
186
+ print("ERR:not_numeric")
187
+ raise SystemExit(0)
188
+
189
+ # <=1: already ratio; >1: treat as percentage
190
+ if x > 1.0:
191
+ x = x / 100.0
192
+
193
+ if x < 0.0 or x > 1.0:
194
+ print("ERR:out_of_range")
195
+ raise SystemExit(0)
196
+
197
+ print(f"{x:.6f}")
198
+ PY
199
+ }
200
+
201
+ parse_slipper_rates() {
202
+ IFS=',' read -r -a raw <<< "$SLIPPER_RATES"
203
+ SLIPPER_VALUES=()
204
+ for token in "${raw[@]}"; do
205
+ token="${token// /}"
206
+ if [ -z "$token" ]; then
207
+ continue
208
+ fi
209
+ local normalized
210
+ normalized=$(normalize_slipper_rate "$token")
211
+ if [[ "$normalized" == ERR:* ]]; then
212
+ echo "Error: invalid slipper rate '${token}' (${normalized#ERR:})" >&2
213
+ exit 1
214
+ fi
215
+ SLIPPER_VALUES+=("$normalized")
216
+ done
217
+ if [ ${#SLIPPER_VALUES[@]} -eq 0 ]; then
218
+ echo "Error: no valid slipper-rate entries provided" >&2
219
+ exit 1
220
+ fi
221
+ }
222
+
223
+ parse_filter_modes() {
224
+ IFS=',' read -r -a raw <<< "$FILTER_MODES"
225
+ MODES=()
226
+ for token in "${raw[@]}"; do
227
+ token="${token// /}"
228
+ token="${token,,}"
229
+ if [ -z "$token" ]; then
230
+ continue
231
+ fi
232
+ case "$token" in
233
+ filter|nofilter) MODES+=("$token") ;;
234
+ *)
235
+ echo "Error: invalid filter mode '${token}'. Use filter or nofilter." >&2
236
+ exit 1
237
+ ;;
238
+ esac
239
+ done
240
+ if [ ${#MODES[@]} -eq 0 ]; then
241
+ echo "Error: no valid filter modes provided" >&2
242
+ exit 1
243
+ fi
244
+ }
245
+
246
+ parse_slipper_rates
247
+ parse_filter_modes
248
+
249
+ format_rate_label() {
250
+ local raw="$1"
251
+ python - "$raw" <<'PY'
252
+ import sys
253
+ x = float(sys.argv[1])
254
+ s = f"{x:.6f}".rstrip("0").rstrip(".")
255
+ print(s.replace(".", "p"))
256
+ PY
257
+ }
258
+
259
+ EXPERIMENTS=()
260
+ for mode in "${MODES[@]}"; do
261
+ if [ "$mode" = "filter" ]; then
262
+ top_p="$FILTER_TOP_P"
263
+ include_zero="False"
264
+ else
265
+ top_p="$NOFILTER_TOP_P"
266
+ include_zero="True"
267
+ fi
268
+ for slipper_rate in "${SLIPPER_VALUES[@]}"; do
269
+ success_rate=$(python - "$slipper_rate" <<'PY'
270
+ import sys
271
+ s = float(sys.argv[1])
272
+ print(f"{1.0 - s:.6f}")
273
+ PY
274
+ )
275
+ EXPERIMENTS+=("${mode}|${top_p}|${include_zero}|${slipper_rate}|${success_rate}")
276
+ done
277
+ done
278
+
279
+ if [ ${#EXPERIMENTS[@]} -eq 0 ]; then
280
+ echo "Error: no experiments generated" >&2
281
+ exit 1
282
+ fi
283
+
284
+ LOG_FILE="logs/frozenlake_slipper_rate_sweep_${MODEL_NAME}.log"
285
+ RESULT_ROOT="logs/frozenlake_slipper_rate_sweep_${MODEL_NAME}"
286
+ CHECKPOINT_ROOT="model_saving/frozenlake_slipper_rate_sweep_${MODEL_NAME}"
287
+
288
+ mkdir -p logs
289
+ mkdir -p "$RESULT_ROOT"
290
+ mkdir -p "$CHECKPOINT_ROOT"
291
+
292
+ echo "=== FrozenLake slipper_rate sweep (${MODEL_NAME}): $(date) ===" | tee "$LOG_FILE"
293
+ echo "Slipper rates: ${SLIPPER_RATES} | Modes: ${FILTER_MODES} | Steps: ${STEPS}" | tee -a "$LOG_FILE"
294
+ echo "Filter top-p: ${FILTER_TOP_P} | NoFilter top-p: ${NOFILTER_TOP_P}" | tee -a "$LOG_FILE"
295
+ echo "GPU groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s | ray_num_cpus=${RAY_NUM_CPUS}" | tee -a "$LOG_FILE"
296
+
297
+ run_experiment() {
298
+ local mode="$1"
299
+ local top_p="$2"
300
+ local include_zero="$3"
301
+ local slipper_rate="$4"
302
+ local success_rate="$5"
303
+ local gpu_list="$6"
304
+
305
+ local slip_pct
306
+ slip_pct=$(python - "$slipper_rate" <<'PY'
307
+ import sys
308
+ s = float(sys.argv[1])
309
+ print(f"{s * 100:.1f}")
310
+ PY
311
+ )
312
+ local slip_label
313
+ slip_label=$(format_rate_label "$slipper_rate")
314
+ local safe_label="slip${slip_label}"
315
+ safe_label="${safe_label,,}"
316
+
317
+ local name="frozenlake_${mode}_${safe_label}-${MODEL_NAME}"
318
+ local task_dir="${RESULT_ROOT}/${mode}/${safe_label}"
319
+ local log_path="${task_dir}/${name}.log"
320
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${mode}/${safe_label}/${name}"
321
+ local gpus_per_exp
322
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
323
+ gpus_per_exp=${#gpu_ids[@]}
324
+
325
+ mkdir -p "$task_dir"
326
+ mkdir -p "$checkpoint_dir"
327
+
328
+ START=$(date +%s)
329
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$CONFIG_NAME" \
330
+ model_path="${MODEL_PATH}" \
331
+ trainer.project_name="${PROJECT_NAME}" \
332
+ trainer.experiment_name="${name}" \
333
+ trainer.total_training_steps="${STEPS}" \
334
+ trainer.save_freq="${SAVE_FREQ}" \
335
+ trainer.default_local_dir="${checkpoint_dir}" \
336
+ trainer.logger="['console','wandb']" \
337
+ trainer.val_before_train=True \
338
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
339
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
340
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
341
+ algorithm.adv_estimator=gae \
342
+ actor_rollout_ref.actor.loss_agg_mode=token-mean \
343
+ actor_rollout_ref.actor.use_kl_loss=False \
344
+ actor_rollout_ref.actor.kl_loss_type=low-var-kl \
345
+ actor_rollout_ref.actor.kl_loss_coef=0 \
346
+ actor_rollout_ref.actor.entropy_coeff=0 \
347
+ actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
348
+ actor_rollout_ref.actor.filter_loss_scaling=none \
349
+ actor_rollout_ref.actor.ppo_mini_batch_size=32 \
350
+ actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
351
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 \
352
+ critic.ppo_mini_batch_size=32 \
353
+ critic.ppo_micro_batch_size_per_gpu=4 \
354
+ ppo_mini_batch_size=32 \
355
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
356
+ actor_rollout_ref.rollout.gpu_memory_utilization="${GPU_MEMORY_UTILIZATION}" \
357
+ actor_rollout_ref.rollout.rollout_filter_strategy=top_p \
358
+ actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax \
359
+ actor_rollout_ref.rollout.rollout_filter_value="${top_p}" \
360
+ actor_rollout_ref.rollout.rollout_filter_include_zero="${include_zero}" \
361
+ actor_rollout_ref.rollout.rollout_filter_type=largest \
362
+ actor_rollout_ref.rollout.rollout_filter_metric=reward_variance \
363
+ custom_envs.CoordFrozenLake.env_config.success_rate="${success_rate}" \
364
+ actor_rollout_ref.actor.checkpoint.save_contents=[model] \
365
+ critic.checkpoint.save_contents=[model] \
366
+ 2>&1 | tee "$log_path"
367
+ EXIT_CODE=${PIPESTATUS[0]}
368
+ END=$(date +%s)
369
+ TOTAL_TIME=$((END - START))
370
+
371
+ timing_values=()
372
+ mapfile -t timing_values < <(
373
+ python - "$log_path" <<'PY'
374
+ import re
375
+ import sys
376
+ from pathlib import Path
377
+
378
+ def last(pattern, text):
379
+ matches = re.findall(pattern, text)
380
+ return matches[-1] if matches else ""
381
+
382
+ try:
383
+ text = Path(sys.argv[1]).read_text(errors="ignore")
384
+ except Exception:
385
+ text = ""
386
+
387
+ patterns = [
388
+ r"timing_s/train_total[:\\s]+([\\d.]+)",
389
+ r"timing_s/eval_total[:\\s]+([\\d.]+)",
390
+ r"timing_s/total[:\\s]+([\\d.]+)",
391
+ ]
392
+
393
+ for pattern in patterns:
394
+ print(last(pattern, text))
395
+ PY
396
+ )
397
+
398
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
399
+ EVAL_TIME_RAW="${timing_values[1]:-}"
400
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
401
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
402
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
403
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
404
+
405
+ local status="success"
406
+ local error_line=""
407
+ if [ $EXIT_CODE -ne 0 ]; then
408
+ status="fail"
409
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
410
+ fi
411
+
412
+ local gpu_label
413
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
414
+ local summary_line="mode=${mode} | slipper_rate=${slipper_rate} (${slip_pct}%) | success_rate=${success_rate} | top_p=${top_p} | include_zero=${include_zero} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
415
+ echo "${summary_line}" > "${task_dir}/${name}.result"
416
+ echo "${summary_line}" | tee -a "$LOG_FILE"
417
+ if [ "$status" = "fail" ]; then
418
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
419
+ fi
420
+ }
421
+
422
+ QUEUE_FILE=$(mktemp -t ragen_frozenlake_slipper_queue.XXXXXX)
423
+ echo 0 > "$QUEUE_FILE"
424
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
425
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
426
+ USE_FLOCK=false
427
+ MAIN_PID=$$
428
+
429
+ cleanup_queue() {
430
+ if [ "$MAIN_PID" != "$$" ]; then
431
+ return
432
+ fi
433
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
434
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
435
+ }
436
+ trap cleanup_queue EXIT
437
+
438
+ if command -v flock >/dev/null 2>&1; then
439
+ USE_FLOCK=true
440
+ fi
441
+
442
+ next_experiment_index() {
443
+ local idx
444
+ if [ "$USE_FLOCK" = true ]; then
445
+ flock -x "$QUEUE_LOCK_FD"
446
+ idx=$(cat "$QUEUE_FILE")
447
+ if [ -z "$idx" ]; then
448
+ idx=0
449
+ fi
450
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
451
+ flock -u "$QUEUE_LOCK_FD"
452
+ echo -1
453
+ return
454
+ fi
455
+ echo $((idx + 1)) > "$QUEUE_FILE"
456
+ flock -u "$QUEUE_LOCK_FD"
457
+ echo "$idx"
458
+ return
459
+ fi
460
+
461
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
462
+ sleep 0.05
463
+ done
464
+ idx=$(cat "$QUEUE_FILE")
465
+ if [ -z "$idx" ]; then
466
+ idx=0
467
+ fi
468
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
469
+ rmdir "$QUEUE_LOCK_DIR"
470
+ echo -1
471
+ return
472
+ fi
473
+ echo $((idx + 1)) > "$QUEUE_FILE"
474
+ rmdir "$QUEUE_LOCK_DIR"
475
+ echo "$idx"
476
+ }
477
+
478
+ run_queue_for_slot() {
479
+ local gpu_list="$1"
480
+ if [ "$USE_FLOCK" = true ]; then
481
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
482
+ fi
483
+ while true; do
484
+ local idx
485
+ idx=$(next_experiment_index)
486
+ if [ "$idx" -lt 0 ]; then
487
+ break
488
+ fi
489
+ IFS='|' read -r mode top_p include_zero slipper_rate success_rate <<< "${EXPERIMENTS[$idx]}"
490
+ run_experiment "$mode" "$top_p" "$include_zero" "$slipper_rate" "$success_rate" "$gpu_list" || true
491
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
492
+ sleep "$COOLDOWN_SECONDS"
493
+ fi
494
+ done
495
+ if [ "$USE_FLOCK" = true ]; then
496
+ exec {QUEUE_LOCK_FD}>&-
497
+ fi
498
+ }
499
+
500
+ pids=()
501
+ for idx in "${!GPU_GROUPS[@]}"; do
502
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
503
+ pids+=("$!")
504
+ done
505
+
506
+ for pid in "${pids[@]}"; do
507
+ wait "$pid"
508
+ done
509
+
510
+ {
511
+ echo ""
512
+ echo "=== FrozenLake slipper_rate Sweep Summary ==="
513
+ echo "Project: ${PROJECT_NAME} | Steps: ${STEPS} | Modes: ${FILTER_MODES}"
514
+ for exp in "${EXPERIMENTS[@]}"; do
515
+ IFS='|' read -r mode top_p include_zero slipper_rate success_rate <<< "$exp"
516
+ slip_label=$(format_rate_label "$slipper_rate")
517
+ safe_label="slip${slip_label}"
518
+ safe_label="${safe_label,,}"
519
+ name="frozenlake_${mode}_${safe_label}-${MODEL_NAME}"
520
+ task_dir="${RESULT_ROOT}/${mode}/${safe_label}"
521
+ if [ -f "${task_dir}/${name}.result" ]; then
522
+ cat "${task_dir}/${name}.result"
523
+ else
524
+ echo "mode=${mode} | slipper_rate=${slipper_rate} | top_p=${top_p} | status=missing"
525
+ fi
526
+ done
527
+ } | tee -a "$LOG_FILE"
scripts/runs/run_kl_sweep.sh ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # KL coefficient sweep for sokoban + GAE, fixing entropy at 0 and top_p filtering.
3
+ set -euo pipefail
4
+
5
+ # Defaults
6
+ STEPS=400
7
+ MODEL_NAME="Qwen2.5-3B"
8
+ MODEL_PATH="Qwen/${MODEL_NAME}"
9
+ PROJECT_NAME="ragen_release_kl_sweep"
10
+ CONFIG_NAME="_2_sokoban"
11
+ SAVE_FREQ=-1
12
+ KL_VALUES="0,0.001,0.003,0.01,0.03,0.1"
13
+ ROLL_FILTER_INCLUDE_ZERO="True"
14
+ GPUS=()
15
+ GPUS_PROVIDED=false
16
+ GPUS_PER_EXP=1
17
+ COOLDOWN_SECONDS=0
18
+ GPU_MEMORY_UTILIZATION=0.5
19
+ RAY_NUM_CPUS=16
20
+
21
+ usage() {
22
+ cat <<'EOF'
23
+ Usage: $0 [options]
24
+ Options:
25
+ --steps N Training steps (default: 400)
26
+ --kl-values LIST Comma-separated kl_loss_coef values (default: 0,0.001,0.003,0.01,0.03,0.1)
27
+ --rollout_filter_include_zero BOOL Whether rollout_filter_include_zero (default: True)
28
+ --gpus LIST Comma-separated GPU IDs
29
+ --gpus-per-exp N GPUs per experiment (default: 1)
30
+ --ray-num-cpus N Max CPUs per task for ray.init (default: 16)
31
+ --gpu-memory-utilization V GPU memory utilization for rollouts (default: 0.5)
32
+ --save-freq N Checkpoint save frequency (default: -1)
33
+ -h, --help Show this help
34
+ EOF
35
+ exit 0
36
+ }
37
+
38
+ parse_bool() {
39
+ local val="${1,,}"
40
+ case "$val" in
41
+ true|1|yes|y) echo "True" ;;
42
+ false|0|no|n) echo "False" ;;
43
+ *)
44
+ echo "Error: expected boolean, got '$1'" >&2
45
+ exit 1
46
+ ;;
47
+ esac
48
+ }
49
+
50
+ while [ $# -gt 0 ]; do
51
+ case "$1" in
52
+ --steps) STEPS="$2"; shift 2 ;;
53
+ --steps=*) STEPS="${1#*=}"; shift ;;
54
+ --kl-values) KL_VALUES="$2"; shift 2 ;;
55
+ --kl-values=*) KL_VALUES="${1#*=}"; shift ;;
56
+ --rollout_filter_include_zero) ROLL_FILTER_INCLUDE_ZERO=$(parse_bool "$2"); shift 2 ;;
57
+ --rollout_filter_include_zero=*) ROLL_FILTER_INCLUDE_ZERO=$(parse_bool "${1#*=}"); shift ;;
58
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
59
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
60
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
61
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
62
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
63
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
64
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
65
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
66
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
67
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
68
+ -h|--help) usage ;;
69
+ *) echo "Unknown argument: $1"; usage ;;
70
+ esac
71
+ done
72
+
73
+ if [ "$GPUS_PROVIDED" = false ]; then
74
+ if command -v nvidia-smi >/dev/null 2>&1; then
75
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
76
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
77
+ GPUS=()
78
+ for ((i=0; i<GPU_COUNT; i++)); do
79
+ GPUS+=("$i")
80
+ done
81
+ fi
82
+ fi
83
+ if [ ${#GPUS[@]} -eq 0 ]; then
84
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
85
+ GPUS=(0 1 2 3 4 5 6 7)
86
+ fi
87
+ fi
88
+
89
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
90
+ echo "Error: --gpus-per-exp must be a positive integer"
91
+ exit 1
92
+ fi
93
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
94
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
95
+ exit 1
96
+ fi
97
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
98
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
99
+ exit 1
100
+ fi
101
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
102
+ echo "Error: --ray-num-cpus must be a positive integer"
103
+ exit 1
104
+ fi
105
+
106
+ GPU_GROUPS=()
107
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
108
+ group="${GPUS[$i]}"
109
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
110
+ group+=",${GPUS[$((i+j))]}"
111
+ done
112
+ GPU_GROUPS+=("$group")
113
+ done
114
+ NUM_SLOTS=${#GPU_GROUPS[@]}
115
+
116
+ short_gpu_name() {
117
+ local name="$1"
118
+ local cleaned
119
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
120
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
121
+ echo "${BASH_REMATCH[1]}"
122
+ return
123
+ fi
124
+ echo "${cleaned%% *}"
125
+ }
126
+
127
+ declare -A GPU_LABELS
128
+ get_gpu_label() {
129
+ local gpu_id="$1"
130
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
131
+ echo "${GPU_LABELS[$gpu_id]}"
132
+ return
133
+ fi
134
+ local name=""
135
+ if command -v nvidia-smi >/dev/null 2>&1; then
136
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
137
+ fi
138
+ if [ -z "$name" ]; then
139
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
140
+ echo "${GPU_LABELS[$gpu_id]}"
141
+ return
142
+ fi
143
+ local short
144
+ short=$(short_gpu_name "$name")
145
+ GPU_LABELS[$gpu_id]="1x${short}"
146
+ echo "${GPU_LABELS[$gpu_id]}"
147
+ }
148
+
149
+ get_gpu_model_label() {
150
+ local models=()
151
+ local id label model
152
+ for id in "${GPUS[@]}"; do
153
+ label=$(get_gpu_label "$id")
154
+ model="${label#1x}"
155
+ models+=("$model")
156
+ done
157
+ local unique_models=()
158
+ local m found
159
+ for m in "${models[@]}"; do
160
+ found=false
161
+ for u in "${unique_models[@]}"; do
162
+ if [ "$u" = "$m" ]; then
163
+ found=true
164
+ break
165
+ fi
166
+ done
167
+ if [ "$found" = false ]; then
168
+ unique_models+=("$m")
169
+ fi
170
+ done
171
+ if [ ${#unique_models[@]} -eq 1 ]; then
172
+ echo "${unique_models[0]}"
173
+ else
174
+ echo "mixed"
175
+ fi
176
+ }
177
+
178
+ get_gpu_label_for_list() {
179
+ local gpu_list="$1"
180
+ IFS=',' read -r -a ids <<< "$gpu_list"
181
+ local count=${#ids[@]}
182
+ if [ "$count" -eq 0 ]; then
183
+ echo "0xGPU"
184
+ return
185
+ fi
186
+ local first_model
187
+ first_model="$(get_gpu_label "${ids[0]}")"
188
+ first_model="${first_model#1x}"
189
+ local id model
190
+ for id in "${ids[@]:1}"; do
191
+ model="$(get_gpu_label "$id")"
192
+ model="${model#1x}"
193
+ if [ "$model" != "$first_model" ]; then
194
+ echo "${count}xmixed"
195
+ return
196
+ fi
197
+ done
198
+ echo "${count}x${first_model}"
199
+ }
200
+
201
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
202
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
203
+ LOG_FILE="logs/kl_sweep_${MODEL_NAME}.log"
204
+ RESULT_ROOT="logs/kl_sweep_${MODEL_NAME}"
205
+ CHECKPOINT_ROOT="model_saving/kl_sweep_${MODEL_NAME}"
206
+
207
+ mkdir -p logs
208
+ mkdir -p "$RESULT_ROOT"
209
+ mkdir -p "$CHECKPOINT_ROOT"
210
+
211
+ echo "=== KL Sweep Runner (${MODEL_NAME}): $(date) ===" | tee "$LOG_FILE"
212
+ echo "Values: ${KL_VALUES} | Steps: ${STEPS} | GPUs per exp: ${GPU_LOG_LABEL}" | tee -a "$LOG_FILE"
213
+ echo "Groups: ${GPU_GROUPS[*]} | GPU memory util: ${GPU_MEMORY_UTILIZATION} | ray_num_cpus: ${RAY_NUM_CPUS} | save_freq: ${SAVE_FREQ}" | tee -a "$LOG_FILE"
214
+
215
+ parse_values() {
216
+ IFS=',' read -r -a raw <<< "$1"
217
+ VALUES=()
218
+ for token in "${raw[@]}"; do
219
+ token="${token// /}"
220
+ if [ -n "$token" ]; then
221
+ VALUES+=("$token")
222
+ fi
223
+ done
224
+ if [ ${#VALUES[@]} -eq 0 ]; then
225
+ echo "Error: no entries provided for value list" >&2
226
+ exit 1
227
+ fi
228
+ }
229
+
230
+ parse_values "$KL_VALUES"
231
+ EXPERIMENTS=("${VALUES[@]}")
232
+
233
+ run_experiment() {
234
+ local value="$1"
235
+ local gpu_list="$2"
236
+ local safe_label="${value//./}"
237
+ local use_kl_loss="False"
238
+ if [ "$value" != "0" ]; then
239
+ use_kl_loss="True"
240
+ fi
241
+ safe_label="${safe_label,,}"
242
+ local filter_tag="nofilter"
243
+ if [ "${ROLL_FILTER_INCLUDE_ZERO}" = "False" ]; then
244
+ filter_tag="filter_zero"
245
+ fi
246
+
247
+ local name="sokoban_kl_sweep_${filter_tag}_${safe_label}-${MODEL_NAME}"
248
+ local task_dir="${RESULT_ROOT}/${filter_tag}/${safe_label}"
249
+ local log_path="${task_dir}/${name}.log"
250
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${safe_label}/${name}"
251
+ local gpus_per_exp
252
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
253
+ gpus_per_exp=${#gpu_ids[@]}
254
+
255
+ mkdir -p "$task_dir"
256
+ mkdir -p "$checkpoint_dir"
257
+
258
+ START=$(date +%s)
259
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$CONFIG_NAME" \
260
+ model_path="${MODEL_PATH}" \
261
+ trainer.project_name="${PROJECT_NAME}" \
262
+ trainer.experiment_name="${name}" \
263
+ trainer.total_training_steps="${STEPS}" \
264
+ trainer.save_freq="${SAVE_FREQ}" \
265
+ trainer.default_local_dir="${checkpoint_dir}" \
266
+ trainer.logger="['console','wandb']" \
267
+ trainer.val_before_train=True \
268
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
269
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
270
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
271
+ algorithm.adv_estimator=gae \
272
+ actor_rollout_ref.actor.use_kl_loss=${use_kl_loss} \
273
+ actor_rollout_ref.actor.kl_loss_coef="${value}" \
274
+ actor_rollout_ref.actor.entropy_coeff=0.0 \
275
+ actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
276
+ actor_rollout_ref.actor.filter_loss_scaling=none \
277
+ actor_rollout_ref.actor.ppo_mini_batch_size=32 \
278
+ actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
279
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 \
280
+ critic.ppo_mini_batch_size=32 \
281
+ critic.ppo_micro_batch_size_per_gpu=4 \
282
+ ppo_mini_batch_size=32 \
283
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
284
+ actor_rollout_ref.rollout.rollout_filter_strategy=top_p \
285
+ actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax \
286
+ actor_rollout_ref.rollout.rollout_filter_value=1 \
287
+ actor_rollout_ref.rollout.rollout_filter_include_zero=${ROLL_FILTER_INCLUDE_ZERO} \
288
+ actor_rollout_ref.rollout.rollout_filter_type=largest \
289
+ actor_rollout_ref.rollout.gpu_memory_utilization="${GPU_MEMORY_UTILIZATION}" \
290
+ actor_rollout_ref.rollout.rollout_filter_metric=reward_variance \
291
+ es_manager.train.env_groups=8 \
292
+ es_manager.train.group_size=16 \
293
+ es_manager.train.env_configs.n_groups='[8]' \
294
+ es_manager.val.env_groups=512 \
295
+ es_manager.val.group_size=1 \
296
+ es_manager.val.env_configs.n_groups='[512]' \
297
+ 2>&1 | tee "$log_path"
298
+ EXIT_CODE=${PIPESTATUS[0]}
299
+
300
+ END=$(date +%s)
301
+ TOTAL_TIME=$((END - START))
302
+
303
+ timing_values=()
304
+ mapfile -t timing_values < <(
305
+ python - "$log_path" <<'PY'
306
+ import re
307
+ import sys
308
+ from pathlib import Path
309
+
310
+ def last(pattern, text):
311
+ matches = re.findall(pattern, text)
312
+ return matches[-1] if matches else ""
313
+
314
+ try:
315
+ text = Path(sys.argv[1]).read_text(errors="ignore")
316
+ except Exception:
317
+ text = ""
318
+
319
+ patterns = [
320
+ r"timing_s/train_total[:\s]+([\d.]+)",
321
+ r"timing_s/eval_total[:\s]+([\d.]+)",
322
+ r"timing_s/total[:\s]+([\d.]+)",
323
+ ]
324
+
325
+ for pattern in patterns:
326
+ print(last(pattern, text))
327
+ PY
328
+ )
329
+
330
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
331
+ EVAL_TIME_RAW="${timing_values[1]:-}"
332
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
333
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
334
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
335
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
336
+
337
+ local status="success"
338
+ local error_line=""
339
+ if [ $EXIT_CODE -ne 0 ]; then
340
+ status="fail"
341
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
342
+ fi
343
+
344
+ local gpu_label
345
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
346
+ local summary_line="kl=${value} | filter=${filter_tag} | include_zero=${ROLL_FILTER_INCLUDE_ZERO} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
347
+ echo "${summary_line}" > "${task_dir}/${name}.result"
348
+ echo "${summary_line}" | tee -a "$LOG_FILE"
349
+ if [ "$status" = "fail" ]; then
350
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
351
+ fi
352
+ }
353
+
354
+ EXPERIMENT_COUNT=${#EXPERIMENTS[@]}
355
+ if [ $EXPERIMENT_COUNT -eq 0 ]; then
356
+ echo "No experiments to run" >&2
357
+ exit 1
358
+ fi
359
+
360
+ QUEUE_FILE=$(mktemp -t ragen_kl_queue.XXXXXX)
361
+ echo 0 > "$QUEUE_FILE"
362
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
363
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
364
+ USE_FLOCK=false
365
+ MAIN_PID=$$
366
+
367
+ cleanup_queue() {
368
+ if [ "$MAIN_PID" != "$$" ]; then
369
+ return
370
+ fi
371
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
372
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
373
+ }
374
+ trap cleanup_queue EXIT
375
+
376
+ if command -v flock >/dev/null 2>&1; then
377
+ USE_FLOCK=true
378
+ fi
379
+
380
+ next_experiment_index() {
381
+ local idx
382
+ if [ "$USE_FLOCK" = true ]; then
383
+ flock -x "$QUEUE_LOCK_FD"
384
+ idx=$(cat "$QUEUE_FILE")
385
+ if [ -z "$idx" ]; then
386
+ idx=0
387
+ fi
388
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
389
+ flock -u "$QUEUE_LOCK_FD"
390
+ echo -1
391
+ return
392
+ fi
393
+ echo $((idx + 1)) > "$QUEUE_FILE"
394
+ flock -u "$QUEUE_LOCK_FD"
395
+ echo "$idx"
396
+ return
397
+ fi
398
+
399
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
400
+ sleep 0.05
401
+ done
402
+ idx=$(cat "$QUEUE_FILE")
403
+ if [ -z "$idx" ]; then
404
+ idx=0
405
+ fi
406
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
407
+ rmdir "$QUEUE_LOCK_DIR"
408
+ echo -1
409
+ return
410
+ fi
411
+ echo $((idx + 1)) > "$QUEUE_FILE"
412
+ rmdir "$QUEUE_LOCK_DIR"
413
+ echo "$idx"
414
+ }
415
+
416
+ run_queue_for_slot() {
417
+ local gpu_list="$1"
418
+ if [ "$USE_FLOCK" = true ]; then
419
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
420
+ fi
421
+ while true; do
422
+ local idx
423
+ idx=$(next_experiment_index)
424
+ if [ "$idx" -lt 0 ]; then
425
+ break
426
+ fi
427
+ local value="${EXPERIMENTS[$idx]}"
428
+ run_experiment "$value" "$gpu_list" || true
429
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
430
+ sleep "$COOLDOWN_SECONDS"
431
+ fi
432
+ done
433
+ if [ "$USE_FLOCK" = true ]; then
434
+ exec {QUEUE_LOCK_FD}>&-
435
+ fi
436
+ }
437
+
438
+ pids=()
439
+ for idx in "${!GPU_GROUPS[@]}"; do
440
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
441
+ pids+=("$!")
442
+ done
443
+
444
+ for pid in "${pids[@]}"; do
445
+ wait "$pid"
446
+ done
447
+
448
+ {
449
+ echo ""
450
+ echo "=== KL Sweep Summary ==="
451
+ echo "Project: ${PROJECT_NAME} | Steps: ${STEPS} | GPU per exp: ${GPU_LOG_LABEL}"
452
+ for value in "${EXPERIMENTS[@]}"; do
453
+ safe_label="${value//./}"
454
+ safe_label="${safe_label,,}"
455
+ filter_tag="nofilter"
456
+ if [ "${ROLL_FILTER_INCLUDE_ZERO}" = "False" ]; then
457
+ filter_tag="filter_zero"
458
+ fi
459
+ name="sokoban_kl_sweep_${filter_tag}_${safe_label}-${MODEL_NAME}"
460
+ task_dir="${RESULT_ROOT}/${filter_tag}/${safe_label}"
461
+ if [ -f "${task_dir}/${name}.result" ]; then
462
+ cat "${task_dir}/${name}.result"
463
+ else
464
+ echo "kl=${value} | status=missing"
465
+ fi
466
+ done
467
+ } | tee -a "$LOG_FILE"
scripts/runs/run_main_table_diff_algo.sh ADDED
@@ -0,0 +1,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Main Table: Different algorithms (PPO/DAPO/GRPO/DrGRPO) × tasks × filter/no-filter
3
+ # Model: Qwen2.5-3B only
4
+ # Filtering rule: filter => top_p=0.9, nofilter => top_p=1.0
5
+
6
+ set -euo pipefail
7
+
8
+ # Defaults
9
+ STEPS=400
10
+ MODEL_NAME="Qwen2.5-3B"
11
+ TASKS=("sokoban" "frozenlake" "webshop" "metamathqa" "countdown")
12
+ ALGORITHMS=("PPO" "DAPO" "GRPO" "DrGRPO")
13
+ MODEL_PATH=""
14
+ SAVE_FREQ=-1
15
+ FILTER_MODES=("filter" "nofilter")
16
+ FILTERS_OPTION="all"
17
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
18
+
19
+ # GPU settings
20
+ GPUS=()
21
+ GPUS_PROVIDED=false
22
+ GPUS_PER_EXP=1
23
+ COOLDOWN_SECONDS=30
24
+ GPU_MEMORY_UTILIZATION=0.3
25
+ RAY_NUM_CPUS=16
26
+ declare -A GPU_LABELS
27
+
28
+ usage() {
29
+ echo "Usage: $0 [options]"
30
+ echo "Options:"
31
+ echo " --steps N Training steps (default: 400)"
32
+ echo " --tasks LIST Comma-separated tasks (default: sokoban,frozenlake,webshop,metamathqa,countdown)"
33
+ echo " --algos LIST Comma-separated algorithms (default: PPO,DAPO,GRPO,DrGRPO)"
34
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
35
+ echo " --gpus-per-exp N GPUs per experiment (default: 1)"
36
+ echo " --cooldown SECONDS Cooldown between runs on the same GPU group (default: 30)"
37
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
38
+ echo " --ray-num-cpus N Max CPUs per task for ray.init (default: 16)"
39
+ echo " --save-freq N Checkpoint save frequency (default: -1 to disable saving)"
40
+ echo " --filters LIST Comma-separated filter modes (filter,nofilter,all). Default: all"
41
+ echo " -h, --help Show this help"
42
+ exit 0
43
+ }
44
+
45
+ while [ $# -gt 0 ]; do
46
+ case "$1" in
47
+ --steps) STEPS="$2"; shift 2 ;;
48
+ --steps=*) STEPS="${1#*=}"; shift ;;
49
+ --tasks) IFS=',' read -r -a TASKS <<< "$2"; shift 2 ;;
50
+ --tasks=*) IFS=',' read -r -a TASKS <<< "${1#*=}"; shift ;;
51
+ --algos) IFS=',' read -r -a ALGORITHMS <<< "$2"; shift 2 ;;
52
+ --algos=*) IFS=',' read -r -a ALGORITHMS <<< "${1#*=}"; shift ;;
53
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
54
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
55
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
56
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
57
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
58
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
59
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
60
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
61
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
62
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
63
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
64
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
65
+ --filters) FILTERS_OPTION="$2"; shift 2 ;;
66
+ --filters=*) FILTERS_OPTION="${1#*=}"; shift ;;
67
+ -h|--help) usage ;;
68
+ *) echo "Unknown argument: $1"; usage ;;
69
+ esac
70
+ done
71
+
72
+ MODEL_PATH="Qwen/${MODEL_NAME}"
73
+
74
+ if [ "$GPUS_PROVIDED" = false ]; then
75
+ if command -v nvidia-smi >/dev/null 2>&1; then
76
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
77
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
78
+ GPUS=()
79
+ for ((i=0; i<GPU_COUNT; i++)); do
80
+ GPUS+=("$i")
81
+ done
82
+ fi
83
+ fi
84
+ if [ ${#GPUS[@]} -eq 0 ]; then
85
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
86
+ GPUS=(0 1 2 3 4 5 6 7)
87
+ fi
88
+ fi
89
+
90
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
91
+ echo "Error: --gpus-per-exp must be a positive integer"
92
+ exit 1
93
+ fi
94
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
95
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
96
+ exit 1
97
+ fi
98
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
99
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
100
+ exit 1
101
+ fi
102
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
103
+ echo "Error: --ray-num-cpus must be a positive integer"
104
+ exit 1
105
+ fi
106
+
107
+ GPU_GROUPS=()
108
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
109
+ group="${GPUS[$i]}"
110
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
111
+ group+=",${GPUS[$((i+j))]}"
112
+ done
113
+ GPU_GROUPS+=("$group")
114
+ done
115
+ NUM_SLOTS=${#GPU_GROUPS[@]}
116
+
117
+ short_gpu_name() {
118
+ local name="$1"
119
+ local cleaned
120
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
121
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
122
+ echo "${BASH_REMATCH[1]}"
123
+ return
124
+ fi
125
+ echo "${cleaned%% *}"
126
+ }
127
+
128
+ get_gpu_label() {
129
+ local gpu_id="$1"
130
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
131
+ echo "${GPU_LABELS[$gpu_id]}"
132
+ return
133
+ fi
134
+ local name=""
135
+ if command -v nvidia-smi >/dev/null 2>&1; then
136
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
137
+ fi
138
+ if [ -z "$name" ]; then
139
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
140
+ echo "${GPU_LABELS[$gpu_id]}"
141
+ return
142
+ fi
143
+ local short
144
+ short=$(short_gpu_name "$name")
145
+ GPU_LABELS[$gpu_id]="1x${short}"
146
+ echo "${GPU_LABELS[$gpu_id]}"
147
+ }
148
+
149
+ get_gpu_model_label() {
150
+ local models=()
151
+ local id label model
152
+ for id in "${GPUS[@]}"; do
153
+ label=$(get_gpu_label "$id")
154
+ model="${label#1x}"
155
+ models+=("$model")
156
+ done
157
+ local unique_models=()
158
+ local m found
159
+ for m in "${models[@]}"; do
160
+ found=false
161
+ for u in "${unique_models[@]}"; do
162
+ if [ "$u" = "$m" ]; then
163
+ found=true
164
+ break
165
+ fi
166
+ done
167
+ if [ "$found" = false ]; then
168
+ unique_models+=("$m")
169
+ fi
170
+ done
171
+ if [ ${#unique_models[@]} -eq 1 ]; then
172
+ echo "${unique_models[0]}"
173
+ else
174
+ echo "mixed"
175
+ fi
176
+ }
177
+
178
+ get_gpu_label_for_list() {
179
+ local gpu_list="$1"
180
+ IFS=',' read -r -a ids <<< "$gpu_list"
181
+ local count=${#ids[@]}
182
+ if [ "$count" -eq 0 ]; then
183
+ echo "0xGPU"
184
+ return
185
+ fi
186
+ local first_model
187
+ first_model="$(get_gpu_label "${ids[0]}")"
188
+ first_model="${first_model#1x}"
189
+ local id model
190
+ for id in "${ids[@]:1}"; do
191
+ model="$(get_gpu_label "$id")"
192
+ model="${model#1x}"
193
+ if [ "$model" != "$first_model" ]; then
194
+ echo "${count}xmixed"
195
+ return
196
+ fi
197
+ done
198
+ echo "${count}x${first_model}"
199
+ }
200
+
201
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
202
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
203
+ LOG_FILE="logs/diff_algo_${MODEL_NAME}.log"
204
+ RESULT_ROOT="logs"
205
+ CHECKPOINT_ROOT="model_saving/diff_algo_${MODEL_NAME}"
206
+
207
+ mkdir -p logs
208
+ mkdir -p "$RESULT_ROOT"
209
+ mkdir -p "$CHECKPOINT_ROOT"
210
+
211
+ echo "=== Perf Table Runner for ${MODEL_NAME}: $(date) ===" | tee "$LOG_FILE"
212
+ echo "Tasks: ${TASKS[*]} | Steps: ${STEPS} | GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL}" | tee -a "$LOG_FILE"
213
+ echo "GPUS: ${GPUS[*]} | groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s" | tee -a "$LOG_FILE"
214
+
215
+ get_config_for_task() {
216
+ case "$1" in
217
+ countdown) echo "_4_countdown" ;;
218
+ sokoban) echo "_2_sokoban" ;;
219
+ frozenlake) echo "_3_frozen_lake" ;;
220
+ webshop) echo "_6_webshop" ;;
221
+ metamathqa) echo "_5_metamathqa" ;;
222
+ *) echo "" ;;
223
+ esac
224
+ }
225
+
226
+ get_algo_overrides() {
227
+ case "$1" in
228
+ PPO)
229
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
230
+ ;;
231
+ DAPO)
232
+ # DAPO here = PPO + higher clip + no KL + token-level loss.
233
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean actor_rollout_ref.actor.clip_ratio_low=0.2 actor_rollout_ref.actor.clip_ratio_high=0.28 actor_rollout_ref.actor.use_kl_loss=False actor_rollout_ref.actor.kl_loss_coef=0.0 algorithm.use_kl_in_reward=False algorithm.kl_ctrl.kl_coef=0.0"
234
+ ;;
235
+ GRPO)
236
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=True actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean"
237
+ ;;
238
+ DrGRPO)
239
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=False actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-sum"
240
+ ;;
241
+ *)
242
+ echo ""
243
+ ;;
244
+ esac
245
+ }
246
+
247
+ run_experiment() {
248
+ local task=$1
249
+ local algo=$2
250
+ local filter=$3
251
+ local config=$4
252
+ local gpu_list=$5
253
+
254
+ local filter_value
255
+ if [ "$filter" = "filter" ]; then
256
+ filter_value=0.9
257
+ else
258
+ filter_value=1.0
259
+ fi
260
+ local filter_strategy="top_p"
261
+
262
+ local common_overrides=(
263
+ "actor_rollout_ref.actor.use_kl_loss=False"
264
+ "actor_rollout_ref.actor.kl_loss_type=low-var-kl"
265
+ "actor_rollout_ref.actor.kl_loss_coef=0.001"
266
+ "actor_rollout_ref.actor.entropy_coeff=0.001"
267
+ "actor_rollout_ref.actor.entropy_from_logits_with_chunking=True"
268
+ "actor_rollout_ref.actor.filter_loss_scaling=none"
269
+ "actor_rollout_ref.rollout.gpu_memory_utilization=${GPU_MEMORY_UTILIZATION}"
270
+ "actor_rollout_ref.rollout.rollout_filter_strategy=${filter_strategy}"
271
+ "actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax"
272
+ "actor_rollout_ref.rollout.rollout_filter_type=largest"
273
+ "actor_rollout_ref.rollout.rollout_filter_metric=reward_variance"
274
+ "actor_rollout_ref.rollout.rollout_filter_include_zero=True"
275
+ )
276
+
277
+ local env_overrides=()
278
+ if [ "$task" = "frozenlake" ]; then
279
+ env_overrides+=("custom_envs.CoordFrozenLake.env_config.success_rate=1.0")
280
+ fi
281
+
282
+ local checkpoint_overrides=(
283
+ "actor_rollout_ref.actor.checkpoint.save_contents=[model]"
284
+ "critic.checkpoint.save_contents=[model]"
285
+ )
286
+
287
+ local algo_overrides
288
+ algo_overrides=$(get_algo_overrides "$algo")
289
+ read -r -a algo_args <<< "$algo_overrides"
290
+
291
+ local name="${task}-${algo}-${filter}-${MODEL_NAME}"
292
+ local task_dir="${RESULT_ROOT}/diff_algo_${task}_${MODEL_NAME}"
293
+ local log_path="${task_dir}/${name}.log"
294
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${task}/${algo}/${filter}/${name}"
295
+ local gpus_per_exp
296
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
297
+ gpus_per_exp=${#gpu_ids[@]}
298
+
299
+ mkdir -p "$task_dir"
300
+ mkdir -p "${checkpoint_dir}"
301
+ START=$(date +%s)
302
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$config" \
303
+ model_path="${MODEL_PATH}" \
304
+ trainer.project_name="ragen_main_table_diff_algo" \
305
+ trainer.total_training_steps="${STEPS}" \
306
+ trainer.experiment_name="${name}" \
307
+ trainer.save_freq="${SAVE_FREQ}" \
308
+ trainer.default_local_dir="${checkpoint_dir}" \
309
+ trainer.logger="['console','wandb']" \
310
+ trainer.val_before_train=True \
311
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
312
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
313
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
314
+ actor_rollout_ref.rollout.rollout_filter_value="${filter_value}" \
315
+ "${common_overrides[@]}" \
316
+ "${env_overrides[@]}" \
317
+ "${checkpoint_overrides[@]}" \
318
+ "${algo_args[@]}" \
319
+ 2>&1 | tee "$log_path"
320
+ EXIT_CODE=${PIPESTATUS[0]}
321
+ END=$(date +%s)
322
+
323
+ TOTAL_TIME=$((END - START))
324
+ timing_values=()
325
+ mapfile -t timing_values < <(
326
+ python - "$log_path" <<'PY'
327
+ import re
328
+ import sys
329
+ from pathlib import Path
330
+
331
+ def last(pattern, text):
332
+ matches = re.findall(pattern, text)
333
+ return matches[-1] if matches else ""
334
+
335
+ try:
336
+ text = Path(sys.argv[1]).read_text(errors="ignore")
337
+ except Exception:
338
+ text = ""
339
+
340
+ patterns = [
341
+ r"timing_s/train_total[:\s]+([\d.]+)",
342
+ r"timing_s/eval_total[:\s]+([\d.]+)",
343
+ r"timing_s/total[:\s]+([\d.]+)",
344
+ ]
345
+
346
+ for pattern in patterns:
347
+ print(last(pattern, text))
348
+ PY
349
+ )
350
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
351
+ EVAL_TIME_RAW="${timing_values[1]:-}"
352
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
353
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
354
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
355
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
356
+
357
+ local status="success"
358
+ local error_line=""
359
+ if [ $EXIT_CODE -ne 0 ]; then
360
+ status="fail"
361
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
362
+ fi
363
+
364
+ local gpu_label
365
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
366
+ local summary_line="task=${task} | algo=${algo} | filter=${filter} | model=${MODEL_NAME} | steps=${STEPS} | filter=${filter_strategy}:${filter_value} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
367
+ echo "${summary_line}" > "${task_dir}/${name}.result"
368
+ echo "${summary_line}" | tee -a "$LOG_FILE"
369
+ if [ "$status" = "fail" ]; then
370
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
371
+ fi
372
+ return 0
373
+ }
374
+
375
+ EXPERIMENTS=()
376
+ GROUP_LABELS=()
377
+ CURRENT_GROUP=""
378
+
379
+ set_group() {
380
+ CURRENT_GROUP="$1"
381
+ GROUP_LABELS+=("$1")
382
+ }
383
+
384
+ add_experiment() {
385
+ local task=$1
386
+ local algo=$2
387
+ local filter=$3
388
+ local config=$4
389
+ EXPERIMENTS+=("${CURRENT_GROUP}|${task}|${algo}|${filter}|${config}")
390
+ }
391
+
392
+ resolve_filter_selection() {
393
+ local raw="$1"
394
+ if [ -z "$raw" ] || [ "$raw" = "all" ]; then
395
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
396
+ return
397
+ fi
398
+ IFS=',' read -r -a candidates <<< "$raw"
399
+ SELECTED_FILTERS=()
400
+ for candidate in "${candidates[@]}"; do
401
+ candidate="${candidate// /}"
402
+ case "$candidate" in
403
+ filter|nofilter)
404
+ SELECTED_FILTERS+=("$candidate")
405
+ ;;
406
+ "")
407
+ continue
408
+ ;;
409
+ *)
410
+ echo "Unknown filter mode: $candidate" >&2
411
+ exit 1
412
+ ;;
413
+ esac
414
+ done
415
+ if [ ${#SELECTED_FILTERS[@]} -eq 0 ]; then
416
+ echo "No valid filters selected via --filters" >&2
417
+ exit 1
418
+ fi
419
+ }
420
+
421
+ resolve_filter_selection "$FILTERS_OPTION"
422
+
423
+ for algo in "${ALGORITHMS[@]}"; do
424
+ set_group "Algorithm: ${algo}"
425
+ for task in "${TASKS[@]}"; do
426
+ config=$(get_config_for_task "$task")
427
+ if [ -z "$config" ]; then
428
+ echo "Unknown task: $task" >&2
429
+ exit 1
430
+ fi
431
+ for filter in "${SELECTED_FILTERS[@]}"; do
432
+ add_experiment "$task" "$algo" "$filter" "$config"
433
+ done
434
+ done
435
+ done
436
+
437
+ QUEUE_FILE=$(mktemp -t ragen_main_table_queue.XXXXXX)
438
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
439
+ echo 0 > "$QUEUE_FILE"
440
+ USE_FLOCK=false
441
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
442
+ MAIN_PID=$$
443
+
444
+ cleanup_queue() {
445
+ if [ "$$" -ne "$MAIN_PID" ]; then
446
+ return
447
+ fi
448
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
449
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
450
+ }
451
+ trap cleanup_queue EXIT
452
+
453
+ if command -v flock >/dev/null 2>&1; then
454
+ USE_FLOCK=true
455
+ fi
456
+
457
+ next_experiment_index() {
458
+ local idx
459
+ if [ "$USE_FLOCK" = true ]; then
460
+ flock -x "$QUEUE_LOCK_FD"
461
+ idx=$(cat "$QUEUE_FILE")
462
+ if [ -z "$idx" ]; then
463
+ idx=0
464
+ fi
465
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
466
+ flock -u "$QUEUE_LOCK_FD"
467
+ echo -1
468
+ return
469
+ fi
470
+ echo $((idx + 1)) > "$QUEUE_FILE"
471
+ flock -u "$QUEUE_LOCK_FD"
472
+ echo "$idx"
473
+ return
474
+ fi
475
+
476
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
477
+ sleep 0.05
478
+ done
479
+ idx=$(cat "$QUEUE_FILE")
480
+ if [ -z "$idx" ]; then
481
+ idx=0
482
+ fi
483
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
484
+ rmdir "$QUEUE_LOCK_DIR"
485
+ echo -1
486
+ return
487
+ fi
488
+ echo $((idx + 1)) > "$QUEUE_FILE"
489
+ rmdir "$QUEUE_LOCK_DIR"
490
+ echo "$idx"
491
+ }
492
+
493
+ run_queue_for_slot() {
494
+ local gpu_list=$1
495
+ if [ "$USE_FLOCK" = true ]; then
496
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
497
+ fi
498
+ while true; do
499
+ local idx
500
+ idx=$(next_experiment_index)
501
+ if [ "$idx" -lt 0 ]; then
502
+ break
503
+ fi
504
+ local exp="${EXPERIMENTS[$idx]}"
505
+ IFS='|' read -r exp_group task algo filter config <<< "$exp"
506
+ run_experiment "$task" "$algo" "$filter" "$config" "$gpu_list" || true
507
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
508
+ sleep "$COOLDOWN_SECONDS"
509
+ fi
510
+ done
511
+ if [ "$USE_FLOCK" = true ]; then
512
+ exec {QUEUE_LOCK_FD}>&-
513
+ fi
514
+ }
515
+
516
+ pids=()
517
+ for idx in "${!GPU_GROUPS[@]}"; do
518
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
519
+ pids+=("$!")
520
+ done
521
+
522
+ for pid in "${pids[@]}"; do
523
+ wait "$pid"
524
+ done
525
+
526
+ {
527
+ echo ""
528
+ echo "=== Grouped Summary ==="
529
+ echo "GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL} | Model: ${MODEL_NAME} | Steps: ${STEPS}"
530
+ for group_label in "${GROUP_LABELS[@]}"; do
531
+ echo "=== ${group_label} ==="
532
+ for exp in "${EXPERIMENTS[@]}"; do
533
+ IFS='|' read -r exp_group task algo filter config <<< "$exp"
534
+ if [ "$exp_group" != "$group_label" ]; then
535
+ continue
536
+ fi
537
+ name="${task}-${algo}-${filter}-${MODEL_NAME}"
538
+ task_dir="${RESULT_ROOT}/diff_algo_${task}_${MODEL_NAME}"
539
+ if [ -f "${task_dir}/${name}.result" ]; then
540
+ cat "${task_dir}/${name}.result"
541
+ else
542
+ echo "task=${task} | algo=${algo} | filter=${filter} | model=${MODEL_NAME} | status=missing"
543
+ fi
544
+ done
545
+ done
546
+ } | tee -a "$LOG_FILE"
scripts/runs/run_main_table_diff_model.sh ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Model Type: Different model types (Instruct/Reasoning) × tasks × filter/no-filter
3
+ # Algorithm: PPO only
4
+ # Filtering rule: filter => top_p=0.9, nofilter => top_p=1.0
5
+
6
+ set -euo pipefail
7
+
8
+ # Defaults
9
+ STEPS=400
10
+ MODEL_NAMES=("Qwen2.5-3B-Instruct")
11
+ TASKS=("sokoban" "frozenlake" "metamathqa" "countdown")
12
+ SAVE_FREQ=-1
13
+ FILTER_MODES=("filter" "nofilter")
14
+ FILTERS_OPTION="all"
15
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
16
+
17
+ # GPU settings
18
+ GPUS=()
19
+ GPUS_PROVIDED=false
20
+ GPUS_PER_EXP=1
21
+ COOLDOWN_SECONDS=30
22
+ GPU_MEMORY_UTILIZATION=0.3
23
+ RAY_NUM_CPUS=16
24
+ declare -A GPU_LABELS
25
+
26
+ usage() {
27
+ echo "Usage: $0 [options]"
28
+ echo "Options:"
29
+ echo " --steps N Training steps (default: 400)"
30
+ echo " --tasks LIST Comma-separated tasks (default: sokoban,frozenlake,webshop,metamathqa,countdown)"
31
+ echo " --models LIST Comma-separated model names or HF paths (default: Qwen2.5-3B-Instruct)"
32
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
33
+ echo " --gpus-per-exp N GPUs per experiment (default: 1)"
34
+ echo " --cooldown SECONDS Cooldown between runs on the same GPU group (default: 30)"
35
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
36
+ echo " --ray-num-cpus N Max CPUs per task for ray.init (default: 16)"
37
+ echo " --save-freq N Checkpoint save frequency (default: -1 to disable saving)"
38
+ echo " --filters LIST Comma-separated filter modes (filter,nofilter,all). Default: all"
39
+ echo " -h, --help Show this help"
40
+ exit 0
41
+ }
42
+
43
+ while [ $# -gt 0 ]; do
44
+ case "$1" in
45
+ --steps) STEPS="$2"; shift 2 ;;
46
+ --steps=*) STEPS="${1#*=}"; shift ;;
47
+ --tasks) IFS=',' read -r -a TASKS <<< "$2"; shift 2 ;;
48
+ --tasks=*) IFS=',' read -r -a TASKS <<< "${1#*=}"; shift ;;
49
+ --models) IFS=',' read -r -a MODEL_NAMES <<< "$2"; shift 2 ;;
50
+ --models=*) IFS=',' read -r -a MODEL_NAMES <<< "${1#*=}"; shift ;;
51
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
52
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
53
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
54
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
55
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
56
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
57
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
58
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
59
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
60
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
61
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
62
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
63
+ --filters) FILTERS_OPTION="$2"; shift 2 ;;
64
+ --filters=*) FILTERS_OPTION="${1#*=}"; shift ;;
65
+ -h|--help) usage ;;
66
+ *) echo "Unknown argument: $1"; usage ;;
67
+ esac
68
+ done
69
+
70
+ # Map model names to HuggingFace paths
71
+ get_model_path() {
72
+ if [[ "$1" == *"/"* ]]; then
73
+ echo "$1"
74
+ return
75
+ fi
76
+ case "$1" in
77
+ Qwen2.5-3B-Instruct) echo "Qwen/Qwen2.5-3B-Instruct" ;;
78
+ QwQ-32B) echo "Qwen/QwQ-32B" ;;
79
+ Llama-3.2-3B-Instruct) echo "meta-llama/Llama-3.2-3B-Instruct" ;;
80
+ *) echo "Qwen/$1" ;;
81
+ esac
82
+ }
83
+
84
+ if [ "$GPUS_PROVIDED" = false ]; then
85
+ if command -v nvidia-smi >/dev/null 2>&1; then
86
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
87
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
88
+ GPUS=()
89
+ for ((i=0; i<GPU_COUNT; i++)); do
90
+ GPUS+=("$i")
91
+ done
92
+ fi
93
+ fi
94
+ if [ ${#GPUS[@]} -eq 0 ]; then
95
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
96
+ GPUS=(0 1 2 3 4 5 6 7)
97
+ fi
98
+ fi
99
+
100
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
101
+ echo "Error: --gpus-per-exp must be a positive integer"
102
+ exit 1
103
+ fi
104
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
105
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
106
+ exit 1
107
+ fi
108
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
109
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
110
+ exit 1
111
+ fi
112
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
113
+ echo "Error: --ray-num-cpus must be a positive integer"
114
+ exit 1
115
+ fi
116
+
117
+ GPU_GROUPS=()
118
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
119
+ group="${GPUS[$i]}"
120
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
121
+ group+=",${GPUS[$((i+j))]}"
122
+ done
123
+ GPU_GROUPS+=("$group")
124
+ done
125
+ NUM_SLOTS=${#GPU_GROUPS[@]}
126
+
127
+ short_gpu_name() {
128
+ local name="$1"
129
+ local cleaned
130
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
131
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
132
+ echo "${BASH_REMATCH[1]}"
133
+ return
134
+ fi
135
+ echo "${cleaned%% *}"
136
+ }
137
+
138
+ get_gpu_label() {
139
+ local gpu_id="$1"
140
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
141
+ echo "${GPU_LABELS[$gpu_id]}"
142
+ return
143
+ fi
144
+ local name=""
145
+ if command -v nvidia-smi >/dev/null 2>&1; then
146
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
147
+ fi
148
+ if [ -z "$name" ]; then
149
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
150
+ echo "${GPU_LABELS[$gpu_id]}"
151
+ return
152
+ fi
153
+ local short
154
+ short=$(short_gpu_name "$name")
155
+ GPU_LABELS[$gpu_id]="1x${short}"
156
+ echo "${GPU_LABELS[$gpu_id]}"
157
+ }
158
+
159
+ get_gpu_model_label() {
160
+ local models=()
161
+ local id label model
162
+ for id in "${GPUS[@]}"; do
163
+ label=$(get_gpu_label "$id")
164
+ model="${label#1x}"
165
+ models+=("$model")
166
+ done
167
+ local unique_models=()
168
+ local m found
169
+ for m in "${models[@]}"; do
170
+ found=false
171
+ for u in "${unique_models[@]}"; do
172
+ if [ "$u" = "$m" ]; then
173
+ found=true
174
+ break
175
+ fi
176
+ done
177
+ if [ "$found" = false ]; then
178
+ unique_models+=("$m")
179
+ fi
180
+ done
181
+ if [ ${#unique_models[@]} -eq 1 ]; then
182
+ echo "${unique_models[0]}"
183
+ else
184
+ echo "mixed"
185
+ fi
186
+ }
187
+
188
+ get_gpu_label_for_list() {
189
+ local gpu_list="$1"
190
+ IFS=',' read -r -a ids <<< "$gpu_list"
191
+ local count=${#ids[@]}
192
+ if [ "$count" -eq 0 ]; then
193
+ echo "0xGPU"
194
+ return
195
+ fi
196
+ local first_model
197
+ first_model="$(get_gpu_label "${ids[0]}")"
198
+ first_model="${first_model#1x}"
199
+ local id model
200
+ for id in "${ids[@]:1}"; do
201
+ model="$(get_gpu_label "$id")"
202
+ model="${model#1x}"
203
+ if [ "$model" != "$first_model" ]; then
204
+ echo "${count}xmixed"
205
+ return
206
+ fi
207
+ done
208
+ echo "${count}x${first_model}"
209
+ }
210
+
211
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
212
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
213
+ LOG_FILE="logs/diff_model_PPO.log"
214
+ RESULT_ROOT="logs"
215
+ CHECKPOINT_ROOT="model_saving/diff_model"
216
+
217
+ mkdir -p logs
218
+ mkdir -p "$RESULT_ROOT"
219
+ mkdir -p "$CHECKPOINT_ROOT"
220
+
221
+ echo "=== Model Type Runner (PPO): $(date) ===" | tee "$LOG_FILE"
222
+ echo "Models: ${MODEL_NAMES[*]} | Tasks: ${TASKS[*]} | Steps: ${STEPS} | GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL}" | tee -a "$LOG_FILE"
223
+ echo "GPUS: ${GPUS[*]} | groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s" | tee -a "$LOG_FILE"
224
+
225
+ get_config_for_task() {
226
+ case "$1" in
227
+ countdown) echo "_4_countdown" ;;
228
+ sokoban) echo "_2_sokoban" ;;
229
+ frozenlake) echo "_3_frozen_lake" ;;
230
+ webshop) echo "_6_webshop" ;;
231
+ metamathqa) echo "_5_metamathqa" ;;
232
+ *) echo "" ;;
233
+ esac
234
+ }
235
+
236
+ run_experiment() {
237
+ local task=$1
238
+ local model_name=$2
239
+ local filter=$3
240
+ local config=$4
241
+ local gpu_list=$5
242
+
243
+ local model_path
244
+ model_path=$(get_model_path "$model_name")
245
+ local algo="PPO"
246
+ local safe_model_name="${model_name//\//__}"
247
+
248
+ local filter_value
249
+ if [ "$filter" = "filter" ]; then
250
+ filter_value=0.9
251
+ else
252
+ filter_value=1.0
253
+ fi
254
+ local filter_strategy="top_p"
255
+
256
+ local common_overrides=(
257
+ "actor_rollout_ref.actor.use_kl_loss=False"
258
+ "actor_rollout_ref.actor.kl_loss_type=low-var-kl"
259
+ "actor_rollout_ref.actor.kl_loss_coef=0.001"
260
+ "actor_rollout_ref.actor.entropy_coeff=0.001"
261
+ "actor_rollout_ref.actor.entropy_from_logits_with_chunking=True"
262
+ "actor_rollout_ref.actor.filter_loss_scaling=none"
263
+ "actor_rollout_ref.rollout.gpu_memory_utilization=${GPU_MEMORY_UTILIZATION}"
264
+ "actor_rollout_ref.rollout.rollout_filter_strategy=${filter_strategy}"
265
+ "actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax"
266
+ "actor_rollout_ref.rollout.rollout_filter_type=largest"
267
+ "actor_rollout_ref.rollout.rollout_filter_metric=reward_variance"
268
+ "actor_rollout_ref.rollout.rollout_filter_include_zero=True"
269
+ )
270
+
271
+ local env_overrides=()
272
+ if [ "$task" = "frozenlake" ]; then
273
+ env_overrides+=("custom_envs.CoordFrozenLake.env_config.success_rate=1.0")
274
+ fi
275
+
276
+ local checkpoint_overrides=(
277
+ "actor_rollout_ref.actor.checkpoint.save_contents=[model]"
278
+ "critic.checkpoint.save_contents=[model]"
279
+ )
280
+
281
+ # PPO algorithm overrides
282
+ local algo_overrides="algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
283
+ read -r -a algo_args <<< "$algo_overrides"
284
+
285
+ local name="${task}-${algo}-${filter}-${safe_model_name}"
286
+ local task_dir="${RESULT_ROOT}/diff_model_${task}"
287
+ local log_path="${task_dir}/${name}.log"
288
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${task}/${safe_model_name}/${filter}/${name}"
289
+ local gpus_per_exp
290
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
291
+ gpus_per_exp=${#gpu_ids[@]}
292
+
293
+ mkdir -p "$task_dir"
294
+ mkdir -p "${checkpoint_dir}"
295
+ START=$(date +%s)
296
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$config" \
297
+ model_path="${model_path}" \
298
+ trainer.project_name="ragen_main_table_diff_model" \
299
+ trainer.total_training_steps="${STEPS}" \
300
+ trainer.experiment_name="${name}" \
301
+ trainer.save_freq="${SAVE_FREQ}" \
302
+ trainer.default_local_dir="${checkpoint_dir}" \
303
+ trainer.logger="['console','wandb']" \
304
+ trainer.val_before_train=True \
305
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
306
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
307
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
308
+ actor_rollout_ref.rollout.rollout_filter_value="${filter_value}" \
309
+ "${common_overrides[@]}" \
310
+ "${env_overrides[@]}" \
311
+ "${checkpoint_overrides[@]}" \
312
+ "${algo_args[@]}" \
313
+ 2>&1 | tee "$log_path"
314
+ EXIT_CODE=${PIPESTATUS[0]}
315
+ END=$(date +%s)
316
+
317
+ TOTAL_TIME=$((END - START))
318
+ timing_values=()
319
+ mapfile -t timing_values < <(
320
+ python - "$log_path" <<'PY'
321
+ import re
322
+ import sys
323
+ from pathlib import Path
324
+
325
+ def last(pattern, text):
326
+ matches = re.findall(pattern, text)
327
+ return matches[-1] if matches else ""
328
+
329
+ try:
330
+ text = Path(sys.argv[1]).read_text(errors="ignore")
331
+ except Exception:
332
+ text = ""
333
+
334
+ patterns = [
335
+ r"timing_s/train_total[:\s]+([\d.]+)",
336
+ r"timing_s/eval_total[:\s]+([\d.]+)",
337
+ r"timing_s/total[:\s]+([\d.]+)",
338
+ ]
339
+
340
+ for pattern in patterns:
341
+ print(last(pattern, text))
342
+ PY
343
+ )
344
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
345
+ EVAL_TIME_RAW="${timing_values[1]:-}"
346
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
347
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
348
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
349
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
350
+
351
+ local status="success"
352
+ local error_line=""
353
+ if [ $EXIT_CODE -ne 0 ]; then
354
+ status="fail"
355
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
356
+ fi
357
+
358
+ local gpu_label
359
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
360
+ local summary_line="task=${task} | algo=${algo} | filter=${filter} | model=${model_name} | steps=${STEPS} | filter=${filter_strategy}:${filter_value} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
361
+ echo "${summary_line}" > "${task_dir}/${name}.result"
362
+ echo "${summary_line}" | tee -a "$LOG_FILE"
363
+ if [ "$status" = "fail" ]; then
364
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
365
+ fi
366
+ return 0
367
+ }
368
+
369
+ EXPERIMENTS=()
370
+ GROUP_LABELS=()
371
+ CURRENT_GROUP=""
372
+
373
+ resolve_filter_selection() {
374
+ local raw="$1"
375
+ if [ -z "$raw" ] || [ "$raw" = "all" ]; then
376
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
377
+ return
378
+ fi
379
+ IFS=',' read -r -a candidates <<< "$raw"
380
+ SELECTED_FILTERS=()
381
+ for candidate in "${candidates[@]}"; do
382
+ candidate="${candidate// /}"
383
+ case "$candidate" in
384
+ filter|nofilter)
385
+ SELECTED_FILTERS+=("$candidate")
386
+ ;;
387
+ "")
388
+ continue
389
+ ;;
390
+ *)
391
+ echo "Unknown filter mode: $candidate" >&2
392
+ exit 1
393
+ ;;
394
+ esac
395
+ done
396
+ if [ ${#SELECTED_FILTERS[@]} -eq 0 ]; then
397
+ echo "No valid filters selected via --filters" >&2
398
+ exit 1
399
+ fi
400
+ }
401
+
402
+ set_group() {
403
+ CURRENT_GROUP="$1"
404
+ GROUP_LABELS+=("$1")
405
+ }
406
+
407
+ add_experiment() {
408
+ local task=$1
409
+ local model_name=$2
410
+ local filter=$3
411
+ local config=$4
412
+ EXPERIMENTS+=("${CURRENT_GROUP}|${task}|${model_name}|${filter}|${config}")
413
+ }
414
+
415
+ resolve_filter_selection "$FILTERS_OPTION"
416
+
417
+ for model_name in "${MODEL_NAMES[@]}"; do
418
+ set_group "Model: ${model_name}"
419
+ for task in "${TASKS[@]}"; do
420
+ config=$(get_config_for_task "$task")
421
+ if [ -z "$config" ]; then
422
+ echo "Unknown task: $task" >&2
423
+ exit 1
424
+ fi
425
+ for filter in "${SELECTED_FILTERS[@]}"; do
426
+ add_experiment "$task" "$model_name" "$filter" "$config"
427
+ done
428
+ done
429
+ done
430
+
431
+ QUEUE_FILE=$(mktemp -t ragen_model_type_queue.XXXXXX)
432
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
433
+ echo 0 > "$QUEUE_FILE"
434
+ USE_FLOCK=false
435
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
436
+ MAIN_PID=$$
437
+
438
+ cleanup_queue() {
439
+ if [ "$$" -ne "$MAIN_PID" ]; then
440
+ return
441
+ fi
442
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
443
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
444
+ }
445
+ trap cleanup_queue EXIT
446
+
447
+ if command -v flock >/dev/null 2>&1; then
448
+ USE_FLOCK=true
449
+ fi
450
+
451
+ next_experiment_index() {
452
+ local idx
453
+ if [ "$USE_FLOCK" = true ]; then
454
+ flock -x "$QUEUE_LOCK_FD"
455
+ idx=$(cat "$QUEUE_FILE")
456
+ if [ -z "$idx" ]; then
457
+ idx=0
458
+ fi
459
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
460
+ flock -u "$QUEUE_LOCK_FD"
461
+ echo -1
462
+ return
463
+ fi
464
+ echo $((idx + 1)) > "$QUEUE_FILE"
465
+ flock -u "$QUEUE_LOCK_FD"
466
+ echo "$idx"
467
+ return
468
+ fi
469
+
470
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
471
+ sleep 0.05
472
+ done
473
+ idx=$(cat "$QUEUE_FILE")
474
+ if [ -z "$idx" ]; then
475
+ idx=0
476
+ fi
477
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
478
+ rmdir "$QUEUE_LOCK_DIR"
479
+ echo -1
480
+ return
481
+ fi
482
+ echo $((idx + 1)) > "$QUEUE_FILE"
483
+ rmdir "$QUEUE_LOCK_DIR"
484
+ echo "$idx"
485
+ }
486
+
487
+ run_queue_for_slot() {
488
+ local gpu_list=$1
489
+ if [ "$USE_FLOCK" = true ]; then
490
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
491
+ fi
492
+ while true; do
493
+ local idx
494
+ idx=$(next_experiment_index)
495
+ if [ "$idx" -lt 0 ]; then
496
+ break
497
+ fi
498
+ local exp="${EXPERIMENTS[$idx]}"
499
+ IFS='|' read -r exp_group task model_name filter config <<< "$exp"
500
+ run_experiment "$task" "$model_name" "$filter" "$config" "$gpu_list" || true
501
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
502
+ sleep "$COOLDOWN_SECONDS"
503
+ fi
504
+ done
505
+ if [ "$USE_FLOCK" = true ]; then
506
+ exec {QUEUE_LOCK_FD}>&-
507
+ fi
508
+ }
509
+
510
+ pids=()
511
+ for idx in "${!GPU_GROUPS[@]}"; do
512
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
513
+ pids+=("$!")
514
+ done
515
+
516
+ for pid in "${pids[@]}"; do
517
+ wait "$pid"
518
+ done
519
+
520
+ {
521
+ echo ""
522
+ echo "=== Grouped Summary ==="
523
+ echo "GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL} | Algorithm: PPO | Steps: ${STEPS}"
524
+ for group_label in "${GROUP_LABELS[@]}"; do
525
+ echo "=== ${group_label} ==="
526
+ for exp in "${EXPERIMENTS[@]}"; do
527
+ IFS='|' read -r exp_group task model_name filter config <<< "$exp"
528
+ if [ "$exp_group" != "$group_label" ]; then
529
+ continue
530
+ fi
531
+ local safe_model_name="${model_name//\//__}"
532
+ name="${task}-PPO-${filter}-${safe_model_name}"
533
+ task_dir="${RESULT_ROOT}/diff_model_${task}"
534
+ if [ -f "${task_dir}/${name}.result" ]; then
535
+ cat "${task_dir}/${name}.result"
536
+ else
537
+ echo "task=${task} | algo=PPO | filter=${filter} | model=${model_name} | status=missing"
538
+ fi
539
+ done
540
+ done
541
+ } | tee -a "$LOG_FILE"
scripts/runs/run_main_table_diff_size.sh ADDED
@@ -0,0 +1,524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Model Size: Different model sizes (0.5B/1.5B/3B/7B) × tasks × filter/no-filter
3
+ # Algorithm: PPO only
4
+ # Filtering rule: filter => top_p=0.9, nofilter => top_p=1.0
5
+
6
+ set -euo pipefail
7
+
8
+ # Defaults
9
+ STEPS=400
10
+ MODEL_NAMES=("Qwen2.5-0.5B" "Qwen2.5-1.5B" "Qwen2.5-3B" "Qwen2.5-7B")
11
+ TASKS=("sokoban" "frozenlake" "webshop" "metamathqa" "countdown")
12
+ SAVE_FREQ=-1
13
+ FILTER_MODES=("filter" "nofilter")
14
+ FILTERS_OPTION="all"
15
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
16
+
17
+ # GPU settings
18
+ GPUS=()
19
+ GPUS_PROVIDED=false
20
+ GPUS_PER_EXP=1
21
+ COOLDOWN_SECONDS=30
22
+ GPU_MEMORY_UTILIZATION=0.3
23
+ RAY_NUM_CPUS=16
24
+ declare -A GPU_LABELS
25
+
26
+ usage() {
27
+ echo "Usage: $0 [options]"
28
+ echo "Options:"
29
+ echo " --steps N Training steps (default: 400)"
30
+ echo " --tasks LIST Comma-separated tasks (default: sokoban,frozenlake,webshop,metamathqa,countdown)"
31
+ echo " --models LIST Comma-separated model names (default: Qwen2.5-0.5B,Qwen2.5-1.5B,Qwen2.5-3B,Qwen2.5-7B)"
32
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
33
+ echo " --gpus-per-exp N GPUs per experiment (default: 1)"
34
+ echo " --cooldown SECONDS Cooldown between runs on the same GPU group (default: 30)"
35
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
36
+ echo " --ray-num-cpus N Max CPUs per task for ray.init (default: 16)"
37
+ echo " --save-freq N Checkpoint save frequency (default: -1 to disable saving)"
38
+ echo " --filters LIST Comma-separated filter modes (filter,nofilter,all). Default: all"
39
+ echo " -h, --help Show this help"
40
+ exit 0
41
+ }
42
+
43
+ while [ $# -gt 0 ]; do
44
+ case "$1" in
45
+ --steps) STEPS="$2"; shift 2 ;;
46
+ --steps=*) STEPS="${1#*=}"; shift ;;
47
+ --tasks) IFS=',' read -r -a TASKS <<< "$2"; shift 2 ;;
48
+ --tasks=*) IFS=',' read -r -a TASKS <<< "${1#*=}"; shift ;;
49
+ --models) IFS=',' read -r -a MODEL_NAMES <<< "$2"; shift 2 ;;
50
+ --models=*) IFS=',' read -r -a MODEL_NAMES <<< "${1#*=}"; shift ;;
51
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
52
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
53
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
54
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
55
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
56
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
57
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
58
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
59
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
60
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
61
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
62
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
63
+ --filters) FILTERS_OPTION="$2"; shift 2 ;;
64
+ --filters=*) FILTERS_OPTION="${1#*=}"; shift ;;
65
+ -h|--help) usage ;;
66
+ *) echo "Unknown argument: $1"; usage ;;
67
+ esac
68
+ done
69
+
70
+ if [ "$GPUS_PROVIDED" = false ]; then
71
+ if command -v nvidia-smi >/dev/null 2>&1; then
72
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
73
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
74
+ GPUS=()
75
+ for ((i=0; i<GPU_COUNT; i++)); do
76
+ GPUS+=("$i")
77
+ done
78
+ fi
79
+ fi
80
+ if [ ${#GPUS[@]} -eq 0 ]; then
81
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
82
+ GPUS=(0 1 2 3 4 5 6 7)
83
+ fi
84
+ fi
85
+
86
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
87
+ echo "Error: --gpus-per-exp must be a positive integer"
88
+ exit 1
89
+ fi
90
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
91
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
92
+ exit 1
93
+ fi
94
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
95
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
96
+ exit 1
97
+ fi
98
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
99
+ echo "Error: --ray-num-cpus must be a positive integer"
100
+ exit 1
101
+ fi
102
+
103
+ GPU_GROUPS=()
104
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
105
+ group="${GPUS[$i]}"
106
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
107
+ group+=",${GPUS[$((i+j))]}"
108
+ done
109
+ GPU_GROUPS+=("$group")
110
+ done
111
+ NUM_SLOTS=${#GPU_GROUPS[@]}
112
+
113
+ short_gpu_name() {
114
+ local name="$1"
115
+ local cleaned
116
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
117
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
118
+ echo "${BASH_REMATCH[1]}"
119
+ return
120
+ fi
121
+ echo "${cleaned%% *}"
122
+ }
123
+
124
+ get_gpu_label() {
125
+ local gpu_id="$1"
126
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
127
+ echo "${GPU_LABELS[$gpu_id]}"
128
+ return
129
+ fi
130
+ local name=""
131
+ if command -v nvidia-smi >/dev/null 2>&1; then
132
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
133
+ fi
134
+ if [ -z "$name" ]; then
135
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
136
+ echo "${GPU_LABELS[$gpu_id]}"
137
+ return
138
+ fi
139
+ local short
140
+ short=$(short_gpu_name "$name")
141
+ GPU_LABELS[$gpu_id]="1x${short}"
142
+ echo "${GPU_LABELS[$gpu_id]}"
143
+ }
144
+
145
+ get_gpu_model_label() {
146
+ local models=()
147
+ local id label model
148
+ for id in "${GPUS[@]}"; do
149
+ label=$(get_gpu_label "$id")
150
+ model="${label#1x}"
151
+ models+=("$model")
152
+ done
153
+ local unique_models=()
154
+ local m found
155
+ for m in "${models[@]}"; do
156
+ found=false
157
+ for u in "${unique_models[@]}"; do
158
+ if [ "$u" = "$m" ]; then
159
+ found=true
160
+ break
161
+ fi
162
+ done
163
+ if [ "$found" = false ]; then
164
+ unique_models+=("$m")
165
+ fi
166
+ done
167
+ if [ ${#unique_models[@]} -eq 1 ]; then
168
+ echo "${unique_models[0]}"
169
+ else
170
+ echo "mixed"
171
+ fi
172
+ }
173
+
174
+ get_gpu_label_for_list() {
175
+ local gpu_list="$1"
176
+ IFS=',' read -r -a ids <<< "$gpu_list"
177
+ local count=${#ids[@]}
178
+ if [ "$count" -eq 0 ]; then
179
+ echo "0xGPU"
180
+ return
181
+ fi
182
+ local first_model
183
+ first_model="$(get_gpu_label "${ids[0]}")"
184
+ first_model="${first_model#1x}"
185
+ local id model
186
+ for id in "${ids[@]:1}"; do
187
+ model="$(get_gpu_label "$id")"
188
+ model="${model#1x}"
189
+ if [ "$model" != "$first_model" ]; then
190
+ echo "${count}xmixed"
191
+ return
192
+ fi
193
+ done
194
+ echo "${count}x${first_model}"
195
+ }
196
+
197
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
198
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
199
+ LOG_FILE="logs/diff_size_PPO.log"
200
+ RESULT_ROOT="logs"
201
+ CHECKPOINT_ROOT="model_saving/diff_size"
202
+
203
+ mkdir -p logs
204
+ mkdir -p "$RESULT_ROOT"
205
+ mkdir -p "$CHECKPOINT_ROOT"
206
+
207
+ echo "=== Model Size Runner (PPO): $(date) ===" | tee "$LOG_FILE"
208
+ echo "Models: ${MODEL_NAMES[*]} | Tasks: ${TASKS[*]} | Steps: ${STEPS} | GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL}" | tee -a "$LOG_FILE"
209
+ echo "GPUS: ${GPUS[*]} | groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s" | tee -a "$LOG_FILE"
210
+
211
+ get_config_for_task() {
212
+ case "$1" in
213
+ countdown) echo "_4_countdown" ;;
214
+ sokoban) echo "_2_sokoban" ;;
215
+ frozenlake) echo "_3_frozen_lake" ;;
216
+ webshop) echo "_6_webshop" ;;
217
+ metamathqa) echo "_5_metamathqa" ;;
218
+ *) echo "" ;;
219
+ esac
220
+ }
221
+
222
+ run_experiment() {
223
+ local task=$1
224
+ local model_name=$2
225
+ local filter=$3
226
+ local config=$4
227
+ local gpu_list=$5
228
+
229
+ local model_path="Qwen/${model_name}"
230
+ local algo="PPO"
231
+
232
+ local filter_value
233
+ if [ "$filter" = "filter" ]; then
234
+ filter_value=0.9
235
+ else
236
+ filter_value=1.0
237
+ fi
238
+ local filter_strategy="top_p"
239
+
240
+ local common_overrides=(
241
+ "actor_rollout_ref.actor.use_kl_loss=False"
242
+ "actor_rollout_ref.actor.kl_loss_type=low-var-kl"
243
+ "actor_rollout_ref.actor.kl_loss_coef=0.001"
244
+ "actor_rollout_ref.actor.entropy_coeff=0.001"
245
+ "actor_rollout_ref.actor.entropy_from_logits_with_chunking=True"
246
+ "actor_rollout_ref.actor.filter_loss_scaling=none"
247
+ "actor_rollout_ref.rollout.gpu_memory_utilization=${GPU_MEMORY_UTILIZATION}"
248
+ "actor_rollout_ref.rollout.rollout_filter_strategy=${filter_strategy}"
249
+ "actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax"
250
+ "actor_rollout_ref.rollout.rollout_filter_type=largest"
251
+ "actor_rollout_ref.rollout.rollout_filter_metric=reward_variance"
252
+ "actor_rollout_ref.rollout.rollout_filter_include_zero=True"
253
+ )
254
+
255
+ local env_overrides=()
256
+ if [ "$task" = "frozenlake" ]; then
257
+ env_overrides+=("custom_envs.CoordFrozenLake.env_config.success_rate=1.0")
258
+ fi
259
+
260
+ local checkpoint_overrides=(
261
+ "actor_rollout_ref.actor.checkpoint.save_contents=[model]"
262
+ "critic.checkpoint.save_contents=[model]"
263
+ )
264
+
265
+ # PPO algorithm overrides
266
+ local algo_overrides="algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
267
+ read -r -a algo_args <<< "$algo_overrides"
268
+
269
+ local name="${task}-${algo}-${filter}-${model_name}"
270
+ local task_dir="${RESULT_ROOT}/diff_size_${task}"
271
+ local log_path="${task_dir}/${name}.log"
272
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${task}/${model_name}/${filter}/${name}"
273
+ local gpus_per_exp
274
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
275
+ gpus_per_exp=${#gpu_ids[@]}
276
+
277
+ mkdir -p "$task_dir"
278
+ mkdir -p "${checkpoint_dir}"
279
+ START=$(date +%s)
280
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$config" \
281
+ model_path="${model_path}" \
282
+ trainer.project_name="ragen_main_table_diff_size" \
283
+ trainer.total_training_steps="${STEPS}" \
284
+ trainer.experiment_name="${name}" \
285
+ trainer.save_freq="${SAVE_FREQ}" \
286
+ trainer.default_local_dir="${checkpoint_dir}" \
287
+ trainer.logger="['console','wandb']" \
288
+ trainer.val_before_train=True \
289
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
290
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
291
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
292
+ actor_rollout_ref.rollout.rollout_filter_value="${filter_value}" \
293
+ "${common_overrides[@]}" \
294
+ "${env_overrides[@]}" \
295
+ "${checkpoint_overrides[@]}" \
296
+ "${algo_args[@]}" \
297
+ 2>&1 | tee "$log_path"
298
+ EXIT_CODE=${PIPESTATUS[0]}
299
+ END=$(date +%s)
300
+
301
+ TOTAL_TIME=$((END - START))
302
+ timing_values=()
303
+ mapfile -t timing_values < <(
304
+ python - "$log_path" <<'PY'
305
+ import re
306
+ import sys
307
+ from pathlib import Path
308
+
309
+ def last(pattern, text):
310
+ matches = re.findall(pattern, text)
311
+ return matches[-1] if matches else ""
312
+
313
+ try:
314
+ text = Path(sys.argv[1]).read_text(errors="ignore")
315
+ except Exception:
316
+ text = ""
317
+
318
+ patterns = [
319
+ r"timing_s/train_total[:\s]+([\d.]+)",
320
+ r"timing_s/eval_total[:\s]+([\d.]+)",
321
+ r"timing_s/total[:\s]+([\d.]+)",
322
+ ]
323
+
324
+ for pattern in patterns:
325
+ print(last(pattern, text))
326
+ PY
327
+ )
328
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
329
+ EVAL_TIME_RAW="${timing_values[1]:-}"
330
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
331
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
332
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
333
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
334
+
335
+ local status="success"
336
+ local error_line=""
337
+ if [ $EXIT_CODE -ne 0 ]; then
338
+ status="fail"
339
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
340
+ fi
341
+
342
+ local gpu_label
343
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
344
+ local summary_line="task=${task} | algo=${algo} | filter=${filter} | model=${model_name} | steps=${STEPS} | filter=${filter_strategy}:${filter_value} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
345
+ echo "${summary_line}" > "${task_dir}/${name}.result"
346
+ echo "${summary_line}" | tee -a "$LOG_FILE"
347
+ if [ "$status" = "fail" ]; then
348
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
349
+ fi
350
+ return 0
351
+ }
352
+
353
+ EXPERIMENTS=()
354
+ GROUP_LABELS=()
355
+ CURRENT_GROUP=""
356
+
357
+ resolve_filter_selection() {
358
+ local raw="$1"
359
+ if [ -z "$raw" ] || [ "$raw" = "all" ]; then
360
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
361
+ return
362
+ fi
363
+ IFS=',' read -r -a candidates <<< "$raw"
364
+ SELECTED_FILTERS=()
365
+ for candidate in "${candidates[@]}"; do
366
+ candidate="${candidate// /}"
367
+ case "$candidate" in
368
+ filter|nofilter)
369
+ SELECTED_FILTERS+=("$candidate")
370
+ ;;
371
+ "")
372
+ continue
373
+ ;;
374
+ *)
375
+ echo "Unknown filter mode: $candidate" >&2
376
+ exit 1
377
+ ;;
378
+ esac
379
+ done
380
+ if [ ${#SELECTED_FILTERS[@]} -eq 0 ]; then
381
+ echo "No valid filters selected via --filters" >&2
382
+ exit 1
383
+ fi
384
+ }
385
+
386
+ set_group() {
387
+ CURRENT_GROUP="$1"
388
+ GROUP_LABELS+=("$1")
389
+ }
390
+
391
+ add_experiment() {
392
+ local task=$1
393
+ local model_name=$2
394
+ local filter=$3
395
+ local config=$4
396
+ EXPERIMENTS+=("${CURRENT_GROUP}|${task}|${model_name}|${filter}|${config}")
397
+ }
398
+
399
+ resolve_filter_selection "$FILTERS_OPTION"
400
+
401
+ for model_name in "${MODEL_NAMES[@]}"; do
402
+ set_group "Model: ${model_name}"
403
+ for task in "${TASKS[@]}"; do
404
+ config=$(get_config_for_task "$task")
405
+ if [ -z "$config" ]; then
406
+ echo "Unknown task: $task" >&2
407
+ exit 1
408
+ fi
409
+ for filter in "${SELECTED_FILTERS[@]}"; do
410
+ add_experiment "$task" "$model_name" "$filter" "$config"
411
+ done
412
+ done
413
+ done
414
+
415
+ QUEUE_FILE=$(mktemp -t ragen_model_size_queue.XXXXXX)
416
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
417
+ echo 0 > "$QUEUE_FILE"
418
+ USE_FLOCK=false
419
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
420
+ MAIN_PID=$$
421
+
422
+ cleanup_queue() {
423
+ if [ "$$" -ne "$MAIN_PID" ]; then
424
+ return
425
+ fi
426
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
427
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
428
+ }
429
+ trap cleanup_queue EXIT
430
+
431
+ if command -v flock >/dev/null 2>&1; then
432
+ USE_FLOCK=true
433
+ fi
434
+
435
+ next_experiment_index() {
436
+ local idx
437
+ if [ "$USE_FLOCK" = true ]; then
438
+ flock -x "$QUEUE_LOCK_FD"
439
+ idx=$(cat "$QUEUE_FILE")
440
+ if [ -z "$idx" ]; then
441
+ idx=0
442
+ fi
443
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
444
+ flock -u "$QUEUE_LOCK_FD"
445
+ echo -1
446
+ return
447
+ fi
448
+ echo $((idx + 1)) > "$QUEUE_FILE"
449
+ flock -u "$QUEUE_LOCK_FD"
450
+ echo "$idx"
451
+ return
452
+ fi
453
+
454
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
455
+ sleep 0.05
456
+ done
457
+ idx=$(cat "$QUEUE_FILE")
458
+ if [ -z "$idx" ]; then
459
+ idx=0
460
+ fi
461
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
462
+ rmdir "$QUEUE_LOCK_DIR"
463
+ echo -1
464
+ return
465
+ fi
466
+ echo $((idx + 1)) > "$QUEUE_FILE"
467
+ rmdir "$QUEUE_LOCK_DIR"
468
+ echo "$idx"
469
+ }
470
+
471
+ run_queue_for_slot() {
472
+ local gpu_list=$1
473
+ if [ "$USE_FLOCK" = true ]; then
474
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
475
+ fi
476
+ while true; do
477
+ local idx
478
+ idx=$(next_experiment_index)
479
+ if [ "$idx" -lt 0 ]; then
480
+ break
481
+ fi
482
+ local exp="${EXPERIMENTS[$idx]}"
483
+ IFS='|' read -r exp_group task model_name filter config <<< "$exp"
484
+ run_experiment "$task" "$model_name" "$filter" "$config" "$gpu_list" || true
485
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
486
+ sleep "$COOLDOWN_SECONDS"
487
+ fi
488
+ done
489
+ if [ "$USE_FLOCK" = true ]; then
490
+ exec {QUEUE_LOCK_FD}>&-
491
+ fi
492
+ }
493
+
494
+ pids=()
495
+ for idx in "${!GPU_GROUPS[@]}"; do
496
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
497
+ pids+=("$!")
498
+ done
499
+
500
+ for pid in "${pids[@]}"; do
501
+ wait "$pid"
502
+ done
503
+
504
+ {
505
+ echo ""
506
+ echo "=== Grouped Summary ==="
507
+ echo "GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL} | Algorithm: PPO | Steps: ${STEPS}"
508
+ for group_label in "${GROUP_LABELS[@]}"; do
509
+ echo "=== ${group_label} ==="
510
+ for exp in "${EXPERIMENTS[@]}"; do
511
+ IFS='|' read -r exp_group task model_name filter config <<< "$exp"
512
+ if [ "$exp_group" != "$group_label" ]; then
513
+ continue
514
+ fi
515
+ name="${task}-PPO-${filter}-${model_name}"
516
+ task_dir="${RESULT_ROOT}/diff_size_${task}"
517
+ if [ -f "${task_dir}/${name}.result" ]; then
518
+ cat "${task_dir}/${name}.result"
519
+ else
520
+ echo "task=${task} | algo=PPO | filter=${filter} | model=${model_name} | status=missing"
521
+ fi
522
+ done
523
+ done
524
+ } | tee -a "$LOG_FILE"
scripts/runs/run_search_benchmark.sh ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Search Benchmark: models × algorithms × filter/no-filter on SearchQA (HotpotQA + Dense Retrieval)
3
+ # Models: Qwen2.5-3B-Instruct, Qwen2.5-7B-Instruct, Llama-3.2-3B-Instruct
4
+ # Algorithms: PPO, GRPO
5
+ # Filtering rule: filter => top_p=0.9, nofilter => top_p=1.0
6
+
7
+ set -euo pipefail
8
+
9
+ # Activate ragen conda environment
10
+ eval "$(conda shell.bash hook 2>/dev/null || true)"
11
+ conda activate ragen 2>/dev/null || true
12
+
13
+ # Use user-writable datasets cache to avoid permission conflicts with root-owned lock files
14
+ export HF_DATASETS_CACHE="${HF_DATASETS_CACHE:-${HOME}/.hf_cache/datasets}"
15
+
16
+ # Defaults
17
+ STEPS=200
18
+ MODEL_NAMES=("Qwen2.5-3B-Instruct")
19
+ ALGORITHMS=("PPO")
20
+ SAVE_FREQ=-1
21
+ FILTER_STRATEGY="top_p"
22
+ FILTER_VALUE=""
23
+
24
+ # GPU settings
25
+ GPUS=()
26
+ GPUS_PROVIDED=false
27
+ GPUS_PER_EXP=1
28
+ COOLDOWN_SECONDS=30
29
+ GPU_MEMORY_UTILIZATION=0.6
30
+ TENSOR_PARALLEL_SIZE=1
31
+ MICRO_BATCH_SIZE=""
32
+ MINI_BATCH_SIZE=""
33
+ COLLAPSE_FREQ=""
34
+ RETRIEVAL_PORT=""
35
+ declare -A GPU_LABELS
36
+
37
+ usage() {
38
+ echo "Usage: $0 [options]"
39
+ echo "Options:"
40
+ echo " --steps N Training steps (default: 400)"
41
+ echo " --models LIST Comma-separated model names (default: Qwen2.5-3B-Instruct)"
42
+ echo " --algos LIST Comma-separated algorithms: PPO,GRPO (default: PPO)"
43
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
44
+ echo " --gpus-per-exp N GPUs per experiment (default: 1)"
45
+ echo " --cooldown SECONDS Cooldown between runs on the same GPU group (default: 30)"
46
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.6)"
47
+ echo " --tp N Tensor parallel size for vLLM rollout (default: 1)"
48
+ echo " --micro-batch N micro_batch_size_per_gpu override"
49
+ echo " --mini-batch N ppo_mini_batch_size override"
50
+ echo " --collapse-freq N collapse_detection.compute_freq override"
51
+ echo " --save-freq N Checkpoint save frequency (default: -1 to disable saving)"
52
+ echo " --retrieval-port N Retrieval server port (overrides default 8000 in config)"
53
+ echo " --filter-strategy S Rollout filter strategy: top_p, top_k, etc. (default: top_p)"
54
+ echo " --filter-value V Rollout filter value (default: 1.0 for no filtering)"
55
+ echo " -h, --help Show this help"
56
+ exit 0
57
+ }
58
+
59
+ while [ $# -gt 0 ]; do
60
+ case "$1" in
61
+ --steps) STEPS="$2"; shift 2 ;;
62
+ --steps=*) STEPS="${1#*=}"; shift ;;
63
+ --models) IFS=',' read -r -a MODEL_NAMES <<< "$2"; shift 2 ;;
64
+ --models=*) IFS=',' read -r -a MODEL_NAMES <<< "${1#*=}"; shift ;;
65
+ --algos) IFS=',' read -r -a ALGORITHMS <<< "$2"; shift 2 ;;
66
+ --algos=*) IFS=',' read -r -a ALGORITHMS <<< "${1#*=}"; shift ;;
67
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
68
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
69
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
70
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
71
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
72
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
73
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
74
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
75
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
76
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
77
+ --tp) TENSOR_PARALLEL_SIZE="$2"; shift 2 ;;
78
+ --tp=*) TENSOR_PARALLEL_SIZE="${1#*=}"; shift ;;
79
+ --micro-batch) MICRO_BATCH_SIZE="$2"; shift 2 ;;
80
+ --micro-batch=*) MICRO_BATCH_SIZE="${1#*=}"; shift ;;
81
+ --mini-batch) MINI_BATCH_SIZE="$2"; shift 2 ;;
82
+ --mini-batch=*) MINI_BATCH_SIZE="${1#*=}"; shift ;;
83
+ --collapse-freq) COLLAPSE_FREQ="$2"; shift 2 ;;
84
+ --collapse-freq=*) COLLAPSE_FREQ="${1#*=}"; shift ;;
85
+ --retrieval-port) RETRIEVAL_PORT="$2"; shift 2 ;;
86
+ --retrieval-port=*) RETRIEVAL_PORT="${1#*=}"; shift ;;
87
+ --filter-strategy) FILTER_STRATEGY="$2"; shift 2 ;;
88
+ --filter-strategy=*) FILTER_STRATEGY="${1#*=}"; shift ;;
89
+ --filter-value) FILTER_VALUE="$2"; shift 2 ;;
90
+ --filter-value=*) FILTER_VALUE="${1#*=}"; shift ;;
91
+ -h|--help) usage ;;
92
+ *) echo "Unknown argument: $1"; usage ;;
93
+ esac
94
+ done
95
+
96
+ # Default filter value: 1.0 (no filtering) if not specified
97
+ if [ -z "$FILTER_VALUE" ]; then
98
+ FILTER_VALUE=1.0
99
+ fi
100
+
101
+ # Derive a short filter label for experiment naming / logs
102
+ if [ "$FILTER_VALUE" = "1.0" ] || [ "$FILTER_VALUE" = "1" ]; then
103
+ FILTER_LABEL="nofilter"
104
+ else
105
+ FILTER_LABEL="${FILTER_STRATEGY}${FILTER_VALUE}"
106
+ fi
107
+
108
+ # Fixed: search task config
109
+ CONFIG="_9_search"
110
+
111
+ # Map model names to HuggingFace paths
112
+ get_model_path() {
113
+ if [[ "$1" == *"/"* ]]; then
114
+ echo "$1"
115
+ return
116
+ fi
117
+ case "$1" in
118
+ Qwen2.5-3B-Instruct) echo "Qwen/Qwen2.5-3B-Instruct" ;;
119
+ Qwen2.5-7B-Instruct) echo "Qwen/Qwen2.5-7B-Instruct" ;;
120
+ Llama-3.2-3B-Instruct) echo "meta-llama/Llama-3.2-3B-Instruct" ;;
121
+ *) echo "Qwen/$1" ;;
122
+ esac
123
+ }
124
+
125
+ # Algorithm-specific overrides
126
+ get_algo_overrides() {
127
+ case "$1" in
128
+ PPO)
129
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
130
+ ;;
131
+ GRPO)
132
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=True actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean"
133
+ ;;
134
+ *)
135
+ echo ""
136
+ ;;
137
+ esac
138
+ }
139
+
140
+ # Auto-detect GPUs
141
+ if [ "$GPUS_PROVIDED" = false ]; then
142
+ if command -v nvidia-smi >/dev/null 2>&1; then
143
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
144
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
145
+ GPUS=()
146
+ for ((i=0; i<GPU_COUNT; i++)); do
147
+ GPUS+=("$i")
148
+ done
149
+ fi
150
+ fi
151
+ if [ ${#GPUS[@]} -eq 0 ]; then
152
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
153
+ GPUS=(0 1 2 3 4 5 6 7)
154
+ fi
155
+ fi
156
+
157
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
158
+ echo "Error: --gpus-per-exp must be a positive integer"
159
+ exit 1
160
+ fi
161
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
162
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
163
+ exit 1
164
+ fi
165
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
166
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
167
+ exit 1
168
+ fi
169
+
170
+ GPU_GROUPS=()
171
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
172
+ group="${GPUS[$i]}"
173
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
174
+ group+=",${GPUS[$((i+j))]}"
175
+ done
176
+ GPU_GROUPS+=("$group")
177
+ done
178
+ NUM_SLOTS=${#GPU_GROUPS[@]}
179
+
180
+ short_gpu_name() {
181
+ local name="$1"
182
+ local cleaned
183
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
184
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
185
+ echo "${BASH_REMATCH[1]}"
186
+ return
187
+ fi
188
+ echo "${cleaned%% *}"
189
+ }
190
+
191
+ get_gpu_label() {
192
+ local gpu_id="$1"
193
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
194
+ echo "${GPU_LABELS[$gpu_id]}"
195
+ return
196
+ fi
197
+ local name=""
198
+ if command -v nvidia-smi >/dev/null 2>&1; then
199
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
200
+ fi
201
+ if [ -z "$name" ]; then
202
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
203
+ echo "${GPU_LABELS[$gpu_id]}"
204
+ return
205
+ fi
206
+ local short
207
+ short=$(short_gpu_name "$name")
208
+ GPU_LABELS[$gpu_id]="1x${short}"
209
+ echo "${GPU_LABELS[$gpu_id]}"
210
+ }
211
+
212
+ get_gpu_model_label() {
213
+ local models=()
214
+ local id label model
215
+ for id in "${GPUS[@]}"; do
216
+ label=$(get_gpu_label "$id")
217
+ model="${label#1x}"
218
+ models+=("$model")
219
+ done
220
+ local unique_models=()
221
+ local m found
222
+ for m in "${models[@]}"; do
223
+ found=false
224
+ for u in "${unique_models[@]}"; do
225
+ if [ "$u" = "$m" ]; then
226
+ found=true
227
+ break
228
+ fi
229
+ done
230
+ if [ "$found" = false ]; then
231
+ unique_models+=("$m")
232
+ fi
233
+ done
234
+ if [ ${#unique_models[@]} -eq 1 ]; then
235
+ echo "${unique_models[0]}"
236
+ else
237
+ echo "mixed"
238
+ fi
239
+ }
240
+
241
+ get_gpu_label_for_list() {
242
+ local gpu_list="$1"
243
+ IFS=',' read -r -a ids <<< "$gpu_list"
244
+ local count=${#ids[@]}
245
+ if [ "$count" -eq 0 ]; then
246
+ echo "0xGPU"
247
+ return
248
+ fi
249
+ local first_model
250
+ first_model="$(get_gpu_label "${ids[0]}")"
251
+ first_model="${first_model#1x}"
252
+ local id model
253
+ for id in "${ids[@]:1}"; do
254
+ model="$(get_gpu_label "$id")"
255
+ model="${model#1x}"
256
+ if [ "$model" != "$first_model" ]; then
257
+ echo "${count}xmixed"
258
+ return
259
+ fi
260
+ done
261
+ echo "${count}x${first_model}"
262
+ }
263
+
264
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
265
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
266
+ LOG_DIR="logs/search_benchmark"
267
+ LOG_FILE="logs/search_benchmark.log"
268
+ RESULT_ROOT="logs/search_benchmark"
269
+ CHECKPOINT_ROOT="model_saving/search_benchmark"
270
+
271
+ mkdir -p "$LOG_DIR"
272
+ mkdir -p "$RESULT_ROOT"
273
+ mkdir -p "$CHECKPOINT_ROOT"
274
+
275
+ echo "=== Search Benchmark Runner: $(date) ===" | tee "$LOG_FILE"
276
+ echo "Models: ${MODEL_NAMES[*]} | Algos: ${ALGORITHMS[*]} | Filter: ${FILTER_STRATEGY}:${FILTER_VALUE} | Steps: ${STEPS} | GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL}" | tee -a "$LOG_FILE"
277
+ echo "GPUS: ${GPUS[*]} | groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s" | tee -a "$LOG_FILE"
278
+
279
+ run_experiment() {
280
+ local model_name=$1
281
+ local algo=$2
282
+ local gpu_list=$3
283
+
284
+ local model_path
285
+ model_path=$(get_model_path "$model_name")
286
+
287
+ local filter_strategy="$FILTER_STRATEGY"
288
+ local filter_value="$FILTER_VALUE"
289
+
290
+ local common_overrides=(
291
+ "actor_rollout_ref.actor.use_kl_loss=False"
292
+ "actor_rollout_ref.actor.kl_loss_type=low-var-kl"
293
+ "actor_rollout_ref.actor.kl_loss_coef=0.001"
294
+ "actor_rollout_ref.actor.entropy_coeff=0.001"
295
+ "actor_rollout_ref.actor.entropy_from_logits_with_chunking=True"
296
+ "actor_rollout_ref.actor.filter_loss_scaling=none"
297
+ "actor_rollout_ref.rollout.gpu_memory_utilization=${GPU_MEMORY_UTILIZATION}"
298
+ "actor_rollout_ref.rollout.tensor_model_parallel_size=${TENSOR_PARALLEL_SIZE}"
299
+ )
300
+
301
+ if [ -n "$MICRO_BATCH_SIZE" ]; then
302
+ common_overrides+=("micro_batch_size_per_gpu=${MICRO_BATCH_SIZE}")
303
+ fi
304
+ if [ -n "$MINI_BATCH_SIZE" ]; then
305
+ common_overrides+=("ppo_mini_batch_size=${MINI_BATCH_SIZE}")
306
+ fi
307
+ if [ -n "$COLLAPSE_FREQ" ]; then
308
+ common_overrides+=("collapse_detection.compute_freq=${COLLAPSE_FREQ}")
309
+ fi
310
+
311
+ local checkpoint_overrides=(
312
+ "actor_rollout_ref.actor.checkpoint.save_contents=[model]"
313
+ "critic.checkpoint.save_contents=[model]"
314
+ )
315
+
316
+ local retrieval_overrides=()
317
+ if [ -n "$RETRIEVAL_PORT" ]; then
318
+ retrieval_overrides+=("+custom_envs.SearchQA.env_config.retrieval_server_url=http://127.0.0.1:${RETRIEVAL_PORT}")
319
+ fi
320
+
321
+ local algo_overrides
322
+ algo_overrides=$(get_algo_overrides "$algo")
323
+ read -r -a algo_args <<< "$algo_overrides"
324
+
325
+ local name="search-${algo}-${FILTER_LABEL}-${model_name}"
326
+ local log_path="${LOG_DIR}/${name}.log"
327
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${model_name}/${algo}/${FILTER_LABEL}/${name}"
328
+ local gpus_per_exp
329
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
330
+ gpus_per_exp=${#gpu_ids[@]}
331
+
332
+ # Limit Ray CPU workers to avoid spawning hundreds of idle workers (default: 8 per GPU)
333
+ local ray_num_cpus=$((gpus_per_exp * 8))
334
+ common_overrides+=("ray_kwargs.ray_init.num_cpus=${ray_num_cpus}")
335
+
336
+ mkdir -p "${checkpoint_dir}"
337
+ START=$(date +%s)
338
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$CONFIG" \
339
+ model_path="${model_path}" \
340
+ trainer.project_name="ragen_search_benchmark" \
341
+ trainer.total_training_steps="${STEPS}" \
342
+ trainer.experiment_name="${name}" \
343
+ trainer.save_freq="${SAVE_FREQ}" \
344
+ trainer.default_local_dir="${checkpoint_dir}" \
345
+ trainer.logger="['console','wandb']" \
346
+ trainer.val_before_train=True \
347
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
348
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
349
+ actor_rollout_ref.rollout.rollout_filter_strategy="${filter_strategy}" \
350
+ actor_rollout_ref.rollout.rollout_filter_value="${filter_value}" \
351
+ "${common_overrides[@]}" \
352
+ "${checkpoint_overrides[@]}" \
353
+ "${retrieval_overrides[@]}" \
354
+ "${algo_args[@]}" \
355
+ 2>&1 | tee "$log_path"
356
+ EXIT_CODE=${PIPESTATUS[0]}
357
+ END=$(date +%s)
358
+
359
+ TOTAL_TIME=$((END - START))
360
+ timing_values=()
361
+ mapfile -t timing_values < <(
362
+ python - "$log_path" <<'PY'
363
+ import re
364
+ import sys
365
+ from pathlib import Path
366
+
367
+ def last(pattern, text):
368
+ matches = re.findall(pattern, text)
369
+ return matches[-1] if matches else ""
370
+
371
+ try:
372
+ text = Path(sys.argv[1]).read_text(errors="ignore")
373
+ except Exception:
374
+ text = ""
375
+
376
+ patterns = [
377
+ r"timing_s/train_total[:\s]+([\d.]+)",
378
+ r"timing_s/eval_total[:\s]+([\d.]+)",
379
+ r"timing_s/total[:\s]+([\d.]+)",
380
+ ]
381
+
382
+ for pattern in patterns:
383
+ print(last(pattern, text))
384
+ PY
385
+ )
386
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
387
+ EVAL_TIME_RAW="${timing_values[1]:-}"
388
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
389
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
390
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
391
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
392
+
393
+ local status="success"
394
+ local error_line=""
395
+ if [ $EXIT_CODE -ne 0 ]; then
396
+ status="fail"
397
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
398
+ fi
399
+
400
+ local gpu_label
401
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
402
+ local summary_line="task=search | algo=${algo} | filter=${FILTER_LABEL} | model=${model_name} | steps=${STEPS} | strategy=${filter_strategy}:${filter_value} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
403
+ echo "${summary_line}" > "${LOG_DIR}/${name}.result"
404
+ echo "${summary_line}" | tee -a "$LOG_FILE"
405
+ if [ "$status" = "fail" ]; then
406
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
407
+ fi
408
+ return 0
409
+ }
410
+
411
+ EXPERIMENTS=()
412
+ GROUP_LABELS=()
413
+ CURRENT_GROUP=""
414
+
415
+ set_group() {
416
+ CURRENT_GROUP="$1"
417
+ GROUP_LABELS+=("$1")
418
+ }
419
+
420
+ add_experiment() {
421
+ local model_name=$1
422
+ local algo=$2
423
+ EXPERIMENTS+=("${CURRENT_GROUP}|${model_name}|${algo}")
424
+ }
425
+
426
+ # Build experiment list: models × algos (filter is a global setting)
427
+ for model_name in "${MODEL_NAMES[@]}"; do
428
+ for algo in "${ALGORITHMS[@]}"; do
429
+ set_group "${model_name} / ${algo}"
430
+ add_experiment "$model_name" "$algo"
431
+ done
432
+ done
433
+
434
+ QUEUE_FILE=$(mktemp -t ragen_search_bench_queue.XXXXXX)
435
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
436
+ echo 0 > "$QUEUE_FILE"
437
+ USE_FLOCK=false
438
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
439
+ MAIN_PID=$$
440
+
441
+ cleanup_queue() {
442
+ if [ "$$" -ne "$MAIN_PID" ]; then
443
+ return
444
+ fi
445
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
446
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
447
+ }
448
+ trap cleanup_queue EXIT
449
+
450
+ if command -v flock >/dev/null 2>&1; then
451
+ USE_FLOCK=true
452
+ fi
453
+
454
+ next_experiment_index() {
455
+ local idx
456
+ if [ "$USE_FLOCK" = true ]; then
457
+ flock -x "$QUEUE_LOCK_FD"
458
+ idx=$(cat "$QUEUE_FILE")
459
+ if [ -z "$idx" ]; then
460
+ idx=0
461
+ fi
462
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
463
+ flock -u "$QUEUE_LOCK_FD"
464
+ echo -1
465
+ return
466
+ fi
467
+ echo $((idx + 1)) > "$QUEUE_FILE"
468
+ flock -u "$QUEUE_LOCK_FD"
469
+ echo "$idx"
470
+ return
471
+ fi
472
+
473
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
474
+ sleep 0.05
475
+ done
476
+ idx=$(cat "$QUEUE_FILE")
477
+ if [ -z "$idx" ]; then
478
+ idx=0
479
+ fi
480
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
481
+ rmdir "$QUEUE_LOCK_DIR"
482
+ echo -1
483
+ return
484
+ fi
485
+ echo $((idx + 1)) > "$QUEUE_FILE"
486
+ rmdir "$QUEUE_LOCK_DIR"
487
+ echo "$idx"
488
+ }
489
+
490
+ run_queue_for_slot() {
491
+ local gpu_list=$1
492
+ if [ "$USE_FLOCK" = true ]; then
493
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
494
+ fi
495
+ while true; do
496
+ local idx
497
+ idx=$(next_experiment_index)
498
+ if [ "$idx" -lt 0 ]; then
499
+ break
500
+ fi
501
+ local exp="${EXPERIMENTS[$idx]}"
502
+ IFS='|' read -r exp_group model_name algo <<< "$exp"
503
+ run_experiment "$model_name" "$algo" "$gpu_list" || true
504
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
505
+ sleep "$COOLDOWN_SECONDS"
506
+ fi
507
+ done
508
+ if [ "$USE_FLOCK" = true ]; then
509
+ exec {QUEUE_LOCK_FD}>&-
510
+ fi
511
+ }
512
+
513
+ pids=()
514
+ for idx in "${!GPU_GROUPS[@]}"; do
515
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
516
+ pids+=("$!")
517
+ done
518
+
519
+ for pid in "${pids[@]}"; do
520
+ wait "$pid"
521
+ done
522
+
523
+ {
524
+ echo ""
525
+ echo "=== Grouped Summary ==="
526
+ echo "GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL} | Steps: ${STEPS}"
527
+ for group_label in "${GROUP_LABELS[@]}"; do
528
+ echo "=== ${group_label} ==="
529
+ for exp in "${EXPERIMENTS[@]}"; do
530
+ IFS='|' read -r exp_group model_name algo <<< "$exp"
531
+ if [ "$exp_group" != "$group_label" ]; then
532
+ continue
533
+ fi
534
+ name="search-${algo}-${FILTER_LABEL}-${model_name}"
535
+ if [ -f "${LOG_DIR}/${name}.result" ]; then
536
+ cat "${LOG_DIR}/${name}.result"
537
+ else
538
+ echo "task=search | algo=${algo} | filter=${FILTER_LABEL} | model=${model_name} | status=missing"
539
+ fi
540
+ done
541
+ done
542
+ } | tee -a "$LOG_FILE"
scripts/runs/run_sokoban_ppo_filter_grad_analysis.sh ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Runner for Sokoban PPO/GRPO with top-p=0.9 filtering plus periodic
3
+ # gradient-analysis passes during training.
4
+ #
5
+ # This intentionally stays close to scripts/runs/run_main_table_diff_algo.sh:
6
+ # - task: sokoban
7
+ # - algo: PPO or GRPO
8
+ # - filter: top_p=0.9
9
+ # - model: Qwen2.5-3B
10
+ # - train batch: 8 groups x 16 samples (same as the main-table setup)
11
+ # - gradient-analysis batch: 128 groups x 16 samples
12
+ #
13
+ # Validation policy:
14
+ # - one validation before training
15
+ # - periodic validation every 10 steps
16
+ #
17
+ # Gradient-analysis policy:
18
+ # - run gradient analysis every 50 steps
19
+ # - current trainer trigger is step 1, 51, 101, ...
20
+ # - do not exit after the analysis step
21
+
22
+ set -euo pipefail
23
+
24
+ STEPS=101
25
+ SAVE_FREQ=100
26
+ GPU_MEMORY_UTILIZATION=0.3
27
+ RAY_NUM_CPUS=16
28
+ PPO_MICRO_BATCH_SIZE_PER_GPU=4
29
+ LOG_PROB_MICRO_BATCH_SIZE_PER_GPU=4
30
+ GPUS=()
31
+ GPUS_PROVIDED=false
32
+
33
+ MODEL_NAME="Qwen2.5-3B"
34
+ MODEL_PATH="Qwen/${MODEL_NAME}"
35
+ TASK="sokoban"
36
+ ALGO="PPO"
37
+ FILTER_LABEL="filter"
38
+ FILTER_VALUE="0.9"
39
+ GROUP_SIZE=16
40
+ ENV_GROUPS=8
41
+ ANALYSIS_GROUP_SIZE=16
42
+ ANALYSIS_ENV_GROUPS=128
43
+ CONFIG_NAME="_2_sokoban"
44
+
45
+ normalize_algo() {
46
+ case "$1" in
47
+ PPO|ppo) echo "PPO" ;;
48
+ GRPO|grpo) echo "GRPO" ;;
49
+ *)
50
+ echo "Error: unsupported --algo '$1'. Supported values: PPO, GRPO" >&2
51
+ exit 1
52
+ ;;
53
+ esac
54
+ }
55
+
56
+ get_algo_overrides() {
57
+ case "$1" in
58
+ PPO)
59
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
60
+ ;;
61
+ GRPO)
62
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=True actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean"
63
+ ;;
64
+ *)
65
+ echo "Error: unsupported algorithm '$1'" >&2
66
+ exit 1
67
+ ;;
68
+ esac
69
+ }
70
+
71
+ usage() {
72
+ echo "Usage: $0 [options]"
73
+ echo "Options:"
74
+ echo " --algo NAME Training algorithm: PPO or GRPO (default: PPO)"
75
+ echo " --steps N Training steps (default: 101)"
76
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
77
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
78
+ echo " --ray-num-cpus N Max CPUs for ray.init (default: 16)"
79
+ echo " --ppo-micro-batch-size-per-gpu N PPO micro batch size per GPU for actor/critic (default: 4)"
80
+ echo " --log-prob-micro-batch-size-per-gpu N log-prob micro batch size per GPU for ref/rollout (default: 4)"
81
+ echo " --save-freq N Checkpoint save frequency (default: 100)"
82
+ echo " -h, --help Show this help"
83
+ exit 0
84
+ }
85
+
86
+ while [ $# -gt 0 ]; do
87
+ case "$1" in
88
+ --algo) ALGO="$(normalize_algo "$2")"; shift 2 ;;
89
+ --algo=*) ALGO="$(normalize_algo "${1#*=}")"; shift ;;
90
+ --steps) STEPS="$2"; shift 2 ;;
91
+ --steps=*) STEPS="${1#*=}"; shift ;;
92
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
93
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
94
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
95
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
96
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
97
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
98
+ --ppo-micro-batch-size-per-gpu) PPO_MICRO_BATCH_SIZE_PER_GPU="$2"; shift 2 ;;
99
+ --ppo-micro-batch-size-per-gpu=*) PPO_MICRO_BATCH_SIZE_PER_GPU="${1#*=}"; shift ;;
100
+ --log-prob-micro-batch-size-per-gpu) LOG_PROB_MICRO_BATCH_SIZE_PER_GPU="$2"; shift 2 ;;
101
+ --log-prob-micro-batch-size-per-gpu=*) LOG_PROB_MICRO_BATCH_SIZE_PER_GPU="${1#*=}"; shift ;;
102
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
103
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
104
+ -h|--help) usage ;;
105
+ *) echo "Unknown argument: $1"; usage ;;
106
+ esac
107
+ done
108
+
109
+ if [ "$GPUS_PROVIDED" = false ]; then
110
+ if command -v nvidia-smi >/dev/null 2>&1; then
111
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
112
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
113
+ GPUS=()
114
+ for ((i=0; i<GPU_COUNT; i++)); do
115
+ GPUS+=("$i")
116
+ done
117
+ fi
118
+ fi
119
+ if [ ${#GPUS[@]} -eq 0 ]; then
120
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
121
+ GPUS=(0 1 2 3 4 5 6 7)
122
+ fi
123
+ fi
124
+
125
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
126
+ echo "Error: --ray-num-cpus must be a positive integer" >&2
127
+ exit 1
128
+ fi
129
+ if ! [[ "$PPO_MICRO_BATCH_SIZE_PER_GPU" =~ ^[0-9]+$ ]] || [ "$PPO_MICRO_BATCH_SIZE_PER_GPU" -lt 1 ]; then
130
+ echo "Error: --ppo-micro-batch-size-per-gpu must be a positive integer" >&2
131
+ exit 1
132
+ fi
133
+ if ! [[ "$LOG_PROB_MICRO_BATCH_SIZE_PER_GPU" =~ ^[0-9]+$ ]] || [ "$LOG_PROB_MICRO_BATCH_SIZE_PER_GPU" -lt 1 ]; then
134
+ echo "Error: --log-prob-micro-batch-size-per-gpu must be a positive integer" >&2
135
+ exit 1
136
+ fi
137
+
138
+ ALGO_OVERRIDES=$(get_algo_overrides "$ALGO")
139
+ read -r -a ALGO_ARGS <<< "$ALGO_OVERRIDES"
140
+
141
+ GPU_LIST=$(IFS=,; echo "${GPUS[*]}")
142
+ NUM_GPUS=${#GPUS[@]}
143
+ if [ "$NUM_GPUS" -lt 1 ]; then
144
+ echo "Error: no GPUs available" >&2
145
+ exit 1
146
+ fi
147
+
148
+ EXP_NAME="${TASK}-${ALGO}-${FILTER_LABEL}-topp09-${MODEL_NAME}-train${ENV_GROUPS}x${GROUP_SIZE}-analysis${ANALYSIS_ENV_GROUPS}x${ANALYSIS_GROUP_SIZE}-grad-every50"
149
+ LOG_DIR="logs/gradient_analysis_${TASK}_${MODEL_NAME}"
150
+ CHECKPOINT_DIR="model_saving/gradient_analysis/${TASK}/${ALGO}/${FILTER_LABEL}/${EXP_NAME}"
151
+ LOG_PATH="${LOG_DIR}/${EXP_NAME}.log"
152
+
153
+ mkdir -p "$LOG_DIR"
154
+ mkdir -p "$CHECKPOINT_DIR"
155
+
156
+ echo "=== Gradient Analysis Runner: $(date) ===" | tee "$LOG_PATH"
157
+ echo "task=${TASK} algo=${ALGO} filter=top_p:${FILTER_VALUE} model=${MODEL_NAME} steps=${STEPS} gpus=${GPU_LIST}" | tee -a "$LOG_PATH"
158
+ echo "train_group_size=${GROUP_SIZE} train_env_groups=${ENV_GROUPS} analysis_group_size=${ANALYSIS_GROUP_SIZE} analysis_env_groups=${ANALYSIS_ENV_GROUPS} gradient_analysis_every=50 exit_after_gradient_analysis=False" | tee -a "$LOG_PATH"
159
+ echo "ppo_micro_batch_per_gpu=${PPO_MICRO_BATCH_SIZE_PER_GPU} log_prob_micro_batch_per_gpu=${LOG_PROB_MICRO_BATCH_SIZE_PER_GPU}" | tee -a "$LOG_PATH"
160
+
161
+ CUDA_VISIBLE_DEVICES="${GPU_LIST}" python train.py --config-name "${CONFIG_NAME}" \
162
+ model_path="${MODEL_PATH}" \
163
+ trainer.project_name="ragen_gradient_analysis" \
164
+ trainer.experiment_name="${EXP_NAME}" \
165
+ trainer.total_training_steps="${STEPS}" \
166
+ trainer.save_freq="${SAVE_FREQ}" \
167
+ trainer.default_local_dir="${CHECKPOINT_DIR}" \
168
+ trainer.logger="['console','wandb']" \
169
+ trainer.val_before_train=True \
170
+ trainer.test_freq=10 \
171
+ trainer.n_gpus_per_node="${NUM_GPUS}" \
172
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
173
+ system.CUDA_VISIBLE_DEVICES="'${GPU_LIST}'" \
174
+ es_manager.train.env_groups="${ENV_GROUPS}" \
175
+ es_manager.train.group_size="${GROUP_SIZE}" \
176
+ es_manager.train.env_configs.n_groups="[${ENV_GROUPS}]" \
177
+ actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu="${PPO_MICRO_BATCH_SIZE_PER_GPU}" \
178
+ actor_rollout_ref.actor.use_kl_loss=False \
179
+ actor_rollout_ref.actor.kl_loss_type=low_var_kl \
180
+ actor_rollout_ref.actor.kl_loss_coef=0.001 \
181
+ actor_rollout_ref.actor.entropy_coeff=0.001 \
182
+ actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
183
+ actor_rollout_ref.actor.filter_loss_scaling=none \
184
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu="${LOG_PROB_MICRO_BATCH_SIZE_PER_GPU}" \
185
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu="${LOG_PROB_MICRO_BATCH_SIZE_PER_GPU}" \
186
+ actor_rollout_ref.rollout.gpu_memory_utilization="${GPU_MEMORY_UTILIZATION}" \
187
+ actor_rollout_ref.rollout.rollout_filter_value="${FILTER_VALUE}" \
188
+ actor_rollout_ref.rollout.rollout_filter_strategy=top_p \
189
+ actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=linear \
190
+ actor_rollout_ref.rollout.rollout_filter_type=largest \
191
+ actor_rollout_ref.rollout.rollout_filter_metric=reward_variance \
192
+ actor_rollout_ref.rollout.rollout_filter_include_zero=False \
193
+ actor_rollout_ref.actor.checkpoint.save_contents=[model] \
194
+ critic.ppo_micro_batch_size_per_gpu="${PPO_MICRO_BATCH_SIZE_PER_GPU}" \
195
+ critic.checkpoint.save_contents=[model] \
196
+ trainer.gradient_analysis_mode=True \
197
+ trainer.gradient_analysis_every=50 \
198
+ trainer.gradient_analysis_env_groups="${ANALYSIS_ENV_GROUPS}" \
199
+ trainer.gradient_analysis_group_size="${ANALYSIS_GROUP_SIZE}" \
200
+ trainer.gradient_analysis_log_prefilter=True \
201
+ trainer.exit_after_gradient_analysis=False \
202
+ actor_rollout_ref.rollout.gradient_analysis_num_buckets=6 \
203
+ actor_rollout_ref.rollout.gradient_analysis_bucket_mode=quantile \
204
+ "${ALGO_ARGS[@]}" \
205
+ 2>&1 | tee -a "$LOG_PATH"
scripts/runs/run_sokoban_ppo_filter_grad_analysis_probe_ckpt.sh ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Probe a saved Sokoban PPO/GRPO checkpoint with gradient analysis only.
3
+ #
4
+ # This script resumes from an existing `global_step_*` checkpoint directory and:
5
+ # - does not update critic or actor
6
+ # - runs one gradient-analysis pass
7
+ # - logs both post-filter and pre-filter grad metrics
8
+ #
9
+ # By default it targets the checkpoint layout produced by
10
+ # scripts/runs/run_sokoban_ppo_filter_grad_analysis.sh.
11
+
12
+ set -euo pipefail
13
+
14
+ GPU_MEMORY_UTILIZATION=0.3
15
+ RAY_NUM_CPUS=16
16
+ PPO_MICRO_BATCH_SIZE_PER_GPU=4
17
+ LOG_PROB_MICRO_BATCH_SIZE_PER_GPU=4
18
+ GPUS=()
19
+ GPUS_PROVIDED=false
20
+
21
+ MODEL_NAME="Qwen2.5-3B"
22
+ MODEL_PATH="Qwen/${MODEL_NAME}"
23
+ TASK="sokoban"
24
+ ALGO="PPO"
25
+ FILTER_LABEL="filter"
26
+ FILTER_VALUE="0.9"
27
+ GROUP_SIZE=16
28
+ ENV_GROUPS=8
29
+ ANALYSIS_GROUP_SIZE=16
30
+ ANALYSIS_ENV_GROUPS=128
31
+ CONFIG_NAME="_2_sokoban"
32
+
33
+ CHECKPOINT_STEP=101
34
+ CHECKPOINT_ROOT=""
35
+ RESUME_FROM_PATH=""
36
+ VAL_BEFORE_TRAIN=false
37
+
38
+ normalize_algo() {
39
+ case "$1" in
40
+ PPO|ppo) echo "PPO" ;;
41
+ GRPO|grpo) echo "GRPO" ;;
42
+ *)
43
+ echo "Error: unsupported --algo '$1'. Supported values: PPO, GRPO" >&2
44
+ exit 1
45
+ ;;
46
+ esac
47
+ }
48
+
49
+ get_algo_overrides() {
50
+ case "$1" in
51
+ PPO)
52
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
53
+ ;;
54
+ GRPO)
55
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=True actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean"
56
+ ;;
57
+ *)
58
+ echo "Error: unsupported algorithm '$1'" >&2
59
+ exit 1
60
+ ;;
61
+ esac
62
+ }
63
+
64
+ usage() {
65
+ echo "Usage: $0 [options]"
66
+ echo "Options:"
67
+ echo " --algo NAME Training algorithm of the checkpoint: PPO or GRPO (default: PPO)"
68
+ echo " --checkpoint-step N Checkpoint step to probe (default: 101)"
69
+ echo " --checkpoint-root DIR Root directory containing global_step_* checkpoints"
70
+ echo " --resume-from-path DIR Exact global_step_* directory to probe"
71
+ echo " --with-val Run validation before the gradient-analysis probe"
72
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
73
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
74
+ echo " --ray-num-cpus N Max CPUs for ray.init (default: 16)"
75
+ echo " --ppo-micro-batch-size-per-gpu N PPO micro batch size per GPU for actor/critic (default: 4)"
76
+ echo " --log-prob-micro-batch-size-per-gpu N"
77
+ echo " Log-prob micro batch size per GPU for ref/rollout (default: 4)"
78
+ echo " -h, --help Show this help"
79
+ exit 0
80
+ }
81
+
82
+ while [ $# -gt 0 ]; do
83
+ case "$1" in
84
+ --algo) ALGO="$(normalize_algo "$2")"; shift 2 ;;
85
+ --algo=*) ALGO="$(normalize_algo "${1#*=}")"; shift ;;
86
+ --checkpoint-step) CHECKPOINT_STEP="$2"; shift 2 ;;
87
+ --checkpoint-step=*) CHECKPOINT_STEP="${1#*=}"; shift ;;
88
+ --checkpoint-root) CHECKPOINT_ROOT="$2"; shift 2 ;;
89
+ --checkpoint-root=*) CHECKPOINT_ROOT="${1#*=}"; shift ;;
90
+ --resume-from-path) RESUME_FROM_PATH="$2"; shift 2 ;;
91
+ --resume-from-path=*) RESUME_FROM_PATH="${1#*=}"; shift ;;
92
+ --with-val) VAL_BEFORE_TRAIN=true; shift ;;
93
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
94
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
95
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
96
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
97
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
98
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
99
+ --ppo-micro-batch-size-per-gpu) PPO_MICRO_BATCH_SIZE_PER_GPU="$2"; shift 2 ;;
100
+ --ppo-micro-batch-size-per-gpu=*) PPO_MICRO_BATCH_SIZE_PER_GPU="${1#*=}"; shift ;;
101
+ --log-prob-micro-batch-size-per-gpu) LOG_PROB_MICRO_BATCH_SIZE_PER_GPU="$2"; shift 2 ;;
102
+ --log-prob-micro-batch-size-per-gpu=*) LOG_PROB_MICRO_BATCH_SIZE_PER_GPU="${1#*=}"; shift ;;
103
+ -h|--help) usage ;;
104
+ *) echo "Unknown argument: $1"; usage ;;
105
+ esac
106
+ done
107
+
108
+ if [ "$GPUS_PROVIDED" = false ]; then
109
+ if command -v nvidia-smi >/dev/null 2>&1; then
110
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
111
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
112
+ GPUS=()
113
+ for ((i=0; i<GPU_COUNT; i++)); do
114
+ GPUS+=("$i")
115
+ done
116
+ fi
117
+ fi
118
+ if [ ${#GPUS[@]} -eq 0 ]; then
119
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
120
+ GPUS=(0 1 2 3 4 5 6 7)
121
+ fi
122
+ fi
123
+
124
+ if ! [[ "$CHECKPOINT_STEP" =~ ^[0-9]+$ ]]; then
125
+ echo "Error: --checkpoint-step must be a non-negative integer" >&2
126
+ exit 1
127
+ fi
128
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
129
+ echo "Error: --ray-num-cpus must be a positive integer" >&2
130
+ exit 1
131
+ fi
132
+ if ! [[ "$PPO_MICRO_BATCH_SIZE_PER_GPU" =~ ^[0-9]+$ ]] || [ "$PPO_MICRO_BATCH_SIZE_PER_GPU" -lt 1 ]; then
133
+ echo "Error: --ppo-micro-batch-size-per-gpu must be a positive integer" >&2
134
+ exit 1
135
+ fi
136
+ if ! [[ "$LOG_PROB_MICRO_BATCH_SIZE_PER_GPU" =~ ^[0-9]+$ ]] || [ "$LOG_PROB_MICRO_BATCH_SIZE_PER_GPU" -lt 1 ]; then
137
+ echo "Error: --log-prob-micro-batch-size-per-gpu must be a positive integer" >&2
138
+ exit 1
139
+ fi
140
+
141
+ SOURCE_EXP_NAME="${TASK}-${ALGO}-${FILTER_LABEL}-topp09-${MODEL_NAME}-train${ENV_GROUPS}x${GROUP_SIZE}-analysis${ANALYSIS_ENV_GROUPS}x${ANALYSIS_GROUP_SIZE}-grad-every50"
142
+
143
+ if [ -z "$CHECKPOINT_ROOT" ]; then
144
+ CHECKPOINT_ROOT="model_saving/gradient_analysis/${TASK}/${ALGO}/${FILTER_LABEL}/${SOURCE_EXP_NAME}"
145
+ fi
146
+
147
+ if [ -z "$RESUME_FROM_PATH" ]; then
148
+ RESUME_FROM_PATH="${CHECKPOINT_ROOT}/global_step_${CHECKPOINT_STEP}"
149
+ fi
150
+
151
+ if [[ "$RESUME_FROM_PATH" =~ global_step_([0-9]+)$ ]]; then
152
+ CHECKPOINT_STEP="${BASH_REMATCH[1]}"
153
+ else
154
+ echo "Error: --resume-from-path must point to a global_step_* directory" >&2
155
+ exit 1
156
+ fi
157
+
158
+ if [ ! -d "$RESUME_FROM_PATH" ]; then
159
+ echo "Error: checkpoint directory not found: $RESUME_FROM_PATH" >&2
160
+ exit 1
161
+ fi
162
+
163
+ ALGO_OVERRIDES=$(get_algo_overrides "$ALGO")
164
+ read -r -a ALGO_ARGS <<< "$ALGO_OVERRIDES"
165
+
166
+ GPU_LIST=$(IFS=,; echo "${GPUS[*]}")
167
+ NUM_GPUS=${#GPUS[@]}
168
+ if [ "$NUM_GPUS" -lt 1 ]; then
169
+ echo "Error: no GPUs available" >&2
170
+ exit 1
171
+ fi
172
+
173
+ PROBE_TOTAL_STEPS="$CHECKPOINT_STEP"
174
+ if [ "$PROBE_TOTAL_STEPS" -lt 1 ]; then
175
+ PROBE_TOTAL_STEPS=1
176
+ fi
177
+
178
+ VAL_LABEL="noval"
179
+ if [ "$VAL_BEFORE_TRAIN" = true ]; then
180
+ VAL_LABEL="withval"
181
+ fi
182
+
183
+ EXP_NAME="${TASK}-${ALGO}-${FILTER_LABEL}-topp09-${MODEL_NAME}-probe-ckpt${CHECKPOINT_STEP}-${VAL_LABEL}-kl_and_entropy"
184
+ LOG_DIR="logs/gradient_analysis_probe_${TASK}_${MODEL_NAME}"
185
+ OUTPUT_DIR="model_saving/gradient_analysis_probe/${TASK}/${ALGO}/${FILTER_LABEL}/${EXP_NAME}"
186
+ LOG_PATH="${LOG_DIR}/${EXP_NAME}.log"
187
+
188
+ mkdir -p "$LOG_DIR"
189
+ mkdir -p "$OUTPUT_DIR"
190
+
191
+ echo "=== Gradient Analysis Checkpoint Probe: $(date) ===" | tee "$LOG_PATH"
192
+ echo "task=${TASK} algo=${ALGO} model=${MODEL_NAME} ckpt=${RESUME_FROM_PATH} gpus=${GPU_LIST}" | tee -a "$LOG_PATH"
193
+ echo "train_group_size=${GROUP_SIZE} train_env_groups=${ENV_GROUPS} analysis_group_size=${ANALYSIS_GROUP_SIZE} analysis_env_groups=${ANALYSIS_ENV_GROUPS}" | tee -a "$LOG_PATH"
194
+ echo "gradient_analysis_only=True gradient_analysis_every=1 exit_after_gradient_analysis=True val_before_train=${VAL_BEFORE_TRAIN}" | tee -a "$LOG_PATH"
195
+ echo "ppo_micro_batch_per_gpu=${PPO_MICRO_BATCH_SIZE_PER_GPU} log_prob_micro_batch_per_gpu=${LOG_PROB_MICRO_BATCH_SIZE_PER_GPU}" | tee -a "$LOG_PATH"
196
+
197
+ CUDA_VISIBLE_DEVICES="${GPU_LIST}" python3 train.py --config-name "${CONFIG_NAME}" \
198
+ model_path="${MODEL_PATH}" \
199
+ trainer.project_name="ragen_gradient_analysis_probe" \
200
+ trainer.experiment_name="${EXP_NAME}" \
201
+ trainer.total_training_steps="${PROBE_TOTAL_STEPS}" \
202
+ trainer.save_freq=-1 \
203
+ trainer.default_local_dir="${OUTPUT_DIR}" \
204
+ trainer.logger="['console','wandb']" \
205
+ trainer.resume_mode=resume_path \
206
+ trainer.resume_from_path="${RESUME_FROM_PATH}" \
207
+ trainer.val_before_train="${VAL_BEFORE_TRAIN}" \
208
+ trainer.test_freq=0 \
209
+ trainer.n_gpus_per_node="${NUM_GPUS}" \
210
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
211
+ system.CUDA_VISIBLE_DEVICES="'${GPU_LIST}'" \
212
+ es_manager.train.env_groups="${ENV_GROUPS}" \
213
+ es_manager.train.group_size="${GROUP_SIZE}" \
214
+ es_manager.train.env_configs.n_groups="[${ENV_GROUPS}]" \
215
+ actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu="${PPO_MICRO_BATCH_SIZE_PER_GPU}" \
216
+ actor_rollout_ref.actor.use_kl_loss=True \
217
+ actor_rollout_ref.actor.kl_loss_type=low_var_kl \
218
+ actor_rollout_ref.actor.kl_loss_coef=0.001 \
219
+ actor_rollout_ref.actor.entropy_coeff=0.001 \
220
+ actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
221
+ actor_rollout_ref.actor.filter_loss_scaling=none \
222
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu="${LOG_PROB_MICRO_BATCH_SIZE_PER_GPU}" \
223
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu="${LOG_PROB_MICRO_BATCH_SIZE_PER_GPU}" \
224
+ actor_rollout_ref.rollout.gpu_memory_utilization="${GPU_MEMORY_UTILIZATION}" \
225
+ actor_rollout_ref.rollout.rollout_filter_value="${FILTER_VALUE}" \
226
+ actor_rollout_ref.rollout.rollout_filter_strategy=top_p \
227
+ actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=linear \
228
+ actor_rollout_ref.rollout.rollout_filter_type=largest \
229
+ actor_rollout_ref.rollout.rollout_filter_metric=reward_variance \
230
+ actor_rollout_ref.rollout.rollout_filter_include_zero=False \
231
+ actor_rollout_ref.actor.checkpoint.save_contents=[model] \
232
+ critic.ppo_micro_batch_size_per_gpu="${PPO_MICRO_BATCH_SIZE_PER_GPU}" \
233
+ critic.checkpoint.save_contents=[model] \
234
+ trainer.gradient_analysis_mode=True \
235
+ trainer.gradient_analysis_every=1 \
236
+ trainer.gradient_analysis_env_groups="${ANALYSIS_ENV_GROUPS}" \
237
+ trainer.gradient_analysis_group_size="${ANALYSIS_GROUP_SIZE}" \
238
+ trainer.gradient_analysis_log_prefilter=True \
239
+ trainer.gradient_analysis_only=True \
240
+ trainer.exit_after_gradient_analysis=True \
241
+ actor_rollout_ref.rollout.gradient_analysis_num_buckets=6 \
242
+ actor_rollout_ref.rollout.gradient_analysis_bucket_mode=quantile \
243
+ "${ALGO_ARGS[@]}" \
244
+ 2>&1 | tee -a "$LOG_PATH"
scripts/runs/run_top_p_sweep.sh ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Top-p sweep for sokoban using GAE with the requested filter overrides.
3
+ set -euo pipefail
4
+
5
+ # Defaults
6
+ STEPS=400
7
+ MODEL_NAME="Qwen2.5-3B"
8
+ MODEL_PATH="Qwen/${MODEL_NAME}"
9
+ PROJECT_NAME="ragen_release_top_p_sweep"
10
+ CONFIG_NAME="_2_sokoban"
11
+ SAVE_FREQ=-1
12
+ ROLL_FILTER_VALUES="1.0,0.98,0.95,0.9,0.8,0.6,0.4,nofilter"
13
+ GPUS=()
14
+ GPUS_PROVIDED=false
15
+ GPUS_PER_EXP=1
16
+ COOLDOWN_SECONDS=0
17
+ GPU_MEMORY_UTILIZATION=0.5
18
+ RAY_NUM_CPUS=16
19
+
20
+ usage() {
21
+ cat <<'EOF'
22
+ Usage: $0 [options]
23
+ Options:
24
+ --steps N Training steps (default: 400)
25
+ --rollout_filter_value LIST Comma-separated top_p values (default: 1.0,0.98,0.95,0.9,0.8,0.6,0.4,nofilter)
26
+ --gpus LIST Comma-separated GPU IDs (auto-detected if omitted)
27
+ --gpus-per-exp N GPUs per experiment (default: 1)
28
+ --ray-num-cpus N Max CPUs per task for ray.init (default: 16)
29
+ --gpu-memory-utilization V GPU memory utilization for rollouts (default: 0.5)
30
+ --save-freq N Checkpoint save frequency (default: -1)
31
+ -h, --help Show this help message
32
+ EOF
33
+ exit 0
34
+ }
35
+
36
+ while [ $# -gt 0 ]; do
37
+ case "$1" in
38
+ --steps) STEPS="$2"; shift 2 ;;
39
+ --steps=*) STEPS="${1#*=}"; shift ;;
40
+ --rollout_filter_value) ROLL_FILTER_VALUES="$2"; shift 2 ;;
41
+ --rollout_filter_value=*) ROLL_FILTER_VALUES="${1#*=}"; shift ;;
42
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
43
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
44
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
45
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
46
+ --ray-num-cpus) RAY_NUM_CPUS="$2"; shift 2 ;;
47
+ --ray-num-cpus=*) RAY_NUM_CPUS="${1#*=}"; shift ;;
48
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
49
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
50
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
51
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
52
+ -h|--help) usage ;;
53
+ *) echo "Unknown argument: $1"; usage ;;
54
+ esac
55
+ done
56
+
57
+ if [ "$GPUS_PROVIDED" = false ]; then
58
+ if command -v nvidia-smi >/dev/null 2>&1; then
59
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
60
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
61
+ GPUS=()
62
+ for ((i=0; i<GPU_COUNT; i++)); do
63
+ GPUS+=("$i")
64
+ done
65
+ fi
66
+ fi
67
+ if [ ${#GPUS[@]} -eq 0 ]; then
68
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
69
+ GPUS=(0 1 2 3 4 5 6 7)
70
+ fi
71
+ fi
72
+
73
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
74
+ echo "Error: --gpus-per-exp must be a positive integer"
75
+ exit 1
76
+ fi
77
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
78
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
79
+ exit 1
80
+ fi
81
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
82
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
83
+ exit 1
84
+ fi
85
+ if ! [[ "$RAY_NUM_CPUS" =~ ^[0-9]+$ ]] || [ "$RAY_NUM_CPUS" -lt 1 ]; then
86
+ echo "Error: --ray-num-cpus must be a positive integer"
87
+ exit 1
88
+ fi
89
+
90
+ GPU_GROUPS=()
91
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
92
+ group="${GPUS[$i]}"
93
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
94
+ group+=",${GPUS[$((i+j))]}"
95
+ done
96
+ GPU_GROUPS+=("$group")
97
+ done
98
+ NUM_SLOTS=${#GPU_GROUPS[@]}
99
+
100
+ short_gpu_name() {
101
+ local name="$1"
102
+ local cleaned
103
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
104
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
105
+ echo "${BASH_REMATCH[1]}"
106
+ return
107
+ fi
108
+ echo "${cleaned%% *}"
109
+ }
110
+
111
+ declare -A GPU_LABELS
112
+ get_gpu_label() {
113
+ local gpu_id="$1"
114
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
115
+ echo "${GPU_LABELS[$gpu_id]}"
116
+ return
117
+ fi
118
+ local name=""
119
+ if command -v nvidia-smi >/dev/null 2>&1; then
120
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
121
+ fi
122
+ if [ -z "$name" ]; then
123
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
124
+ echo "${GPU_LABELS[$gpu_id]}"
125
+ return
126
+ fi
127
+ local short
128
+ short=$(short_gpu_name "$name")
129
+ GPU_LABELS[$gpu_id]="1x${short}"
130
+ echo "${GPU_LABELS[$gpu_id]}"
131
+ }
132
+
133
+ get_gpu_model_label() {
134
+ local models=()
135
+ local id label model
136
+ for id in "${GPUS[@]}"; do
137
+ label=$(get_gpu_label "$id")
138
+ model="${label#1x}"
139
+ models+=("$model")
140
+ done
141
+ local unique_models=()
142
+ local m found
143
+ for m in "${models[@]}"; do
144
+ found=false
145
+ for u in "${unique_models[@]}"; do
146
+ if [ "$u" = "$m" ]; then
147
+ found=true
148
+ break
149
+ fi
150
+ done
151
+ if [ "$found" = false ]; then
152
+ unique_models+=("$m")
153
+ fi
154
+ done
155
+ if [ ${#unique_models[@]} -eq 1 ]; then
156
+ echo "${unique_models[0]}"
157
+ else
158
+ echo "mixed"
159
+ fi
160
+ }
161
+
162
+ get_gpu_label_for_list() {
163
+ local gpu_list="$1"
164
+ IFS=',' read -r -a ids <<< "$gpu_list"
165
+ local count=${#ids[@]}
166
+ if [ "$count" -eq 0 ]; then
167
+ echo "0xGPU"
168
+ return
169
+ fi
170
+ local first_model
171
+ first_model="$(get_gpu_label "${ids[0]}")"
172
+ first_model="${first_model#1x}"
173
+ local id model
174
+ for id in "${ids[@]:1}"; do
175
+ model="$(get_gpu_label "$id")"
176
+ model="${model#1x}"
177
+ if [ "$model" != "$first_model" ]; then
178
+ echo "${count}xmixed"
179
+ return
180
+ fi
181
+ done
182
+ echo "${count}x${first_model}"
183
+ }
184
+
185
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
186
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
187
+ LOG_FILE="logs/top_p_sweep_${MODEL_NAME}.log"
188
+ RESULT_ROOT="logs/top_p_sweep_${MODEL_NAME}"
189
+ CHECKPOINT_ROOT="model_saving/top_p_sweep_${MODEL_NAME}"
190
+
191
+ mkdir -p logs
192
+ mkdir -p "$RESULT_ROOT"
193
+ mkdir -p "$CHECKPOINT_ROOT"
194
+
195
+ echo "=== Top-p Sweep Runner (${MODEL_NAME}): $(date) ===" | tee "$LOG_FILE"
196
+ echo "Values: ${ROLL_FILTER_VALUES} | Steps: ${STEPS} | GPUs per exp: ${GPU_LOG_LABEL}" | tee -a "$LOG_FILE"
197
+ echo "Groups: ${GPU_GROUPS[*]} | GPU memory util: ${GPU_MEMORY_UTILIZATION} | ray_num_cpus: ${RAY_NUM_CPUS} | save_freq: ${SAVE_FREQ}" | tee -a "$LOG_FILE"
198
+
199
+ parse_rollout_values() {
200
+ IFS=',' read -r -a raw <<< "$ROLL_FILTER_VALUES"
201
+ ROLL_VALUES=()
202
+ for token in "${raw[@]}"; do
203
+ token="${token// /}"
204
+ if [ -n "$token" ]; then
205
+ ROLL_VALUES+=("$token")
206
+ fi
207
+ done
208
+ if [ ${#ROLL_VALUES[@]} -eq 0 ]; then
209
+ echo "Error: no rollout_filter_value entries provided" >&2
210
+ exit 1
211
+ fi
212
+ }
213
+
214
+ parse_rollout_values
215
+ EXPERIMENTS=("${ROLL_VALUES[@]}")
216
+
217
+ run_experiment() {
218
+ local value="$1"
219
+ local gpu_list="$2"
220
+
221
+ local include_zero="False"
222
+ local filter_value="$value"
223
+ if [ "$value" = "nofilter" ]; then
224
+ include_zero="True"
225
+ filter_value="1.0"
226
+ fi
227
+ local safe_label="${value//./}"
228
+ safe_label="${safe_label,,}"
229
+
230
+ local name="sokoban_top_p_${safe_label}-${MODEL_NAME}"
231
+ local task_dir="${RESULT_ROOT}/${safe_label}"
232
+ local log_path="${task_dir}/${name}.log"
233
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${safe_label}/${name}"
234
+ local gpus_per_exp
235
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
236
+ gpus_per_exp=${#gpu_ids[@]}
237
+
238
+ mkdir -p "$task_dir"
239
+ mkdir -p "$checkpoint_dir"
240
+
241
+ START=$(date +%s)
242
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$CONFIG_NAME" \
243
+ model_path="${MODEL_PATH}" \
244
+ trainer.project_name="${PROJECT_NAME}" \
245
+ trainer.experiment_name="${name}" \
246
+ trainer.total_training_steps="${STEPS}" \
247
+ trainer.save_freq="${SAVE_FREQ}" \
248
+ trainer.default_local_dir="${checkpoint_dir}" \
249
+ trainer.logger="['console','wandb']" \
250
+ trainer.val_before_train=True \
251
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
252
+ ray_kwargs.ray_init.num_cpus="${RAY_NUM_CPUS}" \
253
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
254
+ algorithm.adv_estimator=gae \
255
+ actor_rollout_ref.actor.use_kl_loss=True \
256
+ actor_rollout_ref.actor.kl_loss_coef=0.001 \
257
+ actor_rollout_ref.actor.entropy_coeff=0.001 \
258
+ actor_rollout_ref.actor.entropy_from_logits_with_chunking=True \
259
+ actor_rollout_ref.actor.filter_loss_scaling=none \
260
+ actor_rollout_ref.actor.ppo_mini_batch_size=32 \
261
+ actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=4 \
262
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 \
263
+ critic.ppo_mini_batch_size=32 \
264
+ critic.ppo_micro_batch_size_per_gpu=4 \
265
+ ppo_mini_batch_size=32 \
266
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 \
267
+ actor_rollout_ref.rollout.rollout_filter_strategy=top_p \
268
+ actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=softmax \
269
+ actor_rollout_ref.rollout.rollout_filter_value=${filter_value} \
270
+ actor_rollout_ref.rollout.rollout_filter_include_zero=${include_zero} \
271
+ actor_rollout_ref.rollout.rollout_filter_type=largest \
272
+ actor_rollout_ref.rollout.gpu_memory_utilization="${GPU_MEMORY_UTILIZATION}" \
273
+ actor_rollout_ref.rollout.rollout_filter_metric=reward_variance \
274
+ es_manager.train.env_groups=8 \
275
+ es_manager.train.group_size=16 \
276
+ es_manager.train.env_configs.n_groups='[8]' \
277
+ es_manager.val.env_groups=512 \
278
+ es_manager.val.group_size=1 \
279
+ es_manager.val.env_configs.n_groups='[512]' \
280
+ 2>&1 | tee "$log_path"
281
+ EXIT_CODE=${PIPESTATUS[0]}
282
+
283
+ END=$(date +%s)
284
+ TOTAL_TIME=$((END - START))
285
+
286
+ timing_values=()
287
+ mapfile -t timing_values < <(
288
+ python - "$log_path" <<'PY'
289
+ import re
290
+ import sys
291
+ from pathlib import Path
292
+
293
+ def last(pattern, text):
294
+ matches = re.findall(pattern, text)
295
+ return matches[-1] if matches else ""
296
+
297
+ try:
298
+ text = Path(sys.argv[1]).read_text(errors="ignore")
299
+ except Exception:
300
+ text = ""
301
+
302
+ patterns = [
303
+ r"timing_s/train_total[:\s]+([\d.]+)",
304
+ r"timing_s/eval_total[:\s]+([\d.]+)",
305
+ r"timing_s/total[:\s]+([\d.]+)",
306
+ ]
307
+
308
+ for pattern in patterns:
309
+ print(last(pattern, text))
310
+ PY
311
+ )
312
+
313
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
314
+ EVAL_TIME_RAW="${timing_values[1]:-}"
315
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
316
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
317
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
318
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
319
+
320
+ local status="success"
321
+ local error_line=""
322
+ if [ $EXIT_CODE -ne 0 ]; then
323
+ status="fail"
324
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
325
+ fi
326
+
327
+ local gpu_label
328
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
329
+ local summary_line="value=${value} | include_zero=${include_zero} | filter_value=${filter_value} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
330
+ echo "${summary_line}" > "${task_dir}/${name}.result"
331
+ echo "${summary_line}" | tee -a "$LOG_FILE"
332
+ if [ "$status" = "fail" ]; then
333
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
334
+ fi
335
+ }
336
+
337
+ EXPERIMENT_COUNT=${#EXPERIMENTS[@]}
338
+ if [ $EXPERIMENT_COUNT -eq 0 ]; then
339
+ echo "No experiments to run" >&2
340
+ exit 1
341
+ fi
342
+
343
+ QUEUE_FILE=$(mktemp -t ragen_top_p_queue.XXXXXX)
344
+ echo 0 > "$QUEUE_FILE"
345
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
346
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
347
+ USE_FLOCK=false
348
+ MAIN_PID=$$
349
+
350
+ cleanup_queue() {
351
+ if [ "$MAIN_PID" != "$$" ]; then
352
+ return
353
+ fi
354
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
355
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
356
+ }
357
+ trap cleanup_queue EXIT
358
+
359
+ if command -v flock >/dev/null 2>&1; then
360
+ USE_FLOCK=true
361
+ fi
362
+
363
+ next_experiment_index() {
364
+ local idx
365
+ if [ "$USE_FLOCK" = true ]; then
366
+ flock -x "$QUEUE_LOCK_FD"
367
+ idx=$(cat "$QUEUE_FILE")
368
+ if [ -z "$idx" ]; then
369
+ idx=0
370
+ fi
371
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
372
+ flock -u "$QUEUE_LOCK_FD"
373
+ echo -1
374
+ return
375
+ fi
376
+ echo $((idx + 1)) > "$QUEUE_FILE"
377
+ flock -u "$QUEUE_LOCK_FD"
378
+ echo "$idx"
379
+ return
380
+ fi
381
+
382
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
383
+ sleep 0.05
384
+ done
385
+ idx=$(cat "$QUEUE_FILE")
386
+ if [ -z "$idx" ]; then
387
+ idx=0
388
+ fi
389
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
390
+ rmdir "$QUEUE_LOCK_DIR"
391
+ echo -1
392
+ return
393
+ fi
394
+ echo $((idx + 1)) > "$QUEUE_FILE"
395
+ rmdir "$QUEUE_LOCK_DIR"
396
+ echo "$idx"
397
+ }
398
+
399
+ run_queue_for_slot() {
400
+ local gpu_list="$1"
401
+ if [ "$USE_FLOCK" = true ]; then
402
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
403
+ fi
404
+ while true; do
405
+ local idx
406
+ idx=$(next_experiment_index)
407
+ if [ "$idx" -lt 0 ]; then
408
+ break
409
+ fi
410
+ local value="${EXPERIMENTS[$idx]}"
411
+ run_experiment "$value" "$gpu_list" || true
412
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
413
+ sleep "$COOLDOWN_SECONDS"
414
+ fi
415
+ done
416
+ if [ "$USE_FLOCK" = true ]; then
417
+ exec {QUEUE_LOCK_FD}>&-
418
+ fi
419
+ }
420
+
421
+ pids=()
422
+ for idx in "${!GPU_GROUPS[@]}"; do
423
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
424
+ pids+=("$!")
425
+ done
426
+
427
+ for pid in "${pids[@]}"; do
428
+ wait "$pid"
429
+ done
430
+
431
+ {
432
+ echo ""
433
+ echo "=== Top-p Sweep Summary ==="
434
+ echo "Project: ${PROJECT_NAME} | Steps: ${STEPS} | GPU per exp: ${GPU_LOG_LABEL}"
435
+ for val in "${EXPERIMENTS[@]}"; do
436
+ safe_label="${val//./p}"
437
+ safe_label="${safe_label,,}"
438
+ name="sokoban_top_p_${safe_label}-${MODEL_NAME}"
439
+ task_dir="${RESULT_ROOT}/${safe_label}"
440
+ if [ -f "${task_dir}/${name}.result" ]; then
441
+ cat "${task_dir}/${name}.result"
442
+ else
443
+ echo "value=${val} | status=missing"
444
+ fi
445
+ done
446
+ } | tee -a "$LOG_FILE"
scripts/runs/run_webshop_release_combos.sh ADDED
@@ -0,0 +1,565 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Webshop (release): GRPO with 4 release filter modes
3
+ # Model:
4
+ # - Qwen2.5-3B-Instruct
5
+ # Filter modes:
6
+ # - topk25 => top_k, keep top 25% of groups
7
+ # - topp09 => top_p=0.9 with linear aggregation
8
+ # - topp095 => top_p=0.95 with linear aggregation
9
+ # - nofilter => top_p=1.0 with linear aggregation
10
+
11
+ set -euo pipefail
12
+
13
+ # Defaults
14
+ STEPS=100
15
+ TASK="webshop-release"
16
+ CONFIG="_6_webshop"
17
+ SAVE_FREQ=100
18
+ NUM_GROUPS=16
19
+ GROUP_SIZE=8
20
+ MODEL_NAME="Qwen2.5-3B-Instruct"
21
+ ALGO="GRPO"
22
+ FILTER_MODES=("topk25" "topp09" "topp095" "nofilter")
23
+ FILTERS_OPTION="all"
24
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
25
+
26
+ # GPU settings
27
+ GPUS=()
28
+ GPUS_PROVIDED=false
29
+ GPUS_PER_EXP=1
30
+ COOLDOWN_SECONDS=30
31
+ GPU_MEMORY_UTILIZATION=0.3
32
+ declare -A GPU_LABELS
33
+
34
+ usage() {
35
+ echo "Usage: $0 [options]"
36
+ echo "Options:"
37
+ echo " --steps N Training steps (default: 100)"
38
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
39
+ echo " --gpus-per-exp N GPUs per experiment (default: 1)"
40
+ echo " --cooldown SECONDS Cooldown between runs on the same GPU group (default: 30)"
41
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
42
+ echo " --save-freq N Checkpoint save frequency (default: 100)"
43
+ echo " --filters LIST Comma-separated filter modes (topk25,topp09,topp095,nofilter,all). Default: all"
44
+ echo " -h, --help Show this help"
45
+ exit 0
46
+ }
47
+
48
+ while [ $# -gt 0 ]; do
49
+ case "$1" in
50
+ --steps) STEPS="$2"; shift 2 ;;
51
+ --steps=*) STEPS="${1#*=}"; shift ;;
52
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
53
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
54
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
55
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
56
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
57
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
58
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
59
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
60
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
61
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
62
+ --filters) FILTERS_OPTION="$2"; shift 2 ;;
63
+ --filters=*) FILTERS_OPTION="${1#*=}"; shift ;;
64
+ -h|--help) usage ;;
65
+ *) echo "Unknown argument: $1"; usage ;;
66
+ esac
67
+ done
68
+
69
+ # Map model names to HuggingFace paths
70
+ get_model_path() {
71
+ if [[ "$1" == *"/"* ]]; then
72
+ echo "$1"
73
+ return
74
+ fi
75
+ case "$1" in
76
+ Qwen2.5-3B-Instruct) echo "Qwen/Qwen2.5-3B-Instruct" ;;
77
+ Qwen2.5-7B-Instruct) echo "Qwen/Qwen2.5-7B-Instruct" ;;
78
+ Llama-3.2-3B-Instruct) echo "meta-llama/Llama-3.2-3B-Instruct" ;;
79
+ *) echo "Qwen/$1" ;;
80
+ esac
81
+ }
82
+
83
+ get_algo_overrides() {
84
+ case "$1" in
85
+ PPO)
86
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
87
+ ;;
88
+ GRPO)
89
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=True actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean"
90
+ ;;
91
+ *)
92
+ echo ""
93
+ ;;
94
+ esac
95
+ }
96
+
97
+ if [ "$GPUS_PROVIDED" = false ]; then
98
+ if command -v nvidia-smi >/dev/null 2>&1; then
99
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
100
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
101
+ GPUS=()
102
+ for ((i=0; i<GPU_COUNT; i++)); do
103
+ GPUS+=("$i")
104
+ done
105
+ fi
106
+ fi
107
+ if [ ${#GPUS[@]} -eq 0 ]; then
108
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
109
+ GPUS=(0 1 2 3 4 5 6 7)
110
+ fi
111
+ fi
112
+
113
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
114
+ echo "Error: --gpus-per-exp must be a positive integer"
115
+ exit 1
116
+ fi
117
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
118
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
119
+ exit 1
120
+ fi
121
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
122
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
123
+ exit 1
124
+ fi
125
+
126
+ GPU_GROUPS=()
127
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
128
+ group="${GPUS[$i]}"
129
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
130
+ group+=",${GPUS[$((i+j))]}"
131
+ done
132
+ GPU_GROUPS+=("$group")
133
+ done
134
+ NUM_SLOTS=${#GPU_GROUPS[@]}
135
+
136
+ short_gpu_name() {
137
+ local name="$1"
138
+ local cleaned
139
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
140
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
141
+ echo "${BASH_REMATCH[1]}"
142
+ return
143
+ fi
144
+ echo "${cleaned%% *}"
145
+ }
146
+
147
+ get_gpu_label() {
148
+ local gpu_id="$1"
149
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
150
+ echo "${GPU_LABELS[$gpu_id]}"
151
+ return
152
+ fi
153
+ local name=""
154
+ if command -v nvidia-smi >/dev/null 2>&1; then
155
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
156
+ fi
157
+ if [ -z "$name" ]; then
158
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
159
+ echo "${GPU_LABELS[$gpu_id]}"
160
+ return
161
+ fi
162
+ local short
163
+ short=$(short_gpu_name "$name")
164
+ GPU_LABELS[$gpu_id]="1x${short}"
165
+ echo "${GPU_LABELS[$gpu_id]}"
166
+ }
167
+
168
+ get_gpu_model_label() {
169
+ local models=()
170
+ local id label model
171
+ for id in "${GPUS[@]}"; do
172
+ label=$(get_gpu_label "$id")
173
+ model="${label#1x}"
174
+ models+=("$model")
175
+ done
176
+ local unique_models=()
177
+ local m found
178
+ for m in "${models[@]}"; do
179
+ found=false
180
+ for u in "${unique_models[@]}"; do
181
+ if [ "$u" = "$m" ]; then
182
+ found=true
183
+ break
184
+ fi
185
+ done
186
+ if [ "$found" = false ]; then
187
+ unique_models+=("$m")
188
+ fi
189
+ done
190
+ if [ ${#unique_models[@]} -eq 1 ]; then
191
+ echo "${unique_models[0]}"
192
+ else
193
+ echo "mixed"
194
+ fi
195
+ }
196
+
197
+ get_gpu_label_for_list() {
198
+ local gpu_list="$1"
199
+ IFS=',' read -r -a ids <<< "$gpu_list"
200
+ local count=${#ids[@]}
201
+ if [ "$count" -eq 0 ]; then
202
+ echo "0xGPU"
203
+ return
204
+ fi
205
+ local first_model
206
+ first_model="$(get_gpu_label "${ids[0]}")"
207
+ first_model="${first_model#1x}"
208
+ local id model
209
+ for id in "${ids[@]:1}"; do
210
+ model="$(get_gpu_label "$id")"
211
+ model="${model#1x}"
212
+ if [ "$model" != "$first_model" ]; then
213
+ echo "${count}xmixed"
214
+ return
215
+ fi
216
+ done
217
+ echo "${count}x${first_model}"
218
+ }
219
+
220
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
221
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
222
+ LOG_FILE="logs/webshop_release_combos.log"
223
+ RESULT_ROOT="logs"
224
+ CHECKPOINT_ROOT="model_saving/webshop_release_combos"
225
+
226
+ mkdir -p logs
227
+ mkdir -p "$RESULT_ROOT"
228
+ mkdir -p "$CHECKPOINT_ROOT"
229
+
230
+ echo "=== Webshop Release Combos Runner: $(date) ===" | tee "$LOG_FILE"
231
+ echo "Task: ${TASK} | Steps: ${STEPS} | GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL}" | tee -a "$LOG_FILE"
232
+ echo "GPUS: ${GPUS[*]} | groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s" | tee -a "$LOG_FILE"
233
+
234
+ get_filter_config() {
235
+ case "$1" in
236
+ topk25)
237
+ echo "top_k|0.25|linear|topk25"
238
+ ;;
239
+ topp09)
240
+ echo "top_p|0.9|linear|topp09-linear"
241
+ ;;
242
+ topp095)
243
+ echo "top_p|0.95|linear|topp095-linear"
244
+ ;;
245
+ nofilter)
246
+ echo "top_p|1.0|linear|nofilter"
247
+ ;;
248
+ *)
249
+ echo "Unknown filter mode: $1" >&2
250
+ return 1
251
+ ;;
252
+ esac
253
+ }
254
+
255
+ build_experiment_name() {
256
+ local task=$1
257
+ local algo=$2
258
+ local filter_suffix=$3
259
+ local model_name=$4
260
+ echo "${task}-${algo}-${filter_suffix}-${model_name}-${NUM_GROUPS}x${GROUP_SIZE}"
261
+ }
262
+
263
+ run_experiment() {
264
+ local task=$1
265
+ local model_name=$2
266
+ local algo=$3
267
+ local filter=$4
268
+ local config=$5
269
+ local gpu_list=$6
270
+
271
+ local model_path
272
+ model_path=$(get_model_path "$model_name")
273
+
274
+ local filter_strategy
275
+ local filter_value
276
+ local filter_prob_mode
277
+ local filter_suffix
278
+ IFS='|' read -r filter_strategy filter_value filter_prob_mode filter_suffix <<< "$(get_filter_config "$filter")"
279
+ local include_zero=True
280
+
281
+ local common_overrides=(
282
+ "actor_rollout_ref.actor.use_kl_loss=False"
283
+ "actor_rollout_ref.actor.kl_loss_type=low-var-kl"
284
+ "actor_rollout_ref.actor.kl_loss_coef=0.001"
285
+ "actor_rollout_ref.actor.entropy_coeff=0.001"
286
+ "actor_rollout_ref.actor.entropy_from_logits_with_chunking=True"
287
+ "actor_rollout_ref.actor.filter_loss_scaling=none"
288
+ "actor_rollout_ref.rollout.gpu_memory_utilization=${GPU_MEMORY_UTILIZATION}"
289
+ "actor_rollout_ref.rollout.rollout_filter_strategy=${filter_strategy}"
290
+ "actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=${filter_prob_mode}"
291
+ "actor_rollout_ref.rollout.rollout_filter_type=largest"
292
+ "actor_rollout_ref.rollout.rollout_filter_metric=reward_variance"
293
+ "actor_rollout_ref.rollout.rollout_filter_include_zero=${include_zero}"
294
+ )
295
+
296
+ local env_overrides=()
297
+
298
+ local checkpoint_overrides=(
299
+ "actor_rollout_ref.actor.checkpoint.save_contents=[model]"
300
+ "critic.checkpoint.save_contents=[model]"
301
+ )
302
+
303
+ local algo_overrides
304
+ algo_overrides=$(get_algo_overrides "$algo")
305
+ read -r -a algo_args <<< "$algo_overrides"
306
+
307
+ local name
308
+ name=$(build_experiment_name "$task" "$algo" "$filter_suffix" "$model_name")
309
+ local task_dir="${RESULT_ROOT}/webshop_release_combos"
310
+ local log_path="${task_dir}/${name}.log"
311
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${model_name}/${algo}/${filter}/${name}"
312
+ local gpus_per_exp
313
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
314
+ gpus_per_exp=${#gpu_ids[@]}
315
+
316
+ mkdir -p "$task_dir"
317
+ mkdir -p "${checkpoint_dir}"
318
+ START=$(date +%s)
319
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$config" \
320
+ model_path="${model_path}" \
321
+ micro_batch_size_per_gpu=1 \
322
+ log_prob_micro_batch_size_per_gpu=1 \
323
+ agent_proxy.max_turn=9 \
324
+ trainer.project_name="main_webshop" \
325
+ trainer.total_training_steps="${STEPS}" \
326
+ trainer.experiment_name="${name}" \
327
+ trainer.save_freq="${SAVE_FREQ}" \
328
+ trainer.default_local_dir="${checkpoint_dir}" \
329
+ trainer.logger="['console','wandb']" \
330
+ trainer.val_before_train=True \
331
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
332
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
333
+ actor_rollout_ref.rollout.rollout_filter_value="${filter_value}" \
334
+ actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=1 \
335
+ actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=1 \
336
+ ppo_mini_batch_size=32 \
337
+ es_manager.train.env_groups=${NUM_GROUPS} \
338
+ es_manager.train.group_size=${GROUP_SIZE} \
339
+ es_manager.train.env_configs.n_groups="[${NUM_GROUPS}]" \
340
+ es_manager.val.env_groups=256 \
341
+ es_manager.val.group_size=1 \
342
+ es_manager.val.env_configs.n_groups="[256]" \
343
+ "${common_overrides[@]}" \
344
+ "${env_overrides[@]}" \
345
+ "${checkpoint_overrides[@]}" \
346
+ "${algo_args[@]}" \
347
+ 2>&1 | tee "$log_path"
348
+ EXIT_CODE=${PIPESTATUS[0]}
349
+ END=$(date +%s)
350
+
351
+ TOTAL_TIME=$((END - START))
352
+ timing_values=()
353
+ mapfile -t timing_values < <(
354
+ python - "$log_path" <<'PY'
355
+ import re
356
+ import sys
357
+ from pathlib import Path
358
+
359
+ def last(pattern, text):
360
+ matches = re.findall(pattern, text)
361
+ return matches[-1] if matches else ""
362
+
363
+ try:
364
+ text = Path(sys.argv[1]).read_text(errors="ignore")
365
+ except Exception:
366
+ text = ""
367
+
368
+ patterns = [
369
+ r"timing_s/train_total[:\s]+([\d.]+)",
370
+ r"timing_s/eval_total[:\s]+([\d.]+)",
371
+ r"timing_s/total[:\s]+([\d.]+)",
372
+ ]
373
+
374
+ for pattern in patterns:
375
+ print(last(pattern, text))
376
+ PY
377
+ )
378
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
379
+ EVAL_TIME_RAW="${timing_values[1]:-}"
380
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
381
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
382
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
383
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
384
+
385
+ local status="success"
386
+ local error_line=""
387
+ if [ $EXIT_CODE -ne 0 ]; then
388
+ status="fail"
389
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
390
+ fi
391
+
392
+ local gpu_label
393
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
394
+ local summary_line="task=${task} | algo=${algo} | filter=${filter} | model=${model_name} | steps=${STEPS} | filter=${filter_strategy}:${filter_value} | prob_mode=${filter_prob_mode} | include_zero=${include_zero} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
395
+ echo "${summary_line}" > "${task_dir}/${name}.result"
396
+ echo "${summary_line}" | tee -a "$LOG_FILE"
397
+ if [ "$status" = "fail" ]; then
398
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
399
+ fi
400
+ return 0
401
+ }
402
+
403
+ EXPERIMENTS=()
404
+ GROUP_LABELS=()
405
+ CURRENT_GROUP=""
406
+
407
+ resolve_filter_selection() {
408
+ local raw="$1"
409
+ if [ -z "$raw" ] || [ "$raw" = "all" ]; then
410
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
411
+ return
412
+ fi
413
+ IFS=',' read -r -a candidates <<< "$raw"
414
+ SELECTED_FILTERS=()
415
+ for candidate in "${candidates[@]}"; do
416
+ candidate="${candidate// /}"
417
+ case "$candidate" in
418
+ topk25|topp09|topp095|nofilter)
419
+ SELECTED_FILTERS+=("$candidate")
420
+ ;;
421
+ "")
422
+ continue
423
+ ;;
424
+ *)
425
+ echo "Unknown filter mode: $candidate" >&2
426
+ exit 1
427
+ ;;
428
+ esac
429
+ done
430
+ if [ ${#SELECTED_FILTERS[@]} -eq 0 ]; then
431
+ echo "No valid filters selected via --filters" >&2
432
+ exit 1
433
+ fi
434
+ }
435
+
436
+ set_group() {
437
+ CURRENT_GROUP="$1"
438
+ GROUP_LABELS+=("$1")
439
+ }
440
+
441
+ add_experiment() {
442
+ local model_name=$1
443
+ local algo=$2
444
+ local filter=$3
445
+ EXPERIMENTS+=("${CURRENT_GROUP}|${TASK}|${model_name}|${algo}|${filter}|${CONFIG}")
446
+ }
447
+
448
+ resolve_filter_selection "$FILTERS_OPTION"
449
+
450
+ set_group "${MODEL_NAME} + ${ALGO}"
451
+ for filter in "${SELECTED_FILTERS[@]}"; do
452
+ add_experiment "$MODEL_NAME" "$ALGO" "$filter"
453
+ done
454
+
455
+ QUEUE_FILE=$(mktemp -t ragen_webshop_small_queue.XXXXXX)
456
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
457
+ echo 0 > "$QUEUE_FILE"
458
+ USE_FLOCK=false
459
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
460
+ MAIN_PID=$$
461
+
462
+ cleanup_queue() {
463
+ if [ "$$" -ne "$MAIN_PID" ]; then
464
+ return
465
+ fi
466
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
467
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
468
+ }
469
+ trap cleanup_queue EXIT
470
+
471
+ if command -v flock >/dev/null 2>&1; then
472
+ USE_FLOCK=true
473
+ fi
474
+
475
+ next_experiment_index() {
476
+ local idx
477
+ if [ "$USE_FLOCK" = true ]; then
478
+ flock -x "$QUEUE_LOCK_FD"
479
+ idx=$(cat "$QUEUE_FILE")
480
+ if [ -z "$idx" ]; then
481
+ idx=0
482
+ fi
483
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
484
+ flock -u "$QUEUE_LOCK_FD"
485
+ echo -1
486
+ return
487
+ fi
488
+ echo $((idx + 1)) > "$QUEUE_FILE"
489
+ flock -u "$QUEUE_LOCK_FD"
490
+ echo "$idx"
491
+ return
492
+ fi
493
+
494
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
495
+ sleep 0.05
496
+ done
497
+ idx=$(cat "$QUEUE_FILE")
498
+ if [ -z "$idx" ]; then
499
+ idx=0
500
+ fi
501
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
502
+ rmdir "$QUEUE_LOCK_DIR"
503
+ echo -1
504
+ return
505
+ fi
506
+ echo $((idx + 1)) > "$QUEUE_FILE"
507
+ rmdir "$QUEUE_LOCK_DIR"
508
+ echo "$idx"
509
+ }
510
+
511
+ run_queue_for_slot() {
512
+ local gpu_list=$1
513
+ if [ "$USE_FLOCK" = true ]; then
514
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
515
+ fi
516
+ while true; do
517
+ local idx
518
+ idx=$(next_experiment_index)
519
+ if [ "$idx" -lt 0 ]; then
520
+ break
521
+ fi
522
+ local exp="${EXPERIMENTS[$idx]}"
523
+ IFS='|' read -r exp_group task model_name algo filter config <<< "$exp"
524
+ run_experiment "$task" "$model_name" "$algo" "$filter" "$config" "$gpu_list" || true
525
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
526
+ sleep "$COOLDOWN_SECONDS"
527
+ fi
528
+ done
529
+ if [ "$USE_FLOCK" = true ]; then
530
+ exec {QUEUE_LOCK_FD}>&-
531
+ fi
532
+ }
533
+
534
+ pids=()
535
+ for idx in "${!GPU_GROUPS[@]}"; do
536
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
537
+ pids+=("$!")
538
+ done
539
+
540
+ for pid in "${pids[@]}"; do
541
+ wait "$pid"
542
+ done
543
+
544
+ {
545
+ echo ""
546
+ echo "=== Grouped Summary ==="
547
+ echo "GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL} | Task: ${TASK} | Steps: ${STEPS}"
548
+ for group_label in "${GROUP_LABELS[@]}"; do
549
+ echo "=== ${group_label} ==="
550
+ for exp in "${EXPERIMENTS[@]}"; do
551
+ IFS='|' read -r exp_group task model_name algo filter config <<< "$exp"
552
+ if [ "$exp_group" != "$group_label" ]; then
553
+ continue
554
+ fi
555
+ IFS='|' read -r _filter_strategy _filter_value _filter_prob_mode filter_suffix <<< "$(get_filter_config "$filter")"
556
+ name=$(build_experiment_name "$task" "$algo" "$filter_suffix" "$model_name")
557
+ task_dir="${RESULT_ROOT}/webshop_release_combos"
558
+ if [ -f "${task_dir}/${name}.result" ]; then
559
+ cat "${task_dir}/${name}.result"
560
+ else
561
+ echo "task=${task} | algo=${algo} | filter=${filter} | model=${model_name} | status=missing"
562
+ fi
563
+ done
564
+ done
565
+ } | tee -a "$LOG_FILE"
scripts/runs/run_webshop_small_combos.sh ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Webshop (small): 4 model×algo combos with filter/no-filter
3
+ # 1) Qwen2.5-3B-Instruct + PPO
4
+ # 2) Qwen2.5-3B-Instruct + GRPO
5
+ # 3) Qwen2.5-7B-Instruct + PPO
6
+ # 4) Llama-3.2-3B-Instruct + PPO
7
+ # Filtering rule: filter => top_p=0.9, nofilter => top_p=1.0
8
+
9
+ set -euo pipefail
10
+
11
+ # Defaults
12
+ STEPS=100
13
+ TASK="webshop"
14
+ CONFIG="_6_webshop"
15
+ SAVE_FREQ=100
16
+ NUM_GROUPS=8
17
+ GROUP_SIZE=16
18
+ COMBOS_SELECTION=""
19
+ FILTER_MODES=("filter" "nofilter")
20
+ FILTERS_OPTION="all"
21
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
22
+
23
+ # GPU settings
24
+ GPUS=()
25
+ GPUS_PROVIDED=false
26
+ GPUS_PER_EXP=1
27
+ COOLDOWN_SECONDS=30
28
+ GPU_MEMORY_UTILIZATION=0.3
29
+ declare -A GPU_LABELS
30
+
31
+ usage() {
32
+ echo "Usage: $0 [options]"
33
+ echo "Options:"
34
+ echo " --steps N Training steps (default: 100)"
35
+ echo " --gpus LIST Comma-separated GPU IDs (default: auto-detect)"
36
+ echo " --gpus-per-exp N GPUs per experiment (default: 1)"
37
+ echo " --cooldown SECONDS Cooldown between runs on the same GPU group (default: 30)"
38
+ echo " --gpu-memory-utilization V Rollout gpu_memory_utilization (default: 0.3)"
39
+ echo " --save-freq N Checkpoint save frequency (default: 100)"
40
+ echo " --filters LIST Comma-separated filter modes (filter,nofilter,all). Default: all"
41
+ echo " --combos LIST Comma-separated 1-based combo indices to run (e.g., 2,3,4). Default: all"
42
+ echo " -h, --help Show this help"
43
+ exit 0
44
+ }
45
+
46
+ while [ $# -gt 0 ]; do
47
+ case "$1" in
48
+ --steps) STEPS="$2"; shift 2 ;;
49
+ --steps=*) STEPS="${1#*=}"; shift ;;
50
+ --gpus) IFS=',' read -r -a GPUS <<< "$2"; GPUS_PROVIDED=true; shift 2 ;;
51
+ --gpus=*) IFS=',' read -r -a GPUS <<< "${1#*=}"; GPUS_PROVIDED=true; shift ;;
52
+ --gpus-per-exp) GPUS_PER_EXP="$2"; shift 2 ;;
53
+ --gpus-per-exp=*) GPUS_PER_EXP="${1#*=}"; shift ;;
54
+ --cooldown) COOLDOWN_SECONDS="$2"; shift 2 ;;
55
+ --cooldown=*) COOLDOWN_SECONDS="${1#*=}"; shift ;;
56
+ --gpu-memory-utilization) GPU_MEMORY_UTILIZATION="$2"; shift 2 ;;
57
+ --gpu-memory-utilization=*) GPU_MEMORY_UTILIZATION="${1#*=}"; shift ;;
58
+ --save-freq) SAVE_FREQ="$2"; shift 2 ;;
59
+ --save-freq=*) SAVE_FREQ="${1#*=}"; shift ;;
60
+ --filters) FILTERS_OPTION="$2"; shift 2 ;;
61
+ --filters=*) FILTERS_OPTION="${1#*=}"; shift ;;
62
+ --combos) COMBOS_SELECTION="$2"; shift 2 ;;
63
+ --combos=*) COMBOS_SELECTION="${1#*=}"; shift ;;
64
+ -h|--help) usage ;;
65
+ *) echo "Unknown argument: $1"; usage ;;
66
+ esac
67
+ done
68
+
69
+ # Map model names to HuggingFace paths
70
+ get_model_path() {
71
+ if [[ "$1" == *"/"* ]]; then
72
+ echo "$1"
73
+ return
74
+ fi
75
+ case "$1" in
76
+ Qwen2.5-3B-Instruct) echo "Qwen/Qwen2.5-3B-Instruct" ;;
77
+ Qwen2.5-7B-Instruct) echo "Qwen/Qwen2.5-7B-Instruct" ;;
78
+ Llama-3.2-3B-Instruct) echo "meta-llama/Llama-3.2-3B-Instruct" ;;
79
+ *) echo "Qwen/$1" ;;
80
+ esac
81
+ }
82
+
83
+ # Algorithm overrides (from diff_algo script)
84
+ get_algo_overrides() {
85
+ case "$1" in
86
+ PPO)
87
+ echo "algorithm.adv_estimator=gae actor_rollout_ref.actor.loss_agg_mode=token-mean"
88
+ ;;
89
+ GRPO)
90
+ echo "algorithm.adv_estimator=grpo algorithm.norm_adv_by_std_in_grpo=True actor_rollout_ref.actor.loss_agg_mode=seq-mean-token-mean"
91
+ ;;
92
+ *)
93
+ echo ""
94
+ ;;
95
+ esac
96
+ }
97
+
98
+ if [ "$GPUS_PROVIDED" = false ]; then
99
+ if command -v nvidia-smi >/dev/null 2>&1; then
100
+ GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l | tr -d ' ')
101
+ if [[ "$GPU_COUNT" =~ ^[0-9]+$ ]] && [ "$GPU_COUNT" -gt 0 ]; then
102
+ GPUS=()
103
+ for ((i=0; i<GPU_COUNT; i++)); do
104
+ GPUS+=("$i")
105
+ done
106
+ fi
107
+ fi
108
+ if [ ${#GPUS[@]} -eq 0 ]; then
109
+ echo "Warning: failed to auto-detect GPUs, falling back to 0-7" >&2
110
+ GPUS=(0 1 2 3 4 5 6 7)
111
+ fi
112
+ fi
113
+
114
+ if ! [[ "$GPUS_PER_EXP" =~ ^[0-9]+$ ]] || [ "$GPUS_PER_EXP" -lt 1 ]; then
115
+ echo "Error: --gpus-per-exp must be a positive integer"
116
+ exit 1
117
+ fi
118
+ if (( ${#GPUS[@]} < GPUS_PER_EXP )); then
119
+ echo "Error: --gpus-per-exp (${GPUS_PER_EXP}) exceeds available GPUs (${#GPUS[@]})"
120
+ exit 1
121
+ fi
122
+ if (( ${#GPUS[@]} % GPUS_PER_EXP != 0 )); then
123
+ echo "Error: GPU count (${#GPUS[@]}) must be divisible by --gpus-per-exp (${GPUS_PER_EXP})"
124
+ exit 1
125
+ fi
126
+
127
+ GPU_GROUPS=()
128
+ for ((i=0; i<${#GPUS[@]}; i+=GPUS_PER_EXP)); do
129
+ group="${GPUS[$i]}"
130
+ for ((j=1; j<GPUS_PER_EXP; j++)); do
131
+ group+=",${GPUS[$((i+j))]}"
132
+ done
133
+ GPU_GROUPS+=("$group")
134
+ done
135
+ NUM_SLOTS=${#GPU_GROUPS[@]}
136
+
137
+ short_gpu_name() {
138
+ local name="$1"
139
+ local cleaned
140
+ cleaned=$(echo "$name" | sed -E 's/^NVIDIA //; s/^Tesla //; s/^GeForce //; s/^Quadro //; s/^RTX //')
141
+ if [[ "$cleaned" =~ (B[0-9]{2,3}|H[0-9]{2,3}|A[0-9]{2,3}|L[0-9]{2,3}|V100|T4|P100|K80) ]]; then
142
+ echo "${BASH_REMATCH[1]}"
143
+ return
144
+ fi
145
+ echo "${cleaned%% *}"
146
+ }
147
+
148
+ get_gpu_label() {
149
+ local gpu_id="$1"
150
+ if [ -n "${GPU_LABELS[$gpu_id]+x}" ]; then
151
+ echo "${GPU_LABELS[$gpu_id]}"
152
+ return
153
+ fi
154
+ local name=""
155
+ if command -v nvidia-smi >/dev/null 2>&1; then
156
+ name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i "$gpu_id" 2>/dev/null | head -1)
157
+ fi
158
+ if [ -z "$name" ]; then
159
+ GPU_LABELS[$gpu_id]="1xGPU${gpu_id}"
160
+ echo "${GPU_LABELS[$gpu_id]}"
161
+ return
162
+ fi
163
+ local short
164
+ short=$(short_gpu_name "$name")
165
+ GPU_LABELS[$gpu_id]="1x${short}"
166
+ echo "${GPU_LABELS[$gpu_id]}"
167
+ }
168
+
169
+ get_gpu_model_label() {
170
+ local models=()
171
+ local id label model
172
+ for id in "${GPUS[@]}"; do
173
+ label=$(get_gpu_label "$id")
174
+ model="${label#1x}"
175
+ models+=("$model")
176
+ done
177
+ local unique_models=()
178
+ local m found
179
+ for m in "${models[@]}"; do
180
+ found=false
181
+ for u in "${unique_models[@]}"; do
182
+ if [ "$u" = "$m" ]; then
183
+ found=true
184
+ break
185
+ fi
186
+ done
187
+ if [ "$found" = false ]; then
188
+ unique_models+=("$m")
189
+ fi
190
+ done
191
+ if [ ${#unique_models[@]} -eq 1 ]; then
192
+ echo "${unique_models[0]}"
193
+ else
194
+ echo "mixed"
195
+ fi
196
+ }
197
+
198
+ get_gpu_label_for_list() {
199
+ local gpu_list="$1"
200
+ IFS=',' read -r -a ids <<< "$gpu_list"
201
+ local count=${#ids[@]}
202
+ if [ "$count" -eq 0 ]; then
203
+ echo "0xGPU"
204
+ return
205
+ fi
206
+ local first_model
207
+ first_model="$(get_gpu_label "${ids[0]}")"
208
+ first_model="${first_model#1x}"
209
+ local id model
210
+ for id in "${ids[@]:1}"; do
211
+ model="$(get_gpu_label "$id")"
212
+ model="${model#1x}"
213
+ if [ "$model" != "$first_model" ]; then
214
+ echo "${count}xmixed"
215
+ return
216
+ fi
217
+ done
218
+ echo "${count}x${first_model}"
219
+ }
220
+
221
+ GPU_MODEL_LABEL=$(get_gpu_model_label)
222
+ GPU_LOG_LABEL="${GPUS_PER_EXP}x${GPU_MODEL_LABEL}"
223
+ LOG_FILE="logs/webshop_small_combos.log"
224
+ RESULT_ROOT="logs"
225
+ CHECKPOINT_ROOT="model_saving/webshop_small_combos"
226
+
227
+ mkdir -p logs
228
+ mkdir -p "$RESULT_ROOT"
229
+ mkdir -p "$CHECKPOINT_ROOT"
230
+
231
+ echo "=== Webshop Small Combos Runner: $(date) ===" | tee "$LOG_FILE"
232
+ echo "Task: ${TASK} | Steps: ${STEPS} | GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL}" | tee -a "$LOG_FILE"
233
+ echo "GPUS: ${GPUS[*]} | groups: ${GPU_GROUPS[*]} | cooldown=${COOLDOWN_SECONDS}s" | tee -a "$LOG_FILE"
234
+
235
+ run_experiment() {
236
+ local task=$1
237
+ local model_name=$2
238
+ local algo=$3
239
+ local filter=$4
240
+ local config=$5
241
+ local gpu_list=$6
242
+
243
+ local model_path
244
+ model_path=$(get_model_path "$model_name")
245
+
246
+ local filter_value
247
+ local include_zero
248
+ if [ "$filter" = "filter" ]; then
249
+ filter_value=0.9
250
+ include_zero=False
251
+ else
252
+ filter_value=1.0
253
+ include_zero=True
254
+ fi
255
+ local filter_strategy="top_p"
256
+
257
+ local common_overrides=(
258
+ "actor_rollout_ref.actor.use_kl_loss=False"
259
+ "actor_rollout_ref.actor.kl_loss_type=low-var-kl"
260
+ "actor_rollout_ref.actor.kl_loss_coef=0.001"
261
+ "actor_rollout_ref.actor.entropy_coeff=0.001"
262
+ "actor_rollout_ref.actor.entropy_from_logits_with_chunking=True"
263
+ "actor_rollout_ref.actor.filter_loss_scaling=none"
264
+ "actor_rollout_ref.rollout.gpu_memory_utilization=${GPU_MEMORY_UTILIZATION}"
265
+ "actor_rollout_ref.rollout.rollout_filter_strategy=${filter_strategy}"
266
+ "actor_rollout_ref.rollout.rollout_filter_top_p_prob_mode=linear"
267
+ "actor_rollout_ref.rollout.rollout_filter_type=largest"
268
+ "actor_rollout_ref.rollout.rollout_filter_metric=reward_variance"
269
+ "actor_rollout_ref.rollout.rollout_filter_include_zero=${include_zero}"
270
+ )
271
+
272
+ local env_overrides=()
273
+
274
+ local checkpoint_overrides=(
275
+ "actor_rollout_ref.actor.checkpoint.save_contents=[model]"
276
+ "critic.checkpoint.save_contents=[model]"
277
+ )
278
+
279
+ local algo_overrides
280
+ algo_overrides=$(get_algo_overrides "$algo")
281
+ read -r -a algo_args <<< "$algo_overrides"
282
+
283
+ local name="${task}-${algo}-${filter}-${model_name}-${NUM_GROUPS}x${GROUP_SIZE}-linear"
284
+ local task_dir="${RESULT_ROOT}/webshop_small_combos"
285
+ local log_path="${task_dir}/${name}.log"
286
+ local checkpoint_dir="${CHECKPOINT_ROOT}/${model_name}/${algo}/${filter}/${name}"
287
+ local gpus_per_exp
288
+ IFS=',' read -r -a gpu_ids <<< "$gpu_list"
289
+ gpus_per_exp=${#gpu_ids[@]}
290
+
291
+ mkdir -p "$task_dir"
292
+ mkdir -p "${checkpoint_dir}"
293
+ START=$(date +%s)
294
+ CUDA_VISIBLE_DEVICES="${gpu_list}" python train.py --config-name "$config" \
295
+ model_path="${model_path}" \
296
+ micro_batch_size_per_gpu=1 \
297
+ agent_proxy.max_turn=12 \
298
+ trainer.project_name="main_webshop" \
299
+ trainer.total_training_steps="${STEPS}" \
300
+ trainer.experiment_name="${name}" \
301
+ trainer.save_freq="${SAVE_FREQ}" \
302
+ trainer.default_local_dir="${checkpoint_dir}" \
303
+ trainer.logger="['console','wandb']" \
304
+ trainer.val_before_train=True \
305
+ trainer.n_gpus_per_node="${gpus_per_exp}" \
306
+ system.CUDA_VISIBLE_DEVICES="'${gpu_list}'" \
307
+ actor_rollout_ref.rollout.rollout_filter_value="${filter_value}" \
308
+ ppo_mini_batch_size=16 \
309
+ es_manager.train.env_groups=${NUM_GROUPS} \
310
+ es_manager.train.group_size=${GROUP_SIZE} \
311
+ es_manager.train.env_configs.n_groups="[${NUM_GROUPS}]" \
312
+ es_manager.val.env_groups=128 \
313
+ es_manager.val.group_size=1 \
314
+ es_manager.val.env_configs.n_groups="[128]" \
315
+ "${common_overrides[@]}" \
316
+ "${env_overrides[@]}" \
317
+ "${checkpoint_overrides[@]}" \
318
+ "${algo_args[@]}" \
319
+ 2>&1 | tee "$log_path"
320
+ EXIT_CODE=${PIPESTATUS[0]}
321
+ END=$(date +%s)
322
+
323
+ TOTAL_TIME=$((END - START))
324
+ timing_values=()
325
+ mapfile -t timing_values < <(
326
+ python - "$log_path" <<'PY'
327
+ import re
328
+ import sys
329
+ from pathlib import Path
330
+
331
+ def last(pattern, text):
332
+ matches = re.findall(pattern, text)
333
+ return matches[-1] if matches else ""
334
+
335
+ try:
336
+ text = Path(sys.argv[1]).read_text(errors="ignore")
337
+ except Exception:
338
+ text = ""
339
+
340
+ patterns = [
341
+ r"timing_s/train_total[:\s]+([\d.]+)",
342
+ r"timing_s/eval_total[:\s]+([\d.]+)",
343
+ r"timing_s/total[:\s]+([\d.]+)",
344
+ ]
345
+
346
+ for pattern in patterns:
347
+ print(last(pattern, text))
348
+ PY
349
+ )
350
+ TRAIN_TIME_RAW="${timing_values[0]:-}"
351
+ EVAL_TIME_RAW="${timing_values[1]:-}"
352
+ TOTAL_TIME_RAW="${timing_values[2]:-}"
353
+ TRAIN_TIME=$([ -n "$TRAIN_TIME_RAW" ] && printf "%.2f" "$TRAIN_TIME_RAW" || echo "N/A")
354
+ EVAL_TIME=$([ -n "$EVAL_TIME_RAW" ] && printf "%.2f" "$EVAL_TIME_RAW" || echo "N/A")
355
+ TOTAL_TIME_METRIC=$([ -n "$TOTAL_TIME_RAW" ] && printf "%.2f" "$TOTAL_TIME_RAW" || echo "N/A")
356
+
357
+ local status="success"
358
+ local error_line=""
359
+ if [ $EXIT_CODE -ne 0 ]; then
360
+ status="fail"
361
+ error_line=$(tail -2 "$log_path" | tr '\n' ' ')
362
+ fi
363
+
364
+ local gpu_label
365
+ gpu_label=$(get_gpu_label_for_list "$gpu_list")
366
+ local summary_line="task=${task} | algo=${algo} | filter=${filter} | model=${model_name} | steps=${STEPS} | filter=${filter_strategy}:${filter_value} | train_time=${TRAIN_TIME}s | eval_time=${EVAL_TIME}s | total_time=${TOTAL_TIME_METRIC}s | wall_time=${TOTAL_TIME}s | gpu=${gpu_label} | status=${status}"
367
+ echo "${summary_line}" > "${task_dir}/${name}.result"
368
+ echo "${summary_line}" | tee -a "$LOG_FILE"
369
+ if [ "$status" = "fail" ]; then
370
+ echo " error: ${error_line}" | tee -a "$LOG_FILE"
371
+ fi
372
+ return 0
373
+ }
374
+
375
+ EXPERIMENTS=()
376
+ GROUP_LABELS=()
377
+ CURRENT_GROUP=""
378
+
379
+ resolve_filter_selection() {
380
+ local raw="$1"
381
+ if [ -z "$raw" ] || [ "$raw" = "all" ]; then
382
+ SELECTED_FILTERS=("${FILTER_MODES[@]}")
383
+ return
384
+ fi
385
+ IFS=',' read -r -a candidates <<< "$raw"
386
+ SELECTED_FILTERS=()
387
+ for candidate in "${candidates[@]}"; do
388
+ candidate="${candidate// /}"
389
+ case "$candidate" in
390
+ filter|nofilter)
391
+ SELECTED_FILTERS+=("$candidate")
392
+ ;;
393
+ "")
394
+ continue
395
+ ;;
396
+ *)
397
+ echo "Unknown filter mode: $candidate" >&2
398
+ exit 1
399
+ ;;
400
+ esac
401
+ done
402
+ if [ ${#SELECTED_FILTERS[@]} -eq 0 ]; then
403
+ echo "No valid filters selected via --filters" >&2
404
+ exit 1
405
+ fi
406
+ }
407
+
408
+ set_group() {
409
+ CURRENT_GROUP="$1"
410
+ GROUP_LABELS+=("$1")
411
+ }
412
+
413
+ add_experiment() {
414
+ local model_name=$1
415
+ local algo=$2
416
+ local filter=$3
417
+ EXPERIMENTS+=("${CURRENT_GROUP}|${TASK}|${model_name}|${algo}|${filter}|${CONFIG}")
418
+ }
419
+
420
+ resolve_filter_selection "$FILTERS_OPTION"
421
+
422
+ # Define the 4 combos: (model, algo)
423
+ ALL_COMBOS=(
424
+ "Qwen2.5-3B-Instruct|PPO"
425
+ "Qwen2.5-3B-Instruct|GRPO"
426
+ "Qwen2.5-7B-Instruct|PPO"
427
+ "Llama-3.2-3B-Instruct|PPO"
428
+ )
429
+
430
+ if [ -n "$COMBOS_SELECTION" ]; then
431
+ COMBOS=()
432
+ IFS=',' read -r -a combo_indices <<< "$COMBOS_SELECTION"
433
+ for ci in "${combo_indices[@]}"; do
434
+ idx=$((ci - 1))
435
+ if [ "$idx" -ge 0 ] && [ "$idx" -lt ${#ALL_COMBOS[@]} ]; then
436
+ COMBOS+=("${ALL_COMBOS[$idx]}")
437
+ else
438
+ echo "Invalid combo index: $ci (valid: 1-${#ALL_COMBOS[@]})" >&2
439
+ exit 1
440
+ fi
441
+ done
442
+ else
443
+ COMBOS=("${ALL_COMBOS[@]}")
444
+ fi
445
+
446
+ for combo in "${COMBOS[@]}"; do
447
+ IFS='|' read -r model_name algo <<< "$combo"
448
+ set_group "${model_name} + ${algo}"
449
+ for filter in "${SELECTED_FILTERS[@]}"; do
450
+ add_experiment "$model_name" "$algo" "$filter"
451
+ done
452
+ done
453
+
454
+ QUEUE_FILE=$(mktemp -t ragen_webshop_small_queue.XXXXXX)
455
+ QUEUE_LOCK="${QUEUE_FILE}.lock"
456
+ echo 0 > "$QUEUE_FILE"
457
+ USE_FLOCK=false
458
+ QUEUE_LOCK_DIR="${QUEUE_LOCK}.d"
459
+ MAIN_PID=$$
460
+
461
+ cleanup_queue() {
462
+ if [ "$$" -ne "$MAIN_PID" ]; then
463
+ return
464
+ fi
465
+ rm -f "$QUEUE_FILE" "$QUEUE_LOCK"
466
+ rmdir "$QUEUE_LOCK_DIR" 2>/dev/null || true
467
+ }
468
+ trap cleanup_queue EXIT
469
+
470
+ if command -v flock >/dev/null 2>&1; then
471
+ USE_FLOCK=true
472
+ fi
473
+
474
+ next_experiment_index() {
475
+ local idx
476
+ if [ "$USE_FLOCK" = true ]; then
477
+ flock -x "$QUEUE_LOCK_FD"
478
+ idx=$(cat "$QUEUE_FILE")
479
+ if [ -z "$idx" ]; then
480
+ idx=0
481
+ fi
482
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
483
+ flock -u "$QUEUE_LOCK_FD"
484
+ echo -1
485
+ return
486
+ fi
487
+ echo $((idx + 1)) > "$QUEUE_FILE"
488
+ flock -u "$QUEUE_LOCK_FD"
489
+ echo "$idx"
490
+ return
491
+ fi
492
+
493
+ while ! mkdir "$QUEUE_LOCK_DIR" 2>/dev/null; do
494
+ sleep 0.05
495
+ done
496
+ idx=$(cat "$QUEUE_FILE")
497
+ if [ -z "$idx" ]; then
498
+ idx=0
499
+ fi
500
+ if (( idx >= ${#EXPERIMENTS[@]} )); then
501
+ rmdir "$QUEUE_LOCK_DIR"
502
+ echo -1
503
+ return
504
+ fi
505
+ echo $((idx + 1)) > "$QUEUE_FILE"
506
+ rmdir "$QUEUE_LOCK_DIR"
507
+ echo "$idx"
508
+ }
509
+
510
+ run_queue_for_slot() {
511
+ local gpu_list=$1
512
+ if [ "$USE_FLOCK" = true ]; then
513
+ exec {QUEUE_LOCK_FD}>"$QUEUE_LOCK"
514
+ fi
515
+ while true; do
516
+ local idx
517
+ idx=$(next_experiment_index)
518
+ if [ "$idx" -lt 0 ]; then
519
+ break
520
+ fi
521
+ local exp="${EXPERIMENTS[$idx]}"
522
+ IFS='|' read -r exp_group task model_name algo filter config <<< "$exp"
523
+ run_experiment "$task" "$model_name" "$algo" "$filter" "$config" "$gpu_list" || true
524
+ if [ "$COOLDOWN_SECONDS" -gt 0 ]; then
525
+ sleep "$COOLDOWN_SECONDS"
526
+ fi
527
+ done
528
+ if [ "$USE_FLOCK" = true ]; then
529
+ exec {QUEUE_LOCK_FD}>&-
530
+ fi
531
+ }
532
+
533
+ pids=()
534
+ for idx in "${!GPU_GROUPS[@]}"; do
535
+ run_queue_for_slot "${GPU_GROUPS[$idx]}" &
536
+ pids+=("$!")
537
+ done
538
+
539
+ for pid in "${pids[@]}"; do
540
+ wait "$pid"
541
+ done
542
+
543
+ {
544
+ echo ""
545
+ echo "=== Grouped Summary ==="
546
+ echo "GPU per exp: ${GPUS_PER_EXP}x${GPU_MODEL_LABEL} | Task: ${TASK} | Steps: ${STEPS}"
547
+ for group_label in "${GROUP_LABELS[@]}"; do
548
+ echo "=== ${group_label} ==="
549
+ for exp in "${EXPERIMENTS[@]}"; do
550
+ IFS='|' read -r exp_group task model_name algo filter config <<< "$exp"
551
+ if [ "$exp_group" != "$group_label" ]; then
552
+ continue
553
+ fi
554
+ name="${task}-${algo}-${filter}-${model_name}-${NUM_GROUPS}x${GROUP_SIZE}-linear"
555
+ task_dir="${RESULT_ROOT}/webshop_small_combos"
556
+ if [ -f "${task_dir}/${name}.result" ]; then
557
+ cat "${task_dir}/${name}.result"
558
+ else
559
+ echo "task=${task} | algo=${algo} | filter=${filter} | model=${model_name} | status=missing"
560
+ fi
561
+ done
562
+ done
563
+ } | tee -a "$LOG_FILE"
scripts/setup_ragen.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Scripts README
2
+
3
+ ## Release Environment Setup
4
+
5
+ Use the setup flow below for the validated RAGEN environment.
6
+
7
+ This setup has been validated on `H100`, `H200`, and `B200`, and supports:
8
+ - `bandit`
9
+ - `sokoban`
10
+ - `frozenlake`
11
+ - `metamathqa`
12
+ - `countdown`
13
+ - `deepcoder`
14
+
15
+ ## Requirements
16
+
17
+ - `CUDA >= 12.8`
18
+
19
+ ### 1. Clone the repository
20
+
21
+ ```bash
22
+ git clone https://github.com/CHIGUI0/RAGEN.git
23
+ cd RAGEN
24
+ ```
25
+
26
+ ### 2. Create and activate the conda environment
27
+
28
+ ```bash
29
+ conda create -n ragen python=3.12 -y
30
+ conda activate ragen
31
+ ```
32
+
33
+ ### 3. Run the environment setup script
34
+
35
+ ```bash
36
+ bash scripts/setup_ragen.sh
37
+ ```
38
+
39
+ If you want to install the `search` environment, use the following command:
40
+
41
+ ```bash
42
+ bash scripts/setup_ragen.sh --with-search
43
+ ```
44
+
45
+ This release setup does not install `webshop`. If you need `webshop`, use its separate setup flow instead of `setup_ragen.sh`.
46
+
47
+ If you want to run WebShop experiments, see [docs/experiment_webshop_release.md](../docs/experiment_webshop_release.md).
scripts/visualize.py ADDED
@@ -0,0 +1,692 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Local rollout visualizer.
4
+
5
+ Usage:
6
+ python scripts/visualize.py --rollout_path results/ [--host 127.0.0.1] [--port 8000]
7
+
8
+ The script launches a small HTTP server that lets you inspect .pkl files
9
+ (containing verl.DataProto dumps) inside the rollout path. Open the printed
10
+ URL in a browser to explore directories, select a file, and view its
11
+ meta information and non-tensor batches entry by entry.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import json
18
+ import logging
19
+ import threading
20
+ from functools import lru_cache
21
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
22
+ from pathlib import Path
23
+ from typing import Any, Dict, List
24
+ from urllib.parse import parse_qs, urlparse
25
+ import webbrowser
26
+
27
+ import numpy as np
28
+
29
+ from verl import DataProto
30
+
31
+ LOGGER = logging.getLogger(__name__)
32
+
33
+
34
+ def parse_args() -> argparse.Namespace:
35
+ parser = argparse.ArgumentParser(description="Launch a local rollout visualizer")
36
+ parser.add_argument("--rollout_path", required=True, help="Directory containing rollout .pkl files")
37
+ parser.add_argument("--host", default="127.0.0.1", help="Host to bind (default: 127.0.0.1)")
38
+ parser.add_argument("--port", type=int, default=8000, help="Port to bind (default: 8000)")
39
+ parser.add_argument("--no-browser", action="store_true", help="Do not attempt to open a browser automatically")
40
+ return parser.parse_args()
41
+
42
+
43
+ def ensure_within(path: Path, root: Path) -> Path:
44
+ resolved = path.resolve()
45
+ try:
46
+ resolved.relative_to(root)
47
+ except ValueError as exc:
48
+ raise ValueError(f"Path {path} escapes the rollout root {root}") from exc
49
+ return resolved
50
+
51
+
52
+ def numpy_summary(array: np.ndarray) -> Dict[str, Any]:
53
+ array = np.asarray(array)
54
+ summary: Dict[str, Any] = {
55
+ "__type__": "ndarray",
56
+ "dtype": str(array.dtype),
57
+ "shape": list(array.shape),
58
+ "size": int(array.size),
59
+ }
60
+ preview_limit = 32
61
+ flat = array.reshape(-1)
62
+ preview = flat[:preview_limit].tolist()
63
+ summary["preview"] = preview
64
+ summary["preview_count"] = len(preview)
65
+ if array.size <= preview_limit and array.size <= 10_000:
66
+ summary["values"] = array.tolist()
67
+ return summary
68
+
69
+
70
+ def serialize_for_view(value: Any, depth: int = 0) -> Any:
71
+ if depth > 6:
72
+ return repr(value)
73
+
74
+ if value is None or isinstance(value, (str, int, float, bool)):
75
+ return value
76
+
77
+ if isinstance(value, (np.integer, np.floating, np.bool_)):
78
+ return value.item()
79
+
80
+ if isinstance(value, dict):
81
+ return {str(key): serialize_for_view(val, depth + 1) for key, val in value.items()}
82
+
83
+ if isinstance(value, (list, tuple, set)):
84
+ return [serialize_for_view(val, depth + 1) for val in value]
85
+
86
+ if isinstance(value, np.ndarray):
87
+ return numpy_summary(value)
88
+
89
+ return repr(value)
90
+
91
+
92
+ def build_tree(root: Path) -> Dict[str, Any]:
93
+ root_node: Dict[str, Any] = {"name": root.name, "path": "", "type": "dir", "children": []}
94
+ nodes: Dict[str, Dict[str, Any]] = {"": root_node}
95
+
96
+ for file_path in sorted(root.rglob("*.pkl")):
97
+ rel_path = file_path.relative_to(root)
98
+ rel_path_posix = rel_path.as_posix()
99
+ parts = rel_path.parts
100
+ if not parts:
101
+ continue
102
+
103
+ cumulative = []
104
+ for part in parts[:-1]:
105
+ cumulative.append(part)
106
+ current_key = "/".join(cumulative)
107
+ parent_key = "/".join(cumulative[:-1]) if len(cumulative) > 1 else ""
108
+ if current_key not in nodes:
109
+ node = {"name": part, "path": current_key, "type": "dir", "children": []}
110
+ nodes[current_key] = node
111
+ nodes[parent_key]["children"].append(node)
112
+ file_parent_key = "/".join(parts[:-1]) if len(parts) > 1 else ""
113
+ file_node = {"name": parts[-1], "path": rel_path_posix, "type": "file"}
114
+ nodes[file_parent_key]["children"].append(file_node)
115
+
116
+ def sort_children(node: Dict[str, Any]) -> None:
117
+ children = node.get("children")
118
+ if not children:
119
+ return
120
+ children.sort(key=lambda item: (item.get("type") != "dir", item.get("name", "")))
121
+ for child in children:
122
+ if child.get("type") == "dir":
123
+ sort_children(child)
124
+
125
+ sort_children(root_node)
126
+ return root_node
127
+
128
+
129
+ def data_proto_to_payload(file_path: Path) -> Dict[str, Any]:
130
+ data = DataProto.load_from_disk(str(file_path))
131
+ length = len(data)
132
+ items: List[Dict[str, Any]] = []
133
+ for idx in range(length):
134
+ try:
135
+ item = data[idx]
136
+ except Exception as exc: # pragma: no cover - defensive guard
137
+ LOGGER.warning("Failed to read item %s from %s: %s", idx, file_path, exc)
138
+ continue
139
+ items.append(
140
+ {
141
+ "index": idx,
142
+ "meta_info": serialize_for_view(item.meta_info),
143
+ "non_tensor_batch": serialize_for_view(item.non_tensor_batch),
144
+ }
145
+ )
146
+
147
+ return {
148
+ "path": str(file_path),
149
+ "length": length,
150
+ "meta_info": serialize_for_view(data.meta_info),
151
+ "items": items,
152
+ }
153
+
154
+
155
+ class RolloutExplorer:
156
+ def __init__(self, root: Path):
157
+ self.root = root
158
+ self._tree_cache: Dict[str, Any] | None = None
159
+ self._lock = threading.Lock()
160
+
161
+ def tree(self) -> Dict[str, Any]:
162
+ with self._lock:
163
+ if self._tree_cache is None:
164
+ self._tree_cache = build_tree(self.root)
165
+ return self._tree_cache
166
+
167
+ @lru_cache(maxsize=32)
168
+ def load_file(self, relative_path: str) -> Dict[str, Any]:
169
+ normalized_path = Path(relative_path)
170
+ target = ensure_within(self.root / normalized_path, self.root)
171
+ if not target.exists() or not target.is_file():
172
+ raise FileNotFoundError(f"File {relative_path} not found under {self.root}")
173
+ payload = data_proto_to_payload(target)
174
+ payload["relative_path"] = target.relative_to(self.root).as_posix()
175
+ return payload
176
+
177
+
178
+ HTML_PAGE = """<!DOCTYPE html>
179
+ <html lang=\"en\">
180
+ <head>
181
+ <meta charset=\"utf-8\" />
182
+ <title>Rollout Visualizer</title>
183
+ <style>
184
+ :root {
185
+ color-scheme: light dark;
186
+ --bg: #f7f7fb;
187
+ --panel: #ffffffcc;
188
+ --accent: #4a6cff;
189
+ --accent-soft: #e6ebff;
190
+ --text: #1d1d25;
191
+ --border: #d9d9e3;
192
+ }
193
+ * { box-sizing: border-box; }
194
+ body {
195
+ margin: 0;
196
+ font-family: "Segoe UI", Tahoma, sans-serif;
197
+ background: var(--bg);
198
+ color: var(--text);
199
+ }
200
+ header {
201
+ padding: 14px 24px;
202
+ background: linear-gradient(135deg, var(--accent), #7f9bff);
203
+ color: white;
204
+ font-weight: 600;
205
+ letter-spacing: 0.4px;
206
+ }
207
+ #layout {
208
+ display: flex;
209
+ height: calc(100vh - 56px);
210
+ }
211
+ #sidebar {
212
+ width: 28%;
213
+ max-width: 360px;
214
+ min-width: 240px;
215
+ border-right: 1px solid var(--border);
216
+ background: var(--panel);
217
+ padding: 12px 16px;
218
+ overflow-y: auto;
219
+ }
220
+ #content {
221
+ flex: 1;
222
+ overflow-y: auto;
223
+ padding: 20px 28px;
224
+ }
225
+ .tree-node {
226
+ margin-left: 12px;
227
+ }
228
+ .tree-toggle {
229
+ cursor: pointer;
230
+ user-select: none;
231
+ display: inline-flex;
232
+ align-items: center;
233
+ gap: 6px;
234
+ padding: 4px 6px;
235
+ border-radius: 6px;
236
+ }
237
+ .tree-toggle:hover {
238
+ background: var(--accent-soft);
239
+ }
240
+ .file-entry {
241
+ cursor: pointer;
242
+ display: block;
243
+ padding: 4px 8px;
244
+ margin: 2px 0;
245
+ border-radius: 6px;
246
+ }
247
+ .file-entry:hover,
248
+ .file-entry.active {
249
+ background: var(--accent-soft);
250
+ color: var(--accent);
251
+ }
252
+ .panel {
253
+ background: var(--panel);
254
+ border: 1px solid var(--border);
255
+ border-radius: 12px;
256
+ padding: 16px 20px;
257
+ box-shadow: 0 4px 16px rgba(76, 96, 255, 0.05);
258
+ }
259
+ .section-title {
260
+ font-weight: 600;
261
+ margin-bottom: 12px;
262
+ font-size: 18px;
263
+ }
264
+ .meta-grid {
265
+ display: grid;
266
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
267
+ gap: 12px;
268
+ }
269
+ .section-subtitle {
270
+ font-weight: 600;
271
+ margin: 18px 0 10px;
272
+ color: var(--accent);
273
+ font-size: 16px;
274
+ }
275
+ .kv-block {
276
+ border: 1px solid var(--border);
277
+ border-radius: 10px;
278
+ padding: 12px;
279
+ background: #fff;
280
+ }
281
+ .kv-header {
282
+ font-weight: 600;
283
+ margin-bottom: 8px;
284
+ color: var(--accent);
285
+ }
286
+ .kv-body {
287
+ font-size: 14px;
288
+ line-height: 1.5;
289
+ white-space: pre-wrap;
290
+ }
291
+ details {
292
+ border: 1px solid var(--border);
293
+ border-radius: 10px;
294
+ padding: 10px 14px;
295
+ margin-bottom: 10px;
296
+ background: #fff;
297
+ }
298
+ details[open] {
299
+ border-color: var(--accent);
300
+ box-shadow: 0 4px 12px rgba(74, 108, 255, 0.08);
301
+ }
302
+ summary {
303
+ cursor: pointer;
304
+ font-weight: 600;
305
+ color: var(--accent);
306
+ }
307
+ .message-card {
308
+ border: 1px solid var(--border);
309
+ border-radius: 8px;
310
+ padding: 10px 12px;
311
+ margin: 6px 0;
312
+ background: #fbfbff;
313
+ }
314
+ .message-meta {
315
+ font-size: 13px;
316
+ opacity: 0.7;
317
+ margin-bottom: 4px;
318
+ }
319
+ .message-content {
320
+ white-space: pre-wrap;
321
+ font-family: "Fira Code", "Consolas", monospace;
322
+ font-size: 14px;
323
+ }
324
+ .messages-section {
325
+ border: 1px solid var(--border);
326
+ border-radius: 12px;
327
+ padding: 14px 16px;
328
+ background: #f3f5ff;
329
+ margin-bottom: 14px;
330
+ box-shadow: inset 0 0 0 1px rgba(74, 108, 255, 0.05);
331
+ }
332
+ .messages-section .section-subtitle {
333
+ margin-top: 0;
334
+ color: var(--accent);
335
+ }
336
+ .placeholder {
337
+ opacity: 0.6;
338
+ font-style: italic;
339
+ }
340
+ </style>
341
+ </head>
342
+ <body>
343
+ <header>Rollout Visualizer</header>
344
+ <div id="layout">
345
+ <aside id="sidebar">
346
+ <div id="tree"></div>
347
+ </aside>
348
+ <main id="content">
349
+ <div class="panel placeholder">Select a file to inspect its rollout details.</div>
350
+ </main>
351
+ </div>
352
+ <script>
353
+ let activePath = null;
354
+
355
+ async function fetchJSON(url) {
356
+ const res = await fetch(url);
357
+ if (!res.ok) {
358
+ const text = await res.text();
359
+ throw new Error(text || res.statusText);
360
+ }
361
+ return res.json();
362
+ }
363
+
364
+ function createElement(tag, options = {}) {
365
+ const el = document.createElement(tag);
366
+ if (options.className) el.className = options.className;
367
+ if (options.text) el.textContent = options.text;
368
+ if (options.html) el.innerHTML = options.html;
369
+ return el;
370
+ }
371
+
372
+ function renderTree(node, container) {
373
+ const wrapper = createElement('div', { className: 'tree-node' });
374
+ const hasChildren = Array.isArray(node.children) && node.children.length > 0;
375
+
376
+ if (node.type === 'dir') {
377
+ const summary = createElement('div', { className: 'tree-toggle' });
378
+ const icon = createElement('span', { text: hasChildren ? '▸' : '•' });
379
+ icon.dataset.state = 'collapsed';
380
+ const label = createElement('span', { text: node.name || '(root)' });
381
+ summary.append(icon, label);
382
+ wrapper.appendChild(summary);
383
+ const childrenContainer = createElement('div');
384
+ childrenContainer.style.display = 'none';
385
+ if (node.path === '') {
386
+ childrenContainer.style.display = 'block';
387
+ icon.textContent = '▾';
388
+ }
389
+ summary.addEventListener('click', () => {
390
+ if (!hasChildren) return;
391
+ if (childrenContainer.style.display === 'none') {
392
+ childrenContainer.style.display = 'block';
393
+ icon.textContent = '▾';
394
+ } else {
395
+ childrenContainer.style.display = 'none';
396
+ icon.textContent = '▸';
397
+ }
398
+ });
399
+ wrapper.appendChild(childrenContainer);
400
+ node.children.forEach(child => renderTree(child, childrenContainer));
401
+ } else if (node.type === 'file') {
402
+ const entry = createElement('div', { className: 'file-entry', text: node.name });
403
+ entry.dataset.path = node.path;
404
+ entry.addEventListener('click', () => loadFile(node.path, entry));
405
+ wrapper.appendChild(entry);
406
+ }
407
+ container.appendChild(wrapper);
408
+ }
409
+
410
+ function renderKeyValue(container, key, value) {
411
+ const block = createElement('div', { className: 'kv-block' });
412
+ block.appendChild(createElement('div', { className: 'kv-header', text: key }));
413
+ const body = createElement('div', { className: 'kv-body' });
414
+ body.appendChild(renderValue(value, key));
415
+ block.appendChild(body);
416
+ container.appendChild(block);
417
+ }
418
+
419
+ function renderMessages(messages) {
420
+ const wrapper = createElement('div');
421
+ messages.forEach((msg, idx) => {
422
+ const card = createElement('div', { className: 'message-card' });
423
+ const role = msg.role || msg.author || `Message ${idx}`;
424
+ const meta = createElement('div', { className: 'message-meta', text: `${role}` });
425
+ if (msg.timestamp) {
426
+ meta.textContent += ` · ${msg.timestamp}`;
427
+ }
428
+ const contentContainer = createElement('div', { className: 'message-content' });
429
+ let content = msg.content;
430
+ if (Array.isArray(content)) {
431
+ content = content.map(part => typeof part === 'string' ? part : JSON.stringify(part, null, 2)).join('\\n');
432
+ }
433
+ contentContainer.textContent = content ?? '';
434
+ card.append(meta, contentContainer);
435
+ wrapper.appendChild(card);
436
+ });
437
+ return wrapper;
438
+ }
439
+
440
+ function renderNdArray(info) {
441
+ const wrapper = createElement('div');
442
+ const summary = `dtype=${info.dtype} · shape=[${info.shape.join(', ')}] · size=${info.size}`;
443
+ wrapper.appendChild(createElement('div', { text: summary }));
444
+ if (info.preview && info.preview.length) {
445
+ const preview = createElement('pre');
446
+ preview.textContent = JSON.stringify(info.preview, null, 2);
447
+ wrapper.appendChild(preview);
448
+ }
449
+ if (info.values) {
450
+ const details = document.createElement('details');
451
+ details.appendChild(createElement('summary', { text: 'Show full values' }));
452
+ const pre = createElement('pre');
453
+ pre.textContent = JSON.stringify(info.values, null, 2);
454
+ details.appendChild(pre);
455
+ wrapper.appendChild(details);
456
+ }
457
+ return wrapper;
458
+ }
459
+
460
+ function renderValue(value, key = '') {
461
+ if (value === null || typeof value === 'undefined') {
462
+ return createElement('span', { text: '—' });
463
+ }
464
+ if (typeof value !== 'object') {
465
+ return createElement('span', { text: String(value) });
466
+ }
467
+ if (Array.isArray(value)) {
468
+ if (key === 'messages') {
469
+ return renderMessages(value.map(item => typeof item === 'object' ? item : { content: String(item) }));
470
+ }
471
+ const details = document.createElement('details');
472
+ details.appendChild(createElement('summary', { text: `List [${value.length}]` }));
473
+ value.forEach((item, idx) => {
474
+ const line = createElement('div');
475
+ line.appendChild(createElement('strong', { text: `#${idx}` }));
476
+ line.appendChild(createElement('div', { className: 'kv-body' }));
477
+ line.lastChild.appendChild(renderValue(item));
478
+ details.appendChild(line);
479
+ });
480
+ return details;
481
+ }
482
+ if (value.__type__ === 'ndarray') {
483
+ return renderNdArray(value);
484
+ }
485
+ const entries = Object.entries(value);
486
+ const container = createElement('div');
487
+ entries.forEach(([childKey, childValue]) => {
488
+ const block = createElement('div');
489
+ block.appendChild(createElement('strong', { text: childKey }));
490
+ const inner = createElement('div', { className: 'kv-body' });
491
+ inner.appendChild(renderValue(childValue, childKey));
492
+ block.appendChild(inner);
493
+ container.appendChild(block);
494
+ });
495
+ return container;
496
+ }
497
+
498
+ function markActive(entry) {
499
+ document.querySelectorAll('.file-entry.active').forEach(el => el.classList.remove('active'));
500
+ entry.classList.add('active');
501
+ }
502
+
503
+ async function loadFile(path, entryEl) {
504
+ try {
505
+ activePath = path;
506
+ markActive(entryEl);
507
+ const data = await fetchJSON(`/api/file?path=${encodeURIComponent(path)}`);
508
+ renderContent(data);
509
+ } catch (error) {
510
+ console.error(error);
511
+ const panel = createElement('div', { className: 'panel' });
512
+ panel.appendChild(createElement('h2', { text: 'Failed to load file' }));
513
+ panel.appendChild(createElement('pre', { text: error.message }));
514
+ const content = document.getElementById('content');
515
+ content.innerHTML = '';
516
+ content.appendChild(panel);
517
+ }
518
+ }
519
+
520
+ function renderContent(data) {
521
+ const content = document.getElementById('content');
522
+ content.innerHTML = '';
523
+ const panel = createElement('div', { className: 'panel' });
524
+ const title = createElement('div', { className: 'section-title', text: data.relative_path || data.path });
525
+ panel.appendChild(title);
526
+ panel.appendChild(createElement('div', { text: `Entries: ${data.length}` }));
527
+
528
+ const metaSection = createElement('div', { className: 'section-title', text: 'Meta Info (global)' });
529
+ panel.appendChild(metaSection);
530
+ const metaGrid = createElement('div', { className: 'meta-grid' });
531
+ Object.entries(data.meta_info || {}).forEach(([key, value]) => {
532
+ renderKeyValue(metaGrid, key, value);
533
+ });
534
+ if (!Object.keys(data.meta_info || {}).length) {
535
+ metaGrid.appendChild(createElement('div', { className: 'placeholder', text: 'No meta info available.' }));
536
+ }
537
+ panel.appendChild(metaGrid);
538
+
539
+ const itemsSection = createElement('div', { className: 'section-title', text: 'Entries' });
540
+ panel.appendChild(itemsSection);
541
+ if (!data.items.length) {
542
+ panel.appendChild(createElement('div', { className: 'placeholder', text: 'No entries in this DataProto.' }));
543
+ }
544
+ data.items.forEach(item => {
545
+ const details = document.createElement('details');
546
+ const summary = createElement('summary', { text: `Item #${item.index}` });
547
+ details.appendChild(summary);
548
+
549
+ const metaBlock = createElement('div', { className: 'meta-grid' });
550
+ Object.entries(item.meta_info || {}).forEach(([key, value]) => {
551
+ renderKeyValue(metaBlock, key, value);
552
+ });
553
+ if (!Object.keys(item.meta_info || {}).length) {
554
+ metaBlock.appendChild(createElement('div', { className: 'placeholder', text: 'No item-level meta info.' }));
555
+ }
556
+ details.appendChild(metaBlock);
557
+
558
+ const nonTensorEntries = Object.entries(item.non_tensor_batch || {});
559
+ let messagesHandled = false;
560
+ if (nonTensorEntries.length) {
561
+ nonTensorEntries.forEach(([key, value]) => {
562
+ if (key === 'messages_list') {
563
+ const messagesSection = createElement('div', { className: 'messages-section' });
564
+ messagesSection.appendChild(createElement('div', { className: 'section-subtitle', text: 'Messages' }));
565
+ messagesSection.appendChild(renderValue(value, key));
566
+ details.appendChild(messagesSection);
567
+ messagesHandled = true;
568
+ }
569
+ });
570
+ const others = nonTensorEntries.filter(([key]) => key !== 'messages_list');
571
+ if (others.length) {
572
+ const ntBlock = createElement('div', { className: 'meta-grid' });
573
+ others.forEach(([key, value]) => {
574
+ renderKeyValue(ntBlock, key, value);
575
+ });
576
+ details.appendChild(ntBlock);
577
+ }
578
+ if (!messagesHandled && !others.length) {
579
+ details.appendChild(createElement('div', { className: 'placeholder', text: 'No non-tensor batch data.' }));
580
+ }
581
+ } else {
582
+ details.appendChild(createElement('div', { className: 'placeholder', text: 'No non-tensor batch data.' }));
583
+ }
584
+
585
+ panel.appendChild(details);
586
+ });
587
+
588
+ content.appendChild(panel);
589
+ }
590
+
591
+ async function init() {
592
+ try {
593
+ const treeData = await fetchJSON('/api/tree');
594
+ const treeRoot = document.getElementById('tree');
595
+ treeRoot.innerHTML = '';
596
+ renderTree(treeData, treeRoot);
597
+ } catch (error) {
598
+ const treeRoot = document.getElementById('tree');
599
+ treeRoot.textContent = 'Failed to load file tree.';
600
+ console.error(error);
601
+ }
602
+ }
603
+
604
+ init();
605
+ </script>
606
+ </body>
607
+ </html>
608
+ """
609
+
610
+
611
+ class VisualizerHandler(BaseHTTPRequestHandler):
612
+ explorer: RolloutExplorer
613
+
614
+ def do_GET(self) -> None: # noqa: N802 - http.server signature
615
+ parsed = urlparse(self.path)
616
+ if parsed.path == "/":
617
+ self.respond_html(HTML_PAGE)
618
+ return
619
+ if parsed.path == "/api/tree":
620
+ payload = VisualizerHandler.explorer.tree()
621
+ self.respond_json(payload)
622
+ return
623
+ if parsed.path == "/api/file":
624
+ query = parse_qs(parsed.query)
625
+ relative = query.get("path", [None])[0]
626
+ if not relative:
627
+ self.respond_json({"error": "Missing path query parameter"}, status=400)
628
+ return
629
+ try:
630
+ payload = VisualizerHandler.explorer.load_file(relative)
631
+ except FileNotFoundError:
632
+ self.respond_json({"error": "File not found"}, status=404)
633
+ return
634
+ except Exception as exc: # pragma: no cover - defensive guard
635
+ LOGGER.exception("Failed to load %s", relative)
636
+ self.respond_json({"error": str(exc)}, status=500)
637
+ return
638
+ self.respond_json(payload)
639
+ return
640
+
641
+ self.respond_json({"error": "Not found"}, status=404)
642
+
643
+ def log_message(self, format: str, *args: Any) -> None: # noqa: A003 - inherited name
644
+ LOGGER.info("%s - %s", self.address_string(), format % args)
645
+
646
+ def respond_json(self, payload: Any, status: int = 200) -> None:
647
+ body = json.dumps(payload).encode("utf-8")
648
+ self.send_response(status)
649
+ self.send_header("Content-Type", "application/json; charset=utf-8")
650
+ self.send_header("Content-Length", str(len(body)))
651
+ self.end_headers()
652
+ self.wfile.write(body)
653
+
654
+ def respond_html(self, html: str, status: int = 200) -> None:
655
+ body = html.encode("utf-8")
656
+ self.send_response(status)
657
+ self.send_header("Content-Type", "text/html; charset=utf-8")
658
+ self.send_header("Content-Length", str(len(body)))
659
+ self.end_headers()
660
+ self.wfile.write(body)
661
+
662
+
663
+ def main() -> None:
664
+ logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(message)s")
665
+ args = parse_args()
666
+ root = Path(args.rollout_path).expanduser().resolve()
667
+ if not root.exists() or not root.is_dir():
668
+ raise SystemExit(f"Rollout path {root} does not exist or is not a directory")
669
+
670
+ explorer = RolloutExplorer(root)
671
+ VisualizerHandler.explorer = explorer
672
+
673
+ server = ThreadingHTTPServer((args.host, args.port), VisualizerHandler)
674
+
675
+ address = f"http://{args.host}:{args.port}/"
676
+ print(f"Serving rollout visualizer for {root} at {address}")
677
+ if not args.no_browser:
678
+ try:
679
+ webbrowser.open(address)
680
+ except Exception as exc: # pragma: no cover - best effort
681
+ LOGGER.info("Could not open browser automatically: %s", exc)
682
+
683
+ try:
684
+ server.serve_forever()
685
+ except KeyboardInterrupt:
686
+ print("\nShutting down...")
687
+ finally:
688
+ server.server_close()
689
+
690
+
691
+ if __name__ == "__main__":
692
+ main()
tests/env/test_sokoban_render.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ from ragen.env.sokoban.config import SokobanEnvConfig
4
+ from ragen.env.sokoban.env import SokobanEnv
5
+
6
+
7
+ def test_sokoban_render_supports_grid_and_coord():
8
+ seed = 1234
9
+ grid_config = SokobanEnvConfig(
10
+ dim_room=(5, 5),
11
+ num_boxes=1,
12
+ max_steps=10,
13
+ search_depth=20,
14
+ observation_format="grid",
15
+ )
16
+ coord_config = SokobanEnvConfig(
17
+ dim_room=(5, 5),
18
+ num_boxes=1,
19
+ max_steps=10,
20
+ search_depth=20,
21
+ observation_format="coord",
22
+ )
23
+
24
+ grid_env = SokobanEnv(grid_config)
25
+ coord_env = SokobanEnv(coord_config)
26
+
27
+ try:
28
+ grid_obs = grid_env.reset(seed=seed)
29
+ coord_obs = coord_env.reset(seed=seed)
30
+
31
+ assert isinstance(grid_obs, str)
32
+ assert isinstance(coord_obs, str)
33
+
34
+ assert "Board size:" in coord_obs
35
+ assert re.search(r"Walls: \(\d+, \d+\)", coord_obs)
36
+
37
+ assert isinstance(coord_env.render(mode="grid"), str)
38
+ assert "Board size:" in grid_env.render(mode="coord")
39
+ finally:
40
+ grid_env.close()
41
+ coord_env.close()
tests/es_manager/test_seed_iteration.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from omegaconf import OmegaConf
3
+ from ragen.llm_agent.es_manager import EnvStateManager
4
+
5
+
6
+ def make_cfg():
7
+ return OmegaConf.create({
8
+ 'seed': {'train': 7},
9
+ 'es_manager': {
10
+ 'train': {
11
+ 'env_groups': 1,
12
+ 'group_size': 1,
13
+ 'env_configs': {'tags': ['Bandit'], 'n_groups': [1]},
14
+ }
15
+ },
16
+ 'custom_envs': {
17
+ 'Bandit': {
18
+ 'env_type': 'bandit',
19
+ 'max_actions_per_traj': 1,
20
+ 'env_config': None
21
+ }
22
+ }
23
+ })
24
+
25
+
26
+ def test_seed_iteration():
27
+ cfg = make_cfg()
28
+ es = EnvStateManager(cfg, mode='train')
29
+ es.reset()
30
+ first_seed = es.envs[0]['status'].seed
31
+ es.reset()
32
+ second_seed = es.envs[0]['status'].seed
33
+ assert first_seed == 7
34
+ assert second_seed == 8
tests/llm_agent/test_context_window.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ from ragen.llm_agent.ctx_manager import ContextManager
3
+ from omegaconf import OmegaConf
4
+ from verl.verl.protocol import DataProto
5
+
6
+ class DummyTokenizer:
7
+ name_or_path = "qwen" # or "llama-3" or any string your code expects
8
+
9
+ def apply_chat_template(self, messages, add_generation_prompt, tokenize):
10
+ return " ".join([msg["content"] for msg in messages])
11
+
12
+ def __call__(self, texts, return_tensors, padding, padding_side, truncation):
13
+ import torch
14
+ class DummyOutput:
15
+ input_ids = torch.tensor([[1, 2, 3]])
16
+ attention_mask = torch.tensor([[1, 1, 1]])
17
+ return DummyOutput()
18
+
19
+ def encode(self, text):
20
+ # Return a dummy list of token ids; must be at least length 1 for [0] indexing
21
+ return [42, 43]
22
+
23
+ @pytest.fixture
24
+ def dummy_config():
25
+ cfg = OmegaConf.create({
26
+ "agent_proxy": {
27
+ "max_context_window": 2,
28
+ "enable_think": False,
29
+ "use_turn_scores": False,
30
+ "action_sep": "|",
31
+ "reward_normalization": {
32
+ "grouping": "batch",
33
+ "method": "identity"
34
+ }
35
+ },
36
+ "enable_response_mask": False,
37
+ "es_manager": {
38
+ "train": {
39
+ "env_configs": {
40
+ "n_groups": [1],
41
+ "tags": ["sokoban"]
42
+ },
43
+ "group_size": 1
44
+ }
45
+ },
46
+ "custom_envs": {
47
+ "sokoban": {
48
+ "env_type": "sokoban",
49
+ "max_actions_per_traj": 10
50
+ }
51
+ },
52
+ "actor_rollout_ref": {
53
+ "rollout": {
54
+ "response_length": 128
55
+ }
56
+ }
57
+ })
58
+ return cfg
59
+
60
+ def test_context_window_truncation(dummy_config):
61
+ tokenizer = DummyTokenizer()
62
+ ctx = ContextManager(config=dummy_config, tokenizer=tokenizer, mode="train")
63
+ ctx.prefix_lookup = {0: "Initial prompt"}
64
+ ctx.env_config_lookup = {0: {"max_tokens": 128}}
65
+ ctx.env_nums = {"": 1} # For metrics
66
+
67
+ env_outputs = [{
68
+ "env_id": 0,
69
+ "group_id": 0,
70
+ "history": [
71
+ {"state": "S1", "llm_response": "R1", "reward": 0.1, "actions_left": 5},
72
+ {"state": "S2", "llm_response": "R2", "reward": 0.2, "actions_left": 4},
73
+ {"state": "S3", "llm_response": "R3", "reward": 0.3, "actions_left": 3},
74
+ ],
75
+ "metrics": {},
76
+ }]
77
+
78
+ lm_inputs: DataProto = ctx.get_lm_inputs(env_outputs, prepare_for_update=True)
79
+ messages = lm_inputs.non_tensor_batch["messages_list"][0]
80
+
81
+ # Ensure only last 2 turns are present
82
+ assert "S1" not in str(messages)
83
+ assert "S2" in str(messages)
84
+ assert "S3" in str(messages)
verl/.gemini/config.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ have_fun: false
2
+ code_review:
3
+ disable: false
4
+ comment_severity_threshold: HIGH
5
+ max_review_comments: -1
6
+ pull_request_opened:
7
+ help: false
8
+ summary: false
9
+ code_review: true
10
+ ignore_patterns: []
verl/.github/CODEOWNERS ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /docs @eric-haibin-lin @zhaochenyang20 @hongpeng-guo
2
+ /docs/amd_tutorial @yushengsu-thu
3
+ /docs/slang_multiturn @zhaochenyang20 @SwordFaith
4
+ /docs/ascend_tutorial @FightingZhen
5
+
6
+ /recipe/dapo @tongyx361 @PeterSH6 @vermouth1992 @tardis-key @FightingZhen @ji-huazhong
7
+ /recipe/spin @zhaochenyang20
8
+ /recipe/sppo @zhaochenyang20
9
+
10
+ /third_party/sglang @zhaochenyang20 @SwordFaith
11
+ /third_party/vllm @PeterSH6 @wuxibin89
12
+
13
+ /examples/grpo_trainer @vermouth1992 @PeterSH6 @tardis-key @FightingZhen @ji-huazhong
14
+
15
+ /verl/single_controller @zw0610 @wuxibin89 @hongpeng-guo
16
+ /verl/trainer @eric-haibin-lin @vermouth1992 @tongyx361 @PeterSH6
17
+ /verl/models/mcore @ISEEKYAN @vermouth1992
18
+ /verl/models/transformers @vermouth1992 @PeterSH6 @tardis-key @FightingZhen @ji-huazhong
19
+ /verl/workers/engine @eric-haibin-lin @vermouth1992 @ZihengJiang
20
+ /verl/workers/roles @eric-haibin-lin @vermouth1992 @ZihengJiang
21
+ /verl/workers/engine/fsdp @eric-haibin-lin @vermouth1992 @ZihengJiang
22
+ /verl/workers/rollout/vllm_rollout @wuxibin89 @PeterSH6 @chenhaiq
23
+ /verl/workers/rollout/sglang_rollout @zhaochenyang20 @SwordFaith @chenhaiq
24
+ /verl/workers/actor/megatron_actor.py @ISEEKYAN @vermouth1992
25
+ /verl/workers/critic/megatron_critic.py @ISEEKYAN @vermouth1992
26
+ /verl/workers/megatron_workers.py @ISEEKYAN @vermouth1992
27
+
28
+ /tests/single_controller @zw0610 @wuxibin89
29
+ /tests/trainer @eric-haibin-lin @vermouth1992 @tongyx361 @PeterSH6
30
+ /tests/workers/rollout/vllm_rollout @wuxibin89 @PeterSH6 @chenhaiq
verl/.github/ISSUE_TEMPLATE/bug-report.yml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # modified from https://github.com/huggingface/transformers/blob/main/.github/ISSUE_TEMPLATE/bug-report.yml?plain=1
2
+ name: "\U0001F41B Bug Report"
3
+ description: Submit a bug report to help us improve verl
4
+ labels: [ "bug" ]
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: |
9
+ Thanks for taking the time to fill out this bug report! 🤗
10
+
11
+ - type: textarea
12
+ id: system-info
13
+ attributes:
14
+ label: System Info
15
+ description: Please share your system info with us. You can run the command `python scripts/diagnose.py` and copy-paste its output below.
16
+ placeholder: verl version, platform, python version, ...
17
+ validations:
18
+ required: true
19
+
20
+ - type: checkboxes
21
+ id: information-scripts-examples
22
+ attributes:
23
+ label: Information
24
+ description: 'The problem arises when using:'
25
+ options:
26
+ - label: "The official example scripts"
27
+ - label: "My own modified scripts"
28
+
29
+ - type: checkboxes
30
+ id: information-tasks
31
+ attributes:
32
+ label: Tasks
33
+ description: "The tasks I am working on are:"
34
+ options:
35
+ - label: "An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)"
36
+ - label: "My own task or dataset (give details below)"
37
+
38
+ - type: textarea
39
+ id: reproduction
40
+ validations:
41
+ required: true
42
+ attributes:
43
+ label: Reproduction
44
+ description: |
45
+ Please provide a code sample that reproduces the problem you ran into. It can be a Colab link or just a code snippet.
46
+ Please include relevant config information with your code.
47
+ If you have code snippets, error messages, stack traces please provide them here as well.
48
+ Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
49
+ Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.
50
+
51
+ placeholder: |
52
+ Steps to reproduce the behavior:
53
+
54
+ 1.
55
+ 2.
56
+ 3.
57
+
58
+
59
+ - type: textarea
60
+ id: expected-behavior
61
+ validations:
62
+ required: true
63
+ attributes:
64
+ label: Expected behavior
65
+ description: "A clear and concise description of what you would expect to happen."
verl/.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ blank_issues_enabled: true
2
+ version: 0.1
verl/.github/ISSUE_TEMPLATE/feature-request.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # modified from https://github.com/huggingface/transformers/blob/main/.github/ISSUE_TEMPLATE/feature-request.yml?plain=1
2
+ name: "\U0001F680 Feature request"
3
+ description: Submit a proposal/request for a new verl feature
4
+ labels: [ "Feature request" ]
5
+ body:
6
+ - type: textarea
7
+ id: feature-request
8
+ validations:
9
+ required: true
10
+ attributes:
11
+ label: Feature request
12
+ description: |
13
+ A clear and concise description of the feature proposal. Please provide a link to the paper and code in case they exist.
14
+
15
+ - type: textarea
16
+ id: motivation
17
+ validations:
18
+ required: true
19
+ attributes:
20
+ label: Motivation
21
+ description: |
22
+ Please outline the motivation for the proposal. Is your feature request related to a problem? e.g., I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too.
23
+
24
+
25
+ - type: textarea
26
+ id: contribution
27
+ validations:
28
+ required: true
29
+ attributes:
30
+ label: Your contribution
31
+ description: |
32
+ Is there any way that you could help, e.g. by submitting a PR? Make sure to read the CONTRIBUTING.MD [readme](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md)
verl/.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### What does this PR do?
2
+
3
+ > Add **concise** overview of what this PR aims to achieve or accomplish. Reference related GitHub issues and PRs that help with the review.
4
+
5
+ ### Checklist Before Starting
6
+
7
+ - [ ] Search for similar PRs. Paste at least one query link here: ...
8
+ - [ ] Format the PR title as `[{modules}] {type}: {description}` (This will be checked by the CI)
9
+ - `{modules}` include `fsdp`, `megatron`, `sglang`, `vllm`, `rollout`, `trainer`, `ci`, `training_utils`, `recipe`, `hardware`, `deployment`, `ray`, `worker`, `single_controller`, `misc`, `perf`, `model`, `algo`, `env`, `tool`, `ckpt`, `doc`, `data`
10
+ - If this PR involves multiple modules, separate them with `,` like `[megatron, fsdp, doc]`
11
+ - `{type}` is in `feat`, `fix`, `refactor`, `chore`, `test`
12
+ - If this PR breaks any API (CLI arguments, config, function signature, etc.), add `[BREAKING]` to the beginning of the title.
13
+ - Example: `[BREAKING][fsdp, megatron] feat: dynamic batching`
14
+
15
+ ### Test
16
+
17
+ > For changes that can not be tested by CI (e.g., algorithm implementation, new model support), validate by experiment(s) and show results like training curve plots, evaluation results, etc.
18
+
19
+ ### API and Usage Example
20
+
21
+ > Demonstrate how the API changes if any, and provide usage example(s) if possible.
22
+
23
+ ```python
24
+ # Add code snippet or script demonstrating how to use this
25
+ ```
26
+
27
+ ### Design & Code Changes
28
+
29
+ > Demonstrate the high-level design if this PR is complex, and list the specific changes.
30
+
31
+ ### Checklist Before Submitting
32
+
33
+ > [!IMPORTANT]
34
+ > Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
35
+
36
+ - [ ] Read the [Contribute Guide](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md).
37
+ - [ ] Apply [pre-commit checks](https://github.com/volcengine/verl/blob/main/CONTRIBUTING.md#code-linting-and-formatting): `pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=always`
38
+ - [ ] Add / Update [the documentation](https://github.com/volcengine/verl/tree/main/docs).
39
+ - [ ] Add unit or end-to-end test(s) to [the CI workflow](https://github.com/volcengine/verl/tree/main/.github/workflows) to cover all the code. If not feasible, explain why: ...
40
+ - [ ] Once your PR is ready for CI, send a message in [the `ci-request` channel](https://verl-project.slack.com/archives/C091TCESWB1) in [the `verl` Slack workspace](https://join.slack.com/t/verl-project/shared_invite/zt-3855yhg8g-CTkqXu~hKojPCmo7k_yXTQ). (If not accessible, please try [the Feishu group (飞书群)](https://applink.larkoffice.com/client/chat/chatter/add_by_link?link_token=772jd4f1-cd91-441e-a820-498c6614126a).)
verl/.github/dependabot.yml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ## Enabled the dependabot to check the dependencies of the project
2
+ ## Dependabot will open pull requests to update dependencies automatically
3
+
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: pip
7
+ directory: "/"
8
+ schedule:
9
+ interval: weekly
verl/.github/workflows/.deprecate/e2e_eval_aime24.yml ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # # Tests layout
2
+
3
+ # Each folder under tests/ corresponds to a test category for a sub-namespace in verl. For instance:
4
+ # - `tests/trainer` for testing functionality related to `verl/trainer`
5
+ # - `tests/models` for testing functionality related to `verl/models`
6
+ # - ...
7
+
8
+ # There are a few folders with `special_` prefix, created for special purposes:
9
+ # - `special_distributed`: unit tests that must run with multiple GPUs
10
+ # - `special_e2e`: end-to-end tests with training/generation scripts
11
+ # - `special_npu`: tests for NPUs
12
+ # - `special_sanity`: a suite of quick sanity tests
13
+ # - `special_standalone`: a set of test that are designed to run in dedicated environments
14
+
15
+ # Accelerators for tests
16
+ # - By default tests are run with GPU available, except for the ones under `special_npu`, and any test script whose name ends with `on_cpu.py`.
17
+ # - For test scripts with `on_cpu.py` name suffix would be tested on CPU resources in linux environment.
18
+
19
+ # # Workflow layout
20
+
21
+ # All CI tests are configured by yaml files in `.github/workflows/`. Here's an overview of all test configs:
22
+ # 1. A list of always triggered CPU sanity tests: `check-pr-title.yml`, `secrets_scan.yml`, `check-pr-title,yml`, `pre-commit.yml`, `doc.yml`
23
+ # 2. Some heavy multi-GPU unit tests, such as `model.yml`, `vllm.yml`, `sgl.yml`
24
+ # 3. End-to-end tests: `e2e_*.yml`
25
+ # 4. Unit tests
26
+ # - `cpu_unit_tests.yml`, run pytest on all scripts with file name pattern `tests/**/test_*_on_cpu.py`
27
+ # - `gpu_unit_tests.yml`, run pytest on all scripts with file without the `on_cpu.py` suffix.
28
+ # - Since cpu/gpu unit tests by default runs all tests under `tests`, please make sure tests are manually excluded in them when
29
+ # - new workflow yaml is added to `.github/workflows`
30
+ # - new tests are added to workflow mentioned in 2.
31
+
32
+
33
+ name: e2e_eval_aime24
34
+
35
+ on:
36
+ # Trigger the workflow on push or pull request,
37
+ # but only for the main branch
38
+ # For push, for now only anti-patterns are specified so it is more conservative
39
+ # and achieves higher coverage.
40
+ push:
41
+ branches:
42
+ - main
43
+ - v0.*
44
+ paths:
45
+ - "**/*.py"
46
+ # Other entrypoints
47
+ - "!*.md"
48
+ - "!docker/**"
49
+ - "!docs/**"
50
+ - "!examples/**"
51
+ - "!tests/**"
52
+ - "!verl/trainer/main_*.py"
53
+ - "!verl/trainer/fsdp_sft_trainer.py"
54
+ - "!recipe/**"
55
+ - "recipe/r1"
56
+ - "!recipe/r1/README.md"
57
+ pull_request:
58
+ branches:
59
+ - main
60
+ paths:
61
+ - "**/*.py"
62
+ # Other entrypoints
63
+ - "!*.md"
64
+ - "!docker/**"
65
+ - "!docs/**"
66
+ - "!examples/**"
67
+ - "!tests/**"
68
+ - "!verl/trainer/main_*.py"
69
+ - "!verl/trainer/fsdp_sft_trainer.py"
70
+ # Home
71
+ - "recipe/r1"
72
+ - "!recipe/r1/README.md"
73
+ # Other recipes
74
+ - "!recipe/**"
75
+ # Entrypoints
76
+ - ".github/workflows/e2e_eval_aime24.yml"
77
+ - "tests/special_e2e/run_r1_distill_qwen_aime24_eval.sh"
78
+ - "verl/trainer/main_generation.py"
79
+ - "verl/trainer/config/generation.yaml"
80
+
81
+ # Cancel jobs on the same ref if a new one is triggered
82
+ concurrency:
83
+ group: ${{ github.workflow }}-${{ github.ref }}
84
+ cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
85
+
86
+ # Declare permissions just read content.
87
+ permissions:
88
+ contents: read
89
+
90
+ env:
91
+ IMAGE: "verl-ci-cn-beijing.cr.volces.com/verlai/verl:app-verl0.5-transformers4.55.4-vllm0.10.0-mcore0.13.0-te2.2"
92
+ DYNAMIC_RUNNER_ENDPOINT: "https://sd10g3clalm04ug7alq90.apigateway-cn-beijing.volceapi.com/runner"
93
+
94
+ jobs:
95
+ setup:
96
+ if: github.repository_owner == 'volcengine'
97
+ runs-on: ubuntu-latest
98
+ outputs:
99
+ runner-label: ${{ steps.create-runner.outputs.runner-label }}
100
+ mlp-task-id: ${{ steps.create-runner.outputs.mlp-task-id }}
101
+ steps:
102
+ - uses: actions/checkout@v4
103
+ - id: create-runner
104
+ uses: volcengine/vemlp-github-runner@v1
105
+ with:
106
+ mode: "create"
107
+ faas-url: "${{ env.DYNAMIC_RUNNER_ENDPOINT }}"
108
+ mlp-image: "${{ env.IMAGE }}"
109
+
110
+ e2e_eval_aime24:
111
+ needs: setup
112
+ runs-on: ["${{ needs.setup.outputs.runner-label || 'L20x8' }}"]
113
+ timeout-minutes: 40 # Increase this timeout value as needed
114
+ env:
115
+ HTTP_PROXY: ${{ secrets.PROXY_HTTP }}
116
+ HTTPS_PROXY: ${{ secrets.PROXY_HTTPS }}
117
+ NO_PROXY: "localhost,127.0.0.1,hf-mirror.com"
118
+ HF_ENDPOINT: "https://hf-mirror.com"
119
+ HF_HUB_ENABLE_HF_TRANSFER: "0" # This is more stable
120
+ steps:
121
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
122
+ with:
123
+ fetch-depth: 0
124
+ - name: Install the current repository
125
+ run: |
126
+ pip3 install --no-deps -e .[test,gpu,math]
127
+ pip3 install math-verify transformers==4.56.2
128
+ - name: Prepare aime24 dataset
129
+ run: |
130
+ ray stop --force
131
+ python3 recipe/r1/data_process.py --task aime2024
132
+ - name: Running generation and evaluation in AIME 2024
133
+ run: |
134
+ ray stop --force
135
+ bash tests/special_e2e/run_r1_distill_qwen_aime24_eval.sh
136
+
137
+ cleanup:
138
+ runs-on: ubuntu-latest
139
+ needs: [setup, e2e_eval_aime24]
140
+ if: always()
141
+ steps:
142
+ - id: destroy-runner
143
+ uses: volcengine/vemlp-github-runner@v1
144
+ with:
145
+ mode: "destroy"
146
+ faas-url: "${{ env.DYNAMIC_RUNNER_ENDPOINT }}"
147
+ mlp-task-id: "${{ needs.setup.outputs.mlp-task-id }}"