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 / empirical-optimizer.md

300 lines · 16366 bytes Raw Blame History Source

Omega empirical cost model (OMEGA_EMPIRICAL_OPTIMIZER)

Code: src/runtime/rx_costmodel.{c,h}. Tests: tests/runtime/rx_costmodel_unit.c (make test-costmodel, any host) and tests/runtime/rx_empirical_optimizer.c (make test-empirical, AArch64). Receipt: evidence/EMPIRICAL/.

Rule

Omega picks a realization from what it has measured, not from a fixed rule.

features of a call ──► predicted cost of every eligible realization, with spread
                   ──► SELECT one   or   MEASURE two, when a run is worth it
runs it chose      ──► observations ──► the working model
working model      ──► judged apart ──► proposed as a generation's `model` blob
                   ──► promoted by the subject holding the promotion right
                   ──► durable; read back after a restart

This is not authority learning. No feature comes from a capability. An arm is eligible only if the caller says its verdict passed.

The model is a calculator. rx_costmodel.o is linked alone first and the build fails if it references the generation store, any authority operation, or anything that maps, forks or runs code (nm -u check in the Makefile). It can predict, decide and serialize. It cannot promote itself, run what it chooses, or widen what it may choose from.

Why

omega_matvec_dispatch picks with a fixed rule: unroll2 when N ≤ 8, else unroll4_dual. R10 found that rule wrong on the Spark's A725 cores. The probe for this gate (both core classes, 6 × 10 shapes, all five arms) showed how wrong:

The best choice depends on shape and core class together. A rule of the form "if N > k" cannot express that.

Features and targets

FeatureUsed how
input shape (M, N)fit: log2 M, log2 N, product, (log2 N)², N ≤ 3, N % 4 ≠ 0
state size and memory localityfit: doublings of the working set past the core's private L2
hardware statecell: core class from MIDR (X925, A725, other)
resource pressurecell: pressure bucket; learned as a correction (below)
semantic operation classcell: matvec only today (RX_CM_OPS = 1)
thermal staterecorded (acpitz °C); not varied, not fit
current realizationrecorded
evidence requirementenforced: only arms with a passing verdict are eligible
latency and energy budgetconstraints: an arm whose 90% bound misses the budget is skipped
branch count, cognitive requirementconstant for matvec (0, none); recorded
TargetHow it is obtained
latencymeasured, ps per call
energycluster meter (aien_spbm cpu_p / cpu_e); power per arm above idle; predicted energy = latency × power
memorycode bytes + working set
throughputderived from latency
failure probabilityBeta posterior from verification refusals and wrong results; any failure excludes the arm
verification costmeasured, ns, per arm
recompute costsynthesis + verification ns
contentionH3 cost over H1 cost for the same job. The quietest core is chosen per phase, so the two tables may come from different cores of the same class. Only cores in the process's affinity mask are candidates; a core class with no allowed core is absent from the run
qualityexact: output digest equal to the reference's
transfer costnot measured: one shared-memory CPU, no device transfer in this operation

Predictor

One Bayesian linear regression per (cell, arm) on log2 ps per call, with a normal-inverse-gamma ridge prior. The basis has eight readable terms (above). Each (cell, arm) keeps only sufficient statistics: X'X, X'y, y'y, n. So the model is a fixed 28,112-byte blob, well under the 64 KiB generation limit.

Deciding, and when to measure

The chosen arm is the one with the lowest predicted cost among eligible arms that meet the budgets. The competitor is the eligible arm with the largest expected improvement over it:

EI = E[max(0, log2 cost(chosen) − log2 cost(competitor))]

Exploration constraints

ConstraintHow it holds
within capability constraintsarms outside eligible are never chosen or measured: 20,000 random decisions in the unit test, and every held-out decision on the Spark
no unapproved external effectsthe model has no effect path (link check). The harness runs only pure matvec realizations, each verified in a forked child before the parent may run it
never self-promotesthe model cannot reach rx_gen_* (link check). The learner subject's promotion attempts are refused by the native authority, both with its own capability and with the promoter's under its own name. R9 also refuses a proposer promoting its own candidate
resource budgetsexploration budget above; the gate harness counts violations
known-good fallbackthe reference is always eligible. With no durable model, or a torn model blob (RX_GEN_ERR_TORN), Omega runs the reference. Any arm with a failure is excluded

