4.2. E2: the canary with attention over depth#

latent’s canary is a tiny looped model trained from scratch on a toy proof task: a cheap early warning before larger runs. E2 asks whether replacing its recurrence by ARLoop-style attention residuals changes how many Lean-checked certificates it writes, and how that number depends on the number of loops \(R\) at test time (the protocol and the code write \(r\); these notes write \(R\) throughout). The protocol (experiments/e2_small/PROTOCOL.md) was written before any E2 code ran. Everything below is computed from the run’s raw files while the book is built.

4.2.1. The protocol in brief#

  • Task. The latent addition-certificate canary: prompt a+b=, the model writes a compact certificate (c|r…rz;), which is compiled and checked by the pinned Lean checker peano_lab_verify. Splits: 93 training identities; tests iid (35), ood_depth (64, more successor steps than ever seen in training) and ood_operand (32).

  • Training. Identical for every arm: 1,000 AdamW updates, width 64, three seeds (11, 29, 47). The training recurrence is random, \(R = 1 + \text{Poisson}(\lambda)\) with \(\lambda\) drawn from a log-normal with mean 3 and log-sd 0.5, capped at 16; backpropagation is truncated to the last 4 applications of the core. At a given seed every loop arm sees the same batches and the same sequence of \(R\).

  • Arms. latent-recurrent (latent’s model, unchanged: sandwich-norm core with an input-injection adapter), prenorm-loop (a PreNorm core, no injection), arloop-untied (attention residuals over depth with one query per effective sublayer, as in the paper, one residual block per core application, window of 3 plus the embedding), arloop-tied (the same with the queries shared across loops, our variant, defined for any \(R\)), and two untied controls (standard-parameter, standard-depth).

  • Evaluation. Greedy decoding at \(R \in \{1, 2, 4, 8, 16\}\); the metric is the number of certificates accepted by Lean. Effect rule (pre-registered): a paired 95% interval that excludes 0 and the same non-zero sign in all three seeds; anything else is “no effect detected at this scale”. Evidence tier T4 (discovery). [exp]

Run. WMI job 322153 (completed, 410 GPU-seconds) on one NVIDIA GeForce RTX 4090, torch 2.7.1+cu128; checker peano_lab_verify SHA-256 9ca28827c769…; seeds 11, 29, 47. Files: experiments/e2_small/results/322153/.

4.2.2. Lean-accepted certificates#

Recounted here from the raw prediction files (<arm>-seed<seed>/predictions-r<r>.jsonl): a certificate counts as accepted when the record says lean_accepted and the checker exited with code 0.

Hide code cell source

SPLITS = ("iid", "ood_depth", "ood_operand")
LOOP_ARMS = ("latent-recurrent", "prenorm-loop", "arloop-untied", "arloop-tied")
CONTROLS = ("standard-parameter", "standard-depth")
if ready:
    seeds = summary["config"]["seeds"]
    rs = summary["config"]["evaluation_recurrences"]
    records = {}                                       # (arm, seed, r) -> {(split, a, b): accepted}
    consistent = True
    for arm in LOOP_ARMS + CONTROLS:
        for seed in seeds:
            for r in (rs if arm in LOOP_ARMS else [None]):
                rows = [json.loads(line) for line in
                        (RES / f"{arm}-seed{seed}" / f"predictions-r{r}.jsonl").read_text().splitlines() if line.strip()]
                acc = {(row["split"], row["a"], row["b"]): int(bool(row["lean_accepted"]) and row["verifier_exit"] == 0)
                       for row in rows}
                consistent &= all(acc[(row["split"], row["a"], row["b"])] == int(bool(row["lean_accepted"])) for row in rows)
                records[(arm, seed, r)] = acc
    n_items = {sp: summary["split_sizes"][sp] * len(seeds) for sp in SPLITS}

    def count(arm, r, split):
        per = [sum(v for k, v in records[(arm, s, r)].items() if k[0] == split) for s in seeds]
        return sum(per), per

    rows = []
    for arm in LOOP_ARMS + CONTROLS:
        for r in (rs if arm in LOOP_ARMS else [None]):
            cells = []
            for sp in SPLITS:
                tot, per = count(arm, r, sp)
                cells.append(f"{tot} ({'/'.join(map(str, per))})")
            rows.append((arm, r if r else "–", *cells))
    lib.md(lib.table(rows, ["arm", "R", f"iid (of {n_items['iid']})", f"ood_depth (of {n_items['ood_depth']})",
                            f"ood_operand (of {n_items['ood_operand']})"]) +
           "\n\nCell: total over the three seeds (per seed 11/29/47).")

