interplane.Get Omega
Read in your language

omega-feel

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

omega-feel / SPEC.md

285 lines · 20922 bytes Raw Blame History Source

feel: Omega tunes its own kernels while a model runs

Status: the decision core is specified here and checked against Wolfram (section 5). Wiring into an inference engine and every GPU measurement are NOT_RUN (section 7). What the core does not do, and what its checks do not show, is section 6: read it before relying on any sentence of sections 1 to 3.

1. Intent (Drake, 2026-11-18, verbatim)

"build omega to be able to dynamically adjust kernels to optimize speed while the model is running." "I want omega to be able to feel enough to be able to adjust itself to make itself as fast as possible and use wolfram to verify." "I want Omega to go the other way. It should be able to adapt to whatever model is there."

In one line: while any model runs, Omega measures its own kernels, moves to the faster way of running each one, and every decision can be recomputed in Wolfram from the recorded timings. Scope of "never runs a way that gives different results": a way is not run as the incumbent until its output was bit-for-bit equal to the reference's on V launches it was shadowed on (3.2), and one unequal output bans it. After it is admitted its output is not checked again by this core (section 6, item 1).

2. Shape

Three parts, and only the middle one is in this repository so far.

Nothing in feel knows a model. A class is whatever the engine says is "the same work": a kernel kind plus its shape (rows, columns, element type, batch). A new model brings new classes; feel makes a table entry the first time it sees one, and no table has a fixed size (section 4, limits). An arm is one way to run a class: a kernel variant or a launch setting. Arm 0 is always the reference the engine would have used without feel. A class has 2 or more arms.

2.1 Terms

3. The rules (exact; all arithmetic is on non-negative integers)

Constants: H = 12, NMIN = 32, NMAX = 256, V = 3, WARM = 64, REST0 = 1024, RESTMAX = 65536, MNUM = 63, MDEN = 64 (the 64 * and 63 * of adopt by mean below). tests/run.sh requires each of these to be a const of feel.om with this value.

State of one class: K arms; status[a] in {0 untested, 1 admitted, 2 banned}, status[0] = 1; incumbent inc = 0; mode in {rest, shadow, duel}, starting at rest; rest = WARM; restlen = REST0; round-robin pointer next = 0; challenger ch; vcount; duel counters k, w, l, sI, sC, hI, hC, n; tfirst; order bit o; generator z = 1; launch counter i = 0; counts[a] = 0.

Each launch of the class is one step, in this order.

3.1 Choose. i += 1. The arm to run is inc unless the duel rule below says otherwise.

A duel starts with k = w = l = sI = sC = hI = hC = n = 0.

3.2 Verdict (only in shadow mode). Not equal: status[ch] = 2, event B, mode rest, rest = restlen. Equal: vcount += 1; at vcount = V: status[ch] = 1, event M, and a duel starts (the launch that carried the last verdict is not part of it).

3.3 Observe (only for a timed launch; t is its time). k even: tfirst = t. k odd: the pair is complete; tC is the challenger's time and tI the incumbent's; sI += tI; sC += tC; w += 1 if tC < tI; l += 1 if tC > tI; n += 1; if n = NMAX / 2 then hI = sI, hC = sC. Then the first of these that holds ends the duel:

  1. n >= NMIN and l - w >= H and sC >= sI: reject (event R).
  2. n >= NMAX. With the first half (hI, hC) and the second half (sI - hI, sC - hC):
    • hC < hI and sC - hC < sI - hI and w - l >= H: adopt (event A);
    • otherwise 64 * hC < 63 * hI and 64 * (sC - hC) < 63 * (sI - hI): adopt by mean (event Am);
    • otherwise draw (event D).

Adopt: inc = ch, restlen = REST0. Reject or draw: restlen = min(2 * restlen, RESTMAX). In both cases rest = restlen and the mode is rest. Finally k += 1.

Why these rules:

4. The program and the engine entries

feel reads a trace on standard input and writes events on standard output.

