Navigam commited on
Commit
6e2b9c3
·
1 Parent(s): 78c259c

feat: update evaluation results and training scripts for Qwen2.5-7B-Instruct

Browse files

Updated evaluation metrics and added new JSONL files for the Qwen2.5-7B-Instruct model, including detailed task performance data. Enhanced training scripts to reflect changes in output paths and parameters, improving the training process for GRPO and SFT. Updated visualizations and metadata to ensure comprehensive tracking of model performance across various tasks.

results/invalid_action_rate.png CHANGED

Git LFS Details

  • SHA256: 1ee2e6de45d10a797d32b08ce00d30382b3b664d639f7a25c5279f912b2d7e0d
  • Pointer size: 130 Bytes
  • Size of remote file: 54.2 kB

Git LFS Details

  • SHA256: e587ac15c80acf04caa02f1a6937b9abf697cc41804e97a9eb60c49e9ba9a903
  • Pointer size: 130 Bytes
  • Size of remote file: 73.4 kB
results/model_comparison.png CHANGED

Git LFS Details

  • SHA256: 362f759890867432df05a7995a0e0eaa2f18369b4e71f7bd476d2eb55dc7b21c
  • Pointer size: 130 Bytes
  • Size of remote file: 52.8 kB

Git LFS Details

  • SHA256: 5ffd1c027aa5ae8b611ab5575673114e93c2bba8dcca591ed07ced2f0f94982b
  • Pointer size: 130 Bytes
  • Size of remote file: 72.5 kB
results/reward_curve.png CHANGED

Git LFS Details

  • SHA256: c980cbae417a6504471e124c444ffed8eec828a7a89dc71c2e103bb5a4dd3eeb
  • Pointer size: 131 Bytes
  • Size of remote file: 145 kB

Git LFS Details

  • SHA256: 69741534339cc5c14b1ef665d8ade27f8147bc65f5e784ec337c843e10fa4c72
  • Pointer size: 131 Bytes
  • Size of remote file: 115 kB