arm

R

iid (of 105)

ood_depth (of 192)

ood_operand (of 96)

latent-recurrent

1

14 (5/7/2)

0 (0/0/0)

9 (3/2/4)

latent-recurrent

2

14 (6/4/4)

0 (0/0/0)

5 (2/0/3)

latent-recurrent

4

14 (6/4/4)

0 (0/0/0)

5 (2/0/3)

latent-recurrent

8

14 (6/4/4)

0 (0/0/0)

5 (2/0/3)

latent-recurrent

16

14 (6/4/4)

0 (0/0/0)

5 (2/0/3)

prenorm-loop

1

8 (2/3/3)

0 (0/0/0)

0 (0/0/0)

prenorm-loop

2

9 (2/4/3)

0 (0/0/0)

2 (2/0/0)

prenorm-loop

4

7 (1/4/2)

0 (0/0/0)

3 (3/0/0)

prenorm-loop

8

6 (1/3/2)

0 (0/0/0)

2 (1/0/1)

prenorm-loop

16

8 (2/3/3)

0 (0/0/0)

2 (1/0/1)

arloop-untied

1

8 (0/5/3)

0 (0/0/0)

3 (0/1/2)

arloop-untied

2

10 (1/5/4)

0 (0/0/0)

2 (0/1/1)

arloop-untied

4

10 (1/5/4)

0 (0/0/0)

2 (0/2/0)

arloop-untied

8

8 (0/5/3)

0 (0/0/0)

2 (0/2/0)

arloop-untied

16

8 (1/5/2)

0 (0/0/0)

2 (0/2/0)

arloop-tied

1

8 (2/3/3)

0 (0/0/0)

2 (0/2/0)

arloop-tied

2

7 (1/3/3)

0 (0/0/0)

2 (0/2/0)

arloop-tied

4

9 (1/4/4)

0 (0/0/0)

2 (0/2/0)

arloop-tied

8

9 (1/4/4)

0 (0/0/0)

2 (0/2/0)

arloop-tied

16

9 (1/4/4)

0 (0/0/0)

2 (0/2/0)

standard-parameter

–

11 (2/5/4)

0 (0/0/0)

0 (0/0/0)

standard-depth

–

10 (5/3/2)

0 (0/0/0)

1 (0/1/0)

Cell: total over the three seeds (per seed 11/29/47).

Hide code cell source

if ready:
    P = lib.PALETTE
    # latent's decoder neutral; the PreNorm loop gold; the two ARLoop arms indigo (tied queries: dashed)
    STYLE = {"latent-recurrent": (P["neutral"], "-"), "prenorm-loop": (P["pn"], "-"),
             "arloop-untied": (P["ar"], "-"), "arloop-tied": (P["ar"], "--")}
    fig, ax = lib.figure(figsize=(7.5, 3.2))
    lib.style(ax)
    xs = list(range(len(rs)))
    for arm in LOOP_ARMS:
        color, ls = STYLE[arm]
        ys = [count(arm, r, "iid")[0] for r in rs]
        ax.plot(xs, ys, color=color, ls=ls, lw=2, marker="o", ms=5, mec=P["paper"], mew=1.5, label=arm)
    for arm, t in zip(CONTROLS, (0.75, 0.4)):
        y = count(arm, None, "iid")[0]
        ax.axhline(y, color=lib.tint(P["neutral"], t), lw=1.5, label=f"{arm} (no loop): {y}")
    ax.yaxis.set_major_locator(matplotlib.ticker.MaxNLocator(integer=True))
    ax.set_xticks(xs, [str(r) for r in rs])
    ax.set_xlabel("loops R at test time")
    ax.set_ylabel(f"iid certificates accepted (of {n_items['iid']})")
    ax.set_ylim(0, 16)
    ax.legend(frameon=False, fontsize=8, labelcolor=P["ink"], loc="upper center", bbox_to_anchor=(0.5, -0.22), ncol=3)
    fig.tight_layout()
    plt.show()
../_images/f393ad8cca0f932b75806e1841a31838428782bb4c24520c9dbb6689b3ed9836.png

On the iid split at \(R = 4\) (the mean training recurrence) Lean accepts 14 of 105 certificates from latent-recurrent, 10 from arloop-untied, 9 from arloop-tied and 7 from prenorm-loop; the reference arm accepts 14 at every \(R\). No arm, seed or number of loops produces an accepted ood_depth certificate (0 of 192 per arm and \(R\)). [exp]

