BurnyCoder commited on
Commit
7746322
·
verified ·
1 Parent(s): 561adcb

Archive hybrid implementation, locked dependencies and new tests before running models

Browse files
Files changed (36) hide show
  1. logs/hybrid-implementation-release.log +1 -0
  2. logs/study-20261125T105025-confirmation.log +15 -0
  3. publication.json +141 -81
  4. research/README.md +4 -2
  5. research/docs/explorer.js +8 -3
  6. research/docs/index.html +4 -1
  7. research/docs/runbook.md +2 -0
  8. research/docs/study.json +0 -0
  9. research/reports/experiments/abstracts-pilot-s00-hessian_norm-r03-fp64/experiment.md +11 -0
  10. research/reports/experiments/abstracts-pilot-s00-hessian_norm-r03-fp64/learnings.md +5 -0
  11. research/reports/experiments/experiments.md +1 -0
  12. research/reports/experiments/learnings.md +2 -0
  13. research/reports/hybrid/results.md +9 -0
  14. research/reports/paper.pdf +0 -0
  15. research/reports/progress.md +12 -2
  16. research/reports/summary.md +4 -2
  17. research/results/abstracts-pilot-s00-hessian_norm-r03-fp64/state.json +17 -0
  18. research/results/feasibility/abstracts.json +28 -0
  19. research/results/feasibility/one-week.json +77 -0
  20. research/results/selection/abstracts.json +43 -0
  21. research/src/thirdloss/analysis.py +17 -6
  22. research/src/thirdloss/cli.py +11 -5
  23. research/src/thirdloss/hybrid.py +215 -0
  24. research/src/thirdloss/hybrid_results.py +47 -0
  25. research/src/thirdloss/objectives.py +5 -4
  26. research/src/thirdloss/penalties.py +2 -2
  27. research/src/thirdloss/progress.py +5 -1
  28. research/src/thirdloss/release.py +4 -0
  29. research/src/thirdloss/report_figures.py +27 -1
  30. research/src/thirdloss/report_paper.py +17 -7
  31. research/src/thirdloss/report_records.py +19 -2
  32. research/src/thirdloss/reporting.py +61 -2
  33. research/src/thirdloss/study.py +4 -1
  34. research/src/thirdloss/train.py +52 -13
  35. research/src/thirdloss/width.py +77 -0
  36. research/tests/test_hybrid.py +107 -0
logs/hybrid-implementation-release.log ADDED
@@ -0,0 +1 @@
 
 
1
+ findfont: Failed to find font weight semibold for DejaVu Sans, now using 700.
logs/study-20261125T105025-confirmation.log CHANGED
@@ -77,3 +77,18 @@ findfont: Failed to find font weight semibold for DejaVu Sans, now using 700.
77
  {"timestamp": "2026-11-25T10:27:53+00:00", "split": "dev", "prompt": "We investigate the connection between the turnover frequency in the radio\nspectrum, $\\nu", "reference": "_{\\rm TO}$, and the rate of ionising ultra-violet photons,\n$Q_{\\rm HI}$, in extragalactic sources. From a large, optically selected,\nsample we", "continuation": "_{\\rm{break}}$, and the spectral index of the underlying\nspectral index $s_{\\rm{break}}$, and reveal that there is a universal\nrelationship between both quantities that can be used to", "prompt_ids": [1231, 7409, 253, 4602, 875, 253, 25759, 4294, 275, 253, 5553, 187, 39862, 13, 669, 3023], "generated_ids": [1126, 1109, 92, 7054, 12460, 285, 253, 9879, 3605, 273, 253, 6944, 187, 18181, 1544, 3605, 370, 84, 1126, 1109, 92, 7054, 12460, 285, 10313, 326, 627, 310, 247, 10898, 187, 46397, 875, 1097, 13483, 326, 476, 320, 908, 281], "tokens": 40, "sampling_seed": 7403, "temperature": 0.8}
78
  Completed abstracts-pilot-s00-third-r10-fp64 development NLL 3.116312
79
  findfont: Failed to find font weight semibold for DejaVu Sans, now using 700.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  {"timestamp": "2026-11-25T10:27:53+00:00", "split": "dev", "prompt": "We investigate the connection between the turnover frequency in the radio\nspectrum, $\\nu", "reference": "_{\\rm TO}$, and the rate of ionising ultra-violet photons,\n$Q_{\\rm HI}$, in extragalactic sources. From a large, optically selected,\nsample we", "continuation": "_{\\rm{break}}$, and the spectral index of the underlying\nspectral index $s_{\\rm{break}}$, and reveal that there is a universal\nrelationship between both quantities that can be used to", "prompt_ids": [1231, 7409, 253, 4602, 875, 253, 25759, 4294, 275, 253, 5553, 187, 39862, 13, 669, 3023], "generated_ids": [1126, 1109, 92, 7054, 12460, 285, 253, 9879, 3605, 273, 253, 6944, 187, 18181, 1544, 3605, 370, 84, 1126, 1109, 92, 7054, 12460, 285, 10313, 326, 627, 310, 247, 10898, 187, 46397, 875, 1097, 13483, 326, 476, 320, 908, 281], "tokens": 40, "sampling_seed": 7403, "temperature": 0.8}
78
  Completed abstracts-pilot-s00-third-r10-fp64 development NLL 3.116312
79
  findfont: Failed to find font weight semibold for DejaVu Sans, now using 700.
80
+ 2026-11-25T10:29:04+00:00 [calibration] abstracts hessian_norm draw 1/16 estimate 1.15844e+06, CE gradient norm 1.12725, penalty gradient norm 1.4477e+09, 19.75 s
81
+ 2026-11-25T10:29:23+00:00 [calibration] abstracts hessian_norm draw 2/16 estimate 527714, CE gradient norm 1.17571, penalty gradient norm 1.89463e+08, 18.49 s
82
+ 2026-11-25T10:29:42+00:00 [calibration] abstracts hessian_norm draw 3/16 estimate 261117, CE gradient norm 1.20218, penalty gradient norm 1.78487e+08, 18.32 s
83
+ 2026-11-25T10:30:03+00:00 [calibration] abstracts hessian_norm draw 4/16 estimate 2.16188e+06, CE gradient norm 1.0703, penalty gradient norm 2.24502e+09, 18.94 s
84
+ 2026-11-25T10:30:22+00:00 [calibration] abstracts hessian_norm draw 5/16 estimate 334819, CE gradient norm 1.18184, penalty gradient norm 8.39062e+07, 18.40 s
85
+ 2026-11-25T10:30:43+00:00 [calibration] abstracts hessian_norm draw 6/16 estimate 605145, CE gradient norm 1.22194, penalty gradient norm 1.45826e+08, 19.12 s
86
+ 2026-11-25T10:31:02+00:00 [calibration] abstracts hessian_norm draw 7/16 estimate 650125, CE gradient norm 1.11921, penalty gradient norm 1.67848e+08, 17.78 s
87
+ 2026-11-25T10:31:21+00:00 [calibration] abstracts hessian_norm draw 8/16 estimate 299573, CE gradient norm 1.01186, penalty gradient norm 1.13189e+08, 17.82 s
88
+ 2026-11-25T10:31:40+00:00 [calibration] abstracts hessian_norm draw 9/16 estimate 379969, CE gradient norm 1.22581, penalty gradient norm 1.42905e+08, 18.51 s
89
+ 2026-11-25T10:32:01+00:00 [calibration] abstracts hessian_norm draw 10/16 estimate 335985, CE gradient norm 1.168, penalty gradient norm 7.46532e+07, 19.05 s
90
+ 2026-11-25T10:32:20+00:00 [calibration] abstracts hessian_norm draw 11/16 estimate 659706, CE gradient norm 1.15495, penalty gradient norm 2.09725e+08, 18.26 s
91
+ 2026-11-25T10:32:40+00:00 [calibration] abstracts hessian_norm draw 12/16 estimate 407203, CE gradient norm 1.06794, penalty gradient norm 9.65231e+07, 19.00 s
92
+ 2026-11-25T10:33:00+00:00 [calibration] abstracts hessian_norm draw 13/16 estimate 263650, CE gradient norm 1.24234, penalty gradient norm 1.89179e+08, 18.41 s
93
+ 2026-11-25T10:33:19+00:00 [calibration] abstracts hessian_norm draw 14/16 estimate 403261, CE gradient norm 1.17703, penalty gradient norm 1.83369e+08, 17.56 s
94
+ 2026-11-25T10:33:38+00:00 [calibration] abstracts hessian_norm draw 15/16 estimate 208510, CE gradient norm 1.19373, penalty gradient norm 3.39152e+07, 17.59 s
publication.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "collection": "BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378",
3
- "git_revision": "a8a93b15217df9c328dcd46eceb931e341cddbfa",
4
  "repositories": {
5
  "BurnyCoder/thirdloss-arxiv-abstracts-2024": {
6
  "files": {
@@ -61,9 +61,9 @@
61
  "size": 7098
62
  },
63
  "explorer.js": {
64
- "git_blob": "9fcb175964d5391b110e5aa1a0c368993a672b6c",
65
- "sha256": "f864e188a35e62b595f1fd382dd34d2ed7e6f7ae275f613a2c37899cdb13bdab",
66
- "size": 17762
67
  },
68
  "figures/architecture.png": {
69
  "git_blob": "2c41c712a9edfcc9f53e1ac8f76e751e54dc8924",
@@ -81,17 +81,17 @@
81
  "size": 156490
82
  },
83
  "index.html": {
84
- "git_blob": "d8e22afb8e663422375b1a16fa1173836b31c9da",
85
- "sha256": "c3d8177ee2a6a8630119e8ffa748eaedc75dd050195f73169ccb52076a250220",
86
- "size": 8827
87
  },
88
  "study.json": {
89
- "git_blob": "73960aedcab320dd73e89b65aaa8cc346878f726",
90
- "sha256": "808da90e2d2acafb75427861dec1ac1b94c0d52486ba6baeb156d062e7d49a12",
91
- "size": 334907
92
  }
93
  },
94
- "revision": "4b1a82f77e3d74fc3ad349f2d76d69bacebf2776",
95
  "type": "space"
96
  },
97
  "BurnyCoder/thirdloss-pythia-410m-adapters": {
@@ -838,6 +838,11 @@
838
  "sha256": "1c73007c107dd521eed1fea4cd5cde00d25fca4863773228d18e29582eae50dd",
839
  "size": 7536
840
  },
 
 
 
 
 
841
  "logs/hybrid-registration-release.log": {
842
  "git_blob": "2dafb6b7809fb1f853547c6521c01183524f3a75",
843
  "sha256": "4f3296506f987dce6ded9ce5cf76e91cc678cebb8c6f2c3565c584e32dddc3bd",
@@ -989,9 +994,9 @@
989
  "size": 19482
990
  },
991
  "logs/study-20261125T105025-confirmation.log": {
992
- "git_blob": "9f4a3e212887ebad8387d6ca5282d0a275d1bd10",
993
- "sha256": "7d0f997e96d844bb01225f2acda15fa064e01e62b94c4fe249bbd2d1a44a322e",
994
- "size": 30403
995
  },
996
  "logs/update-diagnostic-modelcard.log": {
997
  "git_blob": "86afaf365d1f2181f812d84b59017f771f2e9683",
@@ -1059,9 +1064,9 @@
1059
  "size": 786
1060
  },
1061
  "research/README.md": {
1062
- "git_blob": "0306dda8e0dcdb69e217dcd855497e08d3c34ed8",
1063
- "sha256": "d0d2fd89185db70890a2ee8adacb4c5c7a130856b65f5b25f807c76b7c07d747",
1064
- "size": 25741
1065
  },
1066
  "research/docs/data.md": {
1067
  "git_blob": "1d0a74102cee4ed06b783085ca2ce823c6bf3a42",
@@ -1074,9 +1079,9 @@
1074
  "size": 7098
1075
  },
1076
  "research/docs/explorer.js": {
1077
- "git_blob": "9fcb175964d5391b110e5aa1a0c368993a672b6c",
1078
- "sha256": "f864e188a35e62b595f1fd382dd34d2ed7e6f7ae275f613a2c37899cdb13bdab",
1079
- "size": 17762
1080
  },
1081
  "research/docs/figures/architecture.png": {
1082
  "git_blob": "2c41c712a9edfcc9f53e1ac8f76e751e54dc8924",
@@ -1124,19 +1129,19 @@
1124
  "size": 1435
1125
  },
1126
  "research/docs/index.html": {
1127
- "git_blob": "23df1a0a6a4faeed3ac2a3a5e154a4cb3072472b",
1128
- "sha256": "c16b32ced77952ca14a3e36913183b36199a2adc0ce0b519cdc86aafd4ab8899",
1129
- "size": 9057
1130
  },
1131
  "research/docs/runbook.md": {
1132
- "git_blob": "938491e0017ce70a66a69c6784238cc4c809bbe5",
1133
- "sha256": "69da6528aa791b7cd2fa84f0a97720b69476b7c4e1168eefe12154d72aff67f8",
1134
- "size": 6842
1135
  },
1136
  "research/docs/study.json": {
1137
- "git_blob": "73960aedcab320dd73e89b65aaa8cc346878f726",
1138
- "sha256": "808da90e2d2acafb75427861dec1ac1b94c0d52486ba6baeb156d062e7d49a12",
1139
- "size": 334907
1140
  },
1141
  "research/docs/third-derivative-penalty.md": {
1142
  "git_blob": "a62df59c3abcf3f4335575717346e26663e2d649",
@@ -1183,6 +1188,16 @@
1183
  "sha256": "7e103ed8d5a8104b6a1384c8c002f3585af6b34b3728be2a44a8cd5f4de30e79",
1184
  "size": 231
1185
  },
 
 
 
 
 
 
 
 
 
 
1186
  "research/reports/experiments/abstracts-pilot-s00-third-r01-fp64/experiment.md": {
1187
  "git_blob": "edbf6b5da8d0b4c286103409c23af2058f441256",
1188
  "sha256": "fc1d5a71063755b96e70949cda383f7ab532f92c3f7821312856f018f10c9e48",
@@ -1254,14 +1269,14 @@
1254
  "size": 231
1255
  },
1256
  "research/reports/experiments/experiments.md": {
1257
- "git_blob": "ce69f559a5ef77cd9630d0ed6e5d8b832bc9e6dc",
1258
- "sha256": "cff996c1c6fee59d3ab0484f92607adba3676c7de3da84bccf3c69e9f22aeae3",
1259
- "size": 4540
1260
  },
1261
  "research/reports/experiments/learnings.md": {
1262
- "git_blob": "72421c07cc0fe4546162a66b4262534f7835aebc",
1263
- "sha256": "be1751549daafd6da261e87134e19b02b15d8b7f57ab10f1eef696cb561eb380",
1264
- "size": 5831
1265
  },
1266
  "research/reports/experiments/stories-control-s00-initial-r00/experiment.md": {
1267
  "git_blob": "992585a6ffda93756c0d396ce1a64652b5db5e11",
@@ -1388,15 +1403,20 @@
1388
  "sha256": "ee367dea7be8b4dea20e364c45b5203f0613c172e015260fd3470ec1b96f5ea9",
1389
  "size": 7658
1390
  },
 
 
 
 
 
1391
  "research/reports/literature-review.md": {
1392
  "git_blob": "60cb61940a961b869b09e18931fb885668994e62",
1393
  "sha256": "b428342869af2fd26f05c2b2d2cfc14749a6c9021c62e9f20689d522cdc1ce00",
1394
  "size": 7290
1395
  },
1396
  "research/reports/paper.pdf": {
1397
- "git_blob": "64511cdc4b11581bae23da01a9222e263bd9ebbf",
1398
- "sha256": "ea9d88ae77e5c6e0fc1ca3a2471cc22c984da452a0c745e54da3c2413892b16e",
1399
- "size": 367444
1400
  },
1401
  "research/reports/plan.md": {
1402
  "git_blob": "bbbef734559f38fba5d30195539a46a1249d11eb",
@@ -1414,9 +1434,9 @@
1414
  "size": 5234
1415
  },
1416
  "research/reports/progress.md": {
1417
- "git_blob": "b7a16c76e52bf18d71dd23f228023eac45b126aa",
1418
- "sha256": "e5ea561eae1395361c0c11bd07c7fd730905cdf0298bd5a90a4d756a5f82ecf2",
1419
- "size": 852
1420
  },
1421
  "research/reports/reviews/adapter-verification.md": {
1422
  "git_blob": "1ad4e5807c9e22c39721e238af4c640f4537cf66",
@@ -1434,9 +1454,9 @@
1434
  "size": 1740
1435
  },
1436
  "research/reports/summary.md": {
1437
- "git_blob": "47f1ca9e89e729cdaf2341daa9d0426ff051278c",
1438
- "sha256": "318e27fdc1df105a0d35694c03cd99e2dbac62ec29eb27fb9c96d7acdfadbfd8",
1439
- "size": 3422
1440
  },
1441
  "research/results/abstracts-control-s00-initial-r00/config.json": {
1442
  "git_blob": "0371479e1ad5f1c59b484eb112d315a86c82852d",
@@ -1503,6 +1523,11 @@
1503
  "sha256": "151317f2000a774805912d4132cd2380f7367f9a7a17d4dd780a976fd0bc32a4",
1504
  "size": 1337
1505
  },
 
 
 
 
 
1506
  "research/results/abstracts-pilot-s00-third-r01-fp64/config.json": {
1507
  "git_blob": "d394e2482f47ef5cdfbb831b4657c7e08297f727",
1508
  "sha256": "fa7041dddeec4cb77c7ba0edd75284d10caca1d28d7509b171186ca479d87950",
@@ -1718,11 +1743,26 @@
1718
  "sha256": "f61dcd6d63f102755b2705140b274b65fc870c3cded3961845ca5ed51e1a6d00",
1719
  "size": 3010
1720
  },
 
 
 
 
 
 
 
 
 
 
1721
  "research/results/feasibility/stories.json": {
1722
  "git_blob": "ce046159f638f1cee4085da49a487524f53dafed",
1723
  "sha256": "ca96ea2ec017c3d2ed24e390d910cb39010c82e387e63293aec1619dbbed33a5",
1724
  "size": 875
1725
  },
 
 
 
 
 
1726
  "research/results/selection/stories.json": {
1727
  "git_blob": "a9a120bc0f8705fa86cbf57e032cc4229aab4517",
1728
  "sha256": "e42c2bb8c67a89999fe7ac1e93371b36f9d7674abf05a3fc59ee4ac24c5795ad",
@@ -2024,14 +2064,14 @@
2024
  "size": 86
2025
  },
2026
  "research/src/thirdloss/analysis.py": {
2027
- "git_blob": "91447a2f032e2f8355768c95c7432865aac30760",
2028
- "sha256": "5053445b9bdad9a54a911ea5c6446b3b83ac7007b44c17fa5de02012cfbf98fa",
2029
- "size": 9425
2030
  },
2031
  "research/src/thirdloss/cli.py": {
2032
- "git_blob": "19c3ea6719e20927b79907fe7133b7f20a735a89",
2033
- "sha256": "6d503abc043b625e18586393c188149f2f5eeeb10f324fd1b777a5f78083f279",
2034
- "size": 6500
2035
  },
2036
  "research/src/thirdloss/data.py": {
2037
  "git_blob": "9b06438a0bce64f8d491cd65156ebe8aa04e8916",
@@ -2048,6 +2088,16 @@
2048
  "sha256": "928d4a2bf9fb55094604ab1b1b070dd8c9ed62e8dc7336dd303e6b4d24ce13c9",
2049
  "size": 13687
2050
  },
 
 
 
 
 
 
 
 
 
 
2051
  "research/src/thirdloss/live_hub.py": {
2052
  "git_blob": "11be73956f4e0b255b14b88c6dbd7dbb08439ab6",
2053
  "sha256": "27921980e4fe34b7de486028f531aff00c07ca7bc9037ffda3535984c15ffe40",
@@ -2059,9 +2109,9 @@
2059
  "size": 8088
2060
  },
2061
  "research/src/thirdloss/objectives.py": {
2062
- "git_blob": "0a21a218fd184f52c8a78600d401000c440769b9",
2063
- "sha256": "dd7093a869ef790388a8e3a7a93def84f6525e63d8dc7a3de2d28fc8b26e64c7",
2064
- "size": 10263
2065
  },
