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/tests/q36_codegen_hash.c # 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 / tests / q36_codegen_hash.c` 96 lines ยท 5072 bytes Raw Blame History 1 /* 2 * q36_codegen_hash: sha256 of the encoded program of every kernel shape the 27B / 30B engines build (host only, no 3 * device). Run before and after a shape parameterisation: the old shapes' lines must be byte-identical (Q36, sc L306). 4 * Extra lines for the new shapes are printed after "# new" (they have no "before"). 5 */ 6 #include "omega_blackwell_codegen.h" 7 #include "omega_blackwell_codegen_gdn.h" 8 #include "omega_blackwell_codegen_attn256.h" 9 #include "omega_blackwell_codegen_pattn256.h" 10 #include "omega_blackwell_codegen_router.h" 11 #include "omega_blackwell_codegen_dec.h" 12 #include "sha256.h" 13 #include 14 #include 15 #include 16 17 static BlackwellIRProgram *prog; 18 static uint8_t code[1u << 22]; 19 20 static void emit(const char *name, int rc) { 21 size_t len = 0; 22 if (rc == 0) rc = omega_bw_encode_program(prog, code, sizeof code, &len); 23 if (rc != 0) { printf("%-40s refused rc=%d\n", name, rc); return; } 24 uint8_t d[32]; 25 sha256_ctx c; 26 sha256_init(&c); sha256_update(&c, code, len); sha256_final(&c, d); 27 printf("%-40s %7zu ", name, len); 28 for (int i = 0; i < 32; i++) printf("%02x", d[i]); 29 printf("\n"); 30 } 31 32 int main(void) { 33 prog = calloc(1, sizeof *prog); 34 char n[64]; 35 for (int m = 0; m <= 4; m++) { 36 OmegaGdnSpec s = {.mutant = m}; 37 snprintf(n, sizeof n, "gdn.decode.m%d", m); omega_bw_ir_init(prog); emit(n, omega_blackwell_codegen_gdn_prog(&s, prog)); 38 snprintf(n, sizeof n, "gdn.prep.m%d", m); omega_bw_ir_init(prog); emit(n, omega_blackwell_codegen_gdn_prep_prog(&s, prog)); 39 snprintf(n, sizeof n, "gdn.scan.m%d", m); omega_bw_ir_init(prog); emit(n, omega_blackwell_codegen_gdn_scan_prog(&s, prog)); 40 snprintf(n, sizeof n, "gdn.post.m%d", m); omega_bw_ir_init(prog); emit(n, omega_blackwell_codegen_gdn_post_prog(&s, prog)); 41 } 42 for (int c = 1; c <= 2; c++) { 43 OmegaGdnSpec s = {.copy = c}; 44 snprintf(n, sizeof n, "gdn.copy%d", c); omega_bw_ir_init(prog); emit(n, omega_blackwell_codegen_gdn_copy_prog(&s, prog)); 45 } 46 for (uint32_t d = 1; d <= 4; d++) 47 for (int m = 0; m <= 5; m++) 48 for (uint32_t p = 0; p <= 1; p++) { 49 OmegaDecodeAttn256Spec s = {.depth = d, .mutant = m, .prep = p}; 50 snprintf(n, sizeof n, "attn256.d%u.m%d.p%u", d, m, p); omega_bw_ir_init(prog); 51 emit(n, omega_blackwell_codegen_decode_attn256_prog(&s, prog)); 52 } 53 for (int m = 0; m <= 4; m++) { 54 OmegaPrefillAttn256Spec s = {.mutant = m}; 55 snprintf(n, sizeof n, "pattn256.m%d", m); omega_bw_ir_init(prog); emit(n, omega_blackwell_codegen_prefill_attn256_prog(&s, prog)); 56 } 57 uint32_t warps[3] = {8, 16, 32}; 58 for (int w = 0; w < 3; w++) 59 for (uint32_t d = 1; d <= 4; d++) 60 for (int m = 0; m <= 4; m++) { 61 OmegaRouterSpec s = {.warps = warps[w], .depth = d, .mutant = m}; 62 snprintf(n, sizeof n, "router.w%u.d%u.m%d", warps[w], d, m); omega_bw_ir_init(prog); 63 emit(n, omega_blackwell_codegen_router_prog(&s, prog)); 64 } 65 for (int w = 0; w < 3; w++) /* the ROWS form (L312 lever 2) at the stroke's strides, plain and mutant 6 */ 66 for (int m = 0; m <= 6; m += 6) { 67 OmegaRouterSpec s = {.warps = warps[w], .depth = 4, .mutant = m, .experts = 256, .shared = 1, .xstride = 8192, .lbstride = 16896}; 68 snprintf(n, sizeof n, "router256s.rows.w%u.d4.m%d", warps[w], m); omega_bw_ir_init(prog); 69 emit(n, omega_blackwell_codegen_router_prog(&s, prog)); 70 } 71 /* the decode glue kernels (RES / SWIGLU / ARGMAX / GATHER / GATE / AXPY) at the widths the 30B and 27B graphs use */ 72 const uint32_t widths[3] = {0, 5120, 17408}, strides[3] = {0, 256, 65536}; 73 for (int k = 1; k <= 6; k++) 74 for (uint32_t mode = 0; mode <= 15; mode++) 75 for (int m = 0; m <= 2; m++) 76 for (int wi = 0; wi < 3; wi++) 77 for (int si = 0; si < 3; si++) { 78 if ((k != OMEGA_DEC_RES && k != OMEGA_DEC_ARGMAX && mode) || (k != OMEGA_DEC_AXPY && k != OMEGA_DEC_GATHER && si)) continue; 79 OmegaDecSpec s = {.kind = (OmegaDecKind)k, .mode = mode, .stride = strides[si], .mutant = m, .width = widths[wi]}; 80 snprintf(n, sizeof n, "dec.k%d.mode%u.m%d.w%u.s%u", k, mode, m, widths[wi], strides[si]); omega_bw_ir_init(prog); 81 emit(n, omega_blackwell_codegen_dec_prog(&s, prog)); 82 } 83 /* GROUP (the stroke v2 sort of N heads x S picks into expert segments): S = 8 (0) and 9 (the 35B), mutants 0..3 */ 84 for (uint32_t gr = 0; gr <= 9; gr += 9) 85 for (int m = 0; m <= 3; m++) { 86 OmegaDecSpec s = {.kind = OMEGA_DEC_GROUP, .groups = gr, .mutant = m}; 87 snprintf(n, sizeof n, "dec.k7.g%u.m%d", gr, m); omega_bw_ir_init(prog); 88 emit(n, omega_blackwell_codegen_dec_prog(&s, prog)); 89 } 90 #ifdef Q36_NEW_SHAPES 91 printf("# new\n"); 92 Q36_NEW_SHAPES 93 #endif 94 free(prog); 95 return 0; 96 }