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 / docs / turing / TURING_YIELD_ENERGY_PROTOCOL_V0.md

261 lines · 17822 bytes Raw Blame History Rendered
1# TURING Yield energy protocol V0 (TY-4 measurement reuse, TY-5 concurrent attribution)
2
3Update 2026-09-30: R16 is CLOSED (omega#112, `3dd5eaa`, all gates G1 to G8 PASS) and the `src/runtime/` edit freeze is LIFTED (aien-architecture #70, `e89ba94`). Statements below that the runtime is frozen "until R16" describe the state when this was written.
4
5Status: PRE-REGISTERED. Committed and pushed before any timed run of stage 1 or stage 2.
6Any change after data is seen is a dated amendment at the end of this file, committed before the run it affects.
7Branch `feat/turing-yield-ty45`, base omega `a927bd6`. Date 2026-09-29.
8
9## 1. Question
10
11When two CPU workloads run at the same time, is the package energy of the pair different from the sum of their
12separate costs, and can an inspectable model built from independent signals predict the pair's energy without being
13fitted on it?
14
15The identity `I = E_AB - E_A - E_B + E_0` is algebra. Writing it down proves nothing. The evidence is:
16
17- (a) a confidence interval on `I` over repeated, interleaved rounds, with a statement of whether `I` is
18 distinguishable from zero;
19- (b) an attribution model fitted from per-process PMU counters (independent of the energy meter) on idle and solo
20 windows only, which predicts the energy of a held-out coalition (A+B) within stated uncertainty.
21
22## 2. What is reused, what is new
23
24- Meter and counters: `tests/runtime/r15_measure.{c,h}` linked unchanged (frozen under R16; not edited).
25 `r15_energy_open` is NOT called because it loads NVML (GPU driver library). The harness fills `R15Energy.hwmon`
26 itself after checking all ten `aien_spbm` channel labels, initialises the mutex, and uses `r15_energy_read`,
27 `r15_energy_start_sampler` (10 Hz) and `r15_energy_samples` as they are. PMU: `r15_pmu_open/start/stop` per
28 workload process (pid 0, inherit), so each process counts only its own threads.
29- Bad-window refusal: `tools/r15_reduce.c` `energy_ok` (spbm_ok and every overflow flag zero) and its
30 monotonic rule (end reading >= start reading, else refuse; counters are never unwrapped). The TY reducer compiles
31 `tools/r15_reduce.c` into its own translation unit (its `main` renamed) and calls those functions; it does not
32 copy them. The raw window records use the r15 JSONL writer (`r15_rec_begin`, `r15_json_energy`, `r15_json_pmu`).
33- New (C only): `tests/turing/ty_workload.c` (workload process), `tests/turing/ty_energy_window.c` (measures one
34 window per call), `tools/ty_energy_reduce.c` (reducer), `src/turing/ty_energy.{c,h}` (records, checks),
35 `tests/turing/test_ty_energy.c` + fixtures (hostile tests), `tools/ty_energy_run.sh` (rounds, idle wait, quiet
36 flag), `mk/turing_yield_energy.mk`.
37- No GPU, no NVML, no src/runtime, no src/algebra edits (read-only use of `oma_rz_get`/`oma_rz_find`).
38
39## 3. Workloads (fixed)
40
41- Operation: MA-2 ternary GEMV (Omega-X), shape m = 8192 rows, n = 16384 columns, weight sparsity 0.3, x uniform
42 int8. Weights and x are generated from a seed; every thread's plan is checked bit-exact against `oma_rz_oracle`
43 once before the window. A failed check aborts the window.
44- Workload A: `R1_plain`, seed 1. Packed weights 128 MiB per thread.
45- Workload B: `R2c_crumb`, seed 2. Packed weights 32 MiB per thread.
46- Both are larger than the 8 MiB L3 of each cluster, so both stream from DRAM. A and B are different realizations so
47 their counter mixes differ (untimed 2 s calibration on cpu 5: A retires about 3.3 instructions per cycle, B about
48 5; both move about the same bytes per second). This calibration was the only run before registration and set the
49 shape; it was not metered.
50- One process per workload, one pinned thread per listed core, each thread with its own packed copy. Threads call
51 `run` back to back until the process deadline (planned window length after GO).
52- X925 cores only: cpus 5-9 (cluster 0, L3 shared with A725 cpus 0-4) and 15-19 (cluster 1, L3 with 10-14). The
53 window tool and its 10 Hz sampler are pinned to A725 cpu 0 so they never run on a measured core.
54- Meter scope: all X925 cores are under one channel (`cpu_p`). `cpu_p` therefore cannot separate A from B. The
55 per-participant signal for check (b) is the per-process PMU.
56
57## 4. Conditions and order
58
59Conditions per round: IDLE (no workload), A, B, AB (A and B started together). IDLE is a shuffled condition in every
60round, so each round has its own baseline; there is no fixed idle measured once.
61
62Order: the four conditions are shuffled within each round by a seeded splitmix64 Fisher-Yates shuffle
63(`ty_energy_window --plan`). The seed is recorded in the run manifest. Seeds: stage 1 `0x7459510001`,
64stage 2 `0x7459520001`.
65
66Per window: workloads are started and packed, all report READY, then a fixed 2 s settle, then the start reading,
67GO, the planned window, the end reading after every workload has exited. IDLE uses the same settle and length.
68Between windows the shell waits 3 s.
69
70## 5. Stage 1: contention sweep (exploratory, selects the case)
71
72Configurations (A cores | B cores):
73
74| id | A | B | meaning |
75|---|---|---|---|
76| S1 | 5 | 6 | same L3, 1 + 1 core |
77| S2 | 5 | 15 | cross L3, 1 + 1 |
78| S3 | 5,6 | 7,8 | same L3, 2 + 2 |
79| S4 | 5,6 | 15,16 | cross L3, 2 + 2 |
80| S5 | 5,6,7 | 8,9 | same L3, 3 + 2 (all X925 of cluster 0) |
81| S6 | 5-9 | 15-19 | cross L3, 5 + 5 (all X925) |
82
83Window 10 s, 3 rounds per configuration, configurations in seeded shuffled order, rounds of one configuration
84together.
85
86Contention score per configuration: for each round, slowdown `s_X = 1 - calls_X(AB) / calls_X(solo)` for X in {A, B};
87round score `(s_A + s_B) / 2`; configuration score = mean over rounds.
88
89Selection rule (fixed now):
90- Contention case = the configuration with the highest score. It is called a REAL contention case only if its score
91 is >= 0.05 AND every one of its rounds scores >= 0.02. Otherwise the result states "no contention case found" and
92 stage 2 still runs on the highest-scoring configuration.
93- Control case = the configuration with the lowest absolute score (a near-additive reference).
94- Stage 1 energy numbers are reported as exploratory only.
95
96## 6. Stage 2: confirmatory runs
97
98For the contention case and the control case, in that order: 10 rounds of {IDLE, A, B, AB}, window 30 s (the audit's
99error budget needs >= 19 s for 1% resolution of I; 30 s gives margin). Duration about 24 min per case.
100
101## 7. Recorded per window
102
103Written as one r15-format JSONL record per window (`kind":"ty_window"`), raw files never overwritten:
104
105- meter: start and end `R15EnergySample` (energy_uj pkg, cpu_e, cpu_p, gpc_unverified, gpm; overflow_raw; power_uw;
106 spbm_ok), window duration, all 10 Hz samples inside the window (t_ns, pkg, cpu_e, cpu_p), sample count, largest gap;
107- per workload: realization, cores, pinned, oracle check, planned and actual interval (GO, first and last thread
108 times, exit), completed calls per thread, the six raw PMU counts per PMU with enabled and running times;
109- machine: /proc/loadavg at both ends, per-cpu busy time deltas from /proc/stat (busy on cores not used by the window
110 is the background load), scaling_cur_freq of all 20 cpus at both ends, all thermal zone temperatures at both ends,
111 quiet flag present and whose, headroom of each energy counter to the 32-bit mJ wrap.
112
113Meter facts recorded with the results: resolution 1 mJ step (readings end in 000 µJ) is not accuracy; sampling
11410 Hz, sensor update about 0.1 s; 32-bit mJ counters wrap at about 4.29 MJ, flagged by overflow_raw; no external
115calibration, so absolute accuracy is not claimed; `gpc_unverified` always reads 0 and is unused; observed variance is
116reported per condition.
117
118## 8. Validity (a window is refused, never repaired)
119
120A window is refused if any of: SPBM unavailable or not ok at either edge; any overflow flag set; any energy counter
121decreased (r15_reduce rule, reused); a counter within one window's worth of the wrap; a gap between consecutive 10 Hz
122samples > 300 ms or fewer than 90% of the expected samples; a workload that failed the oracle check, was not pinned,
123exited early, or ran < 98% of the planned length (partial run); a workload interval not inside the meter window
124(interval mismatch); two windows whose meter intervals overlap; PMU running < 99.9% of enabled on the X925 PMU
125(multiplexed counts). A round with any refused window, or without its IDLE window, gives no I.
126
127## 9. Normalisation and uncertainty
128
129- Window energy `E_w` per channel = (end - start) scaled to the planned length: `E_w = dE * T_plan / dt`.
130 Channels: pkg, cpu_p, cpu_e, and rest = pkg - cpu_p - cpu_e (uncore and DRAM side).
131- Analytic edge bound per window: each edge is uncertain by up to one sensor period of power, `P_w * 0.1 s`, uniform,
132 so sd `P_w * 0.1 / sqrt(3)` per edge; for I, four windows and two edges each, combined in quadrature.
133- Empirical: the SD of I over valid rounds. This covers edges, drift and other tenants and is the one used for
134 intervals. The analytic bound is reported next to it.
135
136## 10. Check (a): interval on I
137
138Per round r: `I_r = E_AB - E_A - E_B + E_0` on each channel. Primary statistic: mean over valid rounds with 95%
139Student-t interval (n - 1 degrees of freedom). Secondary: 95% bootstrap percentile interval of the mean
140(splitmix64 seed 0x15, 10,000 resamples, same generator as r15_reduce). I is distinguishable from zero iff the
141primary pkg interval excludes zero.
142
143Check (a) PASSES (the measurement answers the question) iff >= 8 of 10 rounds are valid and the primary pkg interval
144half-width is <= 2% of the mean `E_AB` pkg. The finding (zero, positive, negative) is stated separately from pass/fail.
145
146## 11. Check (b): held-out coalition prediction
147
148Model (fixed now), per window, pkg channel:
149
150 E_w = p0 * T_plan + a * CYC_w + b * INST_w
151
152`CYC_w`, `INST_w` = sum over the window's workload processes of X925 PMU `cpu_cycles` and `inst_retired`
153(0 for IDLE). Fit: ordinary least squares on every valid IDLE, A and B window of the case. Held out: every AB window
154(never used in the fit). The fit reports its coefficients, residual SD `s` (n - 3 degrees of freedom) and the
155condition number of the column-scaled design; above 1e4 the fit is DEGENERATE and check (b) FAILS.
156
157Prediction for an AB window uses the counters measured in that AB window. Per-window 95% prediction interval
158`+- t * s * sqrt(1 + h)`, h the leverage.
159
160Check (b) PASSES iff the fit is not degenerate, the 95% t-interval of the mean held-out error (observed - predicted)
161contains zero, AND at least 80% of held-out windows fall inside their prediction intervals.
162
163Reported next to it (not pass/fail): the naive additive model `E_A + E_B - E_0` (its error is exactly -I); the same
164counter model on `cpu_p`; a variant with `l2d_cache_refill` in place of `inst_retired`.
165
166## 12. Attribution records and conservation
167
168Per valid AB window two attributions are built and checked:
169
1701. Solo counterfactual: idle share `E_0` (COUNTERFACTUAL), A `E_A - E_0`, B `E_B - E_0` (COUNTERFACTUAL), remainder
171 = measured - allocated. A remainder >= 0 is recorded UNATTRIBUTED. If allocated exceeds measured by more than the
172 tolerance (1.96 x empirical SD of I, floored at the analytic edge bound) the attribution is REFUSED.
1732. Counter model (only if check (b) passes): idle `p0 * T_plan` (MODELLED), A and B from their own AB-window counters
174 (COUNTER_DERIVED), remainder UNATTRIBUTED, same refusal rule.
175
176The measured window total is DIRECT. Confidence scale and its mapping to physics FORGE V2 `energy_source`
177(`forge/v2/forge_substrate_v2.h`, 3 levels), fixed in `src/turing/ty_energy.h`:
178
179| TY confidence | meaning | FORGE V2 energy_source |
180|---|---|---|
181| DIRECT | read from the meter for exactly this interval and boundary | MEASURED (1) |
182| COUNTER_DERIVED | a measured total split by measured per-participant counters | MEASURED (1) |
183| CAUSAL_RUNTIME | split by the runtime's own causal record of who ran | ESTIMATED (2) |
184| COUNTERFACTUAL | taken from a different window (solo or idle) | ESTIMATED (2) |
185| MODELLED | from a fitted or cost model, not read for this interval | ESTIMATED (2) |
186| UNATTRIBUTED | measured but assigned to nobody | NOT_MEASURED (0) |
187
188COUNTER_DERIVED maps to MEASURED because FORGE has no finer level; the TY record keeps the finer label. FORGE is not
189changed.
190
191Records use new digest domains `turing.resource_interval.v0` and `turing.resource_attribution.v0`
192(SHA-256(domain || 0x00 || OMG0 bytes), as in `src/turing/field.c`), integers only (µJ, ns). No existing `turing.*`
193encoding or golden changes.
194
195## 13. Quiet machine and safety
196
197`tools/ty_energy_run.sh` runs detached (setsid nohup). Before each stage it waits until load1 < 2, no other `make`,
198bench or qualify process runs, and `~/workspace/.spark-quiet` is absent; then it creates its own quiet flag, runs
199the stage, and removes the flag only if it is still its own. It never kills anything. Other tenants that start
200later are recorded per window (background busy time), not hidden.
201
202## 14. R16 loop inventory
203
204The rounds, idle waits and the between-window pause live in shell (outside the R16 scanner's file types). The C files
205hold only a deadline-bounded call loop and bounded for loops with none of the scanner's wait words, so they add no
206loop-inventory site. Checked with `tools/r16_loop_inventory.sh` after coding; the result is recorded in the result
207document.
208
209## Amendments
210
2112026-09-29, before the first timed stage 1/2 run: Codex completed the interrupted
212harness in an isolated worktree. Energy symbols use the `ty_energy`/`TYE` namespace
213to coexist with TY-1. Hostile synthetic fixtures and sanitizer checks reject
214malformed records, arithmetic overflow, missing sensors, counter wrap and failed
215participants. The driver holds the existing `.argus-bench.lock` as well as its
216owned quiet flag. Workloads, seeds, stage selection, fitting and qualification
217thresholds above are unchanged. CI fixtures are synthetic and prove no hardware
218energy result. No timed data has been used to tune this amendment.
219
2202026-10-19, amendment 2, before any timed TY-4/TY-5 window (no data seen; ledger L109). The protocol cannot be
221followed as written on the box today, for three reasons found by inspection:
222
2231. **No package meter.** The `aien_spbm` hwmon is not loaded on this boot (no `/sys/class/hwmon/*/name` equals
224 `aien_spbm`). Loading it needs sudo, which agents do not use (handoff 2026-10-05-spbm-energy-operator-steps.md
225 gives the operator steps). `ty_energy_window` still runs workloads and records PMU counts, timing and box state
226 with `meter_ok: 0`, but every window is refused for energy by `ty_energy_reduce`, and stage 1's selection needs
227 valid windows, so the reducer cannot select or compute I.
2282. **The quiet rule changed.** `tools/ty_energy_run.sh` creates the machine-wide `~/workspace/.spark-quiet` flag and
229 waits for load1 < 2. Agents may no longer raise that flag without Drake, and the shared box has not been below
230 load 2 today (sensor log). The current mechanism is `quiet-measure` (holds off new builds) with the 20-minute
231 rule (if the wait exceeds 20 minutes, run and record the load).
2323. **A new meter exists.** Wall power from the UPS, `~/yardsticks/sensors/<date>.csv`, one row every ~2 s, 10 W
233 steps, whole UPS output (not the Spark alone).
234
235What runs instead (TY-4/TY-5 wall amendment, "TYW"):
236
237- Stage 1 is not run (its selection needs the package meter in the existing reducer). Two configurations are fixed
238 now without data: **S6** (A on cpus 5-9, B on 15-19: all ten X925 cores, both clusters, the largest power step
239 the wall meter can see and the strongest DRAM sharing) as the contention candidate, and **S2** (A on 5, B on 15:
240 one core each, cross L3) as the near-additive control.
241- Stage 2 as in section 6 but **3 rounds per configuration** (not 10): IDLE, A, B, AB shuffled per round with
242 `ty_energy_window --plan` (seeds `0x7459520001` for S6, `0x7459520002` for S2), 30 s windows, 2 s settle, 3 s
243 between windows, `ty_energy_window` and `ty_workload` unchanged. The whole run is one
244 `quiet-measure spark-receipt tyw -- tools/ty_energy_wall_run.sh OUT` invocation.
245- Energy per window, wall channel: `E_w = mean UPS W over sensor rows inside [GO, GO + planned] x planned`, with
246 the window's monotonic GO time mapped to epoch time by an offset recorded by the driver right before each window
247 (`date +%s%N` beside `/proc/uptime`, 10 ms resolution; the box does not suspend). `tools/ty_energy_wall.c`
248 computes it; package energy is UNAVAILABLE and printed as such.
249- Per round `I_r = E_AB - E_A - E_B + E_0` on the wall channel; mean over valid rounds with 95% Student-t interval
250 (2 degrees of freedom, t = 4.303). A window is refused if a participant failed (`ok`, `oracle_ok`, `pinned`), if it
251 has fewer than 10 sensor rows inside its 30 s, or if the offset cannot be read. Slowdowns
252 `s_X = 1 - calls_X(AB) / calls_X(solo)` are reported per round from the PMU-independent call counts.
253- **Check (a), wall form:** PASS iff all 3 rounds are valid and the 95% half-width of mean I_wall is <= 2% of mean
254 E_AB wall. I is distinguishable from zero iff the interval excludes zero. Prediction: FAIL. Reason: the UPS
255 meter steps by 10 W and other tenants on the shared box (load 5 to 25 today) move the wall draw by tens of watts
256 between windows, against an expected AB step of about 30 to 60 W for S6, so the half-width of I will be several
257 percent of E_AB or more; I for S2 is expected indistinguishable from zero.
258- **Check (b) is NOT RUN**: the counter model has three parameters and 3 rounds give 9 fit windows on a meter whose
259 noise is set by other tenants; a fit there would not test the attribution model. It waits for the package meter.
260
261The hostile fixture tests (`make test-turing-energy`) are run unchanged and reported.