omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / docs / polyglot / OMEGA_LANGUAGE_EVIDENCE_LEDGER.md
| 1 | # Omega language evidence ledger (POLYGLOT-0) |
| 2 | |
| 3 | > **Lane B3 (Mojo) removed on 2026-10-15.** Modular MAX and Mojo were dropped from AIEN, and the Mojo lane's source, |
| 4 | > build rules and test were deleted from this repo. Mojo text below is the original design record, kept unchanged; |
| 5 | > the Mojo receipts stay in `evidence/`. |
| 6 | |
| 7 | What this is: for one exact operation (Omega-X, `y = W.x` with ternary W, int8 x, int32 y; contract |
| 8 | `spec/polyglot-0.md` section 1), which language and weight representation was fastest on each workload shape, |
| 9 | by how much, and where the difference is too small to call. Every number below comes from the receipts of one |
| 10 | timed run. Nothing here generalises beyond that run, that operation, and that core. |
| 11 | |
| 12 | ## Run |
| 13 | |
| 14 | | item | value | |
| 15 | |---|---| |
| 16 | | run id | `20260929T190337Z-2e2238f74ba3` | |
| 17 | | source commit | `2e2238f74ba3b8681606ce0fb08f8feade5dec6d` (branch `feat/polyglot-0`), 0 dirty files | |
| 18 | | contract digest | `4b9034ae795cbcc1bca6739080fce8e83e346b9c4378ce2f320f5228b90d46b1` | |
| 19 | | receipts | 72 (18 candidates x 4 shapes), 216 cells (x 3 sparsities), all `gate_eligible`, not smoke | |
| 20 | | core | cpu 5, Cortex-X925 (midr 0xd85), picked as the most idle X925 (100% idle over 0.3 s) | |
| 21 | | clock | governor `performance`, requested 3.90 GHz at start, end and at every cell start; effective clock measured separately right after the run with `perf stat` on cpu 5: 5,410,961,821 cycles in 1.388 s = 3.90 GHz (no X925 clock cap) | |
| 22 | | load | load average 0.49 before, 0.60 after; no other build/bench/test process, no GPU compute apps; `~/workspace/.spark-quiet` held for the run and removed after | |
| 23 | | samples | N = 21 per cell, round-robin across candidates; shortest kept sample 1.26 ms; 0 short samples kept; 94 samples retaken because scheduler run delay grew; 0 contaminated | |
| 24 | | correctness in run | 21,123 checksum checks, 0 failures (full verifier: `make test-polyglot`, see review) | |
| 25 | | timed wall | 14.8 s; peak RSS 227,192 KiB | |
| 26 | | explainer | `make polyglot-explain POLYGLOT_RUN=20260929T190337Z-2e2238f74ba3`, two runs byte-identical; copy in `evidence/POLYGLOT/polyglot_explain_20260929T190337Z-2e2238f74ba3.txt` | |
| 27 | |
| 28 | Decision rule (explainer, spec section 9 and review G-S7): the selected candidate is the lowest median among |
| 29 | selectable candidates. It is CHOSEN only if the runner-up is slower by more than the band |
| 30 | `max(3 x larger relative MAD, 5%)`; otherwise TIE. In this run `3 x relative MAD` never exceeded 1.63%, so the |
| 31 | band was 5% in every cell. Toolchain-only candidates (Omega's own encoder, spec section 4) and weak baselines |
| 32 | (`R1_plain`) are measured but not selectable. |
| 33 | |
| 34 | ## Results per shape |
| 35 | |
| 36 | Medians in ns per call on one X925 core at 3.90 GHz. "Best C" and "best asm" are the fastest candidate of that |
| 37 | language in the cell. |
| 38 | |
| 39 | ### S1: m=1, n=4096 (call overhead) |
| 40 | |
| 41 | | sparsity | selected | median | runner-up | margin | decision | best Mojo | |
| 42 | |---|---|---|---|---|---|---| |
| 43 | | 0.00 | asm_sdot (asm) | 36.0 | R1_sdot@O3 (C) 36.8 | +2.1% | TIE | MJ1_sdot 41.1 | |
| 44 | | 0.33 | asm_sdot (asm) | 35.9 | R1_sdot@O3 (C) 36.7 | +2.3% | TIE | MJ1_sdot 40.9 | |
| 45 | | 0.66 | R1_sdot@O3 (C) | 36.8 | asm_sdot (asm) 37.0 | +0.7% | TIE | MJ1_sdot 41.1 | |
| 46 | |
| 47 | - For S1 on one X925 core, hand asm (int8 SDOT) and C int8 SDOT at -O3 are tied (within 5%). |
| 48 | - For S1 on one X925 core, the Mojo int8 kernel MJ1_sdot was about 12-14% slower than the tied leaders |
| 49 | (41.1 vs 36.0-36.8 ns). This is outside the band in every S1 cell. |
| 50 | - asm_sdot moved from 35.9-36.0 ns at sparsity 0 and 0.33 to 37.0 ns at 0.66 (2.9%), although a dense int8 |
| 51 | kernel does the same work at any sparsity. Its within-cell MAD is 0.03 ns, so this is a real but unexplained |
| 52 | per-cell effect, not sampling noise. It is the kind of shift the 5% floor exists for. |
| 53 | |
| 54 | ### S2: m=256, n=1024 (cache-resident, 256 KiB int8 in L2) |
| 55 | |
| 56 | | sparsity | selected | median | runner-up | margin | decision | best Mojo | |
| 57 | |---|---|---|---|---|---|---| |
| 58 | | 0.00 | asm_sdot (asm) | 2187.2 | R1_sdot_il@O3 (C) 2191.2 | +0.2% | TIE | MJ1_sdot 2224.6 (+1.7%) | |
| 59 | | 0.33 | R1_sdot_il (C) | 2191.2 | R1_sdot_il@O3 (C) 2191.8 | +0.0% | TIE | MJ1_sdot 2235.5 (+2.0%) | |
| 60 | | 0.66 | R1_sdot_il (C) | 2191.3 | R1_sdot_il@O3 (C) 2191.9 | +0.0% | TIE | MJ1_sdot 2228.2 (+1.7%) | |
| 61 | |
| 62 | - For S2 on one X925 core, asm, C (interleaved SDOT, -O2 or -O3) and Mojo int8 kernels are all within 2.1% |
| 63 | of each other: no language wins. The five fastest selectable candidates in each cell span under 3%. |
| 64 | - Crumb (2 bit per weight) kernels are 19-24% slower here (asm_crumb +19.3%, R2c_crumb +24.0% at sparsity |
| 65 | 0.66): at this size the weights sit in L2 and decoding crumbs costs more than the smaller footprint saves. |
| 66 | |
| 67 | ### S3: m=4096, n=4096 (memory bandwidth) |
| 68 | |
| 69 | | sparsity | selected | median | runner-up | margin | decision | best C | |
| 70 | |---|---|---|---|---|---|---| |
| 71 | | 0.00 | MJ2c_crumb (Mojo) | 139,187 | asm_crumb (asm) 160,802 | +15.5% | CHOSEN | R2c_crumb@O3 164,564 (+18.2%) | |
| 72 | | 0.33 | MJ2c_crumb (Mojo) | 138,958 | asm_crumb (asm) 161,368 | +16.1% | CHOSEN | R2c_crumb@O3 165,828 (+19.3%) | |
| 73 | | 0.66 | MJ2c_crumb (Mojo) | 139,135 | R2c_crumb@O3 (C) 160,978 | +15.7% | CHOSEN | (runner-up); asm_crumb 161,732 (+16.2%) | |
| 74 | |
| 75 | - For S3 on one X925 core, the Mojo crumb kernel MJ2c_crumb beat the hand asm crumb kernel and the best C |
| 76 | crumb kernel by 15.5% to 19.3% on the median, at all three sparsities. The asm minimum at sparsity 0 |
| 77 | (157,834 ns) is still 13.4% above the Mojo median. |
| 78 | - For S3 on one X925 core, every int8 (1 byte per weight) kernel was 228-297% slower than MJ2c_crumb, in all |
| 79 | languages: the representation (crumb2, 4x fewer weight bytes) decides this shape; language choice then decides |
| 80 | about 16% within crumb2. |
| 81 | - The claim is limited to this session. The earlier paired rerun used to set the 5% floor showed run-to-run |
| 82 | median shifts up to 10.4% (p99), so the 15-16% margin should be re-measured in a second run before it is |
| 83 | treated as stable. |
| 84 | - Each S3 sample holds only 8 (asm) to 16 (Mojo) calls, because one call takes 139-162 us. |
| 85 | |
| 86 | ### S4: m=64, n=1024, 256 different x per packed W (compute-bound) |
| 87 | |
| 88 | | sparsity | selected | median | runner-up | margin | decision | best C | |
| 89 | |---|---|---|---|---|---|---| |
| 90 | | 0.00 | asm_sdot (asm) | 414.8 | MJ1_sdot (Mojo) 419.5 | +1.1% | TIE | R1_smmla 420.4 (+1.4%) | |
| 91 | | 0.33 | asm_sdot (asm) | 413.8 | MJ1_sdot (Mojo) 418.8 | +1.2% | TIE | R1_smmla 420.4 (+1.6%) | |
| 92 | | 0.66 | asm_sdot (asm) | 415.7 | MJ1_sdot (Mojo) 419.6 | +0.9% | TIE | R1_smmla 420.3 (+1.1%) | |
| 93 | |
| 94 | - For S4 on one X925 core, hand asm SDOT, Mojo int8 SDOT and C int8 SMMLA are tied (within 1.6%). |
| 95 | - Plain C SDOT (R1_sdot) was 29-30% slower than those three at every sparsity; crumb kernels 35-66% slower. |
| 96 | |
| 97 | ### Omega's own encoder (toolchain-only, not selectable) |
| 98 | |
| 99 | The encoder candidates are machine code emitted at run time by Omega's own AArch64 encoder. Their gate is the |
| 100 | byte comparison report (spec section 4), not speed; they are listed for comparison only. |
| 101 | |
| 102 | - enc_sdot was within 0.3% of asm_sdot in every S1, S2 and S4 cell except S1 sparsity 0.66, where it was |
| 103 | 2.6% faster (36.1 vs 37.0 ns), the cell where asm_sdot shows its unexplained shift. At S4 sparsity 0.66 it was |
| 104 | 0.3% faster (414.7 vs 415.7 ns), inside the band. |
| 105 | - enc_crumb was within 0.6% of asm_crumb at S3 (161,320 vs 160,802 ns at sparsity 0), and so also about 16% |
| 106 | behind MJ2c_crumb. |
| 107 | |
| 108 | ## Code size and build time |
| 109 | |
| 110 | Code size = run + pack function symbols (or the candidate's named code parts: Mojo kernels behind the C adapter, |
| 111 | encoder-emitted bytes plus C thunk and pack). Build time = min of 5 wall runs of the object's build command. For |
| 112 | C and Mojo that object holds several realizations, so the time is shared, not per candidate. Source lines and |
| 113 | unsafe surface are per source file, informational only. |
| 114 | |
| 115 | | candidate | language | repr | code bytes | build time | build note | source lines (file) | unsafe surface (file) | |
| 116 | |---|---|---|---|---|---|---|---| |
| 117 | | asm_sdot | asm | int8 | 1,112 | 5.4 ms | gnu-as 2.42 | 214 | 163 | |
| 118 | | asm_crumb | asm | crumb2 | 1,224 | 5.3 ms | gnu-as 2.42 | 162 | 113 | |
| 119 | | enc_sdot | Omega encoder | int8 | 1,160 | 40 us | in-process emission | 814 | 5 | |
| 120 | | enc_crumb | Omega encoder | crumb2 | 1,276 | 48 us | in-process emission | 814 | 5 | |
| 121 | | MJ1_sdot | Mojo | int8 | 2,036 | 356 ms | mojo 1.0.0, shared object | 250 | 0 | |
| 122 | | MJ2c_crumb | Mojo | crumb2 | 1,716 | 356 ms | mojo 1.0.0, shared object | 250 | 0 | |
| 123 | | R1_sdot / @O3 | C | int8 | 1,792 / 1,792 | 177 / 195 ms | gcc 13.3.0, shared object | 318 | 0 | |
| 124 | | R1_sdot_il / @O3 | C | int8 | 1,012 / 1,084 | 177 / 195 ms | gcc 13.3.0, shared object | 318 | 0 | |
| 125 | | R1_smmla / @O3 | C | int8 | 1,412 / 2,112 | 177 / 195 ms | gcc 13.3.0, shared object | 318 | 0 | |
| 126 | | R2c_crumb / @O3 | C | crumb2 | 1,628 / 1,624 | 197 / 228 ms | gcc 13.3.0, shared object | 389 | 2 | |
| 127 | | R2_bitplane / @O3 | C | bitplane | 2,224 / 2,872 | 197 / 228 ms | gcc 13.3.0, shared object | 389 | 2 | |
| 128 | | R1_plain / @O3 | C | int8 | 708 / 708 | 177 / 195 ms | weak baseline | 318 | 0 | |
| 129 | |
| 130 | Code size spread among the winners and ties is small (1,012 to 2,036 bytes). Mojo's unsafe-surface count of 0 is |
| 131 | what the rule (assembly lines + pointer casts in the file) measures; it does not mean the Mojo code has no raw |
| 132 | pointer use. |
| 133 | |
| 134 | ## Pack cost |
| 135 | |
| 136 | Packing converts W into the candidate's layout once. The receipts give per-weight pack cost and the number of |
| 137 | calls after which a faster kernel pays back its extra pack time against the cheapest-to-pack candidate |
| 138 | (MJ1_sdot, about 0.07-0.08 ns per weight). |
| 139 | |
| 140 | - S3: MJ2c_crumb packs at about 0.60 ns per weight (10.0 ms for 16.8 M weights) and pays back after 22-23 calls. |
| 141 | - S1, S2, S4 selected kernels pack at 0.58-0.79 ns per weight; break-even against MJ1_sdot is 448-492 calls |
| 142 | (S1), 3,969-5,110 calls (S2) and 7,483-8,862 calls (S4). Because the S1, S2 and S4 winners are ties, the |
| 143 | cheaper-to-pack tied candidate is a legitimate choice when W is used only a few thousand times. |
| 144 | |
| 145 | ## Independent statistics check (Grok) |
| 146 | |
| 147 | Grok (`grok -p`, one shot) was given the per-cell top-four medians, MADs, mins, N and the decisions. Its view, |
| 148 | with every figure it cited checked against the receipts: |
| 149 | |
| 150 | - The tie band is 5% in every cell; the MAD term never binds (largest `3 x relMAD` is 1.63%, S3 asm_crumb at |
| 151 | sparsity 0). Against within-run sampling error alone 5% is very conservative; against the earlier run-to-run |
| 152 | scatter (p95 3.6%, p99 10.4%) it is about right. |
| 153 | - The S3 CHOSEN decisions are justified: gaps of 21,615-22,410 ns against MADs of 127-876 ns. |
| 154 | - The 2.9% S1 asm_sdot shift across sparsity is real (about 36x its MAD) and shows that orderings under about 5% |
| 155 | are not identified by this run. The 5% floor is what keeps S1 from a false ranking. |
| 156 | - A qualified S3 statement matches the data; generalising to "Mojo beats asm" or treating 15.5% as stable |
| 157 | past this session would over-claim. |
| 158 | - Grok also estimated, from a fitted tail, that about 3% of run-to-run shifts exceed 5%. That is its model, not a |
| 159 | receipt figure, and is not relied on here. |
| 160 | |
| 161 | ## What this run does not show |
| 162 | |
| 163 | - Anything about other operations, other shapes, other cores (A725), several cores, or the GPU. |
| 164 | - That Mojo is generally faster than hand asm or C: it won one shape (S3) and tied or lost the other three. |
| 165 | - Energy: no energy or power was measured. |
| 166 | - Stability across runs: this is one run. A second timed run is needed before the S3 margin is used for |
| 167 | automatic selection. |
| 168 | |
| 169 | ## Confirmation run (2026-09-29, run 20260929T191231Z-071bfdbd76c7) |
| 170 | |
| 171 | Grok asked for a second run before trusting the S3 margin. Same machine, same core, quiet flag up, 72 receipts, timed wall 14.8 s. |
| 172 | Receipts are kept under `evidence/POLYGLOT/confirm-20260929T191231Z-071bfdbd76c7/` (the bench writes fixed file names, so the |
| 173 | confirmation copy is filed separately and the primary run's receipts stay unchanged). |
| 174 | |
| 175 | S3 medians (ns), best four per sparsity: |
| 176 | |
| 177 | | sparsity | MJ2c_crumb | asm_crumb | enc_crumb | R2c_crumb@O3 | |
| 178 | |---|---|---|---|---| |
| 179 | | 0.00 | 139262 | 160404 | 167166 | 163588 | |
| 180 | | 0.33 | 139479 | 158946 | 162982 | 163122 | |
| 181 | | 0.66 | 139441 | 161312 | 161990 | 163292 | |
| 182 | |
| 183 | The S3 winner is unchanged: the Mojo 2-bit kernel beats hand assembly by 14.0 to 15.7% and the best C by 17.1 to 17.5%. |
| 184 | The qualified statement stands for S3 on one X925 core at 3.90 GHz. Known gap: the bench overwrites receipts by file name; |
| 185 | immutable run-named receipt files are a follow-up. |