Add long-rl-20261014-v5_looped-ei_s0
Browse files- .gitattributes +1 -0
- runs/long-rl-20261014-v5_looped-ei_s0/eval_dev.jsonl +0 -0
- runs/long-rl-20261014-v5_looped-ei_s0/eval_dev_diag.jsonl +0 -0
- runs/long-rl-20261014-v5_looped-ei_s0/eval_old_dev.jsonl +0 -0
- runs/long-rl-20261014-v5_looped-ei_s0/final.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/found_targets.jsonl +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/lean_gate.jsonl +123 -0
- runs/long-rl-20261014-v5_looped-ei_s0/rl_round_005.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/rl_round_010.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/rl_round_015.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/rl_round_020.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/rl_round_025.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/rl_round_030.pt +3 -0
- runs/long-rl-20261014-v5_looped-ei_s0/source/harness.py +472 -0
- runs/long-rl-20261014-v5_looped-ei_s0/source/lean_gate.py +82 -0
- runs/long-rl-20261014-v5_looped-ei_s0/source/lean_tok.py +319 -0
- runs/long-rl-20261014-v5_looped-ei_s0/source/pretrain.py +953 -0
- runs/long-rl-20261014-v5_looped-ei_s0/source/remote.sh +27 -0
- runs/long-rl-20261014-v5_looped-ei_s0/summary.json +0 -0
.gitattributes
CHANGED
|
@@ -47,3 +47,4 @@ runs/long-rl-20261014-v4_untied-ei_s1/found_targets.jsonl filter=lfs diff=lfs me
|
|
| 47 |
runs/long-rl-20261014-v4_untied-ei_s0/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 48 |
runs/long-rl-20261014-v5_untied-ei_s0/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 49 |
runs/long-rl-20261014-v5_untied-ei_s1/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 47 |
runs/long-rl-20261014-v4_untied-ei_s0/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 48 |
runs/long-rl-20261014-v5_untied-ei_s0/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 49 |
runs/long-rl-20261014-v5_untied-ei_s1/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
runs/long-rl-20261014-v5_looped-ei_s0/found_targets.jsonl filter=lfs diff=lfs merge=lfs -text
|
runs/long-rl-20261014-v5_looped-ei_s0/eval_dev.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/long-rl-20261014-v5_looped-ei_s0/eval_dev_diag.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/long-rl-20261014-v5_looped-ei_s0/eval_old_dev.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
runs/long-rl-20261014-v5_looped-ei_s0/final.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e340f445111b38d374c59377eca3e7fc505b1c0853c5dbc554b398918708fd6
|
| 3 |
+
size 38588127
|
runs/long-rl-20261014-v5_looped-ei_s0/found_targets.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2fa2b3f3e00750fd8f9ea3e877596c8190739a68114a0799ac34d636d6e625f8
|
| 3 |
+
size 55614665
|
runs/long-rl-20261014-v5_looped-ei_s0/lean_gate.jsonl
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"utc": "2026-10-14T22:54:30Z", "samples": 12008, "parse_fail": 4284, "distinct_checked": 7690, "lean_ok": 5251, "lean_rej": 2439, "parse_reasons": {"unbound": 2118, "no-eos": 1075, "expected (": 512, "name": 164, "formula": 117, "expected ;": 83, "expected )": 62, "ORE box": 62, "exact not last": 53, "expected :=": 30, "PR position": 5, "trailing tokens": 3}, "lean_wall_s": 27.239928722381592, "lean_proc_s": 517.0205669403076, "workers": 96, "chunk": 400}
|
| 2 |
+
{"utc": "2026-10-14T22:55:30Z", "samples": 5160, "parse_fail": 3908, "distinct_checked": 1247, "lean_ok": 100, "lean_rej": 1147, "parse_reasons": {"unbound": 1857, "no-eos": 989, "expected (": 646, "expected )": 103, "formula": 85, "name": 72, "ORE box": 60, "exact not last": 47, "expected ;": 38, "expected :=": 7, "PR position": 3, "expected hh": 1}, "lean_wall_s": 6.616936683654785, "lean_proc_s": 20.677321910858154, "workers": 96, "chunk": 400}
|
| 3 |
+
{"utc": "2026-10-14T22:57:17Z", "samples": 5160, "parse_fail": 3936, "distinct_checked": 1219, "lean_ok": 162, "lean_rej": 1057, "parse_reasons": {"unbound": 1771, "no-eos": 1103, "expected (": 681, "expected )": 95, "ORE box": 71, "formula": 70, "name": 43, "exact not last": 40, "expected :=": 33, "expected ;": 26, "PR position": 1, "expected =>": 1, "expected hh": 1}, "lean_wall_s": 6.247349977493286, "lean_proc_s": 19.081527709960938, "workers": 96, "chunk": 400}
|
| 4 |
+
{"utc": "2026-10-14T23:00:05Z", "samples": 5136, "parse_fail": 3820, "distinct_checked": 1305, "lean_ok": 250, "lean_rej": 1055, "parse_reasons": {"unbound": 1541, "no-eos": 1308, "expected (": 631, "ORE box": 79, "formula": 77, "expected )": 58, "expected ;": 55, "name": 41, "exact not last": 22, "expected hh": 2, "expected =>": 2, "expected :=": 2, "expected fun": 1, "expected False": 1}, "lean_wall_s": 5.612934589385986, "lean_proc_s": 19.004218816757202, "workers": 96, "chunk": 400}
|
| 5 |
+
{"utc": "2026-10-14T23:02:51Z", "samples": 11992, "parse_fail": 3913, "distinct_checked": 8043, "lean_ok": 5217, "lean_rej": 2826, "parse_reasons": {"unbound": 2038, "no-eos": 812, "expected (": 455, "name": 220, "formula": 115, "expected ;": 80, "ORE box": 61, "exact not last": 60, "expected )": 40, "expected :=": 17, "trailing tokens": 8, "PR position": 5, "expected None": 1, "expected fun": 1}, "lean_wall_s": 26.536112546920776, "lean_proc_s": 523.2650465965271, "workers": 96, "chunk": 400}
|
| 6 |
+
{"utc": "2026-10-14T23:04:07Z", "samples": 4992, "parse_fail": 3396, "distinct_checked": 1590, "lean_ok": 171, "lean_rej": 1419, "parse_reasons": {"unbound": 1549, "no-eos": 799, "expected (": 647, "formula": 119, "ORE box": 74, "name": 72, "exact not last": 57, "expected ;": 51, "expected )": 24, "expected exact": 1, "expected fun": 1, "expected :=": 1, "trailing tokens": 1}, "lean_wall_s": 8.688303709030151, "lean_proc_s": 33.48628807067871, "workers": 96, "chunk": 400}
|
| 7 |
+
{"utc": "2026-10-14T23:05:41Z", "samples": 4968, "parse_fail": 3649, "distinct_checked": 1311, "lean_ok": 270, "lean_rej": 1041, "parse_reasons": {"unbound": 1614, "no-eos": 973, "expected (": 667, "expected ;": 99, "name": 80, "ORE box": 79, "exact not last": 48, "expected )": 38, "formula": 28, "expected :=": 13, "trailing tokens": 4, "expected exact": 3, "PR position": 2, "expected None": 1}, "lean_wall_s": 6.826809644699097, "lean_proc_s": 22.898152351379395, "workers": 96, "chunk": 400}
|
| 8 |
+
{"utc": "2026-10-14T23:08:16Z", "samples": 4968, "parse_fail": 3934, "distinct_checked": 1032, "lean_ok": 161, "lean_rej": 871, "parse_reasons": {"unbound": 1737, "no-eos": 1088, "expected (": 658, "ORE box": 96, "name": 80, "exact not last": 75, "formula": 72, "expected ;": 63, "expected )": 40, "trailing tokens": 13, "expected :=": 4, "PR position": 2, "eof": 2, "expected exact": 2, "expected =>": 1, "expected None": 1}, "lean_wall_s": 5.7668843269348145, "lean_proc_s": 15.972371101379395, "workers": 96, "chunk": 400}
|
| 9 |
+
{"utc": "2026-10-14T23:11:02Z", "samples": 11992, "parse_fail": 3893, "distinct_checked": 8067, "lean_ok": 5335, "lean_rej": 2732, "parse_reasons": {"unbound": 1718, "no-eos": 1076, "expected (": 637, "formula": 141, "name": 102, "expected ;": 81, "exact not last": 69, "ORE box": 34, "expected )": 25, "trailing tokens": 4, "expected :=": 2, "expected None": 2, "PR position": 2}, "lean_wall_s": 27.506676197052002, "lean_proc_s": 542.9428691864014, "workers": 96, "chunk": 400}
|
| 10 |
+
{"utc": "2026-10-14T23:11:51Z", "samples": 4824, "parse_fail": 3329, "distinct_checked": 1488, "lean_ok": 223, "lean_rej": 1265, "parse_reasons": {"unbound": 1300, "no-eos": 952, "expected (": 799, "formula": 65, "name": 56, "exact not last": 52, "expected ;": 47, "expected )": 28, "ORE box": 22, "expected None": 3, "trailing tokens": 3, "eof": 1, "PR position": 1}, "lean_wall_s": 6.132905960083008, "lean_proc_s": 23.413400173187256, "workers": 96, "chunk": 400}
|
| 11 |
+
{"utc": "2026-10-14T23:13:23Z", "samples": 4824, "parse_fail": 3614, "distinct_checked": 1202, "lean_ok": 221, "lean_rej": 981, "parse_reasons": {"unbound": 1551, "no-eos": 1078, "expected (": 694, "formula": 88, "name": 67, "exact not last": 42, "expected ;": 31, "ORE box": 31, "expected )": 22, "PR position": 6, "expected =>": 4}, "lean_wall_s": 4.327411651611328, "lean_proc_s": 12.564753532409668, "workers": 96, "chunk": 400}
|
| 12 |
+
{"utc": "2026-10-14T23:16:36Z", "samples": 4824, "parse_fail": 3850, "distinct_checked": 971, "lean_ok": 80, "lean_rej": 891, "parse_reasons": {"unbound": 1444, "no-eos": 1244, "expected (": 845, "formula": 81, "name": 64, "exact not last": 43, "expected )": 42, "ORE box": 42, "expected ;": 32, "PR position": 3, "expected :=": 3, "expected exact": 2, "expected None": 2, "expected =>": 1, "trailing tokens": 1, "expected hh": 1}, "lean_wall_s": 5.270263195037842, "lean_proc_s": 13.93827223777771, "workers": 96, "chunk": 400}
|
| 13 |
+
{"utc": "2026-10-14T23:19:30Z", "samples": 12000, "parse_fail": 4205, "distinct_checked": 7765, "lean_ok": 5120, "lean_rej": 2645, "parse_reasons": {"unbound": 2170, "no-eos": 774, "expected (": 712, "formula": 136, "name": 119, "expected ;": 79, "exact not last": 73, "ORE box": 46, "expected :=": 43, "expected )": 35, "trailing tokens": 10, "expected exact": 2, "PR position": 2, "expected fun": 2, "expected =>": 1, "expected None": 1}, "lean_wall_s": 27.36125659942627, "lean_proc_s": 534.2770702838898, "workers": 96, "chunk": 400}
|
| 14 |
+
{"utc": "2026-10-14T23:20:24Z", "samples": 4992, "parse_fail": 3652, "distinct_checked": 1331, "lean_ok": 146, "lean_rej": 1185, "parse_reasons": {"unbound": 1619, "expected (": 995, "no-eos": 806, "exact not last": 66, "name": 49, "expected ;": 40, "formula": 36, "expected )": 13, "ORE box": 13, "trailing tokens": 6, "expected :=": 6, "PR position": 1, "expected =>": 1, "expected fun": 1}, "lean_wall_s": 5.113032817840576, "lean_proc_s": 17.70346999168396, "workers": 96, "chunk": 400}
|
| 15 |
+
{"utc": "2026-10-14T23:22:26Z", "samples": 4992, "parse_fail": 3849, "distinct_checked": 1139, "lean_ok": 171, "lean_rej": 968, "parse_reasons": {"unbound": 1680, "no-eos": 1138, "expected (": 766, "formula": 67, "name": 55, "exact not last": 53, "expected ;": 31, "expected )": 26, "ORE box": 19, "expected :=": 7, "expected =>": 4, "trailing tokens": 1, "PR position": 1, "expected exact": 1}, "lean_wall_s": 5.630019426345825, "lean_proc_s": 16.457110166549683, "workers": 96, "chunk": 400}
|
| 16 |
+
{"utc": "2026-10-14T23:24:46Z", "samples": 4992, "parse_fail": 3764, "distinct_checked": 1222, "lean_ok": 215, "lean_rej": 1007, "parse_reasons": {"unbound": 1709, "no-eos": 898, "expected (": 882, "name": 56, "exact not last": 55, "expected ;": 50, "formula": 48, "expected )": 43, "ORE box": 14, "expected :=": 4, "expected =>": 3, "expected None": 1, "expected fun": 1}, "lean_wall_s": 5.075511693954468, "lean_proc_s": 15.670875549316406, "workers": 96, "chunk": 400}
|
| 17 |
+
{"utc": "2026-10-14T23:27:30Z", "samples": 12008, "parse_fail": 4163, "distinct_checked": 7811, "lean_ok": 5264, "lean_rej": 2547, "parse_reasons": {"unbound": 1948, "no-eos": 1141, "expected (": 559, "name": 126, "formula": 98, "expected ;": 95, "expected )": 74, "exact not last": 56, "ORE box": 34, "expected :=": 29, "PR position": 3}, "lean_wall_s": 24.633353233337402, "lean_proc_s": 479.662544965744, "workers": 96, "chunk": 400}
|
| 18 |
+
{"utc": "2026-10-14T23:28:43Z", "samples": 4920, "parse_fail": 3646, "distinct_checked": 1267, "lean_ok": 166, "lean_rej": 1101, "parse_reasons": {"unbound": 1403, "no-eos": 1191, "expected (": 692, "expected ;": 90, "ORE box": 65, "formula": 65, "name": 61, "expected )": 33, "exact not last": 31, "expected :=": 11, "expected None": 1, "expected exact": 1, "PR position": 1, "expected False": 1}, "lean_wall_s": 6.3426737785339355, "lean_proc_s": 20.43372631072998, "workers": 96, "chunk": 400}
|
| 19 |
+
{"utc": "2026-10-14T23:30:12Z", "samples": 4920, "parse_fail": 3894, "distinct_checked": 1021, "lean_ok": 137, "lean_rej": 884, "parse_reasons": {"unbound": 1468, "no-eos": 1180, "expected (": 937, "expected ;": 106, "name": 58, "formula": 47, "ORE box": 30, "exact not last": 29, "expected :=": 21, "expected )": 16, "expected exact": 1, "PR position": 1}, "lean_wall_s": 4.984228849411011, "lean_proc_s": 14.531189918518066, "workers": 96, "chunk": 400}
|
| 20 |
+
{"utc": "2026-10-14T23:33:06Z", "samples": 4920, "parse_fail": 3640, "distinct_checked": 1275, "lean_ok": 307, "lean_rej": 968, "parse_reasons": {"no-eos": 1336, "unbound": 1269, "expected (": 705, "expected ;": 121, "ORE box": 64, "formula": 56, "name": 38, "exact not last": 30, "expected :=": 8, "expected )": 6, "expected exact": 4, "expected =>": 1, "PR position": 1, "expected None": 1}, "lean_wall_s": 6.505025863647461, "lean_proc_s": 20.68951940536499, "workers": 96, "chunk": 400}
|
| 21 |
+
{"utc": "2026-10-14T23:35:51Z", "samples": 11992, "parse_fail": 4393, "distinct_checked": 7566, "lean_ok": 5254, "lean_rej": 2312, "parse_reasons": {"unbound": 1920, "no-eos": 1124, "expected (": 802, "formula": 152, "name": 106, "expected ;": 91, "exact not last": 69, "expected )": 66, "ORE box": 34, "expected :=": 20, "PR position": 4, "trailing tokens": 3, "expected None": 1, "eof": 1}, "lean_wall_s": 26.66136384010315, "lean_proc_s": 496.31030225753784, "workers": 96, "chunk": 400}
|
| 22 |
+
{"utc": "2026-10-14T23:36:56Z", "samples": 5040, "parse_fail": 3536, "distinct_checked": 1495, "lean_ok": 183, "lean_rej": 1312, "parse_reasons": {"unbound": 1399, "no-eos": 1004, "expected (": 825, "expected ;": 61, "formula": 57, "ORE box": 56, "name": 54, "expected )": 34, "exact not last": 31, "expected :=": 8, "PR position": 3, "trailing tokens": 3, "expected None": 1}, "lean_wall_s": 5.73739218711853, "lean_proc_s": 21.835867166519165, "workers": 96, "chunk": 400}
|
| 23 |
+
{"utc": "2026-10-14T23:38:30Z", "samples": 5016, "parse_fail": 3882, "distinct_checked": 1121, "lean_ok": 194, "lean_rej": 927, "parse_reasons": {"unbound": 1289, "expected (": 1197, "no-eos": 1093, "name": 80, "expected ;": 68, "formula": 56, "expected )": 39, "ORE box": 38, "exact not last": 18, "expected None": 2, "expected :=": 1, "expected hh": 1}, "lean_wall_s": 4.242774724960327, "lean_proc_s": 11.517902851104736, "workers": 96, "chunk": 400}
|
| 24 |
+
{"utc": "2026-10-14T23:41:20Z", "samples": 5016, "parse_fail": 3994, "distinct_checked": 1022, "lean_ok": 132, "lean_rej": 890, "parse_reasons": {"unbound": 1362, "no-eos": 1274, "expected (": 1105, "formula": 58, "exact not last": 44, "name": 43, "expected ;": 40, "ORE box": 31, "expected )": 20, "expected :=": 11, "PR position": 2, "expected hh": 1, "expected None": 1, "expected exact": 1, "trailing tokens": 1}, "lean_wall_s": 5.444639444351196, "lean_proc_s": 15.57930588722229, "workers": 96, "chunk": 400}
|
| 25 |
+
{"utc": "2026-10-14T23:44:08Z", "samples": 12008, "parse_fail": 4592, "distinct_checked": 7385, "lean_ok": 5178, "lean_rej": 2207, "parse_reasons": {"unbound": 1947, "no-eos": 1292, "expected (": 829, "name": 132, "formula": 127, "expected ;": 97, "exact not last": 67, "ORE box": 51, "expected )": 24, "trailing tokens": 14, "PR position": 6, "expected None": 2, "expected :=": 2, "expected =>": 1, "expected exact": 1}, "lean_wall_s": 25.115297317504883, "lean_proc_s": 465.57823300361633, "workers": 96, "chunk": 400}
|
| 26 |
+
{"utc": "2026-10-14T23:45:17Z", "samples": 5136, "parse_fail": 4022, "distinct_checked": 1108, "lean_ok": 109, "lean_rej": 999, "parse_reasons": {"unbound": 1698, "expected (": 990, "no-eos": 984, "expected ;": 85, "name": 67, "exact not last": 59, "formula": 44, "ORE box": 41, "PR position": 15, "expected =>": 15, "expected )": 11, "expected :=": 6, "trailing tokens": 5, "expected None": 1, "expected False": 1}, "lean_wall_s": 6.267525672912598, "lean_proc_s": 17.874306678771973, "workers": 96, "chunk": 400}
|
| 27 |
+
{"utc": "2026-10-14T23:46:43Z", "samples": 5136, "parse_fail": 4077, "distinct_checked": 1054, "lean_ok": 245, "lean_rej": 809, "parse_reasons": {"unbound": 1797, "no-eos": 1112, "expected (": 867, "expected ;": 77, "name": 73, "exact not last": 58, "formula": 34, "ORE box": 32, "expected )": 20, "trailing tokens": 2, "expected False": 2, "expected =>": 1, "expected None": 1, "PR position": 1}, "lean_wall_s": 5.15773344039917, "lean_proc_s": 14.543639659881592, "workers": 96, "chunk": 400}
|
| 28 |
+
{"utc": "2026-10-14T23:49:28Z", "samples": 5112, "parse_fail": 4056, "distinct_checked": 1051, "lean_ok": 193, "lean_rej": 858, "parse_reasons": {"unbound": 1643, "no-eos": 1150, "expected (": 932, "expected ;": 91, "name": 67, "formula": 43, "exact not last": 41, "ORE box": 34, "expected )": 23, "expected :=": 16, "trailing tokens": 7, "expected =>": 4, "PR position": 2, "expected None": 1, "eof": 1, "expected False": 1}, "lean_wall_s": 4.0010762214660645, "lean_proc_s": 10.870599746704102, "workers": 96, "chunk": 400}
|
| 29 |
+
{"utc": "2026-10-14T23:52:13Z", "samples": 11992, "parse_fail": 4945, "distinct_checked": 7023, "lean_ok": 4783, "lean_rej": 2240, "parse_reasons": {"unbound": 2433, "no-eos": 1268, "expected (": 880, "formula": 118, "name": 80, "expected ;": 55, "exact not last": 54, "expected )": 21, "expected :=": 20, "ORE box": 13, "PR position": 2, "expected fun": 1}, "lean_wall_s": 25.38173198699951, "lean_proc_s": 450.73031783103943, "workers": 96, "chunk": 400}
|
| 30 |
+
{"utc": "2026-10-14T23:53:16Z", "samples": 5376, "parse_fail": 4103, "distinct_checked": 1270, "lean_ok": 199, "lean_rej": 1071, "parse_reasons": {"unbound": 1730, "no-eos": 1200, "expected (": 896, "exact not last": 80, "formula": 76, "expected )": 40, "name": 39, "expected ;": 23, "expected :=": 13, "ORE box": 4, "expected None": 1, "eof": 1}, "lean_wall_s": 7.600282907485962, "lean_proc_s": 24.474308013916016, "workers": 96, "chunk": 400}
|
| 31 |
+
{"utc": "2026-10-14T23:55:02Z", "samples": 5376, "parse_fail": 4264, "distinct_checked": 1107, "lean_ok": 249, "lean_rej": 858, "parse_reasons": {"unbound": 1750, "no-eos": 1210, "expected (": 1040, "formula": 79, "expected ;": 57, "name": 56, "exact not last": 40, "expected :=": 14, "expected )": 14, "expected exact": 1, "PR position": 1, "expected False": 1, "ORE box": 1}, "lean_wall_s": 6.4546897411346436, "lean_proc_s": 19.004272937774658, "workers": 96, "chunk": 400}
|
| 32 |
+
{"utc": "2026-10-14T23:57:35Z", "samples": 5376, "parse_fail": 4255, "distinct_checked": 1118, "lean_ok": 265, "lean_rej": 853, "parse_reasons": {"unbound": 1469, "no-eos": 1292, "expected (": 1213, "name": 74, "exact not last": 69, "formula": 54, "expected ;": 46, "expected )": 21, "expected :=": 10, "trailing tokens": 3, "expected False": 2, "ORE box": 2}, "lean_wall_s": 5.942103147506714, "lean_proc_s": 17.457094430923462, "workers": 96, "chunk": 400}
|
| 33 |
+
{"utc": "2026-10-15T00:00:30Z", "samples": 12000, "parse_fail": 4624, "distinct_checked": 7350, "lean_ok": 4952, "lean_rej": 2398, "parse_reasons": {"unbound": 2079, "no-eos": 1227, "expected (": 920, "name": 107, "formula": 104, "expected ;": 84, "exact not last": 54, "ORE box": 17, "expected :=": 12, "expected )": 7, "trailing tokens": 5, "PR position": 3, "expected =>": 2, "eof": 1, "expected None": 1, "expected False": 1}, "lean_wall_s": 25.589812755584717, "lean_proc_s": 472.0390977859497, "workers": 96, "chunk": 400}
|
| 34 |
+
{"utc": "2026-10-15T00:01:29Z", "samples": 5400, "parse_fail": 3965, "distinct_checked": 1432, "lean_ok": 277, "lean_rej": 1155, "parse_reasons": {"unbound": 1485, "no-eos": 1180, "expected (": 1058, "formula": 82, "name": 39, "expected ;": 39, "exact not last": 30, "expected )": 30, "ORE box": 13, "expected :=": 6, "PR position": 2, "trailing tokens": 1}, "lean_wall_s": 5.609809875488281, "lean_proc_s": 20.391098737716675, "workers": 96, "chunk": 400}
|
| 35 |
+
{"utc": "2026-10-15T00:03:16Z", "samples": 5400, "parse_fail": 4353, "distinct_checked": 1042, "lean_ok": 103, "lean_rej": 939, "parse_reasons": {"unbound": 1678, "no-eos": 1478, "expected (": 999, "name": 51, "formula": 46, "exact not last": 43, "expected ;": 30, "expected )": 17, "expected :=": 4, "ORE box": 2, "PR position": 2, "trailing tokens": 1, "expected .elim": 1, "eof": 1}, "lean_wall_s": 5.9584856033325195, "lean_proc_s": 17.42629098892212, "workers": 96, "chunk": 400}
|
| 36 |
+
{"utc": "2026-10-15T00:06:16Z", "samples": 5376, "parse_fail": 4020, "distinct_checked": 1348, "lean_ok": 203, "lean_rej": 1145, "parse_reasons": {"unbound": 1452, "expected (": 1228, "no-eos": 1135, "formula": 66, "exact not last": 42, "name": 25, "expected ;": 25, "expected )": 21, "expected :=": 13, "ORE box": 8, "trailing tokens": 3, "eof": 1, "PR position": 1}, "lean_wall_s": 7.739504814147949, "lean_proc_s": 26.17782473564148, "workers": 96, "chunk": 400}
|
| 37 |
+
{"utc": "2026-10-15T00:09:06Z", "samples": 12008, "parse_fail": 4581, "distinct_checked": 7395, "lean_ok": 4703, "lean_rej": 2692, "parse_reasons": {"unbound": 2095, "no-eos": 1060, "expected (": 911, "formula": 142, "name": 133, "expected ;": 114, "exact not last": 53, "expected :=": 29, "expected )": 19, "ORE box": 13, "trailing tokens": 5, "PR position": 3, "expected =>": 1, "expected False": 1, "expected None": 1, "expected exact": 1}, "lean_wall_s": 25.882233142852783, "lean_proc_s": 477.10471868515015, "workers": 96, "chunk": 400}
|
| 38 |
+
{"utc": "2026-10-15T00:10:18Z", "samples": 5520, "parse_fail": 3886, "distinct_checked": 1630, "lean_ok": 195, "lean_rej": 1435, "parse_reasons": {"unbound": 1668, "no-eos": 927, "expected (": 886, "expected ;": 129, "formula": 112, "name": 71, "exact not last": 42, "expected )": 26, "ORE box": 7, "expected :=": 7, "expected None": 4, "trailing tokens": 4, "eof": 1, "expected exact": 1, "expected False": 1}, "lean_wall_s": 7.554620265960693, "lean_proc_s": 30.670580625534058, "workers": 96, "chunk": 400}
|
| 39 |
+
{"utc": "2026-10-15T00:11:56Z", "samples": 5520, "parse_fail": 4128, "distinct_checked": 1389, "lean_ok": 202, "lean_rej": 1187, "parse_reasons": {"unbound": 1670, "no-eos": 1066, "expected (": 1019, "expected ;": 123, "name": 69, "exact not last": 64, "formula": 62, "ORE box": 19, "expected )": 18, "expected :=": 10, "trailing tokens": 4, "PR position": 2, "expected None": 1, "expected exact": 1}, "lean_wall_s": 7.361350059509277, "lean_proc_s": 27.30755305290222, "workers": 96, "chunk": 400}
|
| 40 |
+
{"utc": "2026-10-15T00:14:53Z", "samples": 5496, "parse_fail": 4172, "distinct_checked": 1322, "lean_ok": 207, "lean_rej": 1115, "parse_reasons": {"unbound": 1604, "expected (": 1253, "no-eos": 956, "expected ;": 102, "formula": 78, "name": 77, "exact not last": 45, "expected :=": 35, "expected )": 14, "ORE box": 7, "trailing tokens": 1}, "lean_wall_s": 5.492671728134155, "lean_proc_s": 18.17506241798401, "workers": 96, "chunk": 400}
|
| 41 |
+
{"utc": "2026-10-15T00:17:36Z", "samples": 12000, "parse_fail": 4876, "distinct_checked": 7094, "lean_ok": 4754, "lean_rej": 2340, "parse_reasons": {"unbound": 2035, "no-eos": 1223, "expected (": 1106, "formula": 139, "name": 128, "expected ;": 112, "exact not last": 70, "expected )": 36, "ORE box": 9, "PR position": 6, "expected =>": 5, "trailing tokens": 3, "expected :=": 3, "expected None": 1}, "lean_wall_s": 18.805036783218384, "lean_proc_s": 333.11158514022827, "workers": 96, "chunk": 400}
|
| 42 |
+
{"utc": "2026-10-15T00:18:55Z", "samples": 5664, "parse_fail": 4258, "distinct_checked": 1397, "lean_ok": 163, "lean_rej": 1234, "parse_reasons": {"unbound": 1830, "expected (": 1081, "no-eos": 1008, "formula": 90, "exact not last": 74, "expected ;": 53, "name": 50, "expected )": 40, "expected :=": 15, "expected =>": 8, "ORE box": 5, "trailing tokens": 2, "expected False": 1, "PR position": 1}, "lean_wall_s": 5.659446477890015, "lean_proc_s": 19.833765029907227, "workers": 96, "chunk": 400}
|
| 43 |
+
{"utc": "2026-10-15T00:20:30Z", "samples": 5640, "parse_fail": 4333, "distinct_checked": 1301, "lean_ok": 240, "lean_rej": 1061, "parse_reasons": {"unbound": 1967, "expected (": 1113, "no-eos": 918, "expected ;": 85, "formula": 81, "name": 53, "exact not last": 52, "expected )": 33, "expected :=": 15, "PR position": 10, "expected =>": 2, "trailing tokens": 2, "ORE box": 2}, "lean_wall_s": 5.152469158172607, "lean_proc_s": 16.715556859970093, "workers": 96, "chunk": 400}
|
| 44 |
+
{"utc": "2026-10-15T00:23:18Z", "samples": 5640, "parse_fail": 4462, "distinct_checked": 1169, "lean_ok": 202, "lean_rej": 967, "parse_reasons": {"unbound": 1881, "expected (": 1258, "no-eos": 1027, "formula": 120, "exact not last": 61, "expected ;": 60, "name": 37, "expected )": 11, "expected :=": 3, "ORE box": 2, "eof": 1, "expected hh": 1}, "lean_wall_s": 6.271963357925415, "lean_proc_s": 18.33143711090088, "workers": 96, "chunk": 400}
|
| 45 |
+
{"utc": "2026-10-15T00:26:12Z", "samples": 12000, "parse_fail": 4665, "distinct_checked": 7316, "lean_ok": 4952, "lean_rej": 2364, "parse_reasons": {"unbound": 2079, "no-eos": 1267, "expected (": 892, "expected ;": 129, "formula": 98, "name": 97, "exact not last": 57, "expected )": 24, "trailing tokens": 7, "ORE box": 6, "expected None": 3, "expected :=": 3, "expected =>": 1, "expected False": 1, "expected hh": 1}, "lean_wall_s": 26.914457082748413, "lean_proc_s": 488.3790695667267, "workers": 96, "chunk": 400}
|
| 46 |
+
{"utc": "2026-10-15T00:27:21Z", "samples": 5520, "parse_fail": 4134, "distinct_checked": 1382, "lean_ok": 198, "lean_rej": 1184, "parse_reasons": {"unbound": 1682, "no-eos": 1177, "expected (": 969, "name": 82, "formula": 74, "expected ;": 56, "exact not last": 52, "expected )": 29, "trailing tokens": 8, "expected None": 4, "ORE box": 1}, "lean_wall_s": 8.231770992279053, "lean_proc_s": 30.72229242324829, "workers": 96, "chunk": 400}
|
| 47 |
+
{"utc": "2026-10-15T00:29:09Z", "samples": 5520, "parse_fail": 4306, "distinct_checked": 1209, "lean_ok": 130, "lean_rej": 1079, "parse_reasons": {"unbound": 1925, "expected (": 1105, "no-eos": 1001, "expected ;": 72, "formula": 62, "name": 57, "exact not last": 40, "expected )": 35, "PR position": 3, "expected =>": 2, "ORE box": 2, "expected fun": 1, "expected :=": 1}, "lean_wall_s": 6.955458402633667, "lean_proc_s": 21.014864206314087, "workers": 96, "chunk": 400}
|
| 48 |
+
{"utc": "2026-10-15T00:31:53Z", "samples": 5496, "parse_fail": 4361, "distinct_checked": 1128, "lean_ok": 228, "lean_rej": 900, "parse_reasons": {"unbound": 1887, "no-eos": 1116, "expected (": 1047, "expected ;": 106, "formula": 66, "name": 45, "exact not last": 39, "expected )": 30, "PR position": 13, "ORE box": 3, "expected :=": 3, "expected None": 2, "trailing tokens": 2, "eof": 1, "expected =>": 1}, "lean_wall_s": 6.589255332946777, "lean_proc_s": 19.428964614868164, "workers": 96, "chunk": 400}
|
| 49 |
+
{"utc": "2026-10-15T00:34:47Z", "samples": 11992, "parse_fail": 4911, "distinct_checked": 7058, "lean_ok": 4912, "lean_rej": 2146, "parse_reasons": {"unbound": 2067, "expected (": 1265, "no-eos": 1173, "formula": 141, "name": 99, "exact not last": 73, "expected ;": 53, "expected )": 22, "trailing tokens": 7, "ORE box": 6, "PR position": 2, "eof": 1, "expected None": 1, "expected :=": 1}, "lean_wall_s": 27.19770383834839, "lean_proc_s": 478.9707679748535, "workers": 96, "chunk": 400}
|
| 50 |
+
{"utc": "2026-10-15T00:36:02Z", "samples": 5592, "parse_fail": 4380, "distinct_checked": 1210, "lean_ok": 140, "lean_rej": 1070, "parse_reasons": {"unbound": 1620, "expected (": 1302, "no-eos": 1110, "formula": 120, "expected ;": 71, "name": 63, "exact not last": 52, "expected )": 34, "expected :=": 4, "ORE box": 3, "PR position": 1}, "lean_wall_s": 6.6524622440338135, "lean_proc_s": 19.902666807174683, "workers": 96, "chunk": 400}
|
| 51 |
+
{"utc": "2026-10-15T00:37:32Z", "samples": 5592, "parse_fail": 4310, "distinct_checked": 1276, "lean_ok": 208, "lean_rej": 1068, "parse_reasons": {"unbound": 1726, "no-eos": 1228, "expected (": 1118, "expected ;": 102, "name": 45, "exact not last": 44, "formula": 24, "ORE box": 8, "trailing tokens": 5, "expected )": 5, "expected None": 2, "PR position": 1, "eof": 1, "expected hh": 1}, "lean_wall_s": 7.422692775726318, "lean_proc_s": 23.911064624786377, "workers": 96, "chunk": 400}
|
| 52 |
+
{"utc": "2026-10-15T00:40:26Z", "samples": 5568, "parse_fail": 4710, "distinct_checked": 853, "lean_ok": 95, "lean_rej": 758, "parse_reasons": {"unbound": 1829, "no-eos": 1428, "expected (": 1117, "expected ;": 130, "formula": 76, "name": 61, "exact not last": 42, "expected )": 18, "PR position": 3, "trailing tokens": 2, "ORE box": 2, "expected hh": 1, "expected exact": 1}, "lean_wall_s": 4.986109495162964, "lean_proc_s": 11.013891220092773, "workers": 96, "chunk": 400}
|
| 53 |
+
{"utc": "2026-10-15T00:43:18Z", "samples": 12008, "parse_fail": 5254, "distinct_checked": 6728, "lean_ok": 4854, "lean_rej": 1874, "parse_reasons": {"unbound": 2292, "no-eos": 1320, "expected (": 1041, "expected ;": 146, "formula": 129, "name": 126, "exact not last": 109, "expected )": 52, "ORE box": 29, "expected =>": 3, "PR position": 3, "trailing tokens": 2, "expected False": 1, "expected None": 1}, "lean_wall_s": 20.304322242736816, "lean_proc_s": 337.43798995018005, "workers": 96, "chunk": 400}
|
| 54 |
+
{"utc": "2026-10-15T00:44:20Z", "samples": 5496, "parse_fail": 4284, "distinct_checked": 1210, "lean_ok": 125, "lean_rej": 1085, "parse_reasons": {"unbound": 1749, "expected (": 1271, "no-eos": 917, "expected ;": 103, "expected )": 59, "exact not last": 57, "name": 56, "formula": 53, "ORE box": 14, "PR position": 2, "expected hh": 1, "expected =>": 1, "trailing tokens": 1}, "lean_wall_s": 3.0846171379089355, "lean_proc_s": 9.341657400131226, "workers": 96, "chunk": 400}
|
| 55 |
+
{"utc": "2026-10-15T00:46:04Z", "samples": 5472, "parse_fail": 4234, "distinct_checked": 1232, "lean_ok": 123, "lean_rej": 1109, "parse_reasons": {"unbound": 1687, "expected (": 1088, "no-eos": 1066, "expected ;": 173, "exact not last": 55, "name": 53, "expected )": 40, "formula": 37, "ORE box": 13, "expected :=": 10, "PR position": 7, "trailing tokens": 2, "expected exact": 1, "expected fun": 1, "expected None": 1}, "lean_wall_s": 6.712055683135986, "lean_proc_s": 20.624105215072632, "workers": 96, "chunk": 400}
|
| 56 |
+
{"utc": "2026-10-15T00:49:29Z", "samples": 5472, "parse_fail": 4152, "distinct_checked": 1314, "lean_ok": 156, "lean_rej": 1158, "parse_reasons": {"unbound": 1783, "no-eos": 1044, "expected (": 968, "expected ;": 112, "formula": 78, "name": 60, "exact not last": 50, "expected )": 38, "ORE box": 14, "trailing tokens": 2, "PR position": 1, "expected fun": 1, "expected None": 1}, "lean_wall_s": 7.281758069992065, "lean_proc_s": 24.132739782333374, "workers": 96, "chunk": 400}
|
| 57 |
+
{"utc": "2026-10-15T00:52:15Z", "samples": 11992, "parse_fail": 5243, "distinct_checked": 6732, "lean_ok": 4854, "lean_rej": 1878, "parse_reasons": {"unbound": 2107, "no-eos": 1445, "expected (": 1236, "name": 113, "formula": 89, "expected ;": 89, "exact not last": 81, "ORE box": 35, "expected )": 34, "expected :=": 8, "trailing tokens": 3, "PR position": 2, "expected None": 1}, "lean_wall_s": 24.175652980804443, "lean_proc_s": 404.36166763305664, "workers": 96, "chunk": 400}
|
| 58 |
+
{"utc": "2026-10-15T00:53:23Z", "samples": 5520, "parse_fail": 4548, "distinct_checked": 970, "lean_ok": 92, "lean_rej": 878, "parse_reasons": {"unbound": 1708, "no-eos": 1317, "expected (": 1177, "formula": 107, "exact not last": 64, "name": 59, "expected ;": 51, "ORE box": 37, "expected )": 24, "trailing tokens": 2, "expected False": 1, "PR position": 1}, "lean_wall_s": 6.017580032348633, "lean_proc_s": 15.881116151809692, "workers": 96, "chunk": 400}
|
| 59 |
+
{"utc": "2026-10-15T00:54:45Z", "samples": 5496, "parse_fail": 4630, "distinct_checked": 861, "lean_ok": 114, "lean_rej": 747, "parse_reasons": {"unbound": 1667, "expected (": 1441, "no-eos": 1251, "expected ;": 97, "name": 62, "exact not last": 51, "formula": 23, "ORE box": 19, "expected )": 13, "expected False": 2, "expected exact": 2, "PR position": 1, "expected None": 1}, "lean_wall_s": 5.159216403961182, "lean_proc_s": 11.565471887588501, "workers": 96, "chunk": 400}
|
| 60 |
+
{"utc": "2026-10-15T00:57:26Z", "samples": 5496, "parse_fail": 4650, "distinct_checked": 840, "lean_ok": 112, "lean_rej": 728, "parse_reasons": {"unbound": 1733, "no-eos": 1385, "expected (": 1257, "expected ;": 87, "exact not last": 55, "formula": 55, "name": 53, "expected )": 11, "ORE box": 8, "PR position": 3, "trailing tokens": 1, "eof": 1, "expected :=": 1}, "lean_wall_s": 4.56131649017334, "lean_proc_s": 9.66584849357605, "workers": 96, "chunk": 400}
|
| 61 |
+
{"utc": "2026-10-15T01:00:11Z", "samples": 12000, "parse_fail": 5203, "distinct_checked": 6773, "lean_ok": 4698, "lean_rej": 2075, "parse_reasons": {"unbound": 2127, "no-eos": 1333, "expected (": 1197, "formula": 182, "name": 124, "expected ;": 65, "exact not last": 63, "expected )": 58, "ORE box": 38, "PR position": 11, "expected :=": 3, "expected None": 1, "expected False": 1}, "lean_wall_s": 21.28674030303955, "lean_proc_s": 350.1621115207672, "workers": 96, "chunk": 400}
|
| 62 |
+
{"utc": "2026-10-15T01:01:21Z", "samples": 5664, "parse_fail": 4446, "distinct_checked": 1211, "lean_ok": 175, "lean_rej": 1036, "parse_reasons": {"unbound": 1676, "expected (": 1371, "no-eos": 1039, "exact not last": 82, "formula": 68, "name": 66, "expected )": 59, "expected ;": 53, "ORE box": 21, "expected False": 4, "PR position": 4, "expected None": 3}, "lean_wall_s": 6.7779481410980225, "lean_proc_s": 20.57697057723999, "workers": 96, "chunk": 400}
|
| 63 |
+
{"utc": "2026-10-15T01:03:00Z", "samples": 5664, "parse_fail": 4702, "distinct_checked": 960, "lean_ok": 186, "lean_rej": 774, "parse_reasons": {"unbound": 1781, "expected (": 1321, "no-eos": 1257, "formula": 88, "exact not last": 58, "name": 53, "expected )": 49, "expected ;": 40, "ORE box": 26, "expected :=": 22, "expected False": 5, "expected fun": 2}, "lean_wall_s": 4.90119194984436, "lean_proc_s": 12.866291046142578, "workers": 96, "chunk": 400}
|
| 64 |
+
{"utc": "2026-10-15T01:05:43Z", "samples": 5664, "parse_fail": 4755, "distinct_checked": 906, "lean_ok": 137, "lean_rej": 769, "parse_reasons": {"unbound": 1656, "no-eos": 1426, "expected (": 1339, "formula": 95, "exact not last": 58, "expected ;": 53, "expected )": 48, "name": 45, "ORE box": 27, "expected False": 3, "expected None": 2, "expected :=": 1, "PR position": 1, "expected exact": 1}, "lean_wall_s": 4.8146185874938965, "lean_proc_s": 11.338100671768188, "workers": 96, "chunk": 400}
|
| 65 |
+
{"utc": "2026-10-15T01:08:32Z", "samples": 12016, "parse_fail": 5016, "distinct_checked": 6982, "lean_ok": 4703, "lean_rej": 2279, "parse_reasons": {"unbound": 1903, "no-eos": 1441, "expected (": 1205, "formula": 134, "name": 118, "exact not last": 82, "expected ;": 79, "ORE box": 22, "expected )": 12, "expected :=": 6, "PR position": 5, "trailing tokens": 3, "expected fun": 3, "expected None": 2, "expected False": 1}, "lean_wall_s": 22.455464363098145, "lean_proc_s": 390.5182464122772, "workers": 96, "chunk": 400}
|
| 66 |
+
{"utc": "2026-10-15T01:09:45Z", "samples": 5712, "parse_fail": 4473, "distinct_checked": 1237, "lean_ok": 106, "lean_rej": 1131, "parse_reasons": {"unbound": 1585, "expected (": 1507, "no-eos": 1097, "formula": 89, "exact not last": 62, "name": 61, "expected ;": 40, "expected )": 17, "ORE box": 7, "expected :=": 3, "expected None": 2, "trailing tokens": 1, "expected exact": 1, "expected False": 1}, "lean_wall_s": 6.827733039855957, "lean_proc_s": 21.301926612854004, "workers": 96, "chunk": 400}
|
| 67 |
+
{"utc": "2026-10-15T01:11:19Z", "samples": 5712, "parse_fail": 4783, "distinct_checked": 925, "lean_ok": 187, "lean_rej": 738, "parse_reasons": {"unbound": 1583, "no-eos": 1477, "expected (": 1386, "formula": 93, "expected ;": 80, "name": 60, "exact not last": 58, "expected )": 26, "ORE box": 15, "expected False": 2, "eof": 1, "expected None": 1, "PR position": 1}, "lean_wall_s": 5.362398386001587, "lean_proc_s": 13.16640853881836, "workers": 96, "chunk": 400}
|
| 68 |
+
{"utc": "2026-10-15T01:14:24Z", "samples": 5688, "parse_fail": 4494, "distinct_checked": 1192, "lean_ok": 191, "lean_rej": 1001, "parse_reasons": {"unbound": 1538, "expected (": 1435, "no-eos": 1208, "formula": 88, "expected ;": 85, "exact not last": 61, "name": 53, "ORE box": 15, "expected )": 6, "expected :=": 3, "expected fun": 1, "PR position": 1}, "lean_wall_s": 6.504150867462158, "lean_proc_s": 19.335715770721436, "workers": 96, "chunk": 400}
|
| 69 |
+
{"utc": "2026-10-15T01:17:17Z", "samples": 11992, "parse_fail": 5079, "distinct_checked": 6891, "lean_ok": 4822, "lean_rej": 2069, "parse_reasons": {"unbound": 2148, "no-eos": 1314, "expected (": 1135, "formula": 172, "name": 100, "exact not last": 78, "expected ;": 56, "expected )": 36, "ORE box": 36, "expected exact": 2, "PR position": 2}, "lean_wall_s": 24.733786582946777, "lean_proc_s": 421.6006999015808, "workers": 96, "chunk": 400}
|
| 70 |
+
{"utc": "2026-10-15T01:18:43Z", "samples": 5712, "parse_fail": 4546, "distinct_checked": 1158, "lean_ok": 142, "lean_rej": 1016, "parse_reasons": {"unbound": 1628, "expected (": 1352, "no-eos": 1189, "formula": 92, "exact not last": 81, "expected ;": 63, "expected )": 59, "name": 59, "ORE box": 21, "expected exact": 2}, "lean_wall_s": 6.373459339141846, "lean_proc_s": 18.58591055870056, "workers": 96, "chunk": 400}
|
| 71 |
+
{"utc": "2026-10-15T01:20:17Z", "samples": 5712, "parse_fail": 4381, "distinct_checked": 1324, "lean_ok": 281, "lean_rej": 1043, "parse_reasons": {"unbound": 1517, "expected (": 1303, "no-eos": 1235, "expected ;": 87, "name": 72, "exact not last": 63, "formula": 33, "ORE box": 28, "expected )": 24, "expected :=": 17, "expected exact": 1, "PR position": 1}, "lean_wall_s": 7.578161001205444, "lean_proc_s": 25.976123332977295, "workers": 96, "chunk": 400}
|
| 72 |
+
{"utc": "2026-10-15T01:22:53Z", "samples": 5712, "parse_fail": 4666, "distinct_checked": 1043, "lean_ok": 207, "lean_rej": 836, "parse_reasons": {"unbound": 1635, "expected (": 1424, "no-eos": 1312, "name": 78, "expected ;": 68, "exact not last": 66, "formula": 42, "expected )": 19, "ORE box": 18, "expected exact": 3, "PR position": 1}, "lean_wall_s": 4.948161602020264, "lean_proc_s": 14.311597108840942, "workers": 96, "chunk": 400}
|
| 73 |
+
{"utc": "2026-10-15T01:25:41Z", "samples": 12000, "parse_fail": 5412, "distinct_checked": 6572, "lean_ok": 4475, "lean_rej": 2097, "parse_reasons": {"unbound": 2117, "no-eos": 1674, "expected (": 1145, "expected ;": 145, "name": 93, "formula": 92, "exact not last": 65, "trailing tokens": 31, "ORE box": 29, "expected )": 13, "PR position": 3, "expected :=": 2, "eof": 1, "expected fun": 1, "expected None": 1}, "lean_wall_s": 19.199229955673218, "lean_proc_s": 311.08086347579956, "workers": 96, "chunk": 400}
|
| 74 |
+
{"utc": "2026-10-15T01:26:54Z", "samples": 5736, "parse_fail": 4398, "distinct_checked": 1330, "lean_ok": 233, "lean_rej": 1097, "parse_reasons": {"unbound": 1695, "no-eos": 1210, "expected (": 1174, "name": 104, "expected ;": 71, "formula": 55, "exact not last": 46, "ORE box": 13, "expected )": 12, "trailing tokens": 11, "expected :=": 4, "expected hh": 1, "PR position": 1, "eof": 1}, "lean_wall_s": 5.593934059143066, "lean_proc_s": 19.052808046340942, "workers": 96, "chunk": 400}
|
| 75 |
+
{"utc": "2026-10-15T01:28:39Z", "samples": 5736, "parse_fail": 4742, "distinct_checked": 993, "lean_ok": 230, "lean_rej": 763, "parse_reasons": {"unbound": 1718, "expected (": 1381, "no-eos": 1321, "expected ;": 98, "name": 64, "formula": 47, "exact not last": 39, "expected )": 27, "ORE box": 26, "expected :=": 15, "trailing tokens": 5, "expected None": 1}, "lean_wall_s": 5.790396690368652, "lean_proc_s": 15.731699228286743, "workers": 96, "chunk": 400}
|
| 76 |
+
{"utc": "2026-10-15T01:31:16Z", "samples": 5736, "parse_fail": 4742, "distinct_checked": 994, "lean_ok": 183, "lean_rej": 811, "parse_reasons": {"expected (": 1609, "unbound": 1559, "no-eos": 1332, "name": 76, "expected ;": 73, "exact not last": 45, "formula": 19, "ORE box": 18, "expected )": 7, "expected :=": 2, "expected None": 1, "expected exact": 1}, "lean_wall_s": 4.482644081115723, "lean_proc_s": 12.536518096923828, "workers": 96, "chunk": 400}
|
| 77 |
+
{"utc": "2026-10-15T01:34:08Z", "samples": 12000, "parse_fail": 5231, "distinct_checked": 6731, "lean_ok": 4625, "lean_rej": 2106, "parse_reasons": {"unbound": 1972, "no-eos": 1589, "expected (": 1285, "name": 111, "exact not last": 92, "formula": 79, "expected ;": 62, "ORE box": 9, "expected :=": 8, "PR position": 7, "expected )": 5, "expected None": 4, "expected \u27e9": 3, "expected fun": 3, "expected False": 1, "trailing tokens": 1}, "lean_wall_s": 23.758121013641357, "lean_proc_s": 396.61171221733093, "workers": 96, "chunk": 400}
|
| 78 |
+
{"utc": "2026-10-15T01:35:17Z", "samples": 5856, "parse_fail": 4560, "distinct_checked": 1292, "lean_ok": 149, "lean_rej": 1143, "parse_reasons": {"unbound": 1636, "expected (": 1512, "no-eos": 1178, "formula": 72, "name": 48, "exact not last": 42, "expected ;": 38, "expected :=": 14, "ORE box": 6, "expected )": 6, "expected exact": 3, "expected fun": 2, "trailing tokens": 2, "expected False": 1}, "lean_wall_s": 7.64594841003418, "lean_proc_s": 24.888383626937866, "workers": 96, "chunk": 400}
|
| 79 |
+
{"utc": "2026-10-15T01:37:13Z", "samples": 5856, "parse_fail": 4736, "distinct_checked": 1109, "lean_ok": 212, "lean_rej": 897, "parse_reasons": {"unbound": 1606, "expected (": 1564, "no-eos": 1294, "formula": 86, "expected ;": 62, "name": 49, "exact not last": 41, "ORE box": 17, "expected )": 7, "trailing tokens": 4, "expected False": 2, "expected exact": 2, "expected fun": 1, "expected None": 1}, "lean_wall_s": 4.269249677658081, "lean_proc_s": 12.434568166732788, "workers": 96, "chunk": 400}
|
| 80 |
+
{"utc": "2026-10-15T01:40:11Z", "samples": 5832, "parse_fail": 4813, "distinct_checked": 1013, "lean_ok": 166, "lean_rej": 847, "parse_reasons": {"unbound": 1646, "no-eos": 1457, "expected (": 1404, "expected ;": 83, "formula": 74, "name": 56, "exact not last": 46, "expected :=": 21, "expected )": 15, "ORE box": 8, "expected exact": 1, "expected fun": 1, "expected None": 1}, "lean_wall_s": 6.041028261184692, "lean_proc_s": 16.372698068618774, "workers": 96, "chunk": 400}
|
| 81 |
+
{"utc": "2026-10-15T01:43:04Z", "samples": 11992, "parse_fail": 4942, "distinct_checked": 7031, "lean_ok": 4622, "lean_rej": 2409, "parse_reasons": {"unbound": 1827, "no-eos": 1396, "expected (": 1173, "expected ;": 160, "name": 123, "formula": 115, "exact not last": 54, "expected )": 41, "ORE box": 24, "expected :=": 10, "expected fun": 8, "PR position": 8, "expected None": 2, "trailing tokens": 1}, "lean_wall_s": 20.76321816444397, "lean_proc_s": 359.8461489677429, "workers": 96, "chunk": 400}
|
| 82 |
+
{"utc": "2026-10-15T01:44:17Z", "samples": 5856, "parse_fail": 4450, "distinct_checked": 1397, "lean_ok": 122, "lean_rej": 1275, "parse_reasons": {"unbound": 1668, "expected (": 1319, "no-eos": 1161, "expected ;": 94, "formula": 46, "expected )": 43, "name": 42, "exact not last": 41, "ORE box": 24, "PR position": 6, "expected fun": 3, "expected :=": 2, "expected =>": 1}, "lean_wall_s": 7.390667915344238, "lean_proc_s": 26.479618310928345, "workers": 96, "chunk": 400}
|
| 83 |
+
{"utc": "2026-10-15T01:46:03Z", "samples": 5832, "parse_fail": 4689, "distinct_checked": 1138, "lean_ok": 185, "lean_rej": 953, "parse_reasons": {"unbound": 1594, "expected (": 1500, "no-eos": 1245, "expected ;": 118, "exact not last": 64, "formula": 54, "name": 43, "expected )": 28, "ORE box": 20, "expected fun": 9, "expected exact": 3, "PR position": 3, "expected :=": 3, "trailing tokens": 2, "expected =>": 2, "expected None": 1}, "lean_wall_s": 3.5632243156433105, "lean_proc_s": 10.244489908218384, "workers": 96, "chunk": 400}
|
| 84 |
+
{"utc": "2026-10-15T01:48:50Z", "samples": 5832, "parse_fail": 4664, "distinct_checked": 1161, "lean_ok": 279, "lean_rej": 882, "parse_reasons": {"unbound": 1552, "expected (": 1510, "no-eos": 1300, "expected ;": 112, "name": 55, "exact not last": 51, "formula": 26, "ORE box": 23, "PR position": 23, "expected )": 9, "expected None": 2, "expected =>": 1}, "lean_wall_s": 4.557267189025879, "lean_proc_s": 13.270049810409546, "workers": 96, "chunk": 400}
|
| 85 |
+
{"utc": "2026-10-15T01:51:40Z", "samples": 12000, "parse_fail": 5225, "distinct_checked": 6751, "lean_ok": 4634, "lean_rej": 2117, "parse_reasons": {"unbound": 1944, "no-eos": 1763, "expected (": 1059, "formula": 137, "expected ;": 107, "name": 98, "exact not last": 50, "expected )": 27, "ORE box": 27, "expected fun": 3, "trailing tokens": 2, "PR position": 2, "expected None": 2, "eof": 2, "expected :=": 2}, "lean_wall_s": 21.937574863433838, "lean_proc_s": 361.6458749771118, "workers": 96, "chunk": 400}
|
| 86 |
+
{"utc": "2026-10-15T01:52:52Z", "samples": 5808, "parse_fail": 4535, "distinct_checked": 1266, "lean_ok": 114, "lean_rej": 1152, "parse_reasons": {"unbound": 1768, "no-eos": 1355, "expected (": 1118, "formula": 73, "expected ;": 69, "name": 55, "exact not last": 44, "expected )": 31, "ORE box": 13, "PR position": 2, "expected fun": 2, "expected :=": 2, "trailing tokens": 1, "expected =>": 1, "expected False": 1}, "lean_wall_s": 7.403130054473877, "lean_proc_s": 23.851536989212036, "workers": 96, "chunk": 400}
|
| 87 |
+
{"utc": "2026-10-15T01:54:27Z", "samples": 5808, "parse_fail": 4839, "distinct_checked": 967, "lean_ok": 140, "lean_rej": 827, "parse_reasons": {"unbound": 1757, "no-eos": 1443, "expected (": 1338, "expected ;": 103, "exact not last": 58, "formula": 56, "name": 44, "ORE box": 18, "expected )": 9, "expected fun": 5, "expected :=": 4, "expected None": 2, "expected =>": 1, "PR position": 1}, "lean_wall_s": 5.464831590652466, "lean_proc_s": 13.987034797668457, "workers": 96, "chunk": 400}
|
| 88 |
+
{"utc": "2026-10-15T01:57:17Z", "samples": 5784, "parse_fail": 4777, "distinct_checked": 1004, "lean_ok": 151, "lean_rej": 853, "parse_reasons": {"unbound": 1793, "no-eos": 1389, "expected (": 1307, "expected ;": 81, "formula": 64, "exact not last": 54, "name": 53, "expected )": 16, "ORE box": 16, "trailing tokens": 3, "expected fun": 1}, "lean_wall_s": 6.066097974777222, "lean_proc_s": 16.596617698669434, "workers": 96, "chunk": 400}
|
| 89 |
+
{"utc": "2026-10-15T02:00:12Z", "samples": 12000, "parse_fail": 5047, "distinct_checked": 6936, "lean_ok": 4598, "lean_rej": 2338, "parse_reasons": {"unbound": 2153, "no-eos": 1287, "expected (": 1136, "expected ;": 139, "name": 114, "formula": 98, "exact not last": 55, "expected )": 29, "ORE box": 23, "PR position": 4, "expected None": 3, "trailing tokens": 2, "expected fun": 1, "expected exact": 1, "eof": 1, "expected :=": 1}, "lean_wall_s": 23.594833374023438, "lean_proc_s": 410.20367884635925, "workers": 96, "chunk": 400}
|
| 90 |
+
{"utc": "2026-10-15T02:01:22Z", "samples": 5976, "parse_fail": 4901, "distinct_checked": 1071, "lean_ok": 162, "lean_rej": 909, "parse_reasons": {"unbound": 1800, "no-eos": 1411, "expected (": 1395, "expected ;": 84, "name": 68, "formula": 51, "exact not last": 48, "expected )": 22, "expected :=": 8, "trailing tokens": 6, "ORE box": 5, "expected None": 1, "expected fun": 1, "PR position": 1}, "lean_wall_s": 6.533934116363525, "lean_proc_s": 18.835312128067017, "workers": 96, "chunk": 400}
|
| 91 |
+
{"utc": "2026-10-15T02:03:09Z", "samples": 5976, "parse_fail": 4941, "distinct_checked": 1032, "lean_ok": 252, "lean_rej": 780, "parse_reasons": {"unbound": 1711, "no-eos": 1551, "expected (": 1395, "expected ;": 93, "formula": 67, "name": 55, "exact not last": 30, "expected )": 20, "ORE box": 9, "expected exact": 3, "expected fun": 3, "expected :=": 2, "expected None": 1, "PR position": 1}, "lean_wall_s": 5.741062879562378, "lean_proc_s": 15.86197566986084, "workers": 96, "chunk": 400}
|
| 92 |
+
{"utc": "2026-10-15T02:06:03Z", "samples": 5976, "parse_fail": 4995, "distinct_checked": 978, "lean_ok": 217, "lean_rej": 761, "parse_reasons": {"unbound": 1798, "expected (": 1480, "no-eos": 1399, "expected ;": 93, "exact not last": 58, "formula": 56, "name": 48, "expected )": 39, "ORE box": 9, "trailing tokens": 5, "expected fun": 3, "expected exact": 3, "expected None": 2, "PR position": 1, "expected :=": 1}, "lean_wall_s": 5.627358436584473, "lean_proc_s": 14.987157583236694, "workers": 96, "chunk": 400}
|
| 93 |
+
{"utc": "2026-10-15T02:08:58Z", "samples": 12008, "parse_fail": 5220, "distinct_checked": 6776, "lean_ok": 4679, "lean_rej": 2097, "parse_reasons": {"unbound": 2177, "no-eos": 1320, "expected (": 1229, "formula": 158, "expected ;": 111, "name": 106, "exact not last": 63, "ORE box": 25, "expected )": 15, "expected =>": 4, "PR position": 3, "expected fun": 3, "trailing tokens": 2, "expected exact": 2, "expected False": 1, "expected None": 1}, "lean_wall_s": 24.950101613998413, "lean_proc_s": 411.17578506469727, "workers": 96, "chunk": 400}
|
| 94 |
+
{"utc": "2026-10-15T02:10:11Z", "samples": 5856, "parse_fail": 4771, "distinct_checked": 1083, "lean_ok": 117, "lean_rej": 966, "parse_reasons": {"unbound": 1833, "expected (": 1590, "no-eos": 1030, "formula": 97, "expected ;": 69, "name": 59, "exact not last": 42, "expected )": 17, "ORE box": 13, "expected fun": 10, "expected exact": 3, "expected None": 2, "expected :=": 2, "trailing tokens": 2, "expected False": 1, "expected =>": 1}, "lean_wall_s": 6.512022018432617, "lean_proc_s": 18.796499967575073, "workers": 96, "chunk": 400}
|
| 95 |
+
{"utc": "2026-10-15T02:11:41Z", "samples": 5856, "parse_fail": 5080, "distinct_checked": 775, "lean_ok": 116, "lean_rej": 659, "parse_reasons": {"unbound": 2093, "expected (": 1454, "no-eos": 1245, "formula": 83, "name": 56, "expected ;": 55, "exact not last": 37, "ORE box": 21, "expected fun": 15, "expected )": 7, "expected exact": 5, "trailing tokens": 4, "expected :=": 1, "PR position": 1, "expected None": 1, "expected =>": 1, "eof": 1}, "lean_wall_s": 4.594793081283569, "lean_proc_s": 9.028956174850464, "workers": 96, "chunk": 400}
|
| 96 |
+
{"utc": "2026-10-15T02:14:31Z", "samples": 5832, "parse_fail": 4872, "distinct_checked": 955, "lean_ok": 207, "lean_rej": 748, "parse_reasons": {"unbound": 1894, "no-eos": 1461, "expected (": 1202, "expected ;": 81, "name": 65, "formula": 52, "exact not last": 40, "expected )": 32, "expected fun": 23, "ORE box": 18, "expected exact": 2, "PR position": 1, "trailing tokens": 1}, "lean_wall_s": 5.4388110637664795, "lean_proc_s": 13.415225505828857, "workers": 96, "chunk": 400}
|
| 97 |
+
{"utc": "2026-10-15T02:17:23Z", "samples": 12008, "parse_fail": 5461, "distinct_checked": 6530, "lean_ok": 4613, "lean_rej": 1917, "parse_reasons": {"unbound": 2288, "no-eos": 1546, "expected (": 1150, "name": 111, "formula": 92, "expected )": 69, "exact not last": 69, "expected ;": 63, "expected :=": 38, "ORE box": 29, "expected =>": 2, "expected None": 1, "expected False": 1, "eof": 1, "expected fun": 1}, "lean_wall_s": 24.077598094940186, "lean_proc_s": 390.997034072876, "workers": 96, "chunk": 400}
|
| 98 |
+
{"utc": "2026-10-15T02:18:32Z", "samples": 5904, "parse_fail": 4622, "distinct_checked": 1275, "lean_ok": 229, "lean_rej": 1046, "parse_reasons": {"unbound": 1636, "expected (": 1398, "no-eos": 1341, "exact not last": 54, "expected ;": 47, "formula": 47, "name": 45, "expected )": 40, "expected :=": 6, "ORE box": 5, "expected fun": 2, "PR position": 1}, "lean_wall_s": 6.8811163902282715, "lean_proc_s": 21.952274084091187, "workers": 96, "chunk": 400}
|
| 99 |
+
{"utc": "2026-10-15T02:20:11Z", "samples": 5880, "parse_fail": 4840, "distinct_checked": 1038, "lean_ok": 153, "lean_rej": 885, "parse_reasons": {"unbound": 1819, "no-eos": 1396, "expected (": 1374, "name": 56, "exact not last": 51, "formula": 51, "expected ;": 42, "expected :=": 24, "expected )": 12, "ORE box": 11, "expected None": 2, "PR position": 2}, "lean_wall_s": 6.209363698959351, "lean_proc_s": 17.99554419517517, "workers": 96, "chunk": 400}
|
| 100 |
+
{"utc": "2026-10-15T02:23:33Z", "samples": 5880, "parse_fail": 4696, "distinct_checked": 1178, "lean_ok": 208, "lean_rej": 970, "parse_reasons": {"unbound": 1652, "no-eos": 1448, "expected (": 1335, "name": 68, "exact not last": 56, "expected ;": 42, "formula": 34, "expected )": 27, "expected :=": 25, "ORE box": 7, "PR position": 2}, "lean_wall_s": 6.697340488433838, "lean_proc_s": 19.904075145721436, "workers": 96, "chunk": 400}
|
| 101 |
+
{"utc": "2026-10-15T02:26:31Z", "samples": 12016, "parse_fail": 5705, "distinct_checked": 6290, "lean_ok": 4565, "lean_rej": 1725, "parse_reasons": {"unbound": 2434, "expected (": 1442, "no-eos": 1377, "formula": 124, "expected ;": 97, "name": 82, "exact not last": 59, "expected )": 58, "ORE box": 14, "expected :=": 9, "expected =>": 4, "expected None": 3, "PR position": 2}, "lean_wall_s": 23.532408952713013, "lean_proc_s": 366.5979652404785, "workers": 96, "chunk": 400}
|
| 102 |
+
{"utc": "2026-10-15T02:27:38Z", "samples": 5856, "parse_fail": 4968, "distinct_checked": 884, "lean_ok": 78, "lean_rej": 806, "parse_reasons": {"unbound": 2018, "expected (": 1382, "no-eos": 1247, "expected ;": 108, "exact not last": 66, "expected )": 51, "name": 50, "formula": 31, "ORE box": 11, "expected =>": 3, "expected :=": 1}, "lean_wall_s": 5.363447904586792, "lean_proc_s": 12.445549488067627, "workers": 96, "chunk": 400}
|
| 103 |
+
{"utc": "2026-10-15T02:29:21Z", "samples": 5856, "parse_fail": 5118, "distinct_checked": 736, "lean_ok": 168, "lean_rej": 568, "parse_reasons": {"unbound": 2028, "no-eos": 1585, "expected (": 1215, "expected ;": 105, "name": 66, "exact not last": 59, "formula": 22, "expected )": 15, "ORE box": 14, "expected =>": 5, "expected exact": 1, "expected None": 1, "PR position": 1, "trailing tokens": 1}, "lean_wall_s": 4.185610055923462, "lean_proc_s": 8.165008544921875, "workers": 96, "chunk": 400}
|
| 104 |
+
{"utc": "2026-10-15T02:32:38Z", "samples": 5856, "parse_fail": 5144, "distinct_checked": 709, "lean_ok": 151, "lean_rej": 558, "parse_reasons": {"unbound": 1999, "no-eos": 1492, "expected (": 1322, "expected ;": 119, "name": 69, "exact not last": 57, "formula": 41, "expected )": 22, "ORE box": 13, "expected :=": 4, "expected None": 2, "PR position": 2, "expected fun": 1, "expected =>": 1}, "lean_wall_s": 4.187517404556274, "lean_proc_s": 7.774197816848755, "workers": 96, "chunk": 400}
|
| 105 |
+
{"utc": "2026-10-15T02:35:37Z", "samples": 11984, "parse_fail": 5526, "distinct_checked": 6435, "lean_ok": 4560, "lean_rej": 1875, "parse_reasons": {"unbound": 2136, "expected (": 1646, "no-eos": 1341, "formula": 114, "name": 88, "expected ;": 75, "exact not last": 62, "ORE box": 40, "expected )": 13, "trailing tokens": 5, "expected :=": 4, "PR position": 1, "expected fun": 1}, "lean_wall_s": 23.807654857635498, "lean_proc_s": 362.7413990497589, "workers": 96, "chunk": 400}
|
| 106 |
+
{"utc": "2026-10-15T02:36:43Z", "samples": 6048, "parse_fail": 5054, "distinct_checked": 989, "lean_ok": 160, "lean_rej": 829, "parse_reasons": {"expected (": 1959, "unbound": 1837, "no-eos": 1013, "exact not last": 52, "formula": 50, "expected ;": 47, "name": 45, "ORE box": 27, "expected )": 15, "expected :=": 4, "PR position": 2, "trailing tokens": 2, "expected fun": 1}, "lean_wall_s": 2.987677812576294, "lean_proc_s": 7.391435146331787, "workers": 96, "chunk": 400}
|
| 107 |
+
{"utc": "2026-10-15T02:38:22Z", "samples": 6048, "parse_fail": 5020, "distinct_checked": 1025, "lean_ok": 147, "lean_rej": 878, "parse_reasons": {"unbound": 1829, "expected (": 1638, "no-eos": 1295, "name": 63, "expected ;": 54, "exact not last": 47, "formula": 32, "expected )": 21, "expected :=": 21, "ORE box": 11, "expected =>": 6, "trailing tokens": 1, "PR position": 1, "expected False": 1}, "lean_wall_s": 5.5577614307403564, "lean_proc_s": 15.642215490341187, "workers": 96, "chunk": 400}
|
| 108 |
+
{"utc": "2026-10-15T02:41:49Z", "samples": 6048, "parse_fail": 4974, "distinct_checked": 1068, "lean_ok": 250, "lean_rej": 818, "parse_reasons": {"unbound": 1859, "expected (": 1521, "no-eos": 1267, "expected ;": 81, "formula": 76, "name": 64, "exact not last": 53, "ORE box": 20, "expected )": 14, "expected :=": 13, "PR position": 3, "expected =>": 2, "trailing tokens": 1}, "lean_wall_s": 5.900589942932129, "lean_proc_s": 16.97165298461914, "workers": 96, "chunk": 400}
|
| 109 |
+
{"utc": "2026-10-15T02:44:51Z", "samples": 12000, "parse_fail": 5085, "distinct_checked": 6894, "lean_ok": 4465, "lean_rej": 2429, "parse_reasons": {"unbound": 2061, "no-eos": 1335, "expected (": 1329, "name": 107, "formula": 85, "exact not last": 76, "expected )": 28, "expected ;": 25, "ORE box": 24, "expected :=": 9, "expected None": 2, "expected =>": 1, "expected exact": 1, "expected False": 1, "trailing tokens": 1}, "lean_wall_s": 25.630682945251465, "lean_proc_s": 437.2988407611847, "workers": 96, "chunk": 400}
|
| 110 |
+
{"utc": "2026-10-15T02:46:12Z", "samples": 6120, "parse_fail": 4999, "distinct_checked": 1117, "lean_ok": 196, "lean_rej": 921, "parse_reasons": {"expected (": 2020, "unbound": 1603, "no-eos": 1136, "formula": 50, "exact not last": 49, "name": 47, "expected )": 36, "expected ;": 29, "expected :=": 20, "ORE box": 7, "expected =>": 1, "expected exact": 1}, "lean_wall_s": 6.1320881843566895, "lean_proc_s": 17.949915885925293, "workers": 96, "chunk": 400}
|
| 111 |
+
{"utc": "2026-10-15T02:47:40Z", "samples": 6120, "parse_fail": 4997, "distinct_checked": 1123, "lean_ok": 234, "lean_rej": 889, "parse_reasons": {"expected (": 1692, "unbound": 1672, "no-eos": 1445, "name": 49, "formula": 44, "exact not last": 40, "expected ;": 26, "expected )": 15, "ORE box": 11, "expected exact": 2, "PR position": 1}, "lean_wall_s": 6.467487573623657, "lean_proc_s": 19.11111354827881, "workers": 96, "chunk": 400}
|
| 112 |
+
{"utc": "2026-10-15T02:50:43Z", "samples": 6096, "parse_fail": 5069, "distinct_checked": 1020, "lean_ok": 267, "lean_rej": 753, "parse_reasons": {"expected (": 1660, "no-eos": 1615, "unbound": 1597, "name": 53, "exact not last": 46, "formula": 45, "expected ;": 28, "expected )": 11, "ORE box": 10, "expected exact": 1, "expected None": 1, "PR position": 1, "expected =>": 1}, "lean_wall_s": 5.702097654342651, "lean_proc_s": 15.030066728591919, "workers": 96, "chunk": 400}
|
| 113 |
+
{"utc": "2026-10-15T02:53:41Z", "samples": 12000, "parse_fail": 5594, "distinct_checked": 6388, "lean_ok": 4297, "lean_rej": 2091, "parse_reasons": {"unbound": 2143, "expected (": 1613, "no-eos": 1485, "name": 98, "formula": 76, "expected )": 71, "exact not last": 42, "ORE box": 27, "expected ;": 25, "expected :=": 7, "trailing tokens": 3, "expected None": 3, "expected =>": 1}, "lean_wall_s": 23.637762308120728, "lean_proc_s": 369.39775824546814, "workers": 96, "chunk": 400}
|
| 114 |
+
{"utc": "2026-10-15T02:55:00Z", "samples": 6072, "parse_fail": 5185, "distinct_checked": 883, "lean_ok": 123, "lean_rej": 760, "parse_reasons": {"no-eos": 1649, "expected (": 1649, "unbound": 1547, "expected )": 169, "name": 67, "exact not last": 37, "formula": 26, "expected ;": 18, "ORE box": 14, "expected :=": 5, "PR position": 1, "expected =>": 1, "expected None": 1, "expected fun": 1}, "lean_wall_s": 5.644366264343262, "lean_proc_s": 13.173078060150146, "workers": 96, "chunk": 400}
|
| 115 |
+
{"utc": "2026-10-15T02:56:50Z", "samples": 6072, "parse_fail": 5083, "distinct_checked": 982, "lean_ok": 320, "lean_rej": 662, "parse_reasons": {"no-eos": 1946, "expected (": 1607, "unbound": 1288, "expected )": 98, "name": 49, "exact not last": 31, "expected ;": 21, "expected =>": 16, "ORE box": 11, "formula": 10, "expected :=": 4, "expected None": 2}, "lean_wall_s": 5.626194000244141, "lean_proc_s": 14.429756164550781, "workers": 96, "chunk": 400}
|
| 116 |
+
{"utc": "2026-10-15T02:59:18Z", "samples": 6072, "parse_fail": 5112, "distinct_checked": 955, "lean_ok": 199, "lean_rej": 756, "parse_reasons": {"no-eos": 1952, "expected (": 1470, "unbound": 1386, "expected )": 75, "name": 74, "ORE box": 46, "expected ;": 39, "formula": 29, "exact not last": 26, "expected =>": 10, "expected :=": 3, "expected \u27e9": 2}, "lean_wall_s": 5.454128742218018, "lean_proc_s": 13.959436416625977, "workers": 96, "chunk": 400}
|
| 117 |
+
{"utc": "2026-10-15T03:02:11Z", "samples": 11992, "parse_fail": 5502, "distinct_checked": 6477, "lean_ok": 4197, "lean_rej": 2280, "parse_reasons": {"unbound": 2060, "no-eos": 1550, "expected (": 1443, "expected ;": 89, "name": 84, "expected )": 72, "exact not last": 71, "formula": 69, "expected =>": 20, "ORE box": 20, "expected :=": 17, "PR position": 3, "trailing tokens": 2, "expected None": 1, "expected fun": 1}, "lean_wall_s": 24.76737880706787, "lean_proc_s": 396.7694878578186, "workers": 96, "chunk": 400}
|
| 118 |
+
{"utc": "2026-10-15T03:03:20Z", "samples": 6168, "parse_fail": 4860, "distinct_checked": 1302, "lean_ok": 183, "lean_rej": 1119, "parse_reasons": {"expected (": 1707, "no-eos": 1485, "unbound": 1418, "expected )": 67, "name": 52, "exact not last": 41, "formula": 37, "expected ;": 24, "ORE box": 17, "expected fun": 4, "expected =>": 2, "expected None": 2, "PR position": 1, "expected exact": 1, "trailing tokens": 1, "expected :=": 1}, "lean_wall_s": 7.262990236282349, "lean_proc_s": 24.10919952392578, "workers": 96, "chunk": 400}
|
| 119 |
+
{"utc": "2026-10-15T03:04:58Z", "samples": 6144, "parse_fail": 5140, "distinct_checked": 1003, "lean_ok": 221, "lean_rej": 782, "parse_reasons": {"expected (": 1960, "unbound": 1493, "no-eos": 1481, "name": 54, "exact not last": 42, "expected ;": 36, "expected )": 31, "formula": 17, "ORE box": 13, "expected fun": 5, "expected =>": 2, "expected :=": 2, "expected None": 1, "expected False": 1, "eof": 1, "PR position": 1}, "lean_wall_s": 6.2986977100372314, "lean_proc_s": 17.252012491226196, "workers": 96, "chunk": 400}
|
| 120 |
+
{"utc": "2026-10-15T03:07:54Z", "samples": 6144, "parse_fail": 5088, "distinct_checked": 1051, "lean_ok": 215, "lean_rej": 836, "parse_reasons": {"no-eos": 1701, "expected (": 1626, "unbound": 1575, "name": 57, "expected ;": 42, "exact not last": 40, "formula": 23, "ORE box": 11, "expected )": 5, "expected None": 2, "expected =>": 2, "expected fun": 2, "PR position": 1, "trailing tokens": 1}, "lean_wall_s": 5.638453483581543, "lean_proc_s": 16.279438257217407, "workers": 96, "chunk": 400}
|
| 121 |
+
{"utc": "2026-10-15T03:51:31Z", "samples": 53952, "parse_fail": 32385, "distinct_checked": 21132, "lean_ok": 16259, "lean_rej": 4873, "parse_reasons": {"no-eos": 12483, "expected (": 9489, "unbound": 7365, "formula": 1475, "name": 583, "exact not last": 443, "expected ;": 249, "expected )": 121, "ORE box": 50, "expected :=": 43, "expected fun": 29, "PR position": 26, "expected exact": 11, "expected None": 11, "eof": 5, "expected False": 1, "expected =>": 1}, "lean_wall_s": 70.2880790233612, "lean_proc_s": 3543.5801067352295, "workers": 96, "chunk": 400}
|
| 122 |
+
{"utc": "2026-10-15T03:54:21Z", "samples": 17728, "parse_fail": 3580, "distinct_checked": 14044, "lean_ok": 12335, "lean_rej": 1709, "parse_reasons": {"no-eos": 1754, "unbound": 1511, "name": 98, "expected (": 95, "formula": 38, "expected )": 31, "exact not last": 23, "expected :=": 11, "expected ;": 9, "ORE box": 4, "expected exact": 2, "expected None": 2, "trailing tokens": 1, "expected =>": 1}, "lean_wall_s": 39.376174449920654, "lean_proc_s": 1342.4416501522064, "workers": 96, "chunk": 400}
|
| 123 |
+
{"utc": "2026-10-15T04:08:44Z", "samples": 53952, "parse_fail": 32988, "distinct_checked": 20461, "lean_ok": 14976, "lean_rej": 5485, "parse_reasons": {"no-eos": 13058, "expected (": 8722, "unbound": 7677, "formula": 1950, "exact not last": 478, "name": 471, "expected ;": 246, "expected )": 229, "ORE box": 83, "expected :=": 22, "expected fun": 15, "expected None": 13, "PR position": 13, "expected exact": 5, "eof": 2, "expected False": 2, "trailing tokens": 1, "expected \u27e9": 1}, "lean_wall_s": 68.75238013267517, "lean_proc_s": 3361.181354045868, "workers": 96, "chunk": 400}
|
runs/long-rl-20261014-v5_looped-ei_s0/rl_round_005.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cdf65e2b752cbea9655f5a0fd631073b7c6140190dd7c6a93c0cc20e9a8e3fdb
|
| 3 |
+
size 38584655
|
runs/long-rl-20261014-v5_looped-ei_s0/rl_round_010.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f21506c4986136bce7c5b207c5eeffa8417ff8bd696f3b21cf3b1bfac242f068
|
| 3 |
+
size 38584655
|
runs/long-rl-20261014-v5_looped-ei_s0/rl_round_015.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a38f56009134f508845b4bd6fd52b5208192c90ead7c8d57faa210f1f2ffa0f
|
| 3 |
+
size 38584655
|
runs/long-rl-20261014-v5_looped-ei_s0/rl_round_020.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a563079196952a22aa04b865b577a7ba10f28c0d9e2eaa7866840dc40ad2291a
|
| 3 |
+
size 38584655
|
runs/long-rl-20261014-v5_looped-ei_s0/rl_round_025.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78853341e40fd8b8511d2c46c88ff52d55b3d89ea0fd16ef04e29240ec0a5ac7
|
| 3 |
+
size 38584655
|
runs/long-rl-20261014-v5_looped-ei_s0/rl_round_030.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2038c9f910e690f0f645c76ad4ef08c804aff0833495d835c343bc96631b2d07
|
| 3 |
+
size 38584655
|
runs/long-rl-20261014-v5_looped-ei_s0/source/harness.py
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# imports the fork (model, tokenizer, train, ...), which is not resolvable here
|
| 3 |
+
# pyright: reportMissingImports=false
|
| 4 |
+
"""Harness for long_rl_20261014: pretrain on <= 6 body lines, then RL on the long-proofs set (body 7 to ~45).
|
| 5 |
+
|
| 6 |
+
Forked from the test-time-loops harness (autoresearch_loops/harness.py, sha 2eec1b61666a, the one run 590 and 512 were
|
| 7 |
+
scored with). What changed (Robbie, 2026-10-14):
|
| 8 |
+
|
| 9 |
+
- Lean is the only checker: overlay/lean_gate.py, and a sample counts iff Lean accepts its literal text. nd_verify is
|
| 10 |
+
never called; the decoded ND proof is used only to count lines.
|
| 11 |
+
- Length is body lines (proof lines after the premise block) everywhere: bands, L*, the pretraining cap.
|
| 12 |
+
- Tokenizer: overlay/lean_tok.py (ten atoms, ten premises, 160 names). The overlay directory is first on sys.path.
|
| 13 |
+
- Data (make_data.py): pretraining = Dan's cap-6 file with distractor premises; RL targets / dev / holdout = the
|
| 14 |
+
long-proofs set, band-capped. The old transfer dev pool is evaluated too (EVAL_K_OLD samples), to catch forgetting.
|
| 15 |
+
- The oracle also returns every rollout (token ids and the Lean verdict) for the GRPO arm: sample_rollouts().
|
| 16 |
+
- Sampling batch size follows the model's KV-cache depth (model.kv_layers()), so 8-loop sampling fits an A40.
|
| 17 |
+
|
| 18 |
+
1. pretrain.pretrain(train_recs, PRETRAIN_SECS, ...) -> (model, tok, stats), charged for everything
|
| 19 |
+
2. checks: params <= PARAM_CAP, tok.mode == TOK_MODE, model has an integer KNOB
|
| 20 |
+
3. pretrain.rl(model, tok, targets, train_recs, oracle, RL_SECS, ...): the arm's RL. RL_SECS is wall-clock inside rl()
|
| 21 |
+
minus Lean-gate time.
|
| 22 |
+
4. eval: dev (long-proofs set) with EVAL_K samples at EVAL_LEVEL, by band; old transfer dev with EVAL_K_OLD samples
|
| 23 |
+
5. SIGALRM at TOTAL_SECS
|
| 24 |
+
|
| 25 |
+
python3 harness.py --out artifacts/x [--seed 0] # on the pod (remote.sh)
|
| 26 |
+
ND_FORK=... python3 harness.py --out /tmp/smoke --smoke # CPU plumbing check with real Lean
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
import argparse
|
| 30 |
+
import collections
|
| 31 |
+
import gzip
|
| 32 |
+
import hashlib
|
| 33 |
+
import importlib
|
| 34 |
+
import json
|
| 35 |
+
import os
|
| 36 |
+
import random
|
| 37 |
+
import shutil
|
| 38 |
+
import signal
|
| 39 |
+
import sys
|
| 40 |
+
import time
|
| 41 |
+
import traceback
|
| 42 |
+
from pathlib import Path
|
| 43 |
+
|
| 44 |
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 45 |
+
FORK = os.environ.get("ND_FORK", "/workspace/nd-takehome")
|
| 46 |
+
DATA = os.environ.get("ND_DATA", os.path.join(HERE, "data"))
|
| 47 |
+
# overlay first (tokenizer, Lean-only gate), then the fork (model, sample, train), then this directory (pretrain.py)
|
| 48 |
+
sys.path[:0] = [os.path.join(HERE, "overlay"), FORK, HERE]
|
| 49 |
+
import importlib.util # noqa: E402
|
| 50 |
+
|
| 51 |
+
import torch # noqa: E402
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _overlay(name):
|
| 55 |
+
"""Load overlay/<name>.py under the module name the fork imports. Fork modules put the fork directory at
|
| 56 |
+
sys.path[0] whenever they are imported (nd2lean does, inside lean_tok), so path order alone is not enough:
|
| 57 |
+
registering the module in sys.modules first is what makes every later `import lean_tok` get the overlay."""
|
| 58 |
+
spec = importlib.util.spec_from_file_location(name, os.path.join(HERE, "overlay", f"{name}.py"))
|
| 59 |
+
mod = importlib.util.module_from_spec(spec)
|
| 60 |
+
sys.modules[name] = mod
|
| 61 |
+
spec.loader.exec_module(mod)
|
| 62 |
+
return mod
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
_overlay("lean_tok")
|
| 66 |
+
gate = _overlay("lean_gate").gate
|
| 67 |
+
from eval_set import wilson # noqa: E402 (fork; wilson interval only)
|
| 68 |
+
from nd_verify.verify import parse_proof_tokens # noqa: E402 (a parser: line counts only, never a verdict)
|
| 69 |
+
from sample import generate_ids # noqa: E402 (fork)
|
| 70 |
+
|
| 71 |
+
# ---------------------------------------------------------------- the rules
|
| 72 |
+
TOTAL_SECS = int(os.environ.get("ND_TOTAL_SECS", 6.5 * 3600)) # RL_SECS excludes Lean-gate time (~80 s a round)
|
| 73 |
+
PRETRAIN_SECS = 600 # Dan's file with distractors is ~1.6x the tokens of the plain cap-6 file
|
| 74 |
+
PRETRAIN_GRACE = 30
|
| 75 |
+
RL_SECS = int(os.environ.get("ND_RL_SECS", 3 * 3600))
|
| 76 |
+
RL_GRACE = 120
|
| 77 |
+
PARAM_CAP = 10_000_000
|
| 78 |
+
TEMP = 0.8
|
| 79 |
+
MAX_NEW = 2304 # proof tokens: approach E's 80-line references run to ~1,900; checked against the pools at load
|
| 80 |
+
KV_TOKENS = 1024 * 6 * 1700 # sampling batch * KV layers * tokens: 6 layers x 1,024 x 1,700 is ~16 GB of bf16 KV
|
| 81 |
+
EVAL_K, EVAL_K_OLD = 64, 16
|
| 82 |
+
KNOB = "n_loops"
|
| 83 |
+
EVAL_LEVEL, DIAG_LEVEL = int(os.environ.get("ND_EVAL_LEVEL", 8)), 2
|
| 84 |
+
TOK_MODE = "lean_seq"
|
| 85 |
+
BANDS = ((0, 6), (7, 9), (10, 14), (15, 19), (20, 24), (25, 34), (35, 49), (50, 200))
|
| 86 |
+
DEV = "cuda" if torch.cuda.is_available() else "cpu"
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def read(fn):
|
| 90 |
+
op = gzip.open if fn.endswith(".gz") else open
|
| 91 |
+
return [json.loads(line) for line in op(fn, "rt") if line.strip()]
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def log(msg):
|
| 95 |
+
print(f"[{time.strftime('%H:%M:%S')}] {msg}", flush=True)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def sha(fn):
|
| 99 |
+
return hashlib.sha256(open(fn, "rb").read()).hexdigest()[:12]
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def band(body):
|
| 103 |
+
return next(f"{lo}-{hi}" if hi < 200 else f"{lo}+" for lo, hi in BANDS if lo <= body <= hi)
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class Timeout(Exception):
|
| 107 |
+
pass
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
class BudgetSpent(Timeout):
|
| 111 |
+
pass
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# ---------------------------------------------------------------- sampling and judging
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def body_lines(nd):
|
| 118 |
+
"""(written body lines, pruned body lines) of a decoded ND proof: lines after the premise block, and those the
|
| 119 |
+
last line depends on through citations (a box rule cites the box's first and last lines, so the closure keeps a
|
| 120 |
+
needed box's hypothesis and every line its conclusion depends on)."""
|
| 121 |
+
lines = parse_proof_tokens(nd.split())
|
| 122 |
+
by = {ln["idx"]: ln for ln in lines}
|
| 123 |
+
need, todo = set(), [lines[-1]["idx"]]
|
| 124 |
+
while todo:
|
| 125 |
+
i = todo.pop()
|
| 126 |
+
if i not in need:
|
| 127 |
+
need.add(i)
|
| 128 |
+
todo += by[i]["refs"]
|
| 129 |
+
body = [ln for ln in lines if ln["rule"] != "PR"]
|
| 130 |
+
return len(body), sum(1 for ln in body if ln["idx"] in need)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def kv_batch(model, n_tokens):
|
| 134 |
+
layers = model.kv_layers() if hasattr(model, "kv_layers") else len(model.blocks)
|
| 135 |
+
return max(32, min(1024, KV_TOKENS // (layers * n_tokens)))
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def new_tokens(body, max_new):
|
| 139 |
+
"""Sampling cap for a target of `body` lines: reference proofs run up to ~23 tokens per body line (16 for most), so
|
| 140 |
+
64 + 30 per line leaves >= 1.3x room, and a sample rambling without <eos> no longer holds a whole batch to max_new.
|
| 141 |
+
Rounded up to a multiple of 128 so that a few caps group the samples into full batches."""
|
| 142 |
+
return min(max_new, -(-(64 + 30 * body) // 128) * 128)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def sample(model, tok, recs, k, seed, max_new):
|
| 146 |
+
"""k samples per record at temperature TEMP. Returns per record a list of (ids, decoded ND proof, accepted)."""
|
| 147 |
+
prompts = [r["prompt"] for r in recs for _ in range(k)]
|
| 148 |
+
caps = [new_tokens(r["body"], max_new) for r in recs for _ in range(k)]
|
| 149 |
+
ids = [tok.encode_prompt(p) for p in prompts]
|
| 150 |
+
gen = torch.Generator(device=DEV)
|
| 151 |
+
gen.manual_seed(seed)
|
| 152 |
+
outs, nds, texts = [None] * len(prompts), [None] * len(prompts), [None] * len(prompts)
|
| 153 |
+
for cap in sorted(set(caps)):
|
| 154 |
+
order = sorted((i for i in range(len(prompts)) if caps[i] == cap), key=lambda i: len(ids[i]))
|
| 155 |
+
batch = kv_batch(model, len(ids[order[-1]]) + cap)
|
| 156 |
+
for s in range(0, len(order), batch):
|
| 157 |
+
chunk = order[s : s + batch]
|
| 158 |
+
with torch.autocast("cuda", dtype=torch.bfloat16, enabled=(DEV == "cuda")):
|
| 159 |
+
res = generate_ids(model, tok, [ids[i] for i in chunk], False, TEMP, cap, gen)
|
| 160 |
+
for i, o in zip(chunk, res, strict=True):
|
| 161 |
+
o = o[: o.index(tok.eos) + 1] if tok.eos in o else o
|
| 162 |
+
outs[i], nds[i], texts[i] = o, tok.decode(o), tok.last_text
|
| 163 |
+
if DEV == "cuda":
|
| 164 |
+
torch.cuda.empty_cache()
|
| 165 |
+
gated = gate(tok, prompts, nds, texts)
|
| 166 |
+
flat = [(o, nd, not nd.startswith("LEAN")) for o, nd in zip(outs, gated, strict=True)]
|
| 167 |
+
return [flat[i * k : (i + 1) * k] for i in range(len(recs))]
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def judge(recs, per):
|
| 171 |
+
rows = []
|
| 172 |
+
for r, samples in zip(recs, per, strict=True):
|
| 173 |
+
good = {}
|
| 174 |
+
for _, nd, ok in samples:
|
| 175 |
+
if ok and nd not in good:
|
| 176 |
+
good[nd] = body_lines(nd)
|
| 177 |
+
rows.append({"name": r["name"], "body": r["body"], "solved": bool(good), "n_ok": sum(ok for *_, ok in samples),
|
| 178 |
+
"n_tried": len(samples), "proofs": list(good), "written": [w for w, _ in good.values()],
|
| 179 |
+
"pruned": [p for _, p in good.values()]})
|
| 180 |
+
return rows
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def lstar(solved, recs, need=5):
|
| 184 |
+
ls = [r["body"] for r in recs if r["name"] in solved]
|
| 185 |
+
ge = {L: sum(1 for x in ls if x >= L) for L in range(7, 81)}
|
| 186 |
+
return max([L for L, c in ge.items() if c >= need], default=0), ge
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def by_band(solved, recs):
|
| 190 |
+
by = collections.defaultdict(lambda: [0, 0])
|
| 191 |
+
for r in recs:
|
| 192 |
+
by[band(r["body"])][0] += r["name"] in solved
|
| 193 |
+
by[band(r["body"])][1] += 1
|
| 194 |
+
return {b: {"solved": k, "n": n, "rate": k / n, "ci": list(wilson(k, n))} for b, (k, n) in sorted(by.items())}
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def gate_seconds():
|
| 198 |
+
fn = os.environ.get("LEAN_GATE_LOG")
|
| 199 |
+
return sum(r["lean_wall_s"] for r in read(fn)) if fn and os.path.exists(fn) else 0.0
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
# ---------------------------------------------------------------- the RL oracle
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class Oracle:
|
| 206 |
+
"""What rl() gets instead of data: the model's own attempts at the RL targets, judged by Lean."""
|
| 207 |
+
|
| 208 |
+
def __init__(self, a, tok, targets, found=None, call0=0):
|
| 209 |
+
self.a, self.tok = a, tok
|
| 210 |
+
self.targets = {t["name"]: t for t in targets}
|
| 211 |
+
self.found = collections.defaultdict(dict) # name -> {proof text: {written, pruned, round}}
|
| 212 |
+
self.found.update(found or {}) # a resumed run's earlier proofs
|
| 213 |
+
self.call0 = call0 # a resumed run's earlier oracle calls: call numbers and sampling seeds continue
|
| 214 |
+
self.calls = []
|
| 215 |
+
self.t0 = self.last = time.time()
|
| 216 |
+
self.uncharged = 0.0
|
| 217 |
+
|
| 218 |
+
def used(self):
|
| 219 |
+
return time.time() - self.t0 - self.uncharged
|
| 220 |
+
|
| 221 |
+
def left(self):
|
| 222 |
+
return self.a.rl_secs - self.used()
|
| 223 |
+
|
| 224 |
+
def _sample(self, model, targets, k):
|
| 225 |
+
if self.left() <= 0:
|
| 226 |
+
raise BudgetSpent(f"oracle called with {self.used():.0f}s of {self.a.rl_secs}s used")
|
| 227 |
+
recs = [self.targets[t["name"]] for t in targets]
|
| 228 |
+
call = self.call0 + len(self.calls) + 1
|
| 229 |
+
model.eval()
|
| 230 |
+
t0, g0 = time.time(), gate_seconds()
|
| 231 |
+
per = sample(model, self.tok, recs, k, self.a.seed * 100_000 + call, self.a.max_new)
|
| 232 |
+
secs, gate_s = time.time() - t0, gate_seconds() - g0
|
| 233 |
+
self.uncharged += gate_s
|
| 234 |
+
rows = judge(recs, per)
|
| 235 |
+
new = 0
|
| 236 |
+
for t, row in zip(recs, rows, strict=True):
|
| 237 |
+
for p, w, pl in zip(row["proofs"], row["written"], row["pruned"], strict=True):
|
| 238 |
+
if p not in self.found[t["name"]]:
|
| 239 |
+
self.found[t["name"]][p] = {"written": w, "pruned": pl, "round": call}
|
| 240 |
+
new += 1
|
| 241 |
+
solved = {n for n, d in self.found.items() if d}
|
| 242 |
+
ls, _ = lstar(solved, list(self.targets.values()))
|
| 243 |
+
n = len(recs) * k
|
| 244 |
+
self.calls.append({"round": call, "level": getattr(model, KNOB, None), "k": k, "n_targets": len(recs),
|
| 245 |
+
"sample_acc": sum(x["n_ok"] for x in rows) / max(n, 1), "new_proofs": new,
|
| 246 |
+
"targets_solved": len(solved), "lstar": ls,
|
| 247 |
+
"solved_by_band": {b: v["solved"] for b, v in by_band(solved, list(self.targets.values())).items()},
|
| 248 |
+
"sampling": {"samples": n, "secs": secs, "gate_secs": gate_s},
|
| 249 |
+
"secs": time.time() - self.last, "rl_secs_used": self.used()})
|
| 250 |
+
self.last = time.time()
|
| 251 |
+
c = self.calls[-1]
|
| 252 |
+
log(f"oracle {call}: acc {c['sample_acc']:.4f}, +{new} proofs, solved {len(solved)}/{len(self.targets)}, "
|
| 253 |
+
f"L*={ls}, {KNOB} {c['level']}, {len(recs)} targets x {k}, {n / secs:.0f} samples/s, "
|
| 254 |
+
f"RL clock {c['rl_secs_used']:.0f}/{self.a.rl_secs}s")
|
| 255 |
+
return recs, per, rows
|
| 256 |
+
|
| 257 |
+
def sample(self, model, targets, k):
|
| 258 |
+
"""k attempts per target. Returns per target {name, prompt, body, proofs (distinct Lean-accepted ND proofs),
|
| 259 |
+
n_ok, n_tried}. Raises BudgetSpent once the budget is used up."""
|
| 260 |
+
recs, _, rows = self._sample(model, targets, k)
|
| 261 |
+
return [{"name": t["name"], "prompt": t["prompt"], "body": t["body"], "proofs": row["proofs"],
|
| 262 |
+
"n_ok": row["n_ok"], "n_tried": row["n_tried"]} for t, row in zip(recs, rows, strict=True)]
|
| 263 |
+
|
| 264 |
+
def sample_rollouts(self, model, targets, k):
|
| 265 |
+
"""As sample(), plus `rollouts`: every attempt's proof token ids (eos included when the model ended it) and
|
| 266 |
+
its Lean verdict, for policy-gradient RL."""
|
| 267 |
+
recs, per, rows = self._sample(model, targets, k)
|
| 268 |
+
return [{"name": t["name"], "prompt": t["prompt"], "body": t["body"], "proofs": row["proofs"],
|
| 269 |
+
"n_ok": row["n_ok"], "n_tried": row["n_tried"], "rollouts": [(o, ok) for o, _, ok in samples]}
|
| 270 |
+
for t, row, samples in zip(recs, rows, per, strict=True)]
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
# ---------------------------------------------------------------- stages
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def load_resume(a, targets):
|
| 277 |
+
"""A finished run's directory (final.pt, pretrain.pt, found_targets.jsonl, summary.json) -> (final state, pretrained
|
| 278 |
+
state, found proofs of current targets as Oracle.found entries, earlier oracle calls, earlier RL seconds)."""
|
| 279 |
+
final = torch.load(f"{a.resume}/final.pt", map_location=DEV)
|
| 280 |
+
pre = torch.load(f"{a.resume}/pretrain.pt", map_location=DEV)
|
| 281 |
+
arm = {k: os.environ.get(k) for k in ("ND_ARCH", "ND_RL")}
|
| 282 |
+
assert final["arm"] == arm and final["seed"] == a.seed, (final["arm"], final["seed"], arm, a.seed)
|
| 283 |
+
names = {t["name"] for t in targets}
|
| 284 |
+
found = collections.defaultdict(dict)
|
| 285 |
+
for r in read(f"{a.resume}/found_targets.jsonl"):
|
| 286 |
+
if r["name"] in names:
|
| 287 |
+
found[r["name"]][r["proof"]] = {k: r[k] for k in ("written", "pruned", "round")}
|
| 288 |
+
prior = json.load(open(f"{a.resume}/summary.json"))["rl"]
|
| 289 |
+
return final["state"], pre["state"], found, len(prior["rounds"]), prior["rl_secs_used"]
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def stage_rl(a, agent, tok, model, targets, train_recs, dev, resume=None):
|
| 293 |
+
found, call0 = (resume["found"], resume["calls"]) if resume else (None, 0)
|
| 294 |
+
oracle = Oracle(a, tok, targets, found, call0)
|
| 295 |
+
oracle.gold = dev # gold dev proofs, for the RL probes' likelihood only; never trained on
|
| 296 |
+
oracle.pretrained_state = resume["pretrained"] if resume else None # the probes' pretrained reference
|
| 297 |
+
visible = [{"name": t["name"], "prompt": t["prompt"], "body": t["body"], "band": t["band"]} for t in targets]
|
| 298 |
+
stats = agent.rl(model, tok, visible, train_recs, oracle, a.rl_secs, DEV, a.seed, log)
|
| 299 |
+
if DEV == "cuda":
|
| 300 |
+
torch.cuda.synchronize()
|
| 301 |
+
model.eval()
|
| 302 |
+
with open(f"{a.out}/found_targets.jsonl", "w") as f:
|
| 303 |
+
for t in targets:
|
| 304 |
+
for p, x in oracle.found[t["name"]].items():
|
| 305 |
+
f.write(json.dumps({"name": t["name"], "prompt": t["prompt"], "body": t["body"], "proof": p, **x}) + "\n")
|
| 306 |
+
used = oracle.used()
|
| 307 |
+
log(f"rl returned: {used:.0f}s of {a.rl_secs}s charged, {oracle.uncharged:.0f}s Lean gate")
|
| 308 |
+
return {"rounds": oracle.calls, "secs": time.time() - oracle.t0, "rl_secs_used": used,
|
| 309 |
+
"gate_secs": oracle.uncharged, "targets": len(targets), "stats": dict(stats or {})}
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
def eval_pool(a, tok, model, pool, k, level, tag):
|
| 313 |
+
setattr(model, KNOB, level)
|
| 314 |
+
model.eval()
|
| 315 |
+
t0 = time.time()
|
| 316 |
+
rows = judge(pool, sample(model, tok, pool, k, a.seed * 100_000 + 7777, a.max_new))
|
| 317 |
+
solved = {r["name"] for r in rows if r["solved"]}
|
| 318 |
+
ls, _ = lstar(solved, pool)
|
| 319 |
+
out = {"level": level, "k": k, "solved": len(solved), "n": len(pool), "lstar": ls, "by_band": by_band(solved, pool),
|
| 320 |
+
"sample_acc": sum(r["n_ok"] for r in rows) / max(k * len(pool), 1),
|
| 321 |
+
"max_pruned": max((max(r["pruned"]) for r in rows if r["solved"]), default=0), "secs": time.time() - t0}
|
| 322 |
+
with open(f"{a.out}/eval_{tag}.jsonl", "w") as f:
|
| 323 |
+
for r in rows:
|
| 324 |
+
f.write(json.dumps(r) + "\n")
|
| 325 |
+
log(f"eval {tag} at {KNOB} {level}: solved {len(solved)}/{len(pool)}, L*={ls}, "
|
| 326 |
+
f"by band { {b: v['solved'] for b, v in out['by_band'].items()} }, {out['secs']:.0f}s")
|
| 327 |
+
return out
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
def stage_eval(a, tok, model, dev_pool, old_dev):
|
| 331 |
+
out = {"dev": eval_pool(a, tok, model, dev_pool, a.eval_k, a.eval_level, "dev")}
|
| 332 |
+
out["old_dev"] = eval_pool(a, tok, model, old_dev, a.eval_k_old, a.eval_level, "old_dev")
|
| 333 |
+
if not getattr(model, "untied", False):
|
| 334 |
+
out["dev_diag"] = eval_pool(a, tok, model, dev_pool, a.eval_k, a.diag_level, "dev_diag")
|
| 335 |
+
setattr(model, KNOB, a.eval_level)
|
| 336 |
+
return out
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def write_summary(a, status, **kw):
|
| 340 |
+
s = {"status": status, "metric": kw.get("eval", {}).get("dev", {}).get("solved"),
|
| 341 |
+
"metric_old_dev": kw.get("eval", {}).get("old_dev", {}).get("solved"),
|
| 342 |
+
"metric_rl": (kw.get("rl", {}).get("rounds") or [{}])[-1].get("targets_solved"),
|
| 343 |
+
"arm": {k: os.environ.get(k) for k in ("ND_ARCH", "ND_RL")}, "harness_sha": sha(f"{HERE}/harness.py"),
|
| 344 |
+
"pretrain_sha": sha(f"{HERE}/pretrain.py"), "device": DEV,
|
| 345 |
+
"gpu": torch.cuda.get_device_name(0) if DEV == "cuda" else "cpu", "torch": torch.__version__,
|
| 346 |
+
"total_secs": time.time() - a.T0,
|
| 347 |
+
"rules": {k: globals()[k] for k in ("TOTAL_SECS", "PRETRAIN_SECS", "RL_SECS", "PARAM_CAP", "MAX_NEW",
|
| 348 |
+
"EVAL_K", "EVAL_K_OLD", "EVAL_LEVEL", "DIAG_LEVEL", "TOK_MODE")},
|
| 349 |
+
**kw}
|
| 350 |
+
with open(f"{a.out}/summary.json", "w") as f:
|
| 351 |
+
json.dump(s, f, indent=1)
|
| 352 |
+
log(f"SUMMARY status={status} metric={s['metric']} old_dev={s['metric_old_dev']} metric_rl={s['metric_rl']} "
|
| 353 |
+
f"total {s['total_secs']:.0f}s")
|
| 354 |
+
return s
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
def save_checkpoint(a, model, tok, stage):
|
| 358 |
+
path = Path(a.out) / f"{stage}.pt"
|
| 359 |
+
pending = path.with_suffix(".pt.tmp")
|
| 360 |
+
try:
|
| 361 |
+
torch.save({"state": model.state_dict(), "tok_mode": tok.mode, "stage": stage, "seed": a.seed,
|
| 362 |
+
"arm": {k: os.environ.get(k) for k in ("ND_ARCH", "ND_RL")},
|
| 363 |
+
"harness_sha": sha(f"{HERE}/harness.py"), "pretrain_sha": sha(f"{HERE}/pretrain.py")}, pending)
|
| 364 |
+
os.replace(pending, path)
|
| 365 |
+
finally:
|
| 366 |
+
pending.unlink(missing_ok=True)
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
def load_pools(a):
|
| 370 |
+
train = read(f"{DATA}/pretrain.jsonl.gz")
|
| 371 |
+
assert all(r["body"] <= 6 for r in train), "pretraining file violates the 6-body-line cap"
|
| 372 |
+
targets, dev = read(f"{DATA}/rl.jsonl"), read(f"{DATA}/dev.jsonl")
|
| 373 |
+
old = [r for r in read(f"{FORK}/data/ladder/transfer.jsonl")
|
| 374 |
+
if int(hashlib.sha1(r["key"].encode()).hexdigest(), 16) % 2 == 0] # the loops harness's dev half
|
| 375 |
+
old = [{**r, "body": r["n_lines"] - r["n_prem"]} for r in old]
|
| 376 |
+
tk, dk, pk = ({r["key"] for r in xs} for xs in (targets, dev, train))
|
| 377 |
+
assert not (tk & dk) and not (tk & pk) and not (dk & pk), "theorem leak between pools"
|
| 378 |
+
if a.smoke:
|
| 379 |
+
rng = random.Random(0)
|
| 380 |
+
train = train[:3000]
|
| 381 |
+
targets, dev, old = rng.sample(targets, 12), rng.sample(dev, 6), old[:6]
|
| 382 |
+
return train, targets, dev, old
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
def main():
|
| 386 |
+
ap = argparse.ArgumentParser()
|
| 387 |
+
ap.add_argument("--out", required=True)
|
| 388 |
+
ap.add_argument("--seed", type=int, default=0)
|
| 389 |
+
ap.add_argument("--pretrain-only", action="store_true")
|
| 390 |
+
ap.add_argument("--smoke", action="store_true", help="tiny everything, for a CPU plumbing check")
|
| 391 |
+
ap.add_argument("--resume", help="a finished run's dir: load its final weights and found proofs, skip pretraining, "
|
| 392 |
+
"and continue RL (expert iteration restarts its optimizers every round anyway)")
|
| 393 |
+
ap.add_argument("--rl-hours", type=float, help="RL budget override, e.g. for a resumed run's extra hours")
|
| 394 |
+
a = ap.parse_args()
|
| 395 |
+
a.pretrain_secs, a.rl_secs, a.eval_k, a.eval_k_old, a.max_new = PRETRAIN_SECS, RL_SECS, EVAL_K, EVAL_K_OLD, MAX_NEW
|
| 396 |
+
if a.rl_hours:
|
| 397 |
+
a.rl_secs = int(a.rl_hours * 3600)
|
| 398 |
+
a.eval_level, a.diag_level = EVAL_LEVEL, DIAG_LEVEL
|
| 399 |
+
if a.smoke:
|
| 400 |
+
a.pretrain_secs, a.rl_secs, a.eval_k, a.eval_k_old, a.max_new = 20, 60, 2, 2, 160
|
| 401 |
+
os.makedirs(a.out, exist_ok=True)
|
| 402 |
+
src = Path(a.out) / "source"
|
| 403 |
+
src.mkdir(exist_ok=True)
|
| 404 |
+
for fn in ("pretrain.py", "harness.py", "remote.sh", "overlay/lean_tok.py", "overlay/lean_gate.py"):
|
| 405 |
+
shutil.copy2(Path(HERE) / fn, src / os.path.basename(fn))
|
| 406 |
+
a.T0 = time.time()
|
| 407 |
+
torch.manual_seed(a.seed)
|
| 408 |
+
|
| 409 |
+
def on_alarm(signum, frame):
|
| 410 |
+
raise Timeout()
|
| 411 |
+
|
| 412 |
+
signal.signal(signal.SIGALRM, on_alarm)
|
| 413 |
+
signal.alarm(TOTAL_SECS if not a.smoke else 1800)
|
| 414 |
+
train, targets, dev, old = load_pools(a)
|
| 415 |
+
agent = importlib.import_module("pretrain")
|
| 416 |
+
assert getattr(agent, "GRPO_TEMP", TEMP) == TEMP, "GRPO must score the distribution it samples from"
|
| 417 |
+
for name in ("lean_tok", "lean_gate"): # the Lean-only gate and the widened tokenizer, nothing from the fork
|
| 418 |
+
assert os.path.dirname(sys.modules[name].__file__) == os.path.join(HERE, "overlay"), sys.modules[name].__file__
|
| 419 |
+
log(f"pools: pretrain {len(train):,}, RL targets {len(targets):,}, dev {len(dev)}, old dev {len(old)}; "
|
| 420 |
+
f"arm {os.environ.get('ND_ARCH')}/{os.environ.get('ND_RL')}; device {DEV}; "
|
| 421 |
+
f"harness {sha(f'{HERE}/harness.py')} pretrain {sha(f'{HERE}/pretrain.py')}")
|
| 422 |
+
pre, resume = {}, None
|
| 423 |
+
try:
|
| 424 |
+
t0 = time.time()
|
| 425 |
+
if a.resume:
|
| 426 |
+
final, pretrained, found, calls, prior_secs = load_resume(a, targets)
|
| 427 |
+
model, tok, _ = agent.pretrain(train, 1e-9, DEV, a.seed, log) # zero steps: only builds the model and tokenizer
|
| 428 |
+
model.load_state_dict(final)
|
| 429 |
+
resume = {"found": found, "calls": calls, "pretrained": pretrained}
|
| 430 |
+
pre = {"resumed_from": a.resume, "prior_rl_secs": prior_secs, "prior_calls": calls}
|
| 431 |
+
log(f"resumed from {a.resume}: prior RL clock {prior_secs:.0f}s, {calls} oracle calls, "
|
| 432 |
+
f"{len(found):,} targets already solved, RL budget now {a.rl_secs}s")
|
| 433 |
+
else:
|
| 434 |
+
model, tok, pre = agent.pretrain(train, a.pretrain_secs, DEV, a.seed, log)
|
| 435 |
+
if DEV == "cuda":
|
| 436 |
+
torch.cuda.synchronize()
|
| 437 |
+
pre = dict(pre or {})
|
| 438 |
+
pre["secs"] = time.time() - t0
|
| 439 |
+
model.eval()
|
| 440 |
+
pre["n_params"] = n_params = sum(p.numel() for p in model.parameters())
|
| 441 |
+
longest = max(len(tok.encode_proof(r["proof"])) for r in targets + dev if r.get("proof")) # ladder: none
|
| 442 |
+
pre["longest_reference_tokens"] = longest
|
| 443 |
+
log(f"pretrain returned after {pre['secs']:.0f}s (budget {a.pretrain_secs}s), {n_params:,} params; "
|
| 444 |
+
f"longest reference proof {longest} tokens, MAX_NEW {a.max_new}")
|
| 445 |
+
assert longest <= a.max_new or a.smoke, f"a reference proof ({longest} tokens) exceeds MAX_NEW"
|
| 446 |
+
if pre["secs"] > a.pretrain_secs + PRETRAIN_GRACE and not a.smoke and not a.resume:
|
| 447 |
+
return write_summary(a, "timeout", pretrain=pre, reason="pretrain overran its budget")
|
| 448 |
+
if tok.mode != TOK_MODE or n_params > PARAM_CAP or not isinstance(getattr(model, KNOB, None), int):
|
| 449 |
+
return write_summary(a, "crash", pretrain=pre, reason="tok mode, param cap or knob check failed")
|
| 450 |
+
if not a.resume:
|
| 451 |
+
save_checkpoint(a, model, tok, "pretrain")
|
| 452 |
+
if a.pretrain_only:
|
| 453 |
+
return write_summary(a, "ok", stage="pretrain_only", pretrain=pre)
|
| 454 |
+
rl = stage_rl(a, agent, tok, model, targets, train, dev, resume)
|
| 455 |
+
if rl["rl_secs_used"] > a.rl_secs + RL_GRACE and not a.smoke:
|
| 456 |
+
return write_summary(a, "timeout", pretrain=pre, rl=rl, reason="rl overran its budget")
|
| 457 |
+
save_checkpoint(a, model, tok, "final")
|
| 458 |
+
ev = stage_eval(a, tok, model, dev, old)
|
| 459 |
+
write_summary(a, "ok", pretrain=pre, rl=rl, eval=ev)
|
| 460 |
+
except BudgetSpent as e:
|
| 461 |
+
write_summary(a, "timeout", pretrain=pre, reason=f"rl: {e}")
|
| 462 |
+
except Timeout:
|
| 463 |
+
write_summary(a, "timeout", pretrain=pre, reason=f"exceeded TOTAL_SECS={TOTAL_SECS}")
|
| 464 |
+
except Exception:
|
| 465 |
+
traceback.print_exc()
|
| 466 |
+
write_summary(a, "crash", pretrain=pre, reason=traceback.format_exc()[-2000:])
|
| 467 |
+
finally:
|
| 468 |
+
signal.alarm(0)
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
if __name__ == "__main__":
|
| 472 |
+
main()
|
runs/long-rl-20261014-v5_looped-ei_s0/source/lean_gate.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Lean as the ONLY checker (long_rl_20261014 overlay on the fork's lean_gate.py at 51604b3).
|
| 2 |
+
|
| 3 |
+
gate(tok, prompts, nd_proofs, texts) is called by sample.generate() for a LeanTokenizer. For every distinct
|
| 4 |
+
(prompt, literal Lean text) whose text parsed in the strict grammar it asks Lean (core) whether the literal text proves the
|
| 5 |
+
theorem, and returns the ND proofs with 'LEANREJ ' prefixed where Lean rejects. Unlike the fork's gate there is no
|
| 6 |
+
nd_verify: a sample counts iff Lean accepts it (Robbie, 2026-10-14). The ND proof returned is only the decoder's rendering,
|
| 7 |
+
used for line counts. lean_check() below is the fork's, unchanged.
|
| 8 |
+
|
| 9 |
+
Log: $LEAN_GATE_LOG (default artifacts/lean_gate.jsonl), one json line per generate() call.
|
| 10 |
+
"""
|
| 11 |
+
import os, re, sys, json, time, subprocess, tempfile, shutil, collections
|
| 12 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 13 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 14 |
+
|
| 15 |
+
LEAN = os.path.expanduser('~/.elan/bin/lean')
|
| 16 |
+
CHUNK = int(os.environ.get('LEAN_GATE_CHUNK', '400'))
|
| 17 |
+
WORKERS = int(os.environ.get('LEAN_GATE_WORKERS', str(max(1, (os.cpu_count() or 2) // 2))))
|
| 18 |
+
ERR = re.compile(r'^[^\n]*?:(\d+):\d+: error', re.M)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def _run(lines, workdir, tag, depth=0):
|
| 22 |
+
"""lines: list of one-line theorem sources -> (list of bool, cpu seconds)"""
|
| 23 |
+
fn = os.path.join(workdir, f'c_{tag}.lean')
|
| 24 |
+
with open(fn, 'w') as f:
|
| 25 |
+
f.write('set_option linter.unusedVariables false\n' + '\n'.join(lines) + '\n')
|
| 26 |
+
t0 = time.time()
|
| 27 |
+
try:
|
| 28 |
+
p = subprocess.run([LEAN, '-DmaxErrors=100000000', fn], capture_output=True, text=True, timeout=60 + 2 * len(lines))
|
| 29 |
+
o = p.stdout + p.stderr; rc = p.returncode
|
| 30 |
+
except subprocess.TimeoutExpired:
|
| 31 |
+
o = ''; rc = -9
|
| 32 |
+
cpu = time.time() - t0
|
| 33 |
+
os.remove(fn)
|
| 34 |
+
bad = {int(m.group(1)) - 2 for m in ERR.finditer(o)}
|
| 35 |
+
crashed = rc not in (0, 1) or (rc == 1 and not bad) or any(b < 0 or b >= len(lines) for b in bad)
|
| 36 |
+
if crashed:
|
| 37 |
+
if len(lines) == 1:
|
| 38 |
+
return [False], cpu
|
| 39 |
+
h = len(lines) // 2
|
| 40 |
+
a, ca = _run(lines[:h], workdir, tag + 'a', depth + 1); b, cb = _run(lines[h:], workdir, tag + 'b', depth + 1)
|
| 41 |
+
return a + b, cpu + ca + cb
|
| 42 |
+
return [k not in bad for k in range(len(lines))], cpu
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def lean_check(items):
|
| 46 |
+
"""items: list of (statement text, tactic text) -> (list of bool, wall seconds, summed process seconds)"""
|
| 47 |
+
if not items:
|
| 48 |
+
return [], 0.0, 0.0
|
| 49 |
+
lines = [f'{s.replace("theorem t ", f"theorem t{k} ", 1)} {b}' for k, (s, b) in enumerate(items)]
|
| 50 |
+
wd = tempfile.mkdtemp(prefix='leangate_')
|
| 51 |
+
t0 = time.time()
|
| 52 |
+
chunks = [(lines[i:i + CHUNK], i) for i in range(0, len(lines), CHUNK)]
|
| 53 |
+
with ThreadPoolExecutor(WORKERS) as ex:
|
| 54 |
+
res = list(ex.map(lambda c: _run(c[0], wd, str(c[1])), chunks))
|
| 55 |
+
shutil.rmtree(wd, ignore_errors=True)
|
| 56 |
+
ok = [x for r, _ in res for x in r]
|
| 57 |
+
return ok, time.time() - t0, sum(c for _, c in res)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def gate(tok, prompts, nd_proofs, texts):
|
| 61 |
+
logfn = os.environ.get('LEAN_GATE_LOG', 'artifacts/lean_gate.jsonl')
|
| 62 |
+
keys = {}
|
| 63 |
+
for p, nd, tx in zip(prompts, nd_proofs, texts):
|
| 64 |
+
if tx is not None and not nd.startswith('LEANPARSE'):
|
| 65 |
+
keys.setdefault((p, tx), nd)
|
| 66 |
+
items = list(keys)
|
| 67 |
+
lean_ok, wall, cpu = lean_check([(tok.statement(p), tx) for p, tx in items])
|
| 68 |
+
verdict = dict(zip(items, lean_ok))
|
| 69 |
+
n_parse = sum(1 for nd in nd_proofs if nd.startswith('LEANPARSE'))
|
| 70 |
+
parse_reasons = collections.Counter(nd[10:] for nd in nd_proofs if nd.startswith('LEANPARSE'))
|
| 71 |
+
n_ok = sum(map(bool, lean_ok))
|
| 72 |
+
rec = {'utc': time.strftime('%FT%TZ', time.gmtime()), 'samples': len(prompts), 'parse_fail': n_parse,
|
| 73 |
+
'distinct_checked': len(items), 'lean_ok': n_ok, 'lean_rej': len(items) - n_ok,
|
| 74 |
+
'parse_reasons': dict(parse_reasons.most_common()), 'lean_wall_s': wall, 'lean_proc_s': cpu,
|
| 75 |
+
'workers': WORKERS, 'chunk': CHUNK}
|
| 76 |
+
os.makedirs(os.path.dirname(logfn) or '.', exist_ok=True)
|
| 77 |
+
with open(logfn, 'a') as f:
|
| 78 |
+
f.write(json.dumps(rec) + '\n')
|
| 79 |
+
print(f'[lean_gate] {len(prompts)} samples, parse-fail {n_parse}, distinct checked {len(items)}: lean ok {n_ok}; '
|
| 80 |
+
f'lean {wall:.1f}s wall ({cpu:.1f}s proc, {WORKERS} workers)', flush=True)
|
| 81 |
+
return [nd if tx is None or nd.startswith('LEANPARSE') or verdict[(p, tx)] else 'LEANREJ ' + nd
|
| 82 |
+
for p, nd, tx in zip(prompts, nd_proofs, texts)]
|
runs/long-rl-20261014-v5_looped-ei_s0/source/lean_tok.py
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Lean 4 as the training surface form for the from-scratch model (run lean-format, proposal 8). One symbol per token.
|
| 2 |
+
|
| 3 |
+
The text the model reads and writes is the nd2lean.py rendering of an ND proof, linearised on one line with `;` between
|
| 4 |
+
tactics (no indentation tokens):
|
| 5 |
+
|
| 6 |
+
prompt : theorem t ( P Q R S : Prop ) ( h1 : F1 ) ... : C := by
|
| 7 |
+
proof : have n1 : F1 := h1 ; have n7 : ( P → R ) := ( fun ( n3 : P ) => by have n4 : Q := n1 n3 ; exact n4 ) ; exact n7 <eos>
|
| 8 |
+
|
| 9 |
+
Terms (exactly nd2lean's): PR `hK`; R `nA`; ANDI `⟨ nA , nB ⟩`; ANDE `nA .1|.2`; IMPE / NEGE `nF nA`; ORI `Or.inl|Or.inr nA`;
|
| 10 |
+
BOTE `False.elim nA` (tokens `False` `.elim` `nA`; was `nA .elim` before the 2026-09-22 fix, see nd2lean.py); DN `Classical.byContradiction ( fun hh => nA hh )`; IMPI `( fun ( nS : A ) => by ... ; exact nE )`;
|
| 11 |
+
NEGI the same ending `exact ( nE : False )`; ORE `Or.elim nJ <box> <box>`. `.1 .2 .elim` are glued to the name in the text.
|
| 12 |
+
|
| 13 |
+
Hypothesis names are LABELS, not line indices. 64 name tokens n1..n64; two naming schemes (stored in the ckpt as the mode):
|
| 14 |
+
lean_rand : every training presentation draws a random injective map names -> n1..n64 (names carry no order)
|
| 15 |
+
lean_seq : names are numbered in order of first appearance in the Lean text, plus a random start offset
|
| 16 |
+
(the analogue of the token format's `abs` start-index shift)
|
| 17 |
+
decode() parses the sampled tokens with the strict grammar above and returns the ND proof (spec.md format, N1..) it
|
| 18 |
+
denotes — the "nd2lean inverse" — so nd_verify, prune, normalize and every analysis script work unchanged; a sample
|
| 19 |
+
outside the grammar decodes to 'LEANPARSE <reason>' (rejected by nd_verify). The literal Lean text of the last decoded
|
| 20 |
+
sample is kept in `last_text` and is what lean_gate.py sends to Lean.
|
| 21 |
+
"""
|
| 22 |
+
import random, sys, os
|
| 23 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 24 |
+
from nd_verify.verify import parse_proof_tokens, parse_formula
|
| 25 |
+
from nd2lean import parse_prompt, translate
|
| 26 |
+
|
| 27 |
+
# long_rl_20261014 overlay (on the fork's lean_tok.py at 51604b3): ten atoms (no V, which reads as
|
| 28 |
+
# `v`), up to ten premises (h1..h10), 160 names, and a statement header that declares all ten atoms,
|
| 29 |
+
# so random atom relabelling (tok.atom_ids, HEADER_LEN; pretrain.py's gpu_batch) never touches it.
|
| 30 |
+
ATOMS = ['P', 'Q', 'R', 'S', 'T', 'U', 'W', 'X', 'Y', 'Z']
|
| 31 |
+
sys.modules['nd_verify.verify'].ATOM_NAMES.update(ATOMS) # the ND parsers (formula syntax only; proofs are judged by Lean)
|
| 32 |
+
MAXN = 160
|
| 33 |
+
MAXH = 10
|
| 34 |
+
FSYMS = ['(', ')', '¬', '∧', '∨', '→'] + ATOMS + ['False']
|
| 35 |
+
HEADER_LEN = len(['theorem', 't', '(']) + len(ATOMS) + len([':', 'Prop', ')'])
|
| 36 |
+
PSYMS = ['theorem', 't', ':', 'Prop', ':=', 'by']
|
| 37 |
+
TSYMS = ['have', 'exact', ';', 'fun', '=>', '⟨', '⟩', ',', '.1', '.2', '.elim', 'Or.inl', 'Or.inr', 'Or.elim', 'Classical.byContradiction', 'hh']
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class ParseFail(Exception):
|
| 41 |
+
pass
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def ftoks(f):
|
| 45 |
+
"""formula tuple -> Lean tokens (fully parenthesised, as nd2lean.lf)"""
|
| 46 |
+
t = f[0]
|
| 47 |
+
if t == 'atom': return [f[1]]
|
| 48 |
+
if t == 'bot': return ['False']
|
| 49 |
+
if t == 'not': return ['(', '¬'] + ftoks(f[1]) + [')']
|
| 50 |
+
op = {'and': '∧', 'or': '∨', 'imp': '→'}[t]
|
| 51 |
+
return ['('] + ftoks(f[1]) + [op] + ftoks(f[2]) + [')']
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def fnd(f):
|
| 55 |
+
"""formula tuple -> ND tokens (spec.md)"""
|
| 56 |
+
t = f[0]
|
| 57 |
+
if t == 'atom': return f[1]
|
| 58 |
+
if t == 'bot': return 'F'
|
| 59 |
+
if t == 'not': return f'( ~ {fnd(f[1])} )'
|
| 60 |
+
op = {'and': '&', 'or': 'v', 'imp': '>'}[t]
|
| 61 |
+
return f'( {fnd(f[1])} {op} {fnd(f[2])} )'
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def prompt_tokens(prompt):
|
| 65 |
+
prem, concl = parse_prompt(prompt)
|
| 66 |
+
if len(prem) > MAXH:
|
| 67 |
+
raise ValueError('too many premises')
|
| 68 |
+
out = ['theorem', 't', '('] + ATOMS + [':', 'Prop', ')']
|
| 69 |
+
for j, p in enumerate(prem):
|
| 70 |
+
out += ['(', f'h{j+1}', ':'] + ftoks(p) + [')']
|
| 71 |
+
return out + [':'] + ftoks(concl) + [':=', 'by']
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def proof_tokens(proof):
|
| 75 |
+
"""ND proof body -> Lean tokens with names as ('n', ND index). Mirrors nd2lean.translate (which must have accepted
|
| 76 |
+
the proof); a closed box that no rule cites is dropped, as in nd2lean."""
|
| 77 |
+
lines = parse_proof_tokens(proof.split())
|
| 78 |
+
stack = [[]] # token lists of the open boxes' statements; stack[0] = top level
|
| 79 |
+
hyp = [None] # (idx, formula) of each open box
|
| 80 |
+
last = [None]
|
| 81 |
+
closed = {} # start idx -> (hyp formula, stmts tokens, last idx)
|
| 82 |
+
n_pr = 0
|
| 83 |
+
|
| 84 |
+
def close():
|
| 85 |
+
s = stack.pop(); h = hyp.pop(); l = last.pop()
|
| 86 |
+
closed[h[0]] = (h[1], s, l)
|
| 87 |
+
|
| 88 |
+
def box(s, e, neg=False):
|
| 89 |
+
hf, st, l = closed[s]
|
| 90 |
+
assert l == e, 'box cite'
|
| 91 |
+
ex = ['exact', '(', ('n', e), ':', 'False', ')'] if neg else ['exact', ('n', e)]
|
| 92 |
+
return ['(', 'fun', '(', ('n', s), ':'] + ftoks(hf) + [')', '=>', 'by'] + st + ex + [')']
|
| 93 |
+
|
| 94 |
+
for ln in lines:
|
| 95 |
+
i, d, f, rule, refs = ln['idx'], ln['depth'], ln['formula'], ln['rule'], ln['refs']
|
| 96 |
+
if rule == 'AS':
|
| 97 |
+
while len(stack) - 1 >= d: close()
|
| 98 |
+
stack.append([]); hyp.append((i, f)); last.append(i)
|
| 99 |
+
continue
|
| 100 |
+
while len(stack) - 1 > d: close()
|
| 101 |
+
n = lambda j: ('n', j)
|
| 102 |
+
if rule == 'PR': n_pr += 1; term = [f'h{n_pr}']
|
| 103 |
+
elif rule == 'R': term = [n(refs[0])]
|
| 104 |
+
elif rule == 'ANDI': term = ['⟨', n(refs[0]), ',', n(refs[1]), '⟩']
|
| 105 |
+
elif rule == 'ANDE1': term = [n(refs[0]), '.1']
|
| 106 |
+
elif rule == 'ANDE2': term = [n(refs[0]), '.2']
|
| 107 |
+
elif rule == 'IMPE': term = [n(refs[0]), n(refs[1])]
|
| 108 |
+
elif rule == 'NEGE': term = [n(refs[1]), n(refs[0])]
|
| 109 |
+
elif rule == 'ORI1': term = ['Or.inl', n(refs[0])]
|
| 110 |
+
elif rule == 'ORI2': term = ['Or.inr', n(refs[0])]
|
| 111 |
+
elif rule == 'BOTE': term = ['False', '.elim', n(refs[0])]
|
| 112 |
+
elif rule == 'DN': term = ['Classical.byContradiction', '(', 'fun', 'hh', '=>', n(refs[0]), 'hh', ')']
|
| 113 |
+
elif rule == 'IMPI': term = box(refs[0], refs[1])
|
| 114 |
+
elif rule == 'NEGI': term = box(refs[0], refs[1], neg=True)
|
| 115 |
+
elif rule == 'ORE': term = ['Or.elim', n(refs[0])] + box(refs[1], refs[2]) + box(refs[3], refs[4])
|
| 116 |
+
else: raise ValueError(rule)
|
| 117 |
+
stack[-1] += ['have', n(i), ':'] + ftoks(f) + [':='] + term + [';']
|
| 118 |
+
last[-1] = i
|
| 119 |
+
assert len(stack) == 1
|
| 120 |
+
return stack[0] + ['exact', ('n', lines[-1]['idx'])]
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
class LeanTokenizer:
|
| 124 |
+
def __init__(self, mode='lean_rand'):
|
| 125 |
+
assert mode in ('lean_rand', 'lean_seq')
|
| 126 |
+
self.mode = mode
|
| 127 |
+
self.itos = ['<pad>', '<eos>'] + FSYMS + PSYMS + TSYMS + [f'h{k}' for k in range(1, MAXH + 1)]
|
| 128 |
+
self.ref0 = len(self.itos)
|
| 129 |
+
self.itos += [f'n{k}' for k in range(1, MAXN + 1)]
|
| 130 |
+
self.stoi = {s: i for i, s in enumerate(self.itos)}
|
| 131 |
+
self.atom_ids = [self.stoi[x] for x in ATOMS]
|
| 132 |
+
self.pad, self.eos = 0, 1
|
| 133 |
+
self.shift = True
|
| 134 |
+
self.last_text = None
|
| 135 |
+
|
| 136 |
+
@property
|
| 137 |
+
def vocab_size(self):
|
| 138 |
+
return len(self.itos)
|
| 139 |
+
|
| 140 |
+
def encode_prompt(self, prompt):
|
| 141 |
+
return [self.stoi[t] for t in prompt_tokens(prompt)]
|
| 142 |
+
|
| 143 |
+
def encode_proof(self, body):
|
| 144 |
+
"""ND body -> ids with names numbered by first appearance (n1, n2, ...); <eos> included."""
|
| 145 |
+
order = {}
|
| 146 |
+
out = []
|
| 147 |
+
for t in proof_tokens(body):
|
| 148 |
+
if isinstance(t, tuple):
|
| 149 |
+
k = order.setdefault(t[1], len(order) + 1)
|
| 150 |
+
if k > MAXN: raise ValueError('too many names')
|
| 151 |
+
out.append(self.ref0 + k - 1)
|
| 152 |
+
else:
|
| 153 |
+
out.append(self.stoi[t])
|
| 154 |
+
return out + [self.eos]
|
| 155 |
+
|
| 156 |
+
def shift_abs(self, ids, rng):
|
| 157 |
+
"""name augmentation (the interface name is train.py's)."""
|
| 158 |
+
if not self.shift:
|
| 159 |
+
return ids
|
| 160 |
+
mx = max((x - self.ref0 + 1 for x in ids if x >= self.ref0), default=0)
|
| 161 |
+
if mx == 0:
|
| 162 |
+
return ids
|
| 163 |
+
if self.mode == 'lean_seq':
|
| 164 |
+
s = rng.randint(0, MAXN - mx)
|
| 165 |
+
return [x + s if x >= self.ref0 else x for x in ids]
|
| 166 |
+
perm = rng.sample(range(MAXN), mx)
|
| 167 |
+
return [self.ref0 + perm[x - self.ref0] if x >= self.ref0 else x for x in ids]
|
| 168 |
+
|
| 169 |
+
# ---- text ----
|
| 170 |
+
def text(self, toks):
|
| 171 |
+
"""tokens (strings) -> Lean source text of the tactic block (one line)."""
|
| 172 |
+
out = []
|
| 173 |
+
for t in toks:
|
| 174 |
+
if t in ('.1', '.2', '.elim') and out:
|
| 175 |
+
out[-1] += t
|
| 176 |
+
else:
|
| 177 |
+
out.append(t)
|
| 178 |
+
return ' '.join(out)
|
| 179 |
+
|
| 180 |
+
def statement(self, prompt):
|
| 181 |
+
return ' '.join(prompt_tokens(prompt))
|
| 182 |
+
|
| 183 |
+
def lean_source(self, prompt, proof):
|
| 184 |
+
"""(statement, tactic text) Lean checks for an ND proof: exactly what the model would write."""
|
| 185 |
+
return self.statement(prompt), self.text([self.itos[x] for x in self.encode_proof(proof)[:-1]])
|
| 186 |
+
|
| 187 |
+
# ---- inverse ----
|
| 188 |
+
def decode(self, ids):
|
| 189 |
+
toks = []
|
| 190 |
+
ended = False
|
| 191 |
+
for x in ids:
|
| 192 |
+
if x == self.pad: continue
|
| 193 |
+
if x == self.eos: ended = True; break
|
| 194 |
+
toks.append(self.itos[x])
|
| 195 |
+
self.last_text = self.text(toks) if ended else None
|
| 196 |
+
if not ended:
|
| 197 |
+
return 'LEANPARSE no-eos'
|
| 198 |
+
try:
|
| 199 |
+
return inverse(toks)
|
| 200 |
+
except ParseFail as e:
|
| 201 |
+
return f'LEANPARSE {e}'
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def inverse(toks):
|
| 205 |
+
"""Lean tokens (strict nd2lean grammar) -> ND proof body 'N1 ... ; ... QED'. Names resolve lexically (latest binding wins,
|
| 206 |
+
as in Lean). Raises ParseFail outside the grammar: PR lines first and in order, a box's `exact` cites the box's last line,
|
| 207 |
+
the final `exact` cites the last top-level line."""
|
| 208 |
+
pos = [0]
|
| 209 |
+
out = [] # ND lines (strings)
|
| 210 |
+
forms = {} # ND idx -> formula tuple
|
| 211 |
+
n_pr = [0]; seen_non_pr = [False]
|
| 212 |
+
|
| 213 |
+
def peek():
|
| 214 |
+
return toks[pos[0]] if pos[0] < len(toks) else None
|
| 215 |
+
|
| 216 |
+
def eat(x=None):
|
| 217 |
+
t = peek()
|
| 218 |
+
if t is None or (x is not None and t != x):
|
| 219 |
+
raise ParseFail(f'expected {x}')
|
| 220 |
+
pos[0] += 1
|
| 221 |
+
return t
|
| 222 |
+
|
| 223 |
+
def name_tok():
|
| 224 |
+
t = eat()
|
| 225 |
+
if not (t[0] == 'n' and t[1:].isdigit()):
|
| 226 |
+
raise ParseFail('name')
|
| 227 |
+
return t
|
| 228 |
+
|
| 229 |
+
def formula():
|
| 230 |
+
# re-use the ND formula parser on a token-mapped slice
|
| 231 |
+
m = {'(': '(', ')': ')', '¬': '~', '∧': '&', '∨': 'v', '→': '>', 'False': 'F', **{a: a for a in ATOMS}}
|
| 232 |
+
j = pos[0]; nd = []
|
| 233 |
+
while j < len(toks) and toks[j] in m:
|
| 234 |
+
nd.append(m[toks[j]]); j += 1
|
| 235 |
+
try:
|
| 236 |
+
f, used = parse_formula(nd + ['$'], 0)
|
| 237 |
+
except Exception:
|
| 238 |
+
raise ParseFail('formula')
|
| 239 |
+
pos[0] += used
|
| 240 |
+
return f
|
| 241 |
+
|
| 242 |
+
def ref(scope):
|
| 243 |
+
t = name_tok()
|
| 244 |
+
if t not in scope:
|
| 245 |
+
raise ParseFail('unbound')
|
| 246 |
+
return scope[t]
|
| 247 |
+
|
| 248 |
+
def emit(depth, f, rule, refs):
|
| 249 |
+
i = len(out) + 1
|
| 250 |
+
out.append(f'N{i} ' + '| ' * depth + f'{fnd(f)} : {rule}' + ''.join(f' N{r}' for r in refs) + ' ;')
|
| 251 |
+
forms[i] = f
|
| 252 |
+
return i
|
| 253 |
+
|
| 254 |
+
def box(scope, depth):
|
| 255 |
+
"""'( fun ( n : A ) => by stmts exact .. )' -> (start idx, end idx, neg)"""
|
| 256 |
+
eat('('); eat('fun'); eat('('); nm = name_tok(); eat(':'); hf = formula(); eat(')'); eat('=>'); eat('by')
|
| 257 |
+
s = emit(depth + 1, hf, 'AS', [])
|
| 258 |
+
sc = dict(scope); sc[nm] = s
|
| 259 |
+
lastl = stmts(sc, depth + 1, s)
|
| 260 |
+
eat('exact')
|
| 261 |
+
if peek() == '(':
|
| 262 |
+
eat('('); e = ref(sc); eat(':'); eat('False'); eat(')'); neg = True
|
| 263 |
+
else:
|
| 264 |
+
e = ref(sc); neg = False
|
| 265 |
+
if e != lastl:
|
| 266 |
+
raise ParseFail('exact not last')
|
| 267 |
+
eat(')')
|
| 268 |
+
return s, e, neg
|
| 269 |
+
|
| 270 |
+
def stmts(scope, depth, lastl):
|
| 271 |
+
while peek() == 'have':
|
| 272 |
+
eat('have'); nm = name_tok(); eat(':'); f = formula(); eat(':=')
|
| 273 |
+
t = peek()
|
| 274 |
+
if t is None: raise ParseFail('eof')
|
| 275 |
+
if t[0] == 'h' and t[1:].isdigit():
|
| 276 |
+
eat(); k = int(t[1:])
|
| 277 |
+
if depth != 0 or seen_non_pr[0] or k != n_pr[0] + 1: raise ParseFail('PR position')
|
| 278 |
+
n_pr[0] += 1
|
| 279 |
+
i = emit(0, f, 'PR', [])
|
| 280 |
+
else:
|
| 281 |
+
seen_non_pr[0] = True
|
| 282 |
+
if t == '⟨':
|
| 283 |
+
eat(); a = ref(scope); eat(','); b = ref(scope); eat('⟩'); rule, refs, pre = 'ANDI', [a, b], None
|
| 284 |
+
elif t in ('Or.inl', 'Or.inr'):
|
| 285 |
+
eat(); a = ref(scope); rule, refs = ('ORI1' if t == 'Or.inl' else 'ORI2'), [a]
|
| 286 |
+
elif t == 'Classical.byContradiction':
|
| 287 |
+
eat(); eat('('); eat('fun'); eat('hh'); eat('=>'); a = ref(scope); eat('hh'); eat(')'); rule, refs = 'DN', [a]
|
| 288 |
+
elif t == '(':
|
| 289 |
+
s, e, neg = box(scope, depth); rule, refs = ('NEGI' if neg else 'IMPI'), [s, e]
|
| 290 |
+
elif t == 'Or.elim':
|
| 291 |
+
eat(); j = ref(scope); s1, e1, g1 = box(scope, depth); s2, e2, g2 = box(scope, depth)
|
| 292 |
+
if g1 or g2: raise ParseFail('ORE box')
|
| 293 |
+
rule, refs = 'ORE', [j, s1, e1, s2, e2]
|
| 294 |
+
elif t == 'False':
|
| 295 |
+
eat(); eat('.elim'); a = ref(scope); rule, refs = 'BOTE', [a]
|
| 296 |
+
else:
|
| 297 |
+
a = ref(scope); t2 = peek()
|
| 298 |
+
if t2 == '.1': eat(); rule, refs = 'ANDE1', [a]
|
| 299 |
+
elif t2 == '.2': eat(); rule, refs = 'ANDE2', [a]
|
| 300 |
+
elif t2 == ';': rule, refs = 'R', [a]
|
| 301 |
+
else:
|
| 302 |
+
b = ref(scope)
|
| 303 |
+
if forms[a][0] == 'not': rule, refs = 'NEGE', [b, a]
|
| 304 |
+
else: rule, refs = 'IMPE', [a, b]
|
| 305 |
+
i = emit(depth, f, rule, refs)
|
| 306 |
+
eat(';')
|
| 307 |
+
scope[nm] = i
|
| 308 |
+
lastl = i
|
| 309 |
+
return lastl
|
| 310 |
+
|
| 311 |
+
top = {}
|
| 312 |
+
lastl = stmts(top, 0, None)
|
| 313 |
+
eat('exact')
|
| 314 |
+
e = ref(top)
|
| 315 |
+
if pos[0] != len(toks):
|
| 316 |
+
raise ParseFail('trailing tokens')
|
| 317 |
+
if lastl is None or e != lastl:
|
| 318 |
+
raise ParseFail('exact not last')
|
| 319 |
+
return ' '.join(out) + ' QED'
|
runs/long-rl-20261014-v5_looped-ei_s0/source/pretrain.py
ADDED
|
@@ -0,0 +1,953 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# imports the fork (model, tokenizer, train, ...), which is not resolvable here
|
| 2 |
+
# pyright: reportMissingImports=false
|
| 3 |
+
"""long_rl_20261014: run 512's file (autoresearch_loops ae79d23, the final RL recipe: 507 token-budget fine-tune
|
| 4 |
+
batches, 509 Muon fine-tune, 510 more and shorter rounds) with three arms picked by environment variables:
|
| 5 |
+
|
| 6 |
+
ND_ARCH=untied ND_RL=ei A: run 198's untied six blocks (control 590's patch) + the final expert-iteration recipe
|
| 7 |
+
ND_ARCH=looped ND_RL=ei B: 512's looped trunk (two alternating shared core pairs) + the same recipe
|
| 8 |
+
ND_ARCH=untied ND_RL=grpo C: run 198's untied blocks + GRPO with a found-proof pool (rl_grpo)
|
| 9 |
+
|
| 10 |
+
Changes for this experiment, all arms:
|
| 11 |
+
- tokenizer: overlay/lean_tok.py (ten atoms, ten premises h1..h10, names n1..n160)
|
| 12 |
+
- random atom relabelling: every training batch maps each row's atoms through a random permutation of the ten
|
| 13 |
+
atom tokens (gpu_batch), after the fixed statement header; the analogue of the name-offset shift
|
| 14 |
+
- targets are picked per round by body-line band, weighted toward the frontier (pick_targets), from a pool of
|
| 15 |
+
thousands instead of a fixed 1,500
|
| 16 |
+
|
| 17 |
+
The original contract (harness.py's docstring describes this experiment's changes to it):
|
| 18 |
+
|
| 19 |
+
Contract with harness.py (frozen):
|
| 20 |
+
|
| 21 |
+
pretrain(train_recs, budget_secs, device, seed, log) -> (model, tok, stats)
|
| 22 |
+
|
| 23 |
+
train_recs list of dicts {prompt, proof, n_lines<=6, key, ...}; the frozen cap-6 Stage-1 data
|
| 24 |
+
budget_secs wall-clock you are charged for, from call to return, INCLUDING model construction
|
| 25 |
+
and torch.compile. Overrun by more than the harness grace -> the run is a timeout.
|
| 26 |
+
model nn.Module; <= PARAM_CAP unique params (checked again after rl). The harness samples
|
| 27 |
+
from it with the fork's sample.generate, so it must provide:
|
| 28 |
+
- forward(idx) -> logits (B,T,V) and forward(idx, pos=, mask=, caches=) with a
|
| 29 |
+
per-block KV cache dict, exactly like the fork's GPT (model.blocks must exist)
|
| 30 |
+
- an integer `n_loops` (the harness's KNOB): the loop count applied in eval
|
| 31 |
+
mode. The harness sets it to EVAL_LEVEL for the scored eval and to DIAG_LEVEL
|
| 32 |
+
for the diagnostic one.
|
| 33 |
+
tok must provide encode_prompt, encode_proof, decode, shift_abs, pad, eos, mode, and
|
| 34 |
+
mode must be "lean_seq" (harness TOK_MODE): Lean text in and out, Lean-gated samples.
|
| 35 |
+
Decoder rule: decode() is deterministic and single-pass; it may not call the
|
| 36 |
+
verifier or try alternatives.
|
| 37 |
+
stats dict recorded in summary.json and copied into results.json. MUST contain `curve`:
|
| 38 |
+
a list of {secs, step, train_loss, val_loss} taken every ~CURVE_EVERY seconds
|
| 39 |
+
(see log_point below), so a run's trajectory survives in git. Add anything else.
|
| 40 |
+
val_loss is on VAL_N records held out from train_recs by this file; keep that.
|
| 41 |
+
|
| 42 |
+
rl(model, tok, targets, train_recs, oracle, budget_secs, device, seed, log) -> stats | None
|
| 43 |
+
|
| 44 |
+
targets list of dicts {name, prompt, n_lines}: the 1,500 RL target statements. No proofs.
|
| 45 |
+
oracle oracle.sample(model, targets_subset, k, temperature=0.8, batch=1024) samples k
|
| 46 |
+
attempts per target from the model in eval mode at its current n_loops, and returns
|
| 47 |
+
per target {name, prompt, n_lines, proofs, n_ok, n_tried}; `proofs` are the distinct
|
| 48 |
+
attempts Lean AND nd_verify accepted. This is the only source of new training data.
|
| 49 |
+
oracle.used() / oracle.left(): seconds of the RL budget charged / remaining.
|
| 50 |
+
budget_secs RL_SECS: wall-clock inside rl() minus the oracle's Lean-gate time. Returning more
|
| 51 |
+
than the grace late, or calling the oracle with nothing left, is a timeout.
|
| 52 |
+
The model is trained in place. Everything else about RL is yours: rounds, samples per target,
|
| 53 |
+
loop counts when sampling, which proofs to keep, weighting, replay, optimizer, loss.
|
| 54 |
+
|
| 55 |
+
Anything imported from the fork (ND_FORK) is fair game to copy in here and modify.
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
import collections
|
| 59 |
+
import copy
|
| 60 |
+
import math
|
| 61 |
+
import os
|
| 62 |
+
import random
|
| 63 |
+
import time
|
| 64 |
+
|
| 65 |
+
import torch
|
| 66 |
+
import torch._inductor.config # noqa: F401 (explicit, so the attribute resolves for pyright)
|
| 67 |
+
from lean_tok import HEADER_LEN, MAXN # overlay
|
| 68 |
+
from model import GPT, Block # fork
|
| 69 |
+
from normalize import norm # fork
|
| 70 |
+
from tokenizer import make_tokenizer # fork
|
| 71 |
+
from train import loss_on # fork
|
| 72 |
+
|
| 73 |
+
# ---- knobs
|
| 74 |
+
# Unique blocks: one untied entry block, N_PAIRS pairs of N_CORE shared core blocks that the loops
|
| 75 |
+
# cycle through (loop k applies pair k % N_PAIRS, so 8 loops run A B A B A B A B and 2 loops run
|
| 76 |
+
# A B: the untied six-block topology of control 590), one untied exit block. Same compute per
|
| 77 |
+
# loop count as one shared pair; 6 unique blocks, 9.56M parameters, the untied control's count.
|
| 78 |
+
N_CORE, N_PAIRS = 2, 2
|
| 79 |
+
ARCH = os.environ.get("ND_ARCH", "untied") # untied | looped
|
| 80 |
+
RL_ALGO = os.environ.get("ND_RL", "ei") # ei | grpo
|
| 81 |
+
assert ARCH in ("untied", "looped") and RL_ALGO in ("ei", "grpo"), (ARCH, RL_ALGO)
|
| 82 |
+
N_LAYER, D, N_HEAD = 2 + N_CORE * N_PAIRS, 384, 8
|
| 83 |
+
# Core applications (loops). Training draws one count per batch from TRAIN_LOOPS, in pretraining
|
| 84 |
+
# and in rl()'s fine-tune; eval and sampling apply model.n_loops, which the harness sets for its
|
| 85 |
+
# evals and rl() sets before each oracle call. DEFAULT_LOOPS is used for the validation curve and
|
| 86 |
+
# the harness's post-pretraining greedy check.
|
| 87 |
+
TRAIN_LOOPS = (1, 2, 3, 4, 5, 6, 7, 8)
|
| 88 |
+
DEFAULT_LOOPS = 2
|
| 89 |
+
VAL_LOOPS = (1, 2, 4, 8) # val loss at each count, once, when pretraining ends
|
| 90 |
+
# ---- RL knobs: the old harness's expert iteration (600 AdamW steps per round on up to 4 proofs
|
| 91 |
+
# per solved target, weighted x4, mixed with 20,000 replayed pretraining records), except for
|
| 92 |
+
# where the samples go. Each round every target gets RL_K attempts at RL_FIRST_LOOPS; a target
|
| 93 |
+
# all of them fail on gets RL_RETRY_K more (32 in all, as before) at ONE deeper loop count from
|
| 94 |
+
# RL_RETRY_LOOPS, assigned at random, so proofs that only deeper sampling finds enter the
|
| 95 |
+
# training set and no deep sample is spent on a target one loop already solves. The random
|
| 96 |
+
# assignment makes the retry calls a controlled comparison of loop counts on resistant targets.
|
| 97 |
+
# Rounds repeat until another one would not fit in the budget.
|
| 98 |
+
RL_FIRST_LOOPS, RL_K = 1, 8
|
| 99 |
+
RL_RETRY_LOOPS, RL_RETRY_K = (2, 4, 8), 24
|
| 100 |
+
# The fine-tune sees FT_RECORDS records per round, half the old harness's 600 steps x 128: in
|
| 101 |
+
# 509 the fine-tune had grown to ~74 s of a ~137 s round, so halving it fits about 16 rounds of
|
| 102 |
+
# sampling in RL_SECS instead of 11, with 27% fewer fine-tune records per run; the mix (20-33k
|
| 103 |
+
# records) still gets at least one epoch per round. Records come in the same token-budget
|
| 104 |
+
# batches as pretraining (TOK_BUDGET below) instead of 128-record batches padded to their
|
| 105 |
+
# longest proof, which with 7-14 line RL proofs in nearly every batch was ~3x the content.
|
| 106 |
+
# It uses pretraining's optimizer split: Muon (muon_step, MUON_WD) on the block matrices and the
|
| 107 |
+
# head, AdamW at FT_LR on embeddings, norms and biases. FT_MUON_LR keeps pretraining's 10:1
|
| 108 |
+
# Muon:AdamW ratio and is where pretraining's cosine ends (MUON_LR * MIN_LR_FRAC).
|
| 109 |
+
FT_RECORDS, FT_LR, FT_MUON_LR, FT_WARMUP = 300 * 128, 3e-4, 3e-3, 50
|
| 110 |
+
RETAIN, MAX_PER_THM, RL_WEIGHT = 20000, 4, 4
|
| 111 |
+
# MLP width held at 151's 1280: the fork's Block hardcodes 4 * D (1536 at D 384 would pass the
|
| 112 |
+
# 10M cap), so PeriLNBlock swaps fc1/fc2. 1280 != 3 * D keeps muon_step's QKV-by-shape test valid.
|
| 113 |
+
D_FF = 1280
|
| 114 |
+
BS, LR, MIN_LR_FRAC, WD = 128, 1e-3, 0.3, 0.1
|
| 115 |
+
MUON_LR, MUON_MOMENTUM = 0.01, 0.95
|
| 116 |
+
# Polar Express (Amsel et al. 2025) per-iteration quintic coefficients, as in modded-nanogpt
|
| 117 |
+
# (num_iters=5, safety factor 2e-2): singular values land in ~[0.86, 1.14] instead of the
|
| 118 |
+
# fixed quintic's ~[0.68, 1.13], at the same five iterations.
|
| 119 |
+
NS_COEFFS = (
|
| 120 |
+
(8.156554524902461, -22.48329292557795, 15.878769915207462),
|
| 121 |
+
(4.042929935166739, -2.808917465908714, 0.5000178451051316),
|
| 122 |
+
(3.8916678022926607, -2.772484153217685, 0.5060648178503393),
|
| 123 |
+
(3.285753657755655, -2.3681294933425376, 0.46449024233003106),
|
| 124 |
+
(2.3465413258596377, -1.7097828382687081, 0.42323551169305323),
|
| 125 |
+
)
|
| 126 |
+
# Ten times the AdamW group's per-step multiplicative decay (lr * wd) on the Muon matrices.
|
| 127 |
+
MUON_WD = 10 * WD * LR / MUON_LR
|
| 128 |
+
TOK_MODE = "lean_seq" # required by the harness (Lean protocol)
|
| 129 |
+
# Hybrid heads: half the heads get ALiBi (Press et al. 2021) with the standard slope set for
|
| 130 |
+
# H/2 heads, 2^(-8 i / (H/2)) = 1/4 .. 1/256 with 8 heads; the other half get slope 0, i.e. no
|
| 131 |
+
# positional signal at all (NoPE), so they can look citations up by content at any distance.
|
| 132 |
+
N_ALIBI = N_HEAD // 2
|
| 133 |
+
ALIBI_SLOPES = tuple(2.0 ** (-8.0 * (i + 1) / N_ALIBI) for i in range(N_ALIBI)) + (0.0,) * (
|
| 134 |
+
N_HEAD - N_ALIBI
|
| 135 |
+
)
|
| 136 |
+
VAL_N, CURVE_EVERY = 1024, 15 # records held out for val_loss; seconds between curve points
|
| 137 |
+
# Token-budget batches (fairseq max-tokens): each step takes a run of length-sorted records with
|
| 138 |
+
# count * padded_length <= TOK_BUDGET, so a batch of short proofs has many records and a batch of
|
| 139 |
+
# long ones few, and the padded token count per step is ~constant. 128 x 144 matches the real
|
| 140 |
+
# (unpadded) tokens of the incumbent's 128-record batches (mean record ~135 tokens), whose
|
| 141 |
+
# padding to the batch max (~400) made every step ~3x larger than its content.
|
| 142 |
+
TOK_BUDGET = 128 * 144
|
| 143 |
+
# Multi-token prediction (DeepSeek-V3 2024, Gloeckle et al. 2024), pretraining only: one extra
|
| 144 |
+
# Peri-LN block reads [trunk state at t; embedding of token t+1] and predicts token t+2 through
|
| 145 |
+
# the model's own ln_f/head. Its loss is added at this weight (DeepSeek-V3's early-training value).
|
| 146 |
+
MTP_WEIGHT = 0.3
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
# Muon update adapted from KellerJordan/Muon, commit
|
| 150 |
+
# f98f1cacc0263b04290753e32be8d498c1efc806 (muon.py).
|
| 151 |
+
# MIT License
|
| 152 |
+
# Copyright (c) 2024 Keller Jordan
|
| 153 |
+
#
|
| 154 |
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 155 |
+
# of this software and associated documentation files (the "Software"), to deal
|
| 156 |
+
# in the Software without restriction, including without limitation the rights
|
| 157 |
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 158 |
+
# copies of the Software, and to permit persons to whom the Software is
|
| 159 |
+
# furnished to do so, subject to the following conditions:
|
| 160 |
+
# The above copyright notice and this permission notice shall be included in all
|
| 161 |
+
# copies or substantial portions of the Software.
|
| 162 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 163 |
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 164 |
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 165 |
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 166 |
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 167 |
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 168 |
+
# SOFTWARE.
|
| 169 |
+
@torch.no_grad()
|
| 170 |
+
def muon_step(params, buffers, lr):
|
| 171 |
+
"""Nesterov momentum plus five bf16 Polar Express steps, on hidden matrices only."""
|
| 172 |
+
for p, momentum in zip(params, buffers, strict=True):
|
| 173 |
+
if p.grad is None:
|
| 174 |
+
continue
|
| 175 |
+
momentum.lerp_(p.grad, 1 - MUON_MOMENTUM)
|
| 176 |
+
update = p.grad.lerp(momentum, MUON_MOMENTUM).bfloat16()
|
| 177 |
+
# Only QKV has shape (3D, D) in this GPT; orthogonalize its roles separately.
|
| 178 |
+
if update.size(0) == 3 * update.size(1):
|
| 179 |
+
update = update.reshape(3, update.size(1), update.size(1))
|
| 180 |
+
transpose = update.size(-2) > update.size(-1)
|
| 181 |
+
if transpose:
|
| 182 |
+
update = update.mT
|
| 183 |
+
update = update / (update.norm(dim=(-2, -1), keepdim=True) * (1 + 2e-2) + 1e-6)
|
| 184 |
+
for a, b, c in NS_COEFFS:
|
| 185 |
+
gram = update @ update.mT
|
| 186 |
+
polynomial = b * gram + c * gram @ gram
|
| 187 |
+
update = a * update + polynomial @ update
|
| 188 |
+
if transpose:
|
| 189 |
+
update = update.mT
|
| 190 |
+
p.mul_(1 - lr * MUON_WD)
|
| 191 |
+
# lr may be a 0-d tensor (CUDA-graphed step); scale in p's dtype like add_(alpha=-lr)
|
| 192 |
+
p.sub_(lr * update.reshape_as(p).to(p.dtype))
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
class MuonStep:
|
| 196 |
+
"""muon_step on `matrices` with fresh momentum buffers, called once per step after backward
|
| 197 |
+
(grads must keep fixed addresses: zero_grad(set_to_none=False)). On CUDA the first call
|
| 198 |
+
captures the step as one CUDA graph and later calls replay it instead of ~400 kernel
|
| 199 |
+
launches; CPU smoke runs call muon_step directly."""
|
| 200 |
+
|
| 201 |
+
def __init__(self, matrices, device):
|
| 202 |
+
self.matrices, self.device = matrices, device
|
| 203 |
+
self.buffers = [torch.zeros_like(p) for p in matrices]
|
| 204 |
+
self.lr, self.graph = torch.zeros((), device=device), None
|
| 205 |
+
|
| 206 |
+
def __call__(self, lr):
|
| 207 |
+
self.lr.fill_(lr)
|
| 208 |
+
if self.device != "cuda":
|
| 209 |
+
muon_step(self.matrices, self.buffers, self.lr)
|
| 210 |
+
return
|
| 211 |
+
if self.graph is None:
|
| 212 |
+
state = self.matrices + self.buffers
|
| 213 |
+
saved = [t.clone() for t in state]
|
| 214 |
+
side = torch.cuda.Stream()
|
| 215 |
+
side.wait_stream(torch.cuda.current_stream())
|
| 216 |
+
with torch.cuda.stream(side):
|
| 217 |
+
muon_step(self.matrices, self.buffers, self.lr) # warm-up (lazy cuBLAS init)
|
| 218 |
+
torch.cuda.current_stream().wait_stream(side)
|
| 219 |
+
self.graph = torch.cuda.CUDAGraph()
|
| 220 |
+
with torch.cuda.graph(self.graph):
|
| 221 |
+
muon_step(self.matrices, self.buffers, self.lr)
|
| 222 |
+
with torch.no_grad():
|
| 223 |
+
for t, v in zip(state, saved, strict=True):
|
| 224 |
+
t.copy_(v) # undo the warm-up and capture updates
|
| 225 |
+
self.graph.replay()
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
class PeriLNBlock(Block):
|
| 229 |
+
"""P22 Peri-LN (Kim et al. 2025): the fork's pre-LN block plus a LayerNorm on each branch
|
| 230 |
+
output, so every residual write has unit scale times a learned gain. Attention has no RoPE:
|
| 231 |
+
`mask` is the additive ALiBi bias (B or 1, H, T, S) that LoopedGPT builds once per forward
|
| 232 |
+
and cos/sin are unused."""
|
| 233 |
+
|
| 234 |
+
def __init__(self, d, h):
|
| 235 |
+
super().__init__(d, h)
|
| 236 |
+
self.fc1, self.fc2 = torch.nn.Linear(d, D_FF), torch.nn.Linear(D_FF, d)
|
| 237 |
+
self.ln_attn_out, self.ln_mlp_out = torch.nn.LayerNorm(d), torch.nn.LayerNorm(d)
|
| 238 |
+
|
| 239 |
+
def attn(self, x, cos, sin, mask, cache):
|
| 240 |
+
B, T, D = x.shape
|
| 241 |
+
q, k, v = self.qkv(x).view(B, T, 3, self.h, D // self.h).permute(2, 0, 3, 1, 4)
|
| 242 |
+
if cache is not None: # the fork's preallocated KV cache, unchanged
|
| 243 |
+
if "k" not in cache:
|
| 244 |
+
cache["k"] = k.new_empty(B, self.h, cache["max"], D // self.h)
|
| 245 |
+
cache["v"] = v.new_empty(B, self.h, cache["max"], D // self.h)
|
| 246 |
+
cache["n"] = 0
|
| 247 |
+
n0, n1 = cache["n"], cache["n"] + T
|
| 248 |
+
cache["k"][:, :, n0:n1] = k
|
| 249 |
+
cache["v"][:, :, n0:n1] = v
|
| 250 |
+
cache["n"] = n1
|
| 251 |
+
k, v = cache["k"][:, :, :n1], cache["v"][:, :, :n1]
|
| 252 |
+
y = torch.nn.functional.scaled_dot_product_attention(q, k, v, attn_mask=mask.to(q.dtype))
|
| 253 |
+
return self.proj(y.transpose(1, 2).reshape(B, T, D))
|
| 254 |
+
|
| 255 |
+
def forward(self, x, cos, sin, mask=None, cache=None):
|
| 256 |
+
x = x + self.ln_attn_out(self.attn(self.ln1(x), cos, sin, mask, cache))
|
| 257 |
+
return x + self.ln_mlp_out(self.fc2(torch.nn.functional.gelu(self.fc1(self.ln2(x)))))
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
class LoopedGPT(GPT):
|
| 261 |
+
"""Looped trunk (Universal Transformer, Dehghani et al. 2018; sandwich layout and input
|
| 262 |
+
injection as in Geiping et al. 2025): blocks[0] is the entry block, blocks[1:-1] the core
|
| 263 |
+
pairs, of which loop k applies pair k % N_PAIRS, blocks[-1] the exit block. Every core pass
|
| 264 |
+
starts from ln_loop(state) + e, with e the entry block's output, so each pass sees an input
|
| 265 |
+
of the same scale and the prompt is re-injected instead of being buried under accumulated
|
| 266 |
+
writes.
|
| 267 |
+
|
| 268 |
+
P34: the fork's GPT with ALiBi (Press et al. 2021) instead of RoPE. Head h's attention
|
| 269 |
+
logits get -slope_h * (query position - key position), slopes 2^-1 .. 2^-8 for 8 heads, so
|
| 270 |
+
no rotation of q/k anywhere. Positions come from `pos` (sample.generate's left-padded
|
| 271 |
+
batches) or arange; key positions are kept in caches[0] so cached decoding sees the same
|
| 272 |
+
bias as the full forward. Causality/padding come from `mask` when given, else from rel < 0."""
|
| 273 |
+
|
| 274 |
+
def __init__(self, vocab, n_layer, d, n_head, seed, max_len=1024):
|
| 275 |
+
super().__init__(vocab, n_layer, d, n_head, max_len)
|
| 276 |
+
slopes = torch.tensor(ALIBI_SLOPES).view(1, n_head, 1, 1)
|
| 277 |
+
self.register_buffer("slopes", slopes, persistent=False)
|
| 278 |
+
self.ln_loop = torch.nn.LayerNorm(d)
|
| 279 |
+
self.n_loops, self.loop_rng = DEFAULT_LOOPS, random.Random(seed)
|
| 280 |
+
# Control 590's patch: run 198's trunk, the six blocks independent and applied once; n_loops is ignored.
|
| 281 |
+
self.untied = ARCH == "untied"
|
| 282 |
+
|
| 283 |
+
def kv_layers(self):
|
| 284 |
+
"""KV-cache layers sampling allocates at the current n_loops (the harness sizes batches by it)."""
|
| 285 |
+
return len(self.blocks) if self.untied else 2 + N_CORE * self.n_loops
|
| 286 |
+
|
| 287 |
+
def forward(self, idx, pos=None, mask=None, caches=None):
|
| 288 |
+
return self.head(self.ln_f(self.features(idx, pos, mask, caches)[0]))
|
| 289 |
+
|
| 290 |
+
def features(self, idx, pos=None, mask=None, caches=None):
|
| 291 |
+
"""The trunk: (final hidden state before ln_f, the ALiBi bias used)."""
|
| 292 |
+
B, T = idx.shape
|
| 293 |
+
if pos is None: # training/val: one (1, H, T, T) bias broadcast over the batch
|
| 294 |
+
pos = torch.arange(T, device=idx.device)[None]
|
| 295 |
+
key_pos = pos
|
| 296 |
+
if caches is not None: # incremental decoding: keys are every cached token
|
| 297 |
+
c = caches[0]
|
| 298 |
+
if "pos" not in c:
|
| 299 |
+
c["pos"], c["n_pos"] = pos.new_empty(pos.size(0), c["max"]), 0
|
| 300 |
+
n0, n1 = c["n_pos"], c["n_pos"] + T
|
| 301 |
+
c["pos"][:, n0:n1] = pos
|
| 302 |
+
c["n_pos"] = n1
|
| 303 |
+
key_pos = c["pos"][:, :n1]
|
| 304 |
+
rel = pos[:, None, :, None] - key_pos[:, None, None, :] # (B or 1, 1, T, S)
|
| 305 |
+
bias = -self.slopes * rel.to(self.slopes.dtype)
|
| 306 |
+
bias = bias.masked_fill(rel < 0 if mask is None else ~mask, float("-inf"))
|
| 307 |
+
if self.untied:
|
| 308 |
+
x = self.emb(idx)
|
| 309 |
+
for j, b in enumerate(self.blocks):
|
| 310 |
+
x = b(x, None, None, bias, None if caches is None else caches[j])
|
| 311 |
+
return x, bias
|
| 312 |
+
n = self.loop_rng.choice(TRAIN_LOOPS) if self.training else self.n_loops
|
| 313 |
+
entry, *core, exit_block = self.blocks
|
| 314 |
+
x = e = entry(self.emb(idx), None, None, bias, None if caches is None else caches[0])
|
| 315 |
+
for loop in range(n):
|
| 316 |
+
x = self.ln_loop(x) + e
|
| 317 |
+
for i in range(N_CORE):
|
| 318 |
+
j = 1 + (loop % N_PAIRS) * N_CORE + i # index in self.blocks
|
| 319 |
+
# sample.generate makes one cache dict per unique block; a shared block's keys
|
| 320 |
+
# and values differ per pass, so each pass gets its own sub-cache inside it.
|
| 321 |
+
c = caches and caches[j].setdefault(loop, {"max": caches[j]["max"]})
|
| 322 |
+
x = core[j - 1](x, None, None, bias, c)
|
| 323 |
+
x = exit_block(x, None, None, bias, None if caches is None else caches[-1])
|
| 324 |
+
return x, bias
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
class MTPHead(torch.nn.Module):
|
| 328 |
+
"""The MTP module. A separate nn.Module, never registered on the model, so the harness's
|
| 329 |
+
parameter count, RL AdamW and sampler never see it; it is dropped when pretrain() returns."""
|
| 330 |
+
|
| 331 |
+
def __init__(self, d, h):
|
| 332 |
+
super().__init__()
|
| 333 |
+
self.ln_h, self.ln_e = torch.nn.LayerNorm(d), torch.nn.LayerNorm(d)
|
| 334 |
+
self.proj = torch.nn.Linear(2 * d, d, bias=False)
|
| 335 |
+
self.block = PeriLNBlock(d, h)
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
def mtp_loss(model, mtp, x, m):
|
| 339 |
+
"""The fork's loss_on (next-token CE on proof tokens) plus MTP_WEIGHT times the CE of the
|
| 340 |
+
MTP module's token-(t+2) prediction at the same proof positions. Returns (total, main)."""
|
| 341 |
+
h, bias = model.features(x[:, :-1])
|
| 342 |
+
logits = model.head(model.ln_f(h))
|
| 343 |
+
V = logits.size(-1)
|
| 344 |
+
ce = torch.nn.functional.cross_entropy(
|
| 345 |
+
logits.reshape(-1, V).float(), x[:, 1:].reshape(-1), reduction="none"
|
| 346 |
+
)
|
| 347 |
+
main = (ce * m[:, 1:].reshape(-1)).sum() / m[:, 1:].sum()
|
| 348 |
+
# Position t (0..T-3) gets h_t and emb(x_{t+1}); causal attention over these keeps every
|
| 349 |
+
# prediction of x_{t+2} a function of x_{<=t+1}.
|
| 350 |
+
z = mtp.proj(torch.cat((mtp.ln_h(h[:, :-1]), mtp.ln_e(model.emb(x[:, 1:-1]))), -1))
|
| 351 |
+
z = mtp.block(z, None, None, bias[..., :-1, :-1], None)
|
| 352 |
+
ce2 = torch.nn.functional.cross_entropy(
|
| 353 |
+
model.head(model.ln_f(z)).reshape(-1, V).float(), x[:, 2:].reshape(-1), reduction="none"
|
| 354 |
+
)
|
| 355 |
+
aux = (ce2 * m[:, 2:].reshape(-1)).sum() / m[:, 2:].sum().clamp(min=1)
|
| 356 |
+
return main + MTP_WEIGHT * aux, main, aux
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def val_loss(model, ids, mask, ref_max, lens, tok, gen, autocast):
|
| 360 |
+
"""Mean loss over the first VAL_N records (never trained on), no shift augmentation."""
|
| 361 |
+
model.eval()
|
| 362 |
+
tot = 0.0
|
| 363 |
+
with torch.no_grad(), autocast:
|
| 364 |
+
for i in range(0, VAL_N, BS):
|
| 365 |
+
idxs = torch.arange(i, min(i + BS, VAL_N), device=ids.device)
|
| 366 |
+
x, m = ids[idxs], mask[idxs]
|
| 367 |
+
T = int(lens[idxs].max())
|
| 368 |
+
tot += loss_on(model, x[:, :T], m[:, :T]).item() * len(idxs)
|
| 369 |
+
model.train()
|
| 370 |
+
return tot / VAL_N
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
def to_gpu(data, tok, device):
|
| 374 |
+
"""Pad all (prompt, proof) records once into (N, T) ids + proof mask on the device."""
|
| 375 |
+
N, T = len(data), max(len(p) + len(q) for p, q in data)
|
| 376 |
+
ids = torch.full((N, T), tok.pad, dtype=torch.long)
|
| 377 |
+
mask = torch.zeros((N, T), dtype=torch.bool)
|
| 378 |
+
ref_max = torch.zeros(
|
| 379 |
+
N, dtype=torch.long
|
| 380 |
+
) # largest N<k> index used in the proof, for the shift augmentation
|
| 381 |
+
for i, (p, q) in enumerate(data):
|
| 382 |
+
ids[i, : len(p) + len(q)] = torch.tensor(p + q)
|
| 383 |
+
mask[i, len(p) : len(p) + len(q)] = True
|
| 384 |
+
ref_max[i] = max((x - tok.ref0 + 1 for x in q if x >= tok.ref0), default=0)
|
| 385 |
+
return ids.to(device), mask.to(device), ref_max.to(device), (ids != tok.pad).sum(1).to(device)
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
def token_batches(lens, n_train, gen, rng, first=VAL_N):
|
| 389 |
+
"""One epoch of token-budget batches: a random permutation of the n_train records from
|
| 390 |
+
`first` on, stably sorted by length (equal lengths stay shuffled), cut greedily into runs of
|
| 391 |
+
consecutive records with count * max_len <= TOK_BUDGET, and the runs' order shuffled.
|
| 392 |
+
Returns (order, cuts)."""
|
| 393 |
+
perm = torch.randperm(n_train, device=lens.device, generator=gen) + first
|
| 394 |
+
order = perm[torch.argsort(lens[perm], stable=True)]
|
| 395 |
+
sorted_lens = lens[order].cpu()
|
| 396 |
+
cuts, s = [], 0
|
| 397 |
+
while s < len(sorted_lens):
|
| 398 |
+
window = sorted_lens[s : s + TOK_BUDGET // int(sorted_lens[s])]
|
| 399 |
+
# count * max_len is non-decreasing along the window, so the fits form a prefix.
|
| 400 |
+
e = s + int((torch.arange(1, len(window) + 1) * window <= TOK_BUDGET).sum())
|
| 401 |
+
cuts.append((s, e, int(sorted_lens[e - 1]))) # sorted: last is the batch's max length
|
| 402 |
+
s = e
|
| 403 |
+
rng.shuffle(cuts)
|
| 404 |
+
return order, cuts
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
def gpu_batch(ids, mask, ref_max, lens, idxs, tok, gen, max_len=None, augment=True):
|
| 408 |
+
"""The fork's batch() + tok.shift_abs, vectorised: a random per-row offset is added to
|
| 409 |
+
every ref token, and each row's atoms go through a random permutation of the ten atom tokens
|
| 410 |
+
(positions after the statement header, which declares all ten in a fixed order). augment=False
|
| 411 |
+
leaves rows as sampled (policy-gradient rollouts)."""
|
| 412 |
+
x, m = ids[idxs], mask[idxs]
|
| 413 |
+
# Known on the host for training batches: passing it avoids a GPU sync every step.
|
| 414 |
+
T = int(lens[idxs].max()) if max_len is None else max_len
|
| 415 |
+
x, m = x[:, :T].clone(), m[:, :T]
|
| 416 |
+
if not augment:
|
| 417 |
+
return x, m
|
| 418 |
+
atom_ids = torch.tensor(tok.atom_ids, device=x.device)
|
| 419 |
+
slot = torch.full((tok.vocab_size,), -1, dtype=torch.long, device=x.device)
|
| 420 |
+
slot[atom_ids] = torch.arange(len(atom_ids), device=x.device)
|
| 421 |
+
a = slot[x]
|
| 422 |
+
a[:, :HEADER_LEN] = -1
|
| 423 |
+
perm = torch.rand(len(idxs), len(atom_ids), device=x.device, generator=gen).argsort(1)
|
| 424 |
+
x = torch.where(a >= 0, atom_ids[perm.gather(1, a.clamp(min=0))], x)
|
| 425 |
+
if tok.mode in ("abs", "lean_seq"): # lean_seq: names n1.. get the same start offset
|
| 426 |
+
room = MAXN - ref_max[idxs]
|
| 427 |
+
shift = (
|
| 428 |
+
(torch.rand(len(idxs), device=x.device, generator=gen) * (room + 1))
|
| 429 |
+
.long()
|
| 430 |
+
.clamp(max=room)
|
| 431 |
+
)
|
| 432 |
+
is_ref = (x >= tok.ref0) & m
|
| 433 |
+
x = torch.where(is_ref, x + shift[:, None], x)
|
| 434 |
+
return x, m
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
def pretrain(train_recs, budget_secs, device, seed, log):
|
| 438 |
+
t0 = time.time()
|
| 439 |
+
tok = make_tokenizer(TOK_MODE)
|
| 440 |
+
data = [(tok.encode_prompt(r["prompt"]), tok.encode_proof(r["proof"])) for r in train_recs]
|
| 441 |
+
ids, mask, ref_max, lens = to_gpu(data, tok, device)
|
| 442 |
+
gen = torch.Generator(device=device)
|
| 443 |
+
gen.manual_seed(seed)
|
| 444 |
+
model = LoopedGPT(tok.vocab_size, N_LAYER, D, N_HEAD, seed)
|
| 445 |
+
model.blocks = torch.nn.ModuleList(PeriLNBlock(D, N_HEAD) for _ in range(N_LAYER))
|
| 446 |
+
model.blocks.apply(model._init) # fork init: zero biases
|
| 447 |
+
model = model.to(device)
|
| 448 |
+
mtp = MTPHead(D, N_HEAD)
|
| 449 |
+
mtp.apply(model._init)
|
| 450 |
+
mtp = mtp.to(device)
|
| 451 |
+
# Compile the repeated blocks once each (torch >= 2.9; dynamic shapes, ~14 s): ~14% faster
|
| 452 |
+
# steps. The coalescing tiling analysis crashes on dynamic shapes, so it is off. Undone at
|
| 453 |
+
# handoff so the harness's RL fine-tune and KV-cache sampling run eager.
|
| 454 |
+
torch._inductor.config.triton.coalesce_tiling_analysis = False
|
| 455 |
+
compiled = list(model.blocks) + [mtp.block]
|
| 456 |
+
for b in compiled if device == "cuda" else []: # CPU smoke runs stay eager
|
| 457 |
+
b.compile(dynamic=True)
|
| 458 |
+
for p in list(model.blocks.parameters()) + list(mtp.parameters()):
|
| 459 |
+
if p.ndim == 2:
|
| 460 |
+
# Orthogonal matrices have element second moment gain^2 / max(rows, cols).
|
| 461 |
+
torch.nn.init.orthogonal_(p, gain=0.02 * math.sqrt(max(p.shape)))
|
| 462 |
+
log(
|
| 463 |
+
f"pretrain: {model.n_params():,} params, {len(data):,} records on {device} "
|
| 464 |
+
f"after {time.time() - t0:.0f}s, budget {budget_secs}s"
|
| 465 |
+
)
|
| 466 |
+
# The output readout joins the hidden matrices under Muon; embeddings stay on AdamW.
|
| 467 |
+
trainable = list(model.parameters()) + list(mtp.parameters())
|
| 468 |
+
matrices = [p for p in model.blocks.parameters() if p.ndim == 2] + [model.head.weight]
|
| 469 |
+
matrices += [p for p in mtp.parameters() if p.ndim == 2]
|
| 470 |
+
matrix_ids = {id(p) for p in matrices}
|
| 471 |
+
auxiliary = [p for p in trainable if id(p) not in matrix_ids]
|
| 472 |
+
muon = MuonStep(matrices, device)
|
| 473 |
+
opt = torch.optim.AdamW(
|
| 474 |
+
auxiliary, lr=LR, weight_decay=WD, betas=(0.9, 0.95), fused=device == "cuda"
|
| 475 |
+
)
|
| 476 |
+
autocast = torch.autocast("cuda", dtype=torch.bfloat16, enabled=(device == "cuda"))
|
| 477 |
+
model.train()
|
| 478 |
+
step, last_loss, records_seen = 0, float("nan"), 0
|
| 479 |
+
curve, recent, recent_aux, next_point = [], [], [], CURVE_EVERY
|
| 480 |
+
n_train = len(data) - VAL_N # records [0, VAL_N) are the val slice
|
| 481 |
+
rng, cuts, batches_per_epoch = random.Random(seed), [], None
|
| 482 |
+
order = torch.empty(0, dtype=torch.long, device=device)
|
| 483 |
+
while True:
|
| 484 |
+
frac = (
|
| 485 |
+
time.time() - t0
|
| 486 |
+
) / budget_secs # cosine over wall-clock, so the cap is the schedule
|
| 487 |
+
if frac >= 1.0:
|
| 488 |
+
break
|
| 489 |
+
step += 1
|
| 490 |
+
# No warmup (as in modded-nanogpt): Muon's step is normalized and Adam's is ~lr per
|
| 491 |
+
# element from step 1, and Peri-LN normalizes every branch write.
|
| 492 |
+
lr = LR * MIN_LR_FRAC + 0.5 * LR * (1 - MIN_LR_FRAC) * (1 + math.cos(math.pi * frac))
|
| 493 |
+
for g in opt.param_groups:
|
| 494 |
+
g["lr"] = lr
|
| 495 |
+
if not cuts: # new epoch
|
| 496 |
+
order, cuts = token_batches(lens, n_train, gen, rng)
|
| 497 |
+
batches_per_epoch = len(cuts)
|
| 498 |
+
s, e, T = cuts.pop()
|
| 499 |
+
idxs = order[s:e]
|
| 500 |
+
records_seen += e - s
|
| 501 |
+
x, m = gpu_batch(ids, mask, ref_max, lens, idxs, tok, gen, T)
|
| 502 |
+
with autocast:
|
| 503 |
+
loss, main, aux = mtp_loss(model, mtp, x, m)
|
| 504 |
+
model.zero_grad(set_to_none=False) # grads keep fixed addresses for the Muon CUDA graph
|
| 505 |
+
mtp.zero_grad(set_to_none=False)
|
| 506 |
+
loss.backward()
|
| 507 |
+
torch.nn.utils.clip_grad_norm_(trainable, 1.0)
|
| 508 |
+
opt.step()
|
| 509 |
+
muon(MUON_LR * lr / LR)
|
| 510 |
+
if step % 20 == 0:
|
| 511 |
+
last_loss = main.item() # the next-token CE, comparable with earlier runs
|
| 512 |
+
recent.append(last_loss)
|
| 513 |
+
recent_aux.append(aux.item())
|
| 514 |
+
if (
|
| 515 |
+
time.time() - t0 >= next_point
|
| 516 |
+
): # curve point: mean recent train loss + val loss on the held-out slice
|
| 517 |
+
curve.append(
|
| 518 |
+
{
|
| 519 |
+
"secs": round(time.time() - t0),
|
| 520 |
+
"step": step,
|
| 521 |
+
"train_loss": sum(recent) / len(recent) if recent else last_loss,
|
| 522 |
+
"val_loss": val_loss(model, ids, mask, ref_max, lens, tok, gen, autocast),
|
| 523 |
+
"mtp_loss": sum(recent_aux) / len(recent_aux) if recent_aux else None,
|
| 524 |
+
}
|
| 525 |
+
)
|
| 526 |
+
log(
|
| 527 |
+
f"pretrain step {step} train {curve[-1]['train_loss']:.4f} "
|
| 528 |
+
f"val {curve[-1]['val_loss']:.4f} lr {lr:.2e} {curve[-1]['secs']}s"
|
| 529 |
+
)
|
| 530 |
+
recent, recent_aux, next_point = [], [], next_point + CURVE_EVERY
|
| 531 |
+
val_by_loops = {}
|
| 532 |
+
for n in (VAL_LOOPS if not model.untied else (DEFAULT_LOOPS,)) if step else (): # no steps: a checkpoint rebuild, not a training run
|
| 533 |
+
model.n_loops = n
|
| 534 |
+
val_by_loops[n] = val_loss(model, ids, mask, ref_max, lens, tok, gen, autocast)
|
| 535 |
+
model.n_loops = DEFAULT_LOOPS
|
| 536 |
+
log(f"pretrain val loss by loops: {val_by_loops}")
|
| 537 |
+
for b in compiled:
|
| 538 |
+
b._compiled_call_impl = None
|
| 539 |
+
model.eval()
|
| 540 |
+
return (
|
| 541 |
+
model,
|
| 542 |
+
tok,
|
| 543 |
+
{
|
| 544 |
+
"steps": step,
|
| 545 |
+
"records_seen": records_seen,
|
| 546 |
+
"epochs": records_seen / n_train,
|
| 547 |
+
"batches_per_epoch": batches_per_epoch,
|
| 548 |
+
"tok_budget": TOK_BUDGET,
|
| 549 |
+
"last_loss": last_loss,
|
| 550 |
+
"train_loops": TRAIN_LOOPS,
|
| 551 |
+
"default_loops": DEFAULT_LOOPS,
|
| 552 |
+
"val_by_loops": val_by_loops,
|
| 553 |
+
"curve": curve,
|
| 554 |
+
},
|
| 555 |
+
)
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
def finetune(model, tok, data, rng, device):
|
| 559 |
+
"""The RL fine-tune: pretraining's optimizers (Muon on the hidden matrices, AdamW on the
|
| 560 |
+
rest), linear warmup then cosine to lr/10, over FT_RECORDS records in token-budget batches
|
| 561 |
+
(to_gpu / token_batches / gpu_batch, as pretraining). Muon's momentum restarts every round,
|
| 562 |
+
as AdamW's moments did. The model is in train mode, so every batch draws its own loop count
|
| 563 |
+
from TRAIN_LOOPS. Returns (last loss, steps)."""
|
| 564 |
+
ids, mask, ref_max, lens = to_gpu(data, tok, device)
|
| 565 |
+
gen = torch.Generator(device=device)
|
| 566 |
+
gen.manual_seed(rng.getrandbits(31))
|
| 567 |
+
plan, seen = [], 0 # (order, start, end, padded length) per step, epoch after epoch
|
| 568 |
+
while seen < FT_RECORDS:
|
| 569 |
+
order, cuts = token_batches(lens, len(data), gen, rng, first=0)
|
| 570 |
+
for s, e, T in cuts:
|
| 571 |
+
if seen >= FT_RECORDS:
|
| 572 |
+
break
|
| 573 |
+
plan.append((order, s, e, T))
|
| 574 |
+
seen += e - s
|
| 575 |
+
matrices = [p for p in model.blocks.parameters() if p.ndim == 2] + [model.head.weight]
|
| 576 |
+
matrix_ids = {id(p) for p in matrices}
|
| 577 |
+
auxiliary = [p for p in model.parameters() if id(p) not in matrix_ids]
|
| 578 |
+
opt = torch.optim.AdamW(auxiliary, lr=FT_LR, weight_decay=0.1, betas=(0.9, 0.95))
|
| 579 |
+
muon = MuonStep(matrices, device)
|
| 580 |
+
autocast = torch.autocast("cuda", dtype=torch.bfloat16, enabled=(device == "cuda"))
|
| 581 |
+
model.train()
|
| 582 |
+
for step, (order, s, e, T) in enumerate(plan, 1):
|
| 583 |
+
lr = (
|
| 584 |
+
FT_LR * step / FT_WARMUP
|
| 585 |
+
if step < FT_WARMUP
|
| 586 |
+
else FT_LR / 10 + 0.45 * FT_LR * (1 + math.cos(math.pi * step / len(plan)))
|
| 587 |
+
)
|
| 588 |
+
for g in opt.param_groups:
|
| 589 |
+
g["lr"] = lr
|
| 590 |
+
x, m = gpu_batch(ids, mask, ref_max, lens, order[s:e], tok, gen, T)
|
| 591 |
+
with autocast:
|
| 592 |
+
loss = loss_on(model, x, m)
|
| 593 |
+
model.zero_grad(set_to_none=False) # grads keep fixed addresses for the Muon CUDA graph
|
| 594 |
+
loss.backward()
|
| 595 |
+
torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
|
| 596 |
+
opt.step()
|
| 597 |
+
muon(FT_MUON_LR * lr / FT_LR)
|
| 598 |
+
model.eval()
|
| 599 |
+
return loss.item(), len(plan)
|
| 600 |
+
|
| 601 |
+
|
| 602 |
+
# Targets per round, picked by pick_targets: the old harness's fixed 1,500 targets, now drawn from the
|
| 603 |
+
# whole pool (thousands, body 7 to ~45) with the samples aimed at the frontier.
|
| 604 |
+
N_ROUND = 1500
|
| 605 |
+
|
| 606 |
+
|
| 607 |
+
def pick_targets(targets, found, rng, n=N_ROUND):
|
| 608 |
+
"""n targets for this round. Bands (body lines) get weight 0.1 + their solved fraction up to one
|
| 609 |
+
band past the highest band with any solve, and 0.02 beyond it, so sampling follows the frontier
|
| 610 |
+
instead of spending most of a round on targets far out of reach; within a band, unsolved targets
|
| 611 |
+
come first."""
|
| 612 |
+
bands = sorted({t["band"] for t in targets}, key=lambda b: int(b.split("-")[0].rstrip("+")))
|
| 613 |
+
by = {b: [t for t in targets if t["band"] == b] for b in bands}
|
| 614 |
+
rate = {b: sum(bool(found[t["name"]]) for t in by[b]) / len(by[b]) for b in bands}
|
| 615 |
+
top = max((i for i, b in enumerate(bands) if rate[b] > 0), default=-1)
|
| 616 |
+
w = {b: (0.1 + rate[b]) if i <= top + 1 else 0.02 for i, b in enumerate(bands)}
|
| 617 |
+
out = []
|
| 618 |
+
for b in bands:
|
| 619 |
+
k = min(len(by[b]), round(n * w[b] / sum(w.values())))
|
| 620 |
+
unsolved = [t for t in by[b] if not found[t["name"]]]
|
| 621 |
+
solved = [t for t in by[b] if found[t["name"]]]
|
| 622 |
+
rng.shuffle(unsolved)
|
| 623 |
+
rng.shuffle(solved)
|
| 624 |
+
out += (unsolved + solved)[:k]
|
| 625 |
+
return out
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
@torch.no_grad()
|
| 629 |
+
def rollout_stats(model, tok, rows, device):
|
| 630 |
+
"""Diagnostics on a round's own rollouts, before any update on them, at the model's current n_loops: mean per-token
|
| 631 |
+
entropy of the policy at temperature 1 (sampling uses TEMP), mean -log p of the sampled tokens, mean rollout
|
| 632 |
+
length in tokens, and targets whose rollouts all pass / all fail (zero GRPO advantage). Batching uses its own
|
| 633 |
+
generator and rng, so the run's random streams are the same as without it."""
|
| 634 |
+
items = [(tok.encode_prompt(r["prompt"]), ids) for r in rows for ids, _ in r["rollouts"]]
|
| 635 |
+
ids, mask, _, lens = to_gpu(items, tok, device)
|
| 636 |
+
gen = torch.Generator(device=device)
|
| 637 |
+
gen.manual_seed(0)
|
| 638 |
+
order, cuts = token_batches(lens, len(items), gen, random.Random(0), first=0)
|
| 639 |
+
model.eval()
|
| 640 |
+
sums = {k: 0.0 for k in ("entropy", "nll", "entropy_t", "nll_t")}
|
| 641 |
+
n = 0
|
| 642 |
+
for s, e, T in cuts:
|
| 643 |
+
x, m = gpu_batch(ids, mask, None, lens, order[s:e], tok, gen, T, augment=False)
|
| 644 |
+
with torch.autocast("cuda", dtype=torch.bfloat16, enabled=(device == "cuda")):
|
| 645 |
+
logits = model(x[:, :-1]).float()
|
| 646 |
+
m = m[:, 1:]
|
| 647 |
+
for suffix, temp in (("", 1.0), ("_t", GRPO_TEMP)):
|
| 648 |
+
logp = torch.log_softmax(logits / temp, -1)
|
| 649 |
+
sums["entropy" + suffix] += float(((-(logp.exp() * logp).sum(-1)) * m).sum())
|
| 650 |
+
sums["nll" + suffix] += float((-logp.gather(-1, x[:, 1:, None]).squeeze(-1) * m).sum())
|
| 651 |
+
n += float(m.sum())
|
| 652 |
+
# At the sampling temperature E[-log q(token)] = H(q) exactly, so nll_t well above entropy_t means the sampler
|
| 653 |
+
# and this forward pass disagree.
|
| 654 |
+
return {**{k: v / n for k, v in sums.items()}, "tokens": n / len(items),
|
| 655 |
+
"all_pass": sum(all(ok for _, ok in r["rollouts"]) for r in rows),
|
| 656 |
+
"all_fail": sum(not any(ok for _, ok in r["rollouts"]) for r in rows)}
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
def fmt_stats(rs):
|
| 660 |
+
return (f"rollout entropy {rs['entropy']:.3f}, nll {rs['nll']:.3f}, at T={GRPO_TEMP} entropy "
|
| 661 |
+
f"{rs['entropy_t']:.3f} nll {rs['nll_t']:.3f}, {rs['tokens']:.0f} tokens, "
|
| 662 |
+
f"all pass {rs['all_pass']}, all fail {rs['all_fail']}")
|
| 663 |
+
|
| 664 |
+
|
| 665 |
+
# ---- Per-round KL probes (both arms; v4 on). Exact KLs between next-token distributions at temperature 1, summed over
|
| 666 |
+
# the vocabulary and averaged over proof tokens, both directions, against two references: the previous round's
|
| 667 |
+
# policy (this round's step) and the frozen pretrained model (total drift). On three sets: a sample of this round's
|
| 668 |
+
# rollouts, PROBE_PRETRAIN_N pretraining val records (held out of pretraining, though RL's retained SFT may draw
|
| 669 |
+
# them), and PROBE_GOLD_N dev gold proofs, which the harness hands over as oracle.gold for likelihood only. Weights
|
| 670 |
+
# go to <out>/rl_round_NNN.pt every CKPT_EVERY rounds, so any other KL can be computed later.
|
| 671 |
+
PROBE_ROLLOUTS, PROBE_PRETRAIN_N, PROBE_GOLD_N, CKPT_EVERY = 2048, 512, 200, 5
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
@torch.no_grad()
|
| 675 |
+
def kl_pair(p_model, q_model, tok, items, device):
|
| 676 |
+
"""Mean per proof token over (prompt ids, proof ids) items: KL(p || q), KL(q || p), and each model's -log p of
|
| 677 |
+
the tokens."""
|
| 678 |
+
ids, mask, _, lens = to_gpu(items, tok, device)
|
| 679 |
+
gen = torch.Generator(device=device)
|
| 680 |
+
gen.manual_seed(0)
|
| 681 |
+
order, cuts = token_batches(lens, len(items), gen, random.Random(0), first=0)
|
| 682 |
+
sums = {k: 0.0 for k in ("kl_pq", "kl_qp", "nll_p", "nll_q")}
|
| 683 |
+
n = 0.0
|
| 684 |
+
for s, e, T in cuts:
|
| 685 |
+
x, m = gpu_batch(ids, mask, None, lens, order[s:e], tok, gen, T, augment=False)
|
| 686 |
+
m = m[:, 1:]
|
| 687 |
+
with torch.autocast("cuda", dtype=torch.bfloat16, enabled=(device == "cuda")):
|
| 688 |
+
lp, lq = (torch.log_softmax(mod(x[:, :-1]).float(), -1) for mod in (p_model, q_model))
|
| 689 |
+
sums["kl_pq"] += float(((lp.exp() * (lp - lq)).sum(-1) * m).sum())
|
| 690 |
+
sums["kl_qp"] += float(((lq.exp() * (lq - lp)).sum(-1) * m).sum())
|
| 691 |
+
sums["nll_p"] -= float((lp.gather(-1, x[:, 1:, None]).squeeze(-1) * m).sum())
|
| 692 |
+
sums["nll_q"] -= float((lq.gather(-1, x[:, 1:, None]).squeeze(-1) * m).sum())
|
| 693 |
+
n += float(m.sum())
|
| 694 |
+
return {k: v / max(n, 1.0) for k, v in sums.items()}
|
| 695 |
+
|
| 696 |
+
|
| 697 |
+
class Probe:
|
| 698 |
+
"""Holds the frozen pretrained model and the previous round's weights; measure() after each round's update."""
|
| 699 |
+
|
| 700 |
+
def __init__(self, model, tok, train_recs, oracle, device, log):
|
| 701 |
+
self.tok, self.device, self.log, self.out = tok, device, log, oracle.a.out
|
| 702 |
+
self.pre, self.prev = copy.deepcopy(model).eval(), copy.deepcopy(model).eval()
|
| 703 |
+
if getattr(oracle, "pretrained_state", None) is not None: # a resumed run: drift from the original pretrain
|
| 704 |
+
self.pre.load_state_dict(oracle.pretrained_state)
|
| 705 |
+
pick = random.Random(1234)
|
| 706 |
+
enc = lambda r: (tok.encode_prompt(r["prompt"]), tok.encode_proof(r["proof"])) # noqa: E731
|
| 707 |
+
self.pretrain = [enc(r) for r in pick.sample(train_recs[:VAL_N], min(PROBE_PRETRAIN_N, VAL_N))]
|
| 708 |
+
gold = getattr(oracle, "gold", [])
|
| 709 |
+
self.gold = [enc(r) for r in pick.sample(gold, min(PROBE_GOLD_N, len(gold)))]
|
| 710 |
+
self.rng, self.history = random.Random(4321), []
|
| 711 |
+
|
| 712 |
+
def measure(self, model, rows, round_n):
|
| 713 |
+
"""rows: this round's first-pass rollouts, sampled by the previous round's weights (self.prev)."""
|
| 714 |
+
items = [(self.tok.encode_prompt(r["prompt"]), ids) for r in rows for ids, _ in r["rollouts"]]
|
| 715 |
+
items = self.rng.sample(items, min(PROBE_ROLLOUTS, len(items)))
|
| 716 |
+
loops = model.n_loops
|
| 717 |
+
model.n_loops = self.prev.n_loops = self.pre.n_loops = RL_FIRST_LOOPS
|
| 718 |
+
model.eval()
|
| 719 |
+
step = kl_pair(self.prev, model, self.tok, items, self.device)
|
| 720 |
+
roll = kl_pair(model, self.pre, self.tok, items, self.device)
|
| 721 |
+
pt = kl_pair(model, self.pre, self.tok, self.pretrain, self.device)
|
| 722 |
+
gold = kl_pair(model, self.pre, self.tok, self.gold, self.device) if self.gold else {"nll_p": float("nan")}
|
| 723 |
+
model.n_loops = loops
|
| 724 |
+
r = {"round": round_n, "step": step["kl_pq"], "step_rev": step["kl_qp"], "pre_roll": roll["kl_pq"],
|
| 725 |
+
"pre_roll_rev": roll["kl_qp"], "pre_pt": pt["kl_pq"], "pre_pt_rev": pt["kl_qp"],
|
| 726 |
+
"nll_pt": pt["nll_p"], "nll_gold": gold["nll_p"]}
|
| 727 |
+
self.history.append(r)
|
| 728 |
+
self.log(f"probe round {round_n}: KL(old||new) {r['step']:.5f} KL(new||old) {r['step_rev']:.5f}, "
|
| 729 |
+
f"rollouts KL(pi||pre) {r['pre_roll']:.4f} KL(pre||pi) {r['pre_roll_rev']:.4f}, "
|
| 730 |
+
f"pretrain KL(pi||pre) {r['pre_pt']:.4f} KL(pre||pi) {r['pre_pt_rev']:.4f}, "
|
| 731 |
+
f"nll pretrain {r['nll_pt']:.4f} gold {r['nll_gold']:.4f}")
|
| 732 |
+
if round_n % CKPT_EVERY == 0:
|
| 733 |
+
torch.save({k: v.detach().cpu() for k, v in model.state_dict().items()}, f"{self.out}/rl_round_{round_n:03d}.pt")
|
| 734 |
+
self.prev.load_state_dict(model.state_dict())
|
| 735 |
+
|
| 736 |
+
|
| 737 |
+
def rl(model, tok, targets, train_recs, oracle, budget_secs, device, seed, log):
|
| 738 |
+
if RL_ALGO == "grpo":
|
| 739 |
+
return rl_grpo(model, tok, targets, train_recs, oracle, device, seed, log)
|
| 740 |
+
return rl_ei(model, tok, targets, train_recs, oracle, device, seed, log)
|
| 741 |
+
|
| 742 |
+
|
| 743 |
+
def rl_ei(model, tok, targets, train_recs, oracle, device, seed, log):
|
| 744 |
+
rng = random.Random(seed)
|
| 745 |
+
probe = Probe(model, tok, train_recs, oracle, device, log)
|
| 746 |
+
found = {t["name"]: {} for t in targets} # name -> {normalized proof: proof text}
|
| 747 |
+
for name, proofs in oracle.found.items(): # a resumed run's earlier proofs; empty on a fresh run
|
| 748 |
+
for proof in proofs:
|
| 749 |
+
found[name].setdefault(norm(proof), proof)
|
| 750 |
+
rounds, round_secs, retries, ft_steps, history = 0, 0.0, [], [], []
|
| 751 |
+
# Start a round only if one as long as the last (plus 15%) still fits in the budget.
|
| 752 |
+
while oracle.left() > 1.15 * round_secs:
|
| 753 |
+
t0 = oracle.used()
|
| 754 |
+
model.n_loops = RL_FIRST_LOOPS
|
| 755 |
+
picked = pick_targets(targets, found, rng)
|
| 756 |
+
rows = oracle.sample_rollouts(model, picked, RL_K)
|
| 757 |
+
rs = rollout_stats(model, tok, rows, device) # first pass only: comparable to the GRPO arm's rounds
|
| 758 |
+
first_pass = list(rows)
|
| 759 |
+
failed = [t for t, row in zip(picked, rows, strict=True) if not row["proofs"]]
|
| 760 |
+
rng.shuffle(failed)
|
| 761 |
+
for i, n in enumerate(RL_RETRY_LOOPS):
|
| 762 |
+
part = failed[i :: len(RL_RETRY_LOOPS)]
|
| 763 |
+
if not part:
|
| 764 |
+
continue
|
| 765 |
+
model.n_loops = n
|
| 766 |
+
part_rows = oracle.sample(model, part, RL_RETRY_K)
|
| 767 |
+
cracked = sum(bool(row["proofs"]) for row in part_rows)
|
| 768 |
+
retries.append(
|
| 769 |
+
{"round": rounds + 1, "loops": n, "targets": len(part), "cracked": cracked}
|
| 770 |
+
)
|
| 771 |
+
rows += part_rows
|
| 772 |
+
for row in rows:
|
| 773 |
+
for proof in row["proofs"]:
|
| 774 |
+
found[row["name"]].setdefault(norm(proof), proof)
|
| 775 |
+
mix = []
|
| 776 |
+
for t in targets:
|
| 777 |
+
proofs = list(found[t["name"]].values())
|
| 778 |
+
rng.shuffle(proofs)
|
| 779 |
+
mix += [(t["prompt"], proof) for proof in proofs[:MAX_PER_THM]] * RL_WEIGHT
|
| 780 |
+
n_rl = len(mix)
|
| 781 |
+
# No solves yet: skip the fine-tune and sample again (the old harness stopped RL here). The round is still
|
| 782 |
+
# logged, with its rollout stats.
|
| 783 |
+
loss, steps = float("nan"), 0
|
| 784 |
+
if n_rl:
|
| 785 |
+
mix += [(r["prompt"], r["proof"]) for r in rng.sample(train_recs, min(RETAIN, len(train_recs)))] # min: CPU smoke runs have 3k records
|
| 786 |
+
data = [(tok.encode_prompt(p), tok.encode_proof(q)) for p, q in mix]
|
| 787 |
+
loss, steps = finetune(model, tok, data, rng, device)
|
| 788 |
+
ft_steps.append(steps)
|
| 789 |
+
rounds += 1
|
| 790 |
+
probe.measure(model, first_pass, rounds)
|
| 791 |
+
round_secs = oracle.used() - t0
|
| 792 |
+
history.append({"round": rounds, "rollouts": rs})
|
| 793 |
+
log(
|
| 794 |
+
f"rl round {rounds}: {n_rl} RL records, fine-tune loss {loss:.4f} in {steps} steps, "
|
| 795 |
+
f"{fmt_stats(rs)}, round {round_secs:.0f}s, {oracle.left():.0f}s left"
|
| 796 |
+
)
|
| 797 |
+
model.n_loops = DEFAULT_LOOPS
|
| 798 |
+
return {
|
| 799 |
+
"rounds": rounds,
|
| 800 |
+
"first_loops": RL_FIRST_LOOPS,
|
| 801 |
+
"k_first": RL_K,
|
| 802 |
+
"retry_loops": RL_RETRY_LOOPS,
|
| 803 |
+
"k_retry": RL_RETRY_K,
|
| 804 |
+
"retries": retries,
|
| 805 |
+
"ft_records": FT_RECORDS,
|
| 806 |
+
"ft_steps": ft_steps,
|
| 807 |
+
"ft_optimizer": "muon (polar express) on block matrices and head + adamw on the rest",
|
| 808 |
+
"ft_lr": FT_LR,
|
| 809 |
+
"ft_muon_lr": FT_MUON_LR,
|
| 810 |
+
"history": history,
|
| 811 |
+
"probe": probe.history,
|
| 812 |
+
}
|
| 813 |
+
|
| 814 |
+
|
| 815 |
+
# ---- GRPO arm (ND_RL=grpo). Group-relative policy gradient (GRPO, Shao et al. 2024) with Dr. GRPO's
|
| 816 |
+
# unnormalised advantages r - mean(r) and a constant length normaliser instead of each rollout's length
|
| 817 |
+
# (Liu et al. 2025), and DAPO's dropping of groups that are all pass or all fail (Yu et al. 2025), since
|
| 818 |
+
# they carry no signal. The found-proof pool: once Lean accepts a proof of a target, a later group on
|
| 819 |
+
# that target with no success gets one stored proof in place of a failed rollout, with reward 1, so a
|
| 820 |
+
# target solved once keeps giving a gradient (that member is off-policy; the rest are the model's own).
|
| 821 |
+
# Same target picking, rollouts per target (EI's first pass) and budget as the EI arm; one pass over each
|
| 822 |
+
# round's rollouts in many steps, so a PPO clipped ratio (Schulman et al. 2017) against the sampling policy
|
| 823 |
+
# keeps later steps from moving far, with DAPO's clip-higher and a dual clip on negative advantages (Ye et
|
| 824 |
+
# al. 2020), Leon's settings. The loss and the ratio score the distribution the rollouts came from, logits
|
| 825 |
+
# / GRPO_TEMP (the harness's TEMP). Optimizer split as in EI's fine-tune (Muon on the matrices, AdamW on
|
| 826 |
+
# the rest), at a tenth of its rates. v2 (2026-10-14) used AdamW 1e-4 on everything, no ratio, loss at
|
| 827 |
+
# T=1, and collapsed: unparseable samples up to 100%, entropy spikes to 0.9.
|
| 828 |
+
GRPO_G = 8 # rollouts per target per round
|
| 829 |
+
GRPO_LR, GRPO_MUON_LR, GRPO_WARMUP = FT_LR / 10, FT_MUON_LR / 10, 20
|
| 830 |
+
GRPO_TEMP = 0.8 # must equal the harness's sampling TEMP (asserted there)
|
| 831 |
+
GRPO_CLIP_LOW, GRPO_CLIP_HIGH, GRPO_DUAL_CLIP = 0.2, 0.28, 3.0
|
| 832 |
+
GRPO_LEN_NORM = 256 # constant per-rollout token normaliser
|
| 833 |
+
GRPO_RETAIN_W = 0.5 # retained-pretraining SFT term per step, in place of EI's replayed records
|
| 834 |
+
|
| 835 |
+
|
| 836 |
+
def rl_grpo(model, tok, targets, train_recs, oracle, device, seed, log):
|
| 837 |
+
rng = random.Random(seed)
|
| 838 |
+
gen = torch.Generator(device=device)
|
| 839 |
+
gen.manual_seed(seed)
|
| 840 |
+
found = {t["name"]: {} for t in targets}
|
| 841 |
+
matrices = [p for p in model.blocks.parameters() if p.ndim == 2] + [model.head.weight]
|
| 842 |
+
matrix_ids = {id(p) for p in matrices}
|
| 843 |
+
auxiliary = [p for p in model.parameters() if id(p) not in matrix_ids]
|
| 844 |
+
opt = torch.optim.AdamW(auxiliary, lr=GRPO_LR, weight_decay=0.0, betas=(0.9, 0.95))
|
| 845 |
+
muon = MuonStep(matrices, device)
|
| 846 |
+
probe = Probe(model, tok, train_recs, oracle, device, log)
|
| 847 |
+
autocast = torch.autocast("cuda", dtype=torch.bfloat16, enabled=(device == "cuda"))
|
| 848 |
+
rounds, round_secs, history, step = 0, 0.0, [], 0
|
| 849 |
+
while oracle.left() > 1.15 * round_secs:
|
| 850 |
+
t0 = oracle.used()
|
| 851 |
+
model.n_loops = RL_FIRST_LOOPS
|
| 852 |
+
picked = pick_targets(targets, found, rng)
|
| 853 |
+
rows = oracle.sample_rollouts(model, picked, GRPO_G)
|
| 854 |
+
rs = rollout_stats(model, tok, rows, device) # on-policy, before the found-proof injection and the update
|
| 855 |
+
items, adv, st = [], [], collections.Counter()
|
| 856 |
+
for row in rows:
|
| 857 |
+
for p in row["proofs"]:
|
| 858 |
+
found[row["name"]].setdefault(norm(p), p)
|
| 859 |
+
group = [(ids, float(ok)) for ids, ok in row["rollouts"]]
|
| 860 |
+
if not any(r for _, r in group) and found[row["name"]]:
|
| 861 |
+
group[0] = (tok.encode_proof(rng.choice(list(found[row["name"]].values()))), 1.0)
|
| 862 |
+
st["injected"] += 1
|
| 863 |
+
mean = sum(r for _, r in group) / len(group)
|
| 864 |
+
if mean in (0.0, 1.0):
|
| 865 |
+
st["all_fail" if mean == 0 else "all_pass"] += 1
|
| 866 |
+
continue
|
| 867 |
+
prompt = tok.encode_prompt(row["prompt"])
|
| 868 |
+
items += [(prompt, ids) for ids, _ in group]
|
| 869 |
+
adv += [r - mean for _, r in group]
|
| 870 |
+
st["groups"] += 1
|
| 871 |
+
if items:
|
| 872 |
+
retain = [(tok.encode_prompt(r["prompt"]), tok.encode_proof(r["proof"]))
|
| 873 |
+
for r in rng.sample(train_recs, min(len(items), len(train_recs)))]
|
| 874 |
+
loss, n_steps, ratio = pg_update(model, tok, items, adv, retain, opt, muon, step, gen, rng, autocast, device)
|
| 875 |
+
step += n_steps
|
| 876 |
+
st["steps"], st["items"] = n_steps, len(items)
|
| 877 |
+
st.update(ratio)
|
| 878 |
+
rounds += 1
|
| 879 |
+
probe.measure(model, rows, rounds)
|
| 880 |
+
round_secs = oracle.used() - t0
|
| 881 |
+
history.append({"round": rounds, **st, "rollouts": rs})
|
| 882 |
+
log(f"grpo round {rounds}: {dict(st)}, {fmt_stats(rs)}, round {round_secs:.0f}s, {oracle.left():.0f}s left")
|
| 883 |
+
model.n_loops = DEFAULT_LOOPS
|
| 884 |
+
model.eval()
|
| 885 |
+
return {"rounds": rounds, "algo": "grpo", "g": GRPO_G, "lr": GRPO_LR, "muon_lr": GRPO_MUON_LR, "temp": GRPO_TEMP,
|
| 886 |
+
"clip": [GRPO_CLIP_LOW, GRPO_CLIP_HIGH, GRPO_DUAL_CLIP], "len_norm": GRPO_LEN_NORM,
|
| 887 |
+
"retain_w": GRPO_RETAIN_W, "history": history, "probe": probe.history}
|
| 888 |
+
|
| 889 |
+
|
| 890 |
+
def token_logp(model, x):
|
| 891 |
+
"""log p of each next token of x under logits / GRPO_TEMP, the sampling distribution: (B, T-1)."""
|
| 892 |
+
logits = model(x[:, :-1]).float() / GRPO_TEMP
|
| 893 |
+
return -torch.nn.functional.cross_entropy(
|
| 894 |
+
logits.reshape(-1, logits.size(-1)), x[:, 1:].reshape(-1), reduction="none"
|
| 895 |
+
).view(len(x), -1)
|
| 896 |
+
|
| 897 |
+
|
| 898 |
+
def ppo_surrogate(ratio, a):
|
| 899 |
+
"""Per-token objective to maximise: PPO's clipped min(r a, clip(r) a) with the asymmetric range
|
| 900 |
+
[1 - GRPO_CLIP_LOW, 1 + GRPO_CLIP_HIGH], and for a < 0 floored at GRPO_DUAL_CLIP * a so a token whose
|
| 901 |
+
ratio has grown large cannot drive an unbounded push-down."""
|
| 902 |
+
surr = torch.min(ratio * a, ratio.clamp(1 - GRPO_CLIP_LOW, 1 + GRPO_CLIP_HIGH) * a)
|
| 903 |
+
return torch.where(a < 0, torch.max(surr, GRPO_DUAL_CLIP * a), surr)
|
| 904 |
+
|
| 905 |
+
|
| 906 |
+
def pg_update(model, tok, items, adv, retain, opt, muon, step0, gen, rng, autocast, device):
|
| 907 |
+
"""One pass over the round's rollouts in token-budget batches, each step paired with a retained
|
| 908 |
+
pretraining batch (augmented, as in pretraining). Per token, the PPO clipped surrogate with ratio
|
| 909 |
+
p / p_old, p_old scored before the first step. Returns (last loss, steps, ratio stats)."""
|
| 910 |
+
ids, mask, _, lens = to_gpu(items, tok, device)
|
| 911 |
+
adv_t = torch.tensor(adv, device=device)
|
| 912 |
+
r_ids, r_mask, r_ref, r_lens = to_gpu(retain, tok, device)
|
| 913 |
+
order, cuts = token_batches(lens, len(items), gen, rng, first=0)
|
| 914 |
+
r_order, r_cuts = token_batches(r_lens, len(retain), gen, rng, first=0)
|
| 915 |
+
old = torch.zeros(ids.shape[0], ids.shape[1] - 1, device=device)
|
| 916 |
+
model.eval()
|
| 917 |
+
with torch.no_grad():
|
| 918 |
+
for s, e, T in cuts:
|
| 919 |
+
idxs = order[s:e]
|
| 920 |
+
x, _ = gpu_batch(ids, mask, None, lens, idxs, tok, gen, T, augment=False)
|
| 921 |
+
with autocast:
|
| 922 |
+
old[idxs, : T - 1] = token_logp(model, x)
|
| 923 |
+
model.train()
|
| 924 |
+
loss = torch.zeros(())
|
| 925 |
+
clipped = ratio_sum = n_tok = 0.0
|
| 926 |
+
for k, (s, e, T) in enumerate(cuts):
|
| 927 |
+
step = step0 + k + 1
|
| 928 |
+
warm = min(1.0, step / GRPO_WARMUP)
|
| 929 |
+
for g in opt.param_groups:
|
| 930 |
+
g["lr"] = GRPO_LR * warm
|
| 931 |
+
idxs = order[s:e]
|
| 932 |
+
x, m = gpu_batch(ids, mask, None, lens, idxs, tok, gen, T, augment=False)
|
| 933 |
+
m = m[:, 1:]
|
| 934 |
+
a = adv_t[idxs, None]
|
| 935 |
+
with autocast:
|
| 936 |
+
ratio = torch.exp(token_logp(model, x) - old[idxs, : T - 1])
|
| 937 |
+
pg = -(ppo_surrogate(ratio, a) * m).sum() / (len(idxs) * GRPO_LEN_NORM)
|
| 938 |
+
rs, re_, rT = r_cuts[k % len(r_cuts)]
|
| 939 |
+
rx, rm = gpu_batch(r_ids, r_mask, r_ref, r_lens, r_order[rs:re_], tok, gen, rT)
|
| 940 |
+
loss = pg + GRPO_RETAIN_W * loss_on(model, rx, rm)
|
| 941 |
+
with torch.no_grad():
|
| 942 |
+
out = (ratio < 1 - GRPO_CLIP_LOW) | (ratio > 1 + GRPO_CLIP_HIGH)
|
| 943 |
+
clipped += float((out & m).sum())
|
| 944 |
+
ratio_sum += float((ratio * m).sum())
|
| 945 |
+
n_tok += float(m.sum())
|
| 946 |
+
model.zero_grad(set_to_none=False) # grads keep fixed addresses for the Muon CUDA graph
|
| 947 |
+
loss.backward()
|
| 948 |
+
torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
|
| 949 |
+
opt.step()
|
| 950 |
+
muon(GRPO_MUON_LR * warm)
|
| 951 |
+
model.eval()
|
| 952 |
+
return loss.item(), len(cuts), {"clip_frac": round(clipped / max(n_tok, 1), 4),
|
| 953 |
+
"ratio": round(ratio_sum / max(n_tok, 1), 4)}
|
runs/long-rl-20261014-v5_looped-ei_s0/source/remote.sh
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Runs on the pod. Checks out Dan's fork at the pinned commit (model, sampler, nd2lean; the tokenizer and the Lean
|
| 3 |
+
# gate come from overlay/), installs Lean, runs the harness.
|
| 4 |
+
# Usage: ND_ARCH=untied|looped ND_RL=ei|grpo bash remote.sh <out-dir> [harness.py args...]
|
| 5 |
+
set -euo pipefail
|
| 6 |
+
FORK_COMMIT=51604b3feaa5e66821d1faba22238fe6d96d46d0 # dan-pandori/nd-takehome, branch dan_lean_seed2
|
| 7 |
+
export ND_FORK=/workspace/nd-takehome
|
| 8 |
+
OUT=$1; shift
|
| 9 |
+
HERE=$(cd "$(dirname "$0")" && pwd)
|
| 10 |
+
|
| 11 |
+
if [ ! -d "$ND_FORK/.git" ]; then
|
| 12 |
+
git clone -q https://github.com/dan-pandori/nd-takehome.git "$ND_FORK"
|
| 13 |
+
fi
|
| 14 |
+
git -C "$ND_FORK" cat-file -e "$FORK_COMMIT" 2>/dev/null || git -C "$ND_FORK" fetch -q origin
|
| 15 |
+
git -C "$ND_FORK" checkout -q "$FORK_COMMIT"
|
| 16 |
+
[ -f "$ND_FORK/data/train.jsonl" ] || gunzip -k "$ND_FORK/data/train.jsonl.gz"
|
| 17 |
+
# Lean 4 core is the only checker (overlay/lean_gate.py). Installed before harness.py starts, so it is not charged.
|
| 18 |
+
[ -x ~/.elan/bin/lean ] || curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh \
|
| 19 |
+
| sh -s -- -y --default-toolchain leanprover/lean4:v4.34.0 > /dev/null
|
| 20 |
+
export LEAN_GATE_WORKERS=$(nproc) LEAN_GATE_LOG="$OUT/lean_gate.jsonl" ND_DATA="$HERE/data"
|
| 21 |
+
mkdir -p "$OUT"
|
| 22 |
+
nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
|
| 23 |
+
echo "cpus $(nproc), $(~/.elan/bin/lean --version), arm $ND_ARCH/$ND_RL"
|
| 24 |
+
PY=$(for p in python python3; do "$p" -c "import torch" 2>/dev/null && echo "$p" && break; done)
|
| 25 |
+
echo "python $($PY --version 2>&1), torch $($PY -c 'import torch; print(torch.__version__)')"
|
| 26 |
+
cd "$HERE"
|
| 27 |
+
$PY harness.py --out "$OUT" "$@" 2>&1 | tee "$OUT.log"
|
runs/long-rl-20261014-v5_looped-ei_s0/summary.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|