Record recovered adapter pilot and completed training before full validation
Browse filesFiles changed (25)
- .gitattributes+1
- research/docs/explorer.js+5-1
- research/docs/figures/curves.png
- research/docs/runbook.md+2
- research/docs/study.json
- research/reports/experiments/abstracts-pilot-s00-third-r03/experiment.md+2-2
- research/reports/experiments/abstracts-pilot-s00-third-r03/learnings.md+1-1
- research/reports/experiments/experiments.md+1-1
- research/reports/experiments/learnings.md+1-1
- research/reports/paper.pdf
- research/reports/progress.md+2-2
- research/results/abstracts-pilot-s00-third-r03/attempts.jsonAdded+8
- research/results/abstracts-pilot-s00-third-r03/config.jsonAdded+16
- research/results/abstracts-pilot-s00-third-r03/events.jsonlAdded+22
- research/results/calibration/abstracts-third.jsonAdded+152
- research/results/verification/pythia-initializations.jsonAdded+9
- research/results/verification/pythia-window-comparison.jsonAdded+12
- research/src/thirdloss/cli.py+9-1
- research/src/thirdloss/evaluation.py+12-1
- research/src/thirdloss/models.py+11
- research/src/thirdloss/probe_check.pyAdded+61
- research/src/thirdloss/report_records.py+10-4
- research/src/thirdloss/study.py+7
- research/src/thirdloss/train.py+14-3
- research/tests/test_training.py+1
33 unmodified lines3435363733 unmodified lines*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textresearch/reports/paper.pdf filter=lfs diff=lfs merge=lfs -textresearch/docs/figures/curves.png filter=lfs diff=lfs merge=lfs -text80 unmodified lines818283848586878889869091929380 unmodified lines link.href = repository + "/tree/main/results/" + encodeURIComponent(run.id);
first.append(link);
tr.append(first);
const evaluation = run.evaluation_progress;
const status = evaluation?.targets_to_score > 0
? `${run.status} (${number(100 * evaluation.targets_scored / evaluation.targets_to_score, 1)}%)`
: run.status;
for (const value of [methodName(run.method), run.seed ?? "—", number(run.ratio, 3),
number(run.tokens, 0), number(run.dev_nll, 4), number(run.test_nll, 4),
number(run.tokens_per_sec, 0), number(run.peak_vram_mb, 0), run.status]) {
number(run.tokens_per_sec, 0), number(run.peak_vram_mb, 0), status]) {
tr.append(node("td", value));
}
body.append(tr);14 unmodified lines151617181920212214 unmodified lines
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/`.
After preparing abstracts, `uv run thirdloss verify --pretrained --device cuda` also compares both implementations of the penalty and its entire training gradient on the same pair of training windows, adapter initialization and sign probes. The diagnostic materializes the original joint graph for comparison. Its GPU allocation exceeded 10 GiB during the original replay. The ordinary adapter training path processes the two windows sequentially. `--device cpu` runs the optional comparison in host memory. [Adapter verification](../reports/reviews/adapter-verification.md)
## Load a published checkpoint
All models are indexed in the [Hugging Face collection](https://huggingface.co/collections/BurnyCoder/third-derivatives-in-language-model-training-6b067fb7d5ae3eca49ebb378). The run name identifies its objective, phase, seed and penalty strength. Replace the example run name with the desired published checkpoint. Run from a clone with the locked environment.3 unmodified lines456778991011123 unmodified lines
| Stage | Method | Phase | Seed | Ratio | Train tokens | Dev NLL | Test NLL | Tokens/s | Status || --- | --- | --- | --- | --- | --- | --- | --- | --- | --- || Research abstracts | Third derivative | pilot | 0 | 0.030 | — | — | — | — | failed || Research abstracts | Third derivative | pilot | 0 | 0.030 | 65,536 | 3.0909 | — | — | scoring development |
Training time is — seconds. Peak allocated GPU memory is — MiB. Development token accuracy is —. Test token accuracy is —.Training time is 72.3 seconds. Peak allocated GPU memory is — MiB. Development token accuracy is 0.4143. Test token accuracy is —.
[Design and hyperparameter rationale](../../planned-runs.md) · [Saved configuration](../../../results/abstracts-pilot-s00-third-r03/config.json)
123345# Run learnings
The run recorded a failure. The run ledger contains the error and last metrics. The run ledger records 1 interrupted attempt(s).Development NLL changed by -0.1143 nats per target token from 4,096 to 65,536 training targets. Attribution to the regularizer uses matched comparisons across seeds. The run ledger records 1 interrupted attempt(s).
[Experiment and source records](experiment.md)5 unmodified lines678991011125 unmodified lines
| Run | Stage | Method | Phase | Seed | Ratio | Train tokens | Dev NLL | Test NLL | Tokens/s | Status || --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- || [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) | Research abstracts | Third derivative | pilot | 0 | 0.030 | — | — | — | — | failed || [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) | Research abstracts | Third derivative | pilot | 0 | 0.030 | 65,536 | 3.0909 | — | — | scoring development || [stories-control-s00-initial-r00](./stories-control-s00-initial-r00/experiment.md) | TinyStories | Initial checkpoint | control | 0 | 0.000 | 0 | 8.3437 | — | 0 | complete || [stories-control-s00-unigram-r00](./stories-control-s00-unigram-r00/experiment.md) | TinyStories | Unigram | control | 0 | 0.000 | 0 | 6.0036 | — | 0 | complete || [stories-pilot-s00-ce-r00](./stories-pilot-s00-ce-r00/experiment.md) | TinyStories | Ordinary AdamW | pilot | 0 | 0.000 | 2,097,152 | 3.8770 | — | 123,871 | complete |5 unmodified lines678991011125 unmodified lines
Independent random signs include mixed weight derivatives in the expected penalty. The trace implementation motivating the gradient check converted its estimate to a Python number. [Derivation and references](../literature-review.md)
- [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) — The run recorded a failure. The run ledger contains the error and last metrics. The run ledger records 1 interrupted attempt(s).- [abstracts-pilot-s00-third-r03](./abstracts-pilot-s00-third-r03/experiment.md) — Development NLL changed by -0.1143 nats per target token from 4,096 to 65,536 training targets. Attribution to the regularizer uses matched comparisons across seeds. The run ledger records 1 interrupted attempt(s).
- [stories-control-s00-initial-r00](./stories-control-s00-initial-r00/experiment.md) — The observed development NLL is 8.3437 nats per target token.
12334565 unmodified lines1213141515161718# Study progress
Updated 2026-11-25T07:08:06+00:00.Updated 2026-11-25T07:22:10+00:00.
12 training/control records and 0 final evaluations are complete. This is 10.0% of 120 planned model milestones.
5 unmodified lines
Statistical status: pending. Awaiting confirmatory runs.
**abstracts** has 0 completed runs. Current records: abstracts-pilot-s00-third-r03 (failed, 0 targets).**abstracts** has 0 completed runs. Current records: abstracts-pilot-s00-third-r03 (scoring development, 65,536 targets).
Statistical status: pending. Awaiting confirmatory runs.
12345678{
"failures": [
{
"timestamp": "2026-11-25T07:00:21+00:00",
"error": "FloatingPointError('Nonfinite or zero third calibration norm at draw 0: inf')"
}
]
}12345678910111213141516{
"id": "abstracts-pilot-s00-third-r03",
"stage": "abstracts",
"method": "third",
"phase": "pilot",
"seed": 0,
"ratio": 0.03,
"token_budget": 65536,
"batch_windows": 8,
"context": 128,
"data_manifest_sha256": "0638bd23a7d1dc3ecb9138074ecd922211df2637f60736ddfab7e9aec0b3ccb9",
"microbatch": 2,
"coefficients": {
"third": 8.794990192182448e-22
}
}12345678910111213141516171819202122{"timestamp": "2026-11-25T07:10:36+00:00", "step": 1, "tokens": 1024, "train_seconds": 0.7549512999976287, "loss": 3.3628768920898438, "accuracy": 0.38671875, "lr": 3.3333333333333335e-05, "gradient_norm": 1.1452151536941528, "derivatives": {}}
{"timestamp": "2026-11-25T07:10:43+00:00", "step": 2, "tokens": 2048, "train_seconds": 7.784967199997482, "loss": 3.4265871047973633, "accuracy": 0.3720703125, "lr": 6.666666666666667e-05, "gradient_norm": 1.1557306051254272, "derivatives": {"third": {"estimate": 63550970134528.0, "raw_grad_norm": 1.0867890687798411e+19, "lambda": 8.794990192182448e-22}}, "penalty": 4.4714412722948273e-07}
{"timestamp": "2026-11-25T07:10:46+00:00", "step": 4, "tokens": 4096, "train_seconds": 8.992709899997863, "loss": 3.3350443840026855, "accuracy": 0.3671875, "lr": 9.994033404481737e-05, "gradient_norm": 1.148818850517273, "derivatives": {}, "dev_nll": 3.2052710236166604, "dev_accuracy": 0.40283203125}
{"timestamp": "2026-11-25T07:10:51+00:00", "step": 8, "tokens": 8192, "train_seconds": 11.37447599999723, "loss": 3.153599977493286, "accuracy": 0.412109375, "lr": 9.851624761560943e-05, "gradient_norm": 1.330934762954712, "derivatives": {}, "dev_nll": 3.1850391061161645, "dev_accuracy": 0.4056396484375}
{"timestamp": "2026-11-25T07:10:59+00:00", "step": 11, "tokens": 11264, "train_seconds": 19.229515199996968, "loss": 3.2227602005004883, "accuracy": 0.4150390625, "lr": 9.623426070191522e-05, "gradient_norm": 20.010913848876953, "derivatives": {"third": {"estimate": 1530587563163648.0, "raw_grad_norm": 2.8263922879758997e+21, "lambda": 8.794990192182448e-22}}, "penalty": 1.0769202085040574e-05}
{"timestamp": "2026-11-25T07:11:01+00:00", "step": 12, "tokens": 12288, "train_seconds": 19.830211699998472, "loss": 3.2258496284484863, "accuracy": 0.421875, "lr": 9.525191870029581e-05, "gradient_norm": 1.1856259107589722, "derivatives": {}, "dev_nll": 3.1686210415209644, "dev_accuracy": 0.4073486328125}
{"timestamp": "2026-11-25T07:11:05+00:00", "step": 16, "tokens": 16384, "train_seconds": 22.11336940000183, "loss": 3.1759636402130127, "accuracy": 0.404296875, "lr": 9.028539129595197e-05, "gradient_norm": 1.2954821586608887, "derivatives": {}, "dev_nll": 3.1556127692456357, "dev_accuracy": 0.4083251953125}
{"timestamp": "2026-11-25T07:11:10+00:00", "step": 20, "tokens": 20480, "train_seconds": 24.520824300005188, "loss": 3.365950584411621, "accuracy": 0.3798828125, "lr": 8.38266930414179e-05, "gradient_norm": 1.2729922533035278, "derivatives": {}, "dev_nll": 3.143591393774841, "dev_accuracy": 0.4073486328125}
{"timestamp": "2026-11-25T07:11:17+00:00", "step": 22, "tokens": 22528, "train_seconds": 32.07198700000663, "loss": 3.1026458740234375, "accuracy": 0.400390625, "lr": 8.01209674912089e-05, "gradient_norm": 9.28732681274414, "derivatives": {"third": {"estimate": 1165224627404800.0, "raw_grad_norm": 1.3197244810220038e+21, "lambda": 8.794990192182448e-22}}, "penalty": 8.19851133577173e-06}
{"timestamp": "2026-11-25T07:11:20+00:00", "step": 24, "tokens": 24576, "train_seconds": 33.262805500005925, "loss": 3.1675891876220703, "accuracy": 0.4130859375, "lr": 7.614895343622941e-05, "gradient_norm": 1.4086129665374756, "derivatives": {}, "dev_nll": 3.1338581111631356, "dev_accuracy": 0.4075927734375}
{"timestamp": "2026-11-25T07:11:27+00:00", "step": 25, "tokens": 25600, "train_seconds": 40.032943500005786, "loss": 3.1646835803985596, "accuracy": 0.400390625, "lr": 7.407614758194375e-05, "gradient_norm": 1.3745598793029785, "derivatives": {"third": {"estimate": 143147149557760.0, "raw_grad_norm": 8.819714745499946e+19, "lambda": 8.794990192182448e-22}}, "penalty": 1.0071822211194986e-06}
{"timestamp": "2026-11-25T07:11:31+00:00", "step": 28, "tokens": 28672, "train_seconds": 41.769987900010165, "loss": 3.24495267868042, "accuracy": 0.3994140625, "lr": 6.757685356832243e-05, "gradient_norm": 1.2910264730453491, "derivatives": {}, "dev_nll": 3.1247553065186366, "dev_accuracy": 0.407958984375}
{"timestamp": "2026-11-25T07:11:36+00:00", "step": 32, "tokens": 32768, "train_seconds": 44.11454810001305, "loss": 3.475984573364258, "accuracy": 0.376953125, "lr": 5.84728957956991e-05, "gradient_norm": 1.348798394203186, "derivatives": {}, "dev_nll": 3.116393227071967, "dev_accuracy": 0.40966796875}
{"timestamp": "2026-11-25T07:11:40+00:00", "step": 36, "tokens": 36864, "train_seconds": 46.52359150001212, "loss": 3.1366770267486572, "accuracy": 0.3994140625, "lr": 4.9222074018405206e-05, "gradient_norm": 1.3073307275772095, "derivatives": {}, "dev_nll": 3.109527630964294, "dev_accuracy": 0.4110107421875}
{"timestamp": "2026-11-25T07:11:45+00:00", "step": 40, "tokens": 40960, "train_seconds": 49.058105700012675, "loss": 3.069873094558716, "accuracy": 0.421875, "lr": 4.021559281401244e-05, "gradient_norm": 1.2526063919067383, "derivatives": {}, "dev_nll": 3.1042128810076974, "dev_accuracy": 0.412109375}
{"timestamp": "2026-11-25T07:11:49+00:00", "step": 44, "tokens": 45056, "train_seconds": 51.578499600014766, "loss": 3.3931686878204346, "accuracy": 0.3740234375, "lr": 3.183432393205763e-05, "gradient_norm": 1.2775940895080566, "derivatives": {}, "dev_nll": 3.100137497414835, "dev_accuracy": 0.41259765625}
{"timestamp": "2026-11-25T07:11:54+00:00", "step": 48, "tokens": 49152, "train_seconds": 54.11914360001538, "loss": 3.235374927520752, "accuracy": 0.37890625, "lr": 2.443269974962181e-05, "gradient_norm": 1.304945468902588, "derivatives": {}, "dev_nll": 3.097055894031655, "dev_accuracy": 0.4124755859375}
{"timestamp": "2026-11-25T07:12:02+00:00", "step": 50, "tokens": 51200, "train_seconds": 61.74632690001454, "loss": 3.0874135494232178, "accuracy": 0.4052734375, "lr": 2.1199063110826618e-05, "gradient_norm": 1.267307996749878, "derivatives": {"third": {"estimate": 36042237280256.0, "raw_grad_norm": 1.8375159269671567e+19, "lambda": 8.794990192182448e-22}}, "penalty": 2.535928987073313e-07}
{"timestamp": "2026-11-25T07:12:05+00:00", "step": 52, "tokens": 53248, "train_seconds": 63.20483800001239, "loss": 3.068760871887207, "accuracy": 0.408203125, "lr": 1.8323724811743496e-05, "gradient_norm": 1.184583306312561, "derivatives": {}, "dev_nll": 3.0948601723648608, "dev_accuracy": 0.412841796875}
{"timestamp": "2026-11-25T07:12:10+00:00", "step": 56, "tokens": 57344, "train_seconds": 66.32172880001235, "loss": 3.2506747245788574, "accuracy": 0.40234375, "lr": 1.3765739298084793e-05, "gradient_norm": 1.1677639484405518, "derivatives": {}, "dev_nll": 3.0932112977607176, "dev_accuracy": 0.4134521484375}
{"timestamp": "2026-11-25T07:12:16+00:00", "step": 60, "tokens": 61440, "train_seconds": 69.4508472000125, "loss": 3.1683192253112793, "accuracy": 0.4091796875, "lr": 1.09514941707089e-05, "gradient_norm": 1.2090530395507812, "derivatives": {}, "dev_nll": 3.091967608779669, "dev_accuracy": 0.414306640625}
{"timestamp": "2026-11-25T07:12:21+00:00", "step": 64, "tokens": 65536, "train_seconds": 72.27489250001236, "loss": 3.1733510494232178, "accuracy": 0.400390625, "lr": 1e-05, "gradient_norm": 1.1200544834136963, "derivatives": {}, "dev_nll": 3.09093911992386, "dev_accuracy": 0.414306640625}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152{
"stage": "abstracts",
"kind": "third",
"data_manifest_sha256": "0638bd23a7d1dc3ecb9138074ecd922211df2637f60736ddfab7e9aec0b3ccb9",
"unit_lambda": 2.931663397394149e-20,
"draws": [
{
"draw": 0,
"ce_grad_norm": 1.1272474527359009,
"penalty_grad_norm": 1.744107653806619e+20,
"value": 265727747555328.0,
"norm_ratio": 6.4631758841010535e-21,
"probe_seconds": 6.6500113000001875,
"peak_allocated_mib": 6354.271484375
},
{
"draw": 1,
"ce_grad_norm": 1.1757105588912964,
"penalty_grad_norm": 4.98717745431209e+21,
"value": 3010543904358400.0,
"norm_ratio": 2.357466863094545e-22,
"probe_seconds": 6.50068470000042,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 2,
"ce_grad_norm": 1.2021815776824951,
"penalty_grad_norm": 2.7038835357767434e+18,
"value": 17962486464512.0,
"norm_ratio": 4.446129286915256e-19,
"probe_seconds": 6.208909000000858,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 3,
"ce_grad_norm": 1.0702996253967285,
"penalty_grad_norm": 1.6400195825337523e+20,
"value": 296954944815104.0,
"norm_ratio": 6.526139302209834e-21,
"probe_seconds": 6.415160799999285,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 4,
"ce_grad_norm": 1.181842565536499,
"penalty_grad_norm": 5.48905451595078e+18,
"value": 31501934657536.0,
"norm_ratio": 2.1530895022123633e-19,
"probe_seconds": 6.108574300000328,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 5,
"ce_grad_norm": 1.2219445705413818,
"penalty_grad_norm": 2.274370169494697e+19,
"value": 27829452406784.0,
"norm_ratio": 5.37267234213182e-20,
"probe_seconds": 5.9862028999996255,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 6,
"ce_grad_norm": 1.1192132234573364,
"penalty_grad_norm": 3.59346047387737e+19,
"value": 15019091689472.0,
"norm_ratio": 3.114583370523893e-20,
"probe_seconds": 6.139835399997537,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 7,
"ce_grad_norm": 1.0118643045425415,
"penalty_grad_norm": 2.757049388682895e+21,
"value": 1504090567737344.0,
"norm_ratio": 3.670098579648339e-22,
"probe_seconds": 6.22955169999841,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 8,
"ce_grad_norm": 1.225813627243042,
"penalty_grad_norm": 6.602691569608819e+18,
"value": 5855106301952.0,
"norm_ratio": 1.8565362539199544e-19,
"probe_seconds": 5.914080399998056,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 9,
"ce_grad_norm": 1.167998194694519,
"penalty_grad_norm": 2.1537623831724413e+19,
"value": 32228790763520.0,
"norm_ratio": 5.423059683000338e-20,
"probe_seconds": 6.2061707000029855,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 10,
"ce_grad_norm": 1.1549506187438965,
"penalty_grad_norm": 1.2663927538607718e+19,
"value": 27836349939712.0,
"norm_ratio": 9.12000337354167e-20,
"probe_seconds": 6.111348800000997,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 11,
"ce_grad_norm": 1.0679398775100708,
"penalty_grad_norm": 5.172649748649782e+19,
"value": 83065531531264.0,
"norm_ratio": 2.064589580589398e-20,
"probe_seconds": 6.134617499999877,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 12,
"ce_grad_norm": 1.2423405647277832,
"penalty_grad_norm": 4.519667255084921e+19,
"value": 40152789417984.0,
"norm_ratio": 2.7487434242644055e-20,
"probe_seconds": 6.022774100001698,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 13,
"ce_grad_norm": 1.177032709121704,
"penalty_grad_norm": 2.6147074281208077e+20,
"value": 137183746850816.0,
"norm_ratio": 4.501584752706495e-21,
"probe_seconds": 5.9077686999989965,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 14,
"ce_grad_norm": 1.1937261819839478,
"penalty_grad_norm": 7.480117052732963e+19,
"value": 202575806726144.0,
"norm_ratio": 1.595865644305397e-20,
"probe_seconds": 6.179321399999026,
"peak_allocated_mib": 6354.27197265625
},
{
"draw": 15,
"ce_grad_norm": 1.1019200086593628,
"penalty_grad_norm": 6.702447510817866e+18,
"value": 7641613991936.0,
"norm_ratio": 1.6440561554280656e-19,
"probe_seconds": 6.32930209999904,
"peak_allocated_mib": 6354.27197265625
}
]
}123456789{
"timestamp": "2026-11-25T07:10:36+00:00",
"seed": 0,
"cpu_adapter_sha256_by_build": [
"1c45ca4d5b3a6cd1b53eadaa7df8af15e21a040a8a61aa7f0e91d1b6f019320b",
"1c45ca4d5b3a6cd1b53eadaa7df8af15e21a040a8a61aa7f0e91d1b6f019320b",
"1c45ca4d5b3a6cd1b53eadaa7df8af15e21a040a8a61aa7f0e91d1b6f019320b"
]
}123456789101112{
"timestamp": "2026-11-25T07:12:23+00:00",
"model": "EleutherAI/pythia-410m",
"seed": 0,
"calibration_draw": 0,
"probe_generation": "CUDA stream 827, seed 6247, FP32 CPU model derivatives, FP64 reductions",
"max_logit_abs_diff": 0.0,
"joint_penalty": 3507310145714932.0,
"two_window_penalty": 3507310136327515.0,
"relative_vector_error": 7.224275647290446e-08,
"cosine": 0.9999999999999951
}41 unmodified lines42434445464748495017 unmodified lines6869706871727374757677787941 unmodified lines sub.add_argument("--stage",choices=HORIZONS,required=True)
if action in {"train","study","evaluate"}:
sub.add_argument("--device",default="cuda")
if action=="verify":
sub.add_argument("--pretrained",action="store_true",help="Also compare a full joint derivative on the prepared adapter training corpus")
sub.add_argument("--device",default="cuda",help="Device for the optional full pretrained cross-check")
if action=="train":
sub.add_argument("--method",choices=(*METHODS,"unigram","initial"),required=True)
sub.add_argument("--phase",choices=("pilot","control","confirm","smoke"),default="pilot")17 unmodified lines storage = storage_root(project)
if args.action=="verify":
from .verification import verify
return verify(project)
verify(project)
if args.pretrained:
from .probe_check import verify_pretrained
from .records import setup_device
verify_pretrained(project,setup_device(args.device))
return
if args.action=="dashboard":
return dashboard(project,args.port)
if args.action in {"report","progress","publish"}:12345673 unmodified lines11121313141516175 unmodified lines232425262728293031323310 unmodified lines444546474849505152535455565758"""Token-weighted NLL, exact token accuracy, and uncurated paired development continuations."""
import math
import time
import numpy as np
import torch
from tokenizers import Tokenizer3 unmodified lines
@torch.no_grad()
def score(model, path, device, batch_size, limit_windows=None, unigram=None):
def score(model, path, device, batch_size, limit_windows=None, unigram=None, progress=None):
"""Score each packed target once, including a final short window, with a fixed context grid."""
tokens = np.memmap(path, mode="r", dtype="<u2")
n = len(tokens) - 15 unmodified lines indices = np.linspace(0, full-1, limit_windows, dtype=np.int64)
tail = 0
total_loss, correct, count = 0.0, 0, 0
started = last_log = time.perf_counter()
def report():
progress({"targets_scored":count,"targets_to_score":len(indices)*CONTEXT+tail,
"nll_so_far":total_loss/count,"accuracy_so_far":correct/count,
"score_seconds":time.perf_counter()-started})
if model is not None:
model.eval()
10 unmodified lines offsets = indices[start:start+batch_size, None] * CONTEXT + np.arange(CONTEXT+1)
loss, hits = batch_score(tokens[offsets])
total_loss, correct, count = total_loss+loss, correct+hits, count+offsets.shape[0]*CONTEXT
if progress and time.perf_counter()-last_log>=60:
report()
last_log = time.perf_counter()
if tail:
loss, hits = batch_score(np.asarray(tokens[full*CONTEXT:])[None, :])
total_loss, correct, count = total_loss+loss, correct+hits, count+tail
nll = total_loss/count
if progress:
report()
return {"nll": nll, "accuracy": correct/count, "tokens": count, "perplexity": math.exp(nll)}
5 unmodified lines6789101112121 unmodified lines1341351361371381391401411421431441451461471481495 unmodified lines"""
from dataclasses import asdict, dataclass
import hashlib
from pathlib import Path
import torch121 unmodified lines return out if isinstance(out, torch.Tensor) else out.logits
def trainable_digest(model):
"""Fingerprint each named trainable tensor at initialization to audit seed pairing."""
digest = hashlib.sha256()
for name,p in model.named_parameters():
if p.requires_grad:
digest.update(name.encode("utf-8"))
digest.update(p.detach().contiguous().cpu().view(torch.uint8).numpy().tobytes())
return digest.hexdigest()
def token_nll(logits, targets):
"""Elementwise stable next-token NLL, exposing all derivative orders in the log partition."""
observed = logits.gather(-1, targets.unsqueeze(-1)).squeeze(-1)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061"""Compare both fourth-order implementations on identical pretrained weights and probes."""
import hashlib
import time
import torch
from .models import build_model, logits_of, token_loss, trainable_digest
from .objectives import two_window_third_gradient
from .penalties import estimate, partials, random_signs
from .records import BATCHES, storage_root, time_now, write_json
from .windows import TrainingWindows, generator, probe_rows
def verify_pretrained(project,device):
"""Use training calibration draw zero. The full joint GPU graph can exceed 10 GiB."""
storage = storage_root(project)
model = build_model("abstracts",0,device,storage).eval()
parameters = tuple(p for p in model.parameters() if p.requires_grad)
seed,step = 6247,0
x,y = TrainingWindows(storage/"data"/"abstracts"/"train.bin",seed,BATCHES["abstracts"]).get(step,device)
rows = probe_rows(seed,step,len(x))
x,y = x[rows],y[rows]
rng = generator(device,seed,step,827)
u,v = random_signs(parameters,rng),random_signs(parameters,rng)
def digest(tensors):
h = hashlib.sha256()
for tensor in tensors:
h.update(tensor.detach().contiguous().cpu().numpy().tobytes())
return h.hexdigest()
result = {"timestamp":time_now(),"device":str(device),"seed":0,"calibration_seed":seed,"draw":step,
"initial_trainable_sha256":trainable_digest(model),"input_sha256":digest((x,y)),
"probes_sha256":digest((*u,*v))}
with torch.no_grad():
single = torch.cat([logits_of(model,t[None,:]) for t in x])
result["max_logit_abs_difference"] = (logits_of(model,x)-single).abs().max().item()
del single
def calculate(implementation):
if device.type=="cuda":
torch.cuda.empty_cache()
torch.cuda.reset_peak_memory_stats(device)
start = time.perf_counter()
if implementation=="joint":
loss = token_loss(logits_of(model,x),y)
value = estimate(loss,parameters,"third",u=u,v=v)
gradient = partials(value,parameters,create_graph=False)
else:
value,gradient = two_window_third_gradient(model,parameters,x,y,u,v)
flat = torch.cat([g.detach().reshape(-1).cpu().double() for g in gradient])
result[implementation] = {"penalty":value.item(),"gradient_norm":flat.norm().item(),
"seconds":time.perf_counter()-start,"finite":bool(flat.isfinite().all()),
"peak_allocated_mib":torch.cuda.max_memory_allocated(device)/2**20 if device.type=="cuda" else None}
return flat
joint = calculate("joint")
split = calculate("sequential")
result["relative_gradient_difference"] = ((joint-split).norm()/joint.norm()).item()
result["gradient_cosine"] = torch.nn.functional.cosine_similarity(joint,split,dim=0).item()
result["relative_penalty_difference"] = abs(result["joint"]["penalty"]-result["sequential"]["penalty"])/result["joint"]["penalty"]
write_json(project/"results"/"verification"/f"pythia-joint-{device.type}.json",result)
print(result,flush=True)
return result36 unmodified lines373839404041424360 unmodified lines10410510610710710810911011113 unmodified lines12512612712812913013113213313413513213613713813914014114214339 unmodified lines18318418518018618718818936 unmodified lines "batch_size", "architecture", "commit", "dataset_revision", "data_hash",
"freeze_id", "test_manifest_sha256", "test_tokens", "data_manifest_sha256",
"token_budget", "batch_windows", "microbatch", "context", "weights_sha256", "dev_tokens",
"git_revision", "gpu", "torch", "matched_dev_nll", "finished_at",
"git_revision", "gpu", "torch", "matched_dev_nll", "finished_at", "initial_trainable_sha256",
)
EVENT_FIELDS = (
"step", "tokens", "train_seconds", "loss", "accuracy", "penalty", "dev_nll",60 unmodified lines
def run_record(folder: Path) -> dict:
"""Join configuration, events and final summary with explicit completion state."""
config = read_json(folder / "config.json")
state = read_json(folder / "state.json")
config = {**state,**read_json(folder / "config.json")}
summary = read_json(folder / "summary.json")
last_error = read_json(folder / "failure.json")
events = read_lines(folder / "events.jsonl")13 unmodified lines if "token_budget" in record:
record["target_tokens"] = record["token_budget"]
record["id"] = folder.name
if "targets_scored" in state and not summary:
record["evaluation_progress"] = state
failures = read_json(folder / "attempts.json").get("failures", [])
if last_error and last_error not in failures:
failures.append(last_error)
if failures:
record["failures"] = failures
resumed = bool(last_error and events and events[-1].get("timestamp", "")>last_error.get("timestamp", ""))
if last_error and not summary:
if last_error and not summary and not resumed:
record["status"] = "failed"
record["error"] = str(last_error.get("error", "Recorded failure"))
elif resumed and not summary:
record["status"] = "scoring development" if record.get("tokens")==record.get("token_budget") else "training"
else:
record.setdefault("status", "complete" if summary else "in progress" if events else "configured")
record["events"] = []39 unmodified lines directory = Path(root) / "results"
runs = []
for folder in sorted(directory.glob("*")):
if folder.is_dir() and any((folder / f).is_file() for f in ("config.json", "summary.json", "failure.json")):
if folder.is_dir() and any((folder / f).is_file() for f in ("config.json", "summary.json", "failure.json", "state.json")):
runs.append(run_record(folder))
stages = {stage: analyze_stage(runs, stage) for stage in STAGES}
for run in runs:59 unmodified lines606162636465663 unmodified lines70717273747576777879808159 unmodified lines split = read_json(storage/"data"/stage/"manifest.json")["splits"]["test"]
frozen = {"stage":stage,"ratios":selection,"test_sha256":split["sha256"],"runs":{}}
for seed in range(1,9):
initial = set()
for method in ("ce","trace","third"):
name = run_name(stage,method,"confirm",seed,selection.get(method,0))
summary = read_json(project/"results"/name/"summary.json")3 unmodified lines raise ValueError(f"Different corpus for {name}")
weights_file(storage,summary)
frozen["runs"][name] = summary["weights_sha256"]
if summary.get("initial_trainable_sha256"):
initial.add(summary["initial_trainable_sha256"])
if len(initial)>1:
raise ValueError(f"Initial trainable weights differ across {stage} seed {seed} arms")
if initial:
frozen.setdefault("initializations",{})[str(seed)] = initial.pop()
frozen["freeze_id"] = hashlib.sha256(json.dumps(frozen,sort_keys=True).encode()).hexdigest()
path = project/"results"/"freeze"/f"{stage}.json"
if path.exists() and read_json(path)!=frozen:11 unmodified lines121314151516171896 unmodified lines1151161171181191201219 unmodified lines1311321331331341351361371381391401419 unmodified lines15115215315415515615715815916016116216316431 unmodified lines19619719819920020120219320320420520610 unmodified lines21721821922022122222311 unmodified linesfrom filelock import FileLock
from .evaluation import sample_outputs, score, unigram_distribution
from .models import build_model, export_weights
from .models import build_model, export_weights, trainable_digest
from .objectives import add_penalty, calibrate, ce_backward
from .records import (BATCHES, CONTEXT, HORIZONS, RATIOS, Recorder, json_lines, read_json,
run_name, sha256, time_now, write_json)96 unmodified lines write_json(log,history)
if marker.exists():
remember(read_json(marker))
marker.unlink()
try:
return _run(project, storage, config, recorder, device, microbatch)
except Exception as exc:9 unmodified lines manifest = read_json(data/"manifest.json")
config["data_manifest_sha256"] = sha256(data/"manifest.json")
config["microbatch"] = microbatch
config["coefficients"] = chosen_coefficients(project,storage,config,device,microbatch)
output = recorder.directory
state_path = output/"state.json"
if not (output/"summary.json").exists():
write_json(state_path,{**config,"status":"initializing","timestamp":time_now()})
config["coefficients"] = chosen_coefficients(project,storage,config,device,microbatch)
if (output/"config.json").exists() and read_json(output/"config.json") != config:
raise ValueError(f"Existing run configuration conflicts with {config['id']}")
write_json(output/"config.json",config)9 unmodified lines parameters = tuple(p for p in model.parameters() if p.requires_grad) if model is not None else ()
summary = {**config, "device":str(device), "torch":str(torch.__version__), "platform":platform.platform(),
"gpu":torch.cuda.get_device_name(device) if device.type=="cuda" else None,
"initial_trainable_sha256":trainable_digest(model) if model is not None else None,
"git_revision":subprocess.check_output(["git","rev-parse","HEAD"],cwd=project,text=True).strip(),
"trainable_parameters":sum(p.numel() for p in parameters)}
batch = BATCHES[stage]
steps = budget//(batch*CONTEXT)
elapsed = 0.0
if budget:
write_json(state_path,{"status":"training","timestamp":time_now()})
windows = TrainingWindows(data/"train.bin",seed,batch)
groups = [{"params":[p for p in parameters if p.ndim>1],"weight_decay":0.1},
{"params":[p for p in parameters if p.ndim<=1],"weight_decay":0.0}]31 unmodified lines save_state(ckpt/"latest.pt",model,optimizer,done,elapsed,config)
del optimizer
dist = unigram_distribution(data/"train.bin",4096 if stage=="stories" else 50304) if method=="unigram" else None
write_json(state_path,{"status":"scoring development","timestamp":time_now()})
def evaluation_progress(row):
write_json(state_path,{"status":"scoring development",**row})
recorder.emit({"split":"dev",**row},"evaluation.jsonl")
validation = score(model,data/"dev.bin",device,microbatch,unigram=dist)
validation = score(model,data/"dev.bin",device,microbatch,unigram=dist,progress=evaluation_progress)
# A rerun after final-checkpoint interruption writes each documented sample exactly once.
sample_path = output/"samples.jsonl"
if sample_path.exists():10 unmodified lines dev_nll=validation["nll"],dev_accuracy=validation["accuracy"],dev_tokens=validation["tokens"],
finished_at=time_now(),status="complete")
write_json(summary_path,summary)
state_path.unlink(missing_ok=True)
(output/"failure.json").unlink(missing_ok=True)
print(f"Completed {config['id']} development NLL {summary['dev_nll']:.6f}",flush=True)
return summary78 unmodified lines7980818283848578 unmodified lines store2 = tmp_path/"store2"
shutil.copytree(root/"data",store2/"data")
normal = train.run_one(reference,store2,"stories","third","smoke",seed,0.03,torch.device("cpu"))
assert normal["initial_trainable_sha256"] == resumed["initial_trainable_sha256"]
rel = f"checkpoints/{normal['id']}/export/model.safetensors"
first, second = load_file(str(root/rel)),load_file(str(store2/rel))
for name in first:.gitattributes+1
research/docs/explorer.js+5-1
research/docs/figures/curves.png


research/docs/runbook.md+2
research/docs/study.json
research/reports/experiments/abstracts-pilot-s00-third-r03/experiment.md+2-2
research/reports/experiments/abstracts-pilot-s00-third-r03/learnings.md+1-1
research/reports/experiments/experiments.md+1-1
research/reports/experiments/learnings.md+1-1
research/reports/paper.pdf
research/reports/progress.md+2-2
research/results/abstracts-pilot-s00-third-r03/attempts.jsonAdded+8
research/results/abstracts-pilot-s00-third-r03/config.jsonAdded+16
research/results/abstracts-pilot-s00-third-r03/events.jsonlAdded+22
research/results/calibration/abstracts-third.jsonAdded+152
research/results/verification/pythia-initializations.jsonAdded+9
research/results/verification/pythia-window-comparison.jsonAdded+12
research/src/thirdloss/cli.py+9-1
research/src/thirdloss/evaluation.py+12-1
research/src/thirdloss/models.py+11
research/src/thirdloss/probe_check.pyAdded+61
research/src/thirdloss/report_records.py+10-4
research/src/thirdloss/study.py+7
research/src/thirdloss/train.py+14-3
research/tests/test_training.py+1