Automated push from Zaratan
Browse filesFiles changed (28)
- README.md+20-5
- figures/beat_d12.json+12-11
- figures/beat_d16.json+1
- figures/fig3_depth_scaling.png
- figures/seq_check_g13.jsonAdded+110
- figures/summary.md+20-5
- results/g14-d12-L2-s0.jsonAdded+39
- results/g14-d12-L2-s1.jsonAdded+39
- results/g14-d12-L3-s0.jsonAdded+39
- results/g14-d12-L3-s1.jsonAdded+39
- results/g14-d12-L4-s0.jsonAdded+39
- results/g14-d12-L4-s1.jsonAdded+39
- results/g14-d4-L12-s0.jsonAdded+39
- results/g14-d4-L12-s1.jsonAdded+39
- results/g14-d8-L6-s0.jsonAdded+39
- results/g14-d8-L6-s1.jsonAdded+39
- results/g14-d8-L8-s0.jsonAdded+39
- results/g14-d8-L8-s1.jsonAdded+39
- results/g15-german-distill-s0.jsonAdded+36
- results/g15-german-matched-s0.jsonAdded+36
- results/g15-german-matched-s1.jsonAdded+36
- slurm/g18.shAdded+38
- slurm/t8b.shAdded+26
- src/beat_baselines.py+7-6
- src/diffusion.py+114-6
- src/model.py+31-2
- src/train_add.py+27-5
- src/train_text8.py+22-7
51 unmodified lines525354555657585960616246 unmodified lines1091101111091101111121121131141151161171181191 unmodified line12112212312012412512612712812913013113213313413513613713813914051 unmodified lines| georgian | 93.9 | 93.9 | +0.0 || german | 78.9 | 79.3 | +0.4 || german | 75.6 | 79.5 | +3.9 || german | 78.6 | 78.9 | +0.3 || german | 78.9 | 79.3 | +0.4 || german | 77.9 | 78.0 | +0.1 || german | 79.4 | 81.0 | +1.7 || german | 76.5 | 77.6 | +1.0 || german | 75.6 | 79.5 | +3.9 || german | 76.4 | 78.9 | +2.5 || german | 77.2 | 78.3 | +1.0 |46 unmodified lines
The account in THEORY.md predicts minimum depth growing as log2(n), since the carry is a prefix scan. A ripple-carry account predicts linear growth; an impossibility account predicts no depth suffices.
| digits | 2L | 3L | 4L | 6L | 8L | log2(n) | min depth >90% ||---|---|---|---|---|---|---|---|| **4** | 100 | 100 | 100 | 100 | 100 | 2.0 | 2 || **8** | 99 | 100 | – | – | – | 3.0 | 2 || digits | 2L | 3L | 4L | 6L | 8L | 12L | log2(n) | min depth >90% ||---|---|---|---|---|---|---|---|---|| **4** | 100 | 100 | 100 | 100 | 100 | 100 | 2.0 | 2 || **8** | 99 | 100 | 100 | 100 | 100 | – | 3.0 | 2 || **12** | 48 | 100 | 100 | – | – | – | 3.6 | 3 |
## Table 7 — Which component carries the gain (inflection)
1 unmodified line|---|---|---|---|---|---|| finnish | 51.4 | – | – | 51.9 | +7.7 / – / – / +4.9 || georgian | 94.6 | – | – | 94.1 | -0.0 / – / – / -0.0 || german | 76.0 | – | – | 78.4 | +3.2 / – / – / +0.2 || german | 76.0 | 77.9 | 78.6 | 78.4 | +3.2 / +1.4 / +0.3 / +0.2 || navajo | 28.0 | – | – | 26.9 | +8.0 / – / – / +4.5 || russian | 71.6 | – | – | 72.3 | +2.2 / – / – / -0.3 || turkish | 78.7 | – | – | 82.3 | +3.5 / – / – / +0.8 |
## Table 9 — Did the baseline fail to parallelise, or fail to learn?
A 20-digit answer occupies 21 slots, so the standard 16-pass grid is not a sequential decode. Re-decoded at one token per pass, the two explanations separate.
| digits | mode | @1 pass | fully sequential | reading ||---|---|---|---|---|| 20 | full | 99.8 | 85.7 | learned it and parallelises || 20 | mdlm | 0.0 | 0.0 | never learned the task || 24 | full | 33.7 | 33.3 | learned it and parallelises || 24 | mdlm | 0.0 | 0.0 | never learned the task |
3 unmodified lines4567789101112131414151617181920212221222324252627282829303031323334353637343536373839405 unmodified lines46474849505151525354553 unmodified lines "confidence": [ 0.766875, 0.764375, 0.7637499999999999, 0.76375, 0.763125, 0.7625 ], "entropy": [ 0.766875, 0.764375, 0.7637499999999999, 0.76375, 0.763125, 0.7625 ], "entropy-gated": [ 0.766875, 0.764375, 0.7637499999999999, 0.7618750000000001, 0.76375, 0.761875, 0.7625 ], "margin": [ 0.766875, 0.764375, 0.7637499999999999, 0.76375, 0.763125, 0.7618750000000001 0.761875 ], "random": [ 0.766875, 0.771875, 0.76875, 0.7675000000000001, 0.7637499999999999 0.764375, 0.768125, 0.770625, 0.76625 ] }, "ours": {5 unmodified lines 0.999375 ] }, "significance": {}, "summary": { "best_inference_1pass": 0.766875, "best_inference_any_budget": 0.771875, "best_inference_any_budget": 0.770625, "ours_1pass": 1.0 }}45 unmodified lines4647484950515245 unmodified lines 0.749375 ] }, "significance": {}, "summary": { "best_inference_1pass": 0.25, "best_inference_any_budget": 0.25,123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110[ { "run": "g13-d20-full-s0", "digits": 20, "mode": "full", "seed": 0, "slots": 20, "acc_1pass": 1.0, "acc_sequential": 1.0 }, { "run": "g13-d20-full-s1", "digits": 20, "mode": "full", "seed": 1, "slots": 20, "acc_1pass": 0.995, "acc_sequential": 0.5700000000000001 }, { "run": "g13-d20-full-s2", "digits": 20, "mode": "full", "seed": 2, "slots": 20, "acc_1pass": 1.0, "acc_sequential": 1.0 }, { "run": "g13-d20-mdlm-s0", "digits": 20, "mode": "mdlm", "seed": 0, "slots": 20, "acc_1pass": 0.0, "acc_sequential": 0.0 }, { "run": "g13-d20-mdlm-s1", "digits": 20, "mode": "mdlm", "seed": 1, "slots": 20, "acc_1pass": 0.0, "acc_sequential": 0.0 }, { "run": "g13-d20-mdlm-s2", "digits": 20, "mode": "mdlm", "seed": 2, "slots": 20, "acc_1pass": 0.0, "acc_sequential": 0.0 }, { "run": "g13-d24-full-s0", "digits": 24, "mode": "full", "seed": 0, "slots": 25, "acc_1pass": 1.0, "acc_sequential": 1.0 }, { "run": "g13-d24-full-s1", "digits": 24, "mode": "full", "seed": 1, "slots": 25, "acc_1pass": 0.01, "acc_sequential": 0.0 }, { "run": "g13-d24-full-s2", "digits": 24, "mode": "full", "seed": 2, "slots": 25, "acc_1pass": 0.0, "acc_sequential": 0.0 }, { "run": "g13-d24-mdlm-s0", "digits": 24, "mode": "mdlm", "seed": 0, "slots": 25, "acc_1pass": 0.0, "acc_sequential": 0.0 }, { "run": "g13-d24-mdlm-s1", "digits": 24, "mode": "mdlm", "seed": 1, "slots": 25, "acc_1pass": 0.0, "acc_sequential": 0.0 }, { "run": "g13-d24-mdlm-s2", "digits": 24, "mode": "mdlm", "seed": 2, "slots": 25, "acc_1pass": 0.0, "acc_sequential": 0.0 }]34 unmodified lines353637383940414243444546 unmodified lines9293949293949595969798991001011021 unmodified line10410510610310710810911011111211311411511611711811912012112234 unmodified lines| georgian | 93.9 | 93.9 | +0.0 || german | 78.9 | 79.3 | +0.4 || german | 75.6 | 79.5 | +3.9 || german | 78.6 | 78.9 | +0.3 || german | 78.9 | 79.3 | +0.4 || german | 77.9 | 78.0 | +0.1 || german | 79.4 | 81.0 | +1.7 || german | 76.5 | 77.6 | +1.0 || german | 75.6 | 79.5 | +3.9 || german | 76.4 | 78.9 | +2.5 || german | 77.2 | 78.3 | +1.0 |46 unmodified lines
The account in THEORY.md predicts minimum depth growing as log2(n), since the carry is a prefix scan. A ripple-carry account predicts linear growth; an impossibility account predicts no depth suffices.
| digits | 2L | 3L | 4L | 6L | 8L | log2(n) | min depth >90% ||---|---|---|---|---|---|---|---|| **4** | 100 | 100 | 100 | 100 | 100 | 2.0 | 2 || **8** | 99 | 100 | – | – | – | 3.0 | 2 || digits | 2L | 3L | 4L | 6L | 8L | 12L | log2(n) | min depth >90% ||---|---|---|---|---|---|---|---|---|| **4** | 100 | 100 | 100 | 100 | 100 | 100 | 2.0 | 2 || **8** | 99 | 100 | 100 | 100 | 100 | – | 3.0 | 2 || **12** | 48 | 100 | 100 | – | – | – | 3.6 | 3 |
## Table 7 — Which component carries the gain (inflection)
1 unmodified line|---|---|---|---|---|---|| finnish | 51.4 | – | – | 51.9 | +7.7 / – / – / +4.9 || georgian | 94.6 | – | – | 94.1 | -0.0 / – / – / -0.0 || german | 76.0 | – | – | 78.4 | +3.2 / – / – / +0.2 || german | 76.0 | 77.9 | 78.6 | 78.4 | +3.2 / +1.4 / +0.3 / +0.2 || navajo | 28.0 | – | – | 26.9 | +8.0 / – / – / +4.5 || russian | 71.6 | – | – | 72.3 | +2.2 / – / – / -0.3 || turkish | 78.7 | – | – | 82.3 | +3.5 / – / – / +0.8 |
## Table 9 — Did the baseline fail to parallelise, or fail to learn?
A 20-digit answer occupies 21 slots, so the standard 16-pass grid is not a sequential decode. Re-decoded at one token per pass, the two explanations separate.
| digits | mode | @1 pass | fully sequential | reading ||---|---|---|---|---|| 20 | full | 99.8 | 85.7 | learned it and parallelises || 20 | mdlm | 0.0 | 0.0 | never learned the task || 24 | full | 33.7 | 33.3 | learned it and parallelises || 24 | mdlm | 0.0 | 0.0 | never learned the task |
123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 12, "seq_len": 40, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 2, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 0, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d12-L2-s0" }, "accuracy_by_passes": { "1": 0.0125, "2": 0.0125, "3": 0.0175, "4": 0.02, "6": 0.02, "8": 0.015, "12": 0.0175, "16": 0.0175 }, "minutes": 7.428513753414154, "compute": { "params": 3557376, "train_tokens": 307200000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 12, "seq_len": 40, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 2, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 1, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d12-L2-s1" }, "accuracy_by_passes": { "1": 0.9450000000000001, "2": 0.9724999999999999, "3": 0.985, "4": 0.9975, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 7.385485406716665, "compute": { "params": 3557376, "train_tokens": 307200000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 12, "seq_len": 40, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 3, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 0, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d12-L3-s0" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 9.707445001602172, "compute": { "params": 5330304, "train_tokens": 307200000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 12, "seq_len": 40, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 3, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 1, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d12-L3-s1" }, "accuracy_by_passes": { "1": 0.9975, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 9.8550892273585, "compute": { "params": 5330304, "train_tokens": 307200000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 12, "seq_len": 40, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 4, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 0, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d12-L4-s0" }, "accuracy_by_passes": { "1": 0.9975, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 12.583855005105336, "compute": { "params": 7103232, "train_tokens": 307200000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 12, "seq_len": 40, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 4, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 1, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d12-L4-s1" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 12.607550446192423, "compute": { "params": 7103232, "train_tokens": 307200000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 4, "seq_len": 16, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 12, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 0, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d4-L12-s0" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 31.564673300584158, "compute": { "params": 21286656, "train_tokens": 122880000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 4, "seq_len": 16, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 12, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 1, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d4-L12-s1" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 30.931939947605134, "compute": { "params": 21286656, "train_tokens": 122880000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 8, "seq_len": 28, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 6, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 0, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d8-L6-s0" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 17.343261142571766, "compute": { "params": 10649088, "train_tokens": 215040000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 8, "seq_len": 28, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 6, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 1, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d8-L6-s1" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 17.595031853516897, "compute": { "params": 10649088, "train_tokens": 215040000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 8, "seq_len": 28, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 8, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 0, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d8-L8-s0" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 22.44843115409215, "compute": { "params": 14194944, "train_tokens": 215040000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536373839{ "args": { "mode": "full", "K_max": 16, "K": 4, "lam": 1.0, "digits": 8, "seq_len": 28, "n_train": 800000, "n_eval": 400, "eval_bs": 100, "d": 384, "layers": 8, "heads": 6, "pe": "rope", "bs": 128, "steps": 60000, "lr": 0.0001, "warmup": 4000, "seed": 1, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g14-d8-L8-s1" }, "accuracy_by_passes": { "1": 1.0, "2": 1.0, "3": 1.0, "4": 1.0, "6": 1.0, "8": 1.0, "12": 1.0, "16": 1.0 }, "minutes": 21.78090745608012, "compute": { "params": 14194944, "train_tokens": 215040000, "fwd_per_step": 2 }}123456789101112131415161718192021222324252627282930313233343536{ "args": { "lang": "german", "size": "medium", "mode": "distill", "seq_len": 48, "d": 256, "layers": 6, "heads": 8, "pe": "rope", "bs": 64, "steps": 15000, "lr": 0.0001, "warmup": 1000, "K": 4, "lam": 1.0, "seed": 0, "data_root": "/scratch/zt1/project/msml612/user/govind02/pcmd/data/sig", "eval_bs": 128, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g15-german-distill-s0" }, "accuracy_by_passes": { "1": 0.7861328125, "2": 0.7795703125, "4": 0.783203125, "8": 0.788359375, "16": 0.7893359375, "32": 0.7893359375, "ar": 0.0776171875 }, "minutes": 4.292282120386759, "compute": { "params": 4776448, "answer_len_mean": 10.743975639343262 }}123456789101112131415161718192021222324252627282930313233343536{ "args": { "lang": "german", "size": "medium", "mode": "matched", "seq_len": 48, "d": 256, "layers": 6, "heads": 8, "pe": "rope", "bs": 64, "steps": 15000, "lr": 0.0001, "warmup": 1000, "K": 4, "lam": 1.0, "seed": 0, "data_root": "/scratch/zt1/project/msml612/user/govind02/pcmd/data/sig", "eval_bs": 128, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g15-german-matched-s0" }, "accuracy_by_passes": { "1": 0.793515625, "2": 0.7919921875, "4": 0.796171875, "8": 0.8094140625, "16": 0.810390625, "32": 0.810390625, "ar": 0.080546875 }, "minutes": 2.4515843311945598, "compute": { "params": 4776448, "answer_len_mean": 10.743975639343262 }}123456789101112131415161718192021222324252627282930313233343536{ "args": { "lang": "german", "size": "medium", "mode": "matched", "seq_len": 48, "d": 256, "layers": 6, "heads": 8, "pe": "rope", "bs": 64, "steps": 15000, "lr": 0.0001, "warmup": 1000, "K": 4, "lam": 1.0, "seed": 1, "data_root": "/scratch/zt1/project/msml612/user/govind02/pcmd/data/sig", "eval_bs": 128, "out": "/scratch/zt1/project/msml612/user/govind02/pcmd/runs/g15-german-matched-s1" }, "accuracy_by_passes": { "1": 0.7653515625, "2": 0.7673046875, "4": 0.776640625, "8": 0.7758203125, "16": 0.7758203125, "32": 0.7758203125, "ar": 0.0721875 }, "minutes": 2.444871123631795, "compute": { "params": 4776448, "answer_len_mean": 10.743975639343262 }}1234567891011121314151617181920212223242526272829303132333435363738#!/bin/bash# Grid 18 - does budget conditioning remove the crossover?## At 20 digits, same config as g13, we already have both endpoints measured:# mdlm 0.0 @1 pass, 0.0 @sequential (never learned the task)# full 99.8 @1 pass, 85.7 @sequential (wins at 1, LOSES at 20)# so this grid only needs the two new arms to complete a 4-way comparison at a# single configuration.## anybudget sample K per example AND condition the model on it# anybudget_nc sample K identically but do NOT condition - the ablation that# separates "mixing budgets" from "knowing the budget"## Prediction: anybudget is strong at BOTH ends; anybudget_nc improves the# sequential end but gives back the one-pass end, because without conditioning# one set of weights has to serve contradictory targets.#SBATCH -J g18#SBATCH -p gpu-h100#SBATCH --gpus=h100:1#SBATCH -c 8#SBATCH --mem=64g#SBATCH -t 8:00:00#SBATCH -o logs/g18-%A_%a.out#SBATCH --array=0-5%6source /etc/profileSCR=/scratch/zt1/project/msml612/user/$USERmodule load python/3.10.10export PYTHONPATH=cd $SCR/pcmd/srcMODES=(anybudget anybudget_nc); SEEDS=(0 1 2)I=$SLURM_ARRAY_TASK_IDM=${MODES[$((I / 3))]}; S=${SEEDS[$((I % 3))]}NAME="g18-d20-$M-s$S"echo "=== $NAME ==="$SCR/hf_env/bin/python -u train_add.py --mode $M --digits 20 --seq_len 64 --seed $S \ --n_train 1500000 --n_eval 400 --eval_bs 100 \ --d 512 --layers 12 --heads 8 --bs 128 --steps 150000 --lr 1e-4 --warmup 6000 \ --out $SCR/pcmd/runs/$NAME1234567891011121314151617181920212223242526#!/bin/bash# The capstone experiment: does the training-side fix compose with the# inference-side fix on data that contains BOTH failure modes at once?#SBATCH -J t8#SBATCH -p gpu-h100#SBATCH --gpus=h100:1#SBATCH -c 8#SBATCH --mem=64g#SBATCH -t 16:00:00#SBATCH -o logs/t8-%A_%a.out#SBATCH --array=0-5source /etc/profileSCR=/scratch/zt1/project/msml612/user/$USERmodule load python/3.10.10export PYTHONPATH=cd $SCR/pcmd/srcMODES=(mdlm matched anybudget); SEEDS=(0 1)I=$SLURM_ARRAY_TASK_IDM=${MODES[$((I / 2))]}; S=${SEEDS[$((I % 2))]}NAME="t8-$M-s$S"echo "=== $NAME ==="$SCR/hf_env/bin/python -u train_text8.py --mode $M --seed $S \ --root $SCR/pcmd/data/text8 --seq_len 256 \ --d 512 --layers 12 --heads 8 --bs 128 --steps 60000 --lr 1e-4 --warmup 4000 \ --K 8 --lam 1.0 --n_gen 256 --gen_bs 64 \ --evallm $SCR/pcmd/runs/evallm --out $SCR/pcmd/runs/$NAME137 unmodified lines138139140141141142143144145146147143144145146147148149150151152137 unmodified linesITEMS = {}for strat, tau in [("confidence", None), ("entropy", None), ("entropy-gated", 0.5), ("margin", None), ("random", None)]: row = [] row, row_items = [], [] for steps in (1, 2, 4, 8, 16): vals = [] for d in base_dirs: m, _ = load(d) vals.append(run(m, steps, "entropy" if strat == "entropy-gated" else strat, tau)) row.append(float(np.mean(vals))) vals = [run(load(d)[0], steps, "entropy" if strat == "entropy-gated" else strat, tau) for d in base_dirs] per = np.mean(np.stack(vals), axis=0) # per-item, averaged over seeds row.append(float(per.mean())); row_items.append(per) results["inference_time_on_baseline"][strat] = row ITEMS[strat] = row_items print(f"{strat:<22}" + "".join(f"{v*100:8.1f}" for v in row))
row, ours_items = [], []531 unmodified lines53253353453553553653753817 unmodified lines55655755855955956056156215 unmodified lines57857958058158158258358412 unmodified lines59759859960060060160260312 unmodified lines6166176186196196206216226238 unmodified lines63263363463463563663763853 unmodified lines692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801531 unmodified lines
@torch.no_grad()def entropy_budget_decode(model, x, tok, device, budget=0.5, max_steps=256, temperature=1.0, fillable=None): temperature=1.0, fillable=None, budget_cond=None): """FIX (ii): commit a set whose summed conditional entropy stays under `budget`.
At each pass, rank the still-masked positions by conditional entropy and17 unmodified lines has = masked.any(1) if not has.any(): break logits = model(x) logits = model(x, budget=budget_cond) nfe += 1 if temperature != 1.0: logits = logits / temperature15 unmodified lines
@torch.no_grad()def confidence_threshold_decode(model, x, tok, device, tau=0.9, max_steps=256, temperature=1.0, fillable=None): temperature=1.0, fillable=None, budget_cond=None): """The published inference-time competitor (confidence-threshold family).
Commit every masked position whose top-1 probability exceeds `tau`. This is12 unmodified lines has = masked.any(1) if not has.any(): break logits = model(x) logits = model(x, budget=budget_cond) nfe += 1 if temperature != 1.0: logits = logits / temperature12 unmodified lines
@torch.no_grad()def fixed_k_decode(model, x, tok, device, steps, temperature=1.0, fillable=None):def fixed_k_decode(model, x, tok, device, steps, temperature=1.0, fillable=None, budget_cond=None): """Plain K-pass decoding: reveal an equal share of positions per pass, highest-confidence first. The non-adaptive reference point, and the setting in which the addition results are reported."""8 unmodified lines has = masked.any(1) if not has.any(): break logits = model(x) logits = model(x, budget=budget_cond) nfe += 1 if temperature != 1.0: logits = logits / temperature53 unmodified lines return uncond_mdlm_loss(model, x0, tok, "matched", K) base = uncond_mdlm_loss(model, x0, tok, "matched", K) return base + lam * uncond_mdlm_loss(model, x0, tok, "matched", 2)
# ------------------------------------------------ any-budget masked diffusion ---# The limitation the fixed-K method has, stated plainly: training at a single K# is a COMMITMENT to one decoding budget. Measured on 20-digit addition, a model# trained for one pass scores 99.8% at one pass and 85.7% at twenty - the# baseline's own disease with the roles swapped, because intermediate# partially-decoded states are themselves off-distribution for it.## That makes a fixed-K method unable to dominate a quality-vs-compute frontier:# it wins at K and loses away from K. Since the frontier is precisely the axis# the parallel-decoding literature competes on, fixing this is what turns a# single good operating point into a curve that dominates.## The fix: sample K during training and TELL the model which K it is being# trained for. One network then serves every budget. Cost is one embedding# lookup and no extra forward passes, so it is cheaper than the fixed-K method# it replaces.
BUDGETS = (1, 2, 4, 8, 16, 32, 64, 128, 256)
def sample_budget(B, device, choices=BUDGETS, weights=None): """Draw a decoding budget per example.
Per-example rather than per-batch so a single step covers many budgets, which keeps the gradient signal for every bin alive at every step. """ c = torch.as_tensor(choices, device=device, dtype=torch.float) if weights is None: idx = torch.randint(0, len(c), (B,), device=device) else: w = torch.as_tensor(weights, device=device, dtype=torch.float) idx = torch.multinomial(w.expand(B, -1), 1).squeeze(1) return c[idx]
def _t_for_budget(K): """Draw t from the mask ratios a K-pass decode actually visits.
A K-pass decode evaluates the model at {1, (K-1)/K, ..., 1/K}. Drawing the step index uniformly in [1, K] and dividing reproduces exactly that set, including the atom at t = 1 that continuous U(0,1) never supplies. """ step = (torch.rand_like(K) * K).floor() + 1.0 return (step / K).clamp(1e-6, 1.0)
def cond_any_budget_loss(model, x0, amask, tok, choices=BUDGETS, condition=True): """Any-budget objective for conditional tasks (addition, inflection).""" B = x0.shape[0] dev = x0.device K = sample_budget(B, dev, choices) t = _t_for_budget(K)
m = _cond_mask(x0, amask, tok, t) xt = torch.where(m, torch.full_like(x0, tok.mask), x0) logits = model(xt, budget=K if condition else None) ce = F.cross_entropy(logits.reshape(-1, logits.size(-1)), x0.reshape(-1), reduction="none").view(B, -1) return ((ce * m).sum(1) / m.sum(1).clamp_min(1)).mean()
def uncond_any_budget_loss(model, x0, tok, choices=BUDGETS, condition=True): """Any-budget objective for unconditional text.
Keeps the 1/t ELBO weighting so that, with a uniform-t schedule and no conditioning, this reduces exactly to the published MDLM objective. """ B, L = x0.shape dev = x0.device K = sample_budget(B, dev, choices) t = _t_for_budget(K)
m = torch.rand(B, L, device=dev) < t[:, None] m[torch.arange(B, device=dev), torch.randint(0, L, (B,), device=dev)] = True xt = torch.where(m, torch.full_like(x0, tok.mask), x0) logits = model(xt, budget=K if condition else None) ce = F.cross_entropy(logits.reshape(-1, logits.size(-1)), x0.reshape(-1), reduction="none").view(B, L) return ((1.0 / t) * (ce * m).sum(1) / L).mean()
@torch.no_grad()def cond_decode_budget(model, x0, amask, tok, steps, device, condition=True): """`cond_decode`, but the model is told the budget it is being run at.""" x = torch.where(amask, torch.full_like(x0, tok.mask), x0).to(device) am = amask.to(device) B, L = x.shape n_ans = int(am[0].sum()) bud = torch.full((B,), float(steps), device=device) if condition else None pred = None for s in range(steps, 0, -1): masked = (x == tok.mask) & am if not masked.any(): break conf, pred = real_probs(model(x, budget=bud), tok).max(-1) conf = conf.masked_fill(~masked, -1e9) left = int(n_ans * (s - 1) / steps) for b in range(B): k = max(0, int(masked[b].sum()) - left) if k: x[b, conf[b].topk(k).indices] = pred[b, conf[b].topk(k).indices] rem = (x == tok.mask) & am if rem.any() and pred is not None: x[rem] = pred[rem] return x92 unmodified lines939495969697989910010110210310410510610710810911011111211311415 unmodified lines13013113213313413513613713813914014114214314412114514614714814915015115215315415592 unmodified lines
class Transformer(nn.Module): def __init__(self, vocab, d=384, n_layers=6, n_heads=6, pe="ape", causal=False, max_len=256): def __init__(self, vocab, d=384, n_layers=6, n_heads=6, pe="ape", causal=False, max_len=256, budget_bins=0): super().__init__() self.pe_kind, self.causal = pe, causal self.budget_bins = budget_bins self.emb = nn.Embedding(vocab, d) # Budget conditioning. A K-pass decode only visits mask ratios # {1, (K-1)/K, ..., 1/K}, so a model trained for one K is mis-specified # at every other K - measured directly: our 20-digit model scores 99.8% # at one pass and 85.7% at twenty. Telling the model which budget it is # being decoded at lets ONE network serve every budget instead of a # family of networks each good at a single point. # budget_bins=0 keeps the parameter absent entirely, so checkpoints # trained before this existed still load. if budget_bins: self.budget_emb = nn.Embedding(budget_bins, d) # Segment embedding: which part of the equation a token belongs to. # Place-value ids deliberately collide across operands and answer, so a # bidirectional model needs this to tell those tokens apart; a causal15 unmodified lines if isinstance(m, nn.Linear) and m.bias is not None: nn.init.zeros_(m.bias)
@staticmethod def budget_bin(K, n_bins, device): """Map a decoding budget K to a bin index by log2, clamped.
Budgets are used on a log scale (1, 2, 4, ... L), so log2 is the natural parameterisation and keeps the table small. """ if not torch.is_tensor(K): K = torch.as_tensor(K, device=device) K = K.to(device).float().clamp_min(1.0) return torch.log2(K).round().long().clamp_(0, n_bins - 1)
def forward(self, idx, pad_mask=None, pos_ids=None): def forward(self, idx, pad_mask=None, pos_ids=None, budget=None): B, L = idx.shape x = self.emb(idx) if self.budget_bins and budget is not None: b = self.budget_bin(budget, self.budget_bins, idx.device) if b.ndim == 0: b = b.expand(B) x = x + self.budget_emb(b)[:, None, :] if self.pe_kind == "ape": p = torch.arange(L, device=idx.device)[None] if pos_ids is None else pos_ids x = x + self.pos(p)19 unmodified lines202122232423242526272829303132333429 unmodified lines6465666768697071727374757677787964808182836884858687889 unmodified lines98991001011028510310410510610713 unmodified lines12112212312412512612712812919 unmodified lines
def get_args(): p = argparse.ArgumentParser() p.add_argument("--mode", choices=["mdlm", "matched", "distill", "full", "prog"], default="mdlm", help="prog = parallelism curriculum (the method)") p.add_argument("--mode", choices=["mdlm", "matched", "distill", "full", "prog", "anybudget", "anybudget_nc"], default="mdlm", help="anybudget = sample K and condition on it (the method); " "anybudget_nc = same K sampling WITHOUT conditioning, " "the ablation that isolates what conditioning buys") p.add_argument("--budget_bins", type=int, default=10, help="log2 bins for budget conditioning; 0 disables") p.add_argument("--K_max", type=int, default=16) p.add_argument("--K", type=int, default=8, help="parallelism the schedule is matched to") p.add_argument("--lam", type=float, default=1.0, help="one-pass supervision weight")29 unmodified lines
@torch.no_grad()def evaluate(model, a, tok, device): """Accuracy across the whole pass grid.
The grid now runs out to a FULLY SEQUENTIAL decode (one token per pass), not just 16: a 20-digit answer has 21 slots, so stopping at 16 never measures sequential decoding at all and cannot tell "failed to parallelise" apart from "failed to learn". """ model.eval() out = {} X, A, _ = build_addition(a.n_eval, a.digits, a.seq_len, seed=90_000, exact=True) X, A = torch.from_numpy(X), torch.from_numpy(A) cond = getattr(model, "budget_bins", 0) > 0 grid = sorted(set(PASS_GRID) | {int(A[0].sum())}) for steps in PASS_GRID: for steps in grid: accs = [] for i in range(0, len(X), a.eval_bs): xb, ab = X[i:i + a.eval_bs].to(device), A[i:i + a.eval_bs].to(device) pred = dfn.cond_decode(model, xb, ab, tok, steps, device) pred = (dfn.cond_decode_budget(model, xb, ab, tok, steps, device) if cond else dfn.cond_decode(model, xb, ab, tok, steps, device)) accs.append(exact_match(pred.cpu(), xb.cpu(), ab.cpu(), tok)) out[str(steps)] = float(np.mean(accs)) model.train()9 unmodified lines X, A, tok = build_addition(a.n_train, a.digits, a.seq_len, seed=a.seed) X, A = torch.from_numpy(X), torch.from_numpy(A)
cond = a.mode == "anybudget" model = Transformer(len(tok), a.d, a.layers, a.heads, a.pe, causal=False, max_len=a.seq_len + 8).to(dev) causal=False, max_len=a.seq_len + 8, budget_bins=a.budget_bins if cond else 0).to(dev) print(f"[{a.mode}] params={model.n_params()/1e6:.2f}M digits<={a.digits} " f"K={a.K} device={dev}", flush=True)
13 unmodified lines if a.mode == "prog": loss, K_now, lam_now = dfn.pmd_progressive( model, xb, ab, tok, step / max(1, a.steps), a.K_max, a.lam) elif a.mode in ("anybudget", "anybudget_nc"): loss = dfn.cond_any_budget_loss(model, xb, ab, tok, condition=cond) else: loss = dfn.pmd_loss(model, xb, ab, tok, a.mode, a.K, a.lam) loss.backward()39 unmodified lines404142434344454647484923 unmodified lines7374757374767778798081824 unmodified lines878889909192859394959687 unmodified lines18418518618718818919019119219319419518319619719819920020118920220320420520620720819520921021121221339 unmodified lines
def get_args(): p = argparse.ArgumentParser() p.add_argument("--mode", choices=["mdlm", "matched", "full"], default="mdlm") p.add_argument("--mode", choices=["mdlm", "matched", "full", "anybudget", "anybudget_nc"], default="mdlm") p.add_argument("--budget_bins", type=int, default=10) p.add_argument("--K", type=int, default=8, help="parallelism the schedule is matched to") p.add_argument("--lam", type=float, default=1.0) p.add_argument("--root", default="data/text8")23 unmodified linesprint(f"text8: train {tr.shape} valid {va.shape} test {te.shape} vocab {len(tok)}", flush=True)
model = Transformer(len(tok), a.d, a.layers, a.heads, "rope", causal=False, max_len=a.seq_len + 8).to(dev)COND = a.mode == "anybudget"model = Transformer(len(tok), a.d, a.layers, a.heads, "rope", causal=False, max_len=a.seq_len + 8, budget_bins=a.budget_bins if COND else 0).to(dev)print(f"denoiser params: {sum(q.numel() for q in model.parameters())/1e6:.1f}M", flush=True)opt = torch.optim.AdamW(model.parameters(), lr=a.lr, weight_decay=0.01, betas=(0.9, 0.95))sched = torch.optim.lr_scheduler.LambdaLR(4 unmodified linesfor step in range(a.steps): x = torch.from_numpy(next(it)).to(dev) with torch.autocast("cuda", dtype=torch.bfloat16, enabled=(dev == "cuda")): if a.mode in ("anybudget", "anybudget_nc"): loss = dfn.uncond_any_budget_loss(model, x, tok, condition=COND) else: loss = dfn.text_loss(model, x, tok, a.mode, a.K, a.lam) loss = dfn.text_loss(model, x, tok, a.mode, a.K, a.lam) opt.zero_grad(set_to_none=True) loss.backward() torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)87 unmodified linesprint("\n=== decoding: quality against compute ===", flush=True)res["decode"] = {}
def bud(K): """The budget to declare to the model, or None if it is not conditioned.""" return (torch.full((a.gen_bs,), float(K), device=dev)) if COND else None
print("fixed-K (non-adaptive reference):", flush=True)for K in (1, 2, 4, 8, 16, 32, 64, 128, 256): res["decode"][f"fixedK_{K}"] = evaluate( f"fixed-K K={K}", lambda b, K=K: dfn.fixed_k_decode(model, b, tok, dev, K)) lambda b, K=K: dfn.fixed_k_decode(model, b, tok, dev, K, budget_cond=bud(K)))
print("confidence-threshold (published inference-time method):", flush=True)for tau in (0.5, 0.7, 0.9, 0.95, 0.99): res["decode"][f"conf_{tau}"] = evaluate( f"confidence tau={tau}", lambda b, tau=tau: dfn.confidence_threshold_decode(model, b, tok, dev, tau)) lambda b, tau=tau: dfn.confidence_threshold_decode( model, b, tok, dev, tau, budget_cond=bud(8)))
print("entropy-budget (ours, fix (ii)):", flush=True)for B in (0.05, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0): res["decode"][f"entbudget_{B}"] = evaluate( f"entropy-budget B={B}", lambda b, B=B: dfn.entropy_budget_decode(model, b, tok, dev, B)) lambda b, B=B: dfn.entropy_budget_decode( model, b, tok, dev, B, budget_cond=bud(8)))
torch.save(model.state_dict(), os.path.join(a.out, "model.pt"))json.dump(res, open(os.path.join(a.out, "result.json"), "w"), indent=2)README.md+20-5
figures/beat_d12.json+12-11
figures/beat_d16.json+1
figures/fig3_depth_scaling.png


figures/seq_check_g13.jsonAdded+110
figures/summary.md+20-5
results/g14-d12-L2-s0.jsonAdded+39
results/g14-d12-L2-s1.jsonAdded+39
results/g14-d12-L3-s0.jsonAdded+39
results/g14-d12-L3-s1.jsonAdded+39
results/g14-d12-L4-s0.jsonAdded+39
results/g14-d12-L4-s1.jsonAdded+39
results/g14-d4-L12-s0.jsonAdded+39
results/g14-d4-L12-s1.jsonAdded+39
results/g14-d8-L6-s0.jsonAdded+39
results/g14-d8-L6-s1.jsonAdded+39
results/g14-d8-L8-s0.jsonAdded+39
results/g14-d8-L8-s1.jsonAdded+39
results/g15-german-distill-s0.jsonAdded+36
results/g15-german-matched-s0.jsonAdded+36
results/g15-german-matched-s1.jsonAdded+36
slurm/g18.shAdded+38
slurm/t8b.shAdded+26
src/beat_baselines.py+7-6
src/diffusion.py+114-6
src/model.py+31-2
src/train_add.py+27-5
src/train_text8.py+22-7