Research log Small Model Experimentation
GitHub

Qwen Structural Latent Compiler Expansion

Grown to longer chains

The one idea you need

Rather than writing steps out as text and picking the best-looking guess, the model fills a fixed form — a starting number plus a list of operations — that a calculator then runs. For longer problems, that filled form is copied into a bigger one with more blank rows.

The question

Can a model directly fill in a runnable calculation program instead of writing it out as text, and can that program be stretched to handle much longer calculations?

What we found

Yes, mostly. The model fills fixed slots with operations a calculator runs — no text, no trying many guesses and picking one. After the learned short form was copied into bigger ones, it stayed perfectly correct on 8- and 16-step chains and hit about 83% on the hardest 24-step ones, where reworded versions of a problem still computed identically.

Why it matters

For structured or runnable outputs, let a small model fill fixed operation slots directly rather than generate text and rerank guesses — it is cheaper, repeatable, and you add capacity by copying weights into more slots. Expect some slippage on the longest chains.

Shortest chains, 8 and 16 steps100% correctfinal answer right after the grown solver runs the fixed operation lists
Longest chains, 24 stepsabout 83% correctaccuracy on the hardest, longest problems after growing the slots
Reworded 24-step problems100% matcha differently phrased problem produces the same computation
Both of a reworded pair correct, 24 stepsabout 88%matched problem pairs where both answers came out right
On this page
  1. Results at a glance
  2. Overview
  3. Report
    1. Question
    2. Method
    3. Runs
    4. Results
    5. Figures
    6. Interpretation
    7. Artifacts
  4. Experiment log
  5. Figures
  6. Data files
  7. Reproduce
  8. Related

Results at a glance 3

How often the grown solver got the right answer, by problem length

How to read

Grouped bars show how often the final grown solver reached the right answer for 8-, 16-, and 24-step problems, with three bars each for the plain, reworded, and paired phrasings. Taller bars are better.

0%25%50%75%100%100%100%100%length 8100%100%100%length 1682.8%100%93.8%length 24

Takeaway → Bars stay at full height for 8- and 16-step problems and dip only for the longest, so stretching the solver cost almost nothing on what it already handled.

Data table
program lengthstandardparaphrasepaired
length 8100%100%100%
length 16100%100%100%
length 2482.8%100%93.8%

Numbers from experiments/qwen_structural_latent_compiler_expansion/reports/aggregate_metrics.csv (main run, stage3_max24 rows)

Technical framing

Executable accuracy after expansion to 24 slots, by program length — The final 24-slot compiler keeps perfect accuracy on length-8 and length-16 programs and reaches 82.8-100% on length-24 splits.

Accuracy as longer problems were added in stages

How to read

Lines track answer accuracy over training for the plain phrasing, one line per problem length; each line begins when that length is first introduced. Higher lines are better.

80%90%100%110%400600length 8length 16length 24

Takeaway → Each length's line holds near the top as longer ones are added — the 16-step line even climbs to perfect — so adding longer problems never dragged shorter ones down.

Data table
training step (stage ends: 300, 450, 750)length 8length 16length 24
300100%
450100%98.4%
750100%100%82.8%

Numbers from experiments/qwen_structural_latent_compiler_expansion/reports/aggregate_metrics.csv (main run, all stages, standard splits)

Technical framing

Accuracy across expansion stages (standard split) — Expanding from 8 to 16 to 24 slots never degrades shorter lengths; length 16 starts at 98.4% and reaches 100%, length 24 ends at 82.8%.

Do reworded versions of a problem solve the same way?

How to read

Grouped bars show three checks — both rewordings correct, the same internal steps, and matching partial steps — for 8-, 16-, and 24-step problems. Taller is better.

0%25%50%75%100%100%100%100%length 8100%100%100%length 1687.5%87.5%99.2%length 24

Takeaway → Consistency holds at full height for 8- and 16-step problems and eases only to about seven-eighths for the longest, so rewordings mostly solve the same way.

Data table
program lengthboth paraphrases correctlatent state-trace consistencystate prefix recovered
length 8100%100%100%
length 16100%100%100%
length 2487.5%87.5%99.2%

Numbers from experiments/qwen_structural_latent_compiler_expansion/reports/aggregate_metrics.csv (main run, stage3_max24 paired splits)

Technical framing

