Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/gpu/forge/provider.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / gpu / forge / provider.om` 453 lines · 11689 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note gpu/forge/provider.om: Request-bound FORGE provider registry & admission engine. 3 note Matches declared computational contracts to eligible hardware providers. 4 note Enforces honest qualification discipline (BLOCKED_HARDWARE / NOT_RUN never 5 note promoted to QUALIFIED), strict substrate binding (no silent fallback to an 6 note unrequested backend), FORGE V2 calibration freshness & envelope checks, 7 note error-kind dominance, and eligible-set digital fallback admission. 8 note Composable OM-2 library module (compose after hardware.om and envelope.om). 9 10 note ---- Provider Qualification Statuses ---- 11 const FG_QUAL_QUALIFIED uint 1 12 const FG_QUAL_EXERCISED uint 2 13 const FG_QUAL_SIMULATED uint 3 14 const FG_QUAL_BLOCKED_HW uint 4 15 const FG_QUAL_NOT_RUN uint 5 16 const FG_QUAL_FAULTED uint 6 17 18 note ---- FORGE V2 Acceptable Error Kinds ---- 19 const FG_ERRK_EXACT uint 1 20 const FG_ERRK_BOUNDED_DET uint 2 21 const FG_ERRK_BOUNDED_STOCH uint 3 22 const FG_ERRK_MEASURED_DIST uint 4 23 24 note ---- FORGE V2 Fault States ---- 25 const FG_FAULT_NONE uint 0 26 const FG_FAULT_TRANSIENT uint 1 27 const FG_FAULT_PERSISTENT uint 2 28 const FG_FAULT_UNAVAILABLE uint 3 29 30 note ---- FORGE Lowering Kinds (forge_types.h) ---- 31 const FG_LOW_NONE uint 0 32 const FG_LOW_SIMULATED uint 1 33 const FG_LOW_COMPILED uint 2 34 35 note ---- Admission Decision Status Codes ---- 36 const FG_ADMIT_OK uint 0 37 const FG_ADMIT_BLOCKED_HARDWARE uint 1 38 const FG_ADMIT_NOT_RUN uint 2 39 const FG_ADMIT_NO_PROVIDER uint 3 40 const FG_ADMIT_ENVELOPE_VIOL uint 4 41 const FG_ADMIT_CAL_STALE uint 5 42 const FG_ADMIT_CAL_ENVELOPE uint 6 43 const FG_ADMIT_FAULTED uint 7 44 const FG_ADMIT_ERROR_KIND uint 8 45 const FG_ADMIT_NO_DIGITAL_FB uint 9 46 const FG_ADMIT_QUEUE_FULL uint 10 47 48 const FG_MAX_PROVIDERS uint 16 49 50 note ---- Provider Registry Storage (globals accessed directly inside module) ---- 51 global fg_reg_cnt uint 1 52 global fg_reg_pid uint 16 53 global fg_reg_hwid uint 16 54 global fg_reg_sub uint 16 55 global fg_reg_qual uint 16 56 global fg_reg_errk uint 16 57 global fg_reg_creq uint 16 58 global fg_reg_cepoch ulong 16 59 global fg_reg_cwin ulong 16 60 global fg_reg_ctmin int 16 61 global fg_reg_ctmax int 16 62 global fg_reg_fault uint 16 63 global fg_reg_qact uint 16 64 global fg_reg_low uint 16 65 66 fn fg_reg_clear to void 67 put fg_reg_cnt 0 uint 0 68 for i ulong 16 69 put fg_reg_pid i uint 0 70 put fg_reg_hwid i uint 0 71 put fg_reg_sub i uint 0 72 put fg_reg_qual i uint 0 73 put fg_reg_errk i uint 0 74 put fg_reg_creq i uint 0 75 put fg_reg_cepoch i ulong 0 76 put fg_reg_cwin i ulong 0 77 put fg_reg_ctmin i int 0 78 put fg_reg_ctmax i int 0 79 put fg_reg_fault i uint 0 80 put fg_reg_qact i uint 0 81 put fg_reg_low i uint 0 82 end 83 ret 84 end 85 86 fn fg_reg_count to uint 87 ret get fg_reg_cnt 0 88 end 89 90 fn fg_reg_add p view ForgeProvider to bool 91 n = get fg_reg_cnt 0 92 if ge n FG_MAX_PROVIDERS 93 ret false 94 end 95 idx = ulong n 96 put fg_reg_pid idx get p prov_id 97 put fg_reg_hwid idx get p hw_id 98 put fg_reg_sub idx get p substrate_class 99 put fg_reg_qual idx get p qual_status 100 put fg_reg_errk idx get p error_kind 101 put fg_reg_creq idx get p cal_req 102 put fg_reg_cepoch idx get p cal_epoch_s 103 put fg_reg_cwin idx get p cal_window_s 104 put fg_reg_ctmin idx get p cal_tmin_mc 105 put fg_reg_ctmax idx get p cal_tmax_mc 106 put fg_reg_fault idx get p fault_state 107 put fg_reg_qact idx get p active_queues 108 put fg_reg_low idx get p lowering_kind 109 put fg_reg_cnt 0 add n 1 110 ret true 111 end 112 113 fn fg_reg_get idx uint dst edit ForgeProvider to bool 114 n = get fg_reg_cnt 0 115 if ge idx n 116 ret false 117 end 118 k = ulong idx 119 put dst prov_id get fg_reg_pid k 120 put dst hw_id get fg_reg_hwid k 121 put dst substrate_class get fg_reg_sub k 122 put dst qual_status get fg_reg_qual k 123 put dst error_kind get fg_reg_errk k 124 put dst cal_req get fg_reg_creq k 125 put dst cal_epoch_s get fg_reg_cepoch k 126 put dst cal_window_s get fg_reg_cwin k 127 put dst cal_tmin_mc get fg_reg_ctmin k 128 put dst cal_tmax_mc get fg_reg_ctmax k 129 put dst fault_state get fg_reg_fault k 130 put dst active_queues get fg_reg_qact k 131 put dst lowering_kind get fg_reg_low k 132 ret true 133 end 134 135 fn fg_reg_find_by_id pid uint dst edit ForgeProvider to bool 136 n = get fg_reg_cnt 0 137 i = uint 0 138 while lt i n bound 16 139 if eq get fg_reg_pid ulong i pid 140 ret fg_reg_get i dst 141 end 142 i = add i 1 143 end 144 ret false 145 end 146 147 fn fg_reg_set_fault idx uint fstate uint to bool 148 if ge idx get fg_reg_cnt 0 149 ret false 150 end 151 put fg_reg_fault ulong idx fstate 152 ret true 153 end 154 155 fn fg_reg_set_queues idx uint qact uint to bool 156 if ge idx get fg_reg_cnt 0 157 ret false 158 end 159 put fg_reg_qact ulong idx qact 160 ret true 161 end 162 163 note Populate standard FORGE providers (GB10, Grace CPU, Generic CPU, Analog Sim, Unqual GPU, Optical) 164 fn fg_reg_load_defaults to void 165 fg_reg_clear 166 p = new ForgeProvider 1 FG_HW_GB10_SM121 FG_SUB_DIGITAL_GPU FG_QUAL_QUALIFIED FG_ERRK_EXACT 0 0 0 0 0 FG_FAULT_NONE 0 FG_LOW_COMPILED 167 ok = fg_reg_add p 168 put p prov_id uint 2 169 put p hw_id FG_HW_AARCH64_GRACE 170 put p substrate_class FG_SUB_DIGITAL_CPU 171 put p qual_status FG_QUAL_QUALIFIED 172 put p error_kind FG_ERRK_EXACT 173 put p cal_req uint 0 174 put p lowering_kind FG_LOW_COMPILED 175 ok = and ok fg_reg_add p 176 put p prov_id uint 3 177 put p hw_id FG_HW_GENERIC_CPU 178 put p substrate_class FG_SUB_DIGITAL_CPU 179 put p qual_status FG_QUAL_EXERCISED 180 put p error_kind FG_ERRK_EXACT 181 put p cal_req uint 0 182 put p lowering_kind FG_LOW_COMPILED 183 ok = and ok fg_reg_add p 184 put p prov_id uint 4 185 put p hw_id FG_HW_ANALOG_SIM 186 put p substrate_class FG_SUB_ANALOG_IN_MEMORY 187 put p qual_status FG_QUAL_SIMULATED 188 put p error_kind FG_ERRK_BOUNDED_DET 189 put p cal_req uint 1 190 put p cal_epoch_s ulong 1000 191 put p cal_window_s ulong 3600 192 put p cal_tmin_mc int 15000 193 put p cal_tmax_mc int 65000 194 put p lowering_kind FG_LOW_SIMULATED 195 ok = and ok fg_reg_add p 196 put p prov_id uint 5 197 put p hw_id FG_HW_UNQUAL_GPU 198 put p substrate_class FG_SUB_DIGITAL_GPU 199 put p qual_status FG_QUAL_BLOCKED_HW 200 put p error_kind FG_ERRK_EXACT 201 put p cal_req uint 0 202 put p cal_epoch_s ulong 0 203 put p cal_window_s ulong 0 204 put p cal_tmin_mc int 0 205 put p cal_tmax_mc int 0 206 put p lowering_kind FG_LOW_NONE 207 ok = and ok fg_reg_add p 208 put p prov_id uint 6 209 put p hw_id FG_HW_OPTICAL_SIM 210 put p substrate_class FG_SUB_OPTICAL_PHOTONIC 211 put p qual_status FG_QUAL_NOT_RUN 212 put p error_kind FG_ERRK_BOUNDED_STOCH 213 put p cal_req uint 1 214 put p cal_epoch_s ulong 1000 215 put p cal_window_s ulong 600 216 put p cal_tmin_mc int 20000 217 put p cal_tmax_mc int 40000 218 put p lowering_kind FG_LOW_NONE 219 ok = and ok fg_reg_add p 220 if not ok 221 trap 8 222 end 223 ret 224 end 225 226 note ---- Calibration & Single-Provider Eligibility Checks (FORGE V2) ---- 227 228 fn fg_prov_check_cal p view ForgeProvider bud view ForgeBudget to uint 229 if eq get p cal_req 0 230 ret FG_ADMIT_OK 231 end 232 now_s = get bud now_epoch_s 233 ep = get p cal_epoch_s 234 win = get p cal_window_s 235 if eq win 0 236 ret FG_ADMIT_CAL_STALE 237 end 238 if lt now_s ep 239 ret FG_ADMIT_CAL_STALE 240 end 241 if ge sub now_s ep win 242 ret FG_ADMIT_CAL_STALE 243 end 244 tmc = get bud temp_mc 245 if lt tmc get p cal_tmin_mc 246 ret FG_ADMIT_CAL_ENVELOPE 247 end 248 if gt tmc get p cal_tmax_mc 249 ret FG_ADMIT_CAL_ENVELOPE 250 end 251 ret FG_ADMIT_OK 252 end 253 254 fn fg_prov_eval_one p view ForgeProvider req view ForgeContract bud view ForgeBudget env edit ForgeEnvCheck to uint 255 fg_env_reset env 256 if ne get p fault_state FG_FAULT_NONE 257 ret FG_ADMIT_FAULTED 258 end 259 qs = get p qual_status 260 if eq qs FG_QUAL_FAULTED 261 ret FG_ADMIT_FAULTED 262 end 263 if eq qs FG_QUAL_BLOCKED_HW 264 ret FG_ADMIT_BLOCKED_HARDWARE 265 end 266 if eq qs FG_QUAL_NOT_RUN 267 ret FG_ADMIT_NOT_RUN 268 end 269 if eq get req req_qual 1 270 if ne qs FG_QUAL_QUALIFIED 271 ret FG_ADMIT_BLOCKED_HARDWARE 272 end 273 end 274 rk = get req error_kind 275 if eq rk 0 276 rk = FG_ERRK_EXACT 277 end 278 if gt get p error_kind rk 279 ret FG_ADMIT_ERROR_KIND 280 end 281 crc = fg_prov_check_cal p bud 282 if ne crc FG_ADMIT_OK 283 ret crc 284 end 285 hid = new ForgeHwId 0 0 0 0 0 0 0 0 0 0 0 0 286 hcap = new ForgeHwCap 0 0 0 0 0.0f64 0.0f64 0 0 0 0.0f64 0 0 287 if not fg_hw_load_profile get p hw_id hid hcap 288 ret FG_ADMIT_NO_PROVIDER 289 end 290 if ge get p active_queues get hcap max_queues 291 ret FG_ADMIT_QUEUE_FULL 292 end 293 erc = fg_env_check hid hcap req bud env 294 if ne erc FG_ENV_OK 295 ret FG_ADMIT_ENVELOPE_VIOL 296 end 297 ret FG_ADMIT_OK 298 end 299 300 fn fg_env_copy dst edit ForgeEnvCheck src view ForgeEnvCheck to void 301 put dst ok get src ok 302 put dst violation get src violation 303 put dst ws_bytes get src ws_bytes 304 put dst traffic_bytes get src traffic_bytes 305 put dst flops get src flops 306 put dst eff_ctas get src eff_ctas 307 put dst eff_thr get src eff_thr 308 put dst waves get src waves 309 put dst arith_int get src arith_int 310 put dst comp_us get src comp_us 311 put dst bw_us get src bw_us 312 put dst roof_us get src roof_us 313 put dst est_power_w get src est_power_w 314 put dst est_energy_mj get src est_energy_mj 315 put dst compute_bound get src compute_bound 316 ret 317 end 318 319 note Refusal priority: prefer specific envelope/cal/error/qual reasons over generic NO_PROVIDER 320 fn fg_refuse_prio code uint to uint 321 if eq code FG_ADMIT_ENVELOPE_VIOL 322 ret uint 10 323 end 324 if eq code FG_ADMIT_CAL_STALE 325 ret uint 9 326 end 327 if eq code FG_ADMIT_CAL_ENVELOPE 328 ret uint 9 329 end 330 if eq code FG_ADMIT_ERROR_KIND 331 ret uint 8 332 end 333 if eq code FG_ADMIT_QUEUE_FULL 334 ret uint 7 335 end 336 if eq code FG_ADMIT_BLOCKED_HARDWARE 337 ret uint 6 338 end 339 if eq code FG_ADMIT_NOT_RUN 340 ret uint 5 341 end 342 if eq code FG_ADMIT_FAULTED 343 ret uint 4 344 end 345 ret uint 1 346 end 347 348 note Check whether any registered digital provider can satisfy the contract (FORGE V2 §10) 349 fn fg_has_digital_fallback req view ForgeContract bud view ForgeBudget to uint 350 n = get fg_reg_cnt 0 351 p = new ForgeProvider 0 0 0 0 0 0 0 0 0 0 0 0 0 352 tmp_env = new ForgeEnvCheck 0 0 0 0 0 0 0 0 0.0f64 0.0f64 0.0f64 0.0f64 0.0f64 0.0f64 0 353 i = uint 0 354 while lt i n bound 16 355 if fg_reg_get i p 356 if fg_sub_is_digital get p substrate_class 357 rc = fg_prov_eval_one p req bud tmp_env 358 if eq rc FG_ADMIT_OK 359 ret uint 1 360 end 361 end 362 end 363 i = add i 1 364 end 365 ret uint 0 366 end 367 368 fn fg_admit_reset adm edit ForgeAdmit to void 369 put adm admitted uint 0 370 put adm status FG_ADMIT_NO_PROVIDER 371 put adm prov_id uint 0 372 put adm hw_id uint 0 373 put adm env_viol FG_ENV_OK 374 put adm has_dig_fb uint 0 375 put adm elig_cnt uint 0 376 ret 377 end 378 379 fn fg_prov_better cur view ForgeEnvCheck best view ForgeEnvCheck pid uint best_pid uint ec uint to bool 380 if eq ec 0 381 ret true 382 end 383 if lt get cur roof_us get best roof_us 384 ret true 385 end 386 if eq get cur roof_us get best roof_us 387 if lt pid best_pid 388 ret true 389 end 390 end 391 ret false 392 end 393 394 fn fg_prov_try_one idx uint req view ForgeContract bud view ForgeBudget adm edit ForgeAdmit best_env edit ForgeEnvCheck to void 395 p = new ForgeProvider 0 0 0 0 0 0 0 0 0 0 0 0 0 396 if not fg_reg_get idx p 397 ret 398 end 399 if ne get req req_substrate 0 400 if ne get p substrate_class get req req_substrate 401 ret 402 end 403 end 404 cur_env = new ForgeEnvCheck 0 0 0 0 0 0 0 0 0.0f64 0.0f64 0.0f64 0.0f64 0.0f64 0.0f64 0 405 rc = fg_prov_eval_one p req bud cur_env 406 if eq rc FG_ADMIT_OK 407 ec = get adm elig_cnt 408 if fg_prov_better cur_env best_env get p prov_id get adm prov_id ec 409 put adm prov_id get p prov_id 410 put adm hw_id get p hw_id 411 fg_env_copy best_env cur_env 412 end 413 put adm elig_cnt add ec 1 414 else 415 if gt fg_refuse_prio rc fg_refuse_prio get adm status 416 put adm status rc 417 put adm env_viol get cur_env violation 418 end 419 end 420 ret 421 end 422 423 note Request-bound provider admission engine (deterministic minimum-roofline selection) 424 fn fg_prov_admit req view ForgeContract bud view ForgeBudget adm edit ForgeAdmit best_env edit ForgeEnvCheck to uint 425 fg_admit_reset adm 426 fg_env_reset best_env 427 i = uint 0 428 while lt i get fg_reg_cnt 0 bound 16 429 fg_prov_try_one i req bud adm best_env 430 i = add i 1 431 end 432 dig_fb = fg_has_digital_fallback req bud 433 put adm has_dig_fb dig_fb 434 if eq get adm elig_cnt 0 435 put adm admitted uint 0 436 ret get adm status 437 end 438 win = new ForgeProvider 0 0 0 0 0 0 0 0 0 0 0 0 0 439 if fg_reg_find_by_id get adm prov_id win 440 if not fg_sub_is_digital get win substrate_class 441 if eq dig_fb 0 442 put adm admitted uint 0 443 put adm status FG_ADMIT_NO_DIGITAL_FB 444 put adm env_viol FG_ENV_OK 445 ret FG_ADMIT_NO_DIGITAL_FB 446 end 447 end 448 end 449 put adm admitted uint 1 450 put adm status FG_ADMIT_OK 451 put adm env_viol FG_ENV_OK 452 ret FG_ADMIT_OK 453 end