results/runs/Qwen2.5-7B-Instruct__base-qwen2.5-7b/base-qwen2.5-7b_eval.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {"task_id": "e1_launch_readiness", "policy_kind": "model", "steps": 3, "total_reward": 1.39, "terminal_reward": 0.91, "reward_trace": [0.29000000000000004, 0.19, 0.9099999999999999], "verifier_pass_rate": 1.0, "passed_checks": ["qa_report_present", "final_rec_valid", "no_missed_milestones"], "failed_checks": [], "milestones_total": 2, "milestones_complete": 2, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 4, "success": true, "episode_index": 0, "model_stage": "base-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": ""}
2
+ {"task_id": "m1_budget_reallocation", "policy_kind": "model", "steps": 6, "total_reward": 2.056667, "terminal_reward": 0.806667, "reward_trace": [0.09000000000000001, 0.29000000000000004, 0.19, 0.39, 0.29000000000000004, 0.8066666666666666], "verifier_pass_rate": 0.666667, "passed_checks": ["required_agents_consulted", "conflict_logged", "conflict_resolved", "phased_plan"], "failed_checks": ["budget_constraint_acknowledged", "reasoning_documented"], "milestones_total": 3, "milestones_complete": 3, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 7, "success": false, "episode_index": 0, "model_stage": "base-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": ""}
3
+ {"task_id": "h1_acquisition_defence", "policy_kind": "model", "steps": 8, "total_reward": 2.283333, "terminal_reward": 0.753333, "reward_trace": [0.09000000000000001, 0.09000000000000001, 0.29000000000000004, 0.19, 0.39, 0.29000000000000004, 0.19, 0.7533333333333332], "verifier_pass_rate": 0.666667, "passed_checks": ["all_agents_consulted", "conflict_explicitly_resolved", "resolution_has_type", "counter_offer_present", "deadline_present", "retention_addressed", "no_single_agent_copied", "swd_version_rich"], "failed_checks": ["multi_conflict_logged", "rich_reasoning_log", "timeline_constraint_acknowledged", "all_phases_reached"], "milestones_total": 5, "milestones_complete": 3, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 9, "success": false, "episode_index": 0, "model_stage": "base-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": ""}
results/runs/Qwen2.5-7B-Instruct__base-qwen2.5-7b/metadata.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_stage": "base-qwen2.5-7b",
3
+ "policy": "hf",
4
+ "model": "Qwen/Qwen2.5-7B-Instruct",
5
+ "adapter": "",
6
+ "tasks": [
7
+ "e1_launch_readiness",
8
+ "m1_budget_reallocation",
9
+ "h1_acquisition_defence"
10
+ ],
11
+ "episodes": 1,
12
+ "max_steps": 30,
13
+ "max_new_tokens": 1536,
14
+ "eval_file": "results/runs/Qwen2.5-7B-Instruct__base-qwen2.5-7b/base-qwen2.5-7b_eval.jsonl",
15
+ "metrics_by_task": {
16
+ "e1_launch_readiness": {
17
+ "avg_terminal_reward": 0.91,
18
+ "avg_verifier_pass_rate": 1.0,
19
+ "success_rate": 1.0
20
+ },
21
+ "m1_budget_reallocation": {
22
+ "avg_terminal_reward": 0.806667,
23
+ "avg_verifier_pass_rate": 0.666667,
24
+ "success_rate": 0.0
25
+ },
26
+ "h1_acquisition_defence": {
27
+ "avg_terminal_reward": 0.753333,
28
+ "avg_verifier_pass_rate": 0.666667,
29
+ "success_rate": 0.0
30
+ }
31
+ }
32
+ }
results/runs/Qwen2.5-7B-Instruct__grpo_Qwen2.5-7B-Instruct__grpo-qwen2.5-7b/grpo-qwen2.5-7b_eval.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {"task_id": "e1_launch_readiness", "policy_kind": "model", "steps": 4, "total_reward": 1.58, "terminal_reward": 0.91, "reward_trace": [0.29000000000000004, 0.19, 0.19, 0.9099999999999999], "verifier_pass_rate": 1.0, "passed_checks": ["qa_report_present", "final_rec_valid", "no_missed_milestones"], "failed_checks": [], "milestones_total": 2, "milestones_complete": 2, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 5, "success": true, "episode_index": 0, "model_stage": "grpo-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": "outputs/grpo_Qwen2.5-7B-Instruct"}
2
+ {"task_id": "m1_budget_reallocation", "policy_kind": "model", "steps": 5, "total_reward": 1.508333, "terminal_reward": 0.548333, "reward_trace": [0.09000000000000001, 0.29000000000000004, 0.19, 0.39, 0.5483333333333333], "verifier_pass_rate": 0.5, "passed_checks": ["required_agents_consulted", "conflict_logged", "conflict_resolved"], "failed_checks": ["phased_plan", "budget_constraint_acknowledged", "reasoning_documented"], "milestones_total": 3, "milestones_complete": 2, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 6, "success": false, "episode_index": 0, "model_stage": "grpo-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": "outputs/grpo_Qwen2.5-7B-Instruct"}
3
+ {"task_id": "h1_acquisition_defence", "policy_kind": "model", "steps": 60, "total_reward": 1.54, "terminal_reward": -0.01, "reward_trace": [0.09000000000000001, 0.09000000000000001, 0.29000000000000004, 0.19, 0.19, 0.39, 0.29000000000000004, -0.03, -0.03, -0.03, 0.19, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, 0.19, 0.19, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01, -0.01], "verifier_pass_rate": 0.416667, "passed_checks": ["all_agents_consulted", "conflict_explicitly_resolved", "resolution_has_type", "no_single_agent_copied", "swd_version_rich"], "failed_checks": ["multi_conflict_logged", "rich_reasoning_log", "counter_offer_present", "deadline_present", "retention_addressed", "timeline_constraint_acknowledged", "all_phases_reached"], "milestones_total": 5, "milestones_complete": 2, "milestones_missed": 3, "invalid_action_count": 47, "env_error_count": 47, "errors": ["invalid_action: 1 validation error for CorpAction\nreward\n Extra inputs are not permitted [type=extra_forbidden, input_value=0.39, input_type=float]\n For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden", "invalid_action: 1 validation error for CorpAction\nreward\n Extra inputs are not permitted [type=extra_forbidden, input_value=0.39, input_type=float]\n For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden", "invalid_action: 1 validation error for CorpAction\nreward\n Extra inputs are not permitted [type=extra_forbidden, input_value=0.39, input_type=float]\n For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)", "invalid_action: Expecting ',' delimiter: line 1 column 78 (char 77)"], "final_swd_version": 14, "success": false, "episode_index": 0, "model_stage": "grpo-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": "outputs/grpo_Qwen2.5-7B-Instruct"}
results/runs/Qwen2.5-7B-Instruct__grpo_Qwen2.5-7B-Instruct__grpo-qwen2.5-7b/metadata.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_stage": "grpo-qwen2.5-7b",
3
+ "policy": "hf",
4
+ "model": "Qwen/Qwen2.5-7B-Instruct",
5
+ "adapter": "outputs/grpo_Qwen2.5-7B-Instruct",
6
+ "tasks": [
7
+ "e1_launch_readiness",
8
+ "m1_budget_reallocation",
9
+ "h1_acquisition_defence"
10
+ ],
11
+ "episodes": 1,
12
+ "max_steps": 30,
13
+ "max_new_tokens": 1536,
14
+ "eval_file": "results/runs/Qwen2.5-7B-Instruct__grpo_Qwen2.5-7B-Instruct__grpo-qwen2.5-7b/grpo-qwen2.5-7b_eval.jsonl",
15
+ "metrics_by_task": {
16
+ "e1_launch_readiness": {
17
+ "avg_terminal_reward": 0.91,
18
+ "avg_verifier_pass_rate": 1.0,
19
+ "success_rate": 1.0
20
+ },
21
+ "m1_budget_reallocation": {
22
+ "avg_terminal_reward": 0.548333,
23
+ "avg_verifier_pass_rate": 0.5,
24
+ "success_rate": 0.0
25
+ },
26
+ "h1_acquisition_defence": {
27
+ "avg_terminal_reward": -0.01,
28
+ "avg_verifier_pass_rate": 0.416667,
29
+ "success_rate": 0.0
30
+ }
31
+ }
32
+ }
results/runs/Qwen2.5-7B-Instruct__sft_Qwen2.5-7B-Instruct__sft-qwen2.5-7b/metadata.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_stage": "sft-qwen2.5-7b",
3
+ "policy": "hf",
4
+ "model": "Qwen/Qwen2.5-7B-Instruct",
5
+ "adapter": "outputs/sft_Qwen2.5-7B-Instruct",
6
+ "tasks": [
7
+ "e1_launch_readiness",
8
+ "m1_budget_reallocation",
9
+ "h1_acquisition_defence"
10
+ ],
11
+ "episodes": 1,
12
+ "max_steps": 30,
13
+ "max_new_tokens": 1536,
14
+ "eval_file": "results/runs/Qwen2.5-7B-Instruct__sft_Qwen2.5-7B-Instruct__sft-qwen2.5-7b/sft-qwen2.5-7b_eval.jsonl",
15
+ "metrics_by_task": {
16
+ "e1_launch_readiness": {
17
+ "avg_terminal_reward": 0.91,
18
+ "avg_verifier_pass_rate": 1.0,
19
+ "success_rate": 1.0
20
+ },
21
+ "m1_budget_reallocation": {
22
+ "avg_terminal_reward": 0.943333,
23
+ "avg_verifier_pass_rate": 1.0,
24
+ "success_rate": 1.0
25
+ },
26
+ "h1_acquisition_defence": {
27
+ "avg_terminal_reward": 0.515,
28
+ "avg_verifier_pass_rate": 0.5,
29
+ "success_rate": 0.0
30
+ }
31
+ }
32
+ }
results/runs/Qwen2.5-7B-Instruct__sft_Qwen2.5-7B-Instruct__sft-qwen2.5-7b/sft-qwen2.5-7b_eval.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {"task_id": "e1_launch_readiness", "policy_kind": "model", "steps": 4, "total_reward": 1.58, "terminal_reward": 0.91, "reward_trace": [0.29000000000000004, 0.19, 0.19, 0.9099999999999999], "verifier_pass_rate": 1.0, "passed_checks": ["qa_report_present", "final_rec_valid", "no_missed_milestones"], "failed_checks": [], "milestones_total": 2, "milestones_complete": 2, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 5, "success": true, "episode_index": 0, "model_stage": "sft-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": "outputs/sft_Qwen2.5-7B-Instruct"}
2
+ {"task_id": "m1_budget_reallocation", "policy_kind": "model", "steps": 6, "total_reward": 2.093333, "terminal_reward": 0.943333, "reward_trace": [0.09000000000000001, 0.29000000000000004, 0.19, 0.19, 0.39, 0.9433333333333334], "verifier_pass_rate": 1.0, "passed_checks": ["required_agents_consulted", "conflict_logged", "conflict_resolved", "phased_plan", "budget_constraint_acknowledged", "reasoning_documented"], "failed_checks": [], "milestones_total": 3, "milestones_complete": 3, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 7, "success": true, "episode_index": 0, "model_stage": "sft-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": "outputs/sft_Qwen2.5-7B-Instruct"}
3
+ {"task_id": "h1_acquisition_defence", "policy_kind": "model", "steps": 15, "total_reward": 2.915, "terminal_reward": 0.515, "reward_trace": [0.09000000000000001, 0.09000000000000001, 0.29000000000000004, 0.19, 0.19, 0.39, 0.29000000000000004, -0.03, -0.03, -0.03, 0.39, 0.19, 0.19, 0.19, 0.515], "verifier_pass_rate": 0.5, "passed_checks": ["all_agents_consulted", "multi_conflict_logged", "conflict_explicitly_resolved", "resolution_has_type", "no_single_agent_copied", "swd_version_rich"], "failed_checks": ["rich_reasoning_log", "counter_offer_present", "deadline_present", "retention_addressed", "timeline_constraint_acknowledged", "all_phases_reached"], "milestones_total": 5, "milestones_complete": 3, "milestones_missed": 0, "invalid_action_count": 0, "env_error_count": 0, "errors": [], "final_swd_version": 16, "success": false, "episode_index": 0, "model_stage": "sft-qwen2.5-7b", "policy": "hf", "model": "Qwen/Qwen2.5-7B-Instruct", "adapter": "outputs/sft_Qwen2.5-7B-Instruct"}
results/success_by_task.png CHANGED