2066
  "research/src/thirdloss/overlap.py": {
2067
  "git_blob": "869bfc3223ac8688e908d7e7f649db27397ded99",
@@ -2069,9 +2119,9 @@
2069
  "size": 5553
2070
  },
2071
  "research/src/thirdloss/penalties.py": {
2072
- "git_blob": "4c39e88b2b7a27461936eb6f8b5baa49b09383c1",
2073
- "sha256": "3ba3962d8459f5997e4652eb67f2f33b67eaf46e99e5486eafa643b3f6f1f7bb",
2074
- "size": 2906
2075
  },
2076
  "research/src/thirdloss/precision.py": {
2077
  "git_blob": "476cc82ccc66376eeaff5c9461158b34ca39e7e2",
@@ -2084,9 +2134,9 @@
2084
  "size": 6073
2085
  },
2086
  "research/src/thirdloss/progress.py": {
2087
- "git_blob": "2a325d32b44c32b95b8a536ce995e2711bb46e04",
2088
- "sha256": "dcdb06fbf348032e353aa8992f1f172eefe6700dad87ffe20fbf5599a645589c",
2089
- "size": 6385
2090
  },
2091
  "research/src/thirdloss/records.py": {
2092
  "git_blob": "a800de00d42944f13a89d8d2f91ce9b2103bbd45",
@@ -2094,45 +2144,50 @@
2094
  "size": 3710
2095
  },
2096
  "research/src/thirdloss/release.py": {
2097
- "git_blob": "8fcf61fba92d559bc5287e854a2026b4a7994e2a",
2098
- "sha256": "39fed695ed3456ff26e09daecb824992d4b0ce794fd979a04e4d77263c0c8d19",
2099
- "size": 5413
2100
  },
2101
  "research/src/thirdloss/report_figures.py": {
2102
- "git_blob": "eee1bf3f6b1e5a4720384b56391233e7cb983233",
2103
- "sha256": "adb5b18ab15b590423fb1df93cc65f7e154c35075c7539853d8ede8273704eef",
2104
- "size": 8948
2105
  },
2106
  "research/src/thirdloss/report_paper.py": {
2107
- "git_blob": "7c51066f66cb69717a20b993db8ebebed45ed472",
2108
- "sha256": "0107f07ad0e976d27e0ab488be453ff81ed303399daec790210c0c0a4d2123b2",
2109
- "size": 32824
2110
  },
2111
  "research/src/thirdloss/report_records.py": {
2112
- "git_blob": "fd290cc837ec69b400901638c43922ee12959290",
2113
- "sha256": "72393291fa68eff469921b9e2e4c03faf69b7bb69931e885bf9ce96eb60a596f",
2114
- "size": 11950
2115
  },
2116
  "research/src/thirdloss/reporting.py": {
2117
- "git_blob": "6be68aed44353bf502b7191475852548a7efdc30",
2118
- "sha256": "d6e9dcf919b532be23b5a5d3ee3660f8a19fa608667ac68a046654de84be9dbe",
2119
- "size": 14923
2120
  },
2121
  "research/src/thirdloss/study.py": {
2122
- "git_blob": "3b0954e5b52408a1262fcbc5b64d05b7051a6575",
2123
- "sha256": "8fd00a89ddd0da145361e3cfa9c4058d3470e2a6c95c507b2daae5cf45d22fa6",
2124
- "size": 10378
2125
  },
2126
  "research/src/thirdloss/train.py": {
2127
- "git_blob": "2d36b6dd27bea2f7a4f2156a114cdc7833c8c82f",
2128
- "sha256": "bdb23ca872251c63dec563106b104f3c60508398c60064ebe1f55954f851cb01",
2129
- "size": 14095
2130
  },
2131
  "research/src/thirdloss/verification.py": {
2132
  "git_blob": "4aa026d9ad8bcfd44856f2f8bd63e7d2a14c30ab",
2133
  "sha256": "1b6a3e76f6aaa7785340fc73b67c0be0c986153b777f015359cfa4334636d95f",
2134
  "size": 1305
2135
  },
 
 
 
 
 
2136
  "research/src/thirdloss/windows.py": {
2137
  "git_blob": "2000a312e8326b97f88acead4b5c53e6d26eeab2",
2138
  "sha256": "7dc423e2a4777184d60a209f5d3b884cc3f4a9d651aba769c5f940902cc73fee",
@@ -2158,6 +2213,11 @@
2158
  "sha256": "6dadeaf5b08d9c2dbe1df2d24a247b23d005a0ededb280630c82f41845084bc5",
2159
  "size": 3476
2160
  },
 
 
 
 
 
2161
  "research/tests/test_reporting.py": {
2162
  "git_blob": "8d35cec22ff32950b18690c8af5142d0b44bc644",
2163
  "sha256": "6a144d3dbae968da797bb4765c8c37b1543abc9e54d32e88f6de8ef8d9218bf5",
@@ -2223,5 +2283,5 @@
2223
  "type": "dataset"
2224
  }
2225
  },
2226
- "verified_at": "2026-11-25T10:28:23+00:00"
2227
  }
 
1
  {
2
  "collection": "BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378",
3
+ "git_revision": "809bfea05aed6dbbe848fc800cf09ef935523f6e",
4
  "repositories": {
5
  "BurnyCoder/thirdloss-arxiv-abstracts-2024": {
6
  "files": {
 
61
  "size": 7098
62
  },
63
  "explorer.js": {
64
+ "git_blob": "76fa33ca5b2dd5a87c8c392a66971a5e7be2acc0",
65
+ "sha256": "3142c81efe2857daade3f549d8820c656f5a4413e9519991415c6563ce32815c",
66
+ "size": 18278
67
  },
68
  "figures/architecture.png": {
69
  "git_blob": "2c41c712a9edfcc9f53e1ac8f76e751e54dc8924",
 
81
  "size": 156490
82
  },
83
  "index.html": {
84
+ "git_blob": "f34264333ceb1b0fd0dec1f0814ab6b772e28aee",
85
+ "sha256": "0f7a122e18ce737a2878064e3d62e4e8a678cb238804e1a8f389d5554d71247f",
86
+ "size": 9173
87
  },
88
  "study.json": {
89
+ "git_blob": "450ebf1be137063c3252120d5e9a9d79fafeeb6f",
90
+ "sha256": "d08a6182a373f8fd6c101873cd168ac82f4976711f81615d67999b501e7d993b",
91
+ "size": 379457
92
  }
93
  },
94
+ "revision": "1ef0d0e1983fe64d18fd0a0118161e0e03d6ae2e",
95
  "type": "space"
96
  },
97
  "BurnyCoder/thirdloss-pythia-410m-adapters": {
 
838
  "sha256": "1c73007c107dd521eed1fea4cd5cde00d25fca4863773228d18e29582eae50dd",
839
  "size": 7536
840
  },
841
+ "logs/hybrid-implementation-release.log": {
842
+ "git_blob": "37bbb4bdbd164007d9e8e84ddbdb5e73b2a11e1d",
843
+ "sha256": "2ae7e37a0d60013de1b3d6870314f24554d6f4af83d0ce06b372b1eed3a9b1c6",
844
+ "size": 79
845
+ },
846
  "logs/hybrid-registration-release.log": {
847
  "git_blob": "2dafb6b7809fb1f853547c6521c01183524f3a75",
848
  "sha256": "4f3296506f987dce6ded9ce5cf76e91cc678cebb8c6f2c3565c584e32dddc3bd",
 
994
  "size": 19482
995
  },
996
  "logs/study-20261125T105025-confirmation.log": {
997
+ "git_blob": "1f62ae28845eddd788f46570012a73125a3b2635",
998
+ "sha256": "1c13abe825e2bd8c3f93f19dbce229889dad1082f8f174c5760cbd69ccd0d873",
999
+ "size": 32815
1000
  },
1001
  "logs/update-diagnostic-modelcard.log": {
1002
  "git_blob": "86afaf365d1f2181f812d84b59017f771f2e9683",
 
1064
  "size": 786
1065
  },
1066
  "research/README.md": {
1067
+ "git_blob": "ec5382f432adf1c4ccb61b3100b468e56329c762",
1068
+ "sha256": "a1f53440f62982bb54408811b1446310b308d8097fa09170ef15c876337c1676",
1069
+ "size": 25971
1070
  },
1071
  "research/docs/data.md": {
1072
  "git_blob": "1d0a74102cee4ed06b783085ca2ce823c6bf3a42",
 
1079
  "size": 7098
1080
  },
1081
  "research/docs/explorer.js": {
1082
+ "git_blob": "76fa33ca5b2dd5a87c8c392a66971a5e7be2acc0",
1083
+ "sha256": "3142c81efe2857daade3f549d8820c656f5a4413e9519991415c6563ce32815c",
1084
+ "size": 18278
1085
  },
1086
  "research/docs/figures/architecture.png": {
1087
  "git_blob": "2c41c712a9edfcc9f53e1ac8f76e751e54dc8924",
 
1129
  "size": 1435
1130
  },
1131
  "research/docs/index.html": {
1132
+ "git_blob": "2321fd840e4a9af8570f7ae2a675a23b5f20d1a2",
1133
+ "sha256": "807bf1ef6cf2b38cf5eabdaa94469be783518dbd626c3e20b6a16f2f4f56106d",
1134
+ "size": 9403
1135
  },
1136
  "research/docs/runbook.md": {
1137
+ "git_blob": "f8e79a6499887599a540813346dc2637fa66b899",
1138
+ "sha256": "78454674f04d677ab6aaebdcda7eced86dea98a08db3426848b6588ff5cc23dd",
1139
+ "size": 7624
1140
  },
1141
  "research/docs/study.json": {
1142
+ "git_blob": "450ebf1be137063c3252120d5e9a9d79fafeeb6f",
1143
+ "sha256": "d08a6182a373f8fd6c101873cd168ac82f4976711f81615d67999b501e7d993b",
1144
+ "size": 379457
1145
  },
1146
  "research/docs/third-derivative-penalty.md": {
1147
  "git_blob": "a62df59c3abcf3f4335575717346e26663e2d649",
 
1188
  "sha256": "7e103ed8d5a8104b6a1384c8c002f3585af6b34b3728be2a44a8cd5f4de30e79",
1189
  "size": 231
1190
  },
1191
+ "research/reports/experiments/abstracts-pilot-s00-hessian_norm-r03-fp64/experiment.md": {
1192
+ "git_blob": "82e15b4581471fe5b1ac3cfe3ee8bd7a8edb161b",
1193
+ "sha256": "9b7975b0f39382b4d920544ff469bf60f936d949fbf848639825c29059a9036e",
1194
+ "size": 778
1195
+ },
1196
+ "research/reports/experiments/abstracts-pilot-s00-hessian_norm-r03-fp64/learnings.md": {
1197
+ "git_blob": "9df9dd986c35964f238cbf7c96b5b3014e4826f9",
1198
+ "sha256": "38dabca49ef1ebbbb543a3db3a8d196b6743d2eeb3297b5b744502984e2cdb58",
1199
+ "size": 103
1200
+ },
1201
  "research/reports/experiments/abstracts-pilot-s00-third-r01-fp64/experiment.md": {
1202
  "git_blob": "edbf6b5da8d0b4c286103409c23af2058f441256",
1203
  "sha256": "fc1d5a71063755b96e70949cda383f7ab532f92c3f7821312856f018f10c9e48",
 
1269
  "size": 231
1270
  },
1271
  "research/reports/experiments/experiments.md": {
1272
+ "git_blob": "5294bed93e1ab3a5a93d1c5ee0537b9386a96bfe",
1273
+ "sha256": "a86b205ead9e74667d0707317c3142a54eca27e31ac5b09d84863c8ecfb2d4bb",
1274
+ "size": 4750
1275
  },
1276
  "research/reports/experiments/learnings.md": {
1277
+ "git_blob": "d7da9ed30545dcc35dc930771c75a786694aebd2",
1278
+ "sha256": "015d83f31211a3da6db219c957952adcdc2d0519b5a251e29d2e0f40bdd664a0",
1279
+ "size": 5979
1280
  },
1281
  "research/reports/experiments/stories-control-s00-initial-r00/experiment.md": {
1282
  "git_blob": "992585a6ffda93756c0d396ce1a64652b5db5e11",
 
1403
  "sha256": "ee367dea7be8b4dea20e364c45b5203f0613c172e015260fd3470ec1b96f5ea9",
1404
  "size": 7658
1405
  },
1406
+ "research/reports/hybrid/results.md": {
1407
+ "git_blob": "eb779c2efa542e30c7c29e73bc074265b92d4417",
1408
+ "sha256": "26c3d81d0c6604f7b582dbf0abaae2002607b08764dbefba109c120483a8a66e",
1409
+ "size": 974
1410
+ },
1411
  "research/reports/literature-review.md": {
1412
  "git_blob": "60cb61940a961b869b09e18931fb885668994e62",
1413
  "sha256": "b428342869af2fd26f05c2b2d2cfc14749a6c9021c62e9f20689d522cdc1ce00",
1414
  "size": 7290
1415
  },
1416
  "research/reports/paper.pdf": {
1417
+ "git_blob": "a931e877485713c653d22a976080b6ee0a151582",
1418
+ "sha256": "299f21af7f38a63a6eed35bb1db8f5c395b372b0d52211c9169143ff9566d89f",
1419
+ "size": 368636
1420
  },
1421
  "research/reports/plan.md": {
1422
  "git_blob": "bbbef734559f38fba5d30195539a46a1249d11eb",
 
1434
  "size": 5234
1435
  },
1436
  "research/reports/progress.md": {
1437
+ "git_blob": "cf73313918abb33772b33e11798f543143e61cfe",
1438
+ "sha256": "ae39a115a948ca9a9463a5b22fe37282ed0805cc0560bd88f02b755207b2f422",
1439
+ "size": 1512
1440
  },
1441
  "research/reports/reviews/adapter-verification.md": {
1442
  "git_blob": "1ad4e5807c9e22c39721e238af4c640f4537cf66",
 
1454
  "size": 1740
1455
  },
1456
  "research/reports/summary.md": {
1457
+ "git_blob": "d7bc98088f9f6b54d0ae56c9326e3e91c8ceaecc",
1458
+ "sha256": "fd7849db270207850d60e0ea005938c018ec008fb54c3acf6d9c721b5de2b29c",
1459
+ "size": 3620
1460
  },
1461
  "research/results/abstracts-control-s00-initial-r00/config.json": {
1462
  "git_blob": "0371479e1ad5f1c59b484eb112d315a86c82852d",
 
1523
  "sha256": "151317f2000a774805912d4132cd2380f7367f9a7a17d4dd780a976fd0bc32a4",
1524
  "size": 1337
1525
  },
1526
+ "research/results/abstracts-pilot-s00-hessian_norm-r03-fp64/state.json": {
1527
+ "git_blob": "8086e40cd510ed553a36c470ff372e3eb8dffa9e",
1528
+ "sha256": "042ab8a28b5bb54efa9b636ebbec6d96b3e51502856b206b91609e282d64b93e",
1529
+ "size": 471
1530
+ },
1531
  "research/results/abstracts-pilot-s00-third-r01-fp64/config.json": {
1532
  "git_blob": "d394e2482f47ef5cdfbb831b4657c7e08297f727",
1533
  "sha256": "fa7041dddeec4cb77c7ba0edd75284d10caca1d28d7509b171186ca479d87950",
 
1743
  "sha256": "f61dcd6d63f102755b2705140b274b65fc870c3cded3961845ca5ed51e1a6d00",
1744
  "size": 3010
1745
  },
1746
+ "research/results/feasibility/abstracts.json": {
1747
+ "git_blob": "d9a1b3a8fddcb365ff62b5ad988ef880cf1ad85a",
1748
+ "sha256": "90742fa59a059061a6821c025826213178faaeedf6ef52030ddd897cafa199a8",
1749
+ "size": 892
1750
+ },
1751
+ "research/results/feasibility/one-week.json": {
1752
+ "git_blob": "34f8b18370817611959655e1f4a377985a6827f8",
1753
+ "sha256": "fa38370a2c7fcbe411cdb7ef4be2d8b144f9af2f103ba9dfeda4650176d95abf",
1754
+ "size": 3005
1755
+ },
1756
  "research/results/feasibility/stories.json": {
1757
  "git_blob": "ce046159f638f1cee4085da49a487524f53dafed",
1758
  "sha256": "ca96ea2ec017c3d2ed24e390d910cb39010c82e387e63293aec1619dbbed33a5",
1759
  "size": 875
1760
  },
1761
+ "research/results/selection/abstracts.json": {
1762
+ "git_blob": "7b81072e24367e3e4d6ea187083bcaec649eab50",
1763
+ "sha256": "2fdcd45eb84f7e72fd555ad79f03705afcff12c36f35c1de6939049c41b04b7e",
1764
+ "size": 901
1765
+ },
1766
  "research/results/selection/stories.json": {
1767
  "git_blob": "a9a120bc0f8705fa86cbf57e032cc4229aab4517",
1768
  "sha256": "e42c2bb8c67a89999fe7ac1e93371b36f9d7674abf05a3fc59ee4ac24c5795ad",
 
2064
  "size": 86
2065
  },
2066
  "research/src/thirdloss/analysis.py": {
2067
+ "git_blob": "2a1f44b9ac9a3b28544aaaeb739195cfe02901ee",
2068
+ "sha256": "a3c6fed1e4c506513f521823a59ff21174010552948dc09094649412176b14d9",
2069
+ "size": 9767
2070
  },
2071
  "research/src/thirdloss/cli.py": {
2072
+ "git_blob": "b7a8263e895229910a332a6799c8466361553dd3",
2073
+ "sha256": "465b770dc7f7b338dda93ba769b40379a0bfecfc3a4c71b396b8b6501284235b",
2074
+ "size": 6911
2075
  },
2076
  "research/src/thirdloss/data.py": {
2077
  "git_blob": "9b06438a0bce64f8d491cd65156ebe8aa04e8916",
 
2088
  "sha256": "928d4a2bf9fb55094604ab1b1b070dd8c9ed62e8dc7336dd303e6b4d24ce13c9",
2089
  "size": 13687
2090
  },
2091
+ "research/src/thirdloss/hybrid.py": {
2092
+ "git_blob": "bdc15e5b347dd33fb30b448e3c56851ecd9292b4",
2093
+ "sha256": "f234cc1fab1717f5367b6be66120b70ebceb6af974cc0909b4e6b22e86720b9e",
2094
+ "size": 11015
2095
+ },
2096
+ "research/src/thirdloss/hybrid_results.py": {
2097
+ "git_blob": "751742c1cb1ead31b4940e9c3b0c98a9c9fc17d4",
2098
+ "sha256": "34fb6108d9923fa1e4a71cc62768e51d2a70125661b5585beec576fd9211ab5c",
2099
+ "size": 3005
2100
+ },
2101
  "research/src/thirdloss/live_hub.py": {
2102
  "git_blob": "11be73956f4e0b255b14b88c6dbd7dbb08439ab6",
2103
  "sha256": "27921980e4fe34b7de486028f531aff00c07ca7bc9037ffda3535984c15ffe40",
 
2109
  "size": 8088
2110
  },
2111
  "research/src/thirdloss/objectives.py": {
2112
+ "git_blob": "3ac9a79d95a323ca426d2ac61b19fdaaae42e55a",
2113
+ "sha256": "fb95a9b1bf7afacfb91448672c5c898ea01828c113f3c1cfe1959d2fa3fc9cf3",
2114
+ "size": 10378
2115
  },
2116
  "research/src/thirdloss/overlap.py": {
2117
  "git_blob": "869bfc3223ac8688e908d7e7f649db27397ded99",
 
2119
  "size": 5553
2120
  },
2121
  "research/src/thirdloss/penalties.py": {
2122
+ "git_blob": "c2edf32de7e74f25a8f0ba329d3ab68efa2f444d",
2123
+ "sha256": "bfbb5909d54d08bbe9ce000d4c15069d6f892f8faa68c4c85b890bd84774feaa",
2124
+ "size": 2955
2125
  },
2126
  "research/src/thirdloss/precision.py": {
2127
  "git_blob": "476cc82ccc66376eeaff5c9461158b34ca39e7e2",
 
2134
  "size": 6073
2135
  },
2136
  "research/src/thirdloss/progress.py": {
2137
+ "git_blob": "7838665305394260f6a2b732aaf3b2ce1966604d",
2138
+ "sha256": "f81fdd562100bca5ba1b4e48f59e8c17eda4abc5b25c97f16371a10331a20253",
2139
+ "size": 6703
2140
  },
2141
  "research/src/thirdloss/records.py": {
2142
  "git_blob": "a800de00d42944f13a89d8d2f91ce9b2103bbd45",
 
2144
  "size": 3710
2145
  },
2146
  "research/src/thirdloss/release.py": {
2147
+ "git_blob": "32e2066b92b46668ea83131885304384a57972e1",
2148
+ "sha256": "52e44d5475d3a90122ddc4ac510ab3ed1005d2f37f6bdf3aa78a85f2d7f3e01b",
2149
+ "size": 5807
2150
  },
2151
  "research/src/thirdloss/report_figures.py": {
2152
+ "git_blob": "040404ddcb284b590508954c005a7c64bc6521e8",
2153
+ "sha256": "842999a32c58843e43a4f3e6d17789d00dc7ecd821e9458cc980f684ac1d4d59",
2154
+ "size": 10129
2155
  },
2156
  "research/src/thirdloss/report_paper.py": {
2157
+ "git_blob": "a8578227717db49c4d0f7c145f955fd06558b357",
2158
+ "sha256": "6389c2248b3e1c91b8435dea86800d74a99437e5d280380910ee832b0a710a0e",
2159
+ "size": 33672
2160
  },
2161
  "research/src/thirdloss/report_records.py": {
2162
+ "git_blob": "79ba864c4ab454780c970a90d6b9e26f77b81147",
2163
+ "sha256": "13f7f5ab6370b43f4a2310d88aafbb0d00a30f8eb837b203d38dac846790450e",
2164
+ "size": 13208
2165
  },
2166
  "research/src/thirdloss/reporting.py": {
2167
+ "git_blob": "2fdb26036e3d1a74e2dd93338b601668cec9399f",
2168
+ "sha256": "d112ee9f740b6439edf08ab6fc5089de0063181427dcf83f8ea049db25ca7b4c",
2169
+ "size": 19498
2170
  },
2171
  "research/src/thirdloss/study.py": {
2172
+ "git_blob": "e1678f1e03b6f22034f6e25ae276e89bfa52bb33",
2173
+ "sha256": "68c2544c8bd6ee2945ae07533af9009b622c836b70d127f2c44f4af0a0899369",
2174
+ "size": 10541
2175
  },
2176
  "research/src/thirdloss/train.py": {
2177
+ "git_blob": "3c16d7419d10d1709d4a168ad7765909fbef77a6",
2178
+ "sha256": "09e60401938d182643ceb7cea3927ad6c0439d40d6f8cd3e1b2425c2e1206c3c",
2179
+ "size": 16614
2180
  },
2181
  "research/src/thirdloss/verification.py": {
2182
  "git_blob": "4aa026d9ad8bcfd44856f2f8bd63e7d2a14c30ab",
2183
  "sha256": "1b6a3e76f6aaa7785340fc73b67c0be0c986153b777f015359cfa4334636d95f",
2184
  "size": 1305
2185
  },
2186
+ "research/src/thirdloss/width.py": {
2187
+ "git_blob": "271ad17ba188a064e6ae5a98fa54281b72c55e8e",
2188
+ "sha256": "aabe0f894cb7d90650e6ede6e34bb684ca0a1442bec2b630d2ea13aeca821501",
2189
+ "size": 3357
2190
+ },
2191
  "research/src/thirdloss/windows.py": {
2192
  "git_blob": "2000a312e8326b97f88acead4b5c53e6d26eeab2",
2193
  "sha256": "7dc423e2a4777184d60a209f5d3b884cc3f4a9d651aba769c5f940902cc73fee",
 
2213
  "sha256": "6dadeaf5b08d9c2dbe1df2d24a247b23d005a0ededb280630c82f41845084bc5",
2214
  "size": 3476
2215
  },
2216
+ "research/tests/test_hybrid.py": {
2217
+ "git_blob": "5c3efb1bde12e02fc8fcfde30550ce56d831b9bf",
2218
+ "sha256": "ceef1eee885a8d47b0fd6df4bbb207f95f32e743cb2c2512c15ad99c982847e0",
2219
+ "size": 5225
2220
+ },
2221
  "research/tests/test_reporting.py": {
2222
  "git_blob": "8d35cec22ff32950b18690c8af5142d0b44bc644",
2223
  "sha256": "6a144d3dbae968da797bb4765c8c37b1543abc9e54d32e88f6de8ef8d9218bf5",
 
2283
  "type": "dataset"
2284
  }
2285
  },
