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 / evidence / DECODE-LAUNCH-COLLAPSE-20261013 / graph-r4-uncached / worktree.diff

138 lines · 8893 bytes Raw Blame History
1diff --git a/Makefile b/Makefile
2index b7b853c3..c0c41699 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -36,6 +36,7 @@ SRCS += src/omega_gpu_hostmath.c
6 SRCS += src/omega_blackwell_codegen_router.c src/omega_gpu_router_api.c
7 # OWN-30B W-L2 (2026-10-13): decode launch collapse, new files only: command list (N launches, one submit) + glue kernels
8 SRCS += src/omega_gpu_cmdlist.c src/omega_blackwell_codegen_dec.c
9+SRCS += src/omega_gpu_mem_cached.c
10 SRCS += src/omega_gpu_decode_graph.c
11 # OWN-30B (2026-10-13): bf16 streaming GEMV for the lm_head (omega_gpu_bf16_gemv_api.h), new files only
12 SRCS += src/omega_blackwell_codegen_bf16.c src/omega_gpu_bf16_gemv_api.c
13diff --git a/src/omega_gpu_fp8_api.c b/src/omega_gpu_fp8_api.c
14index 934cc583..501ad1b6 100644
15--- a/src/omega_gpu_fp8_api.c
16+++ b/src/omega_gpu_fp8_api.c
17@@ -4,6 +4,7 @@
18 * coherent with direct CPU mappings"), one launch = omega_gpu_session_launch (shader-cache
19 * invalidate, constant bank, QMD0/QMD1, marker, L2_FLUSH_DIRTY, second marker on uncached memory). */
20 #include "omega_gpu_fp8_api.h"
21+#include "omega_gpu_mem_cached.h"
22 #include "omega_blackwell_codegen_moe.h"
23 #include "omega_gpu_session.h"
24 #include "omega_gpu_fmt.h"
25@@ -35,6 +36,7 @@ static struct {
26 int depth_set; uint32_t depth; /* depth override (depth_set: 0 = automatic) */
27 uint32_t gpr_pad; /* registers declared beyond the kernel's peak (diagnosis knob) */
28 int mutant, no_fold, sealed;
29+ int weights_cached; /* omega_gpu_fp8_set_weight_cache: uploads after it allocate GPU-cached (read-only weights) */
30 bool hooked;
31 Slot cache[CACHE_SLOTS];
32 unsigned next;
33@@ -224,7 +226,8 @@ int omega_gpu_fp8_tensor_upload(uint32_t experts, uint32_t n, uint32_t k, const
34 t->experts = experts; t->n = n; t->k = k;
35 int rc = OMEGA_GPU_FP8_OK;
36 omega_gpu_session_lock();
37- if (!dev_open_locked() || omega_gpu_session_alloc(wbytes, &t->w) != 0 || omega_gpu_session_alloc(scount * 4u, &t->s) != 0) rc = OMEGA_GPU_FP8_CHIP_FAIL;
38+ int (*const alloc)(size_t, OmegaGpuMem *) = g.weights_cached ? omega_gpu_session_alloc_cached : omega_gpu_session_alloc;
39+ if (!dev_open_locked() || alloc(wbytes, &t->w) != 0 || alloc(scount * 4u, &t->s) != 0) rc = OMEGA_GPU_FP8_CHIP_FAIL;
40 omega_gpu_session_unlock();
41 if (rc == OMEGA_GPU_FP8_OK) {
42 memcpy(t->w.cpu, w, wbytes);
43@@ -367,3 +370,7 @@ int omega_gpu_fp8_gemv_grouped_record(OmegaGpuCmdList *cl, const OmegaGpuFp8Tens
44 if (!cl) return OMEGA_GPU_FP8_BAD_ARGS;
45 return gemv_core(t, groups, NULL, NULL, NULL, x_rows, NULL, NULL, tab_va, x_va, cl, y_va);
46 }
47+
48+/* ---- weight cache policy (OWN-30B L2 kernel-time cut) ---- */
49+void omega_gpu_fp8_set_weight_cache(int on) { omega_gpu_session_lock(); g.weights_cached = on ? 1 : 0; omega_gpu_session_unlock(); }
50+int omega_gpu_fp8_weight_cache(void) { return g.weights_cached; }
51diff --git a/src/omega_gpu_fp8_api.h b/src/omega_gpu_fp8_api.h
52index 7e43cc3e..43e97650 100644
53--- a/src/omega_gpu_fp8_api.h
54+++ b/src/omega_gpu_fp8_api.h
55@@ -135,6 +135,10 @@ uint32_t omega_gpu_fp8_depth_for(const OmegaFp8GemvSpec *spec, uint32_t n, uint3
56 int omega_gpu_fp8_kernel_fits(const OmegaFp8GemvSpec *spec, uint32_t *declared);
57 /* CTAs per group per launch (0 restores the automatic choice: MAX_CTAS single, GROUPED_CTAS grouped). */
58 void omega_gpu_fp8_set_cta_budget(uint32_t ctas);
59+/* 1: tensors uploaded from now on live in GPU-cached memory (read-only weights; omega_gpu_mem_cached.h). Default 0:
60+ * GPU-uncached like every session buffer. Tensors already uploaded keep their policy. */
61+void omega_gpu_fp8_set_weight_cache(int on);
62+int omega_gpu_fp8_weight_cache(void);
63 /* Diagnosis: declare `pad` registers beyond the kernel's peak in the QMD (0 = exact peak). */
64 void omega_gpu_fp8_set_gpr_pad(uint32_t pad);
65 /* TEST ONLY: deliberately wrong kernels (1 scale dropped, 2 scale block never advances, 3 group table entry
66diff --git a/tests/gpu_decode_graph_test.c b/tests/gpu_decode_graph_test.c
67index 620c8bae..7abf27fd 100644
68--- a/tests/gpu_decode_graph_test.c
69+++ b/tests/gpu_decode_graph_test.c
70@@ -199,9 +199,10 @@ static int host_only(void) {
71 return g_failed ? 1 : 0;
72 }
73
74-static int chip_run(uint32_t layers, uint32_t vocab, uint32_t reps, int red, const char *out_path) {
75+static int chip_run(uint32_t layers, uint32_t vocab, uint32_t reps, int red, int cached, const char *out_path) {
76 FILE *out = out_path ? fopen(out_path, "w") : NULL;
77- if (out) fprintf(out, "{\"layers\":%u,\"vocab\":%u,\"pos\":%u,\"reps\":%u,\"red\":%d,", layers, vocab, POS, reps, red);
78+ if (out) fprintf(out, "{\"layers\":%u,\"vocab\":%u,\"pos\":%u,\"reps\":%u,\"red\":%d,\"cached_weights\":%d,", layers, vocab, POS, reps, red, cached);
79+ omega_gpu_fp8_set_weight_cache(cached); /* one variable: the FP8 tensors uploaded below live GPU-cached or not */
80 Model m;
81 uint64_t t0 = omega_gpu_session_now_ns();
82 if (model_build(&m, layers, vocab) != 0) { CHECK(0, "synthetic model build"); return 1; }
83@@ -283,6 +284,8 @@ static int chip_run(uint32_t layers, uint32_t vocab, uint32_t reps, int red, con
84 int prc = run_graph(gr, &m, &C, &st);
85 CHECK(prc == 0 && C.tok == C0.tok && !memcmp(C.logits, C0.logits, (size_t)vocab * 4), "C after the mutants bit-identical to the first C");
86
87+ if (out) { uint64_t h = 1469598103934665603ull; const unsigned char *b = (const unsigned char *)C0.logits; for (size_t i = 0; i < (size_t)vocab * 4; i++) { h ^= b[i]; h *= 1099511628211ull; }
88+ fprintf(out, "\"C0_token\":%u,\"C0_logits_fnv\":\"%016" PRIx64 "\",", C0.tok, h); }
89 /* timeline instrument: stamps on -> one timestamp per launch, monotonic, span within the chip time; token unchanged; off -> refuses */
90 {
91 static uint64_t sts[OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 1]; static uint8_t kinds[OMEGA_GPU_CMDLIST_MAX_LAUNCHES];
92@@ -319,10 +322,11 @@ static int chip_run(uint32_t layers, uint32_t vocab, uint32_t reps, int red, con
93 }
94
95 int main(int argc, char **argv) {
96- int host = 0, red = 0; uint32_t reps = 20, layers = 2, vocab = 151936; const char *out = NULL;
97+ int host = 0, red = 0, cached = 0; uint32_t reps = 20, layers = 2, vocab = 151936; const char *out = NULL;
98 for (int i = 1; i < argc; i++) {
99 if (strcmp(argv[i], "--host-only") == 0) host = 1;
100 else if (strcmp(argv[i], "--red") == 0) red = 1;
101+ else if (strcmp(argv[i], "--cached-weights") == 0) cached = 1;
102 else if (strcmp(argv[i], "--reps") == 0 && i + 1 < argc) reps = (uint32_t)atoi(argv[++i]);
103 else if (strcmp(argv[i], "--layers") == 0 && i + 1 < argc) layers = (uint32_t)atoi(argv[++i]);
104 else if (strcmp(argv[i], "--vocab") == 0 && i + 1 < argc) vocab = (uint32_t)atoi(argv[++i]);
105@@ -331,7 +335,7 @@ int main(int argc, char **argv) {
106 }
107 if (reps == 0) reps = 1;
108 if (layers == 0 || layers > 8) layers = 2;
109- int rc = host ? host_only() : chip_run(layers, vocab, reps, red, out);
110+ int rc = host ? host_only() : chip_run(layers, vocab, reps, red, cached, out);
111 printf("%s: %d checks, %d failed: %s\n", host ? "host-only" : red ? "chip-red" : "chip", g_checks, g_failed, rc ? "FAIL" : "PASS");
112 return rc;
113 }
114diff --git a/tools/run_gpu_decode_graph_chip.sh b/tools/run_gpu_decode_graph_chip.sh
115index 0fd229cf..6b7955bf 100755
116--- a/tools/run_gpu_decode_graph_chip.sh
117+++ b/tools/run_gpu_decode_graph_chip.sh
118@@ -1,5 +1,6 @@
119 #!/bin/bash
120-# run_gpu_decode_graph_chip.sh EVIDENCE_DIR [red] [PHYSICS_DIR]
121+# run_gpu_decode_graph_chip.sh EVIDENCE_DIR [main|red|cached] [PHYSICS_DIR]
122+# cached: main with --cached-weights (FP8 tensors in GPU-cached memory); verdict "GPU_DECODE_GRAPH_CHIP_CACHED: PASS|FAIL"
123 # OWN-30B W-L2a chip gate for omega_gpu_decode_graph (one Qwen3-30B-A3B decode token as one command list).
124 # Caller holds the GB10 lock: flock /tmp/aien-gb10.lock tools/run_gpu_decode_graph_chip.sh EVID
125 # 0. host proofs first (never hardware results): --host-only
126@@ -23,6 +24,12 @@ T=./build/gpu_decode_graph_test
127 sha256sum "$T" build/libomega_gpu.a > "$EVID/binaries.sha256"
128 fail=0
129 $T --host-only 2>&1 | tee "$EVID/host-only.log"; [ "${PIPESTATUS[0]}" = 0 ] || fail=1
130+if [ "$MODE" = cached ]; then
131+ $T --cached-weights --reps "${REPS:-20}" --out "$EVID/receipt-cached.json" 2>&1 | tee "$EVID/cached.log"; rc=${PIPESTATUS[0]}
132+ echo "end $(date -u +%FT%TZ) cached_exit=$rc" >> "$EVID/device.txt"
133+ (cd "$EVID" && sha256sum *.json *.log *.txt *.diff *.sha256 > SHA256SUMS)
134+ if [ "$rc" = 0 ] && [ $fail = 0 ]; then echo "GPU_DECODE_GRAPH_CHIP_CACHED: PASS"; exit 0; else echo "GPU_DECODE_GRAPH_CHIP_CACHED: FAIL"; exit 1; fi
135+fi
136 if [ "$MODE" = red ]; then
137 $T --red --reps "${REPS:-3}" --out "$EVID/receipt-red.json" 2>&1 | tee "$EVID/red.log"; rc=${PIPESTATUS[0]}
138 echo "end $(date -u +%FT%TZ) red_exit=$rc" >> "$EVID/device.txt"