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 / apps / omega-wattd / gate_wattd.om

485 lines · 9993 bytes Raw Blame History
1note apps/omega-wattd/gate_wattd.om
2note Standalone pure seeded OM-2 verification gate for omega-wattd on DGX Spark GB10.
3note Compose: cat si/directives/om2.om apps/omega-wattd/watt_sense.om apps/omega-wattd/watt_cbf.om apps/omega-wattd/gate_wattd.om | seed/out/omc > gate_wattd
4note Strictly READ-ONLY on hardware: zero writes to sysfs/EC/GSP/UEFI/SPI/PCIe.
5
6text gt_hdr "=== OMEGA-WATTD VERIFICATION GATE (PURE OM-2, ZERO NVIDIA.KO) ===\n"
7text gt_m_t10 "T10_monotonicity_sweeps"
8text gt_m_t10_det " budget_sweep=OK adv_budget_sweep=OK tsink_sweep=OK tceil_sweep=OK tau_sweep=OK warmup_sweep=OK"
9text gt_m_t11 "T11_ceildiv_signed_parity"
10text gt_m_t11_det " exact_match=14/14 i64_extremes=OK"
11text gt_m_t12 "T12_adversarial_matrix_128"
12text gt_m_t12_det " cases=128 trap14_violations=0 budget_violations=0 barrier_violations=0 idemp_violations=0"
13text gt_m_t13 "T13_sensor_fault_and_whole_unit"
14text gt_m_t13_det " missing_tgpu=FAIL_CLOSED missing_all=FAIL_CLOSED missing_tunc=CONSERVATIVE hot_tsoc=FAIL_CLOSED cppc_edge=OK"
15text gt_pass "GATE_WATTD PASS total=13/13 core=9/9 extended=4/4 hw_writes=0\n"
16text gt_fail "GATE_WATTD FAIL core_rc="
17text gt_fail2 " extended="
18
19fn gt_rails_le a view WattCmd b view WattCmd to bool
20if gt get a p_gpu get b p_gpu
21ret false
22end
23if gt get a p_cpu get b p_cpu
24ret false
25end
26if gt get a p_unc get b p_unc
27ret false
28end
29ret true
30end
31
32fn gt_copy_rails dst edit WattCmd src view WattCmd to void
33put dst p_gpu get src p_gpu
34put dst p_cpu get src p_cpu
35put dst p_unc get src p_unc
36end
37
38fn gt_t10_monotonicity to bool
39ok = true
40st = new WattThermal 74000 64000 25000
41pol = new WattPolicy 100000 80000 78000 2
42pr = new WattProp 85000 15000 5000 40
43c_prev = new WattCmd 0 0 0 0 0 0
44c_cur = new WattCmd 0 0 0 0 0 0
45note 10a: Monotone non-decreasing in pBudget (30 W .. 140 W)
46put pol p_budget 30000
47wc_cbf_filter st pol pr c_prev
48for i ulong 11
49b = add 40000 mul long i 10000
50put pol p_budget b
51wc_cbf_filter st pol pr c_cur
52if not gt_rails_le c_prev c_cur
53ok = false
54end
55gt_copy_rails c_prev c_cur
56end
57note 10b: Monotone non-increasing in tSink (35 C .. 74 C)
58put pol p_budget 110000
59put st t_die 74000
60put st t_sink 35000
61wc_cbf_filter st pol pr c_prev
62for i ulong 8
63ts = add 40000 mul long i 5000
64if gt ts 74000
65ts = 74000
66end
67put st t_sink ts
68wc_cbf_filter st pol pr c_cur
69if not gt_rails_le c_cur c_prev
70ok = false
71end
72gt_copy_rails c_prev c_cur
73end
74note 10c: Monotone non-decreasing in tCeil (75 C .. 90 C)
75put st t_die 74000
76put st t_sink 64000
77put pol t_ceil 75000
78wc_cbf_filter st pol pr c_prev
79for i ulong 8
80tc = add 76000 mul long i 2000
81if gt tc 90000
82tc = 90000
83end
84put pol t_ceil tc
85wc_cbf_filter st pol pr c_cur
86if not gt_rails_le c_prev c_cur
87ok = false
88end
89gt_copy_rails c_prev c_cur
90end
91note 10d: Monotone non-increasing in tau (0 .. 8 s)
92put pol t_ceil 78000
93put pol tau 0
94wc_cbf_filter st pol pr c_prev
95for i ulong 8
96put pol tau add long i 1
97wc_cbf_filter st pol pr c_cur
98if not gt_rails_le c_cur c_prev
99ok = false
100end
101gt_copy_rails c_prev c_cur
102end
103note 10e: Monotone non-increasing in whole-unit warm-up (tDie - tSink = 10 C fixed)
104put pol tau 2
105put st t_die 50000
106put st t_sink 40000
107wc_cbf_filter st pol pr c_prev
108for i ulong 8
109td = add 55000 mul long i 4000
110put st t_die td
111put st t_sink sub td 10000
112wc_cbf_filter st pol pr c_cur
113if not gt_rails_le c_cur c_prev
114ok = false
115end
116gt_copy_rails c_prev c_cur
117end
118note 10f: Unconditional pBudget monotonicity with adversarial pUnc+pCpu > pBudget
119put st t_die 74000
120put st t_sink 64000
121put pol t_ceil 78000
122put pol tau 2
123put pr p_gpu 80000
124put pr p_cpu 60000
125put pr p_unc 25000
126put pol p_budget 10000
127wc_cbf_filter st pol pr c_prev
128for i ulong 13
129b2 = add 20000 mul long i 10000
130put pol p_budget b2
131wc_cbf_filter st pol pr c_cur
132if not gt_rails_le c_prev c_cur
133ok = false
134end
135gt_copy_rails c_prev c_cur
136end
137if ok
138wd_puts wg_m_pass
139wd_puts gt_m_t10
140wd_puts gt_m_t10_det
141wd_puts ws_lbl_nl
142else
143wd_puts wg_m_fail
144wd_puts gt_m_t10
145wd_puts ws_lbl_nl
146end
147ret ok
148end
149
150fn gt_t11_ceildiv to bool
151ok = true
152if ne wc_ceil_div -2001 1000 -2
153ok = false
154end
155if ne wc_ceil_div -2000 1000 -2
156ok = false
157end
158if ne wc_ceil_div -1999 1000 -1
159ok = false
160end
161if ne wc_ceil_div -1001 1000 -1
162ok = false
163end
164if ne wc_ceil_div -1000 1000 -1
165ok = false
166end
167if ne wc_ceil_div -999 1000 0
168ok = false
169end
170if ne wc_ceil_div -1 1000 0
171ok = false
172end
173if ne wc_ceil_div 0 1000 0
174ok = false
175end
176if ne wc_ceil_div 1 1000 1
177ok = false
178end
179if ne wc_ceil_div 999 1000 1
180ok = false
181end
182if ne wc_ceil_div 1000 1000 1
183ok = false
184end
185if ne wc_ceil_div 1001 1000 2
186ok = false
187end
188if ne wc_ceil_div 9223372036854775807 1000 9223372036854776
189ok = false
190end
191if ne wc_ceil_div sub long -9223372036854775807 1 1000 -9223372036854775
192ok = false
193end
194if ok
195wd_puts wg_m_pass
196wd_puts gt_m_t11
197wd_puts gt_m_t11_det
198wd_puts ws_lbl_nl
199else
200wd_puts wg_m_fail
201wd_puts gt_m_t11
202wd_puts ws_lbl_nl
203end
204ret ok
205end
206
207fn gt_check_one_case st view WattThermal pol view WattPolicy pr view WattProp to bool
208cmd = new WattCmd 0 0 0 0 0 0
209wc_cbf_filter st pol pr cmd
210pg = get cmd p_gpu
211pc = get cmd p_cpu
212pu = get cmd p_unc
213fn_v = get cmd fan_pct
214if or lt pg 0 or lt pc 0 lt pu 0
215ret false
216end
217if gt pg WATT_P_GPU_HARD_MAX
218ret false
219end
220if gt add add pg pc pu wc_max 0 get pol p_budget
221ret false
222end
223if or lt fn_v WATT_FAN_MIN gt fn_v WATT_FAN_MAX
224ret false
225end
226if and ge get pr p_gpu 0 gt pg get pr p_gpu
227ret false
228end
229if and ge get pr p_cpu 0 gt pc get pr p_cpu
230ret false
231end
232if and ge get pr p_unc 0 gt pu get pr p_unc
233ret false
234end
235if not wg_check_idemp st pol cmd
236ret false
237end
238if ne get cmd fail_closed 0
239if or ne pg 0 or ne pc 0 or ne pu 0 ne fn_v WATT_FAN_MAX
240ret false
241end
242ret true
243end
244dt = wc_next_die_delta st pg pc pu
245h = wc_barrier_h get pol t_ceil get st t_die get pol tau dt
246if lt h 0
247ret false
248end
249td_next = add get st t_die dt
250if gt td_next get pol t_ceil
251ret false
252end
253h_next = wc_barrier_h get pol t_ceil td_next get pol tau dt
254if lt h_next 0
255ret false
256end
257ret true
258end
259
260fn gt_set_regime it ulong st edit WattThermal pol edit WattPolicy to void
261put pol p_budget 100000
262put pol p_gpu_budget 80000
263put pol t_ceil 78000
264put pol tau 2
265put st t_amb 25000
266if eq it 0
267put st t_die 44000
268put st t_sink 36000
269ret
270end
271if eq it 1
272put st t_die 66000
273put st t_sink 58000
274ret
275end
276if eq it 2
277put st t_die 77000
278put st t_sink 69000
279ret
280end
281if eq it 3
282put st t_die 78000
283put st t_sink 70000
284ret
285end
286if eq it 4
287put st t_die 77000
288put st t_sink 77900
289put pol tau 20
290ret
291end
292if eq it 5
293put st t_die 77500
294put st t_sink 86000
295ret
296end
297if eq it 6
298put st t_die 48700
299put st t_sink 150000
300put pol t_ceil 85000
301ret
302end
303put st t_die 77000
304put st t_sink 77000
305end
306
307fn gt_t12_adversarial_matrix to bool
308ok = true
309st = new WattThermal 0 0 0
310pol = new WattPolicy 100000 80000 78000 2
311pr = new WattProp 0 0 0 0
312note 8 thermal/fault regimes x 4 GPU requests x 4 CPU/Unc/fan profiles = 128 adversarial cases
313for it ulong 8
314gt_set_regime it st pol
315for ig ulong 4
316pg = long -5000
317if eq ig 1
318pg = 0
319end
320if eq ig 2
321pg = 88000
322end
323if eq ig 3
324pg = 250000
325end
326for ic ulong 4
327pc = mul long ic 20000
328pu = mul long ic 8000
329fp = sub mul long ic 50 10
330put pr p_gpu pg
331put pr p_cpu pc
332put pr p_unc pu
333put pr fan_pct fp
334if not gt_check_one_case st pol pr
335ok = false
336end
337end
338end
339end
340if ok
341wd_puts wg_m_pass
342wd_puts gt_m_t12
343wd_puts gt_m_t12_det
344wd_puts ws_lbl_nl
345else
346wd_puts wg_m_fail
347wd_puts gt_m_t12
348wd_puts ws_lbl_nl
349end
350ret ok
351end
352
353fn gt_t13_reset_zones v long to void
354for z ulong 7
355put g_tz_ok z 1
356put g_tz_mc z v
357end
358put g_wmeta 0 7
359put g_wmeta 5 v
360put g_wmeta 6 v
361put g_wmeta 7 v
362put g_wmeta 8 v
363put g_wmeta 13 1
364end
365
366fn gt_t13_sensor_faults to bool
367ok = true
368st = new WattThermal 0 0 0
369pol78 = new WattPolicy 100000 80000 78000 2
370pr = new WattProp 75000 17000 8000 60
371note 13a: Missing zone5 [TGPU] (6/7 zones ok) MUST fail closed (never t_die=0C fail-open!)
372gt_t13_reset_zones 48700
373put g_tz_ok 5 0
374put g_tz_mc 5 0
375put g_wmeta 0 6
376put g_wmeta 5 0
377put g_wmeta 13 0
378if ws_fill_thermal_state st
379ok = false
380end
381if not wg_check_fail_closed st pol78 pr
382ok = false
383end
384note 13b: Missing all thermal zones (0/7) MUST fail closed (never 45C fabrication!)
385for z ulong 7
386put g_tz_ok z 0
387put g_tz_mc z 0
388end
389put g_wmeta 0 0
390put g_wmeta 8 0
391put g_wmeta 13 0
392if ws_fill_thermal_state st
393ok = false
394end
395if not wg_check_fail_closed st pol78 pr
396ok = false
397end
398note 13c: Missing zone6 [TUNC] (6/7) stays conservative (t_sink >= t_die - 2000, NEVER 25000!)
399gt_t13_reset_zones 60000
400put g_tz_ok 6 0
401put g_tz_mc 6 0
402put g_wmeta 0 6
403put g_wmeta 7 0
404if not ws_fill_thermal_state st
405ok = false
406end
407if ne get st t_sink 58000
408ok = false
409end
410note 13d: Hot Grace TSOC (86C > 78C ceil) with cool TGPU (48.7C) MUST fail closed as whole unit!
411gt_t13_reset_zones 48700
412put g_tz_mc 0 86000
413put g_wmeta 6 86000
414put g_wmeta 8 86000
415if not ws_fill_thermal_state st
416ok = false
417end
418if ne get st t_die 86000
419ok = false
420end
421if not wg_check_fail_closed st pol78 pr
422ok = false
423end
424note 13e: Cold room (20C) keeps t_amb <= t_sink <= t_die
425gt_t13_reset_zones 20000
426if not ws_fill_thermal_state st
427ok = false
428end
429if or gt get st t_amb get st t_sink gt get st t_sink get st t_die
430ok = false
431end
432note 13f: CPPC permille handles small counters (<1024) and huge 64-bit ratios without wrap/trap
433if ne ws_ratio_permille 500 500 1000
434ok = false
435end
436if ne ws_ratio_permille 18446744073709551615 100 1000000
437ok = false
438end
439note Restore live sensors
440ws_sense_all
441if ok
442wd_puts wg_m_pass
443wd_puts gt_m_t13
444wd_puts gt_m_t13_det
445wd_puts ws_lbl_nl
446else
447wd_puts wg_m_fail
448wd_puts gt_m_t13
449wd_puts ws_lbl_nl
450end
451ret ok
452end
453
454fn main to int
455wd_puts gt_hdr
456wd_flush
457core_rc = wc_run_core_gate
458ext_pass = long 0
459if gt_t10_monotonicity
460ext_pass = add ext_pass 1
461end
462if gt_t11_ceildiv
463ext_pass = add ext_pass 1
464end
465if gt_t12_adversarial_matrix
466ext_pass = add ext_pass 1
467end
468if gt_t13_sensor_faults
469ext_pass = add ext_pass 1
470end
471if and eq core_rc 0 eq ext_pass 4
472wd_puts gt_pass
473wd_flush
474ret 0
475end
476wd_puts gt_fail
477wd_put_i64 long core_rc
478wd_puts gt_fail2
479wd_put_i64 ext_pass
480wd_puts wg_m_sum_of
481wd_put_i64 4
482wd_puts wg_m_sum_tail
483wd_flush
484ret 1
485end