2286
+ "verified_at": "2026-11-25T10:33:39+00:00"
2287
  }
research/README.md CHANGED
@@ -47,15 +47,17 @@ A same-probe check on pretrained Pythia found that single-precision arithmetic m
47
  <!-- RESULTS:START -->
48
  [Explore the results](https://burnycoder.github.io/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/) · [Hugging Face explorer](https://huggingface.co/spaces/BurnyCoder/thirdloss-explorer) · [Hugging Face collection](https://huggingface.co/collections/BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378) · [Paper](reports/paper.pdf) · [Run ledger](reports/experiments/experiments.md)
49
 
50
- Recorded 22 runs, including 22 with a completed summary.
51
 
52
  **TinyStories.** Awaiting paired test results (0 of 8 full-horizon training triplets).
53
 
54
  **Research abstracts.** Awaiting paired test results (0 of 8 full-horizon training triplets).
55
 
 
 
56
  **TinyStories development pilot.** At 2,097,152 training targets, the third-order run recorded 0.00004 nats per target token lower against Ordinary AdamW, 0.00024 nats per target token lower against Trace + third derivative, 0.00175 nats per target token lower against Squared Hessian norm, 0.00032 nats per target token lower against Randomized gradient signs, 0.00034 nats per target token lower against Hessian trace. These are single-seed descriptions using strengths selected on development.
57
 
58
- **Research abstracts development pilot.** At 65,536 training targets, the third-order run recorded 0.00091 nats per target token higher against Ordinary AdamW, 0.00074 nats per target token higher against Hessian trace. These are single-seed descriptions using initial pilot strengths.
59
 
60
  ### Measured scores
61
 
 
47
  <!-- RESULTS:START -->
48
  [Explore the results](https://burnycoder.github.io/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/) · [Hugging Face explorer](https://huggingface.co/spaces/BurnyCoder/thirdloss-explorer) · [Hugging Face collection](https://huggingface.co/collections/BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378) · [Paper](reports/paper.pdf) · [Run ledger](reports/experiments/experiments.md)
49
 
50
+ Recorded 23 runs, including 22 with a completed summary.
51
 
52
  **TinyStories.** Awaiting paired test results (0 of 8 full-horizon training triplets).
53
 
54
  **Research abstracts.** Awaiting paired test results (0 of 8 full-horizon training triplets).
55
 
56
+ TinyStories hybrid follow-up: 0 of 48 full runs and 0 of 8 shared checkpoints complete. Geometric decision: awaiting eight paired width measurements. [Width measurements, scores and controls](reports/hybrid/results.md)
57
+
58
  **TinyStories development pilot.** At 2,097,152 training targets, the third-order run recorded 0.00004 nats per target token lower against Ordinary AdamW, 0.00024 nats per target token lower against Trace + third derivative, 0.00175 nats per target token lower against Squared Hessian norm, 0.00032 nats per target token lower against Randomized gradient signs, 0.00034 nats per target token lower against Hessian trace. These are single-seed descriptions using strengths selected on development.
59
 
60
+ **Research abstracts development pilot.** At 65,536 training targets, the third-order run recorded 0.00030 nats per target token higher against Ordinary AdamW, 0.00027 nats per target token higher against Hessian trace. These are single-seed descriptions using strengths selected on development.
61
 
62
  ### Measured scores
63
 
research/docs/explorer.js CHANGED
@@ -15,6 +15,10 @@ const metrics = {
15
  raw_third: ["Third-derivative norm estimate", "squared Frobenius estimate"],
16
  raw_trace: ["Hessian trace estimate", "signed trace estimate"],
17
  raw_hessian_norm: ["Squared Hessian norm estimate", "squared Frobenius estimate"],
 
 
 
 
18
  };
19
  const axes = {tokens: "training target tokens", train_seconds: "training seconds", step: "optimizer steps"};
20
  const numeric = value => typeof value === "number" && Number.isFinite(value);
@@ -67,7 +71,8 @@ function rebuildFilters() {
67
  function showTotals() {
68
  element("runs-count").textContent = number(study.runs.filter(isComplete).length, 0);
69
  for (const [field, target] of [["tokens", "tokens-count"], ["train_seconds", "hours-count"]]) {
70
- const values = study.runs.map(run => run[field]).filter(numeric);
 
71
  const total = values.reduce((a, b) => a + b, 0);
72
  element(target).textContent = values.length ? (field === "tokens" ? compact(total) : number(total / 3600, 2) + " h") : "—";
73
  if (values.length) element(target).title = number(total, 0) + (field === "tokens" ? " training tokens" : " seconds");
@@ -155,7 +160,7 @@ function draw() {
155
  if (metric.endsWith("accuracy")) {
156
  low = 0; high = 100;
157
  } else {
158
- const pad = (high - low || Math.max(Math.abs(high) * .1, .01)) * .09;
159
  low -= pad; high += pad;
160
  if (["dev_nll", "loss", "raw_third", "raw_hessian_norm"].includes(metric)) low = Math.max(0, low);
161
  }
@@ -205,7 +210,7 @@ function draw() {
205
  ctx.fillStyle = "white"; ctx.strokeStyle = methodColor(p.run.method); ctx.lineWidth = 2.3;
206
  ctx.beginPath(); ctx.arc(p.px, p.py, 4.7, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
207
  element("point").textContent = p.run.id + " · " + number(p.x, axis === "train_seconds" ? 1 : 0) +
208
- " " + axes[axis] + " · " + number(p.y, 4) + " " + metrics[metric][1];
209
  }
210
  }
211
 
 
15
  raw_third: ["Third-derivative norm estimate", "squared Frobenius estimate"],
16
  raw_trace: ["Hessian trace estimate", "signed trace estimate"],
17
  raw_hessian_norm: ["Squared Hessian norm estimate", "squared Frobenius estimate"],
18
+ width: ["Directional width", "Euclidean weight distance"], width_probe_nll: ["Width-probe loss", "nats / target token"],
19
+ curvature_rms: ["Rolling RMS curvature", "RMS Hessian eigenvalue estimate"],
20
+ third_lambda: ["Third-derivative coefficient", "coefficient"], trace_lambda: ["Trace coefficient", "coefficient"],
21
+ gradient_norm: ["Unclipped gradient norm", "Euclidean gradient norm"],
22
  };
23
  const axes = {tokens: "training target tokens", train_seconds: "training seconds", step: "optimizer steps"};
24
  const numeric = value => typeof value === "number" && Number.isFinite(value);
 
71
  function showTotals() {
72
  element("runs-count").textContent = number(study.runs.filter(isComplete).length, 0);
73
  for (const [field, target] of [["tokens", "tokens-count"], ["train_seconds", "hours-count"]]) {
74
+ const values = study.runs.filter(run => numeric(run[field])).map(run =>
75
+ Math.max(0,run[field] - (run["inherited_" + field] || 0)));
76
  const total = values.reduce((a, b) => a + b, 0);
77
  element(target).textContent = values.length ? (field === "tokens" ? compact(total) : number(total / 3600, 2) + " h") : "—";
78
  if (values.length) element(target).title = number(total, 0) + (field === "tokens" ? " training tokens" : " seconds");
 
160
  if (metric.endsWith("accuracy")) {
161
  low = 0; high = 100;
162
  } else {
163
+ const pad = (high - low || Math.abs(high) * .1 || .01) * .09;
164
  low -= pad; high += pad;
165
  if (["dev_nll", "loss", "raw_third", "raw_hessian_norm"].includes(metric)) low = Math.max(0, low);
166
  }
 
210
  ctx.fillStyle = "white"; ctx.strokeStyle = methodColor(p.run.method); ctx.lineWidth = 2.3;
211
  ctx.beginPath(); ctx.arc(p.px, p.py, 4.7, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
212
  element("point").textContent = p.run.id + " · " + number(p.x, axis === "train_seconds" ? 1 : 0) +
213
+ " " + axes[axis] + " · " + (p.y !== 0 && Math.abs(p.y)<.0001 ? p.y.toExponential(4) : number(p.y, 4)) + " " + metrics[metric][1];
214
  }
215
  }
216
 
research/docs/index.html CHANGED
@@ -49,6 +49,9 @@
49
  <option value="dev_accuracy">Development accuracy</option><option value="accuracy">Training accuracy</option>
50
  <option value="penalty">Weighted active penalty</option><option value="raw_third">Third-derivative norm estimate</option>
51
  <option value="raw_trace">Hessian trace estimate</option><option value="raw_hessian_norm">Squared Hessian norm estimate</option>
 
 
 
52
  </select></label>
53
  <label>Horizontal axis<select id="axis"><option value="tokens">Training tokens</option><option value="train_seconds">Training time</option><option value="step">Optimizer steps</option></select></label>
54
  </div>
@@ -95,7 +98,7 @@
95
  <p class="prose">Hochreiter and Schmidhuber proposed that among equally good training fits, flatter minima may generalize better. If weights can be rounded more coarsely and still fit, a good predictor can take fewer bits to describe. Here the test of generalization is how well the model predicts unseen tokens. <a href="https://people.idsia.ch/~juergen/fm/node1.html">Flat Minima (1997) ↗</a></p>
96
  <p class="prose">The Hessian describes local loss curvature. On active updates, two independent random sign vectors estimate how quickly that curvature changes for the next-token loss of two text windows. The derivatives cover all TinyStories decoder weights or only Pythia’s trainable attention adapters, including interactions between trainable weights.</p>
97
  <p class="prose">When moving away from a flat bottom makes curvature change faster, the third-derivative penalty can pull the weights back. A steep bowl with constant curvature receives zero penalty from this term. Whether the optimizer finds wider minima is a separate question from the measured next-token loss.</p>
98
- <p class="prose">A proposed TinyStories follow-up would keep the trace active and increase the weight on the third-derivative penalty once loss and recent curvature are low. Keeping that weight high could discourage later steps toward an edge where curvature changes rapidly. The experiment would compare the width retained with a fixed late start. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/reports/plan.md#curvature-dependent-penalty-weight">Schedule and planned controls ↗</a></p>
99
  <img class="architecture" src="figures/penalty-directions.png" alt="Analytic loss curves. Trace and third-derivative penalties push in opposite directions at an asymmetric minimum. They pull displaced weights back in a flat quartic and give zero update in a steep quadratic." loading="lazy">
100
  <p class="curve-note">Circles mark the ordinary loss minima. Arrows show downhill directions for each penalty. The vertical scales vary by panel. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum">Worked examples and the basin-width bound ↗</a></p>
101
  <img class="architecture" src="figures/architecture.png" alt="TinyStories full-weight training and Pythia QKV adaptation feed next-token cross-entropy, a Hessian contraction, a third derivative and the regularized objective." loading="lazy">
 
49
  <option value="dev_accuracy">Development accuracy</option><option value="accuracy">Training accuracy</option>
50
  <option value="penalty">Weighted active penalty</option><option value="raw_third">Third-derivative norm estimate</option>
51
  <option value="raw_trace">Hessian trace estimate</option><option value="raw_hessian_norm">Squared Hessian norm estimate</option>
52
+ <option value="width">Directional width</option><option value="width_probe_nll">Width-probe training NLL</option>
53
+ <option value="curvature_rms">Rolling RMS curvature</option><option value="third_lambda">Third-derivative coefficient</option>
54
+ <option value="trace_lambda">Trace coefficient</option><option value="gradient_norm">Unclipped gradient norm</option>
55
  </select></label>
56
  <label>Horizontal axis<select id="axis"><option value="tokens">Training tokens</option><option value="train_seconds">Training time</option><option value="step">Optimizer steps</option></select></label>
57
  </div>
 
98
  <p class="prose">Hochreiter and Schmidhuber proposed that among equally good training fits, flatter minima may generalize better. If weights can be rounded more coarsely and still fit, a good predictor can take fewer bits to describe. Here the test of generalization is how well the model predicts unseen tokens. <a href="https://people.idsia.ch/~juergen/fm/node1.html">Flat Minima (1997) ↗</a></p>
99
  <p class="prose">The Hessian describes local loss curvature. On active updates, two independent random sign vectors estimate how quickly that curvature changes for the next-token loss of two text windows. The derivatives cover all TinyStories decoder weights or only Pythia’s trainable attention adapters, including interactions between trainable weights.</p>
100
  <p class="prose">When moving away from a flat bottom makes curvature change faster, the third-derivative penalty can pull the weights back. A steep bowl with constant curvature receives zero penalty from this term. Whether the optimizer finds wider minima is a separate question from the measured next-token loss.</p>
101
+ <p class="prose">The TinyStories hybrid follow-up keeps the trace active. Its adaptive arm raises the third-derivative coefficient when recent curvature and training loss fall. Use the hybrid phase and directional width or coefficient measurements above to compare the adaptive arm, fixed ramp and replay controls. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/reports/hybrid/results.md">Widths, development scores and raw rays ↗</a></p>
102
  <img class="architecture" src="figures/penalty-directions.png" alt="Analytic loss curves. Trace and third-derivative penalties push in opposite directions at an asymmetric minimum. They pull displaced weights back in a flat quartic and give zero update in a steep quadratic." loading="lazy">
103
  <p class="curve-note">Circles mark the ordinary loss minima. Arrows show downhill directions for each penalty. The vertical scales vary by panel. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum">Worked examples and the basin-width bound ↗</a></p>
104
  <img class="architecture" src="figures/architecture.png" alt="TinyStories full-weight training and Pythia QKV adaptation feed next-token cross-entropy, a Hessian contraction, a third derivative and the regularized objective." loading="lazy">
research/docs/runbook.md CHANGED
@@ -11,6 +11,8 @@ uv run thirdloss dashboard --port 18765
11
 
12
  In another terminal, open the printed dashboard URL. The public explorer reads the last published results. The local dashboard reads running records. Accuracy is top-one token accuracy and NLL is in nats per target token. The training-time column excludes data preparation, checks, validation, checkpoint serialization and publication.
13
 
 
 
14
  Run `uv run thirdloss study` to execute both stages, select strengths on development data, freeze all confirmatory checkpoints, and evaluate them. The owner's publishing workflow uses `uv run thirdloss study --publish`. This uploads fitted coordinates after each run and the study record after each training/evaluation. A local clone can omit the publishing flag. Repeating the same command resumes the last saved optimization step and skips completed runs. Checkpoints include optimizer state, random state and data cursor. The corpus manifests and run configuration must match. [Data and leakage checks](data.md) · [Preregistered run matrix](../reports/planned-runs.md)
15
 
16
  Use `uv run thirdloss report` to regenerate the README results, PDF, figures, experiment notes, progress and explorer from `results/`. Use `uv run thirdloss progress` for current status. `uv run thirdloss evaluate RUN_ID` verifies the registered weight digest and test split before scoring a frozen run. Both tokenizers are stored alongside their stage data. Full untruncated generated token IDs, prompts, reference continuations and outputs are in each run's `samples.jsonl`. Timestamped session logs are stored locally under `logs/`.
 
11
 
12
  In another terminal, open the printed dashboard URL. The public explorer reads the last published results. The local dashboard reads running records. Accuracy is top-one token accuracy and NLL is in nats per target token. The training-time column excludes data preparation, checks, validation, checkpoint serialization and publication.
13
 
14
+ Use `uv run --locked thirdloss study --with-hybrid` for the two original stages plus the registered six-arm TinyStories follow-up. Once the TinyStories selection and calibration exist, `uv run --locked thirdloss hybrid` runs the follow-up alone. Add `--publish` to mirror each completed arm, optimizer state, unabridged logs, directional-width brackets and report to the project’s GitHub and Hugging Face repositories. Restart with the identical command. Branches inherit the same full-horizon AdamW moments, data position and lagged monitor. Select **hybrid** in the explorer and choose **Directional width** or **Third-derivative coefficient** to inspect a run. [Hybrid preregistration](../reports/hybrid/preregistration.md) · [Per-seed results](../reports/hybrid/results.md)
15
+
16
  Run `uv run thirdloss study` to execute both stages, select strengths on development data, freeze all confirmatory checkpoints, and evaluate them. The owner's publishing workflow uses `uv run thirdloss study --publish`. This uploads fitted coordinates after each run and the study record after each training/evaluation. A local clone can omit the publishing flag. Repeating the same command resumes the last saved optimization step and skips completed runs. Checkpoints include optimizer state, random state and data cursor. The corpus manifests and run configuration must match. [Data and leakage checks](data.md) · [Preregistered run matrix](../reports/planned-runs.md)
17
 
18
  Use `uv run thirdloss report` to regenerate the README results, PDF, figures, experiment notes, progress and explorer from `results/`. Use `uv run thirdloss progress` for current status. `uv run thirdloss evaluate RUN_ID` verifies the registered weight digest and test split before scoring a frozen run. Both tokenizers are stored alongside their stage data. Full untruncated generated token IDs, prompts, reference continuations and outputs are in each run's `samples.jsonl`. Timestamped session logs are stored locally under `logs/`.
research/docs/study.json CHANGED
The diff for this file is too large to render. See raw diff
 
research/reports/experiments/abstracts-pilot-s00-hessian_norm-r03-fp64/experiment.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Research abstracts · Squared Hessian norm
2
+
3
+ Run `abstracts-pilot-s00-hessian_norm-r03-fp64` · [raw records](../../../results/abstracts-pilot-s00-hessian_norm-r03-fp64/) · [registered design](../../preregistration.md)
4
+
5
+ | Stage | Method | Phase | Seed | Ratio | Train tokens | Dev NLL | Test NLL | Tokens/s | Status |
6
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
7
+ | Research abstracts | Squared Hessian norm | pilot | 0 | 0.030 | — | — | — | — | initializing |
8
+
9
+ Training time is — seconds. Peak allocated GPU memory is — MiB. Development token accuracy is —. Test token accuracy is —.
10
+
11
+ [Design and hyperparameter rationale](../../planned-runs.md) · [Saved configuration](../../../results/abstracts-pilot-s00-hessian_norm-r03-fp64/config.json)
research/reports/experiments/abstracts-pilot-s00-hessian_norm-r03-fp64/learnings.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Run learnings
2
+
3
+ A development observation is pending.
4
+
5
+ [Experiment and source records](experiment.md)
research/reports/experiments/experiments.md CHANGED
@@ -9,6 +9,7 @@ NLL is negative log-likelihood in nats per target token. A smaller value assigns
9
  | [abstracts-control-s00-initial-r00](./abstracts-control-s00-initial-r00/experiment.md) | Research abstracts | Initial checkpoint | control | 0 | 0.000 | 0 | 3.2517 | — | 0 | complete |
10
  | [abstracts-control-s00-unigram-r00](./abstracts-control-s00-unigram-r00/experiment.md) | Research abstracts | Unigram | control | 0 | 0.000 | 0 | 7.3306 | — | 0 | complete |
11
  | [abstracts-pilot-s00-ce-r00](./abstracts-pilot-s00-ce-r00/experiment.md) | Research abstracts | Ordinary AdamW | pilot | 0 | 0.000 | 65,536 | 3.1139 | — | 1,659 | complete |
 
12
  | [abstracts-pilot-s00-third-r01-fp64](./abstracts-pilot-s00-third-r01-fp64/experiment.md) | Research abstracts | Third derivative | pilot | 0 | 0.010 | 65,536 | 3.1142 | — | 189 | complete |
13
  | [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) | Research abstracts | Third derivative | diagnostic | 0 | 0.030 | 65,536 | 3.1168 | — | 907 | complete |
14
  | [abstracts-pilot-s00-third-r03-fp64](./abstracts-pilot-s00-third-r03-fp64/experiment.md) | Research abstracts | Third derivative | pilot | 0 | 0.030 | 65,536 | 3.1149 | — | 188 | complete |
 
9
  | [abstracts-control-s00-initial-r00](./abstracts-control-s00-initial-r00/experiment.md) | Research abstracts | Initial checkpoint | control | 0 | 0.000 | 0 | 3.2517 | — | 0 | complete |
10
  | [abstracts-control-s00-unigram-r00](./abstracts-control-s00-unigram-r00/experiment.md) | Research abstracts | Unigram | control | 0 | 0.000 | 0 | 7.3306 | — | 0 | complete |
11
  | [abstracts-pilot-s00-ce-r00](./abstracts-pilot-s00-ce-r00/experiment.md) | Research abstracts | Ordinary AdamW | pilot | 0 | 0.000 | 65,536 | 3.1139 | — | 1,659 | complete |
12
+ | [abstracts-pilot-s00-hessian_norm-r03-fp64](./abstracts-pilot-s00-hessian_norm-r03-fp64/experiment.md) | Research abstracts | Squared Hessian norm | pilot | 0 | 0.030 | — | — | — | — | initializing |
13
  | [abstracts-pilot-s00-third-r01-fp64](./abstracts-pilot-s00-third-r01-fp64/experiment.md) | Research abstracts | Third derivative | pilot | 0 | 0.010 | 65,536 | 3.1142 | — | 189 | complete |
14
  | [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) | Research abstracts | Third derivative | diagnostic | 0 | 0.030 | 65,536 | 3.1168 | — | 907 | complete |
15
  | [abstracts-pilot-s00-third-r03-fp64](./abstracts-pilot-s00-third-r03-fp64/experiment.md) | Research abstracts | Third derivative | pilot | 0 | 0.030 | 65,536 | 3.1149 | — | 188 | complete |
research/reports/experiments/learnings.md CHANGED
@@ -12,6 +12,8 @@ Independent random signs include mixed weight derivatives in the expected penalt
12
 
13
  - [abstracts-pilot-s00-ce-r00](./abstracts-pilot-s00-ce-r00/experiment.md) — Development NLL changed by -0.1172 nats per target token from 4,096 to 65,536 training targets. Attribution to the regularizer uses matched comparisons across seeds.
14
 
 
 
15
  - [abstracts-pilot-s00-third-r01-fp64](./abstracts-pilot-s00-third-r01-fp64/experiment.md) — Development NLL changed by -0.1168 nats per target token from 4,096 to 65,536 training targets. Attribution to the regularizer uses matched comparisons across seeds.
16
 
17
  - [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) — This original FP32 adapter run is preserved as a numerical diagnostic. The same-probe full-checkpoint audit found substantial rounding error in both the penalty and its training gradient. Strength selection and confirmatory inference use separately named FP64 derivative runs. The run ledger records 1 interrupted attempt(s).
 
12
 
13
  - [abstracts-pilot-s00-ce-r00](./abstracts-pilot-s00-ce-r00/experiment.md) — Development NLL changed by -0.1172 nats per target token from 4,096 to 65,536 training targets. Attribution to the regularizer uses matched comparisons across seeds.
14
 
15
+ - [abstracts-pilot-s00-hessian_norm-r03-fp64](./abstracts-pilot-s00-hessian_norm-r03-fp64/experiment.md) — A development observation is pending.
16
+
17
  - [abstracts-pilot-s00-third-r01-fp64](./abstracts-pilot-s00-third-r01-fp64/experiment.md) — Development NLL changed by -0.1168 nats per target token from 4,096 to 65,536 training targets. Attribution to the regularizer uses matched comparisons across seeds.
18
 
19
  - [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) — This original FP32 adapter run is preserved as a numerical diagnostic. The same-probe full-checkpoint audit found substantial rounding error in both the penalty and its training gradient. Strength selection and confirmatory inference use separately named FP64 derivative runs. The run ledger records 1 interrupted attempt(s).
research/reports/hybrid/results.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Hybrid schedules on TinyStories
2
+
3
+ TinyStories hybrid follow-up: 0 of 48 full runs and 0 of 8 shared checkpoints complete. Geometric decision: awaiting eight paired width measurements.
4
+
5
+ [Frozen protocol and decision rule](preregistration.md) · [Interactive measurement and run selector](../../docs/index.html#curves)
6
+
7
+ Two-sided directional width is measured in the original Euclidean weight coordinates at a fixed increase of 0.1 nats per target. Each linked JSON contains all 32 rays and their brackets. A missing upper bound means that the search reached its maximum radius before crossing.
8
+
9
+ The completed branches reused 0 targets of optimization compared with independently training each branch from initialization. The replay permutation couples different seeds through their coefficient histories. The sign-test reference for this comparison assumes exchangeable independent pair signs; that assumption is approximate here. All raw pairs are reported for inspection.
research/reports/paper.pdf CHANGED
Binary files a/research/reports/paper.pdf and b/research/reports/paper.pdf differ
 
research/reports/progress.md CHANGED
@@ -1,6 +1,6 @@
1
  # Study progress
2
 
3
- Updated 2026-11-25T10:27:58+00:00.
4
 
5
  21 training/control records and 0 final evaluations are complete. This is 17.5% of 120 planned model milestones.
6
 
@@ -12,10 +12,20 @@ Pilot rates project 1.69 remaining confirmation GPU-hours, excluding validation,
12
 
13
  Statistical status: pending. Awaiting confirmatory runs.
14
 
15
- **abstracts** has 9 completed runs. The next milestone is determined by the run matrix.
 
 
16
 
17
  Statistical status: pending. Awaiting confirmatory runs.
18
 
 
 
 
 
 
 
 
 
19
  ## Monitoring
20
 
21
  Inspect runs lasting over 10, 30 and 60 minutes at 5, 15 and 30 minute intervals respectively. The live dashboard refreshes between those checks. [Study design](plan.md) · [Run matrix](planned-runs.md) · [Experiment ledger](experiments/experiments.md)
 
1
  # Study progress
2
 
3
+ Updated 2026-11-25T10:33:28+00:00.
4
 
5
  21 training/control records and 0 final evaluations are complete. This is 17.5% of 120 planned model milestones.
6
 
 
12
 
13
  Statistical status: pending. Awaiting confirmatory runs.
14
 
15
+ **abstracts** has 9 completed runs. Current records: abstracts-pilot-s00-hessian_norm-r03-fp64 (initializing, 0 targets).
16
+
17
+ Pilot rates project 9.54 remaining confirmation GPU-hours, excluding validation, exports and uploads.
18
 
19
  Statistical status: pending. Awaiting confirmatory runs.
20
 
21
+ ## One-week feasibility
22
+
23
+ At the pre-test check on 2026-11-25T10:33:28+00:00, pilot timings projected 22.50 hours for all confirmatory training and scoring, with 141.73 hours of the week available for secondary pilots, setup, publication and interruptions. [Timing and GPU memory by method](../results/feasibility/one-week.json)
24
+
25
+ ## TinyStories hybrid follow-up
26
+
27
+ 0 of 48 full runs and 0 of 8 shared checkpoints complete. awaiting eight paired width measurements. [Per-seed widths and development scores](hybrid/results.md)
28
+
29
  ## Monitoring
30
 
31
  Inspect runs lasting over 10, 30 and 60 minutes at 5, 15 and 30 minute intervals respectively. The live dashboard refreshes between those checks. [Study design](plan.md) · [Run matrix](planned-runs.md) · [Experiment ledger](experiments/experiments.md)
research/reports/summary.md CHANGED
@@ -1,18 +1,20 @@
1
  # Study summary
2
 
3
- Recorded 22 runs, including 22 with a completed summary.
4
 
5
  **TinyStories.** Awaiting paired test results (0 of 8 full-horizon training triplets).
6
 
7
  **Research abstracts.** Awaiting paired test results (0 of 8 full-horizon training triplets).
8
 
 
 
9
  [Interactive explorer](https://burnycoder.github.io/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/) · [Per-run ledger](experiments/experiments.md) · [Preregistration](preregistration.md) · [Paper](paper.pdf)
10
 
11
  ## Development observations
12
 
13
  **TinyStories development pilot.** At 2,097,152 training targets, the third-order run recorded 0.00004 nats per target token lower against Ordinary AdamW, 0.00024 nats per target token lower against Trace + third derivative, 0.00175 nats per target token lower against Squared Hessian norm, 0.00032 nats per target token lower against Randomized gradient signs, 0.00034 nats per target token lower against Hessian trace. These are single-seed descriptions using strengths selected on development.
14
 
15
- **Research abstracts development pilot.** At 65,536 training targets, the third-order run recorded 0.00091 nats per target token higher against Ordinary AdamW, 0.00074 nats per target token higher against Hessian trace. These are single-seed descriptions using initial pilot strengths.
16
 
17
  ## Measured scores
18
 
 
1
  # Study summary
2
 
3
+ Recorded 23 runs, including 22 with a completed summary.
4
 
5
  **TinyStories.** Awaiting paired test results (0 of 8 full-horizon training triplets).
6
 
7
  **Research abstracts.** Awaiting paired test results (0 of 8 full-horizon training triplets).
8
 
9
+ TinyStories hybrid follow-up: 0 of 48 full runs and 0 of 8 shared checkpoints complete. Geometric decision: awaiting eight paired width measurements. [Hybrid outcomes](hybrid/results.md)
10
+
11
  [Interactive explorer](https://burnycoder.github.io/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/) · [Per-run ledger](experiments/experiments.md) · [Preregistration](preregistration.md) · [Paper](paper.pdf)
12
 
13
  ## Development observations
14
 
15
  **TinyStories development pilot.** At 2,097,152 training targets, the third-order run recorded 0.00004 nats per target token lower against Ordinary AdamW, 0.00024 nats per target token lower against Trace + third derivative, 0.00175 nats per target token lower against Squared Hessian norm, 0.00032 nats per target token lower against Randomized gradient signs, 0.00034 nats per target token lower against Hessian trace. These are single-seed descriptions using strengths selected on development.
16
 
17
+ **Research abstracts development pilot.** At 65,536 training targets, the third-order run recorded 0.00030 nats per target token higher against Ordinary AdamW, 0.00027 nats per target token higher against Hessian trace. These are single-seed descriptions using strengths selected on development.
18
 
19
  ## Measured scores
20
 
research/results/abstracts-pilot-s00-hessian_norm-r03-fp64/state.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "abstracts-pilot-s00-hessian_norm-r03-fp64",
3
+ "stage": "abstracts",
4
+ "method": "hessian_norm",
5
+ "phase": "pilot",
6
+ "seed": 0,
7
+ "ratio": 0.03,
8
+ "token_budget": 65536,
9
+ "batch_windows": 8,
10
+ "context": 128,
11
+ "data_manifest_sha256": "0638bd23a7d1dc3ecb9138074ecd922211df2637f60736ddfab7e9aec0b3ccb9",
12
+ "microbatch": 2,
13
+ "derivative_dtype": "float64",
14
+ "derivative_device": "cpu",
15
+ "status": "initializing",
16
+ "timestamp": "2026-11-25T10:28:28+00:00"
17
+ }
research/results/feasibility/abstracts.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "stage": "abstracts",
3
+ "arms": [
4
+ {
5
+ "method": "third",
6
+ "pilot_run": "abstracts-pilot-s00-third-r01-fp64",
7
+ "tokens_per_sec": 189.1219465392862,
8
+ "peak_vram_mb": 2346.30029296875,
9
+ "projected_confirm_hours": 6.160493088000351
10
+ },
11
+ {
12
+ "method": "ce",
13
+ "pilot_run": "abstracts-pilot-s00-ce-r00",
14
+ "tokens_per_sec": 1658.777719349496,
15
+ "peak_vram_mb": 2346.30029296875,
16
+ "projected_confirm_hours": 0.7023752675562476
17
+ },
18
+ {
19
+ "method": "trace",
20
+ "pilot_run": "abstracts-pilot-s00-trace-r01-fp64",
21
+ "tokens_per_sec": 434.53219157783866,
22
+ "peak_vram_mb": 2346.30029296875,
23
+ "projected_confirm_hours": 2.6812385066659448
24
+ }
25
+ ],
26
+ "projected_confirm_training_hours": 9.544106862222543,
27
+ "basis": "Pilot training time. Data, calibration, evaluation, checkpoint and upload overhead are additional."
28
+ }
research/results/feasibility/one-week.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "computed_at": "2026-11-25T10:33:28+00:00",
3
+ "first_training_update_at": "2026-11-25T06:47:20+00:00",
4
+ "arms": [
5
+ {
6
+ "stage": "stories",
7
+ "method": "third",
8
+ "pilot_run": "stories-pilot-s00-third-r01",
9
+ "pilot_tokens_per_second": 42480.876701096255,
10
+ "peak_allocated_mib": 608.21533203125,
11
+ "pilot_loop_seconds": 61.195636899999954,
12
+ "pilot_finalizing_seconds": 5.0,
13
+ "projected_test_seconds_per_run": 27.299253957629713,
14
+ "projected_hours_all_seeds": 1.1596985536836208
15
+ },
16
+ {
17
+ "stage": "stories",
18
+ "method": "ce",
19
+ "pilot_run": "stories-pilot-s00-ce-r00",
20
+ "pilot_tokens_per_second": 123871.07334510093,
21
+ "peak_allocated_mib": 608.21533203125,
22
+ "pilot_loop_seconds": 25.10114049999902,
23
+ "pilot_finalizing_seconds": 4.0,
24
+ "projected_test_seconds_per_run": 20.474440468222284,
25
+ "projected_hours_all_seeds": 0.5006301432626987
26
+ },
27
+ {
28
+ "stage": "stories",
29
+ "method": "trace",
30
+ "pilot_run": "stories-pilot-s00-trace-r01",
31
+ "pilot_tokens_per_second": 73185.43191029143,
32
+ "peak_allocated_mib": 608.21533203125,
33
+ "pilot_loop_seconds": 36.05276049999884,
34
+ "pilot_finalizing_seconds": 5.0,
35
+ "projected_test_seconds_per_run": 27.299253957629713,
36
+ "projected_hours_all_seeds": 0.7127140843502676
37
+ },
38
+ {
39
+ "stage": "abstracts",
40
+ "method": "third",
41
+ "pilot_run": "abstracts-pilot-s00-third-r01-fp64",
42
+ "pilot_tokens_per_second": 189.1219465392862,
43
+ "peak_allocated_mib": 2346.30029296875,
44
+ "pilot_loop_seconds": 367.77427570000145,
45
+ "pilot_finalizing_seconds": 705.0,
46
+ "projected_test_seconds_per_run": 670.2049821323709,
47
+ "projected_hours_all_seeds": 9.594220417183072
48
+ },
49
+ {
50
+ "stage": "abstracts",
51
+ "method": "ce",
52
+ "pilot_run": "abstracts-pilot-s00-ce-r00",
53
+ "pilot_tokens_per_second": 1658.777719349496,
54
+ "peak_allocated_mib": 2346.30029296875,
55
+ "pilot_loop_seconds": 60.80243370000244,
56
+ "pilot_finalizing_seconds": 715.0,
57
+ "projected_test_seconds_per_run": 679.7930362401302,
58
+ "projected_hours_all_seeds": 4.180472235200333
59
+ },
60
+ {
61
+ "stage": "abstracts",
62
+ "method": "trace",
63
+ "pilot_run": "abstracts-pilot-s00-trace-r01-fp64",
64
+ "pilot_tokens_per_second": 434.53219157783866,
65
+ "peak_allocated_mib": 2346.30029296875,
66
+ "pilot_loop_seconds": 172.96475099999952,
67
+ "pilot_finalizing_seconds": 755.0,
68
+ "projected_test_seconds_per_run": 718.1452526711671,
69
+ "projected_hours_all_seeds": 6.348585023713697
70
+ }
71
+ ],
72
+ "hours_left_in_week": 164.23111111111112,
73
+ "projected_confirmation_and_scoring_hours": 22.49632045739369,
74
+ "hours_available_for_other_work": 141.73479065371743,
75
+ "fits_measured_budget": true,
76
+ "scope": "All 48 confirmations and test evaluations. Remaining secondary pilots, process startup, publishing, downtime and retries use the reported headroom. Times are observational projections."
77
+ }
research/results/selection/abstracts.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "stage": "abstracts",
3
+ "candidates": {
4
+ "trace": [
5
+ {
6
+ "ratio": 0.01,
7
+ "nll": 3.113974483425786,
8
+ "run": "abstracts-pilot-s00-trace-r01-fp64"
9
+ },
10
+ {
11
+ "ratio": 0.03,
12
+ "nll": 3.11411782781259,
13
+ "run": "abstracts-pilot-s00-trace-r03-fp64"
14
+ },
15
+ {
16
+ "ratio": 0.1,
17
+ "nll": 3.11428017700472,
18
+ "run": "abstracts-pilot-s00-trace-r10-fp64"
19
+ }
20
+ ],
21
+ "third": [
22
+ {
23
+ "ratio": 0.01,
24
+ "nll": 3.1142473177545655,
25
+ "run": "abstracts-pilot-s00-third-r01-fp64"
26
+ },
27
+ {
28
+ "ratio": 0.03,
29
+ "nll": 3.1148602603458824,
30
+ "run": "abstracts-pilot-s00-third-r03-fp64"
31
+ },
32
+ {
33
+ "ratio": 0.1,
34
+ "nll": 3.116312030307629,
35
+ "run": "abstracts-pilot-s00-third-r10-fp64"
36
+ }
37
+ ]
38
+ },
39
+ "ratios": {
40
+ "trace": 0.01,
41
+ "third": 0.01
42
+ }
43
+ }
research/src/thirdloss/analysis.py CHANGED
@@ -27,9 +27,14 @@ def _comparison(records, baseline):
27
  other = records[seed, baseline]["test_nll"]
28
  pairs.append({"seed": seed, "third_nll": third, "baseline_nll": other, "delta": third - other})
29
 
 
 
 
 
 
30
  ordered = sorted(pair["delta"] for pair in pairs)
31
- wins = sum(d < 0 for d in ordered)
32
- losses = sum(d > 0 for d in ordered)
33
  discordant = wins + losses
34
  # Exact upper binomial tail under fair signs conditional on discordant pairs.
35
  # https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binomtest.html
@@ -57,6 +62,14 @@ def _comparison(records, baseline):
57
  }
58
 
59
 
 
 
 
 
 
 
 
 
60
  def _time_match(seed, records, clock="train_seconds"):
61
  """Look backward from the shortest complete training run to actual validation evaluations."""
62
  runs = {method: records[seed, method] for method in _METHODS}
@@ -172,10 +185,8 @@ def analyze_stage(summaries: list[dict], stage: str) -> dict:
172
  comparisons = {baseline: _comparison(records, baseline) for baseline in ("ce", "trace")}
173
  # Holm step-down: adjusted p-values are monotone in raw-p rank; ties receive equal values.
174
  # https://stat.ethz.ch/R-manual/R-devel/library/stats/html/p.adjust.html
175
- running_max = 0.0
176
- for index, stats in enumerate(sorted(comparisons.values(), key=lambda item: item["p_raw"])):
177
- running_max = max(running_max, stats["p_raw"] * (len(comparisons) - index))
178
- stats["p_holm"] = min(1.0, running_max)
179
  if stats["p_holm"] <= 0.05:
180
  stats["interpretation"] = "improved"
181
  elif stats["median_ci"][0] > 0:
 
27
  other = records[seed, baseline]["test_nll"]
28
  pairs.append({"seed": seed, "third_nll": third, "baseline_nll": other, "delta": third - other})
29
 
30
+ return paired_sign(pairs)
31
+
32
+
33
+ def paired_sign(pairs, *, larger=False):
34
+ """Exact conditional paired sign test and symmetric order-statistic median interval."""
35
  ordered = sorted(pair["delta"] for pair in pairs)
36
+ wins = sum(d > 0 if larger else d < 0 for d in ordered)
37
+ losses = sum(d < 0 if larger else d > 0 for d in ordered)
38
  discordant = wins + losses
39
  # Exact upper binomial tail under fair signs conditional on discordant pairs.
40
  # https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binomtest.html
 
62
  }
63
 
64
 
65
+ def holm(comparisons):
66
+ """Adjust a prespecified family using Holm's monotone step-down procedure."""
67
+ maximum = 0.
68
+ for index,row in enumerate(sorted(comparisons.values(),key=lambda item:item["p_raw"])):
69
+ maximum = max(maximum,row["p_raw"]*(len(comparisons)-index))
70
+ row["p_holm"] = min(1.,maximum)
71
+
72
+
73
  def _time_match(seed, records, clock="train_seconds"):
74
  """Look backward from the shortest complete training run to actual validation evaluations."""
75
  runs = {method: records[seed, method] for method in _METHODS}
 
185
  comparisons = {baseline: _comparison(records, baseline) for baseline in ("ce", "trace")}
186
  # Holm step-down: adjusted p-values are monotone in raw-p rank; ties receive equal values.
187
  # https://stat.ethz.ch/R-manual/R-devel/library/stats/html/p.adjust.html
188
+ holm(comparisons)
189
+ for stats in comparisons.values():
 
 
190
  if stats["p_holm"] <= 0.05:
191
  stats["interpretation"] = "improved"
192
  elif stats["median_ci"][0] > 0:
research/src/thirdloss/cli.py CHANGED
@@ -36,14 +36,16 @@ def parser():
36
  p = argparse.ArgumentParser(description=__doc__)
37
  p.add_argument("--project",type=Path,default=Path.cwd())
38
  parsers = p.add_subparsers(dest="action",required=True)
39
- for action in ("prepare","train","study","freeze","evaluate","report","dashboard","publish","audit-hub","progress","verify"):
40
  sub = parsers.add_parser(action)
41
  if action in {"prepare","study"}:
42
  sub.add_argument("--stage",choices=(*HORIZONS,"both"),default="both")
43
  if action in {"train","freeze"}:
44
  sub.add_argument("--stage",choices=HORIZONS,required=True)
45
- if action in {"train","study","evaluate"}:
46
  sub.add_argument("--device",default="cuda")
 
 
47
  if action=="verify":
48
  sub.add_argument("--pretrained",action="store_true",help="Also compare a full joint derivative on the prepared adapter training corpus")
49
  sub.add_argument("--reference",action="store_true",help="Compute the FP64 pretrained reference using the original CUDA signs")
@@ -55,7 +57,7 @@ def parser():
55
  sub.add_argument("--seed",type=int,default=0)
56
  sub.add_argument("--ratio",type=float,default=0.03)
57
  sub.add_argument("--microbatch",type=int)
58
- if action in {"train","study","evaluate"}:
59
  sub.add_argument("--publish",action="store_true",help="Publish results to the configured project accounts")
60
  if action=="evaluate":
61
  sub.add_argument("run_id")
@@ -120,11 +122,15 @@ def main(argv=None):
120
  return
121
  from .records import setup_device
122
  device = setup_device(args.device)
123
- if args.action=="study":
124
  from contextlib import nullcontext
125
  from .live_hub import publish_live
126
  with publish_live(project,storage) if args.publish else nullcontext():
127
- run_study(project,storage,stages,device,args.publish)
 
 
 
 
128
  return
129
  if args.action=="evaluate":
130
  summary = evaluate_one(project,storage,args.run_id,device)
 
36
  p = argparse.ArgumentParser(description=__doc__)
37
  p.add_argument("--project",type=Path,default=Path.cwd())
38
  parsers = p.add_subparsers(dest="action",required=True)
39
+ for action in ("prepare","train","study","hybrid","freeze","evaluate","report","dashboard","publish","audit-hub","progress","verify"):
40
  sub = parsers.add_parser(action)
41
  if action in {"prepare","study"}:
42
  sub.add_argument("--stage",choices=(*HORIZONS,"both"),default="both")
43
  if action in {"train","freeze"}:
44
  sub.add_argument("--stage",choices=HORIZONS,required=True)
45
+ if action in {"train","study","hybrid","evaluate"}:
46
  sub.add_argument("--device",default="cuda")
47
+ if action=="study":
48
+ sub.add_argument("--with-hybrid",action="store_true",help="Include the registered TinyStories hybrid follow-up on the same GPU")
49
  if action=="verify":
50
  sub.add_argument("--pretrained",action="store_true",help="Also compare a full joint derivative on the prepared adapter training corpus")
51
  sub.add_argument("--reference",action="store_true",help="Compute the FP64 pretrained reference using the original CUDA signs")
 
57
  sub.add_argument("--seed",type=int,default=0)
58
  sub.add_argument("--ratio",type=float,default=0.03)
59
  sub.add_argument("--microbatch",type=int)
60
+ if action in {"train","study","hybrid","evaluate"}:
61
  sub.add_argument("--publish",action="store_true",help="Publish results to the configured project accounts")
62
  if action=="evaluate":
63
  sub.add_argument("run_id")
 
122
  return
123
  from .records import setup_device
124
  device = setup_device(args.device)
125
+ if args.action in {"study","hybrid"}:
126
  from contextlib import nullcontext
127
  from .live_hub import publish_live
128
  with publish_live(project,storage) if args.publish else nullcontext():
129
+ if args.action=="hybrid":
130
+ from .hybrid import run_hybrids
131
+ run_hybrids(project,storage,device,args.publish)
132
+ else:
133
+ run_study(project,storage,stages,device,args.publish,with_hybrid=args.with_hybrid)
134
  return
135
  if args.action=="evaluate":
136
  summary = evaluate_one(project,storage,args.run_id,device)
research/src/thirdloss/hybrid.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Registered TinyStories trace/T3 schedules, common optimizer trunks and train-only probes."""
2
+
3
+ import bisect
4
+ import math
5
+ import statistics
6
+ import time
7
+
8
+ from .models import build_model, logits_of, token_loss, trainable_digest
9
+ from .objectives import probe_gradient, vector_norm
10
+ from .penalties import hessian_vector, inner, random_signs
11
+ from .records import BATCHES, CONTEXT, HORIZONS, read_json, run_name, sha256, write_json
12
+ from .width import measure_width
13
+ from .windows import TrainingWindows, generator, probe_rows
14
+
15
+
16
+ SEEDS = range(21,29)
17
+ SWITCH, RAMP_END, END = 2048, 3072, 4096
18
+ STREAMS = {"trace":827,"third":919}
19
+
20
+
21
+ def donor_seed(seed):
22
+ """Permute adaptive schedules cyclically across all eight independent receivers."""
23
+ return 21 + (seed - 22) % len(SEEDS)
24
+
25
+
26
+ class HybridSchedule:
27
+ """Determine each detached coefficient from the already completed observations."""
28
+
29
+ def __init__(self, arm, alpha, cap, delta=0., replay=()):
30
+ self.arm, self.alpha, self.cap, self.delta = arm,alpha,cap,delta
31
+ self.replay = list(replay)
32
+ self.replay_steps = [row[0] for row in self.replay]
33
+ self.q, self.nll, self.changes = [],[],[]
34
+ self.reference, self.eligible, self.weight, self.at_zero = None,False,0.,0
35
+
36
+ def state(self):
37
+ """Store Python scalars/lists so the ordinary weights-only checkpoint can contain them."""
38
+ return {key:getattr(self,key) for key in ("q","nll","changes","reference","eligible","weight","at_zero")}
39
+
40
+ def load(self, state):
41
+ for key in self.state():
42
+ setattr(self,key,state[key])
43
+
44
+ def observe(self, q, loss):
45
+ if not (math.isfinite(q) and q>=0 and math.isfinite(loss)):
46
+ raise FloatingPointError("Nonfinite hybrid curvature or training loss")
47
+ self.q = (self.q+[q])[-8:]
48
+ self.nll = (self.nll+[loss])[-8:]
49
+
50
+ def rms(self):
51
+ return math.sqrt(statistics.mean(self.q)) if self.q else None
52
+
53
+ def fix_reference(self):
54
+ if len(self.q)!=8 or not self.rms():
55
+ raise ValueError("The branch reference requires eight measurements and positive RMS curvature")
56
+ self.reference = self.rms()
57
+
58
+ def coefficients(self, step):
59
+ """Step is the number of completed updates. No current/future loss enters its rule."""
60
+ ramp = min(1.,max(0.,(step-SWITCH)/(RAMP_END-SWITCH)))
61
+ trace = self.alpha
62
+ weight = 0.
63
+ if self.arm=="always":
64
+ weight = self.cap
65
+ elif self.arm=="late":
66
+ weight = self.cap*ramp
67
+ elif self.arm=="strong":
68
+ trace += self.delta*ramp
69
+ elif self.arm=="adaptive" and step>=SWITCH:
70
+ if self.reference is None:
71
+ raise ValueError("Adaptive suffix is missing its pre-branch curvature reference")
72
+ self.eligible |= len(self.q)==8 and statistics.mean(self.nll)<=4.
73
+ if self.eligible:
74
+ weight = max(self.weight,self.cap*max(0.,1.-self.rms()/self.reference))
75
+ elif self.arm=="replay":
76
+ ix = bisect.bisect_right(self.replay_steps,step)-1
77
+ weight = self.replay[ix][1] if ix>=0 else 0.
78
+ if weight!=self.weight or not self.changes:
79
+ self.changes.append([step,weight])
80
+ self.weight = weight
81
+ self.at_zero += int(weight==0.)
82
+ return {"trace":trace,"third":weight}
83
+
84
+
85
+ class HybridProtocol:
86
+ """Couple a schedule to its checkpoints, independently addressed curvature and width probes."""
87
+
88
+ def __init__(self, project, storage, config, replay):
89
+ self.output = project/"results"/config["id"]
90
+ self.train_file = storage/"data"/"stories"/"train.bin"
91
+ self.schedule = HybridSchedule(config["method"],config["alpha"],config["cap"],config.get("delta",0.),replay)
92
+ self.parent = storage/"checkpoints"/config["parent"]/"latest.pt" if "parent" in config else None
93
+ self.parent_output = project/"results"/config["parent"] if self.parent else None
94
+ self.seed = config["seed"]
95
+
96
+ def monitor(self, model, parameters, inputs, targets, step, training_loss):
97
+ """Estimate ||H||²_F/d on the same pair of windows with a separate random direction."""
98
+ if (step+1)%16:
99
+ return {}
100
+ rows = probe_rows(self.seed,step,len(inputs))
101
+ loss = token_loss(logits_of(model,inputs[rows]),targets[rows])
102
+ signs = random_signs(parameters,generator(inputs.device,self.seed,step,937))
103
+ hz = hessian_vector(loss,parameters,signs,create_graph=False)
104
+ q = float(inner(hz,hz))/sum(p.numel() for p in parameters)
105
+ self.schedule.observe(q,float(training_loss))
106
+ if step+1==SWITCH:
107
+ self.schedule.fix_reference()
108
+ return {"curvature_q":q,"curvature_rms":self.schedule.rms(),
109
+ "monitor_mean_nll":statistics.mean(self.schedule.nll),"reference_rms":self.schedule.reference}
110
+
111
+ def checkpoint_width(self, model, step):
112
+ """Write every ray and detect stale results when resuming around a width checkpoint."""
113
+ if step not in (SWITCH,RAMP_END,END):
114
+ return
115
+ path = self.output/f"width-{step}.json"
116
+ origin = self.parent_output/f"width-{step}.json" if self.parent and step==SWITCH else path
117
+ if origin.exists():
118
+ record = read_json(origin)
119
+ if record["weights_sha256"]!=trainable_digest(model):
120
+ raise ValueError("Stored width was taken on different weights")
121
+ if origin!=path:
122
+ write_json(path,record)
123
+ return
124
+ if origin!=path:
125
+ raise FileNotFoundError("The parent trunk must complete its width measurement")
126
+ device = next(model.parameters()).device
127
+ inputs,targets = TrainingWindows(self.train_file,88731,8).get(0,device)
128
+ stats = measure_width(model,lambda: token_loss(logits_of(model,inputs),targets))
129
+ write_json(path,{"step":step,"tokens":step*CONTEXT*BATCHES["stories"],**stats})
130
+ print(f"Width after {step} updates: {stats['width']}, {stats['censored_rays']} censored rays",flush=True)
131
+
132
+ def finish(self, steps):
133
+ schedule = self.schedule
134
+ write_json(self.output/"schedule.json",{"changes":schedule.changes,"zero_steps":schedule.at_zero,
135
+ "steps":steps,"reference_rms":schedule.reference,"eligible":schedule.eligible,
136
+ "final_third_lambda":schedule.weight,"steps_at_cap":
137
+ sum((following[0]-current[0]) for current,following in
138
+ zip(schedule.changes,schedule.changes[1:]+[[steps,None]]) if current[1]==schedule.cap)})
139
+
140
+
141
+ def match_stronger_trace(project,storage,trunk,cap,device):
142
+ """Match the median per-draw unscaled gradient magnitude at the common checkpoint."""
143
+ from safetensors.torch import load_file
144
+ from .study import weights_file
145
+ seed = trunk["seed"]
146
+ path = project/"results"/"hybrid"/"calibration"/f"seed-{seed}.json"
147
+ if path.exists():
148
+ existing = read_json(path)
149
+ if existing["parent_weights_sha256"]!=trunk["weights_sha256"] or existing["cap"]!=cap:
150
+ raise ValueError("Stronger-trace calibration used different weights or cap")
151
+ return existing["delta"]
152
+ started = time.perf_counter()
153
+ model = build_model("stories",seed,device,storage)
154
+ model.load_state_dict(load_file(str(weights_file(storage,trunk))),strict=True)
155
+ params = tuple(model.parameters())
156
+ windows = TrainingWindows(storage/"data"/"stories"/"train.bin",188701+seed,BATCHES["stories"])
157
+ draws = []
158
+ for step in range(16):
159
+ x,y = windows.get(step,device)
160
+ norms = {}
161
+ for kind in ("trace","third"):
162
+ _,gradient = probe_gradient(model,params,x,y,kind,188701+seed,step,stream=STREAMS[kind])
163
+ norms[kind] = float(vector_norm(gradient))
164
+ del gradient
165
+ if any(not (0<n<float("inf")) for n in norms.values()):
166
+ raise FloatingPointError("Nonpositive or nonfinite branch calibration norm")
167
+ draws.append({"draw":step,**norms,"ratio":norms["third"]/norms["trace"]})
168
+ delta = cap*statistics.median(r["ratio"] for r in draws)
169
+ write_json(path,{"parent_weights_sha256":trunk["weights_sha256"],"seed":seed,"cap":cap,
170
+ "draws":draws,"delta":delta,"calibration_seconds":time.perf_counter()-started})
171
+ return delta
172
+
173
+
174
+ def run_hybrids(project,storage,device,publish):
175
+ """Run each trunk once; delay seed 21 replay until seed 28 has published its schedule."""
176
+ from .study import milestone
177
+ from .train import run_config
178
+ selected = read_json(project/"results"/"selection"/"stories.json")["ratios"]
179
+ if any(selected[k]!=.01 for k in STREAMS):
180
+ raise ValueError("Hybrid protocol requires the registered TinyStories 1% selection")
181
+ weights = {k:selected[k]*read_json(project/"results"/"calibration"/f"stories-{k}.json")["unit_lambda"]
182
+ for k in STREAMS}
183
+ def run(seed,arm):
184
+ phase = "branch" if arm=="trunk" else "hybrid"
185
+ name = lambda s,m,p: run_name("stories",m,p,s,.01)
186
+ config = {"stage":"stories","phase":phase,"id":name(seed,arm,phase),"method":arm,"seed":seed,
187
+ "ratio":.01,"token_budget":HORIZONS["stories"]//2 if arm=="trunk" else HORIZONS["stories"],
188
+ "batch_windows":BATCHES["stories"],"context":CONTEXT,"schedule_steps":END,
189
+ "protocol":"hybrid-v1","alpha":weights["trace"],"cap":weights["third"]}
190
+ replay = []
191
+ if arm not in {"trunk","always"}:
192
+ parent = name(seed,"trunk","branch")
193
+ trunk = read_json(project/"results"/parent/"summary.json")
194
+ if trunk["steps"]!=SWITCH or trunk["seed"]!=seed:
195
+ raise ValueError("Incomplete or unmatched branching checkpoint")
196
+ config.update(parent=parent,parent_weights_sha256=trunk["weights_sha256"],
197
+ inherited_tokens=trunk["tokens"],inherited_train_seconds=trunk["train_seconds"],
198
+ parent_restart_sha256=sha256(storage/"checkpoints"/parent/"latest.pt"))
199
+ if arm=="strong":
200
+ config["delta"] = match_stronger_trace(project,storage,trunk,config["cap"],device)
201
+ if arm=="replay":
202
+ donor = name(donor_seed(seed),"adaptive","hybrid")
203
+ path = project/"results"/donor/"schedule.json"
204
+ if read_json(project/"results"/donor/"summary.json")["steps"]!=END:
205
+ raise ValueError("The entire donor schedule must be available before replay")
206
+ config.update(donor=donor,donor_schedule_sha256=sha256(path))
207
+ replay = read_json(path)["changes"]
208
+ row = run_config(project,storage,config,device,protocol=HybridProtocol(project,storage,config,replay))
209
+ milestone(project,storage,row,publish)
210
+ for seed in SEEDS:
211
+ for arm in ("trunk","adaptive","late","trace","strong","always"):
212
+ run(seed,arm)
213
+ if seed!=SEEDS.start:
214
+ run(seed,"replay")
215
+ run(SEEDS.start,"replay")
research/src/thirdloss/hybrid_results.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Summarize measured follow-up geometry independently of the two frozen test comparisons."""
2
+
3
+ import math
4
+
5
+ from .analysis import holm, paired_sign
6
+
7
+
8
+ def hybrid_results(runs):
9
+ """Keep every arm, all horizon-matched pairs and right-censored outcomes in the record."""
10
+ named = {(r["seed"],r["method"]):r for r in runs if r.get("phase")=="hybrid" and r.get("finished_at")}
11
+ trunks = {r["seed"]:r for r in runs if r.get("phase")=="branch" and r.get("finished_at")}
12
+ comparisons,pairs = {},[]
13
+ for baseline in ("late","replay","trace","strong","always"):
14
+ finite_pairs = []
15
+ for seed in range(21,29):
16
+ adaptive,other = named.get((seed,"adaptive")),named.get((seed,baseline))
17
+ if not (adaptive and other):
18
+ continue
19
+ if adaptive["tokens"]!=other["tokens"] or adaptive["tokens"]!=2**24:
20
+ raise ValueError("Hybrid comparisons require full, equal token budgets")
21
+ if (adaptive["initial_trainable_sha256"]!=other["initial_trainable_sha256"] or
22
+ adaptive["data_manifest_sha256"]!=other["data_manifest_sha256"]):
23
+ raise ValueError("Hybrid comparisons require paired initialization and the same corpus")
24
+ values = [r["widths"][str(step)] for r in (adaptive,other) for step in (2048,4096)]
25
+ a0,a1,b0,b1 = values
26
+ if baseline!="always" and (adaptive["parent_restart_sha256"]!=other["parent_restart_sha256"]
27
+ or a0["weights_sha256"]!=b0["weights_sha256"]):
28
+ raise ValueError("Hybrid branches do not share the same AdamW checkpoint and width baseline")
29
+ delta = None if any(v["width"] is None for v in values) else (a1["width"]-a0["width"])-(b1["width"]-b0["width"])
30
+ row = {"seed":seed,"comparator":baseline,"delta":delta,
31
+ "train_probe_nll_delta":a1["baseline_nll"]-b1["baseline_nll"],
32
+ "comparable_fit":abs(a1["baseline_nll"]-b1["baseline_nll"])<=.02,
33
+ "dev_nll_delta":adaptive["dev_nll"]-other["dev_nll"]}
34
+ pairs.append(row)
35
+ if delta is not None and math.isfinite(delta):
36
+ finite_pairs.append(row)
37
+ if baseline in {"late","replay"} and len(finite_pairs)==8:
38
+ comparisons[baseline] = paired_sign(finite_pairs,larger=True)
39
+ if len(comparisons)==2:
40
+ holm(comparisons)
41
+ status = "both width comparisons passed" if all(c["p_holm"]<=.05 for c in comparisons.values()) else "width advantage inconclusive"
42
+ else:
43
+ status = "width endpoint censored" if len(named)==48 else "awaiting eight paired width measurements"
44
+ return {"completed_arms":len(named),"completed_trunks":len(trunks),"status":status,"pairs":pairs,
45
+ "comparisons":comparisons,"shared_training_tokens_saved":sum(
46
+ max(0,sum((s,m) in named for m in ("adaptive","late","trace","strong","replay"))-1)*r["tokens"]
47
+ for s,r in trunks.items())}
research/src/thirdloss/objectives.py CHANGED
@@ -71,9 +71,9 @@ def derivative_replica(stage,seed,storage):
71
  return widen_pythia(build_model(stage,seed,adapter_derivative_device(),storage))
72
 
73
 
74
- def probe_gradient(model, parameters, inputs, targets, kind, seed, step, replica=None):
75
  """Differentiate the sampled penalty, including the fourth-order contraction."""
76
- rng = generator(inputs.device, seed, step, 827)
77
  rows = probe_rows(seed, step, len(inputs))
78
  if replica is not None:
79
  # All arms draw the original CUDA signs. Only the arithmetic and storage of
@@ -158,14 +158,15 @@ def calibrate(project, storage, stage, kind, device, microbatch):
158
  return result
159
 
160
 
161
- def add_penalty(model, parameters, inputs, targets, coefficients, method, seed, step, replica=None):
162
  """Add the gated derivative contribution to already-accumulated CE gradients."""
163
  telemetry = {}
164
  for kind, weight in coefficients.items():
165
  if not weight:
166
  continue
167
  started = time.perf_counter()
168
- value, grads = probe_gradient(model, parameters, inputs, targets, kind, seed, step,replica)
 
169
  raw_norm = vector_norm(grads).item()
170
  if method == "sham":
171
  signs = random_signs(parameters, generator(inputs.device, seed, step, 839))
 
71
  return widen_pythia(build_model(stage,seed,adapter_derivative_device(),storage))
72
 
73
 
74
+ def probe_gradient(model, parameters, inputs, targets, kind, seed, step, replica=None, *, stream=827):
75
  """Differentiate the sampled penalty, including the fourth-order contraction."""
76
+ rng = generator(inputs.device, seed, step, stream)
77
  rows = probe_rows(seed, step, len(inputs))
78
  if replica is not None:
79
  # All arms draw the original CUDA signs. Only the arithmetic and storage of
 
158
  return result
159
 
160
 
161
+ def add_penalty(model, parameters, inputs, targets, coefficients, method, seed, step, replica=None, *, streams=None):
162
  """Add the gated derivative contribution to already-accumulated CE gradients."""
163
  telemetry = {}
164
  for kind, weight in coefficients.items():
165
  if not weight:
166
  continue
167
  started = time.perf_counter()
168
+ value, grads = probe_gradient(model, parameters, inputs, targets, kind, seed, step,replica,
169
+ stream=streams[kind] if streams else 827)
170
  raw_norm = vector_norm(grads).item()
171
  if method == "sham":
172
  signs = random_signs(parameters, generator(inputs.device, seed, step, 839))
research/src/thirdloss/penalties.py CHANGED
@@ -27,9 +27,9 @@ def inner(left, right):
27
  return torch.stack([(a * b).sum() for a, b in zip(left, right, strict=True)]).sum()
28
 
29
 
30
- def hessian_vector(loss, parameters, direction):
31
  """Apply the parameter Hessian through the gradient's directional contraction."""
32
- return partials(inner(partials(loss, parameters), direction), parameters)
33
 
34
 
35
  def third_contraction(loss, parameters, u, v, *, create_graph=True):
 
27
  return torch.stack([(a * b).sum() for a, b in zip(left, right, strict=True)]).sum()
28
 
29
 
30
+ def hessian_vector(loss, parameters, direction, *, create_graph=True):
31
  """Apply the parameter Hessian through the gradient's directional contraction."""
32
+ return partials(inner(partials(loss, parameters), direction), parameters, create_graph=create_graph)
33
 
34
 
35
  def third_contraction(loss, parameters, u, v, *, create_graph=True):
research/src/thirdloss/progress.py CHANGED
@@ -58,7 +58,7 @@ def week_schedule(project):
58
 
59
  def progress(project):
60
  study = study_snapshot(project)
61
- runs = [r for r in study["runs"] if r.get("phase") not in {"smoke","diagnostic"}]
62
  done = [r for r in runs if r["status"] in {"complete","evaluated"}]
63
  tests = [r for r in done if "test_nll" in r]
64
  # Each stage has seven development candidates, two free controls, three ablations,
@@ -91,6 +91,10 @@ def progress(project):
91
  f"scoring, with {schedule['hours_available_for_other_work']:.2f} hours of the week available for "
92
  "secondary pilots, setup, publication and interruptions. [Timing and GPU memory by method]"
93
  "(../results/feasibility/one-week.json)"]
 
 
 
 
94
  lines += ["## Monitoring","Inspect runs lasting over 10, 30 and 60 minutes at 5, 15 and 30 minute intervals "
95
  "respectively. The live dashboard refreshes between those checks. "
96
  "[Study design](plan.md) · [Run matrix](planned-runs.md) · [Experiment ledger](experiments/experiments.md)"]
 
58
 
59
  def progress(project):
60
  study = study_snapshot(project)
61
+ runs = [r for r in study["runs"] if r.get("phase") in {"control","pilot","confirm"}]
62
  done = [r for r in runs if r["status"] in {"complete","evaluated"}]
63
  tests = [r for r in done if "test_nll" in r]
64
  # Each stage has seven development candidates, two free controls, three ablations,
 
91
  f"scoring, with {schedule['hours_available_for_other_work']:.2f} hours of the week available for "
92
  "secondary pilots, setup, publication and interruptions. [Timing and GPU memory by method]"
93
  "(../results/feasibility/one-week.json)"]
94
+ followup = study["hybrid"]
95
+ lines += ["## TinyStories hybrid follow-up",f"{followup['completed_arms']} of 48 full runs and "
96
+ f"{followup['completed_trunks']} of 8 shared checkpoints complete. "
97
+ f"{followup['status']}. [Per-seed widths and development scores](hybrid/results.md)"]
98
  lines += ["## Monitoring","Inspect runs lasting over 10, 30 and 60 minutes at 5, 15 and 30 minute intervals "
99
  "respectively. The live dashboard refreshes between those checks. "
100
  "[Study design](plan.md) · [Run matrix](planned-runs.md) · [Experiment ledger](experiments/experiments.md)"]
research/src/thirdloss/release.py CHANGED
@@ -73,6 +73,10 @@ def publish_weights(project, storage, summary):
73
  f"Use the pinned base and loading instructions in [the guide]({GITHUB}/blob/main/docs/runbook.md).\n")
