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 / seed / ng / physics / pareto_bank.om

297 lines · 6700 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/ng/physics/pareto_bank.om
3note Sovereign Intelligence 2.0 Stage 3 (Pillar 3: Physics-Typed Computing)
4note Pareto Realization Bank: registers multiple proof-bounded realizations per SEMANTIC_ID
5note across precisions and targets (FP64, FP32, BF16, FP8, NVFP4, CPU_X925, CPU_A725, SM121,
6note ARBORIS_SHORTCUT). Enforces proof_mask == 7 (Contract | EGP3 | Antibody) before admission.
7note
8note Compose after:
9note si/directives/om2.om
10note apps/omega-wattd/watt_sense.om
11note apps/omega-wattd/watt_cbf.om
12note seed/ng/target/target_desc.om
13note seed/ng/target/isel.om
14note seed/ng/target/sm121_pe.om
15note seed/ng/target/fabric.om
16
17const PB_CAP ulong 64
18const PB_NONE ulong 999999
19
20note Proof-gate bitmask: bit0=Contract, bit1=EGP3, bit2=Antibody; ALL 3 bits required (== 7)
21const PB_PROOF_CONTRACT ulong 1
22const PB_PROOF_EGP3 ulong 2
23const PB_PROOF_ANTIBODY ulong 4
24const PB_PROOF_REQUIRED ulong 7
25
26note Precision / realization profile IDs
27const PB_PREC_FP64 ulong 1
28const PB_PREC_FP32 ulong 2
29const PB_PREC_BF16 ulong 3
30const PB_PREC_FP8 ulong 4
31const PB_PREC_NVFP4 ulong 5
32const PB_PREC_CPU_X925 ulong 6
33const PB_PREC_CPU_A725 ulong 7
34const PB_PREC_SM121 ulong 8
35const PB_PREC_ARBORIS_SHORTCUT ulong 9
36
37note Registration status / refusal codes
38const PB_OK ulong 0
39const PB_ERR_PROOF_MASK ulong 1
40const PB_ERR_BAD_SEM ulong 2
41const PB_ERR_BAD_TARGET ulong 3
42const PB_ERR_BAD_PREC ulong 4
43const PB_ERR_BAD_METRICS ulong 5
44const PB_ERR_BAD_PTR ulong 6
45const PB_ERR_FULL ulong 7
46
47note Bank storage (struct-of-arrays, 64 proof-bounded realizations)
48global pb_used ulong 64
49global pb_sem ulong 64
50global pb_tid ulong 64
51global pb_prec ulong 64
52global pb_power_mw long 64
53global pb_lat_us long 64
54global pb_joules_uj long 64
55global pb_err_bound long 64
56global pb_proof ulong 64
57global pb_code_ptr ulong 64
58global pb_work_bits long 64
59global pb_count ulong 1
60global pb_rej_proof ulong 1
61
62note Staging area for registering a realization (avoids >6 parameter slots)
63note u64 staging: [0]=sem_id [1]=target_tid [2]=precision_id [3]=proof_mask [4]=code_ptr
64global pb_st_u ulong 8
65note i64 staging: [0]=est_power_mw [1]=est_latency_us [2]=est_joules_uj [3]=proven_err_bound [4]=work_bits
66global pb_st_i long 8
67global pb_last_idx ulong 1
68
69fn pb_init to void
70for i ulong PB_CAP
71put pb_used i 0
72put pb_sem i 0
73put pb_tid i 0
74put pb_prec i 0
75put pb_power_mw i 0
76put pb_lat_us i 0
77put pb_joules_uj i 0
78put pb_err_bound i 0
79put pb_proof i 0
80put pb_code_ptr i 0
81put pb_work_bits i 0
82end
83put pb_count 0 0
84put pb_rej_proof 0 0
85put pb_last_idx 0 PB_NONE
86end
87
88note Derive 64-bit bank SEMANTIC_ID key from the first 8 LE bytes of a 32-byte SHA-256 SEMANTIC_ID
89fn pb_sem_key_from_sha256 dig view uchar * to ulong
90if lt len dig 8
91ret 0
92end
93v = ulong 0
94for i ulong 8
95b = ulong get dig i
96v = or v shl b mul i 8
97end
98ret v
99end
100
101note True iff target_tid executes on the GPU power rail (SM121 / coherent GB10 GPU / Spark Ring)
102fn pb_is_gpu_target tid ulong to bool
103if eq tid TID_SM121
104ret true
105end
106if eq tid TID_APU_GB10
107ret true
108end
109if eq tid TID_SPARK_RING
110ret true
111end
112ret false
113end
114
115note Map (target_tid, precision_id) to fabric.om dispatch mode
116fn pb_mode_for_realization tid ulong prec ulong to ulong
117if eq prec PB_PREC_ARBORIS_SHORTCUT
118ret FAB_MODE_CRYSTALLIZED
119end
120if pb_is_gpu_target tid
121ret FAB_MODE_GPU_NATIVE
122end
123ret FAB_MODE_CPU_NATIVE
124end
125
126note Conservative microjoule estimate from mW and us: ceil(power_mw * lat_us / 1000)
127note 1 mW * 1 us = 1 nJ = 1/1000 uJ
128fn pb_calc_joules_uj power_mw long lat_us long to long
129if or le power_mw 0 le lat_us 0
130ret 0
131end
132if gt power_mw 1000000000
133ret 0
134end
135if gt lat_us 1000000000
136ret 0
137end
138nj = mul power_mw lat_us
139ret wc_ceil_div nj 1000
140end
141
142note Stage identity & proof fields for pb_commit
143fn pb_stage_id sem_id ulong tid ulong prec ulong proof_mask ulong code_ptr ulong to void
144put pb_st_u 0 sem_id
145put pb_st_u 1 tid
146put pb_st_u 2 prec
147put pb_st_u 3 proof_mask
148put pb_st_u 4 code_ptr
149end
150
151note Stage physical & accuracy metrics for pb_commit
152fn pb_stage_phys power_mw long lat_us long joules_uj long err_bound long work_bits long to void
153put pb_st_i 0 power_mw
154put pb_st_i 1 lat_us
155put pb_st_i 2 joules_uj
156put pb_st_i 3 err_bound
157put pb_st_i 4 work_bits
158end
159
160note Admit the staged realization into the bank; strictly enforces proof_mask == 7!
161fn pb_commit to ulong
162put pb_last_idx 0 PB_NONE
163if ne get pb_st_u 3 PB_PROOF_REQUIRED
164put pb_rej_proof 0 add get pb_rej_proof 0 1
165ret PB_ERR_PROOF_MASK
166end
167if eq get pb_st_u 0 0
168ret PB_ERR_BAD_SEM
169end
170if ge get pb_st_u 1 TD_MAX_TARGETS
171ret PB_ERR_BAD_TARGET
172end
173prec = get pb_st_u 2
174if lt prec PB_PREC_FP64
175ret PB_ERR_BAD_PREC
176end
177if gt prec PB_PREC_ARBORIS_SHORTCUT
178ret PB_ERR_BAD_PREC
179end
180if eq get pb_st_u 4 0
181ret PB_ERR_BAD_PTR
182end
183if lt get pb_st_i 0 0
184ret PB_ERR_BAD_METRICS
185end
186if le get pb_st_i 1 0
187ret PB_ERR_BAD_METRICS
188end
189if lt get pb_st_i 2 0
190ret PB_ERR_BAD_METRICS
191end
192if lt get pb_st_i 3 0
193ret PB_ERR_BAD_METRICS
194end
195if lt get pb_st_i 4 0
196ret PB_ERR_BAD_METRICS
197end
198for i ulong PB_CAP
199if eq get pb_used i 0
200put pb_used i 1
201put pb_sem i get pb_st_u 0
202put pb_tid i get pb_st_u 1
203put pb_prec i prec
204put pb_proof i get pb_st_u 3
205put pb_code_ptr i get pb_st_u 4
206put pb_power_mw i get pb_st_i 0
207put pb_lat_us i get pb_st_i 1
208put pb_joules_uj i get pb_st_i 2
209put pb_err_bound i get pb_st_i 3
210wb = get pb_st_i 4
211if eq wb 0
212put pb_work_bits i 1000000
213else
214put pb_work_bits i wb
215end
216put pb_count 0 add get pb_count 0 1
217put pb_last_idx 0 i
218ret PB_OK
219end
220end
221ret PB_ERR_FULL
222end
223
224note Count realizations currently admitted for sem_id
225fn pb_count_for_sem sem_id ulong to ulong
226n = ulong 0
227for i ulong PB_CAP
228if eq get pb_used i 1
229if eq get pb_sem i sem_id
230n = add n 1
231end
232end
233end
234ret n
235end
236
237note True iff realization a strictly Pareto-dominates b on (power_mw, lat_us, err_bound)
238fn pb_dominates a ulong b ulong to bool
239if ge a PB_CAP
240ret false
241end
242if ge b PB_CAP
243ret false
244end
245if ne get pb_used a 1
246ret false
247end
248if ne get pb_used b 1
249ret false
250end
251if ne get pb_sem a get pb_sem b
252ret false
253end
254if gt get pb_power_mw a get pb_power_mw b
255ret false
256end
257if gt get pb_lat_us a get pb_lat_us b
258ret false
259end
260if gt get pb_err_bound a get pb_err_bound b
261ret false
262end
263if lt get pb_power_mw a get pb_power_mw b
264ret true
265end
266if lt get pb_lat_us a get pb_lat_us b
267ret true
268end
269if lt get pb_err_bound a get pb_err_bound b
270ret true
271end
272ret false
273end
274
275note Count non-dominated Pareto-frontier realizations for sem_id
276fn pb_frontier_count sem_id ulong to ulong
277f = ulong 0
278for i ulong PB_CAP
279if eq get pb_used i 1
280if eq get pb_sem i sem_id
281dom = false
282for j ulong PB_CAP
283if ne j i
284if pb_dominates j i
285dom = true
286break
287end
288end
289end
290if not dom
291f = add f 1
292end
293end
294end
295end
296ret f
297end