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 / tools / turing_origsel_indep / README.md
| 1 | <!-- SPDX-License-Identifier: Apache-2.0 --> |
| 2 | # origsel_indep: independent recomputer of the ORIGSEL v1.1 report |
| 3 | |
| 4 | The external referee for Turing-profile-ORIGSEL-v1.1 (omega-mv #700). It is a second |
| 5 | implementation, written in C, of the report defined in `native/turing/REPORT-CONTRACT.md`. It |
| 6 | works from the written contracts and was not ported from the seeded .om evaluator (`origsel.om`). |
| 7 | The two reports must be byte-identical, except for the `h1` lines, which only the .om H mode |
| 8 | produces. |
| 9 | |
| 10 | Sources it implements: |
| 11 | |
| 12 | - `native/turing/REPORT-CONTRACT.md`: arms, orders, MLP, F1 rows, code lengths, D, bootstrap, verdicts, report format. |
| 13 | - `calibration/profiles/Turing-profile-ORIGSEL-v1.1.toml`: binding wherever the contract is silent. |
| 14 | - aien-train 692d8510 `docs/si19/ORIG1-CONTRACT.md` s.2-3 (record layout, features) and s.5 (allow-list). |
| 15 | - aien-train 692d8510 `docs/si19/ORIG1-CONTRACT-v2.md` s.2-3 (admission `oxadm2`, splits `oxhspl`). |
| 16 | - `calibration/docs/CODER_SPEC.md` s.8 (`ub`). |
| 17 | |
| 18 | It runs on the host CPU only and uses no GPU, network or model. |
| 19 | |
| 20 | ## Build |
| 21 | |
| 22 | ``` |
| 23 | make origsel_indep # cc -O2 -std=c11 -ffp-contract=off -fno-fast-math -Wall -Wextra |
| 24 | make selftest # ./origsel_indep --selftest |
| 25 | ``` |
| 26 | |
| 27 | binary32 arithmetic uses C `float`. Each product and each sum is its own statement, and |
| 28 | `-ffp-contract=off` prevents fused multiply-add. That gives round-to-nearest-even with gradual |
| 29 | underflow, the default floating-point environment on AArch64 Linux. `ub` uses |
| 30 | `unsigned __int128` for its 128-bit products. |
| 31 | |
| 32 | ## Usage |
| 33 | |
| 34 | ``` |
| 35 | origsel_indep REC ALLOW V1 IMG_M1 IMG_SH IMG_UN SELECT_OM OMEXP_OM KAPPA_OM > report |
| 36 | origsel_indep --selftest |
| 37 | origsel_indep --fnv FILE |
| 38 | ``` |
| 39 | |
| 40 | - `REC`: the omexp-v1 record file. `ALLOW`: the allow-list text. |
| 41 | - `V1`: the v1 files concatenated, raw records. It may be empty (no burned shapes). |
| 42 | - `IMG_*`: the V2=1 mlp, shuffled and untrained images. |
| 43 | - `SELECT_OM`, `OMEXP_OM`: the unit sources at aien-train 692d8510. `KAPPA_OM`: `native/turing/origsel_kappa.om`. |
| 44 | |
| 45 | Exit status: |
| 46 | |
| 47 | - 0: report written. |
| 48 | - 2: contract refusal. stdout holds the single line `refused allow` or `refused admission <code>`. |
| 49 | - 1: usage error, I/O error, or an input outside the contract. That covers a malformed image, a |
| 50 | V1 file that is not a whole number of records, and a missing unit function. The message goes |
| 51 | to stderr and stdout stays empty. |
| 52 | |
| 53 | `--fnv FILE` prints FNV-1a 64 over every byte of FILE as an unsigned decimal followed by a |
| 54 | newline, then exits 0. This is the hash the allow-list lines use (ORIG1-CONTRACT s.5), and the |
| 55 | glue uses it to write allow-list lines for derived audit files. A file it cannot read exits 1. |
| 56 | |
| 57 | `--selftest` prints the following and exits 0 only when every check passes: |
| 58 | |
| 59 | - `ub` for the golden values in REPORT-CONTRACT and CODER_SPEC s.8: 1, 32768, 43481, 46819, 13107, 13108 and 65536. |
| 60 | - The first five splitmix64 outputs from state 20261025. |
| 61 | - A product-then-sum check that fails if the compiler fused the multiply-add. |
| 62 | |
| 63 | ## Interpretation decisions |
| 64 | |
| 65 | These are the places where a contract left room for more than one reading. The .om consultations |
| 66 | are listed in the next section. |
| 67 | |
| 68 | 1. **Allow-list.** |
| 69 | - The file's FNV-1a 64 covers every byte. |
| 70 | - Lines are split on `\n`. The first line whose leading decimal token equals the hash decides. |
| 71 | If the token overflows u64, the line does not match. |
| 72 | - That line is accepted only when a single space follows the number and the next token, ending |
| 73 | at a space or the end of the line, is exactly `AUTHORIZED` or `SYNTHETIC`. |
| 74 | - Anything else is `refused allow`: no matching line, `REVOKED`, or a malformed status. |
| 75 | - The label is not checked. The .om parser classifies the status by its first letter and |
| 76 | length, so the two parsers can only disagree on a malformed allow-list. |
| 77 | 2. **Check order.** |
| 78 | - The allow-list is checked first, then the whole-file size check `-1` (empty, not a multiple of |
| 79 | 256, or above 524288 bytes), then the per-record codes, then the `-11` disjointness check. |
| 80 | - All input files are read, and must exist, before any check runs. |
| 81 | 3. **-3 family.** The record is refused when word 2 > 5, as the v2 text says ("above 5"). That |
| 82 | admits family word 5 even though v1 defines families only up to 4. `oxfmt2` confirms this reading. |
| 83 | 4. **-14 pairing.** |
| 84 | - Mask word 12 must be exactly 31. |
| 85 | - For arms 0..4, ps must be non-zero and the verified word 24+a must equal **1**. |
| 86 | - For arm 5, ps (word 21) and the verified flag (word 29) must both be 0. |
| 87 | - "Arms 6, 7 absent" means ps words 22 and 23 are 0. The arm count is already forced to 6 by -3. |
| 88 | 5. **-10 range.** The 2^40 check applies to ps of arms 0..4 only. |
| 89 | 6. **-8 sequence.** "The previous record" means the record immediately before this one in the |
| 90 | file, whatever its own code. It is not the previous admitted record. |
| 91 | 7. **-15 duplicate.** A record is a duplicate when an earlier record with final code 0 has the same |
| 92 | (core, pressure, M, N). |
| 93 | 8. **-11 split conflict.** |
| 94 | - The file is refused when two admitted records in different splits share a cell or share (M, N). |
| 95 | - The split is a function of the cell, so this check cannot fire on any file. It is implemented anyway. |
| 96 | 9. **Image acceptance.** The contract says only "SI19SLCK images (kind 2, 11560 bytes)". The checks |
| 97 | are taken from `slverify` in select.om: |
| 98 | - size 11560; |
| 99 | - magic `SI19SLCK`; |
| 100 | - u64 at offset 8 equal to 1, offset 16 (kind) equal to 2, offset 24 (H) equal to 32, offset 136 (nparams) equal to 705; |
| 101 | - the last 8 bytes equal FNV-1a 64 of the bytes before them. |
| 102 | |
| 103 | The range and finiteness checks of `slverify` (`slrange`, `slfinite`) are **not** |
| 104 | reimplemented. Any bit pattern is used as given. A failed check exits 1 (decision 2 above under |
| 105 | exit status), not a report line, because the contract defines no image refusal line. |
| 106 | 10. **MLP inputs.** z_j = (float)f_j / 16.0f. Every feature is a small integer, so this is exact. |
| 107 | All 20 inputs take part in every hidden sum, including the zero one-hot inputs, so ±0 and NaN |
| 108 | propagate exactly as the written loop does. a_h = acc when acc > 0, else +0. |
| 109 | 11. **Fit, D and P1R filters.** |
| 110 | - D is admitted HELD-OUT with pressure 0 and core 0 or 1. P1R uses the same filter with pressure 1. |
| 111 | - Each record's (M, N) is compared with words 5 and 6 of every V1 record. `burned` counts |
| 112 | removed **pressure-0** records only. P1R also excludes V1 shapes ("the same as D"), but that |
| 113 | count is not reported. |
| 114 | - D and P1R stay in file order. |
| 115 | 12. **V1 cell.** A V1 record's cell is 16 fl(M) + fl(N), using fl(0) = 0. V1 records are not |
| 116 | admitted or checked; only words 5 and 6 are read. A V1 file that is not a whole number of |
| 117 | 256-byte records exits 1. |
| 118 | 13. **R neighbour.** Candidates are admitted TRAIN records with the same core class and the same |
| 119 | pressure, in both pressures (the row records are pressure 0, P1R records are pressure 1). |
| 120 | "Lowest record index" is the record's position in the file. |
| 121 | 14. **rows= field.** It prints the F1 counts n_r, not Q_r. Rows are listed in rank order, and for |
| 122 | M2 and A the four kappa contexts are listed in order 0..3, separated by `;`. |
| 123 | 15. **Canonical bytes.** |
| 124 | - A function starts at the line that begins with exactly `fn NAME ` (column 0, trailing space). |
| 125 | - A line is dropped when it is empty (length 0) or its first four bytes are `note`. |
| 126 | - A final line with no newline is counted without one; none of the pinned units has such a line. |
| 127 | - A missing function exits 1. |
| 128 | 16. **F = 0.** The bootstrap draws no RNG outputs. Every replicate sum is 0, so lb = ub = the |
| 129 | P1-only term. The same holds for the (cell, core) bootstrap when F2 = 0. |
| 130 | 17. **Verdict n.** n = |D|. n_min uses integer ceil(P1 x 10^6 / 2321950). |
| 131 | 18. **Bootstrap statistics.** They are signed 64-bit, built from u64 block sums. `total` for `tcf` |
| 132 | is the same over-D total as for `t`. Sort positions are 0-based 166 and 9833, which are ranks |
| 133 | 167 and 9834 in the profile. |
| 134 | |
| 135 | ## .om consultations |
| 136 | |
| 137 | These sources were read only to settle the ambiguities above. No .om evaluator code (`origsel.om`) |
| 138 | was read. |
| 139 | |
| 140 | - `omexp.om` (aien-train 692d8510), the list of `fn`/`global` header lines. |
| 141 | - `omexp.om` lines 482-679: `oxfmt2`, `oxpair2`, `oxval2`, `oxsame`, `oxdup2`, `oxrec2`, |
| 142 | `oxconf`, `oxdisj`, `oxdec`, `oxtally`, `oxadm2`. They settled decisions 3-8. |
| 143 | - `omexp.om` lines 22-35 and 170-293: |
| 144 | - `oxlg16` agrees with the contract's lg16 for v >= 1. |
| 145 | - `oxfnv`. |
| 146 | - `oxload`, the v1 loader; it was in the displayed range and is not used. |
| 147 | - `oxdigit`, `oxline`, `oxstatus`, `oxallow`, for decision 1. |
| 148 | - `select.om`: the file-head `note` lines 1-20, the head of `sladmit`, and `slverify` (for decision 9). |
| 149 | |
| 150 | ## Qualification run (2026-10-25, host only) |
| 151 | |
| 152 | - Fixture `/tmp/turx/run/fixb` (SYNTHETIC, 400 records) wrote `/tmp/turx/run/indep-fix.report`. |
| 153 | - v1 owner file (inspected development data, never D) with the `/tmp/turx/run/ownb` images wrote |
| 154 | `/tmp/turx/run/indep-own.report`. |
| 155 | - Admission counts match the .om trainer's logs: |
| 156 | - owner file: 583 / 330 / 108 / 145, refused 155 (`own.log`); |
| 157 | - fixture: 318 / 206 / 58 / 54, refused 82 (`fix.log`). |
| 158 | - A throwaway diagnostic build, not part of this tool, compared top-1 choices with the trainer's |
| 159 | evaluation output (`v2_eval_*.stdout`). Per split and core it summed the top-1 cost of M1, CSH, |
| 160 | CUN, FR, S and R, the oracle cost, the reference cost and the M1 agreement count. Every value |
| 161 | equalled the trainer's `eval part=1|2 core=0|1` lines for all three images, on both inputs. |
| 162 | - That check covers the trainer's evaluation path only. Agreement with `origsel.om` is still |
| 163 | outstanding. |