Paraphrase-pair consistency of the final compiler — Paraphrased prompts compile to the same latent execution trace 87.5% of the time even at length 24, with near-perfect state prefixes.

In the author’s words from the Report · “Interpretation”

This report is intentionally standalone. The key readout is whether expansion improves or preserves executable accuracy at longer lengths, and whether paraphrase-paired programs compile to the same latent execution trace.

Overview

This experiment tests whether an executable latent program compiler can be expanded structurally from short chains to longer chains without using beam search, candidate reranking, or text program generation.

The model receives a modular-arithmetic prompt plus fixed latent register positions. A Qwen backbone reads the prompt, a direct compiler head predicts an initial value and a sequence of typed operations/arguments, and a differentiable executor supervises the resulting latent program.

Large checkpoints are stored outside this directory under:

/workspace/large_artifacts/qwen_structural_latent_compiler_expansion/checkpoints

Report

Rendered from reports/structural_latent_compiler_expansion_report.md

Question

Can a Qwen-attached executable latent compiler be expanded from short modular programs to longer modular programs while preserving direct executable accuracy, without beam search, candidate reranking, or tokenized program output?

Method

  • A Qwen causal LM reads the arithmetic prompt and fixed latent register markers.
  • A structural compiler head predicts one initial value plus typed operation and argument slots.
  • A differentiable modular executor supervises final answer probability and intermediate state traces.
  • The compiler is expanded by copying learned short-slot parameters into longer slot structures, then continuing training.
  • The run reports argmax executable accuracy, exact program recovery, state prefix recovery, and paraphrase-pair consistency.

Runs

runelapsed_secmodelstage_max_stepsstage_stepstrain_examplesgpu
main_qwen_structural_expansion_s7501833Qwen/Qwen3-4B8,16,24300,150,300512NVIDIA RTX 6000 Ada Generation
pilot_qwen_structural_expansion_s9084.14Qwen/Qwen3-4B8,16,2430,30,3064NVIDIA RTX 6000 Ada Generation
smoke_qwen_structural_expansion6.944Qwen/Qwen3-4B8,16,241,1,14NVIDIA RTX 6000 Ada Generation

Results

Final expanded 24-slot compiler, length-24 splits:

splitexecutor_accuracyprogram_exactstate_prefix_fractionexecutor_pair_both_correctcompiler_pair_state_consistency
standard_L2482.8%82.8%97.9%
paraphrase_L24100.0%100.0%100.0%
paired_L2493.8%93.8%99.2%87.5%87.5%

Best single split executable accuracy was 100.0%; the length-24 table above is the main result.

