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/hardware.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 / hardware.om` 854 lines ยท 22210 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note gpu/forge/hardware.om: FORGE physical machine descriptors, canonical SHA-256 3 note digesting, V1 GB10 KAT verification, and strict physical bounds validation. 4 note Ported from physics-mv (forge/forge_descriptor.{h,c}, forge/v2/forge_substrate_v2.h, 5 note contracts/native-dgx-spark-draft.json). 6 note Composable OM-2 library module (compose after si/directives/om2.om). 7 8 note ---- Core FORGE Data Structures (all structs declared before first fn) ---- 9 10 struct ForgeHwId hw_id uint substrate_class uint pci_vendor uint pci_device uint rm_compute_class uint rm_sm_version uint sm_count uint warp_size uint max_warps_sm uint max_thr_cta uint max_gpr uint obs_flags uint end 11 12 struct ForgeHwCap smem_cta uint smem_sm uint mem_total ulong mem_avail ulong bw_gbps f64 peak_fp32_tf f64 dtype_flags uint feature_flags uint op_flags uint max_power_w f64 max_temp_mc int max_queues uint end 13 14 struct ForgeContract req_id ulong op_class uint dtype uint dim_m ulong dim_n ulong dim_k ulong batch ulong cta_req uint thr_req uint smem_req uint gpr_req uint extra_ws ulong error_kind uint req_substrate uint req_qual uint req_wave_cap uint end 15 16 struct ForgeBudget lat_us f64 energy_mj f64 power_w f64 temp_mc int now_epoch_s ulong supply_uv uint end 17 18 struct ForgeEnvCheck ok uint violation uint ws_bytes ulong traffic_bytes ulong flops ulong eff_ctas uint eff_thr uint waves uint arith_int f64 comp_us f64 bw_us f64 roof_us f64 est_power_w f64 est_energy_mj f64 compute_bound uint end 19 20 struct ForgeProvider prov_id uint hw_id uint substrate_class uint qual_status uint error_kind uint cal_req uint cal_epoch_s ulong cal_window_s ulong cal_tmin_mc int cal_tmax_mc int fault_state uint active_queues uint lowering_kind uint end 21 22 struct ForgeAdmit admitted uint status uint prov_id uint hw_id uint env_viol uint has_dig_fb uint elig_cnt uint end 23 24 struct ForgePlan admitted uint status uint violation uint prov_id uint hw_id uint substrate_class uint qual_status uint lowering_kind uint tile_m uint tile_n uint tile_k uint grid_x uint grid_y uint block_x uint waves uint compute_bound uint end 25 26 struct ForgeSeals plan_id ulong 4 desc_hash ulong 4 req_hash ulong 4 aegis_tok ulong 4 end 27 28 note ---- Hardware Profile IDs ---- 29 const FG_HW_GB10_SM121 uint 1 30 const FG_HW_AARCH64_GRACE uint 2 31 const FG_HW_GENERIC_CPU uint 3 32 const FG_HW_ANALOG_SIM uint 4 33 const FG_HW_UNQUAL_GPU uint 5 34 const FG_HW_OPTICAL_SIM uint 6 35 36 note ---- FORGE V2 Substrate Classes (frozen numeric ids from forge_substrate_v2.h) ---- 37 const FG_SUB_INVALID uint 0x0000 38 const FG_SUB_DIGITAL_CPU uint 0x0001 39 const FG_SUB_DIGITAL_GPU uint 0x0002 40 const FG_SUB_ANALOG_IN_MEMORY uint 0x0010 41 const FG_SUB_NEUROMORPHIC uint 0x0020 42 const FG_SUB_FPGA_CGRA uint 0x0030 43 const FG_SUB_OPTICAL_PHOTONIC uint 0x0040 44 const FG_SUB_RESERVED_FIRST uint 0x8000 45 46 note ---- Operation Family Bitmask (forge_substrate_v2.h) ---- 47 const FG_OP_MATVEC uint 1 48 const FG_OP_MATMUL uint 2 49 const FG_OP_CONV uint 4 50 const FG_OP_ELEMENTWISE uint 8 51 const FG_OP_REDUCTION uint 16 52 const FG_OP_SPIKE_INT uint 32 53 const FG_OP_TRANSFORM uint 64 54 const FG_OP_SAMPLE uint 128 55 const FG_OP_GENERAL uint 256 56 const FG_OP_KNOWN_MASK uint 0x1ff 57 58 note ---- Precision / Dtype Bitmask ---- 59 const FG_DT_FP32 uint 1 60 const FG_DT_FP16 uint 2 61 const FG_DT_BF16 uint 4 62 const FG_DT_FP8 uint 8 63 const FG_DT_INT8 uint 16 64 const FG_DT_INT32 uint 32 65 const FG_DT_U64 uint 64 66 const FG_DT_FP64 uint 128 67 const FG_DT_KNOWN_MASK uint 0xff 68 69 note ---- Hardware Feature Flags (forge_descriptor.h + tensor cores) ---- 70 const FG_FEAT_UNIFIED_MEM uint 1 71 const FG_FEAT_COMPUTE_B uint 2 72 const FG_FEAT_GPFIFO_A uint 4 73 const FG_FEAT_USERMODE_A uint 8 74 const FG_FEAT_PAGE_FAULT uint 16 75 const FG_FEAT_TENSOR_CORES uint 32 76 77 note ---- Hardware Validation Error Codes ---- 78 const FG_HWVAL_OK uint 0 79 const FG_HWVAL_BAD_SUBSTRATE uint 1 80 const FG_HWVAL_BAD_GEOMETRY uint 2 81 const FG_HWVAL_BAD_MEMORY uint 3 82 const FG_HWVAL_BAD_ROOFLINE uint 4 83 const FG_HWVAL_BAD_THERMAL uint 5 84 const FG_HWVAL_BAD_CAPS uint 6 85 const FG_HWVAL_BAD_GB10_ID uint 7 86 87 note ---- Text Constants for V1 KAT (forge_descriptor.c:456-466) ---- 88 text fg_kat_bdf "000f:01:00.0" 89 text fg_kat_drv "580.173.02" 90 text fg_kat_vbios "9a.0b.2d.00.00" 91 text fg_kat_hex "`10d63d05f888eaba4fe473c5f17febe22f462f543ae0c2b005a9a8e5417e09fd`" 92 93 note ---- Pure-Omega FIPS 180-4 SHA-256 (self-contained, stateless) ---- 94 95 fn fg_sha_kinit k edit uint 64 to void 96 put k 0 0x428a2f98 97 put k 1 0x71374491 98 put k 2 0xb5c0fbcf 99 put k 3 0xe9b5dba5 100 put k 4 0x3956c25b 101 put k 5 0x59f111f1 102 put k 6 0x923f82a4 103 put k 7 0xab1c5ed5 104 put k 8 0xd807aa98 105 put k 9 0x12835b01 106 put k 10 0x243185be 107 put k 11 0x550c7dc3 108 put k 12 0x72be5d74 109 put k 13 0x80deb1fe 110 put k 14 0x9bdc06a7 111 put k 15 0xc19bf174 112 put k 16 0xe49b69c1 113 put k 17 0xefbe4786 114 put k 18 0x0fc19dc6 115 put k 19 0x240ca1cc 116 put k 20 0x2de92c6f 117 put k 21 0x4a7484aa 118 put k 22 0x5cb0a9dc 119 put k 23 0x76f988da 120 put k 24 0x983e5152 121 put k 25 0xa831c66d 122 put k 26 0xb00327c8 123 put k 27 0xbf597fc7 124 put k 28 0xc6e00bf3 125 put k 29 0xd5a79147 126 put k 30 0x06ca6351 127 put k 31 0x14292967 128 put k 32 0x27b70a85 129 put k 33 0x2e1b2138 130 put k 34 0x4d2c6dfc 131 put k 35 0x53380d13 132 put k 36 0x650a7354 133 put k 37 0x766a0abb 134 put k 38 0x81c2c92e 135 put k 39 0x92722c85 136 put k 40 0xa2bfe8a1 137 put k 41 0xa81a664b 138 put k 42 0xc24b8b70 139 put k 43 0xc76c51a3 140 put k 44 0xd192e819 141 put k 45 0xd6990624 142 put k 46 0xf40e3585 143 put k 47 0x106aa070 144 put k 48 0x19a4c116 145 put k 49 0x1e376c08 146 put k 50 0x2748774c 147 put k 51 0x34b0bcb5 148 put k 52 0x391c0cb3 149 put k 53 0x4ed8aa4a 150 put k 54 0x5b9cca4f 151 put k 55 0x682e6ff3 152 put k 56 0x748f82ee 153 put k 57 0x78a5636f 154 put k 58 0x84c87814 155 put k 59 0x8cc70208 156 put k 60 0x90befffa 157 put k 61 0xa4506ceb 158 put k 62 0xbef9a3f7 159 put k 63 0xc67178f2 160 ret 161 end 162 163 fn fg_sha_be32 b view uchar 64 off ulong to uint 164 b0 = uint get b off 165 b1 = uint get b add off 1 166 b2 = uint get b add off 2 167 b3 = uint get b add off 3 168 t0 = or shl b0 24 shl b1 16 169 t1 = or shl b2 8 b3 170 ret or t0 t1 171 end 172 173 fn fg_sha_sched blk view uchar 64 w edit uint 64 to void 174 for i ulong 16 175 off = mul i 4 176 put w i fg_sha_be32 blk off 177 end 178 i = ulong 16 179 while lt i 64 bound 48 180 x1 = get w sub i 15 181 s0 = xor xor rotr x1 7 rotr x1 18 shr x1 3 182 x2 = get w sub i 2 183 s1 = xor xor rotr x2 17 rotr x2 19 shr x2 10 184 v = add add get w sub i 16 s0 add get w sub i 7 s1 185 put w i v 186 i = add i 1 187 end 188 ret 189 end 190 191 fn fg_sha_t1 e uint f uint g uint h uint kw uint to uint 192 s1 = xor xor rotr e 6 rotr e 11 rotr e 25 193 ch = xor and e f and not e g 194 ret add add add h s1 ch kw 195 end 196 197 fn fg_sha_t2 a uint b uint c uint to uint 198 s0 = xor xor rotr a 2 rotr a 13 rotr a 22 199 maj = xor xor and a b and a c and b c 200 ret add s0 maj 201 end 202 203 fn fg_sha_round v edit uint 8 ki uint wi uint to void 204 kw = add ki wi 205 t1 = fg_sha_t1 get v 4 get v 5 get v 6 get v 7 kw 206 t2 = fg_sha_t2 get v 0 get v 1 get v 2 207 put v 7 get v 6 208 put v 6 get v 5 209 put v 5 get v 4 210 put v 4 add get v 3 t1 211 put v 3 get v 2 212 put v 2 get v 1 213 put v 1 get v 0 214 put v 0 add t1 t2 215 ret 216 end 217 218 fn fg_sha_compress st edit uint 8 blk view uchar 64 k view uint 64 to void 219 w = new uint 64 0 220 fg_sha_sched blk w 221 v = new uint 8 0 222 for i ulong 8 223 put v i get st i 224 end 225 for i ulong 64 226 fg_sha_round v get k i get w i 227 end 228 for i ulong 8 229 put st i add get st i get v i 230 end 231 ret 232 end 233 234 fn fg_sha_store st view uint 8 dst edit uchar 32 to void 235 for i ulong 8 236 v = get st i 237 off = mul i 4 238 put dst off uchar and shr v 24 0xff 239 put dst add off 1 uchar and shr v 16 0xff 240 put dst add off 2 uchar and shr v 8 0xff 241 put dst add off 3 uchar and v 0xff 242 end 243 ret 244 end 245 246 fn fg_sha256 msg view uchar * dst edit uchar 32 to void 247 st = new uint 8 0 248 put st 0 0x6a09e667 249 put st 1 0xbb67ae85 250 put st 2 0x3c6ef372 251 put st 3 0xa54ff53a 252 put st 4 0x510e527f 253 put st 5 0x9b05688c 254 put st 6 0x1f83d9ab 255 put st 7 0x5be0cd19 256 k = new uint 64 0 257 fg_sha_kinit k 258 blk = new uchar 64 0 259 n = len msg 260 pos = ulong 0 261 while le add pos 64 n bound 256 262 for j ulong 64 263 put blk j get msg add pos j 264 end 265 fg_sha_compress st blk k 266 pos = add pos 64 267 end 268 remn = sub n pos 269 for j ulong 64 270 put blk j uchar 0 271 end 272 j = ulong 0 273 while lt j remn bound 64 274 put blk j get msg add pos j 275 j = add j 1 276 end 277 put blk remn uchar 0x80 278 if ge remn 56 279 fg_sha_compress st blk k 280 for z ulong 64 281 put blk z uchar 0 282 end 283 end 284 bits = mul n 8 285 put blk 56 uchar and shr bits 56 0xff 286 put blk 57 uchar and shr bits 48 0xff 287 put blk 58 uchar and shr bits 40 0xff 288 put blk 59 uchar and shr bits 32 0xff 289 put blk 60 uchar and shr bits 24 0xff 290 put blk 61 uchar and shr bits 16 0xff 291 put blk 62 uchar and shr bits 8 0xff 292 put blk 63 uchar and bits 0xff 293 fg_sha_compress st blk k 294 fg_sha_store st dst 295 ret 296 end 297 298 note ---- Little-Endian Serialization Helpers ---- 299 300 fn fg_put_u16 buf edit uchar * off ulong v uint to void 301 put buf off uchar and v 0xff 302 put buf add off 1 uchar and shr v 8 0xff 303 ret 304 end 305 306 fn fg_put_u32 buf edit uchar * off ulong v uint to void 307 put buf off uchar and v 0xff 308 put buf add off 1 uchar and shr v 8 0xff 309 put buf add off 2 uchar and shr v 16 0xff 310 put buf add off 3 uchar and shr v 24 0xff 311 ret 312 end 313 314 fn fg_put_u64 buf edit uchar * off ulong v ulong to void 315 put buf off uchar and v 0xff 316 put buf add off 1 uchar and shr v 8 0xff 317 put buf add off 2 uchar and shr v 16 0xff 318 put buf add off 3 uchar and shr v 24 0xff 319 put buf add off 4 uchar and shr v 32 0xff 320 put buf add off 5 uchar and shr v 40 0xff 321 put buf add off 6 uchar and shr v 48 0xff 322 put buf add off 7 uchar and shr v 56 0xff 323 ret 324 end 325 326 fn fg_copy_bytes dst edit uchar * doff ulong src view uchar * n ulong to void 327 i = ulong 0 328 while lt i n bound 256 329 put dst add doff i get src i 330 i = add i 1 331 end 332 ret 333 end 334 335 fn fg_hex_nibble v uint to uchar 336 if lt v 10 337 ret uchar add v 48 338 end 339 ret uchar add sub v 10 97 340 end 341 342 fn fg_digest_to_hex dig view uchar 32 dst edit uchar 64 to void 343 for i ulong 32 344 b = uint get dig i 345 put dst mul i 2 fg_hex_nibble and shr b 4 0xf 346 put dst add mul i 2 1 fg_hex_nibble and b 0xf 347 end 348 ret 349 end 350 351 fn fg_bytes_eq a view uchar * b view uchar * n ulong to bool 352 if lt len a n 353 ret false 354 end 355 if lt len b n 356 ret false 357 end 358 i = ulong 0 359 while lt i n bound 256 360 if ne get a i get b i 361 ret false 362 end 363 i = add i 1 364 end 365 ret true 366 end 367 368 note ---- Physical Machine Descriptors ---- 369 370 fn fg_hw_load_gb10 hid edit ForgeHwId hcap edit ForgeHwCap to void 371 note DGX Spark GB10 Blackwell (sm_121): 48 SMs, 6144 cores, 273 GB/s unified LPDDR5x 372 put hid hw_id FG_HW_GB10_SM121 373 put hid substrate_class FG_SUB_DIGITAL_GPU 374 put hid pci_vendor uint 0x10de 375 put hid pci_device uint 0x2e12 376 put hid rm_compute_class uint 0x0000cec0 377 put hid rm_sm_version uint 0x00000a04 378 put hid sm_count uint 48 379 put hid warp_size uint 32 380 put hid max_warps_sm uint 48 381 put hid max_thr_cta uint 1024 382 put hid max_gpr uint 128 383 put hid obs_flags uint 0x1ffff 384 put hcap smem_cta uint 49152 385 put hcap smem_sm uint 233472 386 put hcap mem_total ulong `130660888576` 387 put hcap mem_avail ulong `126917984256` 388 put hcap bw_gbps 273.0f64 389 put hcap peak_fp32_tf 31.0f64 390 put hcap dtype_flags uint 0xff 391 put hcap feature_flags uint 0x3f 392 put hcap op_flags uint 0x1df 393 put hcap max_power_w 140.0f64 394 put hcap max_temp_mc int 85000 395 put hcap max_queues uint 4 396 ret 397 end 398 399 fn fg_hw_load_grace hid edit ForgeHwId hcap edit ForgeHwCap to void 400 note DGX Spark Grace AArch64 CPU: 20 cores, unified LPDDR5x, no FP8 hardware 401 put hid hw_id FG_HW_AARCH64_GRACE 402 put hid substrate_class FG_SUB_DIGITAL_CPU 403 put hid pci_vendor uint 0 404 put hid pci_device uint 0 405 put hid rm_compute_class uint 0 406 put hid rm_sm_version uint 0 407 put hid sm_count uint 20 408 put hid warp_size uint 1 409 put hid max_warps_sm uint 1 410 put hid max_thr_cta uint 64 411 put hid max_gpr uint 32 412 put hid obs_flags uint 0x2800 413 put hcap smem_cta uint 65536 414 put hcap smem_sm uint `1048576` 415 put hcap mem_total ulong `130660888576` 416 put hcap mem_avail ulong `126917984256` 417 put hcap bw_gbps 180.0f64 418 put hcap peak_fp32_tf 1.6f64 419 put hcap dtype_flags uint 0xf7 420 put hcap feature_flags uint 0x01 421 put hcap op_flags uint 0x1df 422 put hcap max_power_w 65.0f64 423 put hcap max_temp_mc int 90000 424 put hcap max_queues uint 4 425 ret 426 end 427 428 fn fg_hw_load_generic_cpu hid edit ForgeHwId hcap edit ForgeHwCap to void 429 note Generic portable AArch64/host CPU profile: 8 cores, 16 GiB RAM, no FP16/BF16/FP8 430 put hid hw_id FG_HW_GENERIC_CPU 431 put hid substrate_class FG_SUB_DIGITAL_CPU 432 put hid pci_vendor uint 0 433 put hid pci_device uint 0 434 put hid rm_compute_class uint 0 435 put hid rm_sm_version uint 0 436 put hid sm_count uint 8 437 put hid warp_size uint 1 438 put hid max_warps_sm uint 1 439 put hid max_thr_cta uint 32 440 put hid max_gpr uint 32 441 put hid obs_flags uint 0x2800 442 put hcap smem_cta uint 32768 443 put hcap smem_sm uint 262144 444 put hcap mem_total ulong `17179869184` 445 put hcap mem_avail ulong `12884901888` 446 put hcap bw_gbps 64.0f64 447 put hcap peak_fp32_tf 0.5f64 448 put hcap dtype_flags uint 0xf1 449 put hcap feature_flags uint 0x01 450 put hcap op_flags uint 0x11b 451 put hcap max_power_w 45.0f64 452 put hcap max_temp_mc int 95000 453 put hcap max_queues uint 2 454 ret 455 end 456 457 fn fg_hw_load_analog_sim hid edit ForgeHwId hcap edit ForgeHwCap to void 458 note FORGE V2 AR2 simulated analog in-memory matvec substrate (SIMULATED_DEVELOPMENT) 459 put hid hw_id FG_HW_ANALOG_SIM 460 put hid substrate_class FG_SUB_ANALOG_IN_MEMORY 461 put hid pci_vendor uint 0 462 put hid pci_device uint 0 463 put hid rm_compute_class uint 0 464 put hid rm_sm_version uint 0 465 put hid sm_count uint 4 466 put hid warp_size uint 1 467 put hid max_warps_sm uint 1 468 put hid max_thr_cta uint 64 469 put hid max_gpr uint 16 470 put hid obs_flags uint 0 471 put hcap smem_cta uint 16384 472 put hcap smem_sm uint 65536 473 put hcap mem_total ulong `16777216` 474 put hcap mem_avail ulong `8388608` 475 put hcap bw_gbps 100.0f64 476 put hcap peak_fp32_tf 4.0f64 477 put hcap dtype_flags uint 0x70 478 put hcap feature_flags uint 0 479 put hcap op_flags uint 0x01 480 put hcap max_power_w 15.0f64 481 put hcap max_temp_mc int 70000 482 put hcap max_queues uint 1 483 ret 484 end 485 486 fn fg_hw_load_unqual_gpu hid edit ForgeHwId hcap edit ForgeHwCap to void 487 note Unqualified discrete GPU profile (non-GB10, BLOCKED_HARDWARE until silicon gate) 488 put hid hw_id FG_HW_UNQUAL_GPU 489 put hid substrate_class FG_SUB_DIGITAL_GPU 490 put hid pci_vendor uint 0x1002 491 put hid pci_device uint 0x74a1 492 put hid rm_compute_class uint 0 493 put hid rm_sm_version uint 0 494 put hid sm_count uint 64 495 put hid warp_size uint 64 496 put hid max_warps_sm uint 32 497 put hid max_thr_cta uint 1024 498 put hid max_gpr uint 256 499 put hid obs_flags uint 0 500 put hcap smem_cta uint 65536 501 put hcap smem_sm uint 65536 502 put hcap mem_total ulong `68719476736` 503 put hcap mem_avail ulong `64424509440` 504 put hcap bw_gbps 1600.0f64 505 put hcap peak_fp32_tf 80.0f64 506 put hcap dtype_flags uint 0xff 507 put hcap feature_flags uint 0x20 508 put hcap op_flags uint 0x1df 509 put hcap max_power_w 350.0f64 510 put hcap max_temp_mc int 85000 511 put hcap max_queues uint 4 512 ret 513 end 514 515 fn fg_hw_load_optical hid edit ForgeHwId hcap edit ForgeHwCap to void 516 note Optical photonic substrate profile (NOT_RUN, no hardware qualified) 517 put hid hw_id FG_HW_OPTICAL_SIM 518 put hid substrate_class FG_SUB_OPTICAL_PHOTONIC 519 put hid pci_vendor uint 0 520 put hid pci_device uint 0 521 put hid rm_compute_class uint 0 522 put hid rm_sm_version uint 0 523 put hid sm_count uint 4 524 put hid warp_size uint 1 525 put hid max_warps_sm uint 1 526 put hid max_thr_cta uint 64 527 put hid max_gpr uint 16 528 put hid obs_flags uint 0 529 put hcap smem_cta uint 16384 530 put hcap smem_sm uint 65536 531 put hcap mem_total ulong `16777216` 532 put hcap mem_avail ulong `8388608` 533 put hcap bw_gbps 120.0f64 534 put hcap peak_fp32_tf 8.0f64 535 put hcap dtype_flags uint 0x71 536 put hcap feature_flags uint 0 537 put hcap op_flags uint 0x03 538 put hcap max_power_w 20.0f64 539 put hcap max_temp_mc int 65000 540 put hcap max_queues uint 1 541 ret 542 end 543 544 fn fg_hw_load_profile pid uint hid edit ForgeHwId hcap edit ForgeHwCap to bool 545 if eq pid FG_HW_GB10_SM121 546 fg_hw_load_gb10 hid hcap 547 ret true 548 end 549 if eq pid FG_HW_AARCH64_GRACE 550 fg_hw_load_grace hid hcap 551 ret true 552 end 553 if eq pid FG_HW_GENERIC_CPU 554 fg_hw_load_generic_cpu hid hcap 555 ret true 556 end 557 if eq pid FG_HW_ANALOG_SIM 558 fg_hw_load_analog_sim hid hcap 559 ret true 560 end 561 if eq pid FG_HW_UNQUAL_GPU 562 fg_hw_load_unqual_gpu hid hcap 563 ret true 564 end 565 if eq pid FG_HW_OPTICAL_SIM 566 fg_hw_load_optical hid hcap 567 ret true 568 end 569 ret false 570 end 571 572 note ---- Substrate Class & Alias Verification ---- 573 574 fn fg_sub_is_known sc uint to bool 575 if eq sc FG_SUB_DIGITAL_CPU 576 ret true 577 end 578 if eq sc FG_SUB_DIGITAL_GPU 579 ret true 580 end 581 if eq sc FG_SUB_ANALOG_IN_MEMORY 582 ret true 583 end 584 if eq sc FG_SUB_NEUROMORPHIC 585 ret true 586 end 587 if eq sc FG_SUB_FPGA_CGRA 588 ret true 589 end 590 if eq sc FG_SUB_OPTICAL_PHOTONIC 591 ret true 592 end 593 ret false 594 end 595 596 fn fg_sub_is_digital sc uint to bool 597 if eq sc FG_SUB_DIGITAL_CPU 598 ret true 599 end 600 if eq sc FG_SUB_DIGITAL_GPU 601 ret true 602 end 603 ret false 604 end 605 606 note Matches forge_descriptor.c:495: sm_121 derived strictly from observed RM fields 607 fn fg_hw_alias_is_sm121 hid view ForgeHwId to bool 608 if eq get hid rm_compute_class uint 0x0000cec0 609 if eq get hid rm_sm_version uint 0x00000a04 610 ret true 611 end 612 end 613 ret false 614 end 615 616 note ---- Strict Physical Bounds Validation ---- 617 618 fn fg_hw_validate hid view ForgeHwId hcap view ForgeHwCap to uint 619 sc = get hid substrate_class 620 if not fg_sub_is_known sc 621 ret FG_HWVAL_BAD_SUBSTRATE 622 end 623 if eq get hid sm_count 0 624 ret FG_HWVAL_BAD_GEOMETRY 625 end 626 if eq get hid warp_size 0 627 ret FG_HWVAL_BAD_GEOMETRY 628 end 629 if eq get hid max_warps_sm 0 630 ret FG_HWVAL_BAD_GEOMETRY 631 end 632 if eq get hid max_thr_cta 0 633 ret FG_HWVAL_BAD_GEOMETRY 634 end 635 if eq get hid max_gpr 0 636 ret FG_HWVAL_BAD_GEOMETRY 637 end 638 mt = get hcap mem_total 639 ma = get hcap mem_avail 640 if eq mt 0 641 ret FG_HWVAL_BAD_MEMORY 642 end 643 if eq ma 0 644 ret FG_HWVAL_BAD_MEMORY 645 end 646 if gt ma mt 647 ret FG_HWVAL_BAD_MEMORY 648 end 649 if gt get hcap smem_cta get hcap smem_sm 650 ret FG_HWVAL_BAD_MEMORY 651 end 652 if le get hcap bw_gbps 0.0f64 653 ret FG_HWVAL_BAD_ROOFLINE 654 end 655 if le get hcap peak_fp32_tf 0.0f64 656 ret FG_HWVAL_BAD_ROOFLINE 657 end 658 if le get hcap max_power_w 0.0f64 659 ret FG_HWVAL_BAD_THERMAL 660 end 661 tmc = get hcap max_temp_mc 662 if le tmc 0 663 ret FG_HWVAL_BAD_THERMAL 664 end 665 if gt tmc 125000 666 ret FG_HWVAL_BAD_THERMAL 667 end 668 if eq get hcap dtype_flags 0 669 ret FG_HWVAL_BAD_CAPS 670 end 671 if eq get hcap op_flags 0 672 ret FG_HWVAL_BAD_CAPS 673 end 674 if eq get hcap max_queues 0 675 ret FG_HWVAL_BAD_CAPS 676 end 677 if fg_hw_alias_is_sm121 hid 678 if ne get hid pci_vendor uint 0x10de 679 ret FG_HWVAL_BAD_GB10_ID 680 end 681 if ne get hid warp_size 32 682 ret FG_HWVAL_BAD_GB10_ID 683 end 684 if gt get hid max_gpr 128 685 ret FG_HWVAL_BAD_GB10_ID 686 end 687 end 688 ret FG_HWVAL_OK 689 end 690 691 note ---- Canonical Hardware Descriptor Digest (SHA-256) ---- 692 693 fn fg_hw_digest hid view ForgeHwId hcap view ForgeHwCap dst edit uchar 32 to void 694 buf = new uchar 128 0 695 put buf 0 uchar 70 696 put buf 1 uchar 71 697 put buf 2 uchar 72 698 put buf 3 uchar 87 699 put buf 4 uchar 45 700 put buf 5 uchar 86 701 put buf 6 uchar 49 702 put buf 7 uchar 0 703 fg_put_u32 buf 8 get hid hw_id 704 fg_put_u32 buf 12 get hid substrate_class 705 fg_put_u32 buf 16 get hid pci_vendor 706 fg_put_u32 buf 20 get hid pci_device 707 fg_put_u32 buf 24 get hid rm_compute_class 708 fg_put_u32 buf 28 get hid rm_sm_version 709 fg_put_u32 buf 32 get hid sm_count 710 fg_put_u32 buf 36 get hid warp_size 711 fg_put_u32 buf 40 get hid max_warps_sm 712 fg_put_u32 buf 44 get hid max_thr_cta 713 fg_put_u32 buf 48 get hid max_gpr 714 fg_put_u32 buf 52 get hid obs_flags 715 fg_put_u32 buf 56 get hcap smem_cta 716 fg_put_u32 buf 60 get hcap smem_sm 717 fg_put_u64 buf 64 get hcap mem_total 718 fg_put_u64 buf 72 get hcap mem_avail 719 bw_m = ulong mul get hcap bw_gbps 1000.0f64 720 fg_put_u64 buf 80 bw_m 721 tf_m = ulong mul get hcap peak_fp32_tf 1000.0f64 722 fg_put_u64 buf 88 tf_m 723 fg_put_u32 buf 96 get hcap dtype_flags 724 fg_put_u32 buf 100 get hcap feature_flags 725 fg_put_u32 buf 104 get hcap op_flags 726 pw_m = ulong mul get hcap max_power_w 1000.0f64 727 fg_put_u64 buf 108 pw_m 728 fg_put_u32 buf 116 uint get hcap max_temp_mc 729 fg_put_u32 buf 120 get hcap max_queues 730 fg_put_u32 buf 124 uint 0 731 fg_sha256 buf dst 732 ret 733 end 734 735 note ---- V1 GB10 208-byte Canonical Serialization Known Answer Test (KAT) ---- 736 note Exact match for physics-mv/forge/forge_descriptor.c:447-493 737 note Expected SHA-256: `10d63d05f888eaba4fe473c5f17febe22f462f543ae0c2b005a9a8e5417e09fd` 738 739 fn fg_hw_v1_kat_build buf edit uchar 208 to void 740 fg_put_u16 buf 0 uint 0x10de 741 fg_put_u16 buf 2 uint 0x2e12 742 fg_put_u16 buf 4 uint 0x10de 743 fg_put_u16 buf 6 uint 0x0000 744 fg_copy_bytes buf 8 fg_kat_bdf len fg_kat_bdf 745 for i ulong 16 746 put buf add 24 i uchar add i 1 747 end 748 fg_put_u32 buf 40 uint 0x0000cec0 749 fg_put_u32 buf 44 uint 0x00000a04 750 fg_put_u32 buf 48 uint 32 751 fg_put_u32 buf 52 uint 48 752 fg_put_u32 buf 56 uint 6144 753 fg_put_u32 buf 60 uint 2 754 fg_copy_bytes buf 64 fg_kat_drv len fg_kat_drv 755 fg_copy_bytes buf 96 fg_kat_vbios len fg_kat_vbios 756 fg_copy_bytes buf 128 fg_kat_drv len fg_kat_drv 757 fg_put_u64 buf 160 ulong `130660888576` 758 fg_put_u64 buf 168 ulong 0x1ffffffffff 759 fg_put_u32 buf 176 uint 4096 760 fg_put_u32 buf 180 uint 1024 761 fg_put_u32 buf 184 uint 49152 762 fg_put_u32 buf 188 uint 0x1f 763 fg_put_u32 buf 192 uint 0x1ffff 764 ret 765 end 766 767 fn fg_hw_v1_kat to bool 768 buf = new uchar 208 0 769 fg_hw_v1_kat_build buf 770 dig = new uchar 32 0 771 fg_sha256 buf dig 772 hex = new uchar 64 0 773 fg_digest_to_hex dig hex 774 ret fg_bytes_eq hex fg_kat_hex 64 775 end 776 777 note ---- Pack/Unpack 32-byte Digests <-> 4x u64 Words (for ForgeSeals) ---- 778 779 fn fg_pack_be64 b view uchar 32 off ulong to ulong 780 r = ulong 0 781 for i ulong 8 782 v = ulong get b add off i 783 r = or shl r 8 v 784 end 785 ret r 786 end 787 788 fn fg_unpack_be64 v ulong dst edit uchar 32 off ulong to void 789 put dst off uchar and shr v 56 0xff 790 put dst add off 1 uchar and shr v 48 0xff 791 put dst add off 2 uchar and shr v 40 0xff 792 put dst add off 3 uchar and shr v 32 0xff 793 put dst add off 4 uchar and shr v 24 0xff 794 put dst add off 5 uchar and shr v 16 0xff 795 put dst add off 6 uchar and shr v 8 0xff 796 put dst add off 7 uchar and v 0xff 797 ret 798 end 799 800 fn fg_seals_put_plan s edit ForgeSeals d view uchar 32 to void 801 for i ulong 4 802 put s plan_id i fg_pack_be64 d mul i 8 803 end 804 ret 805 end 806 807 fn fg_seals_get_plan s view ForgeSeals d edit uchar 32 to void 808 for i ulong 4 809 fg_unpack_be64 get s plan_id i d mul i 8 810 end 811 ret 812 end 813 814 fn fg_seals_put_desc s edit ForgeSeals d view uchar 32 to void 815 for i ulong 4 816 put s desc_hash i fg_pack_be64 d mul i 8 817 end 818 ret 819 end 820 821 fn fg_seals_get_desc s view ForgeSeals d edit uchar 32 to void 822 for i ulong 4 823 fg_unpack_be64 get s desc_hash i d mul i 8 824 end 825 ret 826 end 827 828 fn fg_seals_put_req s edit ForgeSeals d view uchar 32 to void 829 for i ulong 4 830 put s req_hash i fg_pack_be64 d mul i 8 831 end 832 ret 833 end 834 835 fn fg_seals_get_req s view ForgeSeals d edit uchar 32 to void 836 for i ulong 4 837 fg_unpack_be64 get s req_hash i d mul i 8 838 end 839 ret 840 end 841 842 fn fg_seals_put_tok s edit ForgeSeals d view uchar 32 to void 843 for i ulong 4 844 put s aegis_tok i fg_pack_be64 d mul i 8 845 end 846 ret 847 end 848 849 fn fg_seals_get_tok s view ForgeSeals d edit uchar 32 to void 850 for i ulong 4 851 fg_unpack_be64 get s aegis_tok i d mul i 8 852 end 853 ret 854 end