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 / shadow-advice-v0.md

103 lines · 6424 bytes Raw Blame History Rendered
1# Shadow advice v0: default-off scoring of admissible matvec arms (omega #731, ORIG-4)
2
3Integration leaf of aien-train #19 (ORIG-1 aien-train #24, ORIG-2 aien-train #25,
4ORIG-3 benchmarks #45). Consumer: the empirical cost model's matvec arm choice
5(`src/runtime/rx_costmodel.{c,h}`, harness `tests/runtime/rx_empirical_optimizer.c`,
6`spec/empirical-optimizer.md`). Nothing here changes a decision, a measurement, a
7verdict, a weight, a listener or the GPU.
8
9## Rule
10
11```
12consumer (deterministic) ──► generates and verifies the candidate arms, selects, runs
13 │ default off: OMEGA_EMPIRICAL_RECORDS unset ──► nothing is written
14 └─ tap on ──► omexp-v1 records (state + every arm's digest-checked cost)
15shadow advisor (.om) ──► admits the checkpoint and the records, scores the admissible
16 arms, prints ADVICE or FALLBACK lines; reads nothing back
17```
18
19The advisor's output is scores and abstentions, never executable text, a new candidate,
20a permission or authority. A later opt-in active selection is a separate release
21decision after ORIG-3 evidence; it is not part of this specification.
22
23## Pieces
24
25| piece | where | language |
26|---|---|---|
27| record tap, default off | `tests/runtime/rx_empirical_optimizer.c` (`truth_table_tap`, `OMEGA_EMPIRICAL_RECORDS=<fd>`: a descriptor the caller opened for append, e.g. `3>>records.bin`; the harness opens no path named by its environment) | existing C harness, 134 added lines (tap and coverage sample), observation only |
28| record format `omexp-v1`, admission, features, baselines | aien-train `native/si19/omexp.om` (pinned in `native/orig4/orig4.pin`) | handwritten .om |
29| scorer forward and checkpoint admission | aien-train `native/si19/select.om` (pinned) | handwritten .om |
30| shadow advisor | `native/orig4/shadow.om` (+ `shadowmain.om`, the `fn main` dispatch) | handwritten .om |
31| tests and host glue | `tests/orig4/shadow-test.om`, `tests/orig4/run.sh`, gate `tests/gates/omega-orig4-shadow.gate` (step `orig4-shadow` in `tests/gates/run.sh`) | .om, POSIX sh glue |
32
33The .om units are built by this repository's own seeded compiler `seed/out/omc`
34(`seed/out/omc.sha256`); the aien-train units were written for the R5b compiler and
35compile unchanged under it (checked by the gate).
36
37## Admission (every check before the first score)
38
39The stream is one mode byte `S`, a 64-byte config block (8 little-endian words: enable,
40scoring budget in records, image length in the stream, five reserved zero words), the
414096-byte allow-list block, the checkpoint image, then the records to end of input.
42
431. Enable word in the config block must be 1; otherwise `SHADOW disabled` and exit 0
44 (the reversible kill switch; the tap env var is the second, consumer-side switch).
45 Then the config: budget at most 2048, image length 1..32768 (the image buffer),
46 reserved words zero; otherwise exit 68.
472. Dataset allow-list status must be AUTHORIZED or SYNTHETIC (hash lookup; REVOKED or absent
48 refuses, `FALLBACK all reason=allow-N`, exit 67, no advice).
493. Records must pass every omexp-v1 refusal class (`oxload`): size, magic, enumerations,
50 shape, eligible mask, unmeasured or unverified arm, forged mismatch word, sequence,
51 wrong hardware profile (cache bytes per core class), held-out contamination
52 (`FALLBACK all reason=records-N`, exit 66).
534. Checkpoint must pass `sladmit`: length, magic, version, kind/width/parameter count,
54 FNV-1a 64, state ranges, finite parameters (`FALLBACK all reason=image-N`, exit 0,
55 nothing else printed). The dataset binding word is information, not a check: the
56 training dataset's hash is recorded in the image, the advisor prints it and the
57 current file's hash (`data_bound=`, `bound_matches=yes|no`) so a reviewer sees the
58 lineage; a mismatch is reported, not a fallback, since the advisor by design runs over
59 records the model never trained on (`slload`, the resume-mode admission, refuses it).
605. Resource budget: at most 2048 records per invocation and a declared scoring budget
61 of records per run from the config block; past it, every further record is
62 `FALLBACK budget`.
63
64Scoring uses the image's best-on-DEV parameters (`slbest`, as selmain's evaluation mode
65does); the advised arm is the argmin score over the admissible arms, lowest index on a
66tie, the same choice as `slpick`.
67
68## Per record
69
70| condition | output |
71|---|---|
72| record index at or past the scoring budget | `FALLBACK seq=N reason=budget` |
73| core class 2 or pressure above 1 (never in training) | `FALLBACK seq=N reason=ood` |
74| fewer than two admissible arms | `FALLBACK seq=N reason=single` (nothing to rank) |
75| arm count above 8 or unknown arm bits | refused earlier by admission |
76| any score bit pattern non-finite | `FALLBACK seq=N reason=nonfinite` |
77| otherwise | `ADVICE seq=N arm=A incumbent=R oracle=O score=BITS` |
78
79`incumbent` is the fixed rule's arm for that record (what the deterministic path chose
80without any model), `oracle` the cheapest admissible arm by the record's own
81measurements (available only because the tap records every arm; it is printed for the
82cost comparison, never fed back). After the last record one `COST records=N scored=M
83fallback=F adv_cost=A oracle_cost=O incumbent_cost=I` line. Every line is one of
84`SHADOW`, `ADVICE`, `FALLBACK`, `COST`; the gate greps for anything else and fails.
85Over the SYNTHETIC fixture the gate also compares every run's stdout byte for byte with
86`tests/orig4/expected/`, checks that no advised arm is above 4 (the fixture's measured
87arms) and that `adv_cost` and `incumbent_cost` are never below `oracle_cost`, and the
88in-process tests check the advised arm against `oxcand` and the per-record oracle cost
89for both candidate images.
90
91## Cost
92
93The glue times the whole advisor run (load + validation + features + scoring + output)
94for the record file and prints `COST_WALL records=N ms=T`; the advisor's own `COST` line
95carries the record, scored and fallback counts and the advised, oracle and incumbent cost
96sums (ps per call over the scored records). The deterministic path's own cost for the
97same decision is the fixed rule (a comparison in C, nanoseconds). Energy is
98NOT_MEASURED. GB10 is NOT_RUN.
99
100## Not claimed
101
102Any change to `rx_cm_decide` or `omega_matvec_dispatch`; online weight updates; a model
103server; a Cortex writer; a GPU realization; production promotion.