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 / gpu / driver / tests / q38_sass_parity.sh

92 lines · 3959 bytes Raw Blame History
1#!/bin/sh
2# Host-only bit-exact sm_121 SASS parity check:
3# Pure-.om pipeline (cg_dec -> bw_alloc -> bw_enc_sm121) vs libomega_gpu.a C oracle
4# (src/omega_blackwell_codegen_dec.c + src/omega_blackwell_codegen.c -DCUDAPP_MIGRATION_PENDING_C_ENCODER).
5# Zero Spark GPU usage, zero CUDA, zero NVRM.
6set -eu
7
8OMC="${OMC:-$HOME/.local/bin/omc}"
9if [ ! -x "$OMC" ]; then
10 OMC="./seed/out/omc"
11fi
12TMP="${TMPDIR:-/tmp}/q38-sass-parity-$$"
13mkdir -p "$TMP"
14trap 'rm -rf "$TMP"' EXIT
15
16OS="$(uname -s)"
17if [ "$OS" = "Darwin" ]; then
18 { printf 'target a64macos\n'
19 cat gpu/nvidia/om/codegen/cg_dec_emit.om \
20 gpu/nvidia/om/codegen/cg_dec.om \
21 gpu/driver/tests/q38_sass_emit.om; } | "$OMC" > "$TMP/om_emit"
22 { printf 'target a64macos\n'
23 cat gpu/nvidia/om/components/bw_alloc.om \
24 gpu/nvidia/om/encoder/bw_enc_sm121.om \
25 gpu/driver/tests/q38_sass_encode.om; } | "$OMC" > "$TMP/om_enc"
26else
27 cat gpu/nvidia/om/codegen/cg_dec_emit.om \
28 gpu/nvidia/om/codegen/cg_dec.om \
29 gpu/driver/tests/q38_sass_emit.om | "$OMC" > "$TMP/om_emit"
30 cat gpu/nvidia/om/components/bw_alloc.om \
31 gpu/nvidia/om/encoder/bw_enc_sm121.om \
32 gpu/driver/tests/q38_sass_encode.om | "$OMC" > "$TMP/om_enc"
33fi
34chmod +x "$TMP/om_emit" "$TMP/om_enc"
35"$TMP/om_emit" | "$TMP/om_enc" > "$TMP/om.bin"
36
37cat > "$TMP/c_oracle.c" <<'EOF'
38#include "omega_blackwell_codegen.h"
39#include "omega_blackwell_codegen_dec.h"
40#include <stdint.h>
41#include <stdio.h>
42#include <stdlib.h>
43
44/* Unused symbols referenced by non-called functions in omega_blackwell_codegen.c */
45int omega_blackwell_bind_matmul_realization(const OmegaMatMulSpec *s, const OmegaBlackwellKernel *k, OmegaBlackwellRealizationIdentity *id) { (void)s; (void)k; (void)id; return -1; }
46int omega_blackwell_codegen_matmul(const OmegaMatMulSpec *s, OmegaBlackwellKernel *k) { (void)s; (void)k; return -1; }
47void omega_blackwell_kernel_free(OmegaBlackwellKernel *k) { (void)k; }
48int omega_matmul_spec_init(OmegaMatMulSpec *s, uint32_t m, uint32_t k, uint32_t n, OmegaMatMulPrecision p) { (void)s; (void)m; (void)k; (void)n; (void)p; return -1; }
49void sha256_hash(const void *d, size_t n, uint8_t out[32]) { (void)d; (void)n; for (int i = 0; i < 32; i++) out[i] = 0; }
50
51static void emit_one(const OmegaDecSpec *s) {
52 BlackwellIRProgram *p = calloc(1, sizeof *p);
53 if (!p || omega_blackwell_codegen_dec_prog(s, p) != 0) { fprintf(stderr, "codegen fail\n"); exit(1); }
54 uint8_t buf[16384];
55 size_t nb = 0;
56 if (omega_bw_encode_program(p, buf, sizeof buf, &nb) != 0 || nb == 0) { fprintf(stderr, "encode fail\n"); exit(2); }
57 uint32_t len = (uint32_t)nb;
58 if (fwrite(&len, 4, 1, stdout) != 1 || fwrite(buf, 1, nb, stdout) != nb) { fprintf(stderr, "write fail\n"); exit(3); }
59 free(p);
60}
61
62int main(void) {
63 const OmegaDecSpec specs[7] = {
64 { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_NORM, .width = 5120 },
65 { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_ADD | OMEGA_DEC_RES_NORM, .width = 5120 },
66 { .kind = OMEGA_DEC_SWIGLU, .width = 17408 },
67 { .kind = OMEGA_DEC_GATHER, .width = 14336, .stride = 14336 },
68 { .kind = OMEGA_DEC_GATE },
69 { .kind = OMEGA_DEC_ARGMAX, .mode = 0 },
70 { .kind = OMEGA_DEC_ARGMAX, .mode = 1 },
71 };
72 for (int i = 0; i < 7; i++) emit_one(&specs[i]);
73 return 0;
74}
75EOF
76
77cc -O2 -Isrc -DCUDAPP_MIGRATION_PENDING_C_ENCODER \
78 "$TMP/c_oracle.c" \
79 src/omega_blackwell_codegen.c \
80 src/omega_blackwell_codegen_dec.c \
81 -o "$TMP/c_oracle"
82"$TMP/c_oracle" > "$TMP/c.bin"
83
84cmp "$TMP/om.bin" "$TMP/c.bin"
85OM_SHA="$(shasum -a 256 "$TMP/om.bin" | awk '{print $1}')"
86C_SHA="$(shasum -a 256 "$TMP/c.bin" | awk '{print $1}')"
87BYTES="$(wc -c < "$TMP/om.bin" | tr -d ' ')"
88echo "PASS q38_sass_parity: 7/7 Qwen3.8-27B sm_121 kernels bit-exact (${BYTES} bytes, sha256=${OM_SHA})"
89if [ "$OM_SHA" != "$C_SHA" ]; then
90 echo "FAIL sha256 mismatch" >&2
91 exit 1
92fi