Promotion

  1. The working model is proposed as an R9 generation. Its blobs are:
    • model: the canonical blob
    • evidence: the validation summary
    • realization: the arm set
    • config: the policy
    • provenance
  2. An independent judge measures its own validation work: 35 shapes per core class, none of them training shapes. Even-numbered jobs go to the learner for calibration. The judge grades on the odd-numbered ones and accepts only if the candidate:
    • costs at least 5% less than the fixed rule;
    • costs no more than always running the known-good reference;
    • costs no more than the model in force. The code checks this, but this gate makes only a first promotion, so that branch is not exercised.

    Beating the fixed rule alone is not enough. On the first Spark run, a model with its quad4 and scalar knowledge swapped still beat the fixed rule by 5%.

  3. Only a subject holding RX_GEN_RIGHT_PROMOTE on the native Aienux authority can promote.
  4. After promotion the store is closed and recovered, then reopened. The model is read back from the active generation and compared by digest.
  5. Online updates made after promotion stay in the working copy. The durable model is unchanged until another promotion.

The gate

make test-empirical on the DGX Spark. Every policy is charged from the same per-job cost table. The table times every eligible arm in rotating order and keeps the best of 5. The learner never sees the table. The online learner's cost includes every probe it ran.

Policies compared:

Held-out distributions, each run on both core classes:

A second, independent check replays each policy's choices end to end. The blocks alternate, 7 rounds each. For each policy the replay keeps the fastest block among those where the thread waited for its core less than 1% of the time, using /proc/thread-self/schedstat. It also reads the cluster energy meter for that block.

PASS requires, for every core class and held-out distribution:

PASS also requires, overall:

H3 coverage is reported, not gated. The frozen model never saw pressure, so its H3 spread rests on the unseen-shift prior. The first runs had 0.5 as that prior and showed H3 coverage between 1% and 81%, depending on what else was running on the machine. That is why the prior is now 1.0 and why H3 coverage is not a pass condition. This criterion was changed after those runs and is recorded here for that reason.

Hosted CI runs the same test on a different AArch64 core with EMPIRICAL_ALLOW_NO_WIN=1. There a win is recorded (CHAIN_PASS_NO_WIN), not required.

Findings

Qualifying run

Candidate ff0109b, receipt evidence/EMPIRICAL/7aab6079fab855675c89698e62dfb347af7a7c948ffa5fdd4d85aa0564a008a3.json (bound, clean tree, AIENOS c8ab65e, load average 2.1 to 3.8). 44 checks, 0 failures; 20,212 runs checked against the reference, 0 mismatches; planted arm refused, 0 parent runs; 0 budget violations. Model blob 28,112 bytes.

Cost as a fraction of the fixed rule's (table terms; online includes probes):

CoreDistributionfrozenonlinefrozen / best single armreplay wall
X925H1 unseen shapes0.5840.6411.000 (quad4)0.615
X925H2 thin-heavy0.7780.7850.7880.767
X925H3 pressure0.5830.7331.000—
A725H1 unseen shapes0.5570.5620.955 (reference)0.557
A725H2 thin-heavy0.6940.7100.9790.695
A725H3 pressure0.7040.8331.011—

Validation: 0.610 of the fixed rule; 80% intervals covered 0.859. Held-out 80% coverage: H1 0.83 / 0.88, H2 0.74 / 0.79 (X925 / A725); H3, not gated, 0.97 / 0.65. The best single arm differs by core class (quad4 on X925, the reference on A725): no single fixed arm is right for the machine, and on X925 thin-heavy work the learned choice is 21% under quad4-everywhere.

Development runs on the Spark (before the qualifying run)

Each was a full test-empirical run on the shared Spark (load average 2–7, other Omega sessions testing at the same time).

RunChange before itOutcome
1first versionjudge accepted a poisoned model (swapped quad4/scalar still beat the fixed rule by 5%); online learner measured on 154 of 154 training jobs; A725 H1 coverage 0.16
2judge also requires ≤ always-referenceonline cost above the fixed rule on X925 H2 (1.36): near-ties measured every job
3EI rule; probes a quarter job; chunked timing; split calibration; quietest coreall frozen criteria met; online 1.017 of the rule on X925 H3; A725 H3 coverage 0.07
4pressure as a correction; unseen-shift prior 0.5online 0.953 of the rule on X925 H2
5prior 1.0; budget 5% + 0.5 ms; H3 coverage reported, not gatedreplay on X925 H2 1.506 of the rule (energy 1.488): the core was shared for all five blocks
6none (debug readout of replay blocks)every criterion met
—replay: 7 rounds, blocks with core waiting ≥ 1% skippedstability runs below

Stability: 3 of 3 runs passed every criterion (same code as the qualifying candidate, before the rebase onto main). Run 2 was paused partway through by the R15 quiet-machine marker (SIGSTOP until the marker was removed) and still passed. Frozen ratios to the fixed rule ranged 0.56–0.82; online 0.58–0.82; replay 0.56–0.86. H3 coverage, reported but not gated, ranged 0.53–1.00.

The frozen model was 0.50–0.86 of the fixed rule on every core class and distribution in every one of the six runs. The criteria that moved between runs were the online learner's cost and the replay.

Not claimed