runstagesplitglobal_stepmax_stepsexecutor_accuracyprogram_exactstate_prefix_fractionstate_all_exactexecutor_pair_both_correctcompiler_pair_state_consistencylength
main_qwen_structural_expansion_s750stage1_max8paired_L83008100.0%100.0%100.0%1100.0%100.0%8
main_qwen_structural_expansion_s750stage1_max8paraphrase_L8300898.4%98.4%98.4%0.98448
main_qwen_structural_expansion_s750stage1_max8standard_L83008100.0%100.0%100.0%18
main_qwen_structural_expansion_s750stage2_max16paired_L845016100.0%100.0%100.0%1100.0%100.0%8
main_qwen_structural_expansion_s750stage2_max16paraphrase_L845016100.0%100.0%100.0%18
main_qwen_structural_expansion_s750stage2_max16standard_L845016100.0%100.0%100.0%18
main_qwen_structural_expansion_s750stage2_max16paired_L1645016100.0%100.0%100.0%1100.0%100.0%16
main_qwen_structural_expansion_s750stage2_max16paraphrase_L164501698.4%98.4%99.7%0.984416
main_qwen_structural_expansion_s750stage2_max16standard_L164501698.4%98.4%99.7%0.984416
main_qwen_structural_expansion_s750stage3_max24paired_L875024100.0%100.0%100.0%1100.0%100.0%8
main_qwen_structural_expansion_s750stage3_max24paraphrase_L875024100.0%100.0%100.0%18
main_qwen_structural_expansion_s750stage3_max24standard_L875024100.0%100.0%100.0%18
main_qwen_structural_expansion_s750stage3_max24paired_L1675024100.0%100.0%100.0%1100.0%100.0%16
main_qwen_structural_expansion_s750stage3_max24paraphrase_L1675024100.0%100.0%100.0%116
main_qwen_structural_expansion_s750stage3_max24standard_L1675024100.0%100.0%100.0%116
main_qwen_structural_expansion_s750stage3_max24paired_L247502493.8%93.8%99.2%0.937587.5%87.5%24
main_qwen_structural_expansion_s750stage3_max24paraphrase_L2475024100.0%100.0%100.0%124
main_qwen_structural_expansion_s750stage3_max24standard_L247502482.8%82.8%97.9%0.828124
pilot_qwen_structural_expansion_s90stage1_max8paired_L83080.0%0.0%0.0%00.0%37.5%8
pilot_qwen_structural_expansion_s90stage1_max8paraphrase_L83080.0%0.0%0.0%08
pilot_qwen_structural_expansion_s90stage1_max8standard_L83080.0%0.0%0.0%08
pilot_qwen_structural_expansion_s90stage2_max16paired_L860160.0%0.0%0.8%00.0%75.0%8
pilot_qwen_structural_expansion_s90stage2_max16paraphrase_L860166.2%0.0%0.8%08
pilot_qwen_structural_expansion_s90stage2_max16standard_L860160.0%0.0%0.0%08
pilot_qwen_structural_expansion_s90stage2_max16paired_L16601612.5%0.0%0.0%012.5%62.5%16
pilot_qwen_structural_expansion_s90stage2_max16paraphrase_L1660166.2%0.0%0.4%016
pilot_qwen_structural_expansion_s90stage2_max16standard_L1660160.0%0.0%0.4%016
pilot_qwen_structural_expansion_s90stage3_max24paired_L890240.0%0.0%1.6%00.0%0.0%8
pilot_qwen_structural_expansion_s90stage3_max24paraphrase_L890240.0%0.0%0.0%08
pilot_qwen_structural_expansion_s90stage3_max24standard_L890240.0%0.0%0.0%08
pilot_qwen_structural_expansion_s90stage3_max24paired_L1690246.2%0.0%0.0%00.0%0.0%16
pilot_qwen_structural_expansion_s90stage3_max24paraphrase_L1690240.0%0.0%0.0%016
pilot_qwen_structural_expansion_s90stage3_max24standard_L1690240.0%0.0%0.0%016
pilot_qwen_structural_expansion_s90stage3_max24paired_L2490240.0%0.0%0.0%00.0%0.0%24
pilot_qwen_structural_expansion_s90stage3_max24paraphrase_L2490240.0%0.0%0.3%024
pilot_qwen_structural_expansion_s90stage3_max24standard_L2490240.0%0.0%0.0%024
smoke_qwen_structural_expansionstage1_max8paired_L8180.0%0.0%0.0%00.0%0.0%8
smoke_qwen_structural_expansionstage1_max8paraphrase_L8180.0%0.0%0.0%08
smoke_qwen_structural_expansionstage1_max8standard_L8180.0%0.0%0.0%08
smoke_qwen_structural_expansionstage2_max16paired_L82160.0%0.0%0.0%00.0%0.0%8
smoke_qwen_structural_expansionstage2_max16paraphrase_L82160.0%0.0%0.0%08
smoke_qwen_structural_expansionstage2_max16standard_L82160.0%0.0%0.0%08
smoke_qwen_structural_expansionstage2_max16paired_L162160.0%0.0%0.0%00.0%0.0%16
smoke_qwen_structural_expansionstage2_max16paraphrase_L162160.0%0.0%0.0%016
smoke_qwen_structural_expansionstage2_max16standard_L162160.0%0.0%0.0%016
smoke_qwen_structural_expansionstage3_max24paired_L832450.0%0.0%0.0%00.0%0.0%8
smoke_qwen_structural_expansionstage3_max24paraphrase_L83240.0%0.0%0.0%08
smoke_qwen_structural_expansionstage3_max24standard_L83240.0%0.0%0.0%08
smoke_qwen_structural_expansionstage3_max24paired_L163240.0%0.0%0.0%00.0%0.0%16
smoke_qwen_structural_expansionstage3_max24paraphrase_L163240.0%0.0%0.0%016
smoke_qwen_structural_expansionstage3_max24standard_L163240.0%0.0%0.0%016
smoke_qwen_structural_expansionstage3_max24paired_L243240.0%0.0%0.0%00.0%0.0%24
smoke_qwen_structural_expansionstage3_max24paraphrase_L243240.0%0.0%0.0%024
smoke_qwen_structural_expansionstage3_max24standard_L243240.0%0.0%0.0%024