74
  if diagnostic:
75
  card += f"\n{diagnostic['reason']} [Numerical audit]({GITHUB}/blob/main/reports/amendments/adapter-precision.md)\n"
 
 
 
 
76
  card = "---\nlanguage: [en]\npipeline_tag: text-generation\n---\n" + card
77
  (folder/"README.md").write_text(card,encoding="utf-8")
78
  write_json(folder/"training_summary.json",summary)
 
73
  f"Use the pinned base and loading instructions in [the guide]({GITHUB}/blob/main/docs/runbook.md).\n")
74
  if diagnostic:
75
  card += f"\n{diagnostic['reason']} [Numerical audit]({GITHUB}/blob/main/reports/amendments/adapter-precision.md)\n"
76
+ if summary["phase"] in {"branch","hybrid"}:
77
+ card += (f"\nThis checkpoint belongs to the [TinyStories hybrid follow-up]({GITHUB}/blob/main/reports/hybrid/preregistration.md). "
78
+ f"The [per-seed geometry and development outcomes]({GITHUB}/blob/main/reports/hybrid/results.md) "
79
+ "link to full schedules, crossing brackets and the matched controls.\n")
80
  card = "---\nlanguage: [en]\npipeline_tag: text-generation\n---\n" + card
81
  (folder/"README.md").write_text(card,encoding="utf-8")