4.2.3. The pre-registered comparisons#

The primary family compares each new arm with latent-recurrent on iid at \(R = 4\) and \(R = 16\), paired over (seed, item). The statistics are recomputed here from the prediction files with the protocol’s bootstrap (items resampled within each seed, 10,000 draws, seed 20261115).

Hide code cell source

def vector(arm, r, split):
    return {(s, a, b): v for s in seeds for (sp, a, b), v in records[(arm, s, r)].items() if sp == split}

if ready:
    primary = []
    for arm in ("prenorm-loop", "arloop-untied", "arloop-tied"):
        for r in (4, 16):
            res = lib.paired_stratified(vector(arm, r, "iid"), vector("latent-recurrent", r, "iid"), seeds)
            primary.append((arm, r, res))
    lib.md(lib.table([(f"{arm} − latent-recurrent", r, lib.signed(res['diff'], 3),
                       f"[{lib.signed(res['ci95'][0], 3)}, {lib.signed(res['ci95'][1], 3)}]",
                       "/".join(lib.signed(v, 0) for v in res["per_seed_count_diff"].values()),
                       f"{res['only_x']}/{res['only_y']}", lib.pvalue(res['mcnemar_p']),
                       "yes" if res["candidate_effect"] else "no") for arm, r, res in primary],
                     ["comparison (iid)", "R", "difference", "95% interval", "per seed (count)",
                      "discordant", "McNemar p", "effect rule met"]))

comparison (iid)

R

difference

95% interval

per seed (count)

discordant

McNemar p

effect rule met

prenorm-loop − latent-recurrent

4

−0.067

[−0.133, +0.000]

−5/+0/−2

4/11

0.12

no

prenorm-loop − latent-recurrent

16

−0.057

[−0.133, +0.010]

−4/−1/−1

5/11

0.21

no

arloop-untied − latent-recurrent

4

−0.038

[−0.114, +0.038]

−5/+1/+0

7/11

0.48

no

arloop-untied − latent-recurrent

16

−0.057

[−0.133, +0.010]

−5/+1/−2

5/11

0.21

no

arloop-tied − latent-recurrent

4

−0.048

[−0.124, +0.029]

−5/+0/+0

7/12

0.36

no

arloop-tied − latent-recurrent

16

−0.048

[−0.124, +0.029]

−5/+0/+0

7/12

0.36

no

No primary comparison meets the effect rule. All six point estimates are negative (from −0.067 to −0.038 in accuracy, that is the new arms accept fewer certificates than latent’s model), and every 95% interval contains 0. The recomputation agrees in every field with the experiment’s own analysis (analysis.json). [exp]

Hide code cell source

def run_label(s):
    """'arm@r4' -> 'arm at R = 4'; a control has no loops ('arm@rNone' -> 'arm')."""
    arm, _, r = s.partition("@r")
    return arm if r in ("", "None") else f"{arm} at R = {r}"


if ready:
    secondary = [c for c in analysis["comparisons"] if c["family"] != "primary"]
    hits = [c for c in secondary if c["candidate_effect"]]
    lib.md(f"Secondary comparisons (descriptive, uncorrected, read from `analysis.json`): {len(secondary)}, "
           f"of which {len(hits)} meet the rule:\n\n" +
           lib.table([(run_label(c["x"]), run_label(c["y"]), c["split"],
                       lib.signed(c['diff'], 3), f"[{lib.signed(c['ci95'][0], 3)}, {lib.signed(c['ci95'][1], 3)}]",
                       "/".join(lib.signed(v, 0) for v in c["per_seed_count_diff"].values())) for c in hits],
                     ["x", "y", "split", "difference", "95% interval", "per seed"]))

Secondary comparisons (descriptive, uncorrected, read from analysis.json): 114, of which 4 meet the rule:

x

y

split

difference

95% interval

per seed

prenorm-loop at R = 1

latent-recurrent at R = 1

ood_operand

−0.094

[−0.156, −0.042]

−3/−2/−4

prenorm-loop at R = 8

latent-recurrent at R = 8

iid

−0.076

[−0.152, −0.010]

−5/−1/−2

arloop-untied at R = 1

latent-recurrent at R = 1

ood_operand

−0.062

[−0.125, −0.010]

−3/−1/−2

latent-recurrent at R = 1

standard-depth

ood_operand

+0.083

[+0.021, +0.146]

+3/+1/+4

Among the 114 secondary comparisons four meet the rule: three put a new arm below latent’s decoder, one puts the decoder above the depth-matched control, and none favours a new arm. With this many uncorrected tests they are leads at most.