Figures

executor_accuracy_by_length.png

executor_accuracy_by_step.png

program_exact_by_step.png

state_prefix_by_step.png

paired_state_consistency_by_step.png

training_loss.png

training_state_accuracy.png

Interpretation

This report is intentionally standalone. The key readout is whether expansion improves or preserves executable accuracy at longer lengths, and whether paraphrase-paired programs compile to the same latent execution trace.

Artifacts

Experiment log 5

Show the running log (5 entries, 2026-06-24)

2026-06-24

  • Created a fresh standalone experiment directory for structural latent compiler expansion.
  • Motivation: prior beam/search runs were demoted from candidate method to diagnostic because the deployable learned selector repeatedly failed to close the oracle gap. This run removes beam search from the method.
  • Planned run sequence:

    • Smoke: verify the real Qwen QLoRA path, expandable compiler, metrics, checkpoint routing, and report generation.
    • Pilot: short staged expansion run to check whether the objective moves held-out executable accuracy.
    • Main: longer staged expansion run with selected metrics and standalone Markdown/HTML report.

Smoke Run

  • Run: smoke_qwen_structural_expansion
  • Configuration: Qwen/Qwen3-4B QLoRA, stages 8 -> 16 -> 24, one update per stage, tiny eval sets.
  • Outcome: completed successfully. This verified the real model load, latent register collation, compiler expansion, differentiable executor, CSV/JSON logging, and Markdown/HTML report generation.
  • Interpretation: accuracy is not meaningful at this size; the smoke was only an integration gate.

Pilot Run

  • Run: pilot_qwen_structural_expansion_s90
  • Configuration: Qwen/Qwen3-4B QLoRA, stages 8 -> 16 -> 24, 30 updates per stage, weak default trace/state weights.
  • Outcome: completed successfully but did not learn executable programs. Final exact program recovery was 0% on all splits and final length-24 executable accuracy remained at 0% on standard/paraphrase/paired splits.
  • Interpretation: the structural path itself was not falsified; the objective was underweighted and undertrained compared with prior single-compiler recipes. The main run was adjusted to use heavier init/argument trace weights, full state loss, larger compiler width, batch 8, and a longer short-stage bootstrap.

Main Run

  • Run: main_qwen_structural_expansion_s750
  • Configuration: Qwen/Qwen3-4B QLoRA, stage expansion 8 -> 16 -> 24, steps 300/150/300, train lengths 1..8 then 1..16 then 8..24.
  • Outcome:

    • After stage 1: length-8 executable/program exact accuracy was 100.0% standard, 98.4% paraphrase, 100.0% paired.
    • After stage 2: length-16 executable/program exact accuracy was 98.4% standard, 98.4% paraphrase, 100.0% paired, while length-8 retention was 100.0%.
    • After stage 3: length-8 and length-16 retention were 100.0%; length-24 executable/program exact accuracy was 82.8% standard, 100.0% paraphrase, 93.8% paired.
    • Final length-24 state-prefix recovery was 97.9% standard, 100.0% paraphrase, 99.2% paired.
  • Interpretation: this is a clean positive for direct structural expansion of an executable latent compiler without beam search, candidate reranking, or tokenized program output. The remaining weakness is the standard length-24 split, where exact recovery is materially below the paraphrase and paired splits despite very high prefix recovery.

Reports

  • Markdown: reports/structural_latent_compiler_expansion_report.md
  • HTML: reports/structural_latent_compiler_expansion_report.html
  • Figures: reports/figures/

Figures 7

executor accuracy by length
executor accuracy by length · reports/figures/
executor accuracy by step
executor accuracy by step · reports/figures/
paired state consistency by step
paired state consistency by step · reports/figures/
program exact by step
program exact by step · reports/figures/
state prefix by step
state prefix by step · reports/figures/
training loss
training loss · reports/figures/
training state accuracy
training state accuracy · reports/figures/

Data files 7

Result tables and metrics copied from the experiment folder — preview inline or open the raw file.

Reproduce

This entry is source code or analysis only — there is no separate run to reproduce.

Browse the experiment folder on GitHub ↗