SO-CODE at four layers (L4-CODE): depth at a fixed integration time gains 8.5% on code, on every kind of token (Gen 3)
The question of this collection: on Python code, the conservative model trails the matched GPT-2 by 21% at two layers. Does depth help? Each layer of this model advances the token states by one step Δt of a damped second-order flow in a learned potential; the collection holds the total integration time T = L · Δt = 8 fixed and splits it into more, shorter steps, so that only the number of layers changes.
This model (L4-CODE): SO-CODE at four layers, Δt = 2 (SO-CODE: two layers, Δt = 4). Verdict: depth gains 8.5%, the largest gain of any change tried on code, and the gain is general. It settles at 5.48 against SO-CODE's 6.00 and closes 47% of SO-CODE's gap to the matched GPT-2 (4.96), about equally on every kind of token: names copied from far back gain no more than first occurrences, which have nothing to copy. The depth-on-code collection holds the same model at two, four and eight layers.
Result
| model | layers | step Δt | settled perplexity | against SO-CODE |
|---|---|---|---|---|
| SO-CODE, the baseline | 2 | 4 | 6.00 | — |
| L4-CODE (this model) | 4 | 2 | 5.48 | −8.5% |
| L8-CODE | 8 | 1 | 5.35 | −10.7% |
For comparison, on the same code tokens and schedule:
| model | what changes from SO-CODE | settled perplexity | against SO-CODE |
|---|---|---|---|
| matched GPT-2 (not on the Hub) | a transformer, 8 layers, d = 384 | 4.96 | −17.3% |
| FOCK-CODE (not on the Hub) | the Fock register path on | 5.66 | −5.6% |
| FO-b-CODE | trained as a first-order gradient flow | 6.55 | +9.2% |
- This model: settled 5.48 (the mean of the log perplexities of the evals at steps 18,000, 18,500 and 19,000: 5.37, 5.50, 5.59); best 5.37 at step 18,000. Validation perplexity at block 512, on the first 2M tokens of CodeParrot's validation files (a file-level split, so no file is in both).
- Trained on exactly 315,392,000 tokens (19,250 steps × 32 × 512): the ladder's WSD schedule over 16,250 steps, then 3,000 steps at its floor learning rate. SO-CODE and this model start from step 0 at seed 0 on the same batches, so their evaluations are paired step by step.
- 76,625,361 parameters, 53,252 more than SO-CODE's 76,572,109. The layers share V_θ's well bank, V_φ and the context channels; the extra parameters are the two new layers' depth code for the bank (3,840), their V_φ scales (2) and their register destruction gates (49,410), which have no path to the tokens in this conservative-only model. Depth here adds steps, not capacity.
- Pre-registered (
Code_Depth_Runs.md, the XI6-CODE and L4-CODE proposal under entryp-so-code): L4a (L4-CODE settles more than 5% below SO-CODE, below 5.70), called 60%: HIT, 5.48, −8.5%. L4b (its gain is long-range: in the copy split it closes a larger share of the gap on targets last seen 65–512 tokens back than on those last seen 1–16 back), called 55%: HIT on the letter, +2.9 points, but not distinguishable from no difference (95% interval −1.8 to +7.9 points). Registered 2026-10-27, before the run. - Run health: 19,250 steps in 10.9 h in one session from step 0 (2.04 s per step, no layer checkpointing in training, checkpointing during evaluation only); 0 watchdog triggers; largest rise between logged training losses 0.071 (step 13,050, where SO-CODE's largest is 0.073); gradient norm median 0.38 after step 2,000, maximum 2.06 (step 550, warmup); SCAF leak monitor CLEAN at all 4 audits.
Paired by step
The mean difference in log perplexity (nats) between two models over a span of evaluations, with the standard deviation of the per-evaluation differences. FOCK-CODE, trained from step 0 on the same batches, is the other route that helped on code.
| steps | L4-CODE − SO-CODE | L4-CODE − FOCK-CODE |
|---|---|---|
| 2,000–4,000 (5 evals) | −0.293 (SD 0.066), −25.4% | −0.095 (SD 0.040), −9.1% |
| 8,000–13,000 (11 evals) | −0.098 (SD 0.007), −9.3% | −0.025 (SD 0.003), −2.5% |
| 16,000–19,000 (7 evals) | −0.088 (SD 0.004), −8.4% | −0.030 (SD 0.003), −3.0% |
- Behind in warmup, far ahead early, a fixed lead late. This model trails SO-CODE at steps 500 and 1,000 (+6%), leads from step 1,500, most at step 2,500 (−32%: 10.78 against 15.80), and from step 11,000 on stays 8–9% ahead.
- The late lead is consistent: −0.088 nats with an SD of 0.004 per evaluation; the gap's fitted change over the last 3,000 steps is 0.000 nats. One seed each.
- Training loss over steps 16,000–19,250: 1.604 for this model, 1.687 for SO-CODE. It fits the training data better by about as much as the validation data; it does not overfit.
Through training
| step | phase | SO-CODE | L4-CODE | against SO-CODE |
|---|---|---|---|---|
| 500 | warmup | 44.02 | 46.79 | +6.3% |
| 1,000 | stable | 25.13 | 26.63 | +6.0% |
| 1,500 | stable | 20.33 | 17.68 | −13.0% |
| 2,000 | stable | 17.67 | 12.86 | −27.2% |
| 2,500 | stable | 15.80 | 10.78 | −31.8% |
| 3,000 | stable | 12.96 | 9.55 | −26.3% |
| 4,000 | stable | 10.62 | 8.60 | −19.0% |
| 5,000 | stable | 9.27 | 7.95 | −14.2% |
| 8,000 | stable | 7.96 | 7.12 | −10.6% |
| 10,000 | stable | 7.45 | 6.71 | −9.9% |
| 13,000 | decay | 6.38 | 5.86 | −8.2% |
| 16,000 | decay, end | 6.12 | 5.61 | −8.3% |
| 18,000 | floor | 5.87 | 5.37 | −8.5% |
| 19,000 | floor, last eval | 6.10 | 5.59 | −8.4% |
Where the gain is: the copy split
Every validation target (262,144 tokens in 512 windows of 512) is put in groups by what the context offers for it: a first occurrence does not occur earlier in the window, a repeat does, an induction target follows a token pair seen earlier; and by how far back its last earlier occurrence lies. For each group, the table gives the share of SO-CODE's per-token gap to the matched GPT-2 that a model closes (debug/copy_split.py, best checkpoints).
| targets | share of all targets | L4-CODE closes | FOCK-CODE closes |
|---|---|---|---|
| all | 100% | 47.4% | 30.4% |
| first occurrences (nothing to copy) | 27.7% | 47.4% | 33.4% |
| induction targets | 50.0% | 49.4% | 28.3% |
| indentation, newline, space | 21.9% | 33.9% | 21.1% |
| identifiers last seen 1–16 / 65–512 tokens back | 10.0 / 7.7% | 48.5 / 48.0% | 24.3 / 31.4% |
| repeats and induction targets last seen 1–16 / 17–64 / 65–512 back | 34.8 / 25.2 / 12.3% | 45.2 / 48.6 / 48.1% | 26.5 / 30.8 / 29.7% |
- Depth's gain is general. It closes about half of the gap in every group, first occurrences as much as induction targets. Its gain per token grows with the distance (−0.049 nats at 1–16 tokens back, −0.165 at 65–256) only because the gap it scales does. What remains keeps SO-CODE's shape: concentrated in identifiers, growing with the distance.
- Far against near: 48.1% against 45.2%, +2.9 points; 95% interval over windows by a bootstrap −1.8 to +7.9. The register path gives the same reading (+3.2 points). Neither is a long-range gain beyond the noise.
The wells, layer by layer
V_θ is a bank of eight anisotropic Gaussian wells whose centres, widths and depths are computed from the context, shared by all layers and told apart by a learned depth code. The nearest-well ratio is the distance from a token's state to the nearest well centre, divided by the state's norm; the occupancy of a well is exp(−½ (h − μ)ᵀ P (h − μ)), the factor its force and its gradient both carry; n_eff is the effective number of wells in the layer's weights (the exponential of the entropy of the softmax weights, which depend on the context only, not on the state); the removal cost is the perplexity change when every well of one layer is switched off on the trained model. Readings by debug/vtheta_well_probe.py on 16 validation windows (perplexity 6.95 on them).
| reading (step 18,000) | layer 0 | layer 1 | layer 2 | layer 3 |
|---|---|---|---|---|
| nearest-well ratio, median (p99) | 1.33 (2.39) | 1.10 (1.50) | 1.05 (1.39) | 1.33 (1.75) |
| occupancy, strongest well | 0.76 | 0.35 | 0.12 | 0.04 |
| wells in use (n_eff) | 7.5 | 1.5 | 1.6 | 1.3 |
| force carried by two wells (the same two in every layer) | 52% | 100% | 100% | 100% |
| removal cost of the layer's wells | +4,127% | +146% | +57% | +3.6% |
- No dead wells at any checkpoint. From step 500 to the end the median nearest-well ratio stays between 0.82 and 1.33 in every layer; the failure described in
Dead_Wells_in_the_Joint_V_theta_Bank.mddoes not occur at L = 4. - The deep layers run on two wells, the first layer on all eight. In layers 1–3 the same two wells carry all the force from step 500 on; the other six sit two to five state norms away and carry none. Layer 0 uses all eight, wide and near the states. SO-CODE has the same split: keeping only its two working wells in layer 1 costs it 0.0%, keeping two in layer 0 costs +1,980%.
- The layers matter less with depth: removing layer 0's wells breaks the model, removing layer 3's costs a few per cent.
Diagnostics
Refinement (Cell 6b-7). The trained layers are applied N times with the step changed, the loss read on 12 fixed validation batches. Gate 2 keeps Δt = 2 and lets T grow; Gate 3 keeps T = 8 and refines Δt = 8/N, the test of whether the layers approximate a continuous flow (the loss levels off as Δt shrinks) or are maps tied to the trained step.
| N | Gate 2, perplexity | Gate 3, perplexity | Gate 3 penalty, nats |
|---|---|---|---|
| 1 | 50.33 | 155.70 | 3.508 |
| 2 | 22.23 | 121.01 | 3.256 |
| 3 | 6.17 | 8.82 | 0.638 |
| 4 (trained) | 4.66 | 4.66 | 0.000 |
| 6 | 6.28 | 6.75 | 0.370 |
| 8 | 9.85 | 14.46 | 1.132 |
| 12 | 53.91 | 2.448 | |
| 16 | 82.16 | 2.869 |
- A map, not a flow, as for every second-order model in this programme: the loss is lowest at the trained step and rises on both sides. Close to the trained step it rises more slowly than SO-CODE's: one step finer costs 0.37 nats, half the step 1.13 nats (SO-CODE at its own half step: 1.42).
- Resetting the velocity costs +76% (Gate 1: every layer starts from rest instead of from the velocity the previous layer handed on), against SO-CODE's +4%. At four layers the model relies on the carried velocity far more.
- Stiffness (Cell 6b-13): ω·Δt median 2.20 at Δt = 2 (ω = 1.10; SO-CODE 7.55 at Δt = 4, ω = 1.89); by layer 3.00, 2.79, 1.47, 0.89; 53.6% of readings past 2. The deeper layers are softer, and the last two mostly within the explicit-integrator limit. The integrator treats the stiff modes exactly, so this is a reading of stiffness, not of instability.
- Retrieval per layer is SO-CODE's, repeated. In each of layers 1–3 one long context channel (channel 3) finds earlier occurrences 65 or more tokens back at 22, 28, 21 times an even spread (
debug/xi_reach.py); SO-CODE's layer 1 does it at 26.
A reading
In Dead_Wells_in_the_Joint_V_theta_Bank.md, §8, a conjecture says that on code the model is limited by what it does with what its context channels retrieve, not by the retrieval: more retrieval (a sixth channel) did not help, and capacity after retrieval should. This model is the first test, and it is consistent with it: the retrieval per layer is unchanged, each deep layer again acts through two wells, and the gain comes with more steps of readout on the same retrieval, spread over every kind of token. An interpretation, not a measured mechanism.
Reproduction
colab_fock_cfc_baoab_lowrank_depth_ladder_openwebtext_d384.ipynb, Cell 0 changed from the defaults:
REVERSE_CHANNEL=False, VPHI_GRAD_PATH='live', XI_GRAD_PATH='live',
LOWRANK_DAMPED_FLOW=True, # SR2
VPHI_ANALYTIC_FORCE=True, LAYER_CHECKPOINT=False, # speed switches, same arithmetic
CORPUS='code', LADDER_STEPS=16_250, EXTRA_FLOOR_STEPS=3_000 # Python code, then 3,000 steps at the floor
LADDER_L=4 # four layers; dt = T / L = 2, T = 8 as at L = 2
EVAL_LAYER_CHECKPOINT=True # layer checkpointing during evaluation only (memory), same arithmetic
SNAPSHOT_STEPS=[1_000, 1_500, 2_000, 2_500, 3_000] # weights-only snapshots for the well probe
Run Cells 0, 1, 1b, 1c, 1d, 2, 3, 4, 5, 5b and 6, then 8, 7, 6b-7 and 6b-13 (one A100 80 GB; training peaks at 60.5 GB without layer checkpointing, evaluation at 60.7 GB with it). The first code run builds the token cache (about 25 minutes). The well probe is debug/vtheta_well_probe.py, the channels' reach debug/xi_reach.py, the copy split debug/copy_split.py (CPU, on the downloaded run folder).
Training artefacts were written to semsimula_fock_cfc_baoab_code_xi5long_topk16_dt32da16_mh4_aniso_dcvt5x8_vtjoint_cgqk_norc_vplive_xilive_sr2_st16250_L4probe_ob_untied_wsd_e5c_plgate_rep0.05_fockreg0.005_g0.1_baoab_cfc_lowrank_idt2_lr0p0012_noattn/.
Glossary
| term | meaning |
|---|---|
| settled PPL | validation perplexity at block 512, the mean of the last three evals (on this corpus, steps 18,000–19,000). Best is the lowest single eval |
| Gen 1 / Gen 2 / Gen 3 | the model generations. Gen 1: explicit integrators. Gen 2: the CfC/BAOAB ladder with the sources of Vφ and ξ (and of an exchange field) detached, which keeps every force causal, but no loss gradient ever reaches an earlier token through them. Gen 3: the same forward pass with those gradients live |
| live / detached gradients | whether the loss gradient flows into the earlier tokens that act as sources of a force. Detaching changes no forward value; it only cuts that backward path |
| Vθ | the learned scalar potential on a token's state h, given its context ξ: a bank of anisotropic Gaussian wells. Its negative gradient is the conservative force on the token |
| Vφ | a pair potential between a token and a few selected earlier tokens (sparse top-k) |
| ξ | the causal context channels: exponential moving averages of earlier states at several horizons, which condition Vθ |
| Fock mechanism, registers, reverse channel | a pool of register particles, created and destroyed from the token context. The reverse channel is the register-to-token force; it is not the gradient of any potential on the tokens, so it is the model's non-conservative part |
| exchange field | an attention-like token-to-token interaction added to the conservative core. Each token is pushed by earlier tokens through learned query, key and value projections, as in attention. The ladder tests it in two forms, attention and attention_potential |
attention (non-conservative exchange field) | the exchange term enters as a force directly. It is not the gradient of anything, so the step stops being a geodesic step |
attention_potential (attention as a potential) | the same interaction written as a scalar potential whose gradient is the force. The routing weights are computed from the hidden states and held fixed with respect to the state being moved, so the force stays an exact gradient and the model stays conservative |
no-exchange (LADDER_MECHANISM = 'none') | the arm with no exchange field at all: Vθ, Vφ and ξ, plus the Fock register mechanism unless the arm is conservative-only |
live exchange field (RELAX_GRAD_PATH = 'live') | attention_potential with the identical forward force written out over live tensors, so the loss gradient reaches the field's sources and routing. In Gen 2 these were detached, and the field sent no gradient into any hidden state |
| Gen 2 probe | a Gen 2 arm retrained with one gradient path changed, to test a hypothesis before the full Gen 3 ladder. The live-exchange-field probe (attention_potential with RELAX_GRAD_PATH = 'live', the full 32,500 steps) is the one that found the gradient starvation |
| gpt2-matched | the reference transformer: GPT-2 architecture, d = 384, L = 8, tied embeddings (33.7M parameters), trained on the same tokenizer, corpus, batches and token budget. Shared by Gen 2 and Gen 3 |
tag components (vplive, xilive, rglive, norc, L4probe, idt…) | pieces of the run's variant tag, so that every configuration gets its own Drive folder: live Vφ sources, live ξ, live exchange field, no reverse channel, the depth L, and the integrator step Δt |
| conservative-only | a model in which every force is a gradient: no reverse channel and no non-conservative exchange field |
| CfC/BAOAB low-rank propagator | the integrator. Each layer step is split into position (A), force kick (B) and friction (O) substeps, and the stiff harmonic modes of Vθ are integrated exactly in closed form |
| ω·Δt, θ | a stiff mode's frequency times the step size. Past 2, an explicit integrator would be unstable (the wall); the closed-form propagator is not. θ/sin θ is the factor by which a split step's dissipation depends on the mode's phase, largest near θ = π |
| geodesic step, R(geo), share | the step a damped particle would take under Vθ alone; R(geo) is the distance of the real step from it, relative to the step's length. A component's share is how much it moves that distance (6b-9 attribution) |
| Gates 1–3, FLOW / MAPS | see Terms in the geometry section |
| CG1–CG7, 6b-N | the CfC-geometry experiments, and the ladder-notebook cells that run them |
| SCAF, Tier A, Tier B | the in-flight causal-leak monitor. Its core test changes future tokens and requires the logits at earlier positions to stay bit-identical. Tier A asks the same of the hidden states, as 1 − cos between the clean and perturbed state at each earlier position and layer. Tier B asks whether the perturbation moves any earlier state into a different dominant Vθ well (the basin-crossing rate). All three read 0 for a causal model |
| leak tax, prefix-only | the loss difference between scoring a position with only its prefix and with the full sequence; about 0 for a causal model |
| clip-hit | the share of logged steps whose gradient norm exceeded the clipping threshold (1.0) |
| pre-registered | a prediction recorded, with its threshold, before the run |
Files
| path | what |
|---|---|
README.md | this card |
config.json | architecture, training, result and diagnostics |
checkpoints/fock_cfc_*noattn_step18000_best.pt | weights at the best eval (step 18,000), optimizer state stripped |
results/ | the training log, the diagnostic cells' outputs, the well probe at the step-500 checkpoint, the five snapshots and the best checkpoint (well_probe_*; _L<n>_none = layer n's wells removed, _L0123_none all), the channels' reach (xi_reach_l4code.txt) and the copy split (copy_split_report*.txt, every code model against the matched GPT-2 and against SO-CODE) |
code/ | the notebook and the model code (it also carries later, default-off switches) |
Companion notes
| note | what it covers |
|---|---|
Code_Depth_Runs.md | the run records: entries p-l4-code-launch and p-l4-code-result, the rule that decides L8-CODE (p-l8-code-rule) |
Dead_Wells_in_the_Joint_V_theta_Bank.md | the dead wells of the shared V_θ bank, and §8's conjectures on what limits the model on code |
Caveats
- One seed per model. The pairing removes the evaluation noise, not the training-seed spread, which has not been measured. The 8.5% is a consistent difference between these two runs.
- Not settled by the letter of the settling rule, like every code model: the evals still fall by about 0.02 nats over the last 3,000 steps, against a scatter of 0.015. The paired gap to SO-CODE is flat.
- Code only, without the register path. On OpenWebText depth was measured with the register path on (L = 2 to L = 4: −5.7%); there is no OpenWebText twin of this model. Perplexities on code are not comparable with other corpora's.
- Twice the compute per token. Four layers cost about twice two layers' time per step (2.04 against 1.06 s).
Citation
@misc{Gueorguiev2026SemSim,
author = {Gueorguiev, Dimitar P.},
title = {Semantic Simulation: A Prescriptive Lagrangian Framework
for Semantic Inference --- Conservative Potentials,
Conservative and Non-Conservative Memory, and Competing Mechanisms},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.19712427},
url = {https://doi.org/10.5281/zenodo.19712427},
note = {Version v25 (Nov 9, 2026).
Companion code repository (DOI 10.5281/zenodo.24066016):
\url{https://github.com/dimitarpg13/semsimula-paper}}
}
Card generated from _ladder/ladder.json on 2026-11-17.