Interactive execution traces and implementation code for the blog post.
Self-contained HTML pages showing step-by-step execution on the compiled transformer stack machine. Every step is a parabolic attention head operation — dot-product → argmax → value extraction on compiled weight matrices.
| Trace | Problem | Instructions | Steps | Result |
|---|---|---|---|---|
| hungarian-trace.html | Min-cost perfect matching (10×10) | 682 | 23,167 | Cost = 206 |
| sudoku-trace.html | Sudoku (constraint propagation search + verification) | 7,147 | 6,787 | 60/60 verified |
The full Kuhn-Munkres algorithm runs on the stack machine: dual potentials, augmenting path search, traceback. The 10×10 matrix has cost entries stored in heap memory at addresses 0–99, with potential arrays u[], v[], assignment p[], and working arrays at addresses 100–209.
The trace shows uneven iteration lengths (1,312 to 5,701 steps per row) because later augmenting paths must examine more already-assigned columns.
Two phases: Norvig’s constraint propagation (Python) finds the solution through 172 guesses and 162 backtracks, then the stack machine verifies every placement by loading all 20 peer cells from heap memory and comparing. 1,200 I32.LOAD operations and 1,200 EQ comparisons, each a parabolic attention head lookup.
The program generators that compile these algorithms to stack machine instructions:
examples/hungarian.py — Hungarian algorithm assembler + runnerexamples/sudoku.py — Sudoku verifier assembler + runnerThings we learned building these:
JZ/JNZ pop the condition value. Unconditional jumps need PUSH 1; JNZ label — that PUSH 1 consumes a stack slot that gets popped by JNZ. Getting this wrong silently corrupts the stack depth.I32.STORE operand order: stack is [..., addr, value], not [..., value, addr]. The Mojo executor reads value = stack[sp], addr = stack[sp-1].--max-steps override (PR #62).--quiet flag.