Git LFS Details

  • SHA256: 42f02290c7517c43dd544f0607f202ca38028cfa78669e856808144e326ac5f1
  • Pointer size: 130 Bytes
  • Size of remote file: 50 kB

Git LFS Details

  • SHA256: 0075e0047e8ed0d06a71b63f7af8c1a18568c84efc7fa6a54e457eaa63b1c460
  • Pointer size: 130 Bytes
  • Size of remote file: 70 kB
training/train_grpo.py CHANGED
@@ -10,14 +10,26 @@ Run on Colab, Lightning AI H100, or another GPU machine after SFT:
10
 
11
  python training/train_grpo.py \
12
  --model Qwen/Qwen2.5-7B-Instruct \
13
- --adapter outputs/sft_adapter \
14
  --examples data/processed/e1_m1_clean.jsonl \
15
- --output outputs/grpo_adapter \
16
- --max-steps 30
 
17
 
18
  The reward function recreates the environment state from a verified action prefix,
19
  applies the sampled next action, and returns the real environment reward plus
20
  penalties for invalid JSON/actions.
 
 
 
 
 
 
 
 
 
 
 
21
  """
22
 
23
  from __future__ import annotations
@@ -144,18 +156,39 @@ def environment_reward(
144
  def main() -> None:
145
  parser = argparse.ArgumentParser(description="Train CORP-ENV GRPO adapter.")
146
  parser.add_argument("--model", default="Qwen/Qwen2.5-7B-Instruct")
147
- parser.add_argument("--adapter", default="outputs/sft_adapter")
148
  parser.add_argument("--examples", default="data/processed/e1_m1_clean.jsonl")
149
- parser.add_argument("--output", default="outputs/grpo_adapter")
150
  parser.add_argument("--tasks", default="e1_launch_readiness,m1_budget_reallocation")
151
- parser.add_argument("--repeats", type=int, default=128)
 
 
 
 
 
152
  parser.add_argument("--max-prompt-length", type=int, default=8192)
153
  parser.add_argument("--max-completion-length", type=int, default=1024)
154
  parser.add_argument("--lr", type=float, default=5e-6)
155
  parser.add_argument("--batch-size", type=int, default=1)
156
  parser.add_argument("--grad-accum", type=int, default=8)
157
- parser.add_argument("--generations", type=int, default=4)
158
- parser.add_argument("--max-steps", type=int, default=150)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  parser.add_argument("--optim", default="adamw_8bit")
160
  parser.add_argument("--push-to-hub", default="")
161
  args = parser.parse_args()
@@ -164,10 +197,10 @@ def main() -> None:
164
  os.environ.setdefault("CORP_DISABLE_LLM_JUDGE", "1")
165
 
166
  try:
 
167
  from datasets import Dataset
168
  from peft import PeftModel
169
  from trl import GRPOConfig, GRPOTrainer
170
- from unsloth import FastLanguageModel, PatchFastRL
171
  except ImportError as exc:
172
  raise SystemExit(
173
  "GRPO training requires unsloth, trl, datasets, and peft. On Lightning AI, install with:\n"
@@ -186,6 +219,15 @@ def main() -> None:
186
  dtype=None,
187
  load_in_4bit=True,
188
  )
 
 
 
 
 
 
 
 
 
189
  if args.adapter:
190
  model = PeftModel.from_pretrained(model, args.adapter, is_trainable=True)
191
  else:
@@ -210,7 +252,7 @@ def main() -> None:
210
  max_completion_length=args.max_completion_length,
211
  max_steps=args.max_steps,
212
  logging_steps=5,
213
- save_steps=25,
214
  save_total_limit=3,
215
  optim=args.optim,
216
  bf16=True,
 
10
 
11
  python training/train_grpo.py \
12
  --model Qwen/Qwen2.5-7B-Instruct \
13
+ --adapter outputs/sft_Qwen2.5-7B-Instruct \
14
  --examples data/processed/e1_m1_clean.jsonl \
15
+ --output outputs/grpo_Qwen2.5-7B-Instruct \
16
+ --max-steps 50 \
17
+ --push-to-hub your-org/corp-gym-grpo-qwen2.5-7b
18
 
19
  The reward function recreates the environment state from a verified action prefix,
20
  applies the sampled next action, and returns the real environment reward plus
21
  penalties for invalid JSON/actions.
22
+
23
+ Optional speedups (Unsloth picks these up automatically when importable):
24
+
25
+ - **Flash Attention 2** (`flash_attn`): largest win for long contexts / GRPO rollouts.
26
+ Install a wheel matching your **exact** `torch` and CUDA build, or compile with
27
+ `CUDA_HOME` pointing at the **same** CUDA version PyTorch was built for (check
28
+ `python -c "import torch; print(torch.version.cuda)"`). Mismatch (e.g. nvcc 13.0
29
+ vs torch cu128) breaks the build; fix the toolkit or use an image with FA2 preinstalled.
30
+ - **xFormers**: already used as a fallback when FA2 is missing; still slower than FA2.
31
+ - **Qwen3.x “linear attention” fast path**: only for those architectures; not used for
32
+ Qwen2.5 GRPO. See Unsloth logs if you train Qwen3.5+.
33
  """
