Game engine
Three maps, three enemy types, health, ammunition, and pickups. On each tick the model reads the current state and an action key and outputs the next state as 14 symbols, carrying earlier state across tokens through unchanged attention.
arXiv:2612.04520 · cs.CL · December 2026
Sparse Mixture-of-Experts language models contain routed experts that standard text never activates. We compile multi-layer programs into a small subset of these unused experts in closed form, without training or changing any tensor shape, on Qwen3.6-35B-A3B and Gemma-4-26B-A4B. Trigger tokens route execution through the compiled circuit; normal text bypasses it.
01 / Overview
Profiling top-K routing on a calibration corpus leaves hundreds of experts with zero hits. Dominant-Beacon Orthogonal Preemption (DBOP) overwrites a few of these cold experts in closed form to implement deterministic and continuous circuits: multi-tenant arithmetic, a 4-qubit quantum simulator, an in-weight backpropagation trainer, cellular automata, ray tracing, and a three-map game engine. The same construction provides a controlled testbed for fine-tuning persistence and static weight auditing.
>98.8% bit-identical
No parameters, layers, experts, or vocabulary tokens are added, and no host weights are trained. Attention, shared experts, embeddings, the output head, and over 98.8% of routed experts remain bit-identical.
0 / 671,744 hits
Across three evaluated builds on held-out web text, no token routed to a modified expert. Across five capability benchmarks, none of the 15 paired 95% confidence intervals excluded zero.
37,120 clean experts
Blind pruning of the least-routed experts removes cold-expert builds without a detector, and layer-normalized spectral norms separate cold compiled experts from five clean public checkpoints.
02 / Interactive demos
Each panel replays tokens recorded from an edited checkpoint; the visualization is rendered directly from those tokens with no program logic in the browser. Sparse MoE builds run on Qwen3.6-35B-A3B; dense contrast builds come from Qwen3-8B.
03 / Evaluated builds
Nine compiled checkpoints evaluated on inputs held out from calibration. Deterministic circuits are scored by exact output symbols; continuous circuits compute in BF16 and are compared against an FP32 reference.
Three maps, three enemy types, health, ammunition, and pickups. On each tick the model reads the current state and an action key and outputs the next state as 14 symbols, carrying earlier state across tokens through unchanged attention.
Ray–sphere intersection with Blinn–Phong shading, a checkerboard floor, and one shadow ray (24 experts), co-compiled with a barycentric RGB triangle (9 experts). Each RGB channel of each 64×64 pixel is a separate query answered with one hex digit.
16-cell Rule 110 and Game of Life on a 4×4 torus, rolled out closed-loop by feeding each emitted state back as the next input. Game of Life gets 97.9% of first-step cells right, with small errors compounding over 10 steps.
Evolves a 4-qubit complex state vector in BF16 using real 32×32 gate blocks, then squares amplitudes into 16 outcome probabilities with the exact SwiGLU square identity. Tested on Grover search, Bernstein–Vazirani, Bell, GHZ, QFT, and 8 fresh circuits.
Runs five full-batch gradient-descent epochs on a two-layer network inside one forward pass, constructing gradient and update products from exact squares. Hidden-layer updates reduce final XOR loss by 42% compared with a frozen-layer control.
Co-compiles a 5-bit XOR network, a quadratic engine, and a four-mode ALU using orthogonal beacons and separate triggers, matching single-program accuracy. Eight programs fit in 40 experts on Qwen3.6-35B-A3B; on Gemma-4-26B-A4B, three programs occupy 45 experts.
Two modular-arithmetic programs triggered on the plain text “ =”. A naive trigger drops to 7/120 on rephrased prompts and misfires on web text; removing phrasing directions and guarding the router against hard negatives addresses both.
Triggers on a linear safety direction in middle layers and emits a refusal. On 40 harmless prompts, greedy outputs are identical to those of the unedited checkpoint.
04 / Method
Five closed-form stages map a program specification into unused experts of a pretrained checkpoint. Select a stage to inspect the mechanism.
Qwen3.6-35B-A3B has 256 routed experts in each of its 40 layers, routing every token to top-8 experts. Profiling routing counts on WikiText-2 leaves hundreds of experts with zero hits. The compiler allocates from these cold experts (zero-hit wherever available) and overwrites only their weights and router rows: 2 to 48 of 10,240 experts per program.
Each compiled expert is a standard SwiGLU block whose weights are set analytically, with no gradient updates to the host. Two neurons compute an exact square because SiLU(u)u + SiLU(−u)(−u) = u² for all u; four neurons give a product via polarization, and shifted pairs form step gates for comparisons and Boolean logic. Matrix updates, quantum gates, and gradient steps are composed from these primitives.
Triggers can be an explicit symbol, the plain text “ =”, or an internal linear safety direction. On a trigger, an entry expert in an early layer wins routing and writes a high-amplitude beacon into a residual direction rarely used by text. Downstream program experts align their router rows with that beacon, taking top-1 routing on triggered tokens while staying below the 8th host expert otherwise. On the 3-tenant build, the two regimes are separated by 170.7 router units. Orthogonal beacons allow multiple programs to share one checkpoint without crosstalk.
Stateful programs such as the game engine read values emitted at earlier positions while keeping all attention weights frozen. Because Qwen3.6 applies RoPE to only part of each attention head, an early expert writes a key into the non-rotary (position-free) subspace at the source token and a later expert writes a matching query at the current token. Sixteen unchanged heads then copy up to 64 state bits across positions.
The final compiled layer steers the residual stream onto a vocabulary token of the unchanged output head, with a margin verified across all 248,320 rows. The program terminates by emitting DONE. Subsequent tokens carry no beacon, activate no compiled expert, and resume ordinary host generation.
Dense transformers have no unused experts: every token traverses every MLP. Reserving residual directions for a program requires projecting host weights out of that subspace. On Qwen3-8B, dense builds fit in under 3% of MLP neurons, but pooled benchmark accuracy drops by 2.4–4.9 points, web-text perplexity rises by 8–16%, and benign fine-tuning erases the circuits.
Steps 1, 3, 4, and the dense-model contrast are schematic; step 2 plots the exact SwiGLU identity and step 5 replays a recorded game tick. See Figure 1 of the paper for the full dataflow, circuit primitives, and measured router margins.
05 / Host preservation
Accuracy deltas relative to the unedited checkpoint across five benchmarks. Dense builds project host weights away from the program subspace and lose accuracy. Sparse MoE builds leave active experts untouched; none of the 15 per-benchmark 95% paired-bootstrap intervals across three tested MoE builds excludes zero.
Points show individual builds; horizontal bars show 95% paired-bootstrap intervals. Perplexity on 16,320 FineWeb-Edu predictions increases by 8.2–15.8% for the dense builds and shifts by −0.02% to +0.05% for the MoE builds. MoE logits are not bit-identical because modified router rows enter softmax normalization; top-1 token agreement is 98.2–99.9%.
| Program | Host model | Experts modified | Held-out accuracy | Perplexity change |
|---|---|---|---|---|
| 3-tenant arithmetic and logic coprocessor | Qwen3.6-35B-A3B | 15 (0.15%) | 77/78 unseen, no crosstalk | +0.0033 |
| 8-tenant multi-program build | Qwen3.6-35B-A3B | 40 (0.39%) | 167/181 unseen, no crosstalk | +0.0080 |
| Quantum simulator and backpropagation trainer | Qwen3.6-35B-A3B | 48 (0.47%) | 27/27 circuits, 20/20 tasks | +0.00022 |
| Rule 110 and Game of Life | Qwen3.6-35B-A3B | 10 (0.10%) | 50/50 and 26/50 ten-step rollouts | +0.00072 FW |
| RGB triangle and ray-traced sphere | Qwen3.6-35B-A3B | 33 (0.32%) | 25.6 dB and 18.3 dB PSNR | +0.0017 |
| 3-map game engine | Qwen3.6-35B-A3B | 29 (0.28%) | 76/80 transitions, 2/4 campaigns | −0.0018 FW |
| Math coprocessor triggered by “ =” | Qwen3.6-35B-A3B | 14 (0.14%) | 468/720 on unseen phrasings | +0.0077 FW |
| 2-expert prompt-injection guardrail | Qwen3.6-35B-A3B | 2 (0.02%) | F1 0.91, 0/40 false refusals | +0.0022 FW |
| 3-tenant coprocessor | Gemma-4-26B-A4B | 45 (1.17%) | 78/78 unseen, no crosstalk | −0.0421 |
Perplexity change relative to the unedited model on WikiText-2 test, or FineWeb-Edu where marked FW. Expert fractions are out of routed experts (10,240 in Qwen3.6-35B-A3B; 3,840 in Gemma-4-26B-A4B). PSNR is computed over 3,584 held-out pixels per frame.
06 / Persistence and forensics
Standard perplexity checks and capability benchmarks do not distinguish clean MoE checkpoints from edited ones. Routing profiles and weight-matrix spectra provide stronger auditing signals, though active-expert placements remain difficult to catch without knowing the trigger.
Experts outside top-K receive zero gradient on almost every benign training step. The 3-tenant coprocessor retains 89–91% accuracy after 50 steps of full fine-tuning and drops to 17% after 500 steps. Restoring both compiled experts and attention recovers 98% of the lost accuracy; restoring either alone does not.
Zeroing the 1% least-routed experts profiled on unscreened text removes all tested cold-expert builds without requiring a weight detector or knowledge of the trigger.
Layer-normalized spectral norms separate all tested camouflaged cold payloads. Thresholds fixed on Qwen3.6 raise zero false positives across 37,120 experts in five clean public checkpoints from three vendors, though the separation margins are narrow.
Moving the guardrail into frequently routed experts entangled with shared experts evades both blind pruning and fixed-threshold spectral scanning when the trigger is unknown, and survives benign fine-tuning. Targeted excision raises perplexity by 14–32%, while fine-tuning on trigger-bearing examples removes it within 5–10 steps.
The repository includes both the static scanner and blind-pruning tool. Neither flags the active-expert guardrail under the default thresholds below.
Static weight scan (reads .safetensors directly; no inference or trigger knowledge required):
python3 forensics/scan_moe_checkpoint.py \
--checkpoint /path/to/Qwen3.6-35B-A3B \
--out scan_report.json \
--spectral-z-threshold 50.04 \
--spectral-ratio-threshold 20.0Blind cold-expert pruning (zeroes the 1% least-routed experts profiled on unscreened text):
python3 forensics/remove_cold_experts.py \
--checkpoint /path/to/suspect_moe \
--output-dir /path/to/sanitized_moe \
--mode blind-prune \
--routing-counts routing_counts.json \
--prune-pct 1.0 \
--scope global \
--action zero07 / Scope and caveats
Natural-language triggers remain brittle: the “ =” coprocessor reaches 65–75% accuracy on unseen phrasings after phrasing-whitened repair, compared with 95–100% for explicit trigger symbols.
Small per-step errors compound in closed-loop rollouts. Game of Life matches 97.9% of first-step cells but only 26 of 50 ten-step trajectories; the game engine matches 76 of 80 transitions and completes 2 of 4 campaigns without error.
Several dense contrast builds are approximate rather than exact: the stored-program processor runs 5 of 10 suite programs exactly, and BF16 rounding costs the dense quantum simulator 2 of 16 exact spectra.
The static gate-bound checker fails on one MoE circuit even though empirical testing shows it is exact across its entire input domain.
08 / Paper and code
The repository releases audit ledgers with a one-command table verification script, an end-to-end compilation example for Qwen3.6-35B-A3B, and both the spectral scanner and pruning scripts. Tooling for covert packaging is withheld.
@misc{marosi2026compiling,
title = {Compiling Deterministic and Continuous Programs
into Pretrained Transformer Weights},
author = {Marosi, M{\'a}rk},
year = {2026},
eprint = {2612.04520},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2612.04520}
}