Input lines: c CLASS K declares class CLASS with K arms (2..49 in a trace); `t CLASS t0 .. t(K-1) OKMASK` is one launch of that class: the time each arm would take on this launch, and a mask whose bit a says arm a's output equals the reference on this launch. The parser validates every field. The decision uses the time of the chosen arm and the mask bit for the shadowed arm. Any other line, a class used before it is declared, a class declared twice, or a count outside its range: exit 2 and one line on standard error.

Output lines, one per event, in the order they happen: CLASS B ARM I, CLASS M ARM I, and CLASS A|R|Am|D ARM I N W L SI SC, where ARM is the challenger and I the class's launch counter. At end of input, for each declared class in increasing order: CLASS F INC RESTLEN COUNTS.. STATUS...

Exactly, as feel.om does it. A line is its fields with one space between them and a newline at its end, the last line included; nothing else, so an empty line is refused. A number is 1 to 15 decimal digits (leading zeros allowed). OKMASK is below 2^K. On bad input the events already decided stay printed (gate case "a bad line after 67 launches"), then the one line feel: bad input, line N goes to standard error, the exit status is 2 and no F line is written. If standard input cannot be read or standard output cannot be written the exit status is 3. If the host refuses memory for the class tables the events decided so far stay printed, the one line feel: out of memory, line N goes to standard error and the exit status is 4. In 3.1, a launch that finds no arm to try sets rest = restlen and does not count it down.

4.1 The engine entries

These four are what an engine calls; the trace reader calls the same four, so every decision in a trace is a decision of the same code. Each checks its arguments and the order of calls before it changes anything: a refused call changes nothing (the gate builds tests/api-main.om against feel.om and compares what the entries return, tests/api-expected.txt, worked out by hand from this section). A refusal is a returned code, never a trap and never a write to the wrong place.

CallDoesReturns
setup c Kdeclares class c with K arms, once0, or a code
choose cone launch of class c, steps 3.1arm + 65536 * ch + 2^32 * owed, or ERR + code
verdict c equal3.2: equal is 1 for bitwise-equal outputs, else 00, or a code
observe c t3.3: t is the time the chosen arm took0, or a code

In choose's result, arm (bits 0..15) is the arm to run; owed (bits 32..33) is 0 (nothing), 1 (a verdict on arm ch, bits 16..31, run on the same input into scratch memory) or 2 (the time of this launch). ERR is 2^63; a result below it is never an error.

Codes: 1 class not declared; 2 call out of order; 3 argument out of range; 4 class already declared; 5 the host refused memory. When several apply, the lowest number is returned, which is the order the checks run in.

Order of calls, per class (the illegal transitions are the refused ones). choose is allowed only when nothing is owed from the last choose of that class. After a choose that owes a verdict only verdict is allowed, after one that owes a time only observe; each settles the debt. A choose that owes nothing needs no other call. Every other call is code 2. Different classes are independent.

4.2 Limits, and what kind each is

No table has a fixed size. Every per-class and per-arm table is a run-time pool that grows when a class is declared (setup), and the trace reader's time buffer grows with the arms. What remains is stated here with its reason (Drake, 2026-11-11: a limit stays only where it is a width of the machine or the host's memory).

LimitValueKind
a timebelow 10^15width of the 64-bit word: the largest sum is 256 * 64 * (10^15 - 1), below 2^64 (Wolfram, below). 10^15 is 11.57 days in nanoseconds
a class numberbelow 2^52conservative API input ceiling. One 64-bit table at that size alone would require 32 PiB. Memory is proportional to the largest class number declared: number classes from 0 upward
arms per class, API2 to 65535width of the fields of choose's result (16 bits)
arms per class, trace2 to 49width of the mask: it is written as a decimal below 10^15; 2^49 - 1 is below that and 2^50 - 1 is not, so 49 arms fit and 50 do not (Wolfram, below)
memorywhat the host givesa refusal is code 5 / exit 4. Gate: a class number past the address space, and a million classes in 64 MiB
the input and output buffers (65536 bytes)noneread and write chunk sizes, not limits

Wolfram: WolframLanguageEvaluator: {64*256*(10^15-1) < 2^64, N[64*256*(10^15-1)], N[2^64], N[10^15/(10^9*86400)], 2^49-1 < 10^15, 2^50-1 < 10^15} -> {True, 1.6383999999999984*^19, 1.8446744073709552*^19, 11.574074074074074, True, False}.