34
 
35
  from __future__ import annotations
 
156
  def main() -> None:
157
  parser = argparse.ArgumentParser(description="Train CORP-ENV GRPO adapter.")
158
  parser.add_argument("--model", default="Qwen/Qwen2.5-7B-Instruct")
159
+ parser.add_argument("--adapter", default="outputs/sft_Qwen2.5-7B-Instruct")
160
  parser.add_argument("--examples", default="data/processed/e1_m1_clean.jsonl")
161
+ parser.add_argument("--output", default="outputs/grpo_Qwen2.5-7B-Instruct")
162
  parser.add_argument("--tasks", default="e1_launch_readiness,m1_budget_reallocation")
163
+ parser.add_argument(
164
+ "--repeats",
165
+ type=int,
166
+ default=32,
167
+ help="When --examples is missing/empty, build this many synthetic oracle prefixes per task. Ignored if the JSONL yields rows.",
168
+ )
169
  parser.add_argument("--max-prompt-length", type=int, default=8192)
170
  parser.add_argument("--max-completion-length", type=int, default=1024)
171
  parser.add_argument("--lr", type=float, default=5e-6)
172
  parser.add_argument("--batch-size", type=int, default=1)
173
  parser.add_argument("--grad-accum", type=int, default=8)
174
+ parser.add_argument(
175
+ "--generations",
176
+ type=int,
177
+ default=2,
178
+ help="GRPO samples per prompt per step. Lower = faster steps, noisier gradients (try 2 for quick runs, 4 for fuller RL).",
179
+ )
180
+ parser.add_argument(
181
+ "--max-steps",
182
+ type=int,
183
+ default=50,
184
+ help="Optimizer steps (not env episodes). Lower finishes sooner; raise for stronger fit.",
185
+ )
186
+ parser.add_argument(
187
+ "--save-steps",
188
+ type=int,
189
+ default=None,
190
+ help="Checkpoint every N steps. Default: min(25, max(5, max_steps//2)) so short runs still save.",
191
+ )
192
  parser.add_argument("--optim", default="adamw_8bit")