82
  write_json(folder/"training_summary.json",summary)
research/src/thirdloss/report_figures.py CHANGED
@@ -171,13 +171,39 @@ def _paired(study, path) -> bool:
171
  return True
172
 
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  def build_figures(study: dict, directory: Path) -> dict:
175
  """Always emit the method illustrations and add measured plots when observations exist."""
176
  directory.mkdir(parents=True, exist_ok=True)
177
  architecture(directory / "architecture.png")
178
  penalty_directions(directory / "penalty-directions.png")
179
  products = {"architecture": "architecture.png", "penalty_directions": "penalty-directions.png"}
180
- for key, draw in (("curves", _curves), ("paired", _paired)):
181
  file = directory / f"{key}.png"
182
  if draw(study, file):
183
  products[key] = file.name
 
171
  return True
172
 
173
 
174
+ def _hybrid_width(study,path):
175
+ """Plot observed, identifiable widths for each seed in its own panel on a shared scale."""
176
+ groups = {}
177
+ for r in study["runs"]:
178
+ points = [(p["tokens"]/1e6,p["width"]) for p in r.get("widths",{}).values() if finite(p["width"])]
179
+ if points:
180
+ groups.setdefault(r["seed"],[]).append((r["method"],sorted(points)))
181
+ if not groups:
182
+ return False
183
+ columns = min(2,len(groups))
184
+ rows = (len(groups)+columns-1)//columns
185
+ fig = Figure(figsize=(8,2.7*rows+0.6),layout="constrained")
186
+ axes = fig.subplots(rows,columns,sharey=True,squeeze=False).ravel()
187
+ for ax,(seed,records) in zip(axes,sorted(groups.items())):
188
+ for arm,points in records:
189
+ x,y = zip(*points)
190
+ ax.plot(x,y,marker="o",ms=3,color=COLORS[arm],label=METHODS[arm],alpha=.85)
191
+ ax.set_title(f"TinyStories · seed {seed}",loc="left",fontsize=10)
192
+ _axes_style(ax,"Training targets (millions)","Directional width")
193
+ ax.legend(frameon=False,fontsize=6,ncol=2)
194
+ for ax in axes[len(groups):]:
195
+ ax.set_visible(False)
196
+ _save(fig,path)
197
+ return True
198
+
199
+
200
  def build_figures(study: dict, directory: Path) -> dict:
