Dense Latent Query Executor Experiment
The one idea you need
Picture tracking two hidden numbers by keeping a single running note in your head, updating it the instant each instruction is read aloud. You never see the full answer, just one example answer per puzzle. Can that lone note become a reliable step-by-step calculator?
The question
If a model only ever sees one sampled final answer for each practice problem, can its single running memory learn to actually carry out the steps behind that answer?
What we found
Partly. Giving the model enough internal thinking steps to walk through the whole program lifts accuracy sharply, and it clearly beats a model that reads everything in one glance. But the memory stays approximate: at its longest training length it puts only about half its confidence on correct answers, and on the longest programs that slips to about a fifth, with the underlying hidden numbers barely recoverable afterward.
Why it matters
To track a changing state across many steps, update memory one instruction at a time instead of reading everything at once. But a single final-answer signal per example won't build a trustworthy internal state machine — budget for extra training pressure or a bigger memory.
On this page
Results at a glance 8
How to read
Bars show how much of the model's confidence landed on correct answers (taller is better), grouped by program length from short to long. Dark bars are the step-by-step memory model; light bars read the whole program in one glance.
Takeaway → Dark bars sit above light bars at every length, though both shrink sharply as programs grow longer — stepping always does more work.
Data table
| program length | dense recurrent (K=L) | static compiler |
|---|---|---|
| L=4 | 70.2% | 50.4% |
| L=8 | 49.3% | 26.9% |
| L=12 | 36.1% | 13.6% |
| L=16 | 29.6% | 9% |
| L=24 | 21.5% | 5.5% |
Numbers from analysis/summary.md (controls table, from runs/*/metrics_final.csv); report table
Technical framing
Dense recurrent executor vs static compiler: exact query mass by program length (mod 31) — The recurrent dense state does real sequential work, beating a one-pass compiler at every length, but is far from exact at long programs.
How to read
Each line is one program length. The horizontal axis is how many internal thinking steps the model takes; the vertical axis is confidence on correct answers (higher is better). Lines stay flat, then jump.
Takeaway → Every line stays flat until the thinking steps reach the program's length, then leaps up — steps help only when they consume more instructions.
Data table
| internal recurrent steps K | L=4 | L=8 | L=12 | L=16 | L=24 |
|---|---|---|---|---|---|
| 0 | 36.3% | 18.7% | 11.6% | 8.5% | 5% |
| 1 | 40.1% | 19.8% | 11.7% | 8.6% | 5.5% |
| 2 | 44.9% | 20.4% | 11.9% | 9.1% | 5.2% |
| 4 | 70.2% | 21.8% | 12.8% | 8.5% | 4.9% |
| 8 | 70.2% | 49.3% | 14.9% | 9.2% | 5% |
| 12 | 70.2% | 49.3% | 36.1% | 10.8% | 5.4% |
| 16 | 70.2% | 49.3% | 36.1% | 29.6% | 6% |
| 24 | 70.2% | 49.3% | 36.1% | 29.6% | 21.5% |
Numbers from analysis/final_metrics_query_mean.csv (run_label 'Dense recurrent p=31')
Technical framing
Compute threshold: query mass jumps when internal steps K reach program length L (mod 31) — Each length stays flat until K reaches L, then jumps: extra internal steps only help when they consume more program instructions.
How to read
Bars show how much of the true hidden numbers a frozen read-back test could recover from the memory (taller is better), by program length. Dark bars are the step-by-step model; light bars read everything in one glance.
Takeaway → The step-by-step bars tower over the one-glance bars, yet even they fade to almost nothing on long programs — no near-perfect memory.
Data table
| program length | dense recurrent (K=L) | static compiler |
|---|---|---|
| L=4 | 41.6% | 13% |
| L=8 | 18.8% | 3.7% |
| L=12 | 12% | 0.8% |
| L=16 | 8.8% | 0.4% |
| L=24 | 5.7% | 0.2% |
Numbers from analysis/summary.md (controls table, from runs/*/metrics_final.csv); report table
Technical framing
Belief-probe audit: recoverable belief mass in the hidden state (mod 31) — A frozen post-hoc probe recovers far more belief information from the recurrent state, but even it decays fast — no high-fidelity belief machine.
How to read
Bars show confidence on correct answers (taller is better) by program length in an easier setting. Three models: step-by-step memory in order, one-glance reading, and step-by-step memory with its instructions scrambled.
Takeaway → The scrambled-order bars drop near the one-glance model, well below the properly ordered step-by-step model — reading in order is what drives the gain.
Data table
| program length | dense recurrent | static compiler | shuffled recurrent |
|---|---|---|---|
| L=3 | 89.3% | 74% | 75.8% |
| L=6 | 72% | 46.2% | 43.1% |
| L=9 | 55.7% | 25.1% | 26.3% |
| L=12 | 47.7% | 18.7% | 19.8% |
Numbers from report table (Section 8), from runs/*_mod11/metrics_final.csv
Technical framing
Small-modulus diagnostic (mod 11): instruction order matters — Shuffling instruction order before execution erases most of the recurrent advantage, so the gain comes from genuinely sequential processing.
How to read
Bars show confidence on correct answers (taller is better) by program length for four question types: asking one hidden number, the other, their sum, or their difference.
Takeaway → The two single-number questions stay above the sum and difference questions at every length — combining both hidden numbers is consistently harder.
Data table
| Program length L (evaluated at first K >= L) | Query A | Query B | Query A+B | Query A-B |
|---|---|---|---|---|
| L=4 | 73.9% | 77.3% | 63.3% | 66.3% |
| L=8 | 52.9% | 53.7% | 44.4% | 46.2% |
| L=12 | 38.8% | 40% | 31.1% | 34.4% |
| L=16 | 32.8% | 33.6% | 24.6% | 27.4% |
| L=24 | 24% | 25.4% | 17.5% | 19.2% |
Numbers from analysis/mod31_per_query_threshold_summary.csv
Technical framing
Which query is hardest? Query mass at the compute threshold, by query type (mod 31) — Single-variable queries (A, B) beat the combined A+B and A-B queries at every length; the gap persists at held-out lengths.
How to read
Two separate training runs move rightward over time. One line tracks the model learning to answer questions; the other tracks a later test of how much its frozen memory reveals about the hidden numbers. Higher is better.
Takeaway → Both curves climb steeply then level off — the model learns to answer, and its memory turns out to hold much of the hidden-number information.
Data table
| Training step (each phase trained separately) | Executor query mass (5000 steps) | Frozen-model belief probe (2000 steps) |
|---|---|---|
| 1 | 38.4% | 1.9% |
| 200 | — | 46.8% |
| 250 | 44.5% | — |
| 400 | — | 53.4% |
| 500 | 43.8% | — |
| 600 | — | 57.5% |
| 750 | 44.7% | — |
| 800 | — | 58.5% |
| 1000 | 53.4% | 62.9% |
| 1200 | — | 62.2% |
| 1250 | 53.2% | — |
| 1400 | — | 63% |
| 1500 | 55.6% | — |
| 1600 | — | 63.6% |
| 1750 | 61.1% | — |
| 1800 | — | 61.5% |
| 2000 | 60.6% | 64.2% |
| 2250 | 64.3% | — |
| 2500 | 64.8% | — |
| 2750 | 65.3% | — |
| 3000 | 65.3% | — |
| 3250 | 67.2% | — |
| 3500 | 65% | — |
| 3750 | 68.4% | — |
| 4000 | 68.7% | — |
| 4250 | 69.5% | — |
| 4500 | 69% | — |
| 4750 | 69.1% | — |
| 5000 | 68.1% | — |
Numbers from runs/main_dense_mod31/results.json
Technical framing
Training curves (mod 31): executor query mass, then post-hoc belief probe — The executor climbs from 38% to ~69% query mass; a probe on the frozen hidden state then recovers up to 64% belief mass within 2000 steps.
How to read
Bars show how much of the hidden numbers could be recovered from memory (taller is better) by program length, including two lengths longer than any seen in training. Three models: step-by-step, one-glance, and scrambled-order.
Takeaway → On the longer unseen programs the step-by-step bars stay tall while both other models collapse to near zero — only ordered stepping carries over.
Data table
| Program length L (trained on lengths up to 6) | Dense recurrent | Static compiler | Shuffled recurrent |
|---|---|---|---|
| L=3 | 82.5% | 53.7% | 48.7% |
| L=6 | 58.8% | 24.8% | 17.3% |
| L=9 (held out) | 39.1% | 4.8% | 5.7% |
| L=12 (held out) | 31.5% | 2.5% | 3% |
Numbers from analysis/final_metrics_query_mean.csv
Technical framing
Small-modulus (mod 11) belief audit: only the ordered recurrent model keeps belief at held-out lengths — At held-out lengths 9 and 12 the recurrent model keeps 31-39% recoverable belief while both controls collapse below 6%.
How to read
Two lines by program length show how often the model's single best guess was actually a correct answer (higher is better). One line is the step-by-step memory model, the other reads the whole program in one glance.
Takeaway → The step-by-step line runs far above the one-glance line, and the gap widens on the longest programs — stepping helps most when programs get hard.
Data table
| Program length L | Dense recurrent (K=L) | Static compiler (one pass) |
|---|---|---|
| 4 | 79.1% | 54.8% |
| 8 | 59.3% | 29.1% |
| 12 | 44.6% | 11.8% |
| 16 | 37.1% | 9.5% |
| 24 | 28.8% | 5.6% |
Numbers from analysis/mod31_control_summary.csv
Technical framing
Top-1 accuracy on the true support (mod 31): dense recurrent vs static compiler — By top-1 accuracy the recurrent model roughly doubles-to-quintuples the static compiler, and the gap widens at held-out lengths 16 and 24.
In the author’s words from the Report · “Abstract”
At the first K>=L, exact query target mass is 70.2%, 49.3%, 36.1%, 29.6%, and 21.5% for lengths 4, 8, 12, 16, and 24. A matched static compiler reaches 50.4%, 26.9%, 13.6%, 9.0%, and 5.5%. The dense recurrent state is therefore doing useful sequential work, but the result is not near-exact: sampled query supervision plus a generic dense state is insufficient to learn a high-fidelity belief executor at this scale.
Overview
This experiment tests whether a recurrent model with a fixed-width dense hidden state can learn modular belief-state execution from one sampled final query value per example.
Contents
src/dense_latent_query_executor_experiment.py: training, probing, and evaluation harness.src/analyze_dense_latent_query_executor.py: analysis and figure generation.reports/dense_latent_query_executor_paper.md: standalone writeup.reports/dense_latent_query_executor_paper.html: standalone HTML report.reports/dense_latent_query_executor_experiment_log.md: chronological experiment log.runs/: JSON and CSV run outputs.analysis/: generated summaries and figures.checkpoint_manifest.csv: paths and sizes for saved checkpoints.
Checkpoints are written outside the experiment directory under:
../../large_artifacts/dense_latent_query_executor/checkpoints/Download this experiment directory for the normal research bundle. Download ../../large_artifacts/dense_latent_query_executor/ only when saved model weights are needed.
Report
Rendered from reports/dense_latent_query_executor_paper.md
A controlled experiment on whether a fixed-width hidden state can learn sequential belief execution from one sampled final answer
Abstract
This experiment tests whether a recurrent runtime with an ordinary dense hidden vector can learn to execute modular arithmetic and observation-filter programs when the loss supplies only one sampled final query value per example. Each example starts with an unknown pair of registers constrained by B=A+d (mod p). A program applies arithmetic updates and bucket observations. The model receives one query type such as A, B, A+B, or A-B, and the training label is one value sampled from the exact final query distribution.
The full final query distribution and full final belief distribution over (A,B) pairs are withheld from the loss and used only for evaluation. A separate frozen post-hoc probe is trained after executor training to test whether the dense hidden state contains recoverable belief-state information.
On the scaled modulus-31 task, trained on lengths 1-8 and evaluated on lengths 4, 8, 12, 16, and 24, the dense recurrent executor shows a real compute threshold: performance rises when internal recurrent steps K reach program length L. At the first K>=L, exact query target mass is 70.2%, 49.3%, 36.1%, 29.6%, and 21.5% for lengths 4, 8, 12, 16, and 24. A matched static compiler reaches 50.4%, 26.9%, 13.6%, 9.0%, and 5.5%. The dense recurrent state is therefore doing useful sequential work, but the result is not near-exact: sampled query supervision plus a generic dense state is insufficient to learn a high-fidelity belief executor at this scale.
Lay Summary
The model starts with partial knowledge:
B = A + d (mod p)That relation describes many possible (A,B) worlds. A program then changes the registers and sometimes filters the possible worlds:
A = A + 7
observe B % 5 = 3
B = B - A
query A + BTraining gives only one sampled final answer value. It does not give the whole answer distribution, and it does not give the set of possible (A,B) worlds. The question is whether a dense recurrent hidden state learns a reusable internal executor anyway.
The answer is mixed. The dense recurrent model does learn something sequential: it improves sharply once it has enough internal steps to read the whole program, and it beats a static one-pass compiler on held-out lengths. But the learned dense state is approximate. It is much better than the static control, not a solved belief machine.
1. Question
The experiment asks whether sampled-answer supervision can induce a latent recurrent executor in a generic dense hidden state.
The target evidence has five parts:
- Query quality should depend on internal step budget
K. - The threshold should align with program length
L: weak whenK<L, stronger whenK>=L. - The threshold should hold beyond the training length range.
- A post-hoc probe should recover nontrivial belief information from the dense state.
- Static and order-destroying controls should be weaker.
This is a controlled mechanism test. It is not an open-ended language benchmark. The goal is to isolate whether recurrent latent computation emerges from low-bandwidth final-answer supervision.
2. Task
Programs operate over two registers modulo p.
Initial belief:
{(A, B): B = A + d mod p}For p=31, the full state space has 31 * 31 = 961 register pairs, and the initial support contains 31 pairs.
Operations:
| Operation | Meaning |
|---|---|
A=A+c | add a constant to A |
A=A-c | subtract a constant from A |
B=B+c | add a constant to B |
B=B-c | subtract a constant from B |
A=A+B | add B into A |
B=B+A | add A into B |
A=A-B | subtract B from A |
B=B-A | subtract A from B |
OBS_A_BUCKET | filter to states where A % m = r |
OBS_B_BUCKET | filter to states where B % m = r |
Observation residues are sampled from the live support, so every target support is non-empty. For the scaled run, p=31, observation modulus is 5, and each instruction is an observation with probability 0.3.
Each example samples one final query type:
| Query | Distribution being sampled |
|---|---|
A | final distribution of A |
B | final distribution of B |
A_PLUS_B | final distribution of A+B mod p |
A_MINUS_B | final distribution of A-B mod p |
The training label is one value sampled from the exact query distribution. Evaluation computes the exact final query distribution and exact final pair belief.
Training used lengths 1-8. Evaluation used lengths 4, 8, 12, 16, and 24. Lengths 12, 16, and 24 test length generalization.
3. Models
Dense Recurrent Executor
The primary model stores only a dense hidden vector. It embeds the initial relation parameter d, then updates the hidden vector with a GRU-style cell, one program instruction per internal recurrent step. A query head maps the hidden state to logits over all query values for all query types.
The dense state is not a categorical belief table and receives no direct belief supervision.
Static Compiler Control
The static control receives the whole program and initial relation, processes the instruction sequence with a small Transformer encoder, pools the sequence, and predicts query logits in one pass. It has no recurrent execution axis and no variable internal step budget.
Shuffled Recurrent Control
The shuffled recurrent control uses the same dense recurrent architecture as the primary model, but it sorts each program's active instructions before execution. This preserves instruction content while destroying the original order.
Frozen Belief Probe
After executor training, the executor is frozen. A separate MLP probe maps hidden states to distributions over (A,B) pairs. For the recurrent model, the probe is trained on hidden states from training-length prefixes. For the static model, it is trained on the final pooled state. Probe metrics audit hidden-state information; they are not executor training losses.
4. Metrics
The primary metrics evaluate the exact final query distribution:
query_target_mass: total probability assigned to the exact query support.query_top1_on_support: whether the most likely queried value is inside the exact query support.query_target_nll: cross-entropy against the exact query distribution.
The audit metrics evaluate recoverable belief information:
probe_belief_target_mass: total probe probability assigned to the exact final(A,B)support.probe_belief_top1_on_support: whether the most likely probed pair is inside the exact support.probe_belief_target_nll: cross-entropy against the exact final pair distribution.
The belief metrics are post-hoc probe measurements, not executor objectives.
5. Main Result
The dense recurrent executor shows a clear execution-threshold shape at modulus 31. Query mass is weak when K<L, then rises when K reaches program length.


The probe-belief audit shows the same qualitative threshold, but the recovered belief mass is much lower than an exact belief state would require.

The K curves show the threshold by length.


Numerically, averaged across query types:
| Program length | Best query mass when K<L | Best probe belief mass when K<L | First K>=L | Query mass at first K>=L | Probe belief mass at first K>=L | Query top-1 |
|---|---|---|---|---|---|---|
| 4 | 44.9% | 11.3% | 4 | 70.2% | 41.6% | 79.1% |
| 8 | 21.8% | 2.5% | 8 | 49.3% | 18.8% | 59.3% |
| 12 | 14.9% | 1.4% | 12 | 36.1% | 12.0% | 44.6% |
| 16 | 10.8% | 0.8% | 16 | 29.6% | 8.8% | 37.1% |
| 24 | 6.0% | 0.3% | 24 | 21.5% | 5.7% | 28.8% |
The threshold is real, but the scale is limited. Length 24 improves from 6.0% query mass before the execution threshold to 21.5% at K=24. That is a meaningful gain, not a strong solution.
6. Query Types
All four query types show the same broad pattern: direct register queries are easiest, relational queries are harder, and all degrade with length.
At length 24:
| Query | Query mass at K=24 | Probe belief mass at K=24 | Query top-1 |
|---|---|---|---|
A | 24.0% | 5.5% | 31.4% |
A_MINUS_B | 19.2% | 5.7% | 23.2% |
A_PLUS_B | 17.5% | 6.0% | 26.2% |
B | 25.4% | 5.7% | 34.2% |
Relational queries are important because they are harder to answer from shallow marginal cues. The dense recurrent executor improves them, but does not solve them.
7. Controls
The scaled static compiler control shows that the dense recurrent result is not merely one-pass sequence fitting.


At modulus 31, averaged across query types:
| Model | L=4 query | L=8 query | L=12 query | L=16 query | L=24 query |
|---|---|---|---|---|---|
| Dense recurrent | 70.2% | 49.3% | 36.1% | 29.6% | 21.5% |
| Static compiler | 50.4% | 26.9% | 13.6% | 9.0% | 5.5% |
Probe belief target mass separates the models more sharply:
| Model | L=4 probe belief | L=8 probe belief | L=12 probe belief | L=16 probe belief | L=24 probe belief |
|---|---|---|---|---|---|
| Dense recurrent | 41.6% | 18.8% | 12.0% | 8.8% | 5.7% |
| Static compiler | 13.0% | 3.7% | 0.8% | 0.4% | 0.2% |
The small-modulus order control also matters. At modulus 11, the dense recurrent model reached 89.3%, 72.0%, 55.7%, and 47.7% query mass at lengths 3, 6, 9, and 12. The shuffled recurrent control reached 75.8%, 43.1%, 26.3%, and 19.8%. Preserving instruction content while destroying order removes much of the length-generalizing behavior.
8. Small-Modulus Diagnostic
A modulus-11 diagnostic used training lengths 1-6 and evaluation lengths 3, 6, 9, and 12. It shows the same phenomenon in an easier state space.
| Model | L=3 query | L=6 query | L=9 query | L=12 query |
|---|---|---|---|---|
| Dense recurrent | 89.3% | 72.0% | 55.7% | 47.7% |
| Static compiler | 74.0% | 46.2% | 25.1% | 18.7% |
| Shuffled recurrent | 75.8% | 43.1% | 26.3% | 19.8% |
The dense recurrent model is consistently best, but it still degrades with length. The scaled modulus-31 result is therefore not a surprise failure; it is the harder version of the same approximate dense execution behavior.
9. Interpretation
The result supports a narrow mechanism claim:
A generic dense recurrent hidden state can learn a partial sequential executor from one sampled final query label per example, and additional internal steps help when those steps correspond to consuming more program instructions.
The result does not support the stronger claim that sampled final-answer supervision reliably induces an exact hidden belief machine in a generic dense vector.
The evidence for useful sequential execution is:
- the
K=Lthreshold in query metrics, - the same threshold in post-hoc belief-probe metrics,
- length-generalized improvement beyond the training range,
- a clear gap over the scaled static compiler,
- weaker behavior from the order-destroying recurrent control at small modulus.
The evidence against a strong dense executor is just as important:
- query target mass is only 49.3% at the maximum training length of 8,
- query target mass drops to 21.5% at length 24,
- probe belief target mass drops to 5.7% at length 24,
- relational queries remain notably weaker than direct register queries,
- the dense state does not preserve enough information for the post-hoc probe to reconstruct the final belief well.
This is a useful boundary result. Dense recurrence alone creates a measurable serial-compute axis, but the architecture or objective needs more pressure if the target is robust hidden-state execution.
10. Limits
This is a structured experiment.
- The recurrent model uses a direct program counter.
- The instruction vocabulary is small and fixed.
- The operation family is modular arithmetic plus bucket observations.
- The largest completed state space has 961 pairs.
- Supervision is an exact sample from an exact query distribution.
- The belief probe is post-hoc and only measures recoverable information, not necessarily all information in the state.
The dense model has no explicit categorical belief table, but the task itself is still synthetic and tightly controlled. The result should be read as a mechanistic signal, not as a claim about open-ended reasoning.
11. Next Tests
Useful next tests:
- Add auxiliary prefix-query losses or occasional belief distillation and measure whether the dense state becomes stable without fully supervising every example.
- Increase state dimension and compare whether the probe-belief bottleneck is capacity-limited or optimization-limited.
- Replace the GRU cell with a recurrent block that attends over the instruction sequence at each step rather than using a direct program counter.
- Train with randomized
Kand a monotonic refinement loss so later recurrent states are explicitly pressured to improve. - Add a learned halt/no-op policy and test whether the model can choose compute budget.
12. Reproducibility
Primary files:
- Experiment script:
../src/dense_latent_query_executor_experiment.py - Analysis script:
../src/analyze_dense_latent_query_executor.py - Experiment log:
dense_latent_query_executor_experiment_log.md - Results directory:
../runs/ - Analysis directory:
../analysis/ - Checkpoint manifest:
../checkpoint_manifest.csv
Key run directories:
../runs/main_dense_mod31../runs/control_static_mod31../runs/pilot_dense_mod11../runs/control_static_mod11../runs/control_shuffled_mod11../runs/smoke_dense_mod7
Large checkpoint files are stored outside the experiment bundle under:
../../../large_artifacts/dense_latent_query_executor/checkpoints/Environment:
- Python 3.12.3
- PyTorch 2.8.0+cu128
- GPU: NVIDIA RTX 6000 Ada Generation
13. Bottom Line
The dense recurrent executor learned a real but weak latent execution strategy from sampled final query labels. The K-threshold is visible, it generalizes beyond the training length range, and it beats a full-budget static compiler. But the dense state does not become a high-fidelity belief state at modulus 31. The most defensible conclusion is that recurrent dense latent execution is learnable in this setup, but not strong enough without additional architectural or training pressure.
Experiment log 16
Show the running log (16 entries)
Objective
Test whether a latent recurrent runtime with a fixed-width dense hidden state can learn arithmetic and observation-filter execution when each training example provides only one sampled final query value.
The model is not given an explicit categorical belief vector over (A, B) pairs as its state. It keeps a dense vector, executes one instruction per recurrent step, and predicts a final query value. Exact final query distributions and exact final belief distributions are used for evaluation. A frozen post-hoc belief probe is trained after executor training to measure how much exact belief-state information is recoverable from the dense hidden state.
Hypothesis
If sampled-answer supervision can induce a reusable dense latent executor, then:
- Direct query performance should improve sharply when
K >= L. - The threshold should generalize to held-out lengths longer than training.
- A probe trained only on training-length hidden states should recover nontrivial exact belief information on held-out lengths.
- A static dense compiler should not reproduce the same length-generalizing K threshold.
- An order-destroying recurrent control should be weaker, showing that the dense state is using sequential execution rather than only bag-of-instruction statistics.
Task
Initial belief:
B = A + d (mod p), with A unknownPrograms contain:
- arithmetic updates over
AandB - observation filters of the form
A % m = r - observation filters of the form
B % m = r
Observation residues are sampled from the current support, so the target support is never empty.
Each example samples one final query type and one answer value from the exact final query distribution:
ABA+B mod pA-B mod p
The executor is trained with one-label cross-entropy on the sampled answer. Probe training happens only after the executor is frozen.
Models
Dense Recurrent Executor
The primary model encodes the initial relation in a dense vector and updates that vector with a GRU-style recurrent cell, one program instruction per internal step. The query head maps the dense state to logits over the query value for each query type.
Dense Static Compiler Control
The static control receives the whole program and initial relation, pools a Transformer encoder representation, and predicts query logits in one pass. It has no recurrent execution axis.
Shuffled Dense Recurrent Control
The shuffled control uses the same dense recurrent architecture but consumes a deterministic sorted version of the instructions rather than the original sequence. It preserves some instruction content while destroying program order.
Frozen Belief Probe
After executor training, the recurrent model is frozen. A separate MLP probe maps dense hidden states to distributions over (A,B) pairs. The probe is trained on hidden states from training-length prefixes and evaluated on held-out lengths and K values.
Planned Sequence
- Smoke test at tiny modulus.
- Pilot dense recurrent run at small modulus.
- Probe the pilot model.
- Run matched static and shuffled controls at small modulus.
- Run the main dense recurrent experiment at modulus 31.
- Run matched scaled controls.
- Aggregate metrics, generate figures, and write a standalone report.
Smoke Test
Run: ../runs/smoke_dense_mod7
Command:
python experiments/dense_latent_query_executor/src/dense_latent_query_executor_experiment.py --mode dense --modulus 7 --observe_mod 3 --observe_prob 0.4 --train_max_len 3 --eval_lengths 2,3 --eval_k 0,1,2,3 --train_steps 2 --batch_size 16 --eval_batch_size 16 --eval_examples 32 --probe_steps 2 --probe_batch_size 16 --state_dim 64 --instr_dim 32 --log_every 1 --probe_log_every 1 --lr 0.001 --probe_lr 0.001 --output_dir experiments/dense_latent_query_executor/runs/smoke_dense_mod7 --checkpoint_dir large_artifacts/dense_latent_query_executor/checkpoints/smoke_dense_mod7Status: complete.
Result: the script compiled, trained the dense executor from sampled query labels, froze it, trained a belief probe, evaluated exact query and probe-belief metrics, wrote metrics, and saved the checkpoint under ../../../large_artifacts/dense_latent_query_executor/checkpoints/smoke_dense_mod7.
Interpretation: the full dense-state training/probing/evaluation path is functional. The run is intentionally too short to test learning.
Pilot 1: Dense Recurrent Executor, Modulus 11
Run: ../runs/pilot_dense_mod11
Command:
python experiments/dense_latent_query_executor/src/dense_latent_query_executor_experiment.py --mode dense --modulus 11 --observe_mod 4 --observe_prob 0.3 --train_max_len 6 --eval_lengths 3,6,9,12 --eval_k 0,1,2,3,6,9,12 --train_steps 3000 --batch_size 512 --eval_batch_size 512 --eval_examples 512 --probe_steps 1500 --probe_batch_size 512 --state_dim 256 --instr_dim 128 --log_every 200 --probe_log_every 150 --lr 0.001 --probe_lr 0.001 --output_dir experiments/dense_latent_query_executor/runs/pilot_dense_mod11 --checkpoint_dir large_artifacts/dense_latent_query_executor/checkpoints/pilot_dense_mod11Status: complete.
Result at final evaluation:
L=3: atK=3, query target mass reached 83.6-91.5%; probe belief target mass reached 79.6-83.9%.L=6: atK=6, query target mass reached 62.1-77.4%; probe belief target mass reached 56.6-61.3%.L=9: atK=9, query target mass reached 46.7-60.5%; probe belief target mass reached 37.9-40.3%.L=12: atK=12, query target mass reached 40.8-53.4%; probe belief target mass reached 30.6-32.8%.
Interpretation: the dense recurrent model learned a real recurrent execution signal from sampled query labels. The K threshold is visible, and a frozen probe can recover substantial belief information from the dense hidden state. However, the result is not near-exact, and held-out lengths degrade sharply. This is a meaningful positive pilot but not a saturated architecture.
Control 1: Dense Static Compiler, Modulus 11
Run: ../runs/control_static_mod11
Command:
python experiments/dense_latent_query_executor/src/dense_latent_query_executor_experiment.py --mode static --modulus 11 --observe_mod 4 --observe_prob 0.3 --train_max_len 6 --eval_lengths 3,6,9,12 --eval_k 0,1,2,3,6,9,12 --train_steps 3000 --batch_size 512 --eval_batch_size 512 --eval_examples 512 --probe_steps 1500 --probe_batch_size 512 --state_dim 256 --instr_dim 128 --heads 4 --compiler_layers 2 --log_every 200 --probe_log_every 150 --lr 0.001 --probe_lr 0.001 --output_dir experiments/dense_latent_query_executor/runs/control_static_mod11 --checkpoint_dir large_artifacts/dense_latent_query_executor/checkpoints/control_static_mod11Status: complete.
Result at final evaluation:
L=3: query target mass reached 69.3-78.8%; probe belief target mass reached 50.3-57.5%.L=6: query target mass reached 39.3-52.7%; probe belief target mass reached 23.6-25.6%.L=9: query target mass reached 22.9-27.7%; probe belief target mass reached 4.1-5.1%.L=12: query target mass reached 17.3-21.1%; probe belief target mass reached 2.2-2.8%.
Interpretation: the static compiler learns some short-program sampled-query signal but does not preserve the recurrent model's held-out length behavior. Its probed belief state collapses on lengths beyond training.
Control 2: Shuffled Dense Recurrent Executor, Modulus 11
Run: ../runs/control_shuffled_mod11
Command:
python experiments/dense_latent_query_executor/src/dense_latent_query_executor_experiment.py --mode shuffled --modulus 11 --observe_mod 4 --observe_prob 0.3 --train_max_len 6 --eval_lengths 3,6,9,12 --eval_k 0,1,2,3,6,9,12 --train_steps 3000 --batch_size 512 --eval_batch_size 512 --eval_examples 512 --probe_steps 1500 --probe_batch_size 512 --state_dim 256 --instr_dim 128 --log_every 200 --probe_log_every 150 --lr 0.001 --probe_lr 0.001 --output_dir experiments/dense_latent_query_executor/runs/control_shuffled_mod11 --checkpoint_dir large_artifacts/dense_latent_query_executor/checkpoints/control_shuffled_mod11Status: complete.
Result at final evaluation:
L=3: at sufficientK, query target mass reached 71.8-84.2%; probe belief target mass reached 46.9-50.3%.L=6: at sufficientK, query target mass reached 39.5-45.7%; probe belief target mass reached 16.7-17.6%.L=9: at sufficientK, query target mass reached 24.0-28.2%; probe belief target mass reached 5.4-6.1%.L=12: at sufficientK, query target mass reached 18.7-20.9%; probe belief target mass reached 2.7-3.3%.
Interpretation: preserving instruction content while destroying order removes most of the dense recurrent model's held-out behavior. This supports the interpretation that the ordered dense model is learning a sequential update, not only a bag-of-instructions heuristic.
Main Run: Dense Recurrent Executor, Modulus 31
Run: ../runs/main_dense_mod31
Command:
python experiments/dense_latent_query_executor/src/dense_latent_query_executor_experiment.py --mode dense --modulus 31 --observe_mod 5 --observe_prob 0.3 --train_max_len 8 --eval_lengths 4,8,12,16,24 --eval_k 0,1,2,4,8,12,16,24 --train_steps 5000 --batch_size 512 --eval_batch_size 512 --eval_examples 512 --probe_steps 2000 --probe_batch_size 512 --state_dim 256 --instr_dim 128 --log_every 250 --probe_log_every 200 --lr 0.001 --probe_lr 0.001 --output_dir experiments/dense_latent_query_executor/runs/main_dense_mod31 --checkpoint_dir large_artifacts/dense_latent_query_executor/checkpoints/main_dense_mod31Status: complete.
Result at final evaluation:
L=4: atK=4, query target mass averaged 70.2%; query top-1 on support averaged 79.1%; probe belief target mass averaged 41.6%.L=8: atK=8, query target mass averaged 49.3%; query top-1 on support averaged 59.3%; probe belief target mass averaged 18.8%.L=12: atK=12, query target mass averaged 36.1%; query top-1 on support averaged 44.6%; probe belief target mass averaged 12.0%.L=16: atK=16, query target mass averaged 29.6%; query top-1 on support averaged 37.1%; probe belief target mass averaged 8.8%.L=24: atK=24, query target mass averaged 21.5%; query top-1 on support averaged 28.8%; probe belief target mass averaged 5.7%.
Best query mass before K>=L was 44.9%, 21.8%, 14.9%, 10.8%, and 6.0% for lengths 4, 8, 12, 16, and 24. Best probe belief mass before K>=L was 11.3%, 2.5%, 1.4%, 0.8%, and 0.3%.
Interpretation: the dense recurrent model shows a real execution-threshold signature, but it is weak at the scaled modulus. The state contains recoverable belief information and improves sharply when K reaches L, yet the dense hidden state does not form a near-exact belief executor under sampled-query supervision alone. This is a partial positive result with a clear scaling limitation.
Scaled Control: Dense Static Compiler, Modulus 31
Run: ../runs/control_static_mod31
Command:
python experiments/dense_latent_query_executor/src/dense_latent_query_executor_experiment.py --mode static --modulus 31 --observe_mod 5 --observe_prob 0.3 --train_max_len 8 --eval_lengths 4,8,12,16,24 --eval_k 0,1,2,4,8,12,16,24 --train_steps 5000 --batch_size 512 --eval_batch_size 512 --eval_examples 512 --probe_steps 2000 --probe_batch_size 512 --state_dim 256 --instr_dim 128 --heads 4 --compiler_layers 2 --log_every 250 --probe_log_every 200 --lr 0.001 --probe_lr 0.001 --output_dir experiments/dense_latent_query_executor/runs/control_static_mod31 --checkpoint_dir large_artifacts/dense_latent_query_executor/checkpoints/control_static_mod31Status: complete.
Result at final evaluation:
L=4: static query target mass averaged 50.4%; query top-1 on support averaged 54.8%; probe belief target mass averaged 13.0%.L=8: static query target mass averaged 26.9%; query top-1 on support averaged 29.1%; probe belief target mass averaged 3.7%.L=12: static query target mass averaged 13.6%; query top-1 on support averaged 11.8%; probe belief target mass averaged 0.8%.L=16: static query target mass averaged 9.0%; query top-1 on support averaged 9.5%; probe belief target mass averaged 0.4%.L=24: static query target mass averaged 5.5%; query top-1 on support averaged 5.6%; probe belief target mass averaged 0.2%.
Interpretation: the one-pass static compiler learns some short-program query signal but does not match the dense recurrent model's length-generalizing threshold. The gap is especially clear in the probe-belief metric: even where static query mass is nontrivial, recoverable belief mass remains low and collapses on held-out lengths.
Final Analysis Pass
Command:
PYTHONDONTWRITEBYTECODE=1 python experiments/dense_latent_query_executor/src/analyze_dense_latent_query_executor.pyStatus: complete.
Generated:
../analysis/all_metrics_long.csv../analysis/final_metrics_long.csv../analysis/final_metrics_query_mean.csv../analysis/mod31_threshold_summary.csv../analysis/mod31_per_query_threshold_summary.csv../analysis/mod31_control_summary.csv../analysis/summary.md../analysis/figures/
Figures 7







Data files 18
Result tables and metrics copied from the experiment folder — preview inline or open the raw file.
analysis/all_metrics_long.csv83 kBanalysis/final_metrics_long.csv83 kBanalysis/final_metrics_query_mean.csv11 kBanalysis/mod31_control_summary.csv1.8 kBanalysis/mod31_per_query_threshold_summary.csv2.4 kBanalysis/mod31_threshold_summary.csv947 Bruns/control_shuffled_mod11/metrics_final.csv16 kBruns/control_shuffled_mod11/results.json72 kBruns/control_static_mod11/metrics_final.csv2.5 kBruns/control_static_mod11/results.json18 kBruns/control_static_mod31/metrics_final.csv3.1 kBruns/control_static_mod31/results.json22 kBruns/main_dense_mod31/metrics_final.csv23 kBruns/main_dense_mod31/results.json100 kBruns/pilot_dense_mod11/metrics_final.csv16 kBruns/pilot_dense_mod11/results.json72 kBruns/smoke_dense_mod7/metrics_final.csv4.2 kBruns/smoke_dense_mod7/results.json20 kB
Reproduce
The run commands are documented inside the experiment folder (see the README).