Research record
Asmodeus०
A time traveller on a chronal fluid.
A softmax decider that answers alone, and goes back to an era when it needs that era's knowledge.
Measured only. This page shows what was measured, proved or checked. Every figure names its seeds, its control and its source file, and the limits are stated in full below.
Named for Laplace's demon, the intellect that, knowing the present state, could read any past or future from it. It came out of two earlier projects, resolvent and caustic, together.
The mechanism
It answers alone, and it goes back
From the inventor's notes: the softmax “is smart alone, but when he needs knowledge of a particular era he goes back in time.” Below, the project's own code runs on a stream whose law changes and comes back. Each colour is one law, and the era that holds it.
Press play, or drag the slider.
Every frame is a recorded value from zero/research/e0 (bed, era bank, momentum decider, α = 0.003) on one made-up 3,000-token stream. Top: the law in force. Middle: the weight w_t (grey is the window and changepoint experts, which carry much of it until an era has seen enough of a law), with a numbered ring where an unseen law gets a new era and an arc back to the earlier stretch where a returning law was last seen. Bottom: each era's 16×16 table of transition counts, outlined by the weight it holds. The traveller answers alone when one era holds at least 0.99; on this stream that is 30.5% of the steps. Regret on this one stream: 0.0232 nats per token over the oracle (a single stream, not the benchmark below).
How it works
The architecture, one token at a time
An era is a small model of one law: a 16×16 table of transition counts with a Dirichlet prior (a = 0.2), so a new token is added to it and nothing else is touched. The traveller holds only a weight over eras and two tail experts, a short window and a changepoint model for laws no era has seen. It keeps no raw past. For each token x_t:
-
Move
A share α = 0.003 of the weight moves. Half spreads evenly, half follows a learned era-to-era kernel Q, so where the traveller came from predicts where it goes.
v = (1-α)·w + (α/2)/|s| + (α/2)·w_eras·Qdeciders.py:53-62 -
Answer
The answer is the weighted blend of the eras' predictions. If one expert holds at least 0.99 of the weight it answers alone, and no other table is consulted.
p = Σ v(i)·P_i(x_t | x_t-1)
deciders.py:21-22, 121-126 -
Multiply, then normalise
The token that arrived scales each weight by that era's likelihood of it, and the result is renormalised. This Bayes step is the whole memory of the traveller.
w = v ⊙ P(x_t) / Σ v ⊙ P(x_t)
deciders.py:24-29 -
Credit and watch
The token goes into the active era's table. A mixture e-detector watches that era, and by Ville's inequality its false alarms stay below δ = 0.05.
S_t = (S_t-1 + 1/(n(n+1)))·e_t alarm if S_t + 1/(n+1) ≥ 1/δ
arms.py:106-123, 187 -
Jump or birth
On an alarm, with at least 64 transitions of evidence, the recent window is scored under every stored era and under a fresh one. A stored era wins: jump, and the switch is counted into Q. A fresh era wins: birth, and every older table stays as it was.
best = argmax prequential log-likelihood of windowarms.py:196-228, deciders.py:79-81 -
Merge
Two eras that hold the same law fuse when the Dirichlet-multinomial Bayes factor favours one table. Their weights add.
log BF = ML(C+D) - ML(C) - ML(D) merge if log BF > 0
arms.py:236-242, deciders.py:36-38
| Piece | Without it, or with it |
|---|---|
| Era bank | A returning law costs 0.084 nats over the oracle, against 0.693 for BOCPD. |
| Forward filter | Regret 0.034, against 0.125 when the active era answers alone. |
| BOCPD novelty expert | Cost on streams where nothing recurs: 3.71× BOCPD without it, 1.18× with it. |
| Global merge, 64 transitions | 4 to 8 eras for 4 laws before; exactly 4 on 8 of 10 seeds after. |
| Momentum kernel Q | −5.6% regret against fixed share, on 10 of 10 paired seeds. |
| Answer-alone threshold | One era answers on 45.8% of steps, with no measurable loss. |
What has been measured
Regret against an oracle that knows the regime
Streams of 20,000 tokens over 16 symbols, with 4 recurring order-1 laws. Regret is nats per token above an oracle that knows the true regime. Every bar was frozen by sha256 before its result existed, and each round ran on seeds no earlier round had touched.
Both charts: the REC bed, 10 seeds (20–29), synthetic order-1 laws, V = 16. Control: the project's own baselines, tuned on separate tuning seeds (BOCPD is the strongest). Source: research/e0/RESULTS_E0c.md lines 10–14, read by gen_data.py into data.js. The bar B1 passes on 10 of 10 seeds (line 45).
Which way the weight should move
Seven deciders over the same era bank, scored on seeds 40–49 (mean over four beds). The momentum decider beats fixed share on 10 of 10 paired seeds; two others fail the gate that nothing may be lost when no law recurs.
| Decider | REC | CYC-S | NOREC | Score | Gate |
|---|---|---|---|---|---|
| MOM | 0.0262 | 0.1230 | 0.0170 | 0.0486 | pass |
| MOM+GB | 0.0277 | 0.1215 | 0.0170 | 0.0489 | pass |
| SOFT | 0.0268 | 0.1307 | 0.0184 | 0.0515 | pass |
| HARD | 0.0270 | 0.1308 | 0.0183 | 0.0516 | pass |
| TEMP | 0.0276 | 0.1251 | 0.0230 | 0.0516 | fail |
| CTC | 0.0282 | 0.1245 | 0.0238 | 0.0520 | fail |
| GBAYES | 0.0283 | 0.1302 | 0.0192 | 0.0523 | pass |
Against models that read the regime from context
The real competitor is in-context inference. The era bank keeps every regime's counts for the whole stream, while a transformer sees 512 tokens. On seeds 50–59 the era bank clears both frozen bars on 10 of 10 seeds. On recurring regimes it is at least 14.9× lower than the best neural arm on every seed (17× on the mean).
| Arm | Params | REC | CYC-S | NOREC |
|---|---|---|---|---|
| Asmodeus (era bank + MOM) | counts | 0.0272 | 0.1476 | 0.0185 |
| TF-META, meta-trained transformer | 862,992 | 0.4626 | 0.7054 | 0.1822 |
| GRU-ONLINE-L | 16,784 | 0.6875 | 0.6596 | 0.7497 |
| GRU-ONLINE-S | 1,904 | 0.7399 | 0.7165 | 0.7759 |
| GRU-META | 214,544 | 1.0225 | 1.0483 | 0.7135 |
r3: TinyStories at matched size and budget
The Era LM (a tensor-train network with an era bank and the momentum decider) against a transformer, a state-space model, a mixture of experts and linear attention, each at 5.82–5.95M parameters, on the same 1,000,000 training tokens: 1,500 steps, context 128, batch 64, AdamW at 3×10−3. Scored on the first 100,000 validation tokens, in nats per token. Lower is better.
Validation NLL during training
One line per seed (the second seed is fainter). Only runs that finished are drawn.
Final validation NLL, per seed
Filled dot: seed 0. Hollow dot: seed 1. Dotted line: the order-3 n-gram fitted on the same tokens.
Seeds per arm: . Control: the order-3 Jelinek–Mercer n-gram on the same tokens (3.632). Source: zero/parity/results/ts_{arm}_s{seed}.json, setup frozen in parity/ts_bench.py; one RTX 4060 laptop GPU. Read this chart with its limits: a single TinyStories subset, 1,500 steps and at most 2 seeds; the GPT baseline's two seeds differ by 0.41 nats (3.883 and 4.293), so it is under-tuned at this budget and the gap to it says nothing about transformers in general; the mixture of experts ran in fp32 (bf16 broke its router), the others in bf16; the linear-attention run diverged to NaN in bf16 at step 750, the cause is fixed in code and it was not re-run in this pilot; the Asmodeus-native arm ran at context 32 and 300 steps and is not comparable, so it is not drawn.
r3: engineering checks reached
| Check | Result | Source |
|---|---|---|
| Lean gate | 43 modules: no sorry (exit 0), full build (exit 0), axiom audit (exit 0) | lean/gate_r3.json |
| Regression ledger | exact test counts pinned: 188 tests over 15 test files | lm/regress.py, commit 83075fd |
| bf16 stability, E0 bed | 3 seeds, 100 steps each, every loss finite (final 2.714, 2.701, 2.728) | docs/specs/findings/N3_stab_e0_bf16.json |
| Linear-attention bf16 NaN | cause found (elu+1 is exactly 0 in bf16 for x ≤ −8, so 0/0); fix mutation-checked: old code 2 tests fail, fixed code 7 pass | RECONCILE.md “14:40” |
| Faster change alarm (behind a flag) | median detection lag 12, 4, 5, 7, 5, 9 tokens on seeds 50–55, against 36, 40, 35, 50, 38, 30 for the legacy alarm; numpy parity kept (see Limits for what it costs) | RECONCILE.md “14:57” |
| A bed today's read-out cannot fit | KL floor 0.03856, 0.03854, 0.03861, 0.03859, 0.03859 nats per pair on seeds 0–4 (bar ≥ 0.03; entropy 4.9206): the gap the next arm targets | parity/results/pair_rank_floor.json |
The reference code's 16 sanity tests pass (pytest -q test_e0.py, run for this page on the pinned commit). Wall time for one stream on a CPU: 7.8 s for the era bank.
What has been proved
The lemmas are in Lean, and the count is exact
Lean 4 v4.7.0 with a pinned Mathlib. Measured is not proved: a result is called proved here only when its lemma sits in the Lean tree.
lean/FCPA/, plus the index FCPA.leansorry, by the repo's own checker and by grepaxiom and native_decideadmit appears 6 times, all as the name of an ordinary function in L25_Grounding.lean that keeps only grounded data. It is not the tactic.
| Lemma | Claim | Status | Decls |
|---|---|---|---|
| L38 | Regret of the filter over a bank that grows by births and shrinks by merges, for any linear decider | proved, pathwise | 34 |
| L39 | The merge rule is the address rule applied to a whole era; the Bayes factor is an e-value | proved | 21 |
| L39c | log BF = −Div + Gain ± K: divergence linear in evidence, Occam gain logarithmic | proved; sampling bridge cited | 23 |
| L39d | Merging at BF ≥ (j+1)(j+2)/δ bounds false merges by δ; no uniform guarantee exists | proved | 14 |
| L40 | No forgetting for count eras, for settled tokens; the unconditional form is false | proved | 18 |
| L41 | Momentum is an HMM forward filter; a switch costs −log((α/2)Q) | proved | 11 |
| L41b | The learned kernel stays within (k−1) log(n+1) of the best fixed kernel | proved; rate cited | 7 |
| L42 | The log-space filter is exact; answering alone costs at most log(θ + (1−θ)/ε) a step | proved | 8 |
- The free-when-nothing-recurs gate is a theorem. It holds for α ≤ 0.0039 (fixed share) and α ≤ 0.0078 (momentum). The chosen α = 0.003 is inside both.
- The bound is nearly tight. With nothing recurring, momentum measured 0.0012–0.0015 nats per token over BOCPD, and the bound is 0.0016.
- One token cannot swing the weight far. It moves log w(i) by at most log(max P / min P).
- Cited, not proved: L10, L12, L18 (Ky Fan) and TT-1, the sampling bridge of the merge rule, and the convergence rate of the learned kernel. Mathlib v4.7.0 lacks the tools, and none is hidden behind a
sorry.
Limits
Where it stands, and what is not shown
- 0frame
- 1theory
- 2toy beds
- 3ablations
- 4controls
- 5Lean, in progress
- 6GPU engine, in build
- 7real text, next
- The mechanism evidence is synthetic. Every win on regret and re-entry is on order-1 Markov streams built to favour eras. No real regime-switching dataset has been run.
- The context-reading control is small. The best was a 0.86M-parameter transformer; the meta-trained GRU barely learned (validation loss 2.69 against the oracle's 1.78). A larger in-context model belongs to phase 2 and could close part of the gap.
- The TinyStories chart is one subset, 1,500 steps and at most 2 seeds. The GPT baseline is under-tuned (its seeds differ by 0.41 nats), the mixture of experts ran in fp32 and the rest in bf16, linear attention was not re-run in this pilot, and the result is parity, not superiority.
- On text, the era bank adds little. The same network scored without the bank is worse by only 0.0055 (seed 0) and 0.0068 (seed 1) nats per token, so the parity on TinyStories comes from the tensor-train network. Whether the bank helps on text with real regime changes is untested.
- The Asmodeus-native arm does not reach parity. At context 32 and 300 steps it scored 7.0217 validation NLL at 857 tokens per second, about 7× slower per token than the mixture of experts (5,979), and on the toy recurring bed (one seed) its regret is 1.124 against 0.406 for the state-space model. Its quantitative bars on an independent generator (LK1) also failed and stay open.
- The detector repair is open. The faster alarm raises switch events from 16 to 28–37 per stream; on seeds 50–55 it ends with 9–13 eras (bound 4) and purity 0.59–0.71, and the learned-prior and retrospective-split repairs (DR3, DR4) are blocked.
- Lean proves the mathematics, not the Python. Property tests are meant to pin the code's constants to each lemma's hypotheses; the proofs do not. L10, L12, L18, TT-1, the sampling bridge of the merge rule and the rate of the learned kernel are cited, not proved.
- Some choices sit on the edge. The tuned δ = 0.05, window 32 and 64 transitions of evidence lie on the edges of their frozen grids, momentum's 50/50 split was fixed rather than tuned, and the oracle and every count model share the generating prior a = 0.2.
- There is no CUDA code yet. The repository holds no CUDA source at the pinned commit. The GPU engine is stage 6, in build behind a frozen interface, and the reference filter runs one token at a time.