201
  """Always emit the method illustrations and add measured plots when observations exist."""
202
  directory.mkdir(parents=True, exist_ok=True)
203
  architecture(directory / "architecture.png")
204
  penalty_directions(directory / "penalty-directions.png")
205
  products = {"architecture": "architecture.png", "penalty_directions": "penalty-directions.png"}
206
+ for key, draw in (("curves", _curves), ("paired", _paired), ("hybrid_width",_hybrid_width)):
207
  file = directory / f"{key}.png"
208
  if draw(study, file):
209
  products[key] = file.name
research/src/thirdloss/report_paper.py CHANGED
@@ -320,14 +320,25 @@ def write_paper(study: dict, output: Path, figure_dir: Path, figures: dict) -> N
320
  "two tokenization schemes bound the interpretation. More tokens per GPU hour can change "
321
  "the practical ranking. "
322
  f"{_cite('coordinates')} · {_link(REPOSITORY + '/blob/main/reports/preregistration.md', 'Scope of inference')}")
323
- p("Proposed curvature-dependent schedule", "subheading")
324
- p("A TinyStories follow-up would keep the trace active and increase the weight on squared third "
325
  "derivatives once training loss and measured curvature are low. Retaining the highest weight reached "
326
  "could oppose later drift if curvature changes faster at the edge. Direct division can reverse "
327
  "the incentive. For the quartic loss above, the squared ratio of third to second derivative "
328
  "is 4/w<super>2</super> away from zero and grows toward the flat bottom. The final appendix "
329
- "specifies both schedules and the proposed width test. "
330
- f"{_link(REPOSITORY + '/blob/main/reports/plan.md#curvature-dependent-penalty-weight', 'Follow-up design')}")
 
 
 
 
 
 
 
 
 
 
 
331
  p("Conclusion", "heading")
332
  if all(outcome.get("complete") for outcome in study["stages"].values()):
333
  confirmed = [STAGES[s] for s, outcome in study["stages"].items() if outcome.get("success")]
@@ -413,10 +424,9 @@ def write_paper(study: dict, output: Path, figure_dir: Path, figures: dict) -> N
413
  p(f"Rebuild tables, figures, the explorer and this paper with <b>uv run thirdloss report</b>. "
414
  f"{_link(REPOSITORY, 'Code and versioned protocol')}", "caption")
415
  flow.append(PageBreak())
416
- p("Appendix · Proposed TinyStories schedules", "heading")
417
  p("The follow-up asks whether changing the third-derivative coefficient in response to low curvature "
418
- "helps retain a wider low-loss neighborhood. The equations below specify candidate arms for a "
419
- "separate preregistration.")
420
  p("Shared training objective", "subheading")
421
  p("J<sub>t</sub> = L<sub>t</sub> + (I<sub>t</sub>/p) [α<sub>t</sub> h<sub>t</sub> + λ<sub>t</sub> P<sub>3,t</sub>]", "equation")
422
  p("h<sub>t</sub> = a<super>T</super>H<sub>t</sub>a, &nbsp;&nbsp; "
 
320
  "two tokenization schemes bound the interpretation. More tokens per GPU hour can change "
321
  "the practical ranking. "
322
  f"{_cite('coordinates')} · {_link(REPOSITORY + '/blob/main/reports/preregistration.md', 'Scope of inference')}")
323
+ p("Registered curvature-dependent schedule", "subheading")
324
+ p("The TinyStories follow-up keeps the trace active and increases the weight on squared third "
325
  "derivatives once training loss and measured curvature are low. Retaining the highest weight reached "
326
  "could oppose later drift if curvature changes faster at the edge. Direct division can reverse "
327
  "the incentive. For the quartic loss above, the squared ratio of third to second derivative "
328
  "is 4/w<super>2</super> away from zero and grows toward the flat bottom. The final appendix "
329
+ "specifies both schedules and the width test. "
330
+ f"{_link(REPOSITORY + '/blob/main/reports/hybrid/preregistration.md', 'Frozen follow-up design')}")
331
+ hybrid = study["hybrid"]
332
+ if "hybrid_width" in figures:
333
+ flow.append(_figure(figure_dir/figures["hybrid_width"],max_height=285))
334
+ p(f"{hybrid['completed_arms']} of 48 full hybrid arms and {hybrid['completed_trunks']} of 8 shared "
335
+ f"checkpoints have completed. Geometric endpoint: {hybrid['status']}. "
336
+ f"{_link(REPOSITORY + '/blob/main/reports/hybrid/results.md', 'All observed widths, development scores and fit differences')}")
337
+ for comparator,s in hybrid["comparisons"].items():
338
+ lo,hi = s["median_ci"]
339
+ p(f"Adaptive minus {METHODS[comparator]} median width gain {fmt(s['median_delta'],5)} "
340
+ f"[{fmt(lo,5)}, {fmt(hi,5)}]; one-sided sign p = {fmt(s['p_raw'],5)}, Holm p = {fmt(s.get('p_holm'),5)}. "
341
+ "Cross-seed replay shares schedule information across pairs, limiting the independent-sign approximation.","caption")
342
  p("Conclusion", "heading")
343
  if all(outcome.get("complete") for outcome in study["stages"].values()):
344
  confirmed = [STAGES[s] for s, outcome in study["stages"].items() if outcome.get("success")]
 
424
  p(f"Rebuild tables, figures, the explorer and this paper with <b>uv run thirdloss report</b>. "
425
  f"{_link(REPOSITORY, 'Code and versioned protocol')}", "caption")
426
  flow.append(PageBreak())
427
+ p("Appendix · Registered TinyStories schedules", "heading")
428
  p("The follow-up asks whether changing the third-derivative coefficient in response to low curvature "
429
+ "helps retain a wider low-loss neighborhood. Eight paired seeds compare six arms at equal training tokens.")
 
430
  p("Shared training objective", "subheading")
431
  p("J<sub>t</sub> = L<sub>t</sub> + (I<sub>t</sub>/p) [α<sub>t</sub> h<sub>t</sub> + λ<sub>t</sub> P<sub>3,t</sub>]", "equation")