4.2.4. Depth: does \(R = 16\) change anything?#

Hide code cell source

if ready:
    depth = {}
    for arm in LOOP_ARMS:
        x, y = vector(arm, 16, "iid"), vector(arm, 4, "iid")
        depth[arm] = (sum(1 for u in x if x[u] > y[u]), sum(1 for u in x if x[u] < y[u]))
    lib.md(lib.table([(arm, f"{a}/{b}") for arm, (a, b) in depth.items()],
                     ["arm", "iid items accepted only at R = 16 / only at R = 4"]))

arm

iid items accepted only at R = 16 / only at R = 4

latent-recurrent

0/0

prenorm-loop

3/2

arloop-untied

2/4

arloop-tied

0/0

From \(R = 4\) to \(R = 16\) the reference arm and the tied-query arm accept exactly the same iid items; the two others change on a handful of items in both directions. Sixteen loops bring no detectable gain here. [exp]

4.2.5. Where does the read-out look?#

The experiment’s analysis (analysis.json) records the routing weights of the read-out query at \(R = 16\) (four sources: the embedding source \(b_0\) and the three most recent blocks).

Hide code cell source

if ready:
    ro = [x for x in analysis["routing"] if x["r"] == 16]
    lib.md(lib.table([(x["arm"], x["seed"], ", ".join(x["readout_sources"]),
                       f"{x['readout_weights'][x['readout_sources'].index('b0')]:.2f}") for x in ro],
                     ["arm", "seed", "sources of the read-out", "weight on b0"]) +
           "\n\nUniform mixing over four sources would give 0.25.")

arm

seed

sources of the read-out

weight on b0

arloop-untied

11

b0, b14, b15, b16

0.38

arloop-untied

29

b0, b14, b15, b16

0.17

arloop-untied

47

b0, b14, b15, b16

0.36

arloop-tied

11

b0, b14, b15, b16

0.33

arloop-tied

29

b0, b14, b15, b16

0.17

arloop-tied

47

b0, b14, b15, b16

0.24

Uniform mixing over four sources would give 0.25.

The weight on the embedding source ranges from below to above the uniform 0.25 across seeds: no consistent preference for the embedding was learned at this scale.

4.2.6. Reproduction of latent’s job 284986#

The unchanged arm is also a reproduction test: latent-recurrent and both controls at seeds 11 and 29 must give exactly what latent recorded in its job 284986.

Hide code cell source

if ready:
    rep = analysis["reproduction"]
    same, total = sum(x["identical_records"] for x in rep), sum(x["n"] for x in rep)
    verdict = analysis["reproduction_verdict"]
    lib.md(f"Item records identical to job 284986: **{same:,} of {total:,}** (fields: "
           f"{verdict['record_fields']}); recurrence histograms identical: "
           f"{'yes' if verdict['histograms_identical'] else 'no'}; largest difference in the logged loss "
           f"history: {verdict['loss_history_max_abs_diff']}.")

Item records identical to job 284986: 1,834 of 1,834 (fields: prediction, lean_accepted, reference_valid, verifier_exit, certificate_sha256, parse_error); recurrence histograms identical: yes; largest difference in the logged loss history: 0.0.

All 1,834 item records (prediction, Lean verdict, checker exit code, certificate hash) are identical to latent’s, across two torch versions on the same GPU model. An independent recount (runs/e2/referee.md) confirms this. [exp]

4.2.7. What E2 says, and what it does not#

Independent re-check

runs/e2/referee.md: a separate script recounted every cell from the raw prediction files, and the reproduction of latent was checked record by record. Verdict: established as T4 evidence, that is, computational evidence from a small discovery run.

At this scale attention over depth does not beat latent’s recurrent decoder on Lean-checked certificates, no arm gains detectably from more loops, and no arm generalises to the deeper ood_depth problems. This is “no effect detected at this scale”, not evidence that attention residuals cannot help: the models are tiny (width 64, 1,000 updates, 93 training identities), the ARLoop arms differ from latent-recurrent in more than the residual (no adapter, PreNorm instead of sandwich norm), they have no value residuals (registered in the protocol), which the paper’s App. A.1 and A.3 report its sliding window needs, they follow eq. (4) of the paper rather than the released code’s first block, and training uses a random recurrence with truncated backpropagation, where the paper trains at a fixed \(R\) (experiments/e2_small/RESULTS.md, “Caveats”). The tied-query arm is our own variant. Stage 1b trains the same canary for longer (Stage 1: the same tests after more training).