193
  parser.add_argument("--push-to-hub", default="")
194
  args = parser.parse_args()
 
197
  os.environ.setdefault("CORP_DISABLE_LLM_JUDGE", "1")
198
 
199
  try:
200
+ from unsloth import FastLanguageModel, PatchFastRL
201
  from datasets import Dataset
202
  from peft import PeftModel
203
  from trl import GRPOConfig, GRPOTrainer
 
204
  except ImportError as exc:
205
  raise SystemExit(
206
  "GRPO training requires unsloth, trl, datasets, and peft. On Lightning AI, install with:\n"
 
219
  dtype=None,
220
  load_in_4bit=True,
221
  )
222
+ if getattr(tokenizer, "pad_token", None) is None and getattr(
223
+ tokenizer, "eos_token", None
224
+ ) is not None:
225
+ tokenizer.pad_token = tokenizer.eos_token
226
+
227
+ save_steps = args.save_steps
228
+ if save_steps is None:
229
+ save_steps = min(25, max(5, args.max_steps // 2))
230
+
231
  if args.adapter:
232
  model = PeftModel.from_pretrained(model, args.adapter, is_trainable=True)
233
  else:
 
252
  max_completion_length=args.max_completion_length,
253
  max_steps=args.max_steps,
254
  logging_steps=5,
255
+ save_steps=save_steps,
256
  save_total_limit=3,
257
  optim=args.optim,
258
  bf16=True,