432
  p("h<sub>t</sub> = a<super>T</super>H<sub>t</sub>a, &nbsp;&nbsp; "
research/src/thirdloss/report_records.py CHANGED
@@ -9,6 +9,7 @@ from pathlib import Path
9
  from tempfile import NamedTemporaryFile
10
 
11
  from .analysis import analyze_stage
 
12
  from .records import GITHUB as REPOSITORY, PAGES
13
 
14
 
@@ -22,11 +23,14 @@ METHODS = {
22
  "combined": "Trace + third derivative",
23
  "initial": "Initial checkpoint",
24
  "unigram": "Unigram",
 
 
25
  }
26
  COLORS = {
27
  "ce": "#374d67", "trace": "#ac582a", "third": "#007166",
28
  "hessian_norm": "#64569c", "sham": "#ac3c66", "combined": "#3974a2",
29
  "initial": "#674e35", "unigram": "#73736c",
 
30
  }
31
  FIELDS = (
32
  "id", "stage", "method", "phase", "seed", "ratio", "tokens", "steps",
@@ -39,11 +43,14 @@ FIELDS = (
39
  "git_revision", "gpu", "torch", "matched_dev_nll", "finished_at", "initial_trainable_sha256",
40
  "derivative_dtype", "derivative_device", "host_probe_seconds", "training_seconds_excluding_host_probes", "cpu_threads",
41
  "process_peak_rss_mib", "evaluation_batch_windows", "test_seconds", "evaluated_at",
 
 
42
  )
43
  EVENT_FIELDS = (
44
  "step", "tokens", "train_seconds", "loss", "accuracy", "penalty", "dev_nll",
45
  "dev_accuracy", "timestamp", "status", "peak_vram_mb",
46
  "training_seconds_excluding_host_probes", "host_probe_seconds",
 
47
  )
48
 
49
 
@@ -152,6 +159,15 @@ def run_record(folder: Path) -> dict:
152
  if isinstance(details, dict) and finite(details.get("estimate")):
153
  row["raw_" + kind] = details["estimate"]
154
  record["events"].append(row)
 
 
 
 
 
 
 
 
 
155
  record["samples"] = read_lines(folder / "samples.jsonl")
156
  return record
157
 
@@ -161,7 +177,7 @@ def display_events(events: list[dict], maximum: int = 240) -> list[dict]:
161
  if len(events) <= maximum:
162
  return events
163
  keep = {round(i * (len(events) - 1) / (maximum - 1)) for i in range(maximum)}
164
- keep.update(i for i, event in enumerate(events) if finite(event.get("dev_nll")))
165
  return [events[i] for i in sorted(keep)]
166
 
167
 
@@ -207,6 +223,7 @@ def study_snapshot(root: Path = Path(".")) -> dict:
207
  "generated_at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
208
  "runs": runs, "stages": stages, "method_names": METHODS, "stage_names": STAGES,
209
  "colors": COLORS, "context": context, "pilot_comparisons": pilots,"numerics":numerics,
 
210
  }
211
 
212
 
@@ -218,7 +235,7 @@ def example_runs(runs):
218
  """Choose one completed registered checkpoint per method independently of sample text or scores."""
219
  examples = {}
220
  for run in sorted(runs,key=lambda r:r["id"]):
221
- if completed(run) and run["phase"] in {"confirm","pilot","control"} and run["samples"]:
222
  examples.setdefault((run["stage"],run["method"]),run)
223
  return list(examples.values())
224
 
 
9
  from tempfile import NamedTemporaryFile
10
 
11
  from .analysis import analyze_stage
12
+ from .hybrid_results import hybrid_results
13
  from .records import GITHUB as REPOSITORY, PAGES
14
 
15
 
 
23
  "combined": "Trace + third derivative",
24
  "initial": "Initial checkpoint",
25
  "unigram": "Unigram",
26
+ "trunk":"Shared trace checkpoint","adaptive":"Curvature-dependent hybrid","late":"Fixed late hybrid",
27
+ "replay":"Cross-seed replay","strong":"Stronger trace","always":"Always-on hybrid",
28
  }
29
  COLORS = {
30
  "ce": "#374d67", "trace": "#ac582a", "third": "#007166",
31
  "hessian_norm": "#64569c", "sham": "#ac3c66", "combined": "#3974a2",
32
  "initial": "#674e35", "unigram": "#73736c",
33
+ "trunk":"#705d43","adaptive":"#007361","late":"#405fa6","replay":"#9b486c","strong":"#a66f0c","always":"#594489",
34
  }
35
  FIELDS = (
36
  "id", "stage", "method", "phase", "seed", "ratio", "tokens", "steps",
 
43
  "git_revision", "gpu", "torch", "matched_dev_nll", "finished_at", "initial_trainable_sha256",
44
  "derivative_dtype", "derivative_device", "host_probe_seconds", "training_seconds_excluding_host_probes", "cpu_threads",
45
  "process_peak_rss_mib", "evaluation_batch_windows", "test_seconds", "evaluated_at",
46
+ "parent","parent_restart_sha256","donor","alpha","cap","delta","reference_rms","zero_steps","final_third_lambda",
47
+ "inherited_tokens","inherited_train_seconds",
48
  )
49
  EVENT_FIELDS = (
50
  "step", "tokens", "train_seconds", "loss", "accuracy", "penalty", "dev_nll",
51
  "dev_accuracy", "timestamp", "status", "peak_vram_mb",
52
  "training_seconds_excluding_host_probes", "host_probe_seconds",
53
+ "curvature_q","curvature_rms","trace_lambda","third_lambda","reference_rms","monitor_mean_nll","gradient_norm",
54
  )
55
 
56
 
 
159
  if isinstance(details, dict) and finite(details.get("estimate")):
160
  row["raw_" + kind] = details["estimate"]
161
  record["events"].append(row)
162
+ if record.get("phase") in {"hybrid","branch"}:
163
+ record["widths"] = {}
164
+ for path in sorted(folder.glob("width-*.json")):
165
+ width = read_json(path)
166
+ point = {k:v for k,v in width.items() if k!="directions"}
167
+ record["widths"][str(width["step"])] = point
168
+ record["events"].append({"step":width["step"],"tokens":width["tokens"],
169
+ "width":width["width"],"width_probe_nll":width["baseline_nll"]})
170
+ record["events"].sort(key=lambda row:row.get("step",0))
171
  record["samples"] = read_lines(folder / "samples.jsonl")
172
  return record
173
 
 
177
  if len(events) <= maximum:
178
  return events
179
  keep = {round(i * (len(events) - 1) / (maximum - 1)) for i in range(maximum)}
180
+ keep.update(i for i, event in enumerate(events) if finite(event.get("dev_nll")) or "width" in event)
181
  return [events[i] for i in sorted(keep)]
182
 
183
 
 
223
  "generated_at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
224
  "runs": runs, "stages": stages, "method_names": METHODS, "stage_names": STAGES,
225
  "colors": COLORS, "context": context, "pilot_comparisons": pilots,"numerics":numerics,
226
+ "hybrid":hybrid_results(runs),
227
  }
228
 
229
 
 
235
  """Choose one completed registered checkpoint per method independently of sample text or scores."""
236
  examples = {}
237
  for run in sorted(runs,key=lambda r:r["id"]):
238
+ if completed(run) and run["phase"] in {"confirm","pilot","control","hybrid"} and run["samples"]:
239
  examples.setdefault((run["stage"],run["method"]),run)
240
  return list(examples.values())
241
 
research/src/thirdloss/reporting.py CHANGED
@@ -219,10 +219,67 @@ def _update_readme(root: Path, body: str) -> None:
219
  atomic_text(path, re.sub(pattern, lambda _: replacement, before, flags=re.DOTALL))
220
 
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  def build_report(root: Path = Path(".")) -> dict:
223
  """Regenerate README results, PDF, experiment ledger, figures and the static dashboard."""
224
  root = Path(root).resolve()
225
  study = study_snapshot(root)
 
226
  figures = build_figures(study, root / "docs" / "figures")
227
  study["figures"] = figures
228
  static = json.dumps(study, ensure_ascii=False, allow_nan=False, separators=(",", ":"))
@@ -235,7 +292,7 @@ def build_report(root: Path = Path(".")) -> dict:
235
  overview = f"Recorded {counts} runs, including {done} with a completed summary."
236
  documents = [f"[Interactive explorer]({PAGES})", "[Per-run ledger](experiments/experiments.md)",
237
  "[Preregistration](preregistration.md)", "[Paper](paper.pdf)"]
238
- summary = ["# Study summary", overview, _stage_summary(study), " · ".join(documents)]
239
  pilots = _pilot_summary(study)
240
  if pilots:
241
  summary.extend(["## Development observations", pilots])
@@ -251,7 +308,9 @@ def build_report(root: Path = Path(".")) -> dict:
251
  badge = (f"[Explore the results]({PAGES}) · [Hugging Face explorer](https://huggingface.co/spaces/BurnyCoder/thirdloss-explorer) · "
252
  "[Hugging Face collection](https://huggingface.co/collections/BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378) · "
253
  "[Paper](reports/paper.pdf) · [Run ledger](reports/experiments/experiments.md)")
254
- readme = [badge, overview, _stage_summary(study)]
 
 
255
  if pilots:
256
  readme.append(pilots)
257
  if compact:
 
219
  atomic_text(path, re.sub(pattern, lambda _: replacement, before, flags=re.DOTALL))
220
 
221
 
222
+ def _hybrid_report(root,study):
223
+ """Report each observed width, censoring, matched fit and preregistered sign comparison."""
224
+ data = study["hybrid"]
225
+ headline = (f"TinyStories hybrid follow-up: {data['completed_arms']} of 48 full runs and "
226
+ f"{data['completed_trunks']} of 8 shared checkpoints complete. "
227
+ f"Geometric decision: {data['status']}.")
228
+ material = ["# Hybrid schedules on TinyStories",headline,
229
+ "[Frozen protocol and decision rule](preregistration.md) · "
230
+ "[Interactive measurement and run selector](../../docs/index.html#curves)",
231
+ "Two-sided directional width is measured in the original Euclidean weight coordinates at a "
232
+ "fixed increase of 0.1 nats per target. Each linked JSON contains all 32 rays and their brackets. "
233
+ "A missing upper bound means that the search reached its maximum radius before crossing."]
234
+ widths = []
235
+ for r in study["runs"]:
236
+ for w in r.get("widths",{}).values():
237
+ path = f"../../results/{r['id']}/width-{w['step']}.json"
238
+ widths.append([r["seed"],_method(r),f"[{w['step']}]({path})",fmt(w["width"],5),
239
+ fmt(w["width_lower"],5),fmt(w["width_upper"],5),w["censored_rays"],
240
+ fmt(w["baseline_nll"],5),fmt(w["seconds"],2)])
241
+ if widths:
242
+ material += ["## Width observations",_table(widths,["Seed","Arm","Step","Width","Lower","Upper",
243
+ "Censored rays","Training probe NLL","Probe seconds"])]
244
+ if any(finite(w["width"]) for r in study["runs"] for w in r.get("widths",{}).values()):
245
+ material.append("![Median directional width by seed and training arm](../../docs/figures/hybrid_width.png)")
246
+ arms = []
247
+ for r in study["runs"]:
248
+ if r.get("phase") not in {"hybrid","branch"} or not completed(r):
249
+ continue
250
+ url = f"../../results/{r['id']}/schedule.json"
251
+ arms.append([r["seed"],_method(r),fmt(r["dev_nll"],6),fmt(r["dev_accuracy"],5),fmt(r["reference_rms"],5),
252
+ f"[{r['zero_steps']}]({url})",f"{r['final_third_lambda']:.6g}",fmt(r["tokens_per_sec"],0),
253
+ fmt(r["peak_vram_mb"],1),fmt(r["process_peak_rss_mib"],1)])
254
+ if arms:
255
+ material += ["## Full development and resource measurements",_table(arms,["Seed","Arm","Dev NLL","Accuracy",
256
+ "Reference RMS","Steps at zero λ₃","Final λ₃","Targets/s","Allocated GPU MiB","Process peak MiB"])]
257
+ if data["pairs"]:
258
+ material += ["## Adaptive minus comparator per seed","Positive Δwidth favors the adaptive schedule. "
259
+ "Negative ΔNLL favors its prediction. Comparable fit uses the frozen 0.02-nat training threshold.",
260
+ _table([[p["seed"],METHODS[p["comparator"]],fmt(p["delta"],6),fmt(p["dev_nll_delta"],6),
261
+ fmt(p["train_probe_nll_delta"],6),"yes" if p["comparable_fit"] else "no"]
262
+ for p in data["pairs"]],["Seed","Comparator","Δwidth gain","Δdev NLL","Δtrain NLL","Comparable fit"])]
263
+ for comparator,s in data["comparisons"].items():
264
+ lo,hi = s["median_ci"]
265
+ material.append(f"Against {METHODS[comparator]}, the median paired width difference is {fmt(s['median_delta'],6)}, "
266
+ f"interval [{fmt(lo,6)}, {fmt(hi,6)}], coverage {fmt(s['ci_coverage'],4)}. "
267
+ f"Wins/ties/losses: {s['wins']}/{s['ties']}/{s['losses']}. "
268
+ f"One-sided sign p = {fmt(s['p_raw'],5)}, Holm p = {fmt(s.get('p_holm'),5)}.")
269
+ material += [f"The completed branches reused {data['shared_training_tokens_saved']:,} targets of optimization "
270
+ "compared with independently training each branch from initialization. The replay permutation "
271
+ "couples different seeds through their coefficient histories. The sign-test reference for this "
272
+ "comparison assumes exchangeable independent pair signs; that assumption is approximate here. "
273
+ "All raw pairs are reported for inspection."]
274
+ atomic_text(root/"reports"/"hybrid"/"results.md","\n\n".join(material)+"\n")
275
+ return headline
276
+
277
+
278
  def build_report(root: Path = Path(".")) -> dict:
279
  """Regenerate README results, PDF, experiment ledger, figures and the static dashboard."""
280
  root = Path(root).resolve()
281
  study = study_snapshot(root)
282
+ hybrid = _hybrid_report(root,study)
283
  figures = build_figures(study, root / "docs" / "figures")
284
  study["figures"] = figures
285
  static = json.dumps(study, ensure_ascii=False, allow_nan=False, separators=(",", ":"))
 
292
  overview = f"Recorded {counts} runs, including {done} with a completed summary."
293
  documents = [f"[Interactive explorer]({PAGES})", "[Per-run ledger](experiments/experiments.md)",
294
  "[Preregistration](preregistration.md)", "[Paper](paper.pdf)"]
295
+ summary = ["# Study summary", overview, _stage_summary(study), hybrid+" [Hybrid outcomes](hybrid/results.md)", " · ".join(documents)]
296
  pilots = _pilot_summary(study)
297
  if pilots:
298
  summary.extend(["## Development observations", pilots])
 
308
  badge = (f"[Explore the results]({PAGES}) · [Hugging Face explorer](https://huggingface.co/spaces/BurnyCoder/thirdloss-explorer) · "
309
  "[Hugging Face collection](https://huggingface.co/collections/BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378) · "
310
  "[Paper](reports/paper.pdf) · [Run ledger](reports/experiments/experiments.md)")
311
+ readme = [badge, overview, _stage_summary(study),hybrid+" [Width measurements, scores and controls](reports/hybrid/results.md)"]
312
+ if "hybrid_width" in figures:
313
+ readme.append("![Directional width by TinyStories arm and seed](docs/figures/hybrid_width.png)")
314
  if pilots:
315
  readme.append(pilots)
316
  if compact:
research/src/thirdloss/study.py CHANGED
@@ -165,7 +165,7 @@ def feasibility(project, stage):
165
  return result
166
 
167
 
168
- def run_study(project,storage,stages,device,publish):
169
  """Retry-safe complete study. Cached milestones allow continuation after reboot or network loss."""
170
  def run(stage,method,phase,seed,ratio):
171
  row = run_one(project,storage,stage,method,phase,seed,ratio,device)
@@ -187,6 +187,9 @@ def run_study(project,storage,stages,device,publish):
187
  feasibility(project,stage)
188
  for method,ratio in (("hessian_norm",0.03),("sham",selected["third"]),("combined",selected["third"])):
189
  run(stage,method,"pilot",0,ratio)
 
 
 
190
  for stage in stages:
191
  selected = select(project,stage)
192
  for seed in range(1,9):
 
165
  return result
166
 
167
 
168
+ def run_study(project,storage,stages,device,publish,with_hybrid=False):
169
  """Retry-safe complete study. Cached milestones allow continuation after reboot or network loss."""
170
  def run(stage,method,phase,seed,ratio):
171
  row = run_one(project,storage,stage,method,phase,seed,ratio,device)
 
187
  feasibility(project,stage)
188
  for method,ratio in (("hessian_norm",0.03),("sham",selected["third"]),("combined",selected["third"])):
189
  run(stage,method,"pilot",0,ratio)
190
+ if with_hybrid and stage=="stories":
191
+ from .hybrid import run_hybrids
192
+ run_hybrids(project,storage,device,publish)
193
  for stage in stages:
194
  selected = select(project,stage)
195
  for seed in range(1,9):
research/src/thirdloss/train.py CHANGED
@@ -68,29 +68,40 @@ def chosen_coefficients(project, storage, config, device, microbatch):
68
  return {kind: scale*calibrate(project,storage,stage,kind,device,microbatch) for kind,scale in kinds.items()}
69
 
70
 
71
- def save_state(path, model, optimizer, step, elapsed, config):
72
  """Atomically persist optimizer, trainable weights, all stochastic state and next data step."""
73
  state = {"weights":{n:p.detach() for n,p in model.named_parameters() if p.requires_grad},
74
  "optimizer":optimizer.state_dict(), "next_step":step, "train_seconds":elapsed,
75
  "config":config, "cpu_rng":torch.get_rng_state(),
76
  "cuda_rng":torch.cuda.get_rng_state() if next(model.parameters()).is_cuda else None}
 
 
77
  temp = path.with_suffix(".partial")
78
  torch.save(state, temp)
79
  os.replace(temp,path)
80
 
81
 
82
- def restore_state(path, model, optimizer, config, recorder, device):
83
  """Recover the last committed checkpoint and ignore telemetry from interrupted later steps."""
84
  if not path.exists():
85
  return 0, 0.0
86
  state = torch.load(path, map_location="cpu", weights_only=True)
87
- if state["config"] != config:
 
 
 
 
 
 
 
88
  raise ValueError("Resume configuration differs from saved scientific settings")
89
  model.load_state_dict(state["weights"], strict=False)
90
  optimizer.load_state_dict(state["optimizer"])
91
  torch.set_rng_state(state["cpu_rng"])
92
  if state["cuda_rng"] is not None:
93
  torch.cuda.set_rng_state(state["cuda_rng"], device)
 
 
94
  step = state["next_step"]
95
  path = recorder.directory/"events.jsonl"
96
  if path.exists():
@@ -104,7 +115,12 @@ def restore_state(path, model, optimizer, config, recorder, device):
104
 
105
  def run_one(project, storage, stage, method, phase, seed, ratio, device, microbatch=None):
106
  config = scientific_config(stage,method,phase,seed,ratio)
107
- microbatch = microbatch or (32 if stage == "stories" else 2)
 
 
 
 
 
108
  if microbatch < 1:
109
  raise ValueError("A physical batch must contain at least one window")
110
  recorder = Recorder(project, config["id"])
