interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / spec / polyglot-0.md

115 lines · 6808 bytes Raw Blame History Rendered
1# POLYGLOT-0: one meaning, several languages (Omega-X)
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
7Status: CONTRACT (lead-owned). Implementation in progress. Nothing here is qualified until `POLYGLOT_0_PASS`.
8Base: omega main 4b217aa (mixed-algebra PR #78 merged; MA-3 was renamed MA-2 there). If `oma_rz_oracle`, `oma_rz_impl` or
9`oma_rz_plan` change upstream, every polyglot result is re-run before landing.
10
11## 1. Semantic operation
12
13Omega-X is defined once, in `src/algebra/realize_common.h` (MA-3), and is not redefined here:
14
15- input semantic identity: `(W, x)` where `W` is the canonical row-major int8 matrix with every entry in
16 {-1, 0, +1}, shape `m x n`, and `x` is int8^n;
17- output semantic identity: `y = W . x` in int32^m, **exact**;
18- preconditions: `m >= 1`, `1 <= n <= max_n` of the candidate (global bound `OMA_RZ_MAX_N` = 16,777,215 =
19 floor(INT32_MAX / 128), because |y_i| <= 128 n when x_i may be -128); `W`, `x`, `y` non-NULL; `y` does not
20 overlap `W` or `x` (checked by the verifier; candidates may assume it);
21- postcondition: `y` is bit-identical to `oma_rz_oracle(W, m, n, x, y)`;
22- error contract: pack returns `OMA_RZ_E_TRIT` for any weight outside {-1,0,+1}, `OMA_RZ_E_ARG` for bad shape or
23 NULL, `OMA_RZ_E_NOMEM`, `OMA_RZ_E_OVERFLOW`; on error no partial plan is kept (`oma_rz_free` safe);
24 run on an empty plan returns `OMA_RZ_E_ARG`;
25- resources: packed weight bytes, footprint and per-call scratch are declared in `oma_rz_plan`;
26- effects: none (pure; no I/O, no global state, no threads); capabilities: none.
27
28Approximation: none allowed. Any candidate that is not bit-exact is rejected, not ranked.
29
30## 2. Candidate axes
31
32A polyglot candidate is `(language/toolchain, representation, backend)`:
33
34| axis | values in POLYGLOT-0 |
35|---|---|
36| language/toolchain | C (gcc 13.3, -O2 as MA-3 and -O3 -mcpu=native), hand AArch64 assembly (GNU as 2.42), Omega's own AArch64 encoder (toolchain check, see 4), Mojo 1.0 (experiment only) |
37| representation | int8 row-major (MA `R1_sdot`), 2-bit crumb (MA `R2c_crumb`) |
38| backend | Grace CPU, one pinned core, cluster recorded |
39
40No Rust and no Python are written for this program (Drake's standing rules). Rust-vs-C evidence comes only from
41existing code measured as a black box (aienos capability authority crate vs its C port).
42
43clang is not installed on this machine; C is represented by gcc only. Recorded as a limitation.
44
45## 3. Registration
46
47Every non-C candidate is an `oma_rz_impl` (same pack/run ABI as MA-3) registered through
48`src/polyglot/omx_lang.h`, with language metadata. MA-3 files are never edited.
49
50## 4. Own-encoder rule
51
52A realization emitted by Omega's AArch64 encoder is a toolchain candidate, not a language candidate. Its gate is:
53the emitted instruction bytes equal GNU `as` output for the matching assembly realization, or every difference is
54listed with a reason, and its results are bit-exact. Its speed is not counted as a language result.
55
56## 5. Independence of assembly
57
58The assembly author records whether the code was derived from `gcc -S` output. Derived code is labelled
59"compiler-derived" and does not count as an independent language realization.
60
61## 6. Workloads (all four required)
62
63| id | shape | regime |
64|---|---|---|
65| S1 | m=1, n=4096 | call overhead |
66| S2 | m=256, n=1024 (256 KiB int8, L2-resident) | cache-resident |
67| S3 | m=4096, n=4096 | memory bandwidth |
68| S4 | m=64, n=1024, 256 different x per packed W, cache-resident | compute-bound (instruction selection) |
69
70Sparsity 0.0, 0.33 and 0.66 for each shape. Inputs from a fixed seed; the input digest is SHA-256 of W||x.
71
72## 7. Measurement rules
73
74- honour `~/workspace/.spark-quiet`; message the mixed-algebra session before each timed run;
75- pin to one core; record core id, cluster (X925 or A725), cpufreq governor and current frequency, and
76 thermal zone temperatures before and after;
77- interleave candidates round-robin (A B C A B C), never blocks; N >= 20 samples per cell;
78- for small shapes, a timed sample loops enough calls to last >= 1 ms and consumes every y (checksum), so no call
79 is hoisted or removed;
80- report min, median and MAD; skip and re-take samples whose `/proc/thread-self/schedstat` run delay grew;
81- pack cost reported per weight, and the break-even number of calls against the cheapest-to-pack candidate;
82- compile time (wall, 5 runs, min), code size of the realization's text section, peak RSS of the bench process.
83
84Informational only (not gated): source lines, unsafe surface (= assembly lines + pointer casts), defects found
85while authoring.
86
87## 8. Evidence record
88
89One JSON receipt per candidate x workload under `evidence/POLYGLOT/`, fields: semantic_operation ("omega-x"),
90contract digest (SHA-256 of this file section 1), language, toolchain + version, flags, representation, backend,
91machine (cpu model, core, cluster, kernel), build digest (SHA-256 of the realization's object file), input digest,
92correctness (checks, failures), latency min/median/MAD, throughput, bytes moved (weight_bytes + x + y +
93scratch), footprint, pack cost, compile time, code size, informational fields, source commit. The lead maps these
94onto existing `omega_evidence` / `rx_costmodel` receipt fields for POLYGLOT-1.
95
96## 9. Explanation
97
98`polyglot_explain` reads only the contract and the receipts and prints, per workload, which candidate it would
99select, the runner-up, the measured margins, the conversion (pack) cost and break-even, and which alternatives
100were rejected and why. Same inputs give byte-identical output.
101
102## 10. POLYGLOT_0_PASS
103
104All of:
1051. this contract, unchanged since the receipts were produced (contract digest matches);
1062. at least two language candidates that are not compiler-derived (C plus hand assembly at minimum) and at least
107 two representations (int8 and crumb), each bit-exact;
1083. verifier: MA-3's full shape grid, plus 20,000 random cases (random m, n, sparsity, x including -128/127,
109 including m and n not multiples of any vector width, unaligned x and y pointers), plain build and
110 ASan/UBSan build; assembly candidates additionally run with guard pages on both sides of W, x and y; 0 failures;
1114. own-encoder candidate: byte comparison report per section 4 (gate is the report, not speed);
1125. benchmark on S1-S4 with section 7 rules and one receipt per candidate x workload;
1136. explainer output generated from receipts, reproducible byte-for-byte;
1147. an independent reviewer's report with every blocking finding closed;
1158. Mojo is optional: included if it builds and is bit-exact, otherwise recorded as a result, not a failure.