The alarm in place of a cap on classes (Drake, 2026-11-11: "just put a TEST that will alarm"): tests/run.sh declares 100000 classes with the address space limited to 48 MiB and prints ALARM with the figures when the program no longer fits. The threshold is about 500 bytes per class; it was set above what the tables needed when it was written, so a table that starts growing faster, or an arm table per class sized for the worst case, trips it. It tells someone to look. It does not stop the program.

The caller must serialize these entries. They share mutable tables across classes, including during growth.

How feel.om is called: setup c K declares a class; choose c, verdict c equal and observe c t are the three steps; finals prints the F lines. The same three steps (choose, verdict, observe) are what an engine will call; the trace form exists so that every decision can be replayed and recomputed.

5. What Wolfram checked

The result files are produced by the scripts, not typed: each script's final value is one string and the file is that string. tests/wolfram.sha256 (written by sh tests/seal.sh) records the SHA-256 of each script and of its result; tests/run.sh fails when either changed without the other being evaluated and sealed again. That catches drift. It cannot show that a result came from its script: the independent re-evaluation of a script on a fresh Wolfram kernel does that, and the figures are not quoted here: read them in the result files.

These are properties of the model in section 3 on synthetic times. They say nothing yet about a real kernel on a real chip.

6. Scope: what the rules do not do, and what the checks do not show

  1. An admitted arm is not checked again. An arm that gave equal outputs on V shadowed launches is trusted for the life of the process; the incumbent is never compared with the reference again. An arm that is wrong only now and then (scenario lateWrong) is admitted, adopted and never banned; its wrong outputs are delivered. The claim is: the core does not adopt an arm that differed on any of its V shadowed launches. Periodic re-verification would need the engine to shadow the incumbent now and then; it is not part of this core and not built.
  2. A trial of unpredictable slowness. The core sees a launch's time only after the launch, and it cannot interrupt a launch. What it bounds is the number of launches given to a challenger: a challenger that loses every pair, however slow, is turned away by rule 1 at pair NMIN, so it gets NMIN timed launches per duel (and V shadow launches the first time). It then rests for restlen launches, twice as long after each reject, up to RESTMAX. What it does not bound is the time those launches take: with a challenger X times slower, in units of one incumbent launch, the extra time is V X once and NMIN (X-1) per duel, and the share of the whole run it adds is in tests/wolfram-slow-trial-result.txt: it falls toward NMIN (X-1) / (RESTMAX + 2 NMIN) and is large for a very slow X (read the limit lines). A launch that never returns is outside the core; the engine must give every trial a deadline and report the deadline as its time. No early stop for a catastrophic challenger is built (a rule such as "sum above k times the incumbent's after a few pairs" would need its own simulation, its own false-reject figures and a new oracle). Until it is, an engine offers only arms whose slowest plausible case it can afford at that rate.
  3. Rare stalls. A challenger whose own stalls are rarer than about one launch in NMAX can pass a whole duel without showing one. The row for one stall in 128 launches shows adoption of a challenger that is slower on average. The one-in-512 challenger is faster on average.
  4. Adopt by mean needs no win count, by design (3.3.2): the challenger can win fewer pairs than it loses and still be adopted when its sums are lower in both halves by 1/64 (scenario meanWin).
  5. What the gate shows. feel.om equals the oracle on the synthetic traces (the oracle was written from section 3; it is evidence that the program implements these rules, not that the rules are the right ones); the engine entries refuse what 4.1 says (the driver and its expected output were derived by hand); each of the single-line changes to the program or its checks that tests/run.sh lists is caught (mutants); the Wolfram files are the sealed outputs of their scripts, and the constants SPEC and the scripts restate are feel.om's. It does not show behaviour on a chip, or that a real kernel pair is eligible (2.1).
  6. Timing on a GPU perturbs what it measures. A per-launch time on a GPU needs a per-launch event or a synchronisation; that overhead is paid by every timed launch, can be larger than the difference between two arms, and can change the schedule of the work. It is not modelled anywhere here. The first engine measurement has to measure it.

7. Not built, not run