@@ -123,7 +139,7 @@ def run_one(project, storage, stage, method, phase, seed, ratio, device, microba
123
  remember(read_json(marker))
124
  marker.unlink()
125
  try:
126
- return _run(project, storage, config, recorder, device, microbatch)
127
  except Exception as exc:
128
  failure = {"timestamp":time_now(), "error":repr(exc)}
129
  write_json(marker,failure)
@@ -131,7 +147,7 @@ def run_one(project, storage, stage, method, phase, seed, ratio, device, microba
131
  raise
132
 
133
 
134
- def _run(project, storage, config, recorder, device, microbatch):
135
  stage, method, seed, budget = (config[k] for k in ("stage","method","seed","token_budget"))
136
  data = storage/"data"/stage
137
  manifest = read_json(data/"manifest.json")
@@ -144,7 +160,8 @@ def _run(project, storage, config, recorder, device, microbatch):
144
  state_path = output/"state.json"
145
  if not (output/"summary.json").exists():
146
  write_json(state_path,{**config,"status":"initializing","timestamp":time_now()})
147
- config["coefficients"] = chosen_coefficients(project,storage,config,device,microbatch)
 
148
  if (output/"config.json").exists() and read_json(output/"config.json") != config:
149
  raise ValueError(f"Existing run configuration conflicts with {config['id']}")
150
  write_json(output/"config.json",config)
@@ -179,8 +196,14 @@ def _run(project, storage, config, recorder, device, microbatch):
179
  # A restart during the first checkpoint interval must discard measurements from
180
  # updates whose weights and optimizer moments were never committed.
181
  if not (ckpt/"latest.pt").exists():
182
- save_state(ckpt/"latest.pt",model,optimizer,0,0.0,config)
183
- start,elapsed = restore_state(ckpt/"latest.pt",model,optimizer,config,recorder,device)
 
 
 
 
 
 
184
  history = json_lines(output/"events.jsonl")
185
  host_probes = sum(e.get("host_probe_seconds",0.0) for e in history)
186
  # Match elapsed-time comparisons with periodic fixed development windows in every arm.
@@ -195,13 +218,20 @@ def _run(project, storage, config, recorder, device, microbatch):
195
  inputs,targets = windows.get(step,device)
196
  optimizer.zero_grad(set_to_none=True)
197
  base,accuracy = ce_backward(model,inputs,targets,microbatch)
198
- active = bool(config["coefficients"]) and gate(seed,step)
199
- terms = add_penalty(model,parameters,inputs,targets,config["coefficients"],method,seed,step,replica) if active else {}
 
 
 
 
 
 
 
200
  host_seconds = (sum(t["probe_seconds"] for t in terms.values())
201
  if precise and config["derivative_device"]=="cpu" and device.type=="cuda" else 0.0)
202
  host_probes += host_seconds
203
  norm = torch.nn.utils.clip_grad_norm_(parameters,1.0,error_if_nonfinite=True)
204
- lr = learning_rate(stage,step,steps)
205
  for group in optimizer.param_groups:
206
  group["lr"] = lr
207
  optimizer.step()
@@ -214,6 +244,8 @@ def _run(project, storage, config, recorder, device, microbatch):
214
  row = {"step":done, "tokens":done*batch*CONTEXT, "train_seconds":elapsed, "loss":base.item(),
215
  "accuracy":accuracy.item(), "lr":lr, "gradient_norm":norm.item(),"derivatives":terms,
216
  "host_probe_seconds":host_seconds,"training_seconds_excluding_host_probes":max(0.0,elapsed-host_probes)}
 
 
217
  if terms:
218
  row["penalty"] = sum(8*t["lambda"]*t["estimate"] for t in terms.values())
219
  if validate:
@@ -221,9 +253,16 @@ def _run(project, storage, config, recorder, device, microbatch):
221
  row.update(dev_nll=metrics["nll"],dev_accuracy=metrics["accuracy"])
222
  recorder.emit(row)
223
  if done%interval == 0 or done==steps:
224
- save_state(ckpt/"latest.pt",model,optimizer,done,elapsed,config)
 
 
225
  del optimizer
226
  summary.update(host_probe_seconds=host_probes,training_seconds_excluding_host_probes=max(0.0,elapsed-host_probes))
 
 
 
 
 
227
  del replica
228
  dist = unigram_distribution(data/"train.bin",4096 if stage=="stories" else 50304) if method=="unigram" else None
229
  write_json(state_path,{"status":"scoring development","timestamp":time_now()})
 
68
  return {kind: scale*calibrate(project,storage,stage,kind,device,microbatch) for kind,scale in kinds.items()}
69
 
70
 
71
+ def save_state(path, model, optimizer, step, elapsed, config, protocol=None):
72
  """Atomically persist optimizer, trainable weights, all stochastic state and next data step."""
73
  state = {"weights":{n:p.detach() for n,p in model.named_parameters() if p.requires_grad},
74
  "optimizer":optimizer.state_dict(), "next_step":step, "train_seconds":elapsed,
75
  "config":config, "cpu_rng":torch.get_rng_state(),
76
  "cuda_rng":torch.cuda.get_rng_state() if next(model.parameters()).is_cuda else None}
77
+ if protocol is not None:
78
+ state["hybrid_schedule"] = protocol.schedule.state()
79
  temp = path.with_suffix(".partial")
80
  torch.save(state, temp)
81
  os.replace(temp,path)
82
 
83
 
84
+ def restore_state(path, model, optimizer, config, recorder, device, protocol=None):
85
  """Recover the last committed checkpoint and ignore telemetry from interrupted later steps."""
86
  if not path.exists():
87
  return 0, 0.0
88
  state = torch.load(path, map_location="cpu", weights_only=True)
89
+ parent = protocol is not None and path == protocol.parent
90
+ if parent:
91
+ original = state["config"]
92
+ keys = ("seed","stage","data_manifest_sha256","context","batch_windows","microbatch","alpha","cap","schedule_steps","protocol")
93
+ if (original["id"]!=config["parent"] or state["next_step"]!=config["schedule_steps"]//2
94
+ or any(original[key]!=config[key] for key in keys) or sha256(path)!=config["parent_restart_sha256"]):
95
+ raise ValueError("Shared optimizer checkpoint does not match the registered branch")
96
+ elif state["config"] != config:
97
  raise ValueError("Resume configuration differs from saved scientific settings")
98
  model.load_state_dict(state["weights"], strict=False)
99
  optimizer.load_state_dict(state["optimizer"])
100
  torch.set_rng_state(state["cpu_rng"])
101
  if state["cuda_rng"] is not None:
102
  torch.cuda.set_rng_state(state["cuda_rng"], device)
103
+ if protocol is not None:
104
+ protocol.schedule.load(state["hybrid_schedule"])
105
  step = state["next_step"]
106
  path = recorder.directory/"events.jsonl"
107
  if path.exists():
 
115
 
116
  def run_one(project, storage, stage, method, phase, seed, ratio, device, microbatch=None):
117
  config = scientific_config(stage,method,phase,seed,ratio)
118
+ return run_config(project,storage,config,device,microbatch)
119
+
120
+
121
+ def run_config(project, storage, config, device, microbatch=None, protocol=None):
122
+ """Run one identified checkpoint with mutual exclusion and durable failed-attempt records."""
123
+ microbatch = microbatch or (32 if config["stage"] == "stories" else 2)
124
  if microbatch < 1:
125
  raise ValueError("A physical batch must contain at least one window")
126
  recorder = Recorder(project, config["id"])
 
139
  remember(read_json(marker))
140
  marker.unlink()
141
  try:
142
+ return _run(project, storage, config, recorder, device, microbatch,protocol)
143
  except Exception as exc:
144
  failure = {"timestamp":time_now(), "error":repr(exc)}
145
  write_json(marker,failure)
 
147
  raise
148
 
149
 
150
+ def _run(project, storage, config, recorder, device, microbatch, protocol=None):
151
  stage, method, seed, budget = (config[k] for k in ("stage","method","seed","token_budget"))
152
  data = storage/"data"/stage
153
  manifest = read_json(data/"manifest.json")
 
160
  state_path = output/"state.json"
161
  if not (output/"summary.json").exists():
162
  write_json(state_path,{**config,"status":"initializing","timestamp":time_now()})
163
+ config["coefficients"] = ({"trace":config["alpha"],"third":config["cap"]} if protocol is not None
164
+ else chosen_coefficients(project,storage,config,device,microbatch))
165
  if (output/"config.json").exists() and read_json(output/"config.json") != config:
166
  raise ValueError(f"Existing run configuration conflicts with {config['id']}")
167
  write_json(output/"config.json",config)
 
196
  # A restart during the first checkpoint interval must discard measurements from
197
  # updates whose weights and optimizer moments were never committed.
198
  if not (ckpt/"latest.pt").exists():
199
+ initial_step,initial_elapsed = 0,0.
200
+ if protocol is not None and protocol.parent is not None:
201
+ initial_step,initial_elapsed = restore_state(protocol.parent,model,optimizer,config,recorder,device,protocol)
202
+ protocol.checkpoint_width(model,initial_step)
203
+ save_state(ckpt/"latest.pt",model,optimizer,initial_step,initial_elapsed,config,protocol)
204
+ start,elapsed = restore_state(ckpt/"latest.pt",model,optimizer,config,recorder,device,protocol)
205
+ if protocol is not None:
206
+ protocol.checkpoint_width(model,start)
207
  history = json_lines(output/"events.jsonl")
208
  host_probes = sum(e.get("host_probe_seconds",0.0) for e in history)
209
  # Match elapsed-time comparisons with periodic fixed development windows in every arm.
 
218
  inputs,targets = windows.get(step,device)
219
  optimizer.zero_grad(set_to_none=True)
220
  base,accuracy = ce_backward(model,inputs,targets,microbatch)
221
+ coefficients = protocol.schedule.coefficients(step) if protocol is not None else config["coefficients"]
222
+ active = bool(coefficients) and gate(seed,step)
223
+ streams = None
224
+ diagnostics = {}
225
+ if protocol is not None:
226
+ from .hybrid import STREAMS
227
+ streams = STREAMS
228
+ diagnostics = protocol.monitor(model,parameters,inputs,targets,step,base)
229
+ terms = add_penalty(model,parameters,inputs,targets,coefficients,method,seed,step,replica,streams=streams) if active else {}
230
  host_seconds = (sum(t["probe_seconds"] for t in terms.values())
231
  if precise and config["derivative_device"]=="cpu" and device.type=="cuda" else 0.0)
232
  host_probes += host_seconds
233
  norm = torch.nn.utils.clip_grad_norm_(parameters,1.0,error_if_nonfinite=True)
234
+ lr = learning_rate(stage,step,config.get("schedule_steps",steps))
235
  for group in optimizer.param_groups:
236
  group["lr"] = lr
237
  optimizer.step()
 
244
  row = {"step":done, "tokens":done*batch*CONTEXT, "train_seconds":elapsed, "loss":base.item(),
245
  "accuracy":accuracy.item(), "lr":lr, "gradient_norm":norm.item(),"derivatives":terms,
246
  "host_probe_seconds":host_seconds,"training_seconds_excluding_host_probes":max(0.0,elapsed-host_probes)}
247
+ if protocol is not None:
248
+ row.update(trace_lambda=coefficients["trace"],third_lambda=coefficients["third"],**diagnostics)
249
  if terms:
250
  row["penalty"] = sum(8*t["lambda"]*t["estimate"] for t in terms.values())
251
  if validate:
 
253
  row.update(dev_nll=metrics["nll"],dev_accuracy=metrics["accuracy"])
254
  recorder.emit(row)
255
  if done%interval == 0 or done==steps:
256
+ save_state(ckpt/"latest.pt",model,optimizer,done,elapsed,config,protocol)
257
+ if protocol is not None:
258
+ protocol.checkpoint_width(model,done)
259
  del optimizer
260
  summary.update(host_probe_seconds=host_probes,training_seconds_excluding_host_probes=max(0.0,elapsed-host_probes))
261
+ if protocol is not None:
262
+ protocol.finish(steps)
263
+ summary["reference_rms"] = protocol.schedule.reference
264
+ summary["zero_steps"] = protocol.schedule.at_zero
265
+ summary["final_third_lambda"] = protocol.schedule.weight
266
  del replica
267
  dist = unigram_distribution(data/"train.bin",4096 if stage=="stories" else 50304) if method=="unigram" else None
268
  write_json(state_path,{"status":"scoring development","timestamp":time_now()})
research/src/thirdloss/width.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Directional width of an unregularized loss level set in the original weight coordinates."""
2
+
3
+ import math
4
+ import statistics
5
+ import time
6
+
7
+ import torch
8
+
9
+ from .models import trainable_digest
10
+ from .penalties import random_signs
11
+ from .windows import generator
12
+
13
+
14
+ def crossing(loss_at, threshold):
15
+ """Bracket the first observed crossing on the registered outward grid and refine it."""
16
+ lower = 0.
17
+ for exponent in range(-3, 8):
18
+ upper = 2.**exponent
19
+ value = float(loss_at(upper))
20
+ if not math.isfinite(value):
21
+ raise FloatingPointError("Nonfinite width-probe loss")
22
+ if value >= threshold:
23
+ for _ in range(12):
24
+ middle = (lower + upper) / 2
25
+ value = float(loss_at(middle))
26
+ if not math.isfinite(value):
27
+ raise FloatingPointError("Nonfinite width-probe loss")
28
+ if value >= threshold:
29
+ upper = middle
30
+ else:
31
+ lower = middle
32
+ return {"lower":lower, "upper":upper}
33
+ lower = upper
34
+ return {"lower":lower, "upper":None}
35
+
36
+
37
+ @torch.no_grad()
38
+ def measure_width(model, loss, directions=16):
39
+ """Probe two rays per unit direction; preserve exact weights, gradients, mode and RNG."""
40
+ started = time.perf_counter()
41
+ parameters = [p for p in model.parameters() if p.requires_grad]
42
+ original = [p.detach().clone() for p in parameters]
43
+ scale = math.sqrt(sum(p.numel() for p in parameters))
44
+ digest = trainable_digest(model)
45
+ modes = [(module,module.training) for module in model.modules()]
46
+ model.eval()
47
+ rays = []
48
+ try:
49
+ base = float(loss())
50
+ if not math.isfinite(base):
51
+ raise FloatingPointError("Nonfinite unperturbed width-probe loss")
52
+ for index in range(directions):
53
+ signs = random_signs(parameters,generator(parameters[0].device,88731,index,947))
54
+ def at(radius):
55
+ # Reconstruct each perturbation from the saved coordinates to avoid drift.
56
+ torch._foreach_copy_(parameters,original)
57
+ torch._foreach_add_(parameters,signs,alpha=radius/scale)
58
+ return float(loss())
59
+ rays.append({"direction":index,"positive":crossing(at,base+.1),
60
+ "negative":crossing(lambda radius: at(-radius),base+.1)})
61
+ finally:
62
+ torch._foreach_copy_(parameters,original)
63
+ for module,mode in modes:
64
+ module.training = mode
65
+ if trainable_digest(model)!=digest:
66
+ raise RuntimeError("Width measurement changed the training weights")
67
+ lows,highs = [],[]
68
+ for row in rays:
69
+ bounds = [row["positive"],row["negative"]]
70
+ lows.append(sum(x["lower"] for x in bounds))
71
+ highs.append(sum(x["upper"] if x["upper"] is not None else math.inf for x in bounds))
72
+ lower,upper = statistics.median(lows),statistics.median(highs)
73
+ return {"baseline_nll":base,"delta_nll":.1,"directions":rays,"width_lower":lower,
74
+ "width_upper":upper if math.isfinite(upper) else None,
75
+ "width":(lower+upper)/2 if math.isfinite(upper) else None,
76
+ "censored_rays":sum(ray[s]["upper"] is None for ray in rays for s in ("positive","negative")),
77
+ "weights_sha256":digest,"weights_restored":True,"seconds":time.perf_counter()-started}
research/tests/test_hybrid.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Verify the registered schedules, branch pairing and geometric measurement on exact losses."""
2
+
3
+ import math
4
+ import pytest
5
+ import torch
6
+
7
+ from thirdloss.hybrid import HybridSchedule, donor_seed
8
+ from thirdloss.width import crossing, measure_width
9
+
10
+
11
+ def test_lagged_rms_latch_and_replay_survive_checkpoint():
12
+ adaptive = HybridSchedule("adaptive", alpha=0.1, cap=0.3)
13
+ for _ in range(8):
14
+ adaptive.observe(4.0, 3.8)
15
+ adaptive.fix_reference()
16
+ assert adaptive.coefficients(2048) == {"trace": 0.1, "third": 0.0}
17
+ for _ in range(8):
18
+ adaptive.observe(1.0, 3.8)
19
+ assert adaptive.coefficients(2064)["third"] == pytest.approx(0.15)
20
+ restored = HybridSchedule("adaptive", alpha=0.1, cap=0.3)
21
+ restored.load(adaptive.state())
22
+ for _ in range(8):
23
+ restored.observe(16., 5.)
24
+ assert restored.coefficients(2080)["third"] == pytest.approx(0.15)
25
+ replay = HybridSchedule("replay", alpha=0.1, cap=0.3, replay=restored.changes)
26
+ assert replay.coefficients(2063)["third"] == 0
27
+ assert replay.coefficients(2064)["third"] == pytest.approx(0.15)
28
+ assert donor_seed(21) == 28 and donor_seed(22) == 21
29
+
30
+
31
+ def test_fixed_and_stronger_trace_apply_only_after_switch():
32
+ fixed = HybridSchedule("late", alpha=2., cap=6.)
33
+ strong = HybridSchedule("strong", alpha=2., cap=6., delta=4.)
34
+ assert [fixed.coefficients(t)["third"] for t in (0,2048,2560,3072,4095)] == [0,0,3,6,6]
35
+ assert strong.coefficients(2560) == {"trace":4., "third":0.}
36
+ adaptive = HybridSchedule("adaptive",alpha=2.,cap=6.)
37
+ for _ in range(8):
38
+ adaptive.observe(4.,4.5)
39
+ adaptive.fix_reference()
40
+ for _ in range(8):
41
+ adaptive.observe(1.,4.5)
42
+ assert adaptive.coefficients(3072)["third"] == 0.
43
+
44
+
45
+ def test_width_exact_crossing_censor_and_bitwise_restoration():
46
+ model = torch.nn.Linear(2,1,bias=False,dtype=torch.float64)
47
+ original = model.weight.detach().clone()
48
+ model.weight.grad = torch.ones_like(original)
49
+ rng = torch.get_rng_state().clone()
50
+ stats = measure_width(model, lambda: (model.weight-original).square().sum(), directions=3)
51
+ assert stats["width"] == pytest.approx(2*math.sqrt(.1),abs=1e-4)
52
+ assert stats["weights_restored"] and model.training and torch.equal(model.weight,original)
53
+ assert torch.equal(model.weight.grad, torch.ones_like(original))
54
+ assert torch.equal(torch.get_rng_state(),rng)
55
+ assert crossing(lambda radius: 0.,.1) == {"lower":128.,"upper":None}
56
+ unbounded = measure_width(model,lambda: model.weight.sum()*0.,directions=2)
57
+ assert unbounded["width"] is None and unbounded["width_lower"] == 256.
58
+
59
+
60
+ def test_branch_restores_adam_moments_rng_cursor_and_monitor(tmp_path):
61
+ from types import SimpleNamespace
62
+ from thirdloss.records import sha256
63
+ from thirdloss.train import restore_state, save_state
64
+ model = torch.nn.Linear(2,1)
65
+ optim = torch.optim.AdamW(model.parameters(),lr=.01)
66
+ x = torch.tensor([[2.,-3.]])
67
+ model(x).square().sum().backward()
68
+ optim.step()
69
+ parent = tmp_path/"parent.pt"
70
+ cfg = dict(id="trunk",seed=21,stage="stories",data_manifest_sha256="data",context=128,batch_windows=32,
71
+ microbatch=32,alpha=1.,cap=2.,schedule_steps=4096,protocol="hybrid-v1")
72
+ schedule = HybridSchedule("trunk",1.,2.)
73
+ for _ in range(8):
74
+ schedule.observe(1.,3.2)
75
+ schedule.fix_reference()
76
+ save_state(parent,model,optim,2048,123.,cfg,SimpleNamespace(schedule=schedule))
77
+ control = torch.rand(3)
78
+ child = torch.nn.Linear(2,1)
79
+ child_opt = torch.optim.AdamW(child.parameters(),lr=.001)
80
+ child_protocol = SimpleNamespace(parent=parent,schedule=HybridSchedule("adaptive",1.,2.))
81
+ child_cfg = {**cfg,"id":"adaptive","parent":"trunk","parent_restart_sha256":sha256(parent)}
82
+ assert restore_state(parent,child,child_opt,child_cfg,SimpleNamespace(directory=tmp_path),
83
+ torch.device("cpu"),child_protocol)==(2048,123.)
84
+ assert torch.equal(torch.rand(3),control) and child_protocol.schedule.reference==1.
85
+ for net,optimizer in ((model,optim),(child,child_opt)):
86
+ optimizer.zero_grad()
87
+ net(x).square().sum().backward()
88
+ optimizer.step()
89
+ assert all(torch.equal(a,b) for a,b in zip(model.parameters(),child.parameters()))
90
+
91
+
92
+ def test_width_inference_requires_eight_pairs_and_keeps_censoring():
93
+ from thirdloss.hybrid_results import hybrid_results
94
+ records=[]
95
+ for seed in range(21,29):
96
+ for arm,w in (("adaptive",3.),("late",2.),("replay",1.)):
97
+ base={"baseline_nll":2.,"weights_sha256":"same"}
98
+ records.append(dict(seed=seed,method=arm,phase="hybrid",finished_at="today",tokens=2**24,dev_nll=3.,
99
+ initial_trainable_sha256=str(seed),parent_restart_sha256=str(seed),
100
+ data_manifest_sha256="data",widths={"2048":{**base,"width":1.},"4096":{**base,"width":w}}))
101
+ evidence = hybrid_results(records)
102
+ assert evidence["status"]=="both width comparisons passed"
103
+ assert evidence["comparisons"]["late"]["p_holm"]==2/256
104
+ records[-1]["widths"]["4096"]["width"]=None
105
+ evidence = hybrid_results(records)
106
+ assert "replay" not in evidence["comparisons"]
107
+ assert len(evidence["pairs"])==16