diff --git a/.crumb b/.crumb index f3e51fe46..dfd538237 100644 --- a/.crumb +++ b/.crumb @@ -72,38 +72,38 @@ }, { "digest": "f765ad87fdddd9b47f690b07298c951a0f7e7675dc5de4ffe44e33a0c14b1986", - "last_commit": "a8a6a3d3c", + "last_commit": "62d1d0d66", "name": "spec", "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "aaf5acb82fd4c720cd60c85fd6087f636c72a98e2f3740c9295dcfa525dc64d7", - "last_commit": "bf54b19fa", + "digest": "0078285f63e6b0bc64d04e4e60976e392330c828bbb175004e3e806c2ca3346b", + "last_commit": "aa3a32687", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "5395ff8ff9afceebe8e453788f80a3064b831513cc4cb92fd55869115e06b874", - "last_commit": "a8a6a3d3c", + "digest": "d059ad151044edc5dee7abd73930b38bf547288c21d9bca46d2b25a09558111e", + "last_commit": "aa3a32687", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, { - "digest": "308db0e6cf45c0a48f01f5f5f228450f191389de68006915b9ecf9c65b9a2e29", - "last_commit": "a8a6a3d3c", + "digest": "525712c72947533540b1b861dc53bb88f11d9bc388302bf3ee5b14c60ef891f8", + "last_commit": "72f918e3c", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:07bf1706dcffbad66c0353871ff67a6749055da03cee8d8ebdf9a4c91e36bddc", - "compiled_at": "2026-10-30T12:31:50Z", + "children_root": "sha256:97e100029f7324a498602cef10199f7840f68fa53d2537fa8c2752acf39a7563", + "compiled_at": "2026-10-30T17:06:10Z", "compiler": "crumb-compile/1", - "digest": "sha256:904fca8c0e0cf3e3a5e5adb73393e01c7018b920bb542d289904240f70e400d6", + "digest": "sha256:e8e85f3e45e441d9ceb2ef4a497efc28b8cbe2d2ea75799e817cab5b049841ba", "evidence_files": 12622, "evidence_root": "sha256:b1a08e2ce56e6feada0d8a31f06fbd7adee57adc1c1ad8dec220293ee5d439f9", - "files": 17849, - "generated_at_commit": "52a82f392fa513ebbc2d9d719a0f14c385289b06", - "source_tree": "sha256:75458da6553a0ee5ea2af95f46afb658e8a3f6e53cca6e3b4b9874035f78c2ed" + "files": 17853, + "generated_at_commit": "aa3a32687080e2dde46221eb0a66f6009d84c335", + "source_tree": "sha256:016797676b5e4746636cbf3da2a83c4bd02fef60d2b884a2c5d97bef411b849d" }, "owner_lane": "", "provenance": { diff --git a/Makefile b/Makefile index 6b53cd124..6dc548fdd 100644 --- a/Makefile +++ b/Makefile @@ -2699,6 +2699,32 @@ $(GPU_QGEMM_TEST): tests/gpu_qgemm_test.c tests/bw_qmma_model.h tests/bw_warp_si GPU_PFHOST_TEST = $(OUT_DIR)/gpu_pfhost_test $(GPU_PFHOST_TEST): tests/gpu_pfhost_test.c tests/bw_warp_sim_tc.h src/omega_gpu_pfhost.h src/omega_blackwell_codegen_pfhost.h $(OUT_DIR)/libomega_gpu.a $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=1024 -Itests -o $@ tests/gpu_pfhost_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +# omega#456: the prefill tests above, host model and warp simulator only. Every run names --host-only or --sim, the two +# modes that never open the device (each test's main returns before its chip part); chip runs stay under the GB10 lock. +.PHONY: test-gpu-prefill-host +test-gpu-prefill-host: $(GPU_TC_PROBE_TEST) $(GPU_TCGEMM_TEST) $(GPU_PATTN_TEST) $(GPU_PF_MEM_TEST) $(GPU_PFGEMM_TEST) \ + $(GPU_QMMA_PROBE_TEST) $(GPU_QGEMM_TEST) $(GPU_PFHOST_TEST) + ./$(GPU_TC_PROBE_TEST) --host-only + ./$(GPU_QMMA_PROBE_TEST) --host-only + ./$(GPU_PF_MEM_TEST) --host-only + ./$(GPU_TCGEMM_TEST) --host-only + ./$(GPU_TCGEMM_TEST) --sim + ./$(GPU_PATTN_TEST) --host-only + ./$(GPU_PATTN_TEST) --sim + ./$(GPU_PFGEMM_TEST) --host-only + ./$(GPU_PFGEMM_TEST) --sim + ./$(GPU_QGEMM_TEST) --host-only + ./$(GPU_QGEMM_TEST) --sim + ./$(GPU_PFHOST_TEST) --host-only + ./$(GPU_PFHOST_TEST) --sim + @echo "test-gpu-prefill-host: PASS (8 prefill tests, host model + warp simulator, no device)" +# omega#456: tools/own30b_decode_profile.c is a link-only recorder built by hand on the Spark; compile it with the +# project's -Werror flags so a warning cannot land unseen. +.PHONY: check-own30b-decode-profile +check-own30b-decode-profile: tools/own30b_decode_profile.c + @mkdir -p $(OUT_DIR) + $(CC) $(CFLAGS) -c -o $(OUT_DIR)/own30b_decode_profile.o tools/own30b_decode_profile.c + @echo "check-own30b-decode-profile: PASS (compiles with -Werror)" # OWN-30B W-L2 (2026-10-13): command list (many launches, one submission) + decode glue kernels. test-gpu-cmdlist is # host-only + warp simulator; the chip gate is tools/run_gpu_cmdlist_chip.sh under the GB10 lock. .PHONY: test-gpu-cmdlist @@ -2733,10 +2759,65 @@ test-gpu-isolation: $(GPU_ISOLATION_TEST) # host-only; the chip gate is tools/run_gpu_decode_graph_chip.sh under the GB10 lock. .PHONY: test-gpu-decode-graph GPU_DECODE_GRAPH_TEST = $(OUT_DIR)/gpu_decode_graph_test +GPU_DGRAPH_ABORT_TEST = $(OUT_DIR)/test_omega_gpu_decode_graph_abort $(GPU_DECODE_GRAPH_TEST): tests/gpu_decode_graph_test.c src/omega_gpu_decode_graph.h src/omega_gpu_cmdlist.h $(OUT_DIR)/libomega_gpu.a $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_decode_graph_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm -test-gpu-decode-graph: $(GPU_DECODE_GRAPH_TEST) +test-gpu-decode-graph: $(GPU_DECODE_GRAPH_TEST) $(GPU_DGRAPH_ABORT_TEST) test-gpu-decode-graph-abort-mutants test-gpu-decode-graph-timeline ./$(GPU_DECODE_GRAPH_TEST) --host-only + ./$(GPU_DGRAPH_ABORT_TEST) + +# omega #518: lock and token-state recovery of the split API (failed begin_token, abort_token, end_token after a failed +# record, latched session) on a fake platform whose lock refuses a second acquisition. Host only, opens no device. +# Each mutant breaks one rule in a copy of omega_gpu_decode_graph.c linked ahead of the library; the test must FAIL on it. +.PHONY: test-gpu-decode-graph-abort-mutants +GPU_DGRAPH_MUT_DIR = $(OUT_DIR)/dgraph_mut +$(GPU_DGRAPH_ABORT_TEST): tests/test_omega_gpu_decode_graph_abort.c src/omega_gpu_decode_graph.h src/omega_gpu_platform.h $(OUT_DIR)/libomega_gpu.a + $(CC) $(CFLAGS) -o $@ tests/test_omega_gpu_decode_graph_abort.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +test-gpu-decode-graph-abort-mutants: $(OUT_DIR)/libomega_gpu.a + @mkdir -p $(GPU_DGRAPH_MUT_DIR) + @set -e; killed=0; \ + dmut() { name=$$1; script=$$2; \ + sed -e "$$script" src/omega_gpu_decode_graph.c > $(GPU_DGRAPH_MUT_DIR)/$$name.c; \ + if cmp -s src/omega_gpu_decode_graph.c $(GPU_DGRAPH_MUT_DIR)/$$name.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \ + $(CC) $(filter-out -MMD -MP,$(CFLAGS)) -c -o $(GPU_DGRAPH_MUT_DIR)/$$name.o $(GPU_DGRAPH_MUT_DIR)/$$name.c; \ + $(CC) $(filter-out -MMD -MP,$(CFLAGS)) -o $(GPU_DGRAPH_MUT_DIR)/$$name tests/test_omega_gpu_decode_graph_abort.c \ + $(GPU_DGRAPH_MUT_DIR)/$$name.o $(OUT_DIR)/libomega_gpu.a -lpthread -lm; \ + if ./$(GPU_DGRAPH_MUT_DIR)/$$name > $(GPU_DGRAPH_MUT_DIR)/$$name.log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \ + nfail=$$(grep -c '^FAIL' $(GPU_DGRAPH_MUT_DIR)/$$name.log || true); \ + if [ "$$nfail" -eq 0 ]; then echo "mutant $$name: nonzero exit but no FAIL case (did not run?)"; cat $(GPU_DGRAPH_MUT_DIR)/$$name.log; exit 1; fi; \ + echo "mutant $$name killed: $$nfail case(s) failed"; killed=$$((killed+1)); }; \ + dmut begin-fail-keeps-lock 's| omega_gpu_session_unlock(); /\* begin_fail releases \*/| ;|'; \ + dmut begin-fail-stays-in-token 's| g->in_token = 0; g->failed = 1;| g->failed = 1;|'; \ + dmut oneshot-old-bad-args-only 's|if (brc != OMEGA_GPU_DGRAPH_OK) {|if (brc == OMEGA_GPU_DGRAPH_BAD_ARGS) {|'; \ + dmut abort-keeps-lock 's|g->n_stamp = 0; /\* no timeline for an abandoned token \*/|&\n return OMEGA_GPU_DGRAPH_OK;|'; \ + dmut abort-submits 's|^int omega_gpu_decode_graph_abort_token(OmegaGpuDecodeGraph \*g) {$$|&\n if (g \&\& g->in_token) return omega_gpu_decode_graph_end_token(g, NULL, NULL);|'; \ + echo "test-gpu-decode-graph-abort-mutants: $$killed of 5 mutants killed" + +# omega #456: the per-token timeline (set_stamps) never writes past stamp[]: 4096 stamped launches fill it, the 4097th +# (flush_each, one submission per launch) fails the token and leaves no timeline. Fake platform that completes every +# submission; no device. Each mutant breaks one rule in a copy of omega_gpu_decode_graph.c linked ahead of the library; +# the overflow case must FAIL on it. +.PHONY: test-gpu-decode-graph-timeline +GPU_DGRAPH_TL_TEST = $(OUT_DIR)/test_omega_gpu_decode_graph_timeline +GPU_DGRAPH_TL_MUT = $(OUT_DIR)/dgraph_tl_mut +$(GPU_DGRAPH_TL_TEST): tests/test_omega_gpu_decode_graph_timeline.c src/omega_gpu_decode_graph.h src/omega_gpu_platform.h $(OUT_DIR)/libomega_gpu.a + $(CC) $(CFLAGS) -o $@ tests/test_omega_gpu_decode_graph_timeline.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +test-gpu-decode-graph-timeline: $(GPU_DGRAPH_TL_TEST) + ./$(GPU_DGRAPH_TL_TEST) + @mkdir -p $(GPU_DGRAPH_TL_MUT) + @set -e; \ + tmut() { name=$$1; script=$$2; \ + sed -e "$$script" src/omega_gpu_decode_graph.c > $(GPU_DGRAPH_TL_MUT)/$$name.c; \ + if cmp -s src/omega_gpu_decode_graph.c $(GPU_DGRAPH_TL_MUT)/$$name.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \ + $(CC) $(filter-out -MMD -MP,$(CFLAGS)) -o $(GPU_DGRAPH_TL_MUT)/$$name tests/test_omega_gpu_decode_graph_timeline.c \ + $(GPU_DGRAPH_TL_MUT)/$$name.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm; \ + if ./$(GPU_DGRAPH_TL_MUT)/$$name > $(GPU_DGRAPH_TL_MUT)/$$name.log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \ + if ! grep -q '^FAIL one launch past the timeline' $(GPU_DGRAPH_TL_MUT)/$$name.log; then \ + echo "mutant $$name: no FAIL case (did not run?)"; cat $(GPU_DGRAPH_TL_MUT)/$$name.log; exit 1; fi; \ + echo "mutant $$name killed"; }; \ + tmut room-off-by-one 's|(uint32_t)(cnt - from) > room) {|(uint32_t)(cnt - from) > room + 1u) {|'; \ + tmut timeline-after-failure 's#if (!g->stamps || g->failed || #if (!g->stamps || #'; \ + echo "test-gpu-decode-graph-timeline: 2 of 2 mutants killed" # OWN-30B W-L2c (2026-10-14): per-launch fixed cost inside a command list (tests/gpu_launch_cost_test.c, chip only, GB10 lock). GPU_LAUNCH_COST_TEST = $(OUT_DIR)/gpu_launch_cost_test diff --git a/README.md b/README.md index 1cfed2960..e62d7203b 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-numeric-cpu # E1 CP make PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0 test-realize ``` -The full omegatool build (`make`) links the `physics` repository at the commit in `physics.lock`. Some older milestone gate scripts rewrite their receipts in place, so do not run them on a clean checkout you mean to keep; prefer the `make test-*` targets above. Targets that touch the GB10 need the DGX Spark, run one at a time, and are never killed mid-run. The M19 clean-clone gate rebuilds the tree in a temporary directory and runs the milestone gates there; when that nested build or nested run fails, it now prints the tail of its own log to stderr, so a failure names its cause instead of reporting a bare FAIL. CI definitions in `.github/workflows/` list the suites that run on every push. +The full omegatool build (`make`) links the `physics` repository at the commit in `physics.lock`. Some older milestone gate scripts rewrite their receipts in place, so do not run them on a clean checkout you mean to keep; prefer the `make test-*` targets above. Some GPU suites build against physics but still open no device: `make test-gpu-decode-graph` checks the decode graph's glue kernels and, on a fake platform, that a failed or abandoned decode token always gives the GPU session lock back (shown on the fake only; the real-chip decode run is `tools/run_gpu_decode_graph_chip.sh`). Targets that touch the GB10 need the DGX Spark, run one at a time, and are never killed mid-run. The M19 clean-clone gate rebuilds the tree in a temporary directory and runs the milestone gates there; when that nested build or nested run fails, it now prints the tail of its own log to stderr, so a failure names its cause instead of reporting a bare FAIL. CI definitions in `.github/workflows/` list the suites that run on every push. ## Repository layout diff --git a/src/.crumb b/src/.crumb index 7c4b83da7..92c97b4e5 100644 --- a/src/.crumb +++ b/src/.crumb @@ -188,14 +188,14 @@ } ], "children_root": "sha256:2f729945214be989a74d7c2064ae4ba3c2deb52ebea3f334b459198a7bd032ed", - "compiled_at": "2026-10-30T02:49:13Z", + "compiled_at": "2026-10-30T17:05:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:aaf5acb82fd4c720cd60c85fd6087f636c72a98e2f3740c9295dcfa525dc64d7", + "digest": "sha256:0078285f63e6b0bc64d04e4e60976e392330c828bbb175004e3e806c2ca3346b", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 568, - "generated_at_commit": "2cb1ccb5d3c1a1ce1cb94a7a3dd3c221395c4e15", - "source_tree": "sha256:7f1fef46a27e8baf5cf567bb590d417ede3767c5f07e714d0f0812af0645bb4b" + "generated_at_commit": "b17b9e1537678b5d1f760cfe66b77c464dcfaafa", + "source_tree": "sha256:896d39bbe878d108d18e58d9379bf86e0c7f743a0fc2732aa42e9811a714e0e2" }, "owner_lane": "", "provenance": { diff --git a/src/omega_gpu_decode_graph.c b/src/omega_gpu_decode_graph.c index bba753564..211a08ec3 100644 --- a/src/omega_gpu_decode_graph.c +++ b/src/omega_gpu_decode_graph.c @@ -242,7 +242,16 @@ static int submit_now(OmegaGpuDecodeGraph *g) { uint64_t tmp[OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 1]; int cnt = omega_gpu_cmdlist_stamps(g->cl, tmp, OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 1); if (cnt < 0) rc = -1; - else { const int from = g->n_stamp == 0 ? 0 : 1; for (int i = from; i < cnt; i++) g->stamp[g->n_stamp++] = tmp[i]; } + else { + const int from = g->n_stamp == 0 ? 0 : 1; + const uint32_t room = (uint32_t)(sizeof g->stamp / sizeof g->stamp[0]) - g->n_stamp; + if (cnt > from && (uint32_t)(cnt - from) > room) { /* more launches this token than the timeline holds */ + omega_gpu_session_set_error("decode graph: timeline full (more launches per token than OMEGA_GPU_CMDLIST_MAX_LAUNCHES)"); + rc = -1; + } else { + for (int i = from; i < cnt; i++) g->stamp[g->n_stamp++] = tmp[i]; + } + } } g->tagged_in_list = 0; omega_gpu_cmdlist_reset(g->cl); @@ -300,6 +309,14 @@ int omega_gpu_decode_graph_record_swiglu(OmegaGpuDecodeGraph *g, uint64_t gu_va, return add_glue(g, OMEGA_GPU_DGRAPH_K_SWIGLU, &g->k[g->mutant == 1 ? K_SW_M1 : K_SW], OMEGA_DEC_INTER / OMEGA_DEC_THREADS, OMEGA_DEC_TOPK, (size_t)OMEGA_DEC_TOPK * OMEGA_DEC_INTER, a, OMEGA_DEC_SW_WORDS); } +/* A failed begin leaves no token behind: list emptied, out of the token, lock released (no end_token owed, omega #518). */ +static int begin_fail(OmegaGpuDecodeGraph *g) { + omega_gpu_cmdlist_reset(g->cl); + g->in_token = 0; g->failed = 1; + omega_gpu_session_unlock(); /* begin_fail releases */ + return OMEGA_GPU_DGRAPH_CHIP_FAIL; +} + int omega_gpu_decode_graph_begin_token(OmegaGpuDecodeGraph *g, const float *x_embed) { if (!g || g->in_token) return OMEGA_GPU_DGRAPH_BAD_ARGS; omega_gpu_session_lock(); @@ -308,11 +325,11 @@ int omega_gpu_decode_graph_begin_token(OmegaGpuDecodeGraph *g, const float *x_em memset(&g->acc, 0, sizeof g->acc); g->n_kind = 0; g->tagged_in_list = 0; g->n_stamp = 0; omega_gpu_cmdlist_reset(g->cl); - if (!omega_gpu_session_open()) return fail(g, NULL, OMEGA_GPU_DGRAPH_CHIP_FAIL); + if (!omega_gpu_session_open()) return begin_fail(g); uint32_t *tok = cpu_of(g, g->lo.token); tok[0] = TOKEN_POISON; tok[1] = TOKEN_POISON; if (x_embed) memcpy(cpu_of(g, g->lo.x), x_embed, OMEGA_GPU_DGRAPH_HIDDEN * 4u); - if (omega_gpu_session_sync_to_gpu(&g->buf) != 0) return fail(g, NULL, OMEGA_GPU_DGRAPH_CHIP_FAIL); + if (omega_gpu_session_sync_to_gpu(&g->buf) != 0) return begin_fail(g); return OMEGA_GPU_DGRAPH_OK; } @@ -389,9 +406,18 @@ int omega_gpu_decode_graph_end_token(OmegaGpuDecodeGraph *g, uint32_t *token, Om return rc; } +int omega_gpu_decode_graph_abort_token(OmegaGpuDecodeGraph *g) { + if (!g || !g->in_token) return OMEGA_GPU_DGRAPH_BAD_ARGS; + omega_gpu_cmdlist_reset(g->cl); + g->in_token = 0; g->tagged_in_list = 0; g->n_stamp = 0; /* no timeline for an abandoned token */ + omega_gpu_session_unlock(); + return OMEGA_GPU_DGRAPH_OK; +} + int omega_gpu_decode_graph_token(OmegaGpuDecodeGraph *g, const float *x_embed, uint32_t pos, uint32_t *token, OmegaGpuDecodeGraphStats *st) { if (!g) return OMEGA_GPU_DGRAPH_BAD_ARGS; - if (omega_gpu_decode_graph_begin_token(g, x_embed) == OMEGA_GPU_DGRAPH_BAD_ARGS) return OMEGA_GPU_DGRAPH_BAD_ARGS; + const int brc = omega_gpu_decode_graph_begin_token(g, x_embed); + if (brc != OMEGA_GPU_DGRAPH_OK) { if (st) memset(st, 0, sizeof *st); return brc; } /* nothing begun, lock free */ for (uint32_t l = 0; l < g->cfg.layers && !g->failed; l++) (void)omega_gpu_decode_graph_record_layer(g, l, pos); if (!g->failed) (void)omega_gpu_decode_graph_record_final(g); return omega_gpu_decode_graph_end_token(g, token, st); @@ -415,7 +441,7 @@ void omega_gpu_decode_graph_set_stamps(OmegaGpuDecodeGraph *g, int on) { if (g & int omega_gpu_decode_graph_stamps(const OmegaGpuDecodeGraph *g, uint64_t *stamps, uint8_t *kinds, uint32_t cap) { if (!g || g->in_token || !stamps || !kinds) return OMEGA_GPU_DGRAPH_BAD_ARGS; - if (!g->stamps || g->n_stamp != g->n_kind + 1u) { omega_gpu_session_set_error("decode graph: no timeline for the last token (stamps off or it failed)"); return OMEGA_GPU_DGRAPH_BAD_ARGS; } + if (!g->stamps || g->failed || g->n_stamp != g->n_kind + 1u) { omega_gpu_session_set_error("decode graph: no timeline for the last token (stamps off or it failed)"); return OMEGA_GPU_DGRAPH_BAD_ARGS; } if (cap < g->n_stamp) { omega_gpu_session_set_error("decode graph: timeline buffers too small"); return OMEGA_GPU_DGRAPH_BAD_ARGS; } memcpy(stamps, g->stamp, (size_t)g->n_stamp * sizeof stamps[0]); memcpy(kinds, g->kind, (size_t)g->n_kind); diff --git a/src/omega_gpu_decode_graph.h b/src/omega_gpu_decode_graph.h index c213585b2..bb8a78b32 100644 --- a/src/omega_gpu_decode_graph.h +++ b/src/omega_gpu_decode_graph.h @@ -46,8 +46,20 @@ * Memory: every buffer is omega_gpu_session_alloc (GPU-uncached; nvos.h:1117 "For system memory this will not be * coherent with direct CPU mappings"): the host writes x before the submit and reads the token / logits after. * - * Threading: begin_token takes omega_gpu_session_lock() and end_token releases it. Between them only record calls - * (this file's and the four APIs' *_record) may run on this thread; a non-record API call would self-deadlock. + * Threading: begin_token takes omega_gpu_session_lock() and end_token (or abort_token) releases it. Between them only + * record calls (this file's and the four APIs' *_record) may run on this thread; a non-record API call would + * self-deadlock. + * Lock and token state after each call (omega #518; tests/test_omega_gpu_decode_graph_abort.c enforces it): + * begin_token OK: lock held, in the token; exactly one end_token or abort_token is owed. + * BAD_ARGS (NULL graph, already in a token): nothing taken, nothing changed. + * CHIP_FAIL (device open refused or latched, x / token visibility sync refused): lock RELEASED, out of + * the token, list empty; nothing owed (end_token and abort_token answer BAD_ARGS). Nothing was + * submitted, so nothing is uncertain; the next begin_token may simply be called again (a latched + * process fails it again at once: the graph never retries on its own). + * record_* lock still held, still in the token, whatever they return; a failure sticks (later records refuse). + * end_token always releases the lock and leaves the token, success or failure. + * abort_token releases the lock and leaves the token without submitting what was recorded. + * token (one-shot) returns with the lock released in every case. * The four APIs refuse a record that would evict a cached kernel: run one plain call per shape (or one token with the * host path) first, or simply record the first token (an empty cache slot is filled, never evicted). * @@ -63,6 +75,7 @@ * int omega_gpu_decode_graph_record_layer(OmegaGpuDecodeGraph *g, uint32_t layer, uint32_t pos); * int omega_gpu_decode_graph_record_final(OmegaGpuDecodeGraph *g); * int omega_gpu_decode_graph_end_token(OmegaGpuDecodeGraph *g, uint32_t *token, OmegaGpuDecodeGraphStats *st); + * int omega_gpu_decode_graph_abort_token(OmegaGpuDecodeGraph *g); * int omega_gpu_decode_graph_record_res(OmegaGpuDecodeGraph *g, uint32_t mode, uint64_t x_va, uint64_t a_va, uint64_t w_va, * uint64_t nw_va, uint64_t y_va, float eps, float scale); * int omega_gpu_decode_graph_record_swiglu(OmegaGpuDecodeGraph *g, uint64_t gu_va, uint64_t act_va, float scale); @@ -142,7 +155,8 @@ int omega_gpu_decode_graph_set_final_norm(OmegaGpuDecodeGraph *g, const float *f /* One whole token: x_embed (f32 [2048], the token's embedding row) -> greedy token. pos: the token's position. */ int omega_gpu_decode_graph_token(OmegaGpuDecodeGraph *g, const float *x_embed, uint32_t pos, uint32_t *token, OmegaGpuDecodeGraphStats *st); -/* The same in steps. begin_token takes the session lock, empties the list and (x_embed non-NULL) writes x. */ +/* The same in steps. begin_token takes the session lock, empties the list and (x_embed non-NULL) writes x. On + * CHIP_FAIL it has already released the lock and left the token (see Threading above): do not call end_token. */ int omega_gpu_decode_graph_begin_token(OmegaGpuDecodeGraph *g, const float *x_embed); int omega_gpu_decode_graph_record_layer(OmegaGpuDecodeGraph *g, uint32_t layer, uint32_t pos); int omega_gpu_decode_graph_record_final(OmegaGpuDecodeGraph *g); @@ -150,6 +164,10 @@ int omega_gpu_decode_graph_record_final(OmegaGpuDecodeGraph *g); * submit), reads the token (may be NULL), releases the lock. Always releases the lock, also after an earlier failed * record (then returns that failure without submitting). */ int omega_gpu_decode_graph_end_token(OmegaGpuDecodeGraph *g, uint32_t *token, OmegaGpuDecodeGraphStats *st); +/* Abandons a begun token: drops the recorded launches WITHOUT submitting them, leaves the token, releases the lock. + * OK, or BAD_ARGS when no token is begun. Nothing reaches the device, so nothing is uncertain; launches flush_each + * already submitted stay done. The device x keeps what begin_token wrote; the timeline is cleared. */ +int omega_gpu_decode_graph_abort_token(OmegaGpuDecodeGraph *g); /* Glue records (between begin and end): RES (omega_blackwell_codegen_dec.h modes ADD / COMBINE / NORM) and SWIGLU. */ int omega_gpu_decode_graph_record_res(OmegaGpuDecodeGraph *g, uint32_t mode, uint64_t x_va, uint64_t a_va, uint64_t w_va, diff --git a/src/omega_gpu_fp8_api.c b/src/omega_gpu_fp8_api.c index d642cc519..8e366b42e 100644 --- a/src/omega_gpu_fp8_api.c +++ b/src/omega_gpu_fp8_api.c @@ -109,7 +109,7 @@ void omega_gpu_fp8_set_depth(int set, uint32_t depth) { omega_gpu_session_lock() void omega_gpu_fp8_set_gpr_pad(uint32_t pad) { omega_gpu_session_lock(); g.gpr_pad = pad; omega_gpu_session_unlock(); } void omega_gpu_fp8_set_cta_budget(uint32_t ctas) { omega_gpu_session_lock(); g.cta_budget_set = ctas != 0; g.cta_budget = ctas ? ctas : OMEGA_GPU_FP8_MAX_CTAS; cache_clear_locked(); omega_gpu_session_unlock(); } void omega_gpu_fp8_test_set_mutant(int m) { omega_gpu_session_lock(); g.mutant = m; cache_clear_locked(); omega_gpu_session_unlock(); } -void omega_gpu_fp8_test_set_no_fold(int on) { g.no_fold = on ? 1 : 0; } +void omega_gpu_fp8_test_set_no_fold(int on) { omega_gpu_session_lock(); g.no_fold = on ? 1 : 0; omega_gpu_session_unlock(); } void omega_gpu_fp8_seal(int on) { omega_gpu_session_lock(); g.sealed = on ? 1 : 0; omega_gpu_session_unlock(); } /* ---- GEMV variant (W-L2c): 1 = omega_blackwell_codegen_moe.c (default), 2 = omega_blackwell_codegen_moe2.c (row-pipelined) ---- */ @@ -357,12 +357,15 @@ int omega_gpu_fp8_tensor_upload(uint32_t experts, uint32_t n, uint32_t k, const if (!g.weights_cached_set) { const char *v = getenv("AIEN_OMEGA_FP8_WEIGHT_CACHE"); g.weights_cached = (v && v[0] == '1' && v[1] == 0) ? 1 : 0; g.weights_cached_set = 1; } int (*const alloc)(size_t, OmegaGpuMem *) = g.weights_cached ? omega_gpu_session_alloc_cached : omega_gpu_session_alloc; if (!dev_open_locked() || alloc(wbytes, &t->w) != 0 || alloc(scount * 4u, &t->s) != 0) rc = OMEGA_GPU_FP8_CHIP_FAIL; - omega_gpu_session_unlock(); + /* Fill and sync under the lock (omega#456): t is not shared yet, but its CPU views belong to the open device, and a + * device close on another thread between unlock and memcpy would unmap them; sync_to_gpu also reads the open state. + * g.no_fold is read under the lock, as its setter now writes it. The cost is holding the lock for one weight copy. */ if (rc == OMEGA_GPU_FP8_OK) { memcpy(t->w.cpu, w, wbytes); if (omega_fp8_pack_scales(scale, scount, t->s.cpu, g.no_fold) != 0) { omega_gpu_session_set_error("fp8 upload: NaN, inf or overflowing scale"); rc = OMEGA_GPU_FP8_BAD_ARGS; } else if (omega_gpu_session_sync_to_gpu(&t->w) != 0 || omega_gpu_session_sync_to_gpu(&t->s) != 0) rc = OMEGA_GPU_FP8_CHIP_FAIL; } + omega_gpu_session_unlock(); if (rc != OMEGA_GPU_FP8_OK) { omega_gpu_fp8_tensor_free(t); return rc; } *out = t; return OMEGA_GPU_FP8_OK; diff --git a/tests/.crumb b/tests/.crumb index 5fbfcb29c..c3eeb94bf 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -302,14 +302,14 @@ } ], "children_root": "sha256:0c57282ff8cf1d34e5685e2729755f2978917e66debb5423961033be9d25c902", - "compiled_at": "2026-10-30T12:31:50Z", + "compiled_at": "2026-10-30T17:05:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:5395ff8ff9afceebe8e453788f80a3064b831513cc4cb92fd55869115e06b874", + "digest": "sha256:d059ad151044edc5dee7abd73930b38bf547288c21d9bca46d2b25a09558111e", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", - "files": 1386, - "generated_at_commit": "52a82f392fa513ebbc2d9d719a0f14c385289b06", - "source_tree": "sha256:a3b853bb9c0edfc5f1413ccaa2698cc6ea920f2e8795756121667cc9d37f6679" + "files": 1389, + "generated_at_commit": "b17b9e1537678b5d1f760cfe66b77c464dcfaafa", + "source_tree": "sha256:ed9119bb837bc0e711dad2b0bd1255131aaa45ac6e433f0b17b3044f3f4e6d61" }, "owner_lane": "", "provenance": { diff --git a/tests/gates/omega-gpu-decode-graph.gate b/tests/gates/omega-gpu-decode-graph.gate new file mode 100644 index 000000000..2eed6c402 --- /dev/null +++ b/tests/gates/omega-gpu-decode-graph.gate @@ -0,0 +1,24 @@ +# tests/gates/omega-gpu-decode-graph.gate +# Host-only decode-graph suite (omega #518): make test-gpu-decode-graph (decode graph test, abort/lock-recovery test, 5 mutants). No device. +gate: OMEGA-GPU-DECODE-GRAPH +manifest_version: 2 +owner: omega +requires: + - host +inputs: + - Makefile + - mk/ + - src/ + - tests/ + - tools/ + - physics.lock + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["gpu-decode-graph"] +expects: + exit: 0 + verdict: PASS +timeout: 20m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/run.sh b/tests/gates/run.sh index 66da8e1a9..89d7226df 100755 --- a/tests/gates/run.sh +++ b/tests/gates/run.sh @@ -169,6 +169,7 @@ case "$step" in ;; numeric2) make $NOPHYS test-numeric-reduce-cpu test-divsqrt-host ;; tensor) make $NOPHYS test-tensor; make $NOPHYS test-tensor-store; make $NOPHYS test-m20-receipt; make $NOPHYS test-tensor-mutations ;; + gpu-decode-graph) physics_pin; make test-gpu-decode-graph ;; # host-suites-3.yml numeric-lifecycle) make $NOPHYS test-numeric-lifecycle ;; numeric-transc-digest) diff --git a/tests/gpu_fp8gemm_test.c b/tests/gpu_fp8gemm_test.c index 1a9669f47..4e8a46dfa 100644 --- a/tests/gpu_fp8gemm_test.c +++ b/tests/gpu_fp8gemm_test.c @@ -63,7 +63,10 @@ static void weights_free(Weights *W) { free(W->w); free(W->s); } * bytes (word, byte), acc = fma(dot, S', acc), then the SHFL.DOWN tree 16..1. w: the row's k bytes, s: its k/128 scale words * (bf16 bits of one 128-row block), x: natural-order activation row. */ static float emu_row(const uint8_t *w, const uint16_t *s, const float *x, uint32_t k, uint32_t lb) { - float xp[16384]; omega_fp8_pack_x_f32(x, k, xp); + /* static, not 64 KB of stack (omega#456); this test runs one thread. k is bounded by OMEGA_FP8_MAX_K (16384). */ + static float xp[16384]; + if (k > sizeof xp / sizeof xp[0]) { fprintf(stderr, "emu_row: k=%u exceeds %zu\n", k, sizeof xp / sizeof xp[0]); exit(2); } + omega_fp8_pack_x_f32(x, k, xp); float a[32]; const uint32_t steps = k / (32u * lb); for (unsigned lane = 0; lane < 32; lane++) { float acc = 0.0f; diff --git a/tests/test_omega_gpu_decode_graph_abort.c b/tests/test_omega_gpu_decode_graph_abort.c new file mode 100644 index 000000000..4fc8f07fd --- /dev/null +++ b/tests/test_omega_gpu_decode_graph_abort.c @@ -0,0 +1,440 @@ +/* test_omega_gpu_decode_graph_abort: lock and token-state recovery of the decode graph's split API (omega #518) on a + * FAKE OmegaGpuPlatform. Host program, links libomega_gpu.a with the fake installed first; opens no device, touches + * no GPU. + * + * The fake's session lock REFUSES a second acquisition while held (counted in fk.double_locks) instead of blocking, + * so a lock left held by a failed call shows up as a count, not a hung test. The fake device never runs a kernel: a + * submitted list's markers never land (the cmdlist times out on the fake clock), and the graph's token slot is written + * by the "device" at the gpu->cpu sync only when a case arms fk.dev_token (a token the device produced). + * + * Contract under test (omega_gpu_decode_graph.h): a failed begin_token returns with the session lock released and the + * graph out of the token (no end_token owed); abort_token drops a begun token without submitting anything; end_token + * after a failed record submits nothing and releases the lock; an uncertain completion latches the process and every + * later begin fails without a retry or a submission. After each failure: set_final_norm, read, free and the next + * valid token neither deadlock nor see a stale token state. + * + * Each case runs in its own child process (a latch lasts for the life of the process). + */ +#include "omega_gpu_decode_graph.h" +#include "omega_gpu_session.h" +#include "omega_gpu_platform.h" +#include "omega_blackwell_codegen_dec.h" + +#include +#include +#include +#include +#include + +static int case_ok; +#define EXPECT(c) do { if (!(c)) { case_ok = 0; printf(" expect failed at line %d: %s\n", __LINE__, #c); } } while (0) + +/* ---- the fake platform ---- */ +#define NB OMEGA_GPU_HANDLE_SLOTS +#define VA_BASE 0x100000000ull +#define VA_STRIDE 0x1000000ull +static struct { + OmegaGpuHandleTable t; + void *mem[NB]; + OmegaGpuBufferDesc desc[NB]; + OmegaGpuDeviceHandle dev; + OmegaGpuQueueHandle q; + OmegaGpuBufferHandle ring; + uint64_t ns; + unsigned locks_held, double_locks, bad_unlocks; + unsigned submits, dev_opens; + int fail_open, fail_c2g; /* refuse device open / every cpu->gpu visibility sync */ + uint64_t dev_token_va; /* nonzero: the device wrote dev_token there (seen at the gpu->cpu sync) */ + uint32_t dev_token; +} fk; + +static uint64_t f_now_ns(void *c) { (void)c; fk.ns += 1000u; return fk.ns; } +static uint64_t f_now_ms(void *c) { return f_now_ns(c) / 1000000u; } +static int f_wait(void *c, uint64_t ms) { (void)c; fk.ns += ms * 1000000u; return 0; } +static int f_lock(void *c, uint32_t id) { + (void)c; + if (id != OMEGA_GPU_SESSION_LOCK_ID) return OMEGA_GPU_PLAT_REFUSED_ARGS; + if (fk.locks_held) { fk.double_locks++; return OMEGA_GPU_PLAT_REFUSED_BUSY; } /* a real lock would block here forever */ + fk.locks_held = 1; + return 0; +} +static int f_unlock(void *c, uint32_t id) { + (void)c; + if (id != OMEGA_GPU_SESSION_LOCK_ID || !fk.locks_held) { fk.bad_unlocks++; return OMEGA_GPU_PLAT_REFUSED_ARGS; } + fk.locks_held = 0; + return 0; +} +static const char *f_diag(void *c) { (void)c; return fk.fail_open ? "fake device: open refused" : ""; } + +static int f_dev_open(void *c, uint32_t ord, OmegaGpuDeviceHandle *out) { + (void)c; + if (fk.fail_open) return OMEGA_GPU_PLAT_REFUSED_DEVICE; + if (ord != 0 || fk.dev.generation) return OMEGA_GPU_PLAT_REFUSED_LIMIT; + int rc = omega_gpu_handles_open(&fk.t, OMEGA_GPU_HANDLE_DEVICE, 0, 1, 0, &out->index, &out->generation); + if (rc == 0) { fk.dev = *out; fk.dev_opens++; } + return rc; +} +static int f_dev_close(void *c, OmegaGpuDeviceHandle d) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + if (rc) return rc; + /* every handle of the device goes stale; the host memory stays mapped (leaked) so a graph that outlives the device + * writes into its own stale buffer, not freed memory: this test checks the lock, not use after close */ + for (uint32_t i = 0; i < NB; i++) + if (fk.t.live[i] && i != d.index) { (void)omega_gpu_handles_close(&fk.t, i, fk.t.generation[i], fk.t.kind[i]); fk.mem[i] = NULL; } + (void)omega_gpu_handles_close(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + memset(&fk.dev, 0, sizeof fk.dev); memset(&fk.q, 0, sizeof fk.q); + return 0; +} + +static OmegaGpuPlatformCaps g_caps = { + .abi_major = OMEGA_GPU_PLATFORM_ABI_MAJOR, .abi_minor = OMEGA_GPU_PLATFORM_ABI_MINOR, + .services = OMEGA_GPU_SVC_REQUIRED_SESSION, .max_devices = 1, .max_buffers = 1000, .max_queues = 1, .max_inflight = 1, + .max_buffer_bytes = 1ull << 30, .max_total_bytes = 1ull << 32, +}; + +static int f_alloc(void *c, OmegaGpuDeviceHandle d, const OmegaGpuBufferDesc *desc, OmegaGpuBufferHandle *o, + OmegaCpuView *cpu, OmegaGpuVa *g, OmegaGpuBusAddr *b) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + if (!rc) rc = omega_gpu_platform_check_buffer(desc, &g_caps); + if (!rc) rc = omega_gpu_handles_open(&fk.t, desc->kind, desc->bytes, 1000, 1ull << 32, &o->index, &o->generation); + if (rc) return rc; + void *m = calloc(1, desc->bytes); + if (!m) { (void)omega_gpu_handles_close(&fk.t, o->index, o->generation, desc->kind); return OMEGA_GPU_PLAT_REFUSED_LIMIT; } + fk.mem[o->index] = m; fk.desc[o->index] = *desc; + cpu->ptr = m; cpu->len = desc->bytes; g->va = VA_BASE + (uint64_t)o->index * VA_STRIDE; b->iova = 0; + return 0; +} +static int f_free(void *c, OmegaGpuBufferHandle h) { + (void)c; + if (h.index >= NB) return OMEGA_GPU_PLAT_REFUSED_BAD_HANDLE; + int rc = omega_gpu_handles_close(&fk.t, h.index, h.generation, fk.t.kind[h.index]); + if (rc) return rc; + free(fk.mem[h.index]); fk.mem[h.index] = NULL; + return 0; +} +static int buf_live(OmegaGpuBufferHandle h) { return h.index < NB && fk.t.live[h.index] && fk.t.generation[h.index] == h.generation; } +static void *va_to_cpu(uint64_t va) { + for (uint32_t i = 0; i < NB; i++) { + if (!fk.mem[i] || !fk.t.live[i]) continue; + const uint64_t base = VA_BASE + (uint64_t)i * VA_STRIDE; + if (va >= base && va < base + fk.desc[i].bytes) return (uint8_t *)fk.mem[i] + (va - base); + } + return NULL; +} +static int sync_check(OmegaGpuBufferHandle h, uint64_t off, uint64_t len) { + if (!buf_live(h)) return OMEGA_GPU_PLAT_REFUSED_STALE_HANDLE; + if (len == 0 || off > fk.desc[h.index].bytes || len > fk.desc[h.index].bytes - off) return OMEGA_GPU_PLAT_REFUSED_BAD_LENGTH; + return 0; +} +static int f_c2g(void *c, OmegaGpuBufferHandle h, uint64_t off, uint64_t len) { + (void)c; + if (fk.fail_c2g) return OMEGA_GPU_PLAT_REFUSED_DEVICE; + return sync_check(h, off, len); +} +static int f_g2c(void *c, OmegaGpuBufferHandle h, uint64_t off, uint64_t len) { + (void)c; + int rc = sync_check(h, off, len); + if (rc == 0 && fk.dev_token_va) { uint32_t *t = va_to_cpu(fk.dev_token_va); if (t) t[0] = fk.dev_token; } + return rc; +} +static int f_poll(void *c, OmegaGpuBufferHandle h, uint64_t off, uint32_t want, uint64_t ms, uint32_t *seen) { + (void)c; + if (!buf_live(h)) return OMEGA_GPU_PLAT_REFUSED_STALE_HANDLE; + if (!(fk.desc[h.index].rights & OMEGA_GPU_RIGHT_HOST_POLLED)) return OMEGA_GPU_PLAT_REFUSED_BAD_RIGHTS; + const volatile uint32_t *w = (const volatile uint32_t *)((uint8_t *)fk.mem[h.index] + off); + *seen = *w; + if ((int32_t)(*w - want) >= 0) return 0; + fk.ns += ms * 1000000u; + return OMEGA_GPU_POLL_TIMED_OUT; +} +static int f_qopen(void *c, OmegaGpuDeviceHandle d, OmegaGpuBufferHandle ring, OmegaGpuQueueHandle *o) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + if (!rc && (!buf_live(ring) || fk.t.kind[ring.index] != OMEGA_GPU_HANDLE_BUF_QUEUE)) rc = OMEGA_GPU_PLAT_REFUSED_BAD_KIND; + if (!rc) rc = omega_gpu_handles_open(&fk.t, OMEGA_GPU_HANDLE_QUEUE, 0, 1, 0, &o->index, &o->generation); + if (!rc) { fk.q = *o; fk.ring = ring; } + return rc; +} +static int f_qclose(void *c, OmegaGpuQueueHandle q) { + (void)c; + int rc = omega_gpu_handles_close(&fk.t, q.index, q.generation, OMEGA_GPU_HANDLE_QUEUE); + if (!rc) memset(&fk.q, 0, sizeof fk.q); + return rc; +} +/* The fake device accepts the words and runs nothing: no marker, semaphore or output ever lands. */ +static int f_submit(void *c, OmegaGpuQueueHandle q, const uint32_t *w, uint32_t n) { + (void)c; (void)w; + int rc = omega_gpu_handles_check(&fk.t, q.index, q.generation, OMEGA_GPU_HANDLE_QUEUE); + if (rc) return rc; + if ((uint64_t)n * 4u > fk.desc[fk.ring.index].bytes) return OMEGA_GPU_PLAT_REFUSED_BAD_LENGTH; + fk.submits++; + return 0; +} +static int f_retire(void *c, OmegaGpuQueueHandle q) { (void)c; (void)q; return 0; } +static void *f_halloc(void *c, size_t b) { (void)c; return malloc(b); } +static void f_hfree(void *c, void *p) { (void)c; free(p); } + +static OmegaGpuPlatform g_plat = { + .ctx = &fk, .time_now_ms = f_now_ms, .wait_ms = f_wait, .lock = f_lock, .unlock = f_unlock, + .dma_alloc = f_alloc, .dma_free = f_free, .sync_cpu_to_gpu = f_c2g, .sync_gpu_to_cpu = f_g2c, .poll_word = f_poll, + .device_open = f_dev_open, .device_close = f_dev_close, .diag_text = f_diag, + .queue_open = f_qopen, .queue_close = f_qclose, .queue_submit = f_submit, .queue_retire = f_retire, + .time_now_ns = f_now_ns, .host_alloc = f_halloc, .host_free = f_hfree, +}; + +/* ---- a one-layer graph on the fake ---- */ +#define LAYERS 1u +#define VOCAB 256u +#define MAX_POS 256u +typedef struct { + OmegaGpuDecodeAttnCache *attn; + OmegaGpuRouter *router; + OmegaGpuBf16Tensor *lm; + OmegaGpuDecodeGraph *g; +} World; + +static int world_build(World *w) { + memset(w, 0, sizeof *w); + static uint16_t lm_w[VOCAB * OMEGA_GPU_DGRAPH_HIDDEN]; /* zeros: finite bf16 */ + if (omega_gpu_decode_attn_cache_alloc(LAYERS, MAX_POS, 1e6, &w->attn) != 0) return -1; + if (omega_gpu_router_alloc(LAYERS, &w->router) != 0) return -1; + if (omega_gpu_bf16_tensor_upload(VOCAB, OMEGA_GPU_DGRAPH_HIDDEN, lm_w, &w->lm) != 0) return -1; + OmegaGpuDecodeGraphConfig cfg; memset(&cfg, 0, sizeof cfg); + cfg.layers = LAYERS; cfg.vocab = VOCAB; cfg.eps = 1e-6f; cfg.norm_topk = 1; + cfg.router = w->router; cfg.attn = w->attn; cfg.lm_head = w->lm; + return omega_gpu_decode_graph_create(&cfg, &w->g) == OMEGA_GPU_DGRAPH_OK ? 0 : -1; +} +static void world_free(World *w) { + omega_gpu_decode_graph_free(w->g); + omega_gpu_bf16_tensor_free(w->lm); + omega_gpu_router_free(w->router); + omega_gpu_decode_attn_cache_free(w->attn); + memset(w, 0, sizeof *w); +} + +static float g_x[OMEGA_GPU_DGRAPH_HIDDEN], g_norm[OMEGA_GPU_DGRAPH_HIDDEN]; + +/* The postcondition of every failed or finished call: lock free, never taken twice, never released twice. */ +#define EXPECT_LOCK_FREE() do { EXPECT(fk.locks_held == 0); EXPECT(fk.double_locks == 0); EXPECT(fk.bad_unlocks == 0); } while (0) + +/* Not in a token any more: the between-token calls run (BAD_ARGS here would mean in_token stuck). */ +static void expect_between_tokens(World *w) { + EXPECT(omega_gpu_decode_graph_set_final_norm(w->g, g_norm) == OMEGA_GPU_DGRAPH_OK); + EXPECT_LOCK_FREE(); + float x[OMEGA_GPU_DGRAPH_HIDDEN]; + EXPECT(omega_gpu_decode_graph_read(w->g, x, NULL, NULL) == OMEGA_GPU_DGRAPH_OK); + EXPECT_LOCK_FREE(); +} + +/* A valid split-API token: begin, nothing recorded, end; the fake device "wrote" the token. */ +static void expect_valid_token(World *w, uint32_t want) { + OmegaGpuDecodeGraphVas v; omega_gpu_decode_graph_vas(w->g, &v); + fk.dev_token_va = v.token; fk.dev_token = want; + const unsigned submits = fk.submits; + EXPECT(omega_gpu_decode_graph_begin_token(w->g, g_x) == OMEGA_GPU_DGRAPH_OK); + EXPECT(fk.locks_held == 1); + uint32_t tok = 0xdeadu; + OmegaGpuDecodeGraphStats st; memset(&st, 0xff, sizeof st); + EXPECT(omega_gpu_decode_graph_end_token(w->g, &tok, &st) == OMEGA_GPU_DGRAPH_OK); + EXPECT(tok == want && st.launches == 0 && st.submits == 0); + EXPECT(fk.submits == submits); /* an empty list submits nothing */ + EXPECT_LOCK_FREE(); + fk.dev_token_va = 0; +} + +static int install(void) { + memset(&fk, 0, sizeof fk); omega_gpu_handles_init(&fk.t); + for (unsigned i = 0; i < OMEGA_GPU_DGRAPH_HIDDEN; i++) { g_x[i] = (float)(i % 7) - 3.0f; g_norm[i] = 1.0f; } + return omega_gpu_session_set_platform(&g_plat, &g_caps); +} + +/* Visibility sync (cpu->gpu of x and the poisoned token) refused: split and one-shot paths, repeated, then recovery. */ +static void c_sync_fails(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } /* never fall back to the real driver */ + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + EXPECT_LOCK_FREE(); + const unsigned submits = fk.submits; + fk.fail_c2g = 1; + for (int rep = 0; rep < 3; rep++) { /* same outcome every time */ + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT_LOCK_FREE(); + } + /* nothing owed after a failed begin: end and abort see no token */ + uint32_t tok = 7; + EXPECT(omega_gpu_decode_graph_end_token(w.g, &tok, NULL) == OMEGA_GPU_DGRAPH_BAD_ARGS && tok == 7); + EXPECT(omega_gpu_decode_graph_abort_token(w.g) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT(omega_gpu_decode_graph_record_final(w.g) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT_LOCK_FREE(); + /* one-shot: the begin failure comes back as CHIP_FAIL with zeroed stats, lock free */ + OmegaGpuDecodeGraphStats st; memset(&st, 0xff, sizeof st); + tok = 7; + EXPECT(omega_gpu_decode_graph_token(w.g, g_x, 0, &tok, &st) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT(tok == 7 && st.launches == 0 && st.submits == 0 && st.total_ns == 0); + EXPECT_LOCK_FREE(); + EXPECT(fk.submits == submits); /* nothing reached the device, nothing retried */ + EXPECT(!omega_gpu_session_is_blocked()); + fk.fail_c2g = 0; + expect_between_tokens(&w); + expect_valid_token(&w, 42u); + expect_valid_token(&w, 43u); /* and again */ + world_free(&w); + EXPECT_LOCK_FREE(); +} + +/* Device open refused: the session was closed (every handle stale), the reopen in begin_token fails. */ +static void c_open_fails(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } /* never fall back to the real driver */ + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + omega_gpu_session_close(); + EXPECT_LOCK_FREE(); + fk.fail_open = 1; + for (int rep = 0; rep < 3; rep++) { + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT_LOCK_FREE(); + } + EXPECT(omega_gpu_decode_graph_token(w.g, g_x, 0, NULL, NULL) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT_LOCK_FREE(); + EXPECT(omega_gpu_decode_graph_end_token(w.g, NULL, NULL) == OMEGA_GPU_DGRAPH_BAD_ARGS); + /* the graph's buffers belong to the closed device: set_final_norm and read reach the stale sync and refuse (not + * BAD_ARGS: the graph is out of the token), nothing hangs */ + EXPECT(omega_gpu_decode_graph_set_final_norm(w.g, g_norm) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT(omega_gpu_decode_graph_read(w.g, NULL, NULL, NULL) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT_LOCK_FREE(); + fk.fail_open = 0; + /* reopen succeeds; the old graph's buffer is stale, so its begin fails at the visibility sync, lock free */ + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT_LOCK_FREE(); + world_free(&w); + EXPECT_LOCK_FREE(); + /* a fresh graph on the reopened device runs a valid token */ + if (world_build(&w) != 0) { EXPECT(!"world rebuilds after the reopen"); return; } + expect_valid_token(&w, 5u); + world_free(&w); + EXPECT_LOCK_FREE(); +} + +/* The caller abandons a begun token (cancellation): nothing submitted, lock released, the next token runs. */ +static void c_abort(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } /* never fall back to the real driver */ + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + OmegaGpuDecodeGraphVas v; omega_gpu_decode_graph_vas(w.g, &v); + const unsigned submits = fk.submits; + /* abort after a recorded launch */ + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_OK); + EXPECT(omega_gpu_decode_graph_record_res(w.g, OMEGA_DEC_RES_NORM, v.x, 0, 0, v.x, v.xq, 1e-6f, 1.0f) == OMEGA_GPU_DGRAPH_OK); + EXPECT(omega_gpu_decode_graph_abort_token(w.g) == OMEGA_GPU_DGRAPH_OK); + EXPECT_LOCK_FREE(); + EXPECT(fk.submits == submits); + EXPECT(omega_gpu_decode_graph_abort_token(w.g) == OMEGA_GPU_DGRAPH_BAD_ARGS); /* only once */ + EXPECT(omega_gpu_decode_graph_end_token(w.g, NULL, NULL) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT_LOCK_FREE(); + /* abort after a failed record */ + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_OK); + EXPECT(omega_gpu_decode_graph_record_res(w.g, 0xffu, v.x, 0, 0, 0, v.xq, 1e-6f, 1.0f) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT(omega_gpu_decode_graph_abort_token(w.g) == OMEGA_GPU_DGRAPH_OK); + EXPECT_LOCK_FREE(); + EXPECT(fk.submits == submits); + /* abort with nothing begun */ + EXPECT(omega_gpu_decode_graph_abort_token(NULL) == OMEGA_GPU_DGRAPH_BAD_ARGS); + expect_between_tokens(&w); + expect_valid_token(&w, 9u); + world_free(&w); + EXPECT_LOCK_FREE(); +} + +/* end_token after a failed record: no submit, the failure returned, lock released, the next token runs. */ +static void c_end_after_record_fail(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } /* never fall back to the real driver */ + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + OmegaGpuDecodeGraphVas v; omega_gpu_decode_graph_vas(w.g, &v); + const unsigned submits = fk.submits; + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_OK); + EXPECT(omega_gpu_decode_graph_record_res(w.g, OMEGA_DEC_RES_NORM, v.x, 0, 0, v.x, v.xq, 1e-6f, 1.0f) == OMEGA_GPU_DGRAPH_OK); + EXPECT(omega_gpu_decode_graph_record_layer(w.g, 0, 0) == OMEGA_GPU_DGRAPH_BAD_ARGS); /* layer 0 never set */ + EXPECT(omega_gpu_decode_graph_record_final(w.g) == OMEGA_GPU_DGRAPH_CHIP_FAIL); /* failed sticks */ + uint32_t tok = 7; + EXPECT(omega_gpu_decode_graph_end_token(w.g, &tok, NULL) == OMEGA_GPU_DGRAPH_CHIP_FAIL && tok == 7); + EXPECT(fk.submits == submits); + EXPECT_LOCK_FREE(); + /* one-shot with an unset layer: the same, deterministically */ + for (int rep = 0; rep < 2; rep++) { + EXPECT(omega_gpu_decode_graph_token(w.g, g_x, 0, &tok, NULL) == OMEGA_GPU_DGRAPH_CHIP_FAIL && tok == 7); + EXPECT(fk.submits == submits); + EXPECT_LOCK_FREE(); + } + expect_between_tokens(&w); + expect_valid_token(&w, 11u); + world_free(&w); + EXPECT_LOCK_FREE(); +} + +/* An uncertain completion: the submitted list never completes, the process latches. end_token reports the failure (never + * a token); every later begin fails at once with the lock released, submits nothing and retries nothing. */ +static void c_latched(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } /* never fall back to the real driver */ + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + OmegaGpuDecodeGraphVas v; omega_gpu_decode_graph_vas(w.g, &v); + fk.dev_token_va = v.token; fk.dev_token = 3u; /* even a token in the slot must not be claimed after a timeout */ + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_OK); + EXPECT(omega_gpu_decode_graph_record_res(w.g, OMEGA_DEC_RES_NORM, v.x, 0, 0, v.x, v.xq, 1e-6f, 1.0f) == OMEGA_GPU_DGRAPH_OK); + uint32_t tok = 7; + EXPECT(omega_gpu_decode_graph_end_token(w.g, &tok, NULL) == OMEGA_GPU_DGRAPH_CHIP_FAIL && tok == 7); + EXPECT(fk.submits >= 1); + EXPECT(omega_gpu_session_is_blocked()); + EXPECT_LOCK_FREE(); + const unsigned submits = fk.submits, opens = fk.dev_opens; + for (int rep = 0; rep < 3; rep++) { + EXPECT(omega_gpu_decode_graph_begin_token(w.g, g_x) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT_LOCK_FREE(); + EXPECT(omega_gpu_decode_graph_token(w.g, g_x, 0, &tok, NULL) == OMEGA_GPU_DGRAPH_CHIP_FAIL && tok == 7); + EXPECT_LOCK_FREE(); + } + EXPECT(fk.submits == submits && fk.dev_opens == opens); /* no retry, no reopen */ + EXPECT(omega_gpu_decode_graph_end_token(w.g, NULL, NULL) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT(omega_gpu_decode_graph_abort_token(w.g) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT(omega_gpu_decode_graph_set_final_norm(w.g, g_norm) == OMEGA_GPU_DGRAPH_OK); + (void)omega_gpu_decode_graph_read(w.g, NULL, NULL, NULL); /* latched: refused or parked, but it returns */ + EXPECT_LOCK_FREE(); + world_free(&w); + EXPECT_LOCK_FREE(); + EXPECT(omega_gpu_session_is_blocked()); +} + +typedef struct { const char *name; void (*fn)(void); } Case; +static const Case CASES[] = { + { "visibility sync refused at begin: split + one-shot recover", c_sync_fails }, + { "device open refused at begin: lock free, reopen recovers", c_open_fails }, + { "abort_token: cancel a begun token, nothing submitted", c_abort }, + { "end_token after a failed record: no submit, lock free", c_end_after_record_fail }, + { "latched session: begin fails at once, no retry", c_latched }, +}; + +int main(int argc, char **argv) { + const unsigned n = sizeof CASES / sizeof CASES[0]; + if (argc == 2) { /* one case in this process (debugging): its index */ + const unsigned i = (unsigned)atoi(argv[1]); + if (i >= n) return 2; + case_ok = 1; CASES[i].fn(); + printf("%s %s\n", case_ok ? "ok " : "FAIL", CASES[i].name); + return case_ok ? 0 : 1; + } + unsigned failed = 0; + for (unsigned i = 0; i < n; i++) { + fflush(stdout); + pid_t pid = fork(); + if (pid == 0) { case_ok = 1; CASES[i].fn(); fflush(stdout); _exit(case_ok ? 0 : 1); } + int status = 0; + int ok = pid > 0 && waitpid(pid, &status, 0) == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0; + printf("%s %s\n", ok ? "ok " : "FAIL", CASES[i].name); + if (!ok) failed++; + } + printf("test_omega_gpu_decode_graph_abort: %u of %u cases passed: %s\n", n - failed, n, failed ? "FAIL" : "PASS"); + return failed ? 1 : 0; +} diff --git a/tests/test_omega_gpu_decode_graph_timeline.c b/tests/test_omega_gpu_decode_graph_timeline.c new file mode 100644 index 000000000..619eac986 --- /dev/null +++ b/tests/test_omega_gpu_decode_graph_timeline.c @@ -0,0 +1,302 @@ +/* test_omega_gpu_decode_graph_timeline: the decode graph's per-token timeline never writes past stamp[] (omega #456). + * Host program on a FAKE OmegaGpuPlatform that completes every submission (markers, launch semaphores, stamp reports); + * links libomega_gpu.a with the fake installed first; opens no device, touches no GPU. + * + * The timeline holds OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 1 stamps. Batched, a token's list never holds more launches than + * that. With flush_each (one submission per launch) the list is emptied after every launch, so nothing in the command + * list bounds the number of launches a token records: before #456 the 4097th stamped launch wrote stamp[4097], past the + * end of the graph. Contract under test: 4096 launches fill the timeline exactly (stamps() returns 4096); one more fails + * the token (CHIP_FAIL, timeline refused, lock released) and the next token runs normally. + * + * Each case runs in its own child process. + */ +#include "omega_gpu_decode_graph.h" +#include "omega_gpu_session.h" +#include "omega_gpu_platform.h" +#include "omega_gpu_cmdlist.h" +#include "omega_blackwell_submit.h" + +#include +#include +#include +#include +#include + +static int case_ok; +#define EXPECT(c) do { if (!(c)) { case_ok = 0; printf(" expect failed at line %d: %s\n", __LINE__, #c); } } while (0) + +/* ---- the fake platform: every submitted word stream "runs" ---- */ +#define NB OMEGA_GPU_HANDLE_SLOTS +#define VA_BASE 0x100000000ull +#define VA_STRIDE 0x1000000ull +static struct { + OmegaGpuHandleTable t; + void *mem[NB]; + OmegaGpuBufferDesc desc[NB]; + OmegaGpuDeviceHandle dev; + OmegaGpuQueueHandle q; + OmegaGpuBufferHandle ring; + uint64_t ns; + unsigned locks_held, double_locks, bad_unlocks, submits; + uint64_t dev_token_va; /* nonzero: the device wrote dev_token there (seen at the gpu->cpu sync) */ + uint32_t dev_token; +} fk; + +static uint64_t f_now_ns(void *c) { (void)c; fk.ns += 1000u; return fk.ns; } +static uint64_t f_now_ms(void *c) { return f_now_ns(c) / 1000000u; } +static int f_wait(void *c, uint64_t ms) { (void)c; fk.ns += ms * 1000000u; return 0; } +static int f_lock(void *c, uint32_t id) { + (void)c; + if (id != OMEGA_GPU_SESSION_LOCK_ID) return OMEGA_GPU_PLAT_REFUSED_ARGS; + if (fk.locks_held) { fk.double_locks++; return OMEGA_GPU_PLAT_REFUSED_BUSY; } /* a real lock would block forever */ + fk.locks_held = 1; + return 0; +} +static int f_unlock(void *c, uint32_t id) { + (void)c; + if (id != OMEGA_GPU_SESSION_LOCK_ID || !fk.locks_held) { fk.bad_unlocks++; return OMEGA_GPU_PLAT_REFUSED_ARGS; } + fk.locks_held = 0; + return 0; +} +static const char *f_diag(void *c) { (void)c; return ""; } +static int f_dev_open(void *c, uint32_t ord, OmegaGpuDeviceHandle *out) { + (void)c; + if (ord != 0 || fk.dev.generation) return OMEGA_GPU_PLAT_REFUSED_LIMIT; + int rc = omega_gpu_handles_open(&fk.t, OMEGA_GPU_HANDLE_DEVICE, 0, 1, 0, &out->index, &out->generation); + if (rc == 0) fk.dev = *out; + return rc; +} +static int f_dev_close(void *c, OmegaGpuDeviceHandle d) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + if (rc) return rc; + (void)omega_gpu_handles_close(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + memset(&fk.dev, 0, sizeof fk.dev); + return 0; +} +static OmegaGpuPlatformCaps g_caps = { + .abi_major = OMEGA_GPU_PLATFORM_ABI_MAJOR, .abi_minor = OMEGA_GPU_PLATFORM_ABI_MINOR, + .services = OMEGA_GPU_SVC_REQUIRED_SESSION, .max_devices = 1, .max_buffers = 1000, .max_queues = 1, .max_inflight = 1, + .max_buffer_bytes = 1ull << 30, .max_total_bytes = 1ull << 32, +}; +static int f_alloc(void *c, OmegaGpuDeviceHandle d, const OmegaGpuBufferDesc *desc, OmegaGpuBufferHandle *o, + OmegaCpuView *cpu, OmegaGpuVa *g, OmegaGpuBusAddr *b) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + if (!rc) rc = omega_gpu_platform_check_buffer(desc, &g_caps); + if (!rc) rc = omega_gpu_handles_open(&fk.t, desc->kind, desc->bytes, 1000, 1ull << 32, &o->index, &o->generation); + if (rc) return rc; + void *m = calloc(1, desc->bytes); + if (!m) { (void)omega_gpu_handles_close(&fk.t, o->index, o->generation, desc->kind); return OMEGA_GPU_PLAT_REFUSED_LIMIT; } + fk.mem[o->index] = m; fk.desc[o->index] = *desc; + cpu->ptr = m; cpu->len = desc->bytes; g->va = VA_BASE + (uint64_t)o->index * VA_STRIDE; b->iova = 0; + return 0; +} +static int f_free(void *c, OmegaGpuBufferHandle h) { + (void)c; + if (h.index >= NB) return OMEGA_GPU_PLAT_REFUSED_BAD_HANDLE; + int rc = omega_gpu_handles_close(&fk.t, h.index, h.generation, fk.t.kind[h.index]); + if (rc) return rc; + free(fk.mem[h.index]); fk.mem[h.index] = NULL; + return 0; +} +static int buf_live(OmegaGpuBufferHandle h) { return h.index < NB && fk.t.live[h.index] && fk.t.generation[h.index] == h.generation; } +static void *va_to_cpu(uint64_t va) { + for (uint32_t i = 0; i < NB; i++) { + if (!fk.mem[i] || !fk.t.live[i]) continue; + const uint64_t base = VA_BASE + (uint64_t)i * VA_STRIDE; + if (va >= base && va < base + fk.desc[i].bytes) return (uint8_t *)fk.mem[i] + (va - base); + } + return NULL; +} +static int sync_check(OmegaGpuBufferHandle h, uint64_t off, uint64_t len) { + if (!buf_live(h)) return OMEGA_GPU_PLAT_REFUSED_STALE_HANDLE; + if (len == 0 || off > fk.desc[h.index].bytes || len > fk.desc[h.index].bytes - off) return OMEGA_GPU_PLAT_REFUSED_BAD_LENGTH; + return 0; +} +static int f_c2g(void *c, OmegaGpuBufferHandle h, uint64_t off, uint64_t len) { (void)c; return sync_check(h, off, len); } +/* gpu->cpu: a command list's launch semaphores (16-byte slots, every one still INIT) read DONE: the launches ran. + * Only a range whose every 16-byte slot holds INIT is taken for a semaphore array. */ +static int f_g2c(void *c, OmegaGpuBufferHandle h, uint64_t off, uint64_t len) { + (void)c; + int rc = sync_check(h, off, len); + if (rc) return rc; + if (len % 16u == 0) { + uint32_t *w = (uint32_t *)((uint8_t *)fk.mem[h.index] + off); + uint64_t i = 0, n = len / 16u; + while (i < n && w[4 * i] == OMEGA_BW_SEMAPHORE_INTERMEDIATE_INIT) i++; + if (i == n) for (i = 0; i < n; i++) w[4 * i] = OMEGA_BW_SEMAPHORE_INTERMEDIATE_DONE; + } + if (fk.dev_token_va) { uint32_t *t = va_to_cpu(fk.dev_token_va); if (t) t[0] = fk.dev_token; } + return 0; +} +static int f_poll(void *c, OmegaGpuBufferHandle h, uint64_t off, uint32_t want, uint64_t ms, uint32_t *seen) { + (void)c; + if (!buf_live(h)) return OMEGA_GPU_PLAT_REFUSED_STALE_HANDLE; + if (!(fk.desc[h.index].rights & OMEGA_GPU_RIGHT_HOST_POLLED)) return OMEGA_GPU_PLAT_REFUSED_BAD_RIGHTS; + const volatile uint32_t *w = (const volatile uint32_t *)((uint8_t *)fk.mem[h.index] + off); + *seen = *w; + if ((int32_t)(*w - want) >= 0) return 0; + fk.ns += ms * 1000000u; + return OMEGA_GPU_POLL_TIMED_OUT; +} +static int f_qopen(void *c, OmegaGpuDeviceHandle d, OmegaGpuBufferHandle ring, OmegaGpuQueueHandle *o) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, d.index, d.generation, OMEGA_GPU_HANDLE_DEVICE); + if (!rc && (!buf_live(ring) || fk.t.kind[ring.index] != OMEGA_GPU_HANDLE_BUF_QUEUE)) rc = OMEGA_GPU_PLAT_REFUSED_BAD_KIND; + if (!rc) rc = omega_gpu_handles_open(&fk.t, OMEGA_GPU_HANDLE_QUEUE, 0, 1, 0, &o->index, &o->generation); + if (!rc) { fk.q = *o; fk.ring = ring; } + return rc; +} +static int f_qclose(void *c, OmegaGpuQueueHandle q) { + (void)c; + int rc = omega_gpu_handles_close(&fk.t, q.index, q.generation, OMEGA_GPU_HANDLE_QUEUE); + if (!rc) memset(&fk.q, 0, sizeof fk.q); + return rc; +} +static uint32_t mthd(uint32_t subc, uint32_t m, uint32_t count) { return (2u << 28) | (count << 16) | (subc << 13) | (m >> 2); } +/* The fake device runs the stream: semaphore releases (0x005c: the completion markers) write their payload, compute + * report semaphores (0x0158, four-word: the stamps) write {payload, timestamp}. */ +static int f_submit(void *c, OmegaGpuQueueHandle q, const uint32_t *w, uint32_t n) { + (void)c; + int rc = omega_gpu_handles_check(&fk.t, q.index, q.generation, OMEGA_GPU_HANDLE_QUEUE); + if (rc) return rc; + if ((uint64_t)n * 4u > fk.desc[fk.ring.index].bytes) return OMEGA_GPU_PLAT_REFUSED_BAD_LENGTH; + fk.submits++; + for (uint32_t i = 0; i + 5 < n; i++) { + if (w[i] == mthd(0, 0x005c, 5)) { + uint32_t *m = va_to_cpu((uint64_t)w[i + 1] | ((uint64_t)w[i + 2] << 32)); + if (m) *m = w[i + 3]; + i += 5; + } else if (w[i] == mthd(1, 0x0158, 5)) { + uint64_t *s = va_to_cpu((uint64_t)w[i + 3] | ((uint64_t)w[i + 4] << 32)); + if (s) { s[0] = (uint64_t)w[i + 1] | ((uint64_t)w[i + 2] << 32); s[1] = (fk.ns += 1000u); } + i += 5; + } + } + return 0; +} +static int f_retire(void *c, OmegaGpuQueueHandle q) { (void)c; (void)q; return 0; } +static void *f_halloc(void *c, size_t b) { (void)c; return malloc(b); } +static void f_hfree(void *c, void *p) { (void)c; free(p); } + +static OmegaGpuPlatform g_plat = { + .ctx = &fk, .time_now_ms = f_now_ms, .wait_ms = f_wait, .lock = f_lock, .unlock = f_unlock, + .dma_alloc = f_alloc, .dma_free = f_free, .sync_cpu_to_gpu = f_c2g, .sync_gpu_to_cpu = f_g2c, .poll_word = f_poll, + .device_open = f_dev_open, .device_close = f_dev_close, .diag_text = f_diag, + .queue_open = f_qopen, .queue_close = f_qclose, .queue_submit = f_submit, .queue_retire = f_retire, + .time_now_ns = f_now_ns, .host_alloc = f_halloc, .host_free = f_hfree, +}; + +/* ---- a one-layer graph on the fake ---- */ +#define LAYERS 1u +#define VOCAB 256u +#define MAX_POS 256u +typedef struct { + OmegaGpuDecodeAttnCache *attn; + OmegaGpuRouter *router; + OmegaGpuBf16Tensor *lm; + OmegaGpuDecodeGraph *g; +} World; + +static int world_build(World *w) { + memset(w, 0, sizeof *w); + static uint16_t lm_w[VOCAB * OMEGA_GPU_DGRAPH_HIDDEN]; /* zeros: finite bf16 */ + if (omega_gpu_decode_attn_cache_alloc(LAYERS, MAX_POS, 1e6, &w->attn) != 0) return -1; + if (omega_gpu_router_alloc(LAYERS, &w->router) != 0) return -1; + if (omega_gpu_bf16_tensor_upload(VOCAB, OMEGA_GPU_DGRAPH_HIDDEN, lm_w, &w->lm) != 0) return -1; + OmegaGpuDecodeGraphConfig cfg; memset(&cfg, 0, sizeof cfg); + cfg.layers = LAYERS; cfg.vocab = VOCAB; cfg.eps = 1e-6f; cfg.norm_topk = 1; + cfg.router = w->router; cfg.attn = w->attn; cfg.lm_head = w->lm; + if (omega_gpu_decode_graph_create(&cfg, &w->g) != OMEGA_GPU_DGRAPH_OK) return -1; + omega_gpu_decode_graph_set_stamps(w->g, 1); + omega_gpu_decode_graph_set_flush_each(w->g, 1); /* one submission per launch: the list never bounds the token */ + return 0; +} + +static float g_x[OMEGA_GPU_DGRAPH_HIDDEN]; +#define EXPECT_LOCK_FREE() do { EXPECT(fk.locks_held == 0); EXPECT(fk.double_locks == 0); EXPECT(fk.bad_unlocks == 0); } while (0) + +static int install(void) { + memset(&fk, 0, sizeof fk); omega_gpu_handles_init(&fk.t); + for (unsigned i = 0; i < OMEGA_GPU_DGRAPH_HIDDEN; i++) g_x[i] = (float)(i % 7) - 3.0f; + return omega_gpu_session_set_platform(&g_plat, &g_caps); +} + +/* One token of `launches` SWIGLU glue launches (each submitted on its own); returns end_token's code, fills *refused + * with the first record that did not return OK (launches when every record did). */ +static int token_of(World *w, uint32_t launches, uint32_t want, uint32_t *refused, uint32_t *tok) { + OmegaGpuDecodeGraphVas v; omega_gpu_decode_graph_vas(w->g, &v); + fk.dev_token_va = v.token; fk.dev_token = want; + *refused = launches; + if (omega_gpu_decode_graph_begin_token(w->g, g_x) != OMEGA_GPU_DGRAPH_OK) return -1000; + for (uint32_t i = 0; i < launches; i++) + if (omega_gpu_decode_graph_record_swiglu(w->g, v.gu, v.act, 1.0f) != OMEGA_GPU_DGRAPH_OK && *refused == launches) *refused = i; + const int rc = omega_gpu_decode_graph_end_token(w->g, tok, NULL); + fk.dev_token_va = 0; + return rc; +} + +static uint64_t g_st[OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 2]; +static uint8_t g_kd[OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 2]; + +/* MAX_LAUNCHES stamped launches: the timeline is exactly full and reads back whole. */ +static void c_full(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } /* never fall back to the real driver */ + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + uint32_t refused = 0, tok = 0; + EXPECT(token_of(&w, OMEGA_GPU_CMDLIST_MAX_LAUNCHES, 7, &refused, &tok) == OMEGA_GPU_DGRAPH_OK); + EXPECT(refused == OMEGA_GPU_CMDLIST_MAX_LAUNCHES && tok == 7); + EXPECT(fk.submits == OMEGA_GPU_CMDLIST_MAX_LAUNCHES); + EXPECT_LOCK_FREE(); + EXPECT(omega_gpu_decode_graph_stamps(w.g, g_st, g_kd, OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 2) == (int)OMEGA_GPU_CMDLIST_MAX_LAUNCHES); + for (uint32_t i = 0; i < OMEGA_GPU_CMDLIST_MAX_LAUNCHES; i++) if (!(g_st[i + 1] > g_st[i])) { EXPECT(!"stamps increase"); break; } +} + +/* One launch more than the timeline holds: that record fails the token, nothing is written past stamp[], the lock is + * released at end_token, no timeline is offered, and the next (small) token runs and reads back normally. */ +static void c_overflow(void) { + World w; + if (install() != OMEGA_GPU_PLAT_OK) { EXPECT(!"fake platform installs"); return; } + if (world_build(&w) != 0) { EXPECT(!"world builds on the fake"); return; } + uint32_t refused = 0, tok = 0xdeadu; + EXPECT(token_of(&w, OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 1u, 7, &refused, &tok) == OMEGA_GPU_DGRAPH_CHIP_FAIL); + EXPECT(refused == OMEGA_GPU_CMDLIST_MAX_LAUNCHES); /* the 4097th launch, the first that has no stamp slot */ + EXPECT(tok == 0xdeadu); + EXPECT(strstr(omega_gpu_session_last_error(), "timeline full") != NULL); + EXPECT_LOCK_FREE(); + EXPECT(omega_gpu_decode_graph_stamps(w.g, g_st, g_kd, OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 2) == OMEGA_GPU_DGRAPH_BAD_ARGS); + EXPECT(token_of(&w, 3, 9, &refused, &tok) == OMEGA_GPU_DGRAPH_OK); + EXPECT(refused == 3 && tok == 9); + EXPECT_LOCK_FREE(); + EXPECT(omega_gpu_decode_graph_stamps(w.g, g_st, g_kd, OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 2) == 3); +} + +static const struct { const char *name; void (*fn)(void); } CASES[] = { + { "timeline exactly full: 4096 stamped launches read back", c_full }, + { "one launch past the timeline: token fails, no write past stamp[]", c_overflow }, +}; + +int main(int argc, char **argv) { + const unsigned n = sizeof CASES / sizeof CASES[0]; + if (argc == 2) { /* one case in this process (debugging): its index */ + const unsigned i = (unsigned)atoi(argv[1]); + if (i >= n) return 2; + case_ok = 1; CASES[i].fn(); + printf("%s %s\n", case_ok ? "ok " : "FAIL", CASES[i].name); + return case_ok ? 0 : 1; + } + unsigned failed = 0; + for (unsigned i = 0; i < n; i++) { + fflush(stdout); + pid_t pid = fork(); + if (pid == 0) { case_ok = 1; CASES[i].fn(); fflush(stdout); _exit(case_ok ? 0 : 1); } + int status = 0; + int ok = pid > 0 && waitpid(pid, &status, 0) == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0; + printf("%s %s\n", ok ? "ok " : "FAIL", CASES[i].name); + if (!ok) failed++; + } + printf("test_omega_gpu_decode_graph_timeline: %u of %u cases passed: %s\n", n - failed, n, failed ? "FAIL" : "PASS"); + return failed ? 1 : 0; +} diff --git a/tools/.crumb b/tools/.crumb index e9e4932b5..f47a4525b 100644 --- a/tools/.crumb +++ b/tools/.crumb @@ -62,14 +62,14 @@ } ], "children_root": "sha256:8d3d3b952374b3b72e667521f07bf028c4c02bcefff772ad1a71cfff3e5266f2", - "compiled_at": "2026-10-30T11:28:28Z", + "compiled_at": "2026-10-30T14:49:59Z", "compiler": "crumb-compile/1", - "digest": "sha256:308db0e6cf45c0a48f01f5f5f228450f191389de68006915b9ecf9c65b9a2e29", + "digest": "sha256:525712c72947533540b1b861dc53bb88f11d9bc388302bf3ee5b14c60ef891f8", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 298, - "generated_at_commit": "a8a6a3d3c47ce797430f045edc5eae11594ba36d", - "source_tree": "sha256:acd1f1b0080968db950791b4eb2dce39bb0289dc0c2e8794bfc7449023446105" + "files": 299, + "generated_at_commit": "789fa01842b25fe314dc35704e013d13e138ebc4", + "source_tree": "sha256:469a44a1139bdf20837b314e43a26a5c3a51e51d7a87676596dd9a6ab3973ddf" }, "owner_lane": "", "provenance": { diff --git a/tools/require_physics_pin.sh b/tools/require_physics_pin.sh new file mode 100755 index 000000000..683b067aa --- /dev/null +++ b/tools/require_physics_pin.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# require_physics_pin.sh PHYSICS_DIR +# omega#456: the chip runners build against a Physics checkout given on their command line (default +# ~/workspace/physics-own30b-k). They build single targets, so the Makefile's check-physics-lock (run by `all`) +# never ran for them. Each runner calls this first, before it writes evidence or builds anything: it refuses +# (exit 2) when PHYSICS_DIR's HEAD is not the commit in this repo's physics.lock, or when HEAD cannot be read. +# PHYSICS_LOCK_CHECK=0 skips the check, the same override the Makefile honours, and says so on stderr. +set -u +PHYS="${1:?usage: require_physics_pin.sh PHYSICS_DIR}" +ROOT="$(cd "$(dirname "$0")/.." && pwd)" || exit 2 +if [ "${PHYSICS_LOCK_CHECK:-1}" = "0" ]; then + echo "require_physics_pin: PHYSICS_LOCK_CHECK=0, Physics pin NOT checked for $PHYS" >&2 + exit 0 +fi +[ -f "$ROOT/physics.lock" ] || { echo "require_physics_pin: REFUSED: $ROOT/physics.lock not found" >&2; exit 2; } +locked=$(tr -d '[:space:]' < "$ROOT/physics.lock") +actual=$(git -C "$PHYS" rev-parse HEAD 2>/dev/null) || actual="" +if [ -z "$actual" ]; then + echo "require_physics_pin: REFUSED: cannot read HEAD of PHYSICS_DIR=$PHYS" >&2 + exit 2 +fi +if [ "$actual" != "$locked" ]; then + echo "require_physics_pin: REFUSED: PHYSICS_DIR=$PHYS is at $actual but physics.lock pins $locked" >&2 + echo " check out the pinned Physics commit there, pass a checkout at the pin, or set PHYSICS_LOCK_CHECK=0" >&2 + exit 2 +fi +exit 0 diff --git a/tools/run_gpu_bf16_gemv_chip.sh b/tools/run_gpu_bf16_gemv_chip.sh index d2dac9594..1f94a42dd 100755 --- a/tools/run_gpu_bf16_gemv_chip.sh +++ b/tools/run_gpu_bf16_gemv_chip.sh @@ -26,6 +26,7 @@ # Verdict line last: "GPU_BF16_GEMV_CHIP: PASS|FAIL". Steps 0 and 2 decide. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock MODEL="${MODEL_DIR:-$HOME/models/qwen3-30b-a3b-instruct-2507-fp8}" HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 diff --git a/tools/run_gpu_cmdlist_chip.sh b/tools/run_gpu_cmdlist_chip.sh index 9f0ead278..0f950c120 100755 --- a/tools/run_gpu_cmdlist_chip.sh +++ b/tools/run_gpu_cmdlist_chip.sh @@ -24,6 +24,7 @@ # Verdict line last: "GPU_CMDLIST_CHIP: PASS|FAIL". set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_decode_attn_chip.sh b/tools/run_gpu_decode_attn_chip.sh index 4c59a8248..506e3b5a8 100755 --- a/tools/run_gpu_decode_attn_chip.sh +++ b/tools/run_gpu_decode_attn_chip.sh @@ -28,6 +28,7 @@ # Verdict line last: "GPU_DECODE_ATTN_CHIP: PASS|FAIL". Steps 0 and 2 decide; 1 and 3 are recorded. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_decode_graph_chip.sh b/tools/run_gpu_decode_graph_chip.sh index 3f9039eb7..a9f58669e 100755 --- a/tools/run_gpu_decode_graph_chip.sh +++ b/tools/run_gpu_decode_graph_chip.sh @@ -26,6 +26,7 @@ # Verdict line last: "GPU_DECODE_GRAPH_CHIP: PASS|FAIL" (red: "GPU_DECODE_GRAPH_CHIP_RED: FAILED_AS_EXPECTED|UNEXPECTED_PASS"). set -u EVID="${1:?evidence dir}"; MODE="${2:-main}"; PHYS="${3:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_fp8_chip.sh b/tools/run_gpu_fp8_chip.sh index f4deb2823..484a87328 100755 --- a/tools/run_gpu_fp8_chip.sh +++ b/tools/run_gpu_fp8_chip.sh @@ -27,6 +27,7 @@ # Verdict line last: "GPU_FP8_CHIP: PASS|FAIL". Steps 0 and 2 decide; 1 and 3 are recorded. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_fp8_v2_chip.sh b/tools/run_gpu_fp8_v2_chip.sh index 8e3e29a86..f8715ff36 100755 --- a/tools/run_gpu_fp8_v2_chip.sh +++ b/tools/run_gpu_fp8_v2_chip.sh @@ -25,6 +25,7 @@ # Verdict line last: "GPU_FP8_V2_CHIP: PASS|FAIL". Steps 0, 2 and the hash equality decide; GB/s are recorded. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_fp8gemm_chip.sh b/tools/run_gpu_fp8gemm_chip.sh index 13156319b..a5fe21473 100755 --- a/tools/run_gpu_fp8gemm_chip.sh +++ b/tools/run_gpu_fp8gemm_chip.sh @@ -27,6 +27,7 @@ # Verdict line last: "GPU_FP8GEMM_CHIP: PASS|FAIL". Steps 0 and 1 decide. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 { diff --git a/tools/run_gpu_l2_stale_chip.sh b/tools/run_gpu_l2_stale_chip.sh index 7439e13a7..0a20860be 100755 --- a/tools/run_gpu_l2_stale_chip.sh +++ b/tools/run_gpu_l2_stale_chip.sh @@ -25,6 +25,7 @@ # Verdict line last: "GPU_L2_STALE_CHIP: PASS|FAIL". PASS = all 20 runs FRESH (exit 0). set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_l2d_barrier_chip.sh b/tools/run_gpu_l2d_barrier_chip.sh index 62f775fcd..6bf8901e5 100755 --- a/tools/run_gpu_l2d_barrier_chip.sh +++ b/tools/run_gpu_l2d_barrier_chip.sh @@ -23,6 +23,7 @@ # Verdict line last: "GPU_L2D_BARRIER_CHIP: PASS|FAIL". set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_l2d_prefetch_chip.sh b/tools/run_gpu_l2d_prefetch_chip.sh index e71377708..1085fe58f 100755 --- a/tools/run_gpu_l2d_prefetch_chip.sh +++ b/tools/run_gpu_l2d_prefetch_chip.sh @@ -22,6 +22,7 @@ # per-kind TIMELINE and the logits hash. Verdict line last: "GPU_L2D_PREFETCH_CHIP: PASS|FAIL". set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 { echo "start $(date -u +%FT%TZ) omega=$(git rev-parse HEAD) branch=$(git rev-parse --abbrev-ref HEAD) dirty=$(git status --porcelain | wc -l) physics_commit=$(git -C "$PHYS" rev-parse HEAD)" diff --git a/tools/run_gpu_prefill_attn_chip.sh b/tools/run_gpu_prefill_attn_chip.sh index 669e484be..c9cd5349a 100755 --- a/tools/run_gpu_prefill_attn_chip.sh +++ b/tools/run_gpu_prefill_attn_chip.sh @@ -31,6 +31,7 @@ # Verdict line last: "GPU_PREFILL_ATTN_CHIP: PASS|FAIL". Steps 0 and 2 decide; 1 and 3 are recorded. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_router_chip.sh b/tools/run_gpu_router_chip.sh index 9dd7b908a..7a1f0c25d 100755 --- a/tools/run_gpu_router_chip.sh +++ b/tools/run_gpu_router_chip.sh @@ -29,6 +29,7 @@ # Verdict line last: "GPU_ROUTER_CHIP: PASS|FAIL". Steps 0 and 2 decide; 1 and 3 are recorded. set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID" cd "$HERE" || exit 2 diff --git a/tools/run_gpu_tcgemm_chip.sh b/tools/run_gpu_tcgemm_chip.sh index 7837ad542..ad3871f3b 100755 --- a/tools/run_gpu_tcgemm_chip.sh +++ b/tools/run_gpu_tcgemm_chip.sh @@ -21,6 +21,7 @@ # dense qkv and o at 3600 tokens. Kernel only, no model load. Caller holds the lock: flock /tmp/aien-gb10.lock tools/run_gpu_tcgemm_chip.sh EVID set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}"; OUT="${OUT_DIR:-/tmp/t3-omega}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 { diff --git a/tools/run_gpu_tern_chip.sh b/tools/run_gpu_tern_chip.sh index e040308f4..76e032a67 100755 --- a/tools/run_gpu_tern_chip.sh +++ b/tools/run_gpu_tern_chip.sh @@ -31,6 +31,7 @@ # Speeds are judged only against the physical limit: 273 GB/s spec, 237.2 GB/s practical. set -u PHASE="${1:?phase}"; EVID="${2:?evidence dir}"; PHYS="${3:-$HOME/workspace/physics-own30b-k}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 { diff --git a/tools/run_l1g_chip.sh b/tools/run_l1g_chip.sh index 943629ec1..946d1d908 100755 --- a/tools/run_l1g_chip.sh +++ b/tools/run_l1g_chip.sh @@ -22,6 +22,7 @@ set -u EVID="${1:?evidence dir}"; shift; WHAT="${*:-qmma pfgemm}" PHYS="${PHYS:-$HOME/workspace/physics-own30b-k}"; OUT="${OUT_DIR:-/tmp/wl1g-omega}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 { diff --git a/tools/run_t3_baseline_chip.sh b/tools/run_t3_baseline_chip.sh index 3f81214d9..f763e4b03 100755 --- a/tools/run_t3_baseline_chip.sh +++ b/tools/run_t3_baseline_chip.sh @@ -21,6 +21,7 @@ # Kernel only, no model load. Caller holds the GB10 lock: flock /tmp/aien-gb10.lock tools/run_t3_baseline_chip.sh EVID set -u EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}"; OUT="${OUT_DIR:-/tmp/t3-omega}" +"$(dirname "$0")/require_physics_pin.sh" "$PHYS" || exit 2 # omega#456: refuse a Physics checkout other than physics.lock HERE="$(cd "$(dirname "$0")/.." && pwd)" mkdir -p "$EVID"; cd "$HERE" || exit 2 {