diff --git a/.aien/unmapped-ok b/.aien/unmapped-ok index e1ead45db..16dc411e6 100644 --- a/.aien/unmapped-ok +++ b/.aien/unmapped-ok @@ -6,3 +6,4 @@ LICENSE .gitignore README.md CONTRIBUTORS.md +*/README.md diff --git a/.crumb b/.crumb index d121d2dad..b4d5b52d2 100644 --- a/.crumb +++ b/.crumb @@ -47,8 +47,8 @@ "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "d2eb8967a939ebdb0b54e15fe5d849dd5af71c23b812941e4ba86ad2b0f21d39", - "last_commit": "4870b0a4", + "digest": "691ec48b0bf5044b7c1e9fb867ef667c2a8d5ced965ae8ec3cede6d4a41a21f1", + "last_commit": "e715775a", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -59,8 +59,8 @@ "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "e7d38c87a51c3c0ee6e3b18419ef4a01d95029de12ac9bf69eb672654f0ace55", - "last_commit": "ae4ad9c0", + "digest": "d5fe276ca62f3f8876724766f78440adda126428d768d1c49532b0175a829b0e", + "last_commit": "eefdfa3d", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, @@ -71,39 +71,39 @@ "purpose": "Directory research. Purpose not yet described by a human." }, { - "digest": "6327473d41e10acbf43be0918d3557509322bfd7d6e075e114c79c2600a47305", - "last_commit": "43d8d20d", + "digest": "2dd4730b7e14e1b215d011c074e28a3b69a1d9abc96f0208bf21afee4c7d4b1e", + "last_commit": "209199bb", "name": "spec", "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", - "last_commit": "333091a6", + "digest": "c53df5dd6e20fd9d6106288146c04ffe1690ac17c031027fc31f429fa565fb4c", + "last_commit": "eefdfa3d", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", - "last_commit": "88e24bdd", + "digest": "e443c7f6ef7d29a6d70c4aa0cb9193678f8a9a7bd49704167061d60dfaf707ca", + "last_commit": "eefdfa3d", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, { - "digest": "566a123ba248da906e3c42430b73decd7c3ec030a4fd26c909d265aa9bf67db9", - "last_commit": "88e24bdd", + "digest": "9352e55d6b0ccb416f48edf2d9d37fb66477335b51c8dbb4b5a84d7c33091e29", + "last_commit": "df906b21", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:e1a8c008214ad5dbc33a3e184d7e882dc56d1d50f9bd14c58f8773992961557e", - "compiled_at": "2026-10-18T21:10:38Z", + "children_root": "sha256:119053af206413d8ddc881cfae9631e21bfbe08e89dbee1e67d1f6aeeea672f2", + "compiled_at": "2026-10-20T20:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:be7220db494238bb4c33023d1df17286c35f947336bee5fc2e0405c136ec3e73", - "evidence_files": 11127, - "evidence_root": "sha256:4528085ec1661c442b64fb5dc8def65067ea2620ff88e42bcf52d58b7642ea6e", - "files": 14100, - "generated_at_commit": "f4a9849fb127f8d2d664dfc56890752ad180c507", - "source_tree": "sha256:21f93defce6c9ba159a4bd31083db787e156dfaa4afb80c3427cf88f732f8258" + "digest": "sha256:7e2cd30b80e010ed3201cc295f76dcda143ff3e10588c2f43add0c2255eb9d72", + "evidence_files": 11292, + "evidence_root": "sha256:08d02609f034524556b9677f46acc7b12aa3bc6b6c1f0eca83b3d505570bda9a", + "files": 14349, + "generated_at_commit": "738552e3f036b757e740f1dbfa1c4e7de069f63c", + "source_tree": "sha256:9d3ce97a365440d5e1d70a7a7bf45f2077d909dd11b18feea709442798671feb" }, "owner_lane": "", "provenance": { diff --git a/.github/workflows/own30b-host.yml b/.github/workflows/own30b-host.yml new file mode 100644 index 000000000..7401b7e2c --- /dev/null +++ b/.github/workflows/own30b-host.yml @@ -0,0 +1,80 @@ +name: OWN-30B host tiers + +# omega#456: the OWN-30B engine's host tiers that no workflow ran. Every test runs in +# --host-only or --sim mode (host model and warp simulator); none opens a GPU, and the +# runner is NOT the Spark, so nothing here is a chip or hardware result. The chip gates +# stay tools/run_*_chip.sh under the GB10 lock on the Spark. +# +# Coverage of this file: +# own30b-host test-gpu-{bf16-gemv,cmdlist,decode-attn,decode-graph,elementwise,fp8, +# fp8gemm,gpr-boundary,matmul-api,moe-window,reconv,router,tern}, +# test-gpu-prefill-host (tc_probe, qmma_probe, pf_mem, tcgemm, +# prefill_attn, pfgemm, qgemm, pfhost), check-own30b-decode-profile +# (tools/own30b_decode_profile.c with -Werror), and +# tools/require_physics_pin.sh (accepts the pin, refuses a bad checkout). +# nvdisasm is not installed on the runner: tests with a listing check print "skipped" +# for it here and run it on the Spark. test-gpu-attention runs in host-suites-3.yml. + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + paths: + - 'Makefile' + - 'mk/**' + - 'physics.lock' + - 'src/**' + - 'tests/gpu_*' + - 'tests/bw_*' + - 'tools/own30b_decode_profile.c' + - 'tools/require_physics_pin.sh' + - 'tools/run_*_chip.sh' + - '.github/workflows/own30b-host.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + own30b-host: + runs-on: ubuntu-24.04-arm + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Read pinned Physics + id: pins + run: | + sha=$(tr -d '[:space:]' < physics.lock) + test -n "$sha" + echo "physics=$sha" >> "$GITHUB_OUTPUT" + - name: Checkout pinned Physics + uses: actions/checkout@v4 + with: + repository: aien-spark/physics + ref: ${{ steps.pins.outputs.physics }} + path: physics-src + - name: Keep Physics checkout out of Omega tree status + run: echo 'physics-src/' >> .git/info/exclude + - name: Physics pin check (chip runners call it first) + run: | + tools/require_physics_pin.sh "$GITHUB_WORKSPACE/physics-src" + if tools/require_physics_pin.sh /nonexistent 2>refuse.log; then echo "a missing checkout was accepted"; exit 1; fi + grep -q 'REFUSED' refuse.log + - name: Build libomega_gpu.a (pinned Physics, lock check on) + env: + PHYSICS_DIR: ${{ github.workspace }}/physics-src + run: make -j"$(nproc)" check-physics-lock build/libomega_gpu.a + - name: Host tiers + env: + PHYSICS_DIR: ${{ github.workspace }}/physics-src + run: | + set -e + for t in check-own30b-decode-profile test-gpu-bf16-gemv test-gpu-cmdlist test-gpu-decode-attn \ + test-gpu-decode-graph test-gpu-elementwise test-gpu-fp8 test-gpu-fp8gemm test-gpu-gpr-boundary \ + test-gpu-matmul-api test-gpu-moe-window test-gpu-reconv test-gpu-router test-gpu-tern \ + test-gpu-prefill-host; do + echo "::group::make $t" + make -j"$(nproc)" "$t" + echo "::endgroup::" + done diff --git a/Makefile b/Makefile index 3551fea3f..f79fccb70 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,8 @@ SRCS += src/omega_gpu_tcgemm_api.c SRCS += src/omega_blackwell_codegen_pattn.c src/omega_gpu_prefill_attn_api.c # OWN-30B T3b (2026-10-13): device-resident prefill (omega_gpu_prefill.h), new files only SRCS += src/omega_blackwell_codegen_pf.c src/omega_gpu_prefill.c src/omega_blackwell_codegen_tc2.c src/omega_gpu_pfgemm.c +# trainer lane E1 (2026-10-16): device-resident bf16 training GEMM (omega_gpu_tgemm_api.h), new files only +SRCS += src/omega_blackwell_codegen_tgemm.c src/omega_gpu_tgemm_api.c # OWN-30B L1 GEMM (W-L1G, 2026-10-14): native FP8 QMMA, new files only SRCS += src/omega_blackwell_codegen_qmma.c src/omega_blackwell_codegen_qg.c # OWN-30B W-L1G-D (2026-10-14): router logits + MoE combine for the whole-prompt prefill, new files only @@ -700,8 +702,8 @@ RX_COMPOSE_LIVING_CHECKS = $(OUT_DIR)/rx_graph.o $(OUT_DIR)/rx_capq.o $(OUT_DIR) # docs/r16-production-entry-point.md has the table. AIEN_TEST_FLAGS = -DAIEN_TEST_BUILD=1 RX_FABRIC_TEST_SRCS = src/fabric/fabric.c src/fabric/fab_hmac.c src/fabric/fab_loopback.c \ - src/fabric/fab_dispatch.c -RX_R13_TEST_CHECKS = tests/runtime/rx_compose_fixture.h src/fabric/fab_dispatch.h \ + src/fabric/fab_dispatch.c src/fabric/fab_route.c +RX_R13_TEST_CHECKS = tests/runtime/rx_compose_fixture.h src/fabric/fab_dispatch.h src/fabric/fab_route.h \ src/fabric/fab_loopback.h src/fabric/fab_hmac.h tests/fabric/fab_living_phase.h # The production build refuses the flag outright. RX_PROD_REFUSE_TEST = $(if $(findstring AIEN_TEST_BUILD,$(CFLAGS))$(findstring RXC_TEST_HOOKS,$(CFLAGS)),\ @@ -2472,6 +2474,32 @@ test-gpu-fp8: $(GPU_FP8_TEST) ./$(GPU_FP8_TEST) --host-only ./$(GPU_FP8_TEST) --sim +# omega#471: libomega_gpu.a links without -lm (Makefile:35). Two halves, host-only: +# 1. symbol check: no undefined symbol of the archive (one not defined by another member) may be a name that the +# toolchain's libm.so.6 exports. libm's own export table is the denylist, so nothing is hand-maintained; a missing +# libm.so.6 is a FAIL, never a silent pass. glibc also resolves some libm names from libc (ldexpf did), which is +# why a plain link without -lm cannot catch this. +# 2. tests/gpu_libm_free_test.c (links -lm): the libm-free replacements are bit-identical to the libm calls they +# replaced over every relevant input (all exponents, all 256 e4m3 bytes, all 65536 bf16 codes, all 2^32 f32). +.PHONY: test-gpu-libm-free +GPU_LIBM_FREE_TEST = $(OUT_DIR)/gpu_libm_free_test +$(GPU_LIBM_FREE_TEST): tests/gpu_libm_free_test.c src/omega_gpu_fp8_api.h src/omega_gpu_hostmath.h src/omega_blackwell_codegen_moe.h $(OUT_DIR)/libomega_gpu.a + $(CC) $(CFLAGS) -o $@ tests/gpu_libm_free_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +test-gpu-libm-free: $(OUT_DIR)/libomega_gpu.a $(GPU_LIBM_FREE_TEST) + @set -e; libm=$$($(CC) -print-file-name=libm.so.6); \ + if [ ! -f "$$libm" ]; then echo "test-gpu-libm-free: FAIL (libm.so.6 not found: '$$libm')"; exit 1; fi; \ + nm -D --defined-only "$$libm" | awk 'NF>=3{print $$NF}' | sed 's/@.*//' | sort -u > $(OUT_DIR)/libm.exports; \ + nm $(OUT_DIR)/libomega_gpu.a | awk '$$1=="U"{print $$2}' | sort -u > $(OUT_DIR)/libomega_gpu.undef; \ + nm --defined-only $(OUT_DIR)/libomega_gpu.a | awk 'NF==3{print $$3}' | sort -u > $(OUT_DIR)/libomega_gpu.def; \ + test -s $(OUT_DIR)/libm.exports && test -s $(OUT_DIR)/libomega_gpu.undef && test -s $(OUT_DIR)/libomega_gpu.def; \ + hits=$$(comm -23 $(OUT_DIR)/libomega_gpu.undef $(OUT_DIR)/libomega_gpu.def | comm -12 - $(OUT_DIR)/libm.exports); \ + if [ -n "$$hits" ]; then \ + echo "test-gpu-libm-free: FAIL, libomega_gpu.a references libm:"; \ + for s in $$hits; do nm -A $(OUT_DIR)/libomega_gpu.a | grep -w "U $$s" | sed 's/^/ /'; done; exit 1; fi; \ + echo "PASS libomega_gpu.a: 0 of $$(comm -23 $(OUT_DIR)/libomega_gpu.undef $(OUT_DIR)/libomega_gpu.def | wc -l) external symbols are libm exports ($$(wc -l < $(OUT_DIR)/libm.exports) names in $$libm)" + ./$(GPU_LIBM_FREE_TEST) + @echo "test-gpu-libm-free: PASS" + # omega #457 (2026-10-15): host rewrite of a GPU-cached buffer must be visible to the next launch. Chip only; the gate # is tools/run_gpu_l2_stale_chip.sh. GPU_L2_STALE_TEST = $(OUT_DIR)/gpu_l2_stale_test @@ -2511,7 +2539,7 @@ test-gpu-bf16-gemv: $(GPU_BF16_TEST) # Ternary engine T0 (2026-10-15): KT1 W2A8 ternary GEMV (omega_gpu_tern_api.h). test-gpu-tern is host-only (word # arithmetic, packing, segments, budgets, refusals) plus the warp simulator (bit-equal to oma_rz_oracle, f32 segment -# epilogue, mutants 1-3 caught); the chip gate is tools/run_gpu_tern_chip.sh with the quiet flag held. +# epilogue, three warp orders, mutants 1 to 5 caught); the chip gate is tools/run_gpu_tern_chip.sh with the quiet flag held. .PHONY: test-gpu-tern GPU_TERN_TEST = $(OUT_DIR)/gpu_tern_test $(GPU_TERN_TEST): tests/gpu_tern_test.c tests/bw_warp_sim_k.h src/omega_gpu_tern_api.h src/omega_blackwell_codegen_tern.h $(OMA_RZ_SRCS) $(OMA_RZ_HDRS) $(OUT_DIR)/libomega_gpu.a @@ -2555,6 +2583,14 @@ GPU_TC_PEAK_TEST = $(OUT_DIR)/gpu_tc_peak_test $(GPU_TC_PEAK_TEST): tests/gpu_tc_peak_test.c tests/bw_hmma_model.h tests/bw_warp_sim_tc.h src/omega_blackwell_codegen_tc.h $(OUT_DIR)/libomega_gpu.a $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_tc_peak_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +# Training R5 part 2 (2026-10-15): f32 global atomic add probe. --host-only is the simulator; the chip run is one short window. +GPU_ATOMF32_PROBE_TEST = $(OUT_DIR)/gpu_atomf32_probe_test +$(GPU_ATOMF32_PROBE_TEST): tests/gpu_atomf32_probe_test.c tests/bw_warp_sim_tc.h src/omega_bw_em.h src/omega_blackwell_codegen.h $(OUT_DIR)/libomega_gpu.a + $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=256 -Itests -o $@ tests/gpu_atomf32_probe_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +.PHONY: test-atomf32-probe-host +test-atomf32-probe-host: $(GPU_ATOMF32_PROBE_TEST) + $(GPU_ATOMF32_PROBE_TEST) --host-only + # OWN-30B L1 attention (2026-10-13): tensor-core causal prefill attention. --host-only and --sim are host proofs; # the chip gate is tools/run_gpu_prefill_attn_chip.sh. GPU_PATTN_TEST = $(OUT_DIR)/gpu_prefill_attn_test @@ -2567,6 +2603,12 @@ $(GPU_PF_MEM_TEST): tests/gpu_pf_mem_test.c tests/bw_warp_sim_tc.h src/omega_gpu GPU_PFGEMM_TEST = $(OUT_DIR)/gpu_pfgemm_test $(GPU_PFGEMM_TEST): tests/gpu_pfgemm_test.c tests/bw_hmma_model.h tests/bw_warp_sim_tc.h src/omega_gpu_prefill.h src/omega_blackwell_codegen_tc2.h $(OUT_DIR)/libomega_gpu.a $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_pfgemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +# trainer lane E1 (2026-10-16): bf16 training GEMM. --host-only and --sim are host proofs; the chip gate is tools/run_gpu_tgemm_chip.sh +GPU_TGEMM_TEST = $(OUT_DIR)/gpu_tgemm_test +$(GPU_TGEMM_TEST): tests/gpu_tgemm_test.c tests/bw_hmma_model.h tests/bw_warp_sim_tc.h src/omega_gpu_tgemm_api.h src/omega_blackwell_codegen_tgemm.h $(OUT_DIR)/libomega_gpu.a + $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_tgemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +test-gpu-tgemm: $(GPU_TGEMM_TEST) + $(GPU_TGEMM_TEST) --host-only && $(GPU_TGEMM_TEST) --sim GPU_QMMA_PROBE_TEST = $(OUT_DIR)/gpu_qmma_probe_test $(GPU_QMMA_PROBE_TEST): tests/gpu_qmma_probe_test.c tests/bw_qmma_model.h src/omega_blackwell_codegen_qmma.h $(OUT_DIR)/libomega_gpu.a $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_qmma_probe_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm @@ -2576,6 +2618,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 diff --git a/README.md b/README.md index 87f91fbf1..ca5ad9ae9 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ The full omegatool build (`make`) links the `physics` repository at the commit i ## Repository layout -`src/` core and C compiler (`src/compiler/`), `src/runtime/` reaction runtime, `src/fabric/` host-only fabric interface, `src/physics0/` Physics Zero apparatus, `spec/` and `docs/` specifications, `tests/` gate suites, `evidence/` content-addressed receipts, `tools/` harnesses, `mk/` make fragments included by the `Makefile`. Also `bench/prime_race/` (Prime Drag Race implementation), `calibration/` (Turing calibration experiments, preregistration and blinding protocol), `research/` (experiments and prototypes) and `doctrine/` (the Milestone 4 doctrine). +`src/` core and C compiler (`src/compiler/`), `src/runtime/` reaction runtime, `src/fabric/` Fabric membership and cross-machine work hand-off (see [src/fabric/README.md](src/fabric/README.md)), `src/physics0/` Physics Zero apparatus, `spec/` and `docs/` specifications, `tests/` gate suites, `evidence/` content-addressed receipts, `tools/` harnesses, `mk/` make fragments included by the `Makefile`. Also `bench/prime_race/` (Prime Drag Race implementation), `calibration/` (Turing calibration experiments, preregistration and blinding protocol), `research/` (experiments and prototypes) and `doctrine/` (the Milestone 4 doctrine). ## Contributing diff --git a/docs/.crumb b/docs/.crumb index ca5d5ec00..41fbbe3e0 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -124,14 +124,14 @@ } ], "children_root": "sha256:ac7f7ea4b00d4620a993c6dd88a0267f2d49008d415162976e45fa4341e43407", - "compiled_at": "2026-10-16T09:04:56Z", + "compiled_at": "2026-10-16T10:56:28Z", "compiler": "crumb-compile/1", - "digest": "sha256:d2eb8967a939ebdb0b54e15fe5d849dd5af71c23b812941e4ba86ad2b0f21d39", + "digest": "sha256:691ec48b0bf5044b7c1e9fb867ef667c2a8d5ced965ae8ec3cede6d4a41a21f1", "evidence_files": 34, "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", - "files": 127, - "generated_at_commit": "9d368679f13ea58c46bf7580899aee92e39f5885", - "source_tree": "sha256:29d159b6950500f96de859834fd2c5a9e9ba037f9bc88fd97a8ed47a1688233b" + "files": 128, + "generated_at_commit": "278b6c3c5840e5f13472a2f60f50542d81c3821e", + "source_tree": "sha256:839eb7db8dd07e412515e1606afc50ea46372ffa3a4ae242ecc82fa3b43b03cb" }, "owner_lane": "", "provenance": { diff --git a/docs/perf/DECODE_GRAPH_RECEIPT.md b/docs/perf/DECODE_GRAPH_RECEIPT.md new file mode 100644 index 000000000..188b1e46e --- /dev/null +++ b/docs/perf/DECODE_GRAPH_RECEIPT.md @@ -0,0 +1,131 @@ +# Decode-graph performance receipt (`omega-decode-graph-receipt/1`) + +Lane P1 of aien-architecture#233. `tools/dgraph_receipt.c` turns one existing run of the decode-graph +chip test into one machine-readable receipt bound to the commit that was measured, and checks such +receipts. It reads files only: no GPU, no `libomega_gpu`, no new counters. This change does not touch +GPU numerics, barriers, prefetch, submission, memory ownership or any hot path: it only reads the +numbers that `omega_gpu_decode_graph` and `gpu_decode_graph_test` already produce. + +## Where the numbers come from + +| receipt field | source | clock | +|---|---|---| +| `per_token.graph.launches` | `OmegaGpuDecodeGraphStats.launches`: "launches recorded for the token" | count | +| `per_token.graph.submits` | `.submits`: "submissions (1 normally; = launches with flush_each)" | count | +| `per_token.graph.chip_ns` | `.chip_ns`: "sum of the list submissions' first-submit-to-last-marker time" | **host** | +| `per_token.graph.record_ns` | `.record_ns`: "host: begin_token to the submit (recording)" | host | +| `per_token.graph.total_ns` | `.total_ns`: "host: begin_token to end_token return" | host | +| `per_token.graph.sems_done` | `.sems_done`: "launch semaphores found DONE" (not written by the test: `null` + note) | count | +| `per_token.graph.host_overhead_ns` | derived: `total_ns - chip_ns` | host | +| `stamped_token.span_ns`, `stages[].device_ns` | `omega_gpu_decode_graph_stamps()`: "Launch i took stamps[i + 1] - stamps[i] ns" | **device** (PTIMER) | +| `stamped_token.chip_ns` | the stamped token's `.chip_ns` | host | +| `stamped_token.unattributed_ns` | derived: `chip_ns - span_ns` | host minus device | +| `per_token.flush_each.*` | the same list submitted one launch per submission (TEST ONLY `set_flush_each`) | as above | + +Quotes are from `src/omega_gpu_decode_graph.h`. The stats are copied from the `--out` JSON of +`tests/gpu_decode_graph_test.c`; the run's barrier, prefetch and cached-weights settings from its log +("dgraph prefetch" and "fp8 knobs" lines); commit, dirty flag, host and GPU from the runner's +`device.txt`; binary identity from `binaries.sha256`. + +### Host clock vs device clock + +- **`chip_ns` is host time, not device time.** `omega_gpu_cmdlist_submit()` reads the platform clock + (`omega_gpu_session_now_ns()`, `CLOCK_MONOTONIC` on Linux, `omega_gpu_platform_linux.c`) just before + `queue_submit` and again after both completion-marker words were seen and synced. It holds the device + work plus the submit call, the front-end start and the host's marker poll. +- **The device clock appears only with stamps on.** `set_stamps(1)` writes a GPU PTIMER timestamp + before the first launch and after every launch, "taken after its WAIT_FOR_IDLE" + (`omega_gpu_cmdlist.h`). The test runs one extra token this way; its `span_ns` is device time and + always fits inside that token's host `chip_ns` (the checker enforces `span_ns <= chip_ns`). +- `unattributed_ns = chip_ns - span_ns` is the part of the host submit span the device stamps do not + cover. +- `host_overhead_ns = total_ns - chip_ns`: host work outside the submit span (recording, the attention + counter check, output sync, token read, lock). + +### Serial vs overlapping time + +- `chip_ns` is a serial sum: one host span per submission, and submissions never overlap. A graph + token is one submission; a `flush_each` token is one per launch. +- With prefetch off, every barrier mode except the TEST ONLY `none` puts a WAIT_FOR_IDLE before each + stamp, so launches run one after another. The stage times are a serial partition of `span_ns`: they + add up to it exactly (the checker enforces `stage_sum_ns == span_ns`). +- With prefetch on (`AIEN_OMEGA_DGRAPH_PREFETCH=1`), each layer adds one o_proj prefetch launch marked + independent (no barrier before it) and tagged `attn`. Its stamp is the front-end time while the + attention may still be running. So the `attn` stage is the attention-plus-prefetch window. Overlap + is **visible but not measurable**: no counter splits that window. +- `overlap_measurable` is `false` in every receipt this tool writes, and the `reason` field says why. + +## Statuses + +`VERIFIED | EXPERIMENTAL | HISTORICAL | NOT_RUN | FAIL | SUPERSEDED`. Receipts rebuilt from old +evidence logs are **HISTORICAL**: the chip was not run to make them. `VERIFIED` needs a clean tree and a +PASS run. `EXPERIMENTAL` needs a PASS run. `NOT_RUN` carries `per_token: null`, `stamped_token: null` and +a `not_run_reason`, so it holds no numbers. + +## Making a receipt from a run + +From the repo root, after `make dgraph-receipt`: + +``` +build/dgraph_receipt/dgraph_receipt \ + --run-dir evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph \ + --stats evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json \ + --log evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log \ + --status HISTORICAL --repo aien-spark/omega \ + --model "synthetic Qwen3-30B-A3B-shaped decode step, random weights" \ + --precision "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations" \ + --mode "decode, one token per command list (omega_gpu_decode_graph_token), batch 1" \ + --runner "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main" \ + --out receipt.json +build/dgraph_receipt/dgraph_receipt --check receipt.json --evidence-root . +``` + +The generator runs the checker on its own output first and refuses to write a receipt the checker +rejects. It also refuses a log that lacks the run's settings and a stats file and log from different +runs. The exact commands behind the golden fixtures are in `tests/dgraph_receipt/run.sh`. + +## What the checker rejects + +Missing fields, wrong types, unknown top-level fields, a schema other than `/1`, a status outside the +enum, a commit that is not 40 lowercase hex digits, a non-`OWNER/NAME` repo, placeholder strings +anywhere (`""`, `TBD`, `unknown`, `TODO`, `N/A`, `none`, ...), zero tokens, derived numbers that do not +match their inputs (`host_overhead_ns`, `unattributed_ns`, `stage_sum_ns`), stages that do not add up to +`span_ns`, `span_ns > chip_ns`, `sems_done` neither equal to `launches` nor `null` with a note, +`VERIFIED` on a dirty tree, measurements on a `NOT_RUN` receipt, absolute or `..` evidence paths, and, +with `--evidence-root`, evidence paths that do not exist. `make test-dgraph-receipt` proves each rule +with a fixture in `tests/dgraph_receipt/fixtures/` (table: `tests/dgraph_receipt/negatives.txt`). + +## Reproduced numbers (HISTORICAL) + +These are the only numbers here. They are copies of existing evidence, not new claims: + +- `tests/dgraph_receipt/fixtures/good-historical-710d438c-main.json`, from + `evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/` (omega 710d438c, clean tree, GB10, + 2 layers, 20 tokens, prefetch off). Per-token medians: 22 launches in 1 submission, total 3 978 675 ns, + chip (host clock) 3 975 395 ns, record 2 464 ns. Stamped token: device span 3 989 568 ns inside a host + chip span of 4 076 853 ns. +- `tests/dgraph_receipt/fixtures/good-historical-710d438c-prefetch.json`, from + `evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/` run `4-cached-prefetch` (cached + weights, prefetch on, 10 tokens, 24 launches). + +## Limitations + +- Synthetic step on random weights, one fixed position, the same token every rep: this is not a + serving or end-to-end tokens-per-second figure. +- Per-token values are medians taken field by field, so `host_overhead_ns` is a difference of medians. +- The stamped token is one sample. +- No aggregate totals or percentiles: the test writes medians only. +- When `make` did not rebuild the test, `build.log` has no compile line. The receipt then says so and + names the binary by sha256. + +## Gaps (counters that do not exist; none added here) + +- `sems_done` per token: the test's `--out` writer (`tests/gpu_decode_graph_test.c`) does not write it. +- The method-stream build time: `OmegaGpuCmdListStats.host_ns` is filled by `omega_gpu_cmdlist_submit()`, + but `submit_now()` in `src/omega_gpu_decode_graph.c` does not add it to `OmegaGpuDecodeGraphStats`. +- Submit call vs wait inside `chip_ns`: `omega_gpu_cmdlist_submit()` times `queue_submit` through the + marker poll as one span. Splitting them needs a clock read after `queue_submit` returns. +- Per-token distributions: `gpu_decode_graph_test` keeps the per-rep arrays but writes only + `median_u64()` of each. +- Attention vs prefetch inside the overlapped window: with an independent launch, `omega_gpu_cmdlist_submit()` + emits the stamp before it with no WAIT_FOR_IDLE, so no stamp marks the end of the attention alone. diff --git a/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/SHA256SUMS b/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/SHA256SUMS new file mode 100644 index 000000000..a88df52a4 --- /dev/null +++ b/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/SHA256SUMS @@ -0,0 +1,2 @@ +5894569b85825c5d836dd1f7b05bbcea8e3b2ca65a1d26872e7648e6c0dfbe30 probe.log +55b422c45c52a92dcedc1f72b0ba50f0d360b2102826fa887b7f4695b7fe99fb nvdisasm_decode.txt diff --git a/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/nvdisasm_decode.txt b/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/nvdisasm_decode.txt new file mode 100644 index 000000000..bb3004518 --- /dev/null +++ b/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/nvdisasm_decode.txt @@ -0,0 +1,13 @@ +nvdisasm release 13.0, V13.0.85 -b SM121; words written by omega_blackwell_encode_one at dd8ccc74 (scope dst addr data ureg -> w0 w1 w2 w3 -> text) +sys 4 2 5 6 -> 0x020479a3 0x80000005 0x0c1f5306 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, R4, desc[UR6][R2.64], R5 ; +sys 9 10 7 4 -> 0x0a0979a3 0x80000007 0x0c1f5304 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, R9, desc[UR4][R10.64], R7 ; +sys -1 2 5 6 -> 0x02ff79a3 0x80000005 0x0c1f5306 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, RZ, desc[UR6][R2.64], R5 ; +gpu 4 2 5 6 -> 0x020479a3 0x80000005 0x0c1ef306 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, R4, desc[UR6][R2.64], R5 ; +gpu 9 10 7 4 -> 0x0a0979a3 0x80000007 0x0c1ef304 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, R9, desc[UR4][R10.64], R7 ; +gpu -1 2 5 6 -> 0x02ff79a3 0x80000005 0x0c1ef306 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, RZ, desc[UR6][R2.64], R5 ; +gpu -1 40 33 12 -> 0x28ff79a3 0x80000021 0x0c1ef30c 0x00321e00 -> ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, RZ, desc[UR12][R40.64], R33 ; +rejected candidates (Mesa sm90 REDG f32 layout, opcode 0x9a6), each: Unrecognized operation +0x020079a6 0x00000005 0x0c10f306 -> nvdisasm error : Unrecognized operation for functional uni +0x020079a6 0x00000005 0x0c115306 -> nvdisasm error : Unrecognized operation for functional uni +0x020079a6 0x00000005 0x0810f306 -> nvdisasm error : Unrecognized operation for functional uni +0x020079a6 0x00000005 0x0c1ef306 -> nvdisasm error : Unrecognized operation for functional uni diff --git a/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/probe.log b/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/probe.log new file mode 100644 index 000000000..f4205e71c --- /dev/null +++ b/evidence/R5-ATOMF32-PROBE-dd8ccc74-20261016T0301Z/probe.log @@ -0,0 +1,91 @@ +commit dd8ccc746d6a5a146ab0f216cdf2a657636fb5d0 (tree 5c9e71056868c3e01195b138f68554e9c2aa843a) physics 6d7cf0d driver 580.173.02 build/ cleaned at 0db0f0ad (src/ identical at dd8ccc74) 2026-10-16T03:01:40Z +== run 1 +sim SYS add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim SYS add -0.25 from 0 x 128: word 0xc2000000 = -32 (want 0xc2000000, a no-op would leave 0x00000000), 0 faults +sim SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +sim SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +sim GPU add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim GPU add 1.0 from 0, no destination (RZ) x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim CONTROL integer ATOMG.ADD of 1.0f bits x 128: word 0xc0000000 = -2 (want 0x43000000, a no-op would leave 0x00000000), 128 faults + control ok: the check caught the wrong arithmetic +chip SYS add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 65331.7 us = 2.01 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add -0.25 from 0 x 131072: word 0xc7000000 = -32768 (want 0xc7000000, a no-op would leave 0x00000000), 0 faults, 65790.4 us = 1.99 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +chip SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +chip GPU add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 64961.2 us = 2.02 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip GPU add 1.0 from 0, no destination (RZ) x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 65587.3 us = 2.00 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip CONTROL integer ATOMG.ADD of 1.0f bits x 131072: word 0x00000000 = 0 (want 0x48000000, a no-op would leave 0x00000000), 131072 faults, 51005.8 us = 2.57 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) + control ok: the check caught the wrong arithmetic +GPU_ATOMF32_PROBE: PASS +== run 2 +sim SYS add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim SYS add -0.25 from 0 x 128: word 0xc2000000 = -32 (want 0xc2000000, a no-op would leave 0x00000000), 0 faults +sim SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +sim SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +sim GPU add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim GPU add 1.0 from 0, no destination (RZ) x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim CONTROL integer ATOMG.ADD of 1.0f bits x 128: word 0xc0000000 = -2 (want 0x43000000, a no-op would leave 0x00000000), 128 faults + control ok: the check caught the wrong arithmetic +chip SYS add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 64059.1 us = 2.05 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add -0.25 from 0 x 131072: word 0xc7000000 = -32768 (want 0xc7000000, a no-op would leave 0x00000000), 0 faults, 63325.3 us = 2.07 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +chip SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +chip GPU add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 63543.4 us = 2.06 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip GPU add 1.0 from 0, no destination (RZ) x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 63275.4 us = 2.07 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip CONTROL integer ATOMG.ADD of 1.0f bits x 131072: word 0x00000000 = 0 (want 0x48000000, a no-op would leave 0x00000000), 131072 faults, 51676.8 us = 2.54 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) + control ok: the check caught the wrong arithmetic +GPU_ATOMF32_PROBE: PASS +== run 3 +sim SYS add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim SYS add -0.25 from 0 x 128: word 0xc2000000 = -32 (want 0xc2000000, a no-op would leave 0x00000000), 0 faults +sim SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +sim SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +sim GPU add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim GPU add 1.0 from 0, no destination (RZ) x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim CONTROL integer ATOMG.ADD of 1.0f bits x 128: word 0xc0000000 = -2 (want 0x43000000, a no-op would leave 0x00000000), 128 faults + control ok: the check caught the wrong arithmetic +chip SYS add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 62273.9 us = 2.10 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add -0.25 from 0 x 131072: word 0xc7000000 = -32768 (want 0xc7000000, a no-op would leave 0x00000000), 0 faults, 65020.0 us = 2.02 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +chip SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +chip GPU add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 62518.3 us = 2.10 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip GPU add 1.0 from 0, no destination (RZ) x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 64690.4 us = 2.03 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip CONTROL integer ATOMG.ADD of 1.0f bits x 131072: word 0x00000000 = 0 (want 0x48000000, a no-op would leave 0x00000000), 131072 faults, 62054.2 us = 2.11 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) + control ok: the check caught the wrong arithmetic +GPU_ATOMF32_PROBE: PASS +== run 4 +sim SYS add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim SYS add -0.25 from 0 x 128: word 0xc2000000 = -32 (want 0xc2000000, a no-op would leave 0x00000000), 0 faults +sim SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +sim SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +sim GPU add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim GPU add 1.0 from 0, no destination (RZ) x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim CONTROL integer ATOMG.ADD of 1.0f bits x 128: word 0xc0000000 = -2 (want 0x43000000, a no-op would leave 0x00000000), 128 faults + control ok: the check caught the wrong arithmetic +chip SYS add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 63822.7 us = 2.05 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add -0.25 from 0 x 131072: word 0xc7000000 = -32768 (want 0xc7000000, a no-op would leave 0x00000000), 0 faults, 64916.0 us = 2.02 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +chip SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +chip GPU add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 63621.5 us = 2.06 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip GPU add 1.0 from 0, no destination (RZ) x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 63671.8 us = 2.06 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip CONTROL integer ATOMG.ADD of 1.0f bits x 131072: word 0x00000000 = 0 (want 0x48000000, a no-op would leave 0x00000000), 131072 faults, 64174.9 us = 2.04 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) + control ok: the check caught the wrong arithmetic +GPU_ATOMF32_PROBE: PASS +== run 5 +sim SYS add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim SYS add -0.25 from 0 x 128: word 0xc2000000 = -32 (want 0xc2000000, a no-op would leave 0x00000000), 0 faults +sim SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +sim SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +sim GPU add 1.0 from 0 x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim GPU add 1.0 from 0, no destination (RZ) x 128: word 0x43000000 = 128 (want 0x43000000, a no-op would leave 0x00000000), 0 faults +sim CONTROL integer ATOMG.ADD of 1.0f bits x 128: word 0xc0000000 = -2 (want 0x43000000, a no-op would leave 0x00000000), 128 faults + control ok: the check caught the wrong arithmetic +chip SYS add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 66878.0 us = 1.96 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add -0.25 from 0 x 131072: word 0xc7000000 = -32768 (want 0xc7000000, a no-op would leave 0x00000000), 0 faults, 64006.5 us = 2.05 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip SYS add 2^-125 to subnormal 2^-140 (FTZ) x 32: word 0x03800000 = 7.52316385e-37 (want 0x03800000, no-FTZ would be 0x03800008, a no-op would leave 0x00000200), 0 faults +chip SYS add 1.0 to 2^24+2 (round to nearest even) x 32: word 0x4b800002 = 16777220 (want 0x4b800002, a no-op would leave 0x4b800001), 0 faults +chip GPU add 1.0 from 0 x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 66554.9 us = 1.97 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip GPU add 1.0 from 0, no destination (RZ) x 131072: word 0x48000000 = 131072 (want 0x48000000, a no-op would leave 0x00000000), 0 faults, 63885.9 us = 2.05 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) +chip CONTROL integer ATOMG.ADD of 1.0f bits x 131072: word 0x00000000 = 0 (want 0x48000000, a no-op would leave 0x00000000), 131072 faults, 66583.1 us = 1.97 M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling) + control ok: the check caught the wrong arithmetic +GPU_ATOMF32_PROBE: PASS diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/README.md b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/README.md new file mode 100644 index 000000000..859aa4c14 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/README.md @@ -0,0 +1,84 @@ +# KT1 speed: why the ternary GEMV missed its bandwidth gates, and what the fix moved + +Follow-up to `../TERN-T0-KT1-18185404-20261016T0151Z/` (KT1 correct, 0 of 4 shapes at the cold bandwidth gate). +Investigation folder: `investigation/` (the plan with every prediction and verdict, the run scripts, every run +receipt; method `~/.claude/skills/investigate`, one variable per run, negative control before every speed run). + +Pins: omega d58a46a0 (branch tern/kt1-speed, clean: `device.txt`), physics 6d7cf0d4, driver 580.173.02, GB10. Every chip +run held the quiet flag (`quietlock hold --owner kt1-speed-fable`, windows of 6 to 10 minutes). +Script: `tools/run_gpu_tern_chip.sh base|red|main `, then five `gpu_tern_test --bw-only --reps 5` runs +(`receipt-cold-{1..5}.json`). Speeds are fractions of the physical limit (273 GB/s spec, 237.2 GB/s practical). + +## Cause, with evidence + +1. **Per-row 4-byte stores to GPU-uncached memory** (the main cost). A probe that parked the results in shared memory + instead of storing them (`investigation/probe-nostore-1.json`, results unchecked, diagnostic only) cut per-launch + time 25.1 -> 15.7 us at 3840x2560, 53.2 -> 42.0 at 13824x2560, 30.4 -> 25.1 at 2560x6912, 16.2 -> 13.5 at 2560x2560. + The lead came from a per-CTA timeline camera whose own 640 stamp stores slowed launches by 5 to 10 us + (`timeline-1` against `timeline-nostore-1`). +2. **The x round trip ran before any weight moved**: x staging took 2.3 to 3.2 us of every CTA (timeline camera), and a + probe that skipped the x load (`probe-nox-1.json`) saved 0.6 to 2.6 us. +3. **Not the GPU clock.** An in-kernel camera (SR_CLOCKLO against the global timer, `clockcam-1-cam.csv`) read about + 2560 MHz during every launch, including the 8x256 floor launches; nvidia-smi's 208 MHz is a slow sample that misses + microsecond bursts. Longer command lists did not change the fractions. Astra's clock-ramp lead is closed. + +## The fix (commit d58a46a0) + +Single-chunk kernels write each round's 2RW results into shared slots (two slot sets alternating by round, one CTA +barrier per round) and warp 0 stores the round with one coalesced STG. The warp's first unit's weight loads are issued +before the x load, which no longer waits for them; the K loop skips its loads once. Row-major weight loads use LDG.E +immediate offsets (the encoder's LDG.E.64/128 offset field, identical words when 0; simulator mirrors it), so the +register count stays at 54 peak / 56 declared. Host battery 56/56, simulator 34/34 (mutants 1, 2, 3 caught). + +## Verdicts + +| gate | result | receipt | +|---|---|---| +| KT1 bit-equal to `oma_rz_oracle`: 20,000 random rows, MA grid (49,932 rows), 4 BitNet shapes x 2 layouts | PASS, 0 rows differ of 115,500 | `receipt-main.json` | +| f32 q\|k\|v segments | PASS, 0 rows differ | `receipt-main.json` | +| Negative controls: mutants 1, 3, 2 forced | each exits FAIL | `receipt-red-mutant{1,3,2}.json` | +| Cold bandwidth, L2 defeated, floor taken out | 3 of 4 shapes PASS; 2560x2560 FAIL | `receipt-main.json`, `receipt-cold-{1..5}.json` | +| Word table, bf16 and FP8 GEMVs; launch floor; attention refusal | as before (PASS, PASS, recorded) | `receipt-table-*.json`, `receipt-launch-cost.json`, `receipt-attn-20-5.json` | + +Cold fractions of 237.2, in-list launch floor taken out (3.4 to 3.7 us). Before = the 18185404 receipt (main, repeats 2, 3). + +| shape | before | after: five cold runs | gate | +|---|---|---|---| +| 3840 x 2560 (q\|k\|v) | 0.480, 0.463, 0.504 | 0.820, 0.907, 0.899, 0.854, 0.822 | PASS (0.759) | +| 2560 x 2560 (o) | 0.540, 0.533, 0.574 | 0.722, 0.732, 0.717, 0.712, 0.705 | FAIL (0.759) | +| 13824 x 2560 (gate\|up) | 0.766, 0.744, 0.764 | 0.955, 0.952, 0.944, 0.969, 0.946 | PASS (0.843) | +| 2560 x 6912 (down) | 0.718, 0.715, 0.707 | 0.813, 0.768, 0.841, 0.851, 0.856 | PASS (0.759) | + +Store fix alone (prefetch not yet in): 0.816 / 0.687 / 0.933 / 0.738 (`investigation/fix-1.json`); the prefetch added +0.7 to 0.9 us per launch on three shapes and nothing at 2560x2560 (prediction P10 partly wrong, recorded in the plan). + +## Gate measurement: a proposal, not a change + +The present gate judges one launch with the in-list floor subtracted. At 2560x2560 that launch is a single burst +(1280 units over 1280 warps, every warp issues its ten loads at once); 9.7 us remain for 1.64 MB where the practical +limit needs 6.9 us, and the floor itself is 3.7 of 13.4 us. Real decode runs about 150 GEMVs back to back in one +command list, each one's x the previous output (GPU-produced, so it may live in GPU-cached memory), so the honest +figure is the time of that list. Proposal: a decode-like receipt, 150 launches in layer order (q|k|v, o, gate|up, +down) with weights rotated past L2, timed as one list and stated as bytes moved over list time against 237.2, floor +counted (in a dependent chain the floor is real cost), beside the design-doc end-to-end gate of 170 tok/s. The +180 / 200 GB/s single-launch thresholds stay as they are until that receipt exists; this folder does not move them. + +## UNKNOWN + +- The 2.8 us left at 2560x2560 (1.3 us at 3840, 1.8 us at 13824): mechanism not identified (one-burst fill and drain, + first-touch translation, or other). Removing the x round trip did not move it. +- 2560 x 6912 runs in waves (CTA start spread about 20 us in the timeline camera; shared 13.9 KB per CTA) and swings + 0.77 to 0.86 between runs. The launch descriptor's SM shared-memory carveout fields (word 36, kept from a captured + descriptor) were not touched; the documentation for them was not read. Next variable, not this PR. +- Resident CTA capacity and SM count were not measured; the 16x-list camera run failed its oracle check (cause not found). +- Why uncached 4-byte stores cost 9 to 11 us per launch (measured, mechanism not). + +## Added after review (omega#490) + +- `investigation/clockcam-1-cam.csv`: the in-kernel clock camera's raw stamps (SR_CLOCKLO against the global timer per + CTA), the 2560 MHz evidence behind the closed clock lead. +- The warp simulator now visits warps in a chosen order per barrier phase (ascending, descending, or a seeded shuffle; + `WsSim.warp_sched`). Test mutant 4 (one output slot set) is hidden by the ascending order and caught by the other two + (30 and 18 rows wrong of 64); test mutant 5 (no unit clamp) is refused on a partial last round with two K iterations. + `make test-gpu-tern` (host battery plus simulator, no chip) runs in the smoke workflow. +- `SHA256SUMS`: every file in this folder. diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/SHA256SUMS b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/SHA256SUMS new file mode 100644 index 000000000..b8a932de8 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/SHA256SUMS @@ -0,0 +1,141 @@ +960e9944634a3f5ea43f85a0e2f5f25366dce174acfb8c55e53f0dd7e74f470a ./attn-20-5.log +bbc78a8b9f9c722b4a8f579b8ceb60a59ae5c04a33e1f4884d4aab02ab70e00e ./build-base.log +bbc78a8b9f9c722b4a8f579b8ceb60a59ae5c04a33e1f4884d4aab02ab70e00e ./build-main.log +bbc78a8b9f9c722b4a8f579b8ceb60a59ae5c04a33e1f4884d4aab02ab70e00e ./build-red.log +40c451583fb0b0e519c5a604631ba6661f2943126283ee991ac6f1b923f5db8a ./cold-1.log +64496e6bfe38a066bed842961d0f7c4b2c6b54e32ae783983c9e33a0cead4f78 ./cold-2.log +5a55724c6e7c27311e23f0a50395fbbe6c1cceef652f502d9be264122ce17889 ./cold-3.log +d3a1e8490d8a7c4694e91841aa3e765be91cea62beb4b5ca720c60905ffc3db4 ./cold-4.log +4e12bc6b564af360992e51c6b32bf73c9ba01228626c6e9d8fb52304c49c7ac0 ./cold-5.log +0a3caa290de2055f9d6e1f1af0bef60ba1d430c99af401085b792230ced35c35 ./device.txt +2cb9e8adff61b26a1d4cfec2934e019059c22b4802897f945f4c50a6482608fe ./host-only.log +4fd6959376803f936311aa12d59e4999182c5a05cfa4149f5622b9484f29946c ./investigation/baseline-1.json +053dd4e26d346048c54808104e48999bde7af2ab3c7f6cb5065e96079228a75c ./investigation/baseline-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/baseline-1-negative.json +415a356c39f77b8d50490624ff3c4d995d36369c91b7267796bf4c1487c66e5c ./investigation/baseline-2.json +fcd45a185760939f3a1ef5c470650f5430bb45f4ff75828b266fd8bb2fde8874 ./investigation/baseline-2.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/baseline-2-negative.json +6bf4e4258f670ec9590769f0e87f1f8ade8b750597231ab28de7ff7ae42c3aaf ./investigation/baseline-3.json +466b92f0abf60df9f1e2bf5c4c46b7b980cc9cc6506fb877667a660e82374762 ./investigation/baseline-3.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/baseline-3-negative.json +8fd99402b5c5dcc3c8c0c911cb075d41e2c879928a800756709ea6b3340c0d30 ./investigation/baseline-4.json +8df44b9e96b3def8671725907902e64a6e8c84073f02c03966f051d768c87d0f ./investigation/baseline-4.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/baseline-4-negative.json +d4312db6c9e08cde43c86b7d51626ff14f4b7ea517142e6116db428588d7f3a4 ./investigation/baseline-5.json +1542777627b7c4844c9a1c0422611cef0eed44143a5701b1f84b7cddfa895bca ./investigation/baseline-5.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/baseline-5-negative.json +62f0d0ff608358b2cd8aa9e0ca6df2c4efd3ca8c2c5db21ce50fc8922d8437eb ./investigation/baseline-6.json +57b62ca1f7b7ef391e7abea17d3d0f79cf902c08a89240dd095109d0900eab46 ./investigation/baseline-6.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/baseline-6-negative.json +b9249a4ac6fee48fbbec1e4130577ebbf333feb90ff45ce1dab89d6a562120ab ./investigation/block-4.json +41565d5dd02e29284f0db056516e4b40ef8fdf75a0412133a3ea5e6788075414 ./investigation/block-4.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/block-4-negative.json +8b9ae0e6731e4ba3e54f88655ea1bf00c8beb6e245466862452151bcffa81e6e ./investigation/clockcam-1-cam.csv +2533abc9ff263d10a67950fffbdeb134916f7419c0af703a389c21701968d80f ./investigation/clockcam-1.json +dd752474cdf5382dde7dc7f080a4307435e95a78e7801d5bab7bdafd502ff69f ./investigation/clockcam-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/clockcam-1-negative.json +933caf4b354995577f4edfba1b065637bc93ddb1ed67197d69a75a0a9c7667e3 ./investigation/clockcam-m16.json +685ec35d15d502ba39b584c795e04e0a3704116fe08850f4bfb3023e9b7e0dfb ./investigation/clockcam-m16.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/clockcam-m16-negative.json +c4d46e9cd6d10fd3b666ce41c75311f6fa8319323d738a1a918a5780098765d1 ./investigation/ctas-240.json +33a4e965aa53687bc586eb68bbecde9f695ec6a2c956f5280444680080578c9d ./investigation/ctas-240.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/ctas-240-negative.json +d4fce6a8fc858eee38b2e7447c598d81d53c7db99784c0205cc9a140483aabb7 ./investigation/ctas-320.json +9e5228e0e7e26d4cd368b350afcc6d53937d17f3de8e068225047646b1dbd4bf ./investigation/ctas-320.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/ctas-320-negative.json +2fa330cea91b45e4608c7ede56139c66161825f81aecdb5a31764e985f2f1b63 ./investigation/ctas-640.json +f71876af39ef842339158d6e3ef8d55b67ff60f025f90a9da69726171e60daf3 ./investigation/ctas-640.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/ctas-640-negative.json +ea042ac97f34b0105ecfd522a392824a19bee760168be4f195d0a7ef1cf81692 ./investigation/ctas-96.json +0c5141a6d8c3134abd8be112b222ce32ae44e62de6715cddfa6e37628d09e911 ./investigation/ctas-96.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/ctas-96-negative.json +8dd2399c7ee5691b72ac466f2926a7c062ee33a6f6264f747b0734da9bf8cc2b ./investigation/depth-1.json +80b3fc06880b3693d2c9cae4eabf25e0d316da33fc22f6abfa7d5fc8cc6ce7a7 ./investigation/depth-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/depth-1-negative.json +03ec5c6c24f9c43c6bc1062423bec549d347b1a9b6040489dac8d3fe557abcfc ./investigation/depth-2.json +3d94def8020b62d9aff5c912a47cc297809fc005005354b9d0eae0fea0bc4aac ./investigation/depth-2.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/depth-2-negative.json +5fd39c502668c9eb50dd88620b0befcfbb1e193927a38e0457cc0e6e5a765812 ./investigation/depth-3.json +f97cc78fb8b439090420873e2667148b762927f22e9f2eaf96fb7779bc68d297 ./investigation/depth-3.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/depth-3-negative.json +101bcfa674aa821fca538bfb8b73677b15cc85b93c3bf5f0215f83c75b091f1c ./investigation/depth-4.json +44c35b1e7f08f99c8cf15a4136a660a83862a912c0929bf73f0a05372e84f00f ./investigation/depth-4.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/depth-4-negative.json +57110008888e5b1b543b095a4f3565b8d1f0e867bd5be0e5e6f924f3027af74b ./investigation/depth-5.json +60f244dc18c85f04277964ecb179c9a61942040112bb84071c39a28815a58e72 ./investigation/depth-5.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/depth-5-negative.json +24001f874a2e1799f2c5b8831bf6ee5c82f37475be3cab1a8ad9df891fd80e0a ./investigation/fix-1.json +b7e4550e7084d2a5c42a02d91994ce181759e253fbb1201bf2a9cce35aed3de8 ./investigation/fix-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/fix-1-negative.json +6a8df864e4551a5f0f078e6702cabe0db0dc843d2b3739128b96e82fb0d134cc ./investigation/fix2-1.json +6e5cbc491ea45aa7a443c80e859d277f6036c624695c3b87fac3584e025ad574 ./investigation/fix2-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/fix2-1-negative.json +e8276746ac9d837764264991f3ae7fd7fa7d2ae5a0548381c3d058fcc8d82c17 ./investigation/hot-baseline.json +0bf0f81b3984cd40a5998338a3ae8bbaf32ede121132f9db3b7831c0961f2ff1 ./investigation/hot-baseline.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/hot-baseline-negative.json +aa9197672ac832aaa5301c55674b3171ce49562bef310ff3ae7b4d4e3c81e831 ./investigation/load-probe-1.json +f0c855773b41c4d3bb11df810199597ec8cca6b0b72976d2589f4dbada3ab9b3 ./investigation/load-probe-1.meta +67e53b7552d2809b3058ad48470b1137942bfbc9fa0cc77ecadf070e70413be3 ./investigation/load-probe-1-negative.json +a825eae55ffb70a7f1ebace4bb596a00a669876cf0dac79e09c062c1f2e204f4 ./investigation/no-readwait-1.json +41cc5f23d396281c6210efac5474e54d5e48f5a19d6ab5b0ef31c0186bebab74 ./investigation/no-readwait-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/no-readwait-1-negative.json +0d14693aff90ddabe230e534cb5f7a055913256ee33bdc9ed2f51624d844266f ./investigation/no-readwait-hot.json +746b6226b3f58e25e4e7cbda1c03ff5fd27c89e97af5413d520e12790f475acb ./investigation/no-readwait-hot.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/no-readwait-hot-negative.json +f44c90e6df2fae45d38a8250f70e34e87f1bf8cd75eebca7e212e2328238b5c1 ./investigation/plan.md +8f81df78535cc4608704d96de67e7ba2317d429767de9cb2441f9528d8258cfc ./investigation/prefetch-dirty-tree-main.log +a49080609433fbfc7bd7adb0e78d78b7c5f3a9780e3e193624dc3dc5b51c4b4a ./investigation/probe-nostore-1.json +7de35e00c340d15e192f8acc113959ab154cd130b694c63b6b8e4485cd31e46d ./investigation/probe-nostore-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/probe-nostore-1-negative.json +13aba8663d70c3ec478129e62c7ed69352738edea38961f1b159965bd02ae68e ./investigation/probe-nox-1.json +7a8532d2e7d86adcd0f8f81b2b1f40785600d097b7e36a66cc10e7903b9f255d ./investigation/probe-nox-1.meta +f78b053e3aeb08a7b5289b088afbdb990010ce977565ca097941b4ccc96e424e ./investigation/probe-nox-1-negative.json +034c2d3107fab50638949ceca3f3179192cd4fddd21bc5b3b36856158f326742 ./investigation/rows-2.json +037ab23adafa19b621080ef31b4b3bfa7bbf444b223197c2a5c280669d9f11ee ./investigation/rows-2.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/rows-2-negative.json +e67004d584e7226a9720692542cf89c7aeea41cb5474fea5c447d8e0bbeead25 ./investigation/run-cam.sh +5b803ea28476c681d558c2884517e3695c246732b956460f1386a0b9d24ac1f5 ./investigation/run-one.sh +42dae031d30e2be5484b44020e8d58d5744b609ac7888acf31307888b48ead0f ./investigation/shared-output-1.json +db8f1671abed92c129fe78502983cbfdbced0ddc39be0b3df8b39c21062e8cc9 ./investigation/shared-output-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/shared-output-1-negative.json +ae7bed9e3d7e734a63029051ccd5c0161cd3fc10ef1c8bd629d7d303a9259cff ./investigation/stamps-1.json +30576aa478e9092a75a8e798609a0e3346f6953d402cf622cc974161633f4039 ./investigation/stamps-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/stamps-1-negative.json +4ebbdbe05389a9c582f784308ae5edbe0e5b3cd328341b985754ce9f1395fbaa ./investigation/store-fix-only-main.log +40be1ddc247802fa985700515f095572ccf79266ec299ebb9fca9b206ae130ab ./investigation/timeline-1.json +d6edd639658565d8bf1b8963608820717be2a622acaa655afaa33e44c7499d3f ./investigation/timeline-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/timeline-1-negative.json +5c7bb0ed144599d0e0a0b32ae27672421bd812a6038dd4c32e7dbe19d83ff4a0 ./investigation/timeline-hot.json +c3d05bd3ef8f16f0d601554501742bea397e215d8fde803bac2016932437459c ./investigation/timeline-hot.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/timeline-hot-negative.json +3fc0fa018efaa529eb399dd58b5fb29441e6cfdd8b7bb1fa7626536ee41d6e3b ./investigation/timeline-nostore-1.json +5e85f7417bed4e017d0af040c094c70966a41f5c2e9e18039c10ee7050ae6ab1 ./investigation/timeline-nostore-1.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/timeline-nostore-1-negative.json +b5a2ac0aff9a549a2db15e14ade7409082762985125430e07baa32078765a486 ./investigation/warps-16.json +362288892b16968a3d9b98c4ea72ba87196cc3c4aa51e9488c8bc3cd58eb173f ./investigation/warps-16.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/warps-16-negative.json +790709839dae14ab0ab33e7f9a9e1532681551e5a29666a1da5ab525b1a4da3a ./investigation/warps-4.json +86ca8903258a2c893a3c7ea416f1a93c607d99b38a2ce6fe9cb8181d4ac78aeb ./investigation/warps-4.meta +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./investigation/warps-4-negative.json +b8d397bd7c5587f1b860f9dd4d102ece4ddc6f18e6ca156face5a18173ed90fe ./launch-cost.log +cbde8ae6e1d197ce247bce7c97c024cfd5304d094c81415441e25870455fe69c ./main.log +f48478852934c8dc6bb0d4d01fce6189423f5515bee726e144c9411606df3a77 ./README.md +818cc3d21793406ecdec335f951568f423403f3ac63581d9b93d1c2dc68d1c8c ./receipt-attn-20-5.json +f249761b0dfb685b0b3610f9c09e1bdebbfec175a7a99a7cb1fbd55067ed299f ./receipt-cold-1.json +e109072923ca46d40b12e01aeb850f307650de5f626be18b5a85266d4303c7ce ./receipt-cold-2.json +15031af0fb3b7efe432ac8921c9ddc9d0fddf05a6b3663927883cd165f42f4b6 ./receipt-cold-3.json +aad78c8b7d897584fc063680f05f181685f27bb5811648c8dc34197edf6e9b0e ./receipt-cold-4.json +8ebee506886e7ee203887e29a77ffacc2be57e215bd4fc23455b3ca34b774ba0 ./receipt-cold-5.json +2a5f4a5b78838d7b317177dc7d9c6ccce48d8a836d497f5db0b749938b75b699 ./receipt-launch-cost.json +7ae3ad7daec0bc4ccd86074a04793ba45e7c210d3465a7d8f5dda43341ff6d81 ./receipt-main.json +4a59ab69dcc471be6edffe1259a841524979c346cd11f916d242b005e6e8217e ./receipt-red-mutant1.json +0392aa7a526354865398e8c905ab762150443bee7fae08d0d067bceb8cd03089 ./receipt-red-mutant2.json +cd375745ef7a42726d9ea816be42776d178ede95b58373950f27ff67e90b1895 ./receipt-red-mutant3.json +0a3ec90c2bdb0018ae4e5a7ebbcb93f6b430110d3eaf04033d6c9c79ebebb05e ./receipt-table-bf16.json +eb6bf964c1672a85b4317541318eaa2dc676fc361fbdae874a89e20a40356ac4 ./receipt-table-fp8.json +0508ca04ffca29492af93bd4912bfeab04f5e6011b3dc9f7dab4564878d3d45f ./red-mutant1.log +8f769e56517a5587c32cfe4cda7416c8db95a20a6a1148346f4b0dea5694928b ./red-mutant2.log +2ed8785238df7175d6661d1162a35e42d41bcc8aad26d76b1a076546b0e061d9 ./red-mutant3.log +0fc0a25356f76257cb0ad1b92061eca1ff05afa5225e4d3438d0a7e3d3ec453f ./sim.log +3d69045c918bb18218644dd0bc372edffd01ba33dc31d2d0d5fd7b56c25aa99b ./table-bf16.log +216f1f44e839a9e07df1e8104eaa7d21b41bd8e58cf6b3bdf51e1573308859e2 ./table-fp8.log diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/attn-20-5.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/attn-20-5.log new file mode 100644 index 000000000..670672c51 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/attn-20-5.log @@ -0,0 +1,7 @@ +REFUSED: decode attention at 20 query / 5 KV heads, head dim 128 + reason 1: head layout fixed at 32 query / 4 KV heads (8 per KV head); asked 20 / 5 (4 per KV head) + reason 2: fused q|k|v input fixed at 5120 words; the asked layout needs 3840 + reason 3: per-head q_norm / k_norm is built in (Qwen3); a model without QK norm needs a kernel without it + needed: a decode attention kernel for this geometry (ternary engine design KT3) +gpu_decode_attn_test: REFUSED (geometry 20/5/128 not built) +attn-20-5 exit 3 (3 = recorded refusal) diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-base.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-base.log new file mode 100644 index 000000000..49b68201b --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-base.log @@ -0,0 +1,4 @@ +make: 'build/gpu_bf16_gemv_test' is up to date. +make: 'build/gpu_fp8_api_test' is up to date. +make: 'build/gpu_decode_attn_test' is up to date. +make: 'build/gpu_launch_cost_test' is up to date. diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-main.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-main.log new file mode 100644 index 000000000..49b68201b --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-main.log @@ -0,0 +1,4 @@ +make: 'build/gpu_bf16_gemv_test' is up to date. +make: 'build/gpu_fp8_api_test' is up to date. +make: 'build/gpu_decode_attn_test' is up to date. +make: 'build/gpu_launch_cost_test' is up to date. diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-red.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-red.log new file mode 100644 index 000000000..49b68201b --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/build-red.log @@ -0,0 +1,4 @@ +make: 'build/gpu_bf16_gemv_test' is up to date. +make: 'build/gpu_fp8_api_test' is up to date. +make: 'build/gpu_decode_attn_test' is up to date. +make: 'build/gpu_launch_cost_test' is up to date. diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-1.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-1.log new file mode 100644 index 000000000..8fb4558a2 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-1.log @@ -0,0 +1,8 @@ +chip: in-list launch floor (8 x 256, 512 B) median 3.68 us, min 3.49 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 16.32 us per launch -> 150.6 GB/s = 0.552 of 273 spec, 0.635 of 237.2 practical; minus the launch floor 12.64 us -> 194.4 GB/s (0.820 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 13.25 us per launch -> 123.7 GB/s = 0.453 of 273 spec, 0.521 of 237.2 practical; minus the launch floor 9.57 us -> 171.2 GB/s (0.722 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 171.2 (123.7 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 42.72 us per launch -> 207.1 GB/s = 0.759 of 273 spec, 0.873 of 237.2 practical; minus the launch floor 39.04 us -> 226.6 GB/s (0.955 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 26.62 us per launch -> 166.2 GB/s = 0.609 of 273 spec, 0.700 of 237.2 practical; minus the launch floor 22.94 us -> 192.8 GB/s (0.813 of 237.2) +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-1.json +gpu_tern_test: 9 checks, 1 failed: FAIL diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-2.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-2.log new file mode 100644 index 000000000..7d66730c6 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-2.log @@ -0,0 +1,8 @@ +chip: in-list launch floor (8 x 256, 512 B) median 3.84 us, min 3.46 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 15.26 us per launch -> 161.0 GB/s = 0.590 of 273 spec, 0.679 of 237.2 practical; minus the launch floor 11.42 us -> 215.1 GB/s (0.907 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 13.28 us per launch -> 123.4 GB/s = 0.452 of 273 spec, 0.520 of 237.2 practical; minus the launch floor 9.44 us -> 173.6 GB/s (0.732 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 173.6 (123.4 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 43.04 us per launch -> 205.6 GB/s = 0.753 of 273 spec, 0.867 of 237.2 practical; minus the launch floor 39.20 us -> 225.7 GB/s (0.952 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 28.13 us per launch -> 157.3 GB/s = 0.576 of 273 spec, 0.663 of 237.2 practical; minus the launch floor 24.29 us -> 182.1 GB/s (0.768 of 237.2) +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-2.json +gpu_tern_test: 9 checks, 1 failed: FAIL diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-3.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-3.log new file mode 100644 index 000000000..c3e763c0d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-3.log @@ -0,0 +1,8 @@ +chip: in-list launch floor (8 x 256, 512 B) median 3.71 us, min 3.42 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 15.23 us per launch -> 161.3 GB/s = 0.591 of 273 spec, 0.680 of 237.2 practical; minus the launch floor 11.52 us -> 213.3 GB/s (0.899 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 13.34 us per launch -> 122.8 GB/s = 0.450 of 273 spec, 0.518 of 237.2 practical; minus the launch floor 9.63 us -> 170.1 GB/s (0.717 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 170.1 (122.8 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 43.23 us per launch -> 204.6 GB/s = 0.750 of 273 spec, 0.863 of 237.2 practical; minus the launch floor 39.52 us -> 223.9 GB/s (0.944 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 25.89 us per launch -> 170.9 GB/s = 0.626 of 273 spec, 0.720 of 237.2 practical; minus the launch floor 22.18 us -> 199.5 GB/s (0.841 of 237.2) +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-3.json +gpu_tern_test: 9 checks, 1 failed: FAIL diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-4.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-4.log new file mode 100644 index 000000000..ceb02a0ce --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-4.log @@ -0,0 +1,8 @@ +chip: in-list launch floor (8 x 256, 512 B) median 3.62 us, min 3.39 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 15.74 us per launch -> 156.1 GB/s = 0.572 of 273 spec, 0.658 of 237.2 practical; minus the launch floor 12.13 us -> 202.6 GB/s (0.854 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 13.31 us per launch -> 123.1 GB/s = 0.451 of 273 spec, 0.519 of 237.2 practical; minus the launch floor 9.70 us -> 169.0 GB/s (0.712 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 169.0 (123.1 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 42.11 us per launch -> 210.1 GB/s = 0.770 of 273 spec, 0.886 of 237.2 practical; minus the launch floor 38.50 us -> 229.8 GB/s (0.969 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 25.54 us per launch -> 173.2 GB/s = 0.635 of 273 spec, 0.730 of 237.2 practical; minus the launch floor 21.92 us -> 201.8 GB/s (0.851 of 237.2) +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-4.json +gpu_tern_test: 9 checks, 1 failed: FAIL diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-5.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-5.log new file mode 100644 index 000000000..e4a954092 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/cold-5.log @@ -0,0 +1,8 @@ +chip: in-list launch floor (8 x 256, 512 B) median 3.58 us, min 3.46 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 16.19 us per launch -> 151.8 GB/s = 0.556 of 273 spec, 0.640 of 237.2 practical; minus the launch floor 12.61 us -> 194.9 GB/s (0.822 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 13.38 us per launch -> 122.5 GB/s = 0.449 of 273 spec, 0.516 of 237.2 practical; minus the launch floor 9.79 us -> 167.3 GB/s (0.705 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 167.3 (122.5 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 43.01 us per launch -> 205.7 GB/s = 0.754 of 273 spec, 0.867 of 237.2 practical; minus the launch floor 39.42 us -> 224.4 GB/s (0.946 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 25.38 us per launch -> 174.3 GB/s = 0.639 of 273 spec, 0.735 of 237.2 practical; minus the launch floor 21.79 us -> 203.0 GB/s (0.856 of 237.2) +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-5.json +gpu_tern_test: 9 checks, 1 failed: FAIL diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/device.txt b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/device.txt new file mode 100644 index 000000000..897f53fb5 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/device.txt @@ -0,0 +1,12 @@ +phase base start 2026-10-16T03:05:15Z omega=d58a46a0ae0efb7a2ad496fd1528418d23925b54 branch=tern/kt1-speed dirty=0 physics=/home/drakestapleton/workspace/physics-own30b-k physics_commit=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf +7.0.0-1019-nvidia +NVIDIA GB10, 580.173.02 +phase base end 2026-10-16T03:05:24Z +phase red start 2026-10-16T03:05:24Z omega=d58a46a0ae0efb7a2ad496fd1528418d23925b54 branch=tern/kt1-speed dirty=0 physics=/home/drakestapleton/workspace/physics-own30b-k physics_commit=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf +7.0.0-1019-nvidia +NVIDIA GB10, 580.173.02 +phase red end 2026-10-16T03:05:30Z +phase main start 2026-10-16T03:05:30Z omega=d58a46a0ae0efb7a2ad496fd1528418d23925b54 branch=tern/kt1-speed dirty=0 physics=/home/drakestapleton/workspace/physics-own30b-k physics_commit=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf +7.0.0-1019-nvidia +NVIDIA GB10, 580.173.02 +phase main end 2026-10-16T03:05:34Z diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/host-only.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/host-only.log new file mode 100644 index 000000000..fe430b7fe --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/host-only.log @@ -0,0 +1,22 @@ +host: word arithmetic exact on 434000 words (random, all +1, all -1; x random, -128, 127, -1, 0, alternating) +host: codegen k 2560 layout rowmajor epi i32 rows 1 depth 10 warps 8: 676 instructions, peak 54 registers (declared 56), shared 5248 B +host: stall distances >= 6 cycles hold; 2323 stall cycles in program order; shortened-stall control caught +host: codegen k 2560 layout rowmajor epi f32 rows 1 depth 10 warps 8: 697 instructions, peak 61 registers (declared 64), shared 5248 B +host: stall distances >= 6 cycles hold; 2416 stall cycles in program order; shortened-stall control caught +host: codegen k 2560 layout block epi i32 rows 4 depth 2 warps 8: 589 instructions, peak 70 registers (declared 72), shared 5120 B +host: stall distances >= 6 cycles hold; 1504 stall cycles in program order; shortened-stall control caught +host: codegen k 2560 layout block epi f32 rows 4 depth 2 warps 8: 651 instructions, peak 76 registers (declared 80), shared 5120 B +host: stall distances >= 6 cycles hold; 1796 stall cycles in program order; shortened-stall control caught +host: codegen k 6912 layout rowmajor epi i32 rows 1 depth 9 warps 8: 629 instructions, peak 53 registers (declared 56), shared 13952 B +host: stall distances >= 6 cycles hold; 2184 stall cycles in program order; shortened-stall control caught +host: codegen k 6912 layout rowmajor epi f32 rows 1 depth 9 warps 8: 650 instructions, peak 60 registers (declared 64), shared 13952 B +host: stall distances >= 6 cycles hold; 2277 stall cycles in program order; shortened-stall control caught +host: codegen k 6912 layout block epi i32 rows 4 depth 3 warps 8: 765 instructions, peak 82 registers (declared 88), shared 13824 B +host: stall distances >= 6 cycles hold; 1708 stall cycles in program order; shortened-stall control caught +host: codegen k 6912 layout block epi f32 rows 4 depth 3 warps 8: 827 instructions, peak 88 registers (declared 96), shared 13824 B +host: stall distances >= 6 cycles hold; 2000 stall cycles in program order; shortened-stall control caught +host: codegen k 16384 layout rowmajor epi i32 rows 1 depth 16 warps 8: 912 instructions, peak 57 registers (declared 64), shared 16384 B +host: stall distances >= 6 cycles hold; 2972 stall cycles in program order; shortened-stall control caught +host: codegen k 16384 layout block epi i32 rows 4 depth 4 warps 8: 942 instructions, peak 99 registers (declared 104), shared 16384 B +host: stall distances >= 6 cycles hold; 1930 stall cycles in program order; shortened-stall control caught +gpu_tern_test: 56 checks, 0 failed: PASS diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1.json new file mode 100644 index 000000000..1c0904df2 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.168}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 25280, "min_ns": 20000, "gbs": 97.22, "of_spec_273": 0.3561, "of_practical_237_2": 0.4098, "minus_floor_ns": 21856, "minus_floor_gbs": 112.45, "minus_floor_of_spec_273": 0.4119, "minus_floor_of_practical_237_2": 0.4741, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16192, "min_ns": 14048, "gbs": 101.19, "of_spec_273": 0.3706, "of_practical_237_2": 0.4266, "minus_floor_ns": 12768, "minus_floor_gbs": 128.32, "minus_floor_of_spec_273": 0.4700, "minus_floor_of_practical_237_2": 0.5410, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 53216, "min_ns": 33504, "gbs": 166.25, "of_spec_273": 0.6090, "of_practical_237_2": 0.7009, "minus_floor_ns": 49792, "minus_floor_gbs": 177.69, "minus_floor_of_spec_273": 0.6509, "minus_floor_of_practical_237_2": 0.7491, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 30400, "min_ns": 25568, "gbs": 145.52, "of_spec_273": 0.5330, "of_practical_237_2": 0.6135, "minus_floor_ns": 26976, "minus_floor_gbs": 163.99, "minus_floor_of_spec_273": 0.6007, "minus_floor_of_practical_237_2": 0.6913, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1.meta new file mode 100644 index 000000000..35684910c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:09:55Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 39, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2.json new file mode 100644 index 000000000..4572e2ff4 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.488, "min_us": 3.264}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 26080, "min_ns": 21888, "gbs": 94.23, "of_spec_273": 0.3452, "of_practical_237_2": 0.3973, "minus_floor_ns": 22592, "minus_floor_gbs": 108.78, "minus_floor_of_spec_273": 0.3985, "minus_floor_of_practical_237_2": 0.4586, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15744, "min_ns": 13728, "gbs": 104.07, "of_spec_273": 0.3812, "of_practical_237_2": 0.4387, "minus_floor_ns": 12256, "minus_floor_gbs": 133.68, "minus_floor_of_spec_273": 0.4897, "minus_floor_of_practical_237_2": 0.5636, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 52864, "min_ns": 50144, "gbs": 167.36, "of_spec_273": 0.6130, "of_practical_237_2": 0.7056, "minus_floor_ns": 49376, "minus_floor_gbs": 179.18, "minus_floor_of_spec_273": 0.6563, "minus_floor_of_practical_237_2": 0.7554, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 30912, "min_ns": 28256, "gbs": 143.11, "of_spec_273": 0.5242, "of_practical_237_2": 0.6033, "minus_floor_ns": 27424, "minus_floor_gbs": 161.31, "minus_floor_of_spec_273": 0.5909, "minus_floor_of_practical_237_2": 0.6800, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2.meta new file mode 100644 index 000000000..a54cf83c8 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-2.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:20Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +279 MHz, [N/A], 40, 37 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3.json new file mode 100644 index 000000000..2248c4b30 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.392, "min_us": 3.168}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24864, "min_ns": 19392, "gbs": 98.84, "of_spec_273": 0.3621, "of_practical_237_2": 0.4167, "minus_floor_ns": 21472, "minus_floor_gbs": 114.46, "minus_floor_of_spec_273": 0.4193, "minus_floor_of_practical_237_2": 0.4825, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16128, "min_ns": 13856, "gbs": 101.59, "of_spec_273": 0.3721, "of_practical_237_2": 0.4283, "minus_floor_ns": 12736, "minus_floor_gbs": 128.64, "minus_floor_of_spec_273": 0.4712, "minus_floor_of_practical_237_2": 0.5423, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 53536, "min_ns": 37792, "gbs": 165.26, "of_spec_273": 0.6053, "of_practical_237_2": 0.6967, "minus_floor_ns": 50144, "minus_floor_gbs": 176.44, "minus_floor_of_spec_273": 0.6463, "minus_floor_of_practical_237_2": 0.7438, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29728, "min_ns": 25312, "gbs": 148.81, "of_spec_273": 0.5451, "of_practical_237_2": 0.6273, "minus_floor_ns": 26336, "minus_floor_gbs": 167.97, "minus_floor_of_spec_273": 0.6153, "minus_floor_of_practical_237_2": 0.7081, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3.meta new file mode 100644 index 000000000..529f3946d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-3.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:22Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +643 MHz, [N/A], 41, 69 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4.json new file mode 100644 index 000000000..6c9cac98d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.264}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 25248, "min_ns": 20320, "gbs": 97.34, "of_spec_273": 0.3566, "of_practical_237_2": 0.4104, "minus_floor_ns": 21824, "minus_floor_gbs": 112.61, "minus_floor_of_spec_273": 0.4125, "minus_floor_of_practical_237_2": 0.4747, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16576, "min_ns": 14688, "gbs": 98.84, "of_spec_273": 0.3621, "of_practical_237_2": 0.4167, "minus_floor_ns": 13152, "minus_floor_gbs": 124.57, "minus_floor_of_spec_273": 0.4563, "minus_floor_of_practical_237_2": 0.5252, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 55680, "min_ns": 41888, "gbs": 158.90, "of_spec_273": 0.5820, "of_practical_237_2": 0.6699, "minus_floor_ns": 52256, "minus_floor_gbs": 169.31, "minus_floor_of_spec_273": 0.6202, "minus_floor_of_practical_237_2": 0.7138, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29952, "min_ns": 28416, "gbs": 147.69, "of_spec_273": 0.5410, "of_practical_237_2": 0.6226, "minus_floor_ns": 26528, "minus_floor_gbs": 166.76, "minus_floor_of_spec_273": 0.6108, "minus_floor_of_practical_237_2": 0.7030, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4.meta new file mode 100644 index 000000000..27aeea3f1 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-4.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:24Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +1313 MHz, [N/A], 42, 54 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5.json new file mode 100644 index 000000000..dc1674f62 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.616, "min_us": 3.104}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 25088, "min_ns": 20768, "gbs": 97.96, "of_spec_273": 0.3588, "of_practical_237_2": 0.4130, "minus_floor_ns": 21472, "minus_floor_gbs": 114.46, "minus_floor_of_spec_273": 0.4193, "minus_floor_of_practical_237_2": 0.4825, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16416, "min_ns": 14176, "gbs": 99.81, "of_spec_273": 0.3656, "of_practical_237_2": 0.4208, "minus_floor_ns": 12800, "minus_floor_gbs": 128.00, "minus_floor_of_spec_273": 0.4689, "minus_floor_of_practical_237_2": 0.5396, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 54112, "min_ns": 47296, "gbs": 163.50, "of_spec_273": 0.5989, "of_practical_237_2": 0.6893, "minus_floor_ns": 50496, "minus_floor_gbs": 175.21, "minus_floor_of_spec_273": 0.6418, "minus_floor_of_practical_237_2": 0.7387, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 31104, "min_ns": 26496, "gbs": 142.22, "of_spec_273": 0.5210, "of_practical_237_2": 0.5996, "minus_floor_ns": 27488, "minus_floor_gbs": 160.93, "minus_floor_of_spec_273": 0.5895, "minus_floor_of_practical_237_2": 0.6785, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5.meta new file mode 100644 index 000000000..0da48c2f3 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-5.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:26Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +1202 MHz, [N/A], 40, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6.json new file mode 100644 index 000000000..c1dcb0690 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24416, "min_ns": 20448, "gbs": 100.66, "of_spec_273": 0.3687, "of_practical_237_2": 0.4243, "minus_floor_ns": 20992, "minus_floor_gbs": 117.07, "minus_floor_of_spec_273": 0.4288, "minus_floor_of_practical_237_2": 0.4936, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16192, "min_ns": 13536, "gbs": 101.19, "of_spec_273": 0.3706, "of_practical_237_2": 0.4266, "minus_floor_ns": 12768, "minus_floor_gbs": 128.32, "minus_floor_of_spec_273": 0.4700, "minus_floor_of_practical_237_2": 0.5410, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 53760, "min_ns": 32928, "gbs": 164.57, "of_spec_273": 0.6028, "of_practical_237_2": 0.6938, "minus_floor_ns": 50336, "minus_floor_gbs": 175.77, "minus_floor_of_spec_273": 0.6438, "minus_floor_of_practical_237_2": 0.7410, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29984, "min_ns": 24544, "gbs": 147.53, "of_spec_273": 0.5404, "of_practical_237_2": 0.6220, "minus_floor_ns": 26560, "minus_floor_gbs": 166.55, "minus_floor_of_spec_273": 0.6101, "minus_floor_of_practical_237_2": 0.7022, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6.meta new file mode 100644 index 000000000..936f1f06a --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/baseline-6.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:23Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 37, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4.json new file mode 100644 index 000000000..36c2265be --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 1, "rows": 4, "warps": 8, "depth": 2, "ctas": 160}, + "launch_floor_in_list": {"median_us": 4.608, "min_us": 4.416}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 30208, "min_ns": 26592, "gbs": 81.36, "of_spec_273": 0.2980, "of_practical_237_2": 0.3430, "minus_floor_ns": 25600, "minus_floor_gbs": 96.00, "minus_floor_of_spec_273": 0.3516, "minus_floor_of_practical_237_2": 0.4047, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 23840, "min_ns": 19840, "gbs": 68.72, "of_spec_273": 0.2517, "of_practical_237_2": 0.2897, "minus_floor_ns": 19232, "minus_floor_gbs": 85.19, "minus_floor_of_spec_273": 0.3121, "minus_floor_of_practical_237_2": 0.3592, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 82240, "min_ns": 44064, "gbs": 107.58, "of_spec_273": 0.3941, "of_practical_237_2": 0.4535, "minus_floor_ns": 77632, "minus_floor_gbs": 113.97, "minus_floor_of_spec_273": 0.4175, "minus_floor_of_practical_237_2": 0.4805, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 38528, "min_ns": 24960, "gbs": 114.82, "of_spec_273": 0.4206, "of_practical_237_2": 0.4841, "minus_floor_ns": 33920, "minus_floor_gbs": 130.42, "minus_floor_of_spec_273": 0.4777, "minus_floor_of_practical_237_2": 0.5498, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4.meta new file mode 100644 index 000000000..1039ae253 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/block-4.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:39Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +266 MHz, [N/A], 37, 5 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1-cam.csv b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1-cam.csv new file mode 100644 index 000000000..533be394f --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1-cam.csv @@ -0,0 +1,850 @@ +8,256,0,0,7392,2732,1056,2587.1 +8,256,0,1,3904,3029,1184,2558.3 +8,256,0,2,4160,3259,1280,2546.1 +8,256,0,3,3936,3164,1248,2535.3 +8,256,0,4,4096,3041,1184,2568.4 +8,256,0,5,3904,3120,1216,2565.8 +8,256,0,6,4064,3038,1184,2565.9 +8,256,0,7,4096,3176,1216,2611.8 +8,256,0,8,4096,3152,1248,2525.6 +8,256,0,9,4000,3069,1184,2592.1 +8,256,0,10,3872,3032,1184,2560.8 +8,256,0,11,4000,3023,1184,2553.2 +8,256,0,12,4000,2894,1152,2512.2 +8,256,0,13,3936,3030,1184,2559.1 +8,256,0,14,3968,3097,1216,2546.9 +8,256,0,15,5440,6638,2592,2561.0 +8,256,0,16,4096,3139,1216,2581.4 +8,256,0,17,4032,3024,1184,2554.1 +8,256,0,18,4096,3156,1216,2595.4 +8,256,0,19,4128,3209,1248,2571.3 +8,256,0,20,4096,3032,1184,2560.8 +8,256,0,21,3904,3035,1184,2563.3 +8,256,0,22,4064,3131,1216,2574.8 +8,256,0,23,5440,5869,2272,2583.2 +8,256,0,24,4128,3041,1184,2568.4 +8,256,0,25,4096,3116,1216,2562.5 +8,256,0,26,4064,3003,1184,2536.3 +8,256,0,27,4096,3176,1216,2611.8 +8,256,0,28,4096,3021,1152,2622.4 +8,256,0,29,3968,3013,1184,2544.8 +8,256,0,30,3968,3123,1216,2568.3 +8,256,0,31,4096,3163,1248,2534.5 +8,256,1,0,3776,2642,1056,2501.9 +8,256,1,1,3680,2632,1024,2570.3 +8,256,1,2,3712,2638,992,2659.3 +8,256,1,3,3712,2642,1024,2580.1 +8,256,1,4,3808,2636,1024,2574.2 +8,256,1,5,3712,2636,1024,2574.2 +8,256,1,6,3712,2631,1024,2569.3 +8,256,1,7,3712,2629,1024,2567.4 +8,256,1,8,3776,2636,1024,2574.2 +8,256,1,9,3744,2636,1024,2574.2 +8,256,1,10,3712,2637,1024,2575.2 +8,256,1,11,3712,2641,1024,2579.1 +8,256,1,12,3744,2643,1024,2581.1 +8,256,1,13,3712,2639,1024,2577.1 +8,256,1,14,3712,2634,1024,2572.3 +8,256,1,15,3744,2634,1024,2572.3 +8,256,1,16,3776,2635,1024,2573.2 +8,256,1,17,3712,2639,1024,2577.1 +8,256,1,18,3680,2640,1024,2578.1 +8,256,1,19,3712,2644,1024,2582.0 +8,256,1,20,3840,2638,1024,2576.2 +8,256,1,21,3744,2636,1024,2574.2 +8,256,1,22,3712,2612,1024,2550.8 +8,256,1,23,3744,2621,1024,2559.6 +8,256,1,24,3776,2646,1024,2584.0 +8,256,1,25,3712,2604,992,2625.0 +8,256,1,26,3648,2427,960,2528.1 +8,256,1,27,3712,2660,1024,2597.7 +8,256,1,28,3776,2616,1024,2554.7 +8,256,1,29,3712,2642,1056,2501.9 +8,256,1,30,3712,2642,1024,2580.1 +8,256,1,31,3648,2569,1024,2508.8 +8,256,2,0,3776,2721,1056,2576.7 +8,256,2,1,3680,2746,1088,2523.9 +8,256,2,2,3712,2637,992,2658.3 +8,256,2,3,3680,2592,1024,2531.2 +8,256,2,4,3808,2640,1024,2578.1 +8,256,2,5,3712,2636,1024,2574.2 +8,256,2,6,3744,2641,1024,2579.1 +8,256,2,7,3712,2631,1024,2569.3 +8,256,2,8,3776,2637,1024,2575.2 +8,256,2,9,3712,2636,1024,2574.2 +8,256,2,10,3712,2639,1024,2577.1 +8,256,2,11,3744,2637,1024,2575.2 +8,256,2,12,3776,2633,1024,2571.3 +8,256,2,13,3712,2636,1056,2496.2 +8,256,2,14,3680,2635,1056,2495.3 +8,256,2,15,3712,2640,1024,2578.1 +8,256,2,16,3776,2642,1024,2580.1 +8,256,2,17,3712,2638,992,2659.3 +8,256,2,18,3712,2638,1024,2576.2 +8,256,2,19,3712,2638,1024,2576.2 +8,256,2,20,3808,2638,1024,2576.2 +8,256,2,21,3744,2633,1024,2571.3 +8,256,2,22,3744,2639,1024,2577.1 +8,256,2,23,3744,2642,1024,2580.1 +8,256,2,24,3840,2642,1024,2580.1 +8,256,2,25,3744,2635,1024,2573.2 +8,256,2,26,3584,2424,928,2612.1 +8,256,2,27,3744,2640,1056,2500.0 +8,256,2,28,3808,2637,1024,2575.2 +8,256,2,29,3680,2638,1024,2576.2 +8,256,2,30,3712,2640,1024,2578.1 +8,256,2,31,3680,2628,1024,2566.4 +8,256,3,0,3776,2638,1024,2576.2 +8,256,3,1,3680,2635,1024,2573.2 +8,256,3,2,3712,2638,1024,2576.2 +8,256,3,3,3712,2643,1024,2581.1 +8,256,3,4,3776,2636,1024,2574.2 +8,256,3,5,3744,2637,1024,2575.2 +8,256,3,6,3712,2643,1024,2581.1 +8,256,3,7,3744,2629,1024,2567.4 +8,256,3,8,3776,2638,1024,2576.2 +8,256,3,9,3712,2640,1024,2578.1 +8,256,3,10,3712,2641,1024,2579.1 +8,256,3,11,3712,2640,1024,2578.1 +8,256,3,12,3776,2636,1024,2574.2 +8,256,3,13,3712,2636,1024,2574.2 +8,256,3,14,3680,2638,1024,2576.2 +8,256,3,15,3680,2528,992,2548.4 +8,256,3,16,3776,2638,1024,2576.2 +8,256,3,17,3712,2637,1024,2575.2 +8,256,3,18,3712,2638,1024,2576.2 +8,256,3,19,3712,2638,1024,2576.2 +8,256,3,20,3776,2642,1024,2580.1 +8,256,3,21,3744,2640,1024,2578.1 +8,256,3,22,3712,2637,1024,2575.2 +8,256,3,23,3744,2636,1024,2574.2 +8,256,3,24,3808,2638,1024,2576.2 +8,256,3,25,3776,2639,1056,2499.1 +8,256,3,26,3616,2456,960,2558.3 +8,256,3,27,3744,2631,1024,2569.3 +8,256,3,28,3776,2624,1024,2562.5 +8,256,3,29,3712,2634,1024,2572.3 +8,256,3,30,3680,2632,1056,2492.4 +8,256,3,31,3744,2628,1056,2488.6 +8,256,4,0,3776,2634,1056,2494.3 +8,256,4,1,3744,2634,1056,2494.3 +8,256,4,2,3680,2636,1024,2574.2 +8,256,4,3,3712,2637,1024,2575.2 +8,256,4,4,3808,2639,1024,2577.1 +8,256,4,5,3744,2633,992,2654.2 +8,256,4,6,3712,2635,1024,2573.2 +8,256,4,7,3712,2634,1024,2572.3 +8,256,4,8,3808,2641,1024,2579.1 +8,256,4,9,3712,2642,1024,2580.1 +8,256,4,10,3712,2643,1024,2581.1 +8,256,4,11,3680,2638,1024,2576.2 +8,256,4,12,3776,2640,1024,2578.1 +8,256,4,13,3712,2632,1024,2570.3 +8,256,4,14,3712,2640,1024,2578.1 +8,256,4,15,3712,2638,1024,2576.2 +8,256,4,16,3776,2637,1024,2575.2 +8,256,4,17,3712,2655,1056,2514.2 +8,256,4,18,3680,2637,1024,2575.2 +8,256,4,19,3744,2648,1024,2585.9 +8,256,4,20,3808,2635,1024,2573.2 +8,256,4,21,3744,2630,1024,2568.4 +8,256,4,22,3744,2642,1024,2580.1 +8,256,4,23,3744,2640,1024,2578.1 +8,256,4,24,3808,2638,1056,2498.1 +8,256,4,25,3744,2637,1024,2575.2 +8,256,4,26,3584,2446,960,2547.9 +8,256,4,27,3712,2642,1024,2580.1 +8,256,4,28,3808,2640,1056,2500.0 +8,256,4,29,3744,2634,1024,2572.3 +8,256,4,30,3680,2641,1024,2579.1 +8,256,4,31,3744,2634,1024,2572.3 +3840,2560,0,0,40896,12134,22240,545.6 +3840,2560,0,1,25824,28365,12672,2238.4 +3840,2560,0,2,31840,31471,12864,2446.4 +3840,2560,0,3,25344,39564,15584,2538.8 +3840,2560,0,4,32160,28072,11040,2542.8 +3840,2560,0,5,26720,36320,14240,2550.6 +3840,2560,0,6,31168,33141,12992,2550.9 +3840,2560,0,7,27264,31006,12160,2549.8 +3840,2560,0,8,27680,30623,12032,2545.1 +3840,2560,0,9,26432,33465,13088,2556.9 +3840,2560,0,10,27552,31745,12416,2556.8 +3840,2560,0,11,25888,44408,17344,2560.4 +3840,2560,0,12,26048,28387,11136,2549.1 +3840,2560,0,13,25696,39673,15456,2566.8 +3840,2560,0,14,26816,32840,12800,2565.6 +3840,2560,0,15,23264,31059,12192,2547.5 +3840,2560,0,16,26016,31124,12192,2552.8 +3840,2560,0,17,24160,36054,14080,2560.7 +3840,2560,0,18,26560,34057,13344,2552.2 +3840,2560,0,19,31232,48020,18720,2565.2 +3840,2560,0,20,26016,31130,12192,2553.3 +3840,2560,0,21,26464,32847,12832,2559.8 +3840,2560,0,22,27424,32502,12736,2552.0 +3840,2560,0,23,25248,50534,19680,2567.8 +3840,2560,0,24,28384,34762,13600,2556.0 +3840,2560,0,25,27328,29607,11552,2562.9 +3840,2560,0,26,28512,28419,11136,2552.0 +3840,2560,0,27,29184,32445,12672,2560.4 +3840,2560,0,28,28384,29960,11712,2558.1 +3840,2560,0,29,25920,46644,18176,2566.2 +3840,2560,0,30,29984,36428,14208,2563.9 +3840,2560,0,31,28192,30586,12000,2548.8 +3840,2560,0,32,24800,31630,12416,2547.5 +3840,2560,0,33,25408,30699,12032,2551.4 +3840,2560,0,34,24320,27787,10848,2561.5 +3840,2560,0,35,25536,29761,11648,2555.0 +3840,2560,0,36,28416,30455,11904,2558.4 +3840,2560,0,37,29824,35864,14016,2558.8 +3840,2560,0,38,30176,39001,15296,2549.8 +3840,2560,0,39,30816,43621,17056,2557.5 +3840,2560,0,40,42784,89705,34944,2567.1 +3840,2560,1,0,22944,32321,12640,2557.0 +3840,2560,1,1,22496,44733,17472,2560.3 +3840,2560,1,2,27904,40565,15808,2566.1 +3840,2560,1,3,27456,43172,16832,2564.9 +3840,2560,1,4,22400,31475,12256,2568.1 +3840,2560,1,5,24352,34726,13568,2559.4 +3840,2560,1,6,24256,28536,11136,2562.5 +3840,2560,1,7,23840,29741,11584,2567.4 +3840,2560,1,8,24704,34874,13632,2558.2 +3840,2560,1,9,24672,42129,16352,2576.4 +3840,2560,1,10,28288,28829,11360,2537.8 +3840,2560,1,11,25984,47782,18592,2570.0 +3840,2560,1,12,24480,30607,11936,2564.3 +3840,2560,1,13,23584,40779,15872,2569.2 +3840,2560,1,14,26368,35445,13824,2564.0 +3840,2560,1,15,20832,30987,12064,2568.6 +3840,2560,1,16,22656,39182,15264,2567.0 +3840,2560,1,17,22592,32900,12800,2570.3 +3840,2560,1,18,23296,41180,16032,2568.6 +3840,2560,1,19,26048,49293,19168,2571.6 +3840,2560,1,20,21472,40142,15648,2565.3 +3840,2560,1,21,24160,34057,13280,2564.5 +3840,2560,1,22,31136,35568,13888,2561.1 +3840,2560,1,23,25056,42716,16640,2567.1 +3840,2560,1,24,22528,29873,11616,2571.7 +3840,2560,1,25,21952,44614,17376,2567.6 +3840,2560,1,26,24384,46176,17920,2576.8 +3840,2560,1,27,27328,29270,11456,2555.0 +3840,2560,1,28,25952,56520,21984,2571.0 +3840,2560,1,29,25952,44569,17344,2569.7 +3840,2560,1,30,28960,44936,17472,2571.9 +3840,2560,1,31,26048,36608,14240,2570.8 +3840,2560,1,32,23520,45634,17760,2569.5 +3840,2560,1,33,22880,39075,15232,2565.3 +3840,2560,1,34,26688,34521,13536,2550.3 +3840,2560,1,35,24224,36526,14240,2565.0 +3840,2560,1,36,25376,52967,20608,2570.2 +3840,2560,1,37,25536,42077,16352,2573.2 +3840,2560,1,38,30304,40649,15872,2561.1 +3840,2560,1,39,33408,57953,22528,2572.5 +3840,2560,1,40,43040,93892,36448,2576.1 +3840,2560,2,0,24448,35646,13888,2566.7 +3840,2560,2,1,21280,33738,13184,2559.0 +3840,2560,2,2,25792,37041,14400,2572.3 +3840,2560,2,3,28320,35005,13632,2567.9 +3840,2560,2,4,24736,45973,17920,2565.5 +3840,2560,2,5,23552,34501,13472,2560.9 +3840,2560,2,6,23392,37166,14496,2563.9 +3840,2560,2,7,23072,31853,12384,2572.1 +3840,2560,2,8,24032,36804,14336,2567.2 +3840,2560,2,9,22272,30789,12032,2558.9 +3840,2560,2,10,24640,32923,12832,2565.7 +3840,2560,2,11,27424,51957,20224,2569.1 +3840,2560,2,12,26240,31786,12416,2560.1 +3840,2560,2,13,23712,40635,15840,2565.3 +3840,2560,2,14,26912,44153,17184,2569.4 +3840,2560,2,15,22208,32757,12768,2565.6 +3840,2560,2,16,25376,41482,16160,2567.0 +3840,2560,2,17,22464,34767,13504,2574.6 +3840,2560,2,18,23744,41909,16320,2568.0 +3840,2560,2,19,24800,47574,18528,2567.7 +3840,2560,2,20,22784,41831,16288,2568.2 +3840,2560,2,21,25408,40552,15776,2570.5 +3840,2560,2,22,26112,37513,14560,2576.4 +3840,2560,2,23,25504,46657,18144,2571.5 +3840,2560,2,24,27040,27949,10944,2553.8 +3840,2560,2,25,23744,44264,17280,2561.6 +3840,2560,2,26,24128,43148,16800,2568.3 +3840,2560,2,27,28640,30089,11712,2569.1 +3840,2560,2,28,25792,40523,15840,2558.3 +3840,2560,2,29,25568,47253,18368,2572.6 +3840,2560,2,30,29568,38486,14976,2569.8 +3840,2560,2,31,24704,31198,12224,2552.2 +3840,2560,2,32,23264,51450,20000,2572.5 +3840,2560,2,33,22720,32281,12608,2560.4 +3840,2560,2,34,23328,32751,12800,2558.7 +3840,2560,2,35,23648,33512,13056,2566.8 +3840,2560,2,36,22336,44819,17408,2574.6 +3840,2560,2,37,23936,42897,16736,2563.2 +3840,2560,2,38,31488,39774,15488,2568.1 +3840,2560,2,39,28544,54154,21024,2575.8 +3840,2560,2,40,40928,89402,34656,2579.7 +3840,2560,3,0,22784,37593,14656,2565.0 +3840,2560,3,1,22176,36486,14208,2568.0 +3840,2560,3,2,29312,35015,13632,2568.6 +3840,2560,3,3,28960,42197,16448,2565.5 +3840,2560,3,4,24480,41935,16320,2569.5 +3840,2560,3,5,26272,36882,14368,2567.0 +3840,2560,3,6,24160,30926,12096,2556.7 +3840,2560,3,7,23904,27363,10752,2544.9 +3840,2560,3,8,21984,33040,12928,2555.7 +3840,2560,3,9,26400,41260,16064,2568.5 +3840,2560,3,10,23552,27322,10656,2564.0 +3840,2560,3,11,25504,44949,17504,2567.9 +3840,2560,3,12,21856,31093,12160,2557.0 +3840,2560,3,13,24992,39885,15520,2569.9 +3840,2560,3,14,30016,40163,15680,2561.4 +3840,2560,3,15,22848,33980,13248,2564.9 +3840,2560,3,16,23680,43264,16800,2575.2 +3840,2560,3,17,22336,37760,14688,2570.8 +3840,2560,3,18,24480,43345,16896,2565.4 +3840,2560,3,19,23712,38266,14880,2571.6 +3840,2560,3,20,23552,39526,15328,2578.7 +3840,2560,3,21,23456,35604,13888,2563.7 +3840,2560,3,22,23744,33031,12896,2561.3 +3840,2560,3,23,26208,41798,16256,2571.2 +3840,2560,3,24,21504,33666,13120,2566.0 +3840,2560,3,25,21472,40836,15872,2572.8 +3840,2560,3,26,22944,43344,16864,2570.2 +3840,2560,3,27,27968,27952,10912,2561.6 +3840,2560,3,28,25568,38771,15104,2566.9 +3840,2560,3,29,27072,44575,17344,2570.1 +3840,2560,3,30,24320,43384,16864,2572.6 +3840,2560,3,31,26944,41730,16288,2562.0 +3840,2560,3,32,22304,45891,17856,2570.1 +3840,2560,3,33,20352,39546,15360,2574.6 +3840,2560,3,34,23616,37752,14688,2570.3 +3840,2560,3,35,22432,33313,13024,2557.8 +3840,2560,3,36,22784,42470,16512,2572.1 +3840,2560,3,37,23968,43071,16768,2568.6 +3840,2560,3,38,30944,53465,20768,2574.4 +3840,2560,3,39,32032,54321,21120,2572.0 +3840,2560,3,40,42944,88832,34496,2575.1 +3840,2560,4,0,22528,32729,12800,2557.0 +3840,2560,4,1,22048,40272,15712,2563.1 +3840,2560,4,2,27488,38843,15168,2560.9 +3840,2560,4,3,25920,37653,14688,2563.5 +3840,2560,4,4,21600,39424,15328,2572.0 +3840,2560,4,5,22944,32429,12640,2565.6 +3840,2560,4,6,24576,27411,10720,2557.0 +3840,2560,4,7,24864,29434,11488,2562.2 +3840,2560,4,8,23744,37391,14560,2568.1 +3840,2560,4,9,25696,40875,15936,2564.9 +3840,2560,4,10,24672,27009,10560,2557.7 +3840,2560,4,11,25312,48015,18656,2573.7 +3840,2560,4,12,24768,32105,12512,2565.9 +3840,2560,4,13,24096,42123,16384,2571.0 +3840,2560,4,14,28448,37050,14464,2561.5 +3840,2560,4,15,22144,34837,13600,2561.5 +3840,2560,4,16,23008,37882,14752,2567.9 +3840,2560,4,17,24224,41897,16288,2572.3 +3840,2560,4,18,25504,40722,15904,2560.5 +3840,2560,4,19,22048,34578,13440,2572.8 +3840,2560,4,20,22976,38811,15072,2575.0 +3840,2560,4,21,24000,36159,14144,2556.5 +3840,2560,4,22,23360,31645,12352,2561.9 +3840,2560,4,23,25056,40438,15776,2563.3 +3840,2560,4,24,24224,34567,13472,2565.8 +3840,2560,4,25,21248,39205,15264,2568.5 +3840,2560,4,26,24896,46132,17952,2569.7 +3840,2560,4,27,27776,29213,11424,2557.2 +3840,2560,4,28,26912,49101,19136,2565.9 +3840,2560,4,29,24896,45047,17472,2578.2 +3840,2560,4,30,27776,47887,18624,2571.3 +3840,2560,4,31,23968,35066,13696,2560.3 +3840,2560,4,32,23424,50466,19680,2564.3 +3840,2560,4,33,25856,30125,11712,2572.1 +3840,2560,4,34,25408,31912,12448,2563.6 +3840,2560,4,35,25984,35797,13952,2565.7 +3840,2560,4,36,21856,36715,14272,2572.5 +3840,2560,4,37,22048,32474,12672,2562.7 +3840,2560,4,38,30784,44527,17344,2567.3 +3840,2560,4,39,29056,58840,22912,2568.1 +3840,2560,4,40,40896,89507,34752,2575.6 +2560,2560,0,0,22240,19036,7520,2531.4 +2560,2560,0,1,17984,25616,10048,2549.4 +2560,2560,0,2,17088,29585,11584,2554.0 +2560,2560,0,3,21184,28828,11296,2552.1 +2560,2560,0,4,16736,26789,10528,2544.5 +2560,2560,0,5,19104,26563,10400,2554.1 +2560,2560,0,6,15680,24941,9760,2555.4 +2560,2560,0,7,17120,29737,11648,2553.0 +2560,2560,0,8,24576,46855,18304,2559.8 +2560,2560,0,9,20704,25478,9984,2551.9 +2560,2560,0,10,15648,29907,11680,2560.5 +2560,2560,0,11,18176,30134,11744,2565.9 +2560,2560,0,12,19616,25407,9920,2561.2 +2560,2560,0,13,16992,29831,11712,2547.0 +2560,2560,0,14,15584,25343,9920,2554.7 +2560,2560,0,15,18944,28731,11264,2550.7 +2560,2560,0,16,16544,26371,10368,2543.5 +2560,2560,0,17,17280,26342,10304,2556.5 +2560,2560,0,18,18176,26743,10496,2547.9 +2560,2560,0,19,18080,26069,10208,2553.8 +2560,2560,0,20,15488,25166,9856,2553.4 +2560,2560,0,21,17760,31856,12416,2565.7 +2560,2560,0,22,16416,27653,10816,2556.7 +2560,2560,0,23,18432,25457,9952,2558.0 +2560,2560,0,24,18496,28689,11232,2554.2 +2560,2560,0,25,16800,30063,11776,2552.9 +2560,2560,0,26,16768,27344,10688,2558.4 +2560,2560,0,27,16128,25435,9984,2547.6 +2560,2560,0,28,17216,25737,10080,2553.3 +2560,2560,0,29,18496,25912,10176,2546.4 +2560,2560,0,30,18528,28638,11232,2549.7 +2560,2560,0,31,19296,29859,11648,2563.4 +2560,2560,0,32,18656,26603,10432,2550.1 +2560,2560,0,33,15936,25567,10016,2552.6 +2560,2560,0,34,18944,26198,10272,2550.4 +2560,2560,0,35,18336,27840,10912,2551.3 +2560,2560,0,36,19232,26613,10432,2551.1 +2560,2560,0,37,17536,27601,10848,2544.3 +2560,2560,0,38,18208,27358,10688,2559.7 +2560,2560,0,39,17792,26757,10496,2549.3 +2560,2560,0,40,16416,26020,10208,2549.0 +2560,2560,0,41,17792,26383,10336,2552.5 +2560,2560,0,42,18272,27221,10688,2546.9 +2560,2560,0,43,17408,27074,10592,2556.1 +2560,2560,0,44,17984,27692,10848,2552.7 +2560,2560,0,45,14880,27079,10592,2556.6 +2560,2560,0,46,17632,27341,10688,2558.1 +2560,2560,0,47,18240,25765,10112,2548.0 +2560,2560,0,48,15552,23997,9408,2550.7 +2560,2560,0,49,17600,24291,9504,2555.9 +2560,2560,0,50,18624,23521,9216,2552.2 +2560,2560,0,51,15328,25244,9920,2544.8 +2560,2560,0,52,18432,25266,9888,2555.2 +2560,2560,0,53,15936,24811,9760,2542.1 +2560,2560,0,54,16416,26197,10208,2566.3 +2560,2560,0,55,16640,24188,9504,2545.0 +2560,2560,0,56,15968,26935,10560,2550.7 +2560,2560,0,57,16480,30582,11968,2555.3 +2560,2560,0,58,18208,24028,9376,2562.7 +2560,2560,0,59,17504,31422,12288,2557.1 +2560,2560,0,60,22944,33926,13248,2560.8 +2560,2560,0,61,36960,69301,27040,2562.9 +2560,2560,1,0,14944,27868,10912,2553.9 +2560,2560,1,1,16768,31103,12128,2564.6 +2560,2560,1,2,16864,27429,10720,2558.7 +2560,2560,1,3,17280,25790,10080,2558.5 +2560,2560,1,4,15456,26241,10272,2554.6 +2560,2560,1,5,18272,25994,10176,2554.4 +2560,2560,1,6,16096,26606,10432,2550.4 +2560,2560,1,7,16096,26993,10528,2563.9 +2560,2560,1,8,15616,25731,10016,2569.0 +2560,2560,1,9,16608,26673,10400,2564.7 +2560,2560,1,10,15808,27449,10688,2568.2 +2560,2560,1,11,18176,26694,10400,2566.7 +2560,2560,1,12,16544,25659,10016,2561.8 +2560,2560,1,13,15840,31654,12352,2562.7 +2560,2560,1,14,14592,26024,10176,2557.4 +2560,2560,1,15,17472,27645,10784,2563.5 +2560,2560,1,16,14784,28965,11296,2564.2 +2560,2560,1,17,14912,28967,11296,2564.4 +2560,2560,1,18,15712,26353,10272,2565.5 +2560,2560,1,19,17344,26183,10176,2573.0 +2560,2560,1,20,15232,26441,10272,2574.1 +2560,2560,1,21,16064,26798,10432,2568.8 +2560,2560,1,22,15648,27672,10784,2566.0 +2560,2560,1,23,17824,25452,9952,2557.5 +2560,2560,1,24,15104,26780,10464,2559.3 +2560,2560,1,25,16064,25925,10112,2563.8 +2560,2560,1,26,15424,27020,10528,2566.5 +2560,2560,1,27,16224,29673,11584,2561.6 +2560,2560,1,28,16832,28336,11040,2566.7 +2560,2560,1,29,16640,27450,10720,2560.6 +2560,2560,1,30,14848,26923,10496,2565.1 +2560,2560,1,31,17056,28958,11296,2563.6 +2560,2560,1,32,15872,26704,10368,2575.6 +2560,2560,1,33,17216,26105,10176,2565.3 +2560,2560,1,34,16096,26209,10272,2551.5 +2560,2560,1,35,16768,26458,10304,2567.7 +2560,2560,1,36,16000,25186,9824,2563.7 +2560,2560,1,37,15936,27413,10688,2564.8 +2560,2560,1,38,14944,28890,11232,2572.1 +2560,2560,1,39,15808,25915,10080,2570.9 +2560,2560,1,40,15616,26318,10272,2562.1 +2560,2560,1,41,16992,25750,10048,2562.7 +2560,2560,1,42,16192,25597,10016,2555.6 +2560,2560,1,43,16480,26675,10400,2564.9 +2560,2560,1,44,16480,26131,10176,2567.9 +2560,2560,1,45,15200,28768,11200,2568.6 +2560,2560,1,46,16992,26956,10528,2560.4 +2560,2560,1,47,17344,29069,11328,2566.1 +2560,2560,1,48,15616,25649,10016,2560.8 +2560,2560,1,49,15456,24277,9440,2571.7 +2560,2560,1,50,15104,23887,9312,2565.2 +2560,2560,1,51,15520,24927,9728,2562.4 +2560,2560,1,52,14656,24292,9504,2556.0 +2560,2560,1,53,16096,24773,9664,2563.4 +2560,2560,1,54,17280,25642,10016,2560.1 +2560,2560,1,55,15424,24839,9696,2561.8 +2560,2560,1,56,14688,25316,9888,2560.3 +2560,2560,1,57,15808,25555,9984,2559.6 +2560,2560,1,58,14944,24912,9760,2552.5 +2560,2560,1,59,16128,30588,11904,2569.6 +2560,2560,1,60,19168,29149,11328,2573.2 +2560,2560,1,61,32896,68368,26496,2580.3 +2560,2560,2,0,15648,26744,10432,2563.7 +2560,2560,2,1,16704,30668,11968,2562.5 +2560,2560,2,2,15584,27159,10624,2556.4 +2560,2560,2,3,17312,27260,10656,2558.2 +2560,2560,2,4,16320,31300,12160,2574.0 +2560,2560,2,5,16096,29713,11552,2572.1 +2560,2560,2,6,15904,26333,10272,2563.6 +2560,2560,2,7,16992,26864,10464,2567.3 +2560,2560,2,8,15360,25722,10016,2568.1 +2560,2560,2,9,17472,27233,10624,2563.3 +2560,2560,2,10,16064,27086,10560,2565.0 +2560,2560,2,11,16480,27078,10592,2556.5 +2560,2560,2,12,15264,28753,11168,2574.6 +2560,2560,2,13,15872,30152,11776,2560.5 +2560,2560,2,14,14272,26091,10176,2564.0 +2560,2560,2,15,17248,28012,10912,2567.1 +2560,2560,2,16,15584,30710,11968,2566.0 +2560,2560,2,17,15520,28165,10976,2566.1 +2560,2560,2,18,15872,26643,10400,2561.8 +2560,2560,2,19,16448,25817,10048,2569.4 +2560,2560,2,20,15904,26658,10400,2563.3 +2560,2560,2,21,17792,26930,10496,2565.7 +2560,2560,2,22,15104,27271,10656,2559.2 +2560,2560,2,23,15776,26755,10400,2572.6 +2560,2560,2,24,15776,26607,10368,2566.3 +2560,2560,2,25,14720,27585,10752,2565.6 +2560,2560,2,26,15488,25732,10048,2560.9 +2560,2560,2,27,15616,27013,10496,2573.6 +2560,2560,2,28,16864,26233,10272,2553.8 +2560,2560,2,29,18272,26848,10464,2565.7 +2560,2560,2,30,16096,26404,10304,2562.5 +2560,2560,2,31,16480,29161,11360,2567.0 +2560,2560,2,32,15936,31075,12096,2569.0 +2560,2560,2,33,16640,25544,9952,2566.7 +2560,2560,2,34,15424,27023,10528,2566.8 +2560,2560,2,35,17344,26620,10368,2567.5 +2560,2560,2,36,14720,25371,9888,2565.8 +2560,2560,2,37,17120,31508,12256,2570.8 +2560,2560,2,38,16096,25753,10016,2571.2 +2560,2560,2,39,16416,28208,10976,2570.0 +2560,2560,2,40,14720,25623,9984,2566.4 +2560,2560,2,41,15488,25072,9824,2552.1 +2560,2560,2,42,16128,25171,9824,2562.2 +2560,2560,2,43,16064,26558,10400,2553.7 +2560,2560,2,44,15104,25608,9952,2573.2 +2560,2560,2,45,15072,26637,10368,2569.2 +2560,2560,2,46,13920,25956,10080,2575.0 +2560,2560,2,47,16960,27109,10592,2559.4 +2560,2560,2,48,15360,25889,10048,2576.5 +2560,2560,2,49,14944,27209,10624,2561.1 +2560,2560,2,50,16192,23960,9344,2564.2 +2560,2560,2,51,16192,24767,9696,2554.4 +2560,2560,2,52,15136,24524,9568,2563.1 +2560,2560,2,53,15264,24717,9664,2557.6 +2560,2560,2,54,14432,25010,9728,2570.9 +2560,2560,2,55,15904,24466,9536,2565.6 +2560,2560,2,56,15328,23878,9280,2573.1 +2560,2560,2,57,16064,30927,12064,2563.6 +2560,2560,2,58,14624,25458,9920,2566.3 +2560,2560,2,59,15680,30404,11808,2574.9 +2560,2560,2,60,18912,28076,10944,2565.4 +2560,2560,2,61,34240,72167,28032,2574.5 +2560,2560,3,0,15136,26826,10496,2555.8 +2560,2560,3,1,16256,27488,10720,2564.2 +2560,2560,3,2,15200,27987,10912,2564.8 +2560,2560,3,3,18848,26116,10208,2558.4 +2560,2560,3,4,15456,25506,9952,2562.9 +2560,2560,3,5,17632,27087,10592,2557.3 +2560,2560,3,6,15552,25945,10112,2565.8 +2560,2560,3,7,16320,26055,10176,2560.4 +2560,2560,3,8,15168,25574,9984,2561.5 +2560,2560,3,9,17696,26469,10304,2568.8 +2560,2560,3,10,15520,26334,10304,2555.7 +2560,2560,3,11,15840,26611,10368,2566.6 +2560,2560,3,12,16224,26653,10400,2562.8 +2560,2560,3,13,16256,28418,11072,2566.7 +2560,2560,3,14,15456,25795,10080,2559.0 +2560,2560,3,15,17152,27723,10784,2570.8 +2560,2560,3,16,15264,25702,10048,2557.9 +2560,2560,3,17,16928,25587,9984,2562.8 +2560,2560,3,18,15360,26835,10464,2564.5 +2560,2560,3,19,16000,25441,9888,2572.9 +2560,2560,3,20,14208,26621,10400,2559.7 +2560,2560,3,21,16672,33558,12992,2583.0 +2560,2560,3,22,15360,29893,11616,2573.4 +2560,2560,3,23,17312,26400,10304,2562.1 +2560,2560,3,24,15360,27039,10592,2552.8 +2560,2560,3,25,15968,26621,10400,2559.7 +2560,2560,3,26,17280,27676,10816,2558.8 +2560,2560,3,27,15648,27655,10784,2564.4 +2560,2560,3,28,16096,26996,10528,2564.2 +2560,2560,3,29,17248,26674,10400,2564.8 +2560,2560,3,30,14816,26431,10304,2565.1 +2560,2560,3,31,17408,29436,11424,2576.7 +2560,2560,3,32,16704,26517,10336,2565.5 +2560,2560,3,33,16416,27207,10592,2568.6 +2560,2560,3,34,16992,27826,10848,2565.1 +2560,2560,3,35,17536,26084,10176,2563.3 +2560,2560,3,36,16032,25999,10144,2563.0 +2560,2560,3,37,16224,25553,9984,2559.4 +2560,2560,3,38,17152,26803,10464,2561.4 +2560,2560,3,39,16064,26878,10496,2560.8 +2560,2560,3,40,15488,25944,10112,2565.7 +2560,2560,3,41,16768,27188,10624,2559.1 +2560,2560,3,42,16512,25683,9984,2572.4 +2560,2560,3,43,16928,28367,11040,2569.5 +2560,2560,3,44,15936,26146,10208,2561.3 +2560,2560,3,45,14784,27942,10880,2568.2 +2560,2560,3,46,16352,25406,9888,2569.4 +2560,2560,3,47,17152,29782,11584,2571.0 +2560,2560,3,48,16160,25607,9984,2564.8 +2560,2560,3,49,14944,24397,9472,2575.7 +2560,2560,3,50,14112,24187,9408,2570.9 +2560,2560,3,51,15840,24373,9536,2555.9 +2560,2560,3,52,15072,24255,9472,2560.7 +2560,2560,3,53,15776,24851,9664,2571.5 +2560,2560,3,54,14208,25424,9952,2554.7 +2560,2560,3,55,15744,24934,9696,2571.6 +2560,2560,3,56,14304,26184,10208,2565.0 +2560,2560,3,57,15520,30749,11968,2569.3 +2560,2560,3,58,15200,26088,10176,2563.7 +2560,2560,3,59,15904,31004,12064,2570.0 +2560,2560,3,60,20160,29697,11552,2570.7 +2560,2560,3,61,34336,78768,30528,2580.2 +2560,2560,4,0,15232,28001,10912,2566.1 +2560,2560,4,1,16928,30070,11744,2560.5 +2560,2560,4,2,15808,27635,10784,2562.6 +2560,2560,4,3,16000,26082,10144,2571.2 +2560,2560,4,4,14688,26046,10176,2559.6 +2560,2560,4,5,16224,27824,10816,2572.5 +2560,2560,4,6,15776,25414,9920,2561.9 +2560,2560,4,7,15712,26661,10400,2563.6 +2560,2560,4,8,15392,25221,9824,2567.3 +2560,2560,4,9,18656,26169,10176,2571.6 +2560,2560,4,10,16160,27974,10944,2556.1 +2560,2560,4,11,17376,27245,10624,2564.5 +2560,2560,4,12,15584,25898,10080,2569.2 +2560,2560,4,13,15456,29255,11424,2560.8 +2560,2560,4,14,14816,25586,9984,2562.7 +2560,2560,4,15,16704,26096,10208,2556.4 +2560,2560,4,16,14304,27284,10624,2568.1 +2560,2560,4,17,16128,27700,10816,2561.0 +2560,2560,4,18,15680,26852,10464,2566.1 +2560,2560,4,19,16064,26284,10208,2574.8 +2560,2560,4,20,15200,27115,10560,2567.7 +2560,2560,4,21,17440,26520,10336,2565.8 +2560,2560,4,22,14944,27949,10880,2568.8 +2560,2560,4,23,16960,25101,9760,2571.8 +2560,2560,4,24,15392,25577,10016,2553.6 +2560,2560,4,25,16320,30270,11776,2570.5 +2560,2560,4,26,16896,26818,10464,2562.9 +2560,2560,4,27,15456,29342,11456,2561.3 +2560,2560,4,28,17792,26792,10432,2568.3 +2560,2560,4,29,16576,28695,11200,2562.1 +2560,2560,4,30,16448,27127,10528,2576.7 +2560,2560,4,31,17760,32168,12544,2564.4 +2560,2560,4,32,15392,26438,10336,2557.9 +2560,2560,4,33,16608,27174,10560,2573.3 +2560,2560,4,34,16320,27208,10656,2553.3 +2560,2560,4,35,15904,26292,10240,2567.6 +2560,2560,4,36,15808,24999,9728,2569.8 +2560,2560,4,37,16000,31688,12352,2565.4 +2560,2560,4,38,16288,26410,10304,2563.1 +2560,2560,4,39,16192,26536,10336,2567.3 +2560,2560,4,40,16608,26150,10208,2561.7 +2560,2560,4,41,16640,26521,10304,2573.9 +2560,2560,4,42,16832,25491,9952,2561.4 +2560,2560,4,43,17024,26789,10432,2568.0 +2560,2560,4,44,14976,26347,10304,2557.0 +2560,2560,4,45,16128,27809,10816,2571.1 +2560,2560,4,46,15520,25686,10016,2564.5 +2560,2560,4,47,16352,27467,10720,2562.2 +2560,2560,4,48,15424,25272,9856,2564.1 +2560,2560,4,49,15488,24477,9568,2558.2 +2560,2560,4,50,15328,24052,9408,2556.5 +2560,2560,4,51,15584,24148,9440,2558.1 +2560,2560,4,52,14528,24909,9696,2569.0 +2560,2560,4,53,16320,24408,9536,2559.6 +2560,2560,4,54,14016,26681,10432,2557.6 +2560,2560,4,55,15200,24118,9376,2572.3 +2560,2560,4,56,13952,25202,9856,2557.0 +2560,2560,4,57,15840,31443,12224,2572.2 +2560,2560,4,58,14816,24920,9728,2561.7 +2560,2560,4,59,16352,31588,12320,2564.0 +2560,2560,4,60,19008,30724,11936,2574.1 +2560,2560,4,61,32736,65367,25376,2575.9 +13824,2560,0,0,34944,50993,20064,2541.5 +13824,2560,0,1,59680,129400,50528,2561.0 +13824,2560,0,2,64384,132137,51520,2564.8 +13824,2560,0,3,62176,111685,43616,2560.6 +13824,2560,0,4,56416,114618,44608,2569.4 +13824,2560,0,5,59488,141790,55264,2565.7 +13824,2560,0,6,60128,125616,48960,2565.7 +13824,2560,0,7,61472,133145,51904,2565.2 +13824,2560,0,8,59712,124365,48512,2563.6 +13824,2560,0,9,58304,115767,45152,2563.9 +13824,2560,0,10,64352,129016,50304,2564.7 +13824,2560,0,11,74336,158818,61856,2567.5 +13824,2560,1,0,54720,125414,48864,2566.6 +13824,2560,1,1,53120,120660,47008,2566.8 +13824,2560,1,2,53152,124718,48576,2567.5 +13824,2560,1,3,51968,113006,44064,2564.6 +13824,2560,1,4,51072,112047,43680,2565.2 +13824,2560,1,5,56512,128971,50240,2567.1 +13824,2560,1,6,51616,110992,43296,2563.6 +13824,2560,1,7,52256,115154,44896,2564.9 +13824,2560,1,8,50784,106061,41376,2563.3 +13824,2560,1,9,53824,116573,45472,2563.6 +13824,2560,1,10,50848,102097,39808,2564.7 +13824,2560,1,11,60480,136521,53120,2570.0 +13824,2560,2,0,52320,111852,43584,2566.4 +13824,2560,2,1,53344,125120,48704,2569.0 +13824,2560,2,2,51872,112500,43744,2571.8 +13824,2560,2,3,48352,108548,42272,2567.8 +13824,2560,2,4,47808,101898,39680,2568.0 +13824,2560,2,5,55552,124201,48288,2572.1 +13824,2560,2,6,52224,117242,45632,2569.3 +13824,2560,2,7,51648,118017,45920,2570.1 +13824,2560,2,8,51232,107932,41984,2570.8 +13824,2560,2,9,51072,116386,45248,2572.2 +13824,2560,2,10,53056,114088,44384,2570.5 +13824,2560,2,11,54432,123612,48064,2571.8 +13824,2560,3,0,51712,114782,44768,2563.9 +13824,2560,3,1,55488,129241,50240,2572.5 +13824,2560,3,2,52704,116933,45536,2567.9 +13824,2560,3,3,48000,100863,39264,2568.8 +13824,2560,3,4,49344,110182,42880,2569.5 +13824,2560,3,5,56448,128905,50112,2572.3 +13824,2560,3,6,53472,118787,46240,2568.9 +13824,2560,3,7,52512,124594,48448,2571.7 +13824,2560,3,8,50912,110795,43104,2570.4 +13824,2560,3,9,53056,110527,43008,2569.9 +13824,2560,3,10,50016,112433,43744,2570.2 +13824,2560,3,11,55456,111410,43328,2571.3 +13824,2560,4,0,52032,119329,46528,2564.7 +13824,2560,4,1,55232,126680,49312,2568.9 +13824,2560,4,2,50976,111282,43328,2568.4 +13824,2560,4,3,47808,102621,40000,2565.5 +13824,2560,4,4,49600,103305,40160,2572.3 +13824,2560,4,5,55584,127253,49472,2572.2 +13824,2560,4,6,52768,108599,42240,2571.0 +13824,2560,4,7,55008,121956,47424,2571.6 +13824,2560,4,8,50976,108816,42368,2568.4 +13824,2560,4,9,51648,105974,41216,2571.2 +13824,2560,4,10,50304,113083,43968,2571.9 +13824,2560,4,11,50848,106221,41344,2569.2 +2560,6912,0,0,27840,32088,12672,2532.2 +2560,6912,0,1,32128,47941,18976,2526.4 +2560,6912,0,2,32608,39246,15392,2549.8 +2560,6912,0,3,34336,44422,17408,2551.8 +2560,6912,0,4,31584,46928,18336,2559.3 +2560,6912,0,5,33088,44815,17536,2555.6 +2560,6912,0,6,32512,36174,14144,2557.6 +2560,6912,0,7,34624,52261,20416,2559.8 +2560,6912,0,8,32864,42042,16448,2556.1 +2560,6912,0,9,34048,54262,21184,2561.5 +2560,6912,0,10,33632,36168,14144,2557.1 +2560,6912,0,11,32032,43141,16832,2563.0 +2560,6912,0,12,33344,37228,14528,2562.5 +2560,6912,0,13,33472,48688,19040,2557.1 +2560,6912,0,14,32960,38583,15104,2554.5 +2560,6912,0,15,35200,45080,17632,2556.7 +2560,6912,0,16,33568,59317,23200,2556.8 +2560,6912,0,17,31456,41059,16064,2556.0 +2560,6912,0,18,33472,34224,13376,2558.6 +2560,6912,0,19,34176,44344,17312,2561.5 +2560,6912,0,20,31552,37200,14560,2554.9 +2560,6912,0,21,30656,42082,16480,2553.5 +2560,6912,0,22,40064,45020,17600,2558.0 +2560,6912,1,0,31392,40624,15904,2554.3 +2560,6912,1,1,31840,38564,15040,2564.1 +2560,6912,1,2,31040,41840,16384,2553.7 +2560,6912,1,3,33664,42285,16544,2555.9 +2560,6912,1,4,31616,42402,16640,2548.2 +2560,6912,1,5,32448,40671,15936,2552.1 +2560,6912,1,6,31776,42669,16704,2554.4 +2560,6912,1,7,32320,38881,15200,2558.0 +2560,6912,1,8,31008,40914,16032,2552.0 +2560,6912,1,9,33152,44412,17344,2560.7 +2560,6912,1,10,32128,39824,15616,2550.2 +2560,6912,1,11,31104,40968,16000,2560.5 +2560,6912,1,12,31296,39118,15328,2552.1 +2560,6912,1,13,32544,44168,17248,2560.8 +2560,6912,1,14,31232,40765,15904,2563.2 +2560,6912,1,15,31776,45815,17888,2561.2 +2560,6912,1,16,31648,41214,16064,2565.6 +2560,6912,1,17,31552,41721,16256,2566.5 +2560,6912,1,18,31360,40806,15904,2565.8 +2560,6912,1,19,32448,41398,16128,2566.8 +2560,6912,1,20,32832,39984,15584,2565.7 +2560,6912,1,21,31168,41561,16224,2561.7 +2560,6912,1,22,40768,51696,20128,2568.4 +2560,6912,2,0,31104,39623,15488,2558.3 +2560,6912,2,1,32160,39803,15552,2559.3 +2560,6912,2,2,31360,41105,16064,2558.8 +2560,6912,2,3,32896,41132,16032,2565.6 +2560,6912,2,4,29984,42254,16480,2564.0 +2560,6912,2,5,32256,40572,15808,2566.5 +2560,6912,2,6,33120,41470,16128,2571.3 +2560,6912,2,7,31936,38201,14880,2567.3 +2560,6912,2,8,31168,40024,15584,2568.3 +2560,6912,2,9,32480,41482,16192,2561.9 +2560,6912,2,10,37856,39419,15360,2566.3 +2560,6912,2,11,30624,41357,16160,2559.2 +2560,6912,2,12,30272,38983,15200,2564.7 +2560,6912,2,13,32448,42749,16704,2559.2 +2560,6912,2,14,31872,41273,16128,2559.1 +2560,6912,2,15,32448,40329,15744,2561.5 +2560,6912,2,16,31776,41136,16064,2560.8 +2560,6912,2,17,29920,41380,16128,2565.7 +2560,6912,2,18,31200,40665,15872,2562.1 +2560,6912,2,19,32224,41010,16000,2563.1 +2560,6912,2,20,31104,39235,15328,2559.7 +2560,6912,2,21,31072,42200,16480,2560.7 +2560,6912,2,22,41024,45902,17888,2566.1 +2560,6912,3,0,31392,40723,15904,2560.6 +2560,6912,3,1,31232,39647,15456,2565.2 +2560,6912,3,2,31328,43271,16928,2556.2 +2560,6912,3,3,32544,39517,15392,2567.4 +2560,6912,3,4,31456,41568,16256,2557.1 +2560,6912,3,5,31808,39578,15456,2560.7 +2560,6912,3,6,33504,42597,16672,2555.0 +2560,6912,3,7,32352,41443,16160,2564.5 +2560,6912,3,8,32640,41197,16064,2564.6 +2560,6912,3,9,33248,43424,16928,2565.2 +2560,6912,3,10,31360,41322,16096,2567.2 +2560,6912,3,11,31072,41798,16320,2561.2 +2560,6912,3,12,31680,41340,16128,2563.2 +2560,6912,3,13,31872,43366,16896,2566.6 +2560,6912,3,14,31168,40916,15936,2567.5 +2560,6912,3,15,32704,40436,15776,2563.1 +2560,6912,3,16,31040,40666,15840,2567.3 +2560,6912,3,17,32608,41654,16224,2567.4 +2560,6912,3,18,30656,41087,16032,2562.8 +2560,6912,3,19,31872,40709,15904,2559.7 +2560,6912,3,20,31712,37721,14720,2562.6 +2560,6912,3,21,30784,40558,15808,2565.7 +2560,6912,3,22,40576,50587,19680,2570.5 +2560,6912,4,0,31264,40721,15904,2560.4 +2560,6912,4,1,31200,38587,15104,2554.8 +2560,6912,4,2,31232,41402,16160,2562.0 +2560,6912,4,3,33184,40394,15776,2560.5 +2560,6912,4,4,30176,43245,16864,2564.3 +2560,6912,4,5,32448,41543,16192,2565.6 +2560,6912,4,6,32768,40944,15968,2564.1 +2560,6912,4,7,32544,40975,16000,2560.9 +2560,6912,4,8,30816,40961,15968,2565.2 +2560,6912,4,9,33184,42386,16544,2562.0 +2560,6912,4,10,31840,39430,15392,2561.7 +2560,6912,4,11,30912,40657,15904,2556.4 +2560,6912,4,12,30592,40294,15680,2569.8 +2560,6912,4,13,31872,43808,17120,2558.9 +2560,6912,4,14,31360,41439,16192,2559.2 +2560,6912,4,15,31296,36986,14432,2562.8 +2560,6912,4,16,30720,40382,15744,2564.9 +2560,6912,4,17,30784,42964,16768,2562.3 +2560,6912,4,18,32000,40560,15872,2555.4 +2560,6912,4,19,32064,39762,15552,2556.7 +2560,6912,4,20,31488,39561,15456,2559.6 +2560,6912,4,21,31136,39429,15424,2556.3 +2560,6912,4,22,41472,49516,19360,2557.6 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1.json new file mode 100644 index 000000000..94c431316 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.744, "min_us": 3.584}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 25056, "min_ns": 20352, "gbs": 98.08, "of_spec_273": 0.3593, "of_practical_237_2": 0.4135, "minus_floor_ns": 21312, "minus_floor_gbs": 115.32, "minus_floor_of_spec_273": 0.4224, "minus_floor_of_practical_237_2": 0.4862, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16128, "min_ns": 13920, "gbs": 101.59, "of_spec_273": 0.3721, "of_practical_237_2": 0.4283, "minus_floor_ns": 12384, "minus_floor_gbs": 132.30, "minus_floor_of_spec_273": 0.4846, "minus_floor_of_practical_237_2": 0.5578, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 52768, "min_ns": 34944, "gbs": 167.67, "of_spec_273": 0.6142, "of_practical_237_2": 0.7069, "minus_floor_ns": 49024, "minus_floor_gbs": 180.47, "minus_floor_of_spec_273": 0.6611, "minus_floor_of_practical_237_2": 0.7608, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 31872, "min_ns": 27840, "gbs": 138.80, "of_spec_273": 0.5084, "of_practical_237_2": 0.5851, "minus_floor_ns": 28128, "minus_floor_gbs": 157.27, "minus_floor_of_spec_273": 0.5761, "minus_floor_of_practical_237_2": 0.6630, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1.meta new file mode 100644 index 000000000..c5a5f17f9 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:28:09Z +aab7a06828cabd73740a0d3d03f335a331496bbab24edea7be29d18ecd84d195 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/clockcam +208 MHz, [N/A], 38, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16.json new file mode 100644 index 000000000..835445f7e --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.712, "min_us": 3.488}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 0, "copies": 656, "median_ns": 0, "min_ns": 0, "gbs": 0.00, "of_spec_273": 0.0000, "of_practical_237_2": 0.0000, "minus_floor_ns": 0, "minus_floor_gbs": 0.00, "minus_floor_of_spec_273": 0.0000, "minus_floor_of_practical_237_2": 0.0000, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 0, "copies": 992, "median_ns": 0, "min_ns": 0, "gbs": 0.00, "of_spec_273": 0.0000, "of_practical_237_2": 0.0000, "minus_floor_ns": 0, "minus_floor_gbs": 0.00, "minus_floor_of_spec_273": 0.0000, "minus_floor_of_practical_237_2": 0.0000, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 192, "median_ns": 59296, "min_ns": 53600, "gbs": 149.21, "of_spec_273": 0.5465, "of_practical_237_2": 0.6290, "minus_floor_ns": 55584, "minus_floor_gbs": 159.17, "minus_floor_of_spec_273": 0.5830, "minus_floor_of_practical_237_2": 0.6710, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 368, "median_ns": 31264, "min_ns": 28288, "gbs": 141.49, "of_spec_273": 0.5183, "of_practical_237_2": 0.5965, "minus_floor_ns": 27552, "minus_floor_gbs": 160.56, "minus_floor_of_spec_273": 0.5881, "minus_floor_of_practical_237_2": 0.6769, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 6, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16.meta new file mode 100644 index 000000000..e70a62c4e --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/clockcam-m16.meta @@ -0,0 +1,5 @@ +2026-10-16T02:28:11Z +aab7a06828cabd73740a0d3d03f335a331496bbab24edea7be29d18ecd84d195 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/clockcam +208 MHz, [N/A], 38, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240.json new file mode 100644 index 000000000..d63ffd44e --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 240}, + "launch_floor_in_list": {"median_us": 3.520, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 23360, "min_ns": 17664, "gbs": 105.21, "of_spec_273": 0.3854, "of_practical_237_2": 0.4435, "minus_floor_ns": 19840, "minus_floor_gbs": 123.87, "minus_floor_of_spec_273": 0.4537, "minus_floor_of_practical_237_2": 0.5222, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15840, "min_ns": 13472, "gbs": 103.43, "of_spec_273": 0.3789, "of_practical_237_2": 0.4361, "minus_floor_ns": 12320, "minus_floor_gbs": 132.99, "minus_floor_of_spec_273": 0.4871, "minus_floor_of_practical_237_2": 0.5607, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 58240, "min_ns": 52384, "gbs": 151.91, "of_spec_273": 0.5565, "of_practical_237_2": 0.6404, "minus_floor_ns": 54720, "minus_floor_gbs": 161.68, "minus_floor_of_spec_273": 0.5922, "minus_floor_of_practical_237_2": 0.6816, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 32288, "min_ns": 25312, "gbs": 137.01, "of_spec_273": 0.5019, "of_practical_237_2": 0.5776, "minus_floor_ns": 28768, "minus_floor_gbs": 153.77, "minus_floor_of_spec_273": 0.5633, "minus_floor_of_practical_237_2": 0.6483, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240.meta new file mode 100644 index 000000000..df05b4de6 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-240.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:30Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +253 MHz, [N/A], 40, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320.json new file mode 100644 index 000000000..fedcbbdd4 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 320}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.168}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 22528, "min_ns": 18432, "gbs": 109.09, "of_spec_273": 0.3996, "of_practical_237_2": 0.4599, "minus_floor_ns": 19104, "minus_floor_gbs": 128.64, "minus_floor_of_spec_273": 0.4712, "minus_floor_of_practical_237_2": 0.5423, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15968, "min_ns": 13504, "gbs": 102.61, "of_spec_273": 0.3758, "of_practical_237_2": 0.4326, "minus_floor_ns": 12544, "minus_floor_gbs": 130.61, "minus_floor_of_spec_273": 0.4784, "minus_floor_of_practical_237_2": 0.5506, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 60544, "min_ns": 43232, "gbs": 146.13, "of_spec_273": 0.5353, "of_practical_237_2": 0.6161, "minus_floor_ns": 57120, "minus_floor_gbs": 154.89, "minus_floor_of_spec_273": 0.5674, "minus_floor_of_practical_237_2": 0.6530, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 30400, "min_ns": 26368, "gbs": 145.52, "of_spec_273": 0.5330, "of_practical_237_2": 0.6135, "minus_floor_ns": 26976, "minus_floor_gbs": 163.99, "minus_floor_of_spec_273": 0.6007, "minus_floor_of_practical_237_2": 0.6913, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320.meta new file mode 100644 index 000000000..a397f873c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-320.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:32Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 40, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640.json new file mode 100644 index 000000000..c2f617040 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 640}, + "launch_floor_in_list": {"median_us": 3.392, "min_us": 3.168}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 22112, "min_ns": 17728, "gbs": 111.14, "of_spec_273": 0.4071, "of_practical_237_2": 0.4686, "minus_floor_ns": 18720, "minus_floor_gbs": 131.28, "minus_floor_of_spec_273": 0.4809, "minus_floor_of_practical_237_2": 0.5535, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15520, "min_ns": 13888, "gbs": 105.57, "of_spec_273": 0.3867, "of_practical_237_2": 0.4451, "minus_floor_ns": 12128, "minus_floor_gbs": 135.09, "minus_floor_of_spec_273": 0.4948, "minus_floor_of_practical_237_2": 0.5695, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 68256, "min_ns": 47072, "gbs": 129.62, "of_spec_273": 0.4748, "of_practical_237_2": 0.5465, "minus_floor_ns": 64864, "minus_floor_gbs": 136.40, "minus_floor_of_spec_273": 0.4996, "minus_floor_of_practical_237_2": 0.5750, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 30112, "min_ns": 25184, "gbs": 146.91, "of_spec_273": 0.5381, "of_practical_237_2": 0.6193, "minus_floor_ns": 26720, "minus_floor_gbs": 165.56, "minus_floor_of_spec_273": 0.6064, "minus_floor_of_practical_237_2": 0.6980, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640.meta new file mode 100644 index 000000000..33080550d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-640.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:34Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 40, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96.json new file mode 100644 index 000000000..5ad0b7399 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 96}, + "launch_floor_in_list": {"median_us": 3.488, "min_us": 3.296}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 25408, "min_ns": 21568, "gbs": 96.73, "of_spec_273": 0.3543, "of_practical_237_2": 0.4078, "minus_floor_ns": 21920, "minus_floor_gbs": 112.12, "minus_floor_of_spec_273": 0.4107, "minus_floor_of_practical_237_2": 0.4727, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 21472, "min_ns": 16608, "gbs": 76.30, "of_spec_273": 0.2795, "of_practical_237_2": 0.3217, "minus_floor_ns": 17984, "minus_floor_gbs": 91.10, "minus_floor_of_spec_273": 0.3337, "minus_floor_of_practical_237_2": 0.3841, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 56032, "min_ns": 30656, "gbs": 157.90, "of_spec_273": 0.5784, "of_practical_237_2": 0.6657, "minus_floor_ns": 52544, "minus_floor_gbs": 168.38, "minus_floor_of_spec_273": 0.6168, "minus_floor_of_practical_237_2": 0.7099, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29152, "min_ns": 24800, "gbs": 151.75, "of_spec_273": 0.5558, "of_practical_237_2": 0.6397, "minus_floor_ns": 25664, "minus_floor_gbs": 172.37, "minus_floor_of_spec_273": 0.6314, "minus_floor_of_practical_237_2": 0.7267, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96.meta new file mode 100644 index 000000000..1d43cd49b --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/ctas-96.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:28Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 40, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1.json new file mode 100644 index 000000000..5bee22396 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 1, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 25344, "min_ns": 22272, "gbs": 96.97, "of_spec_273": 0.3552, "of_practical_237_2": 0.4088, "minus_floor_ns": 21920, "minus_floor_gbs": 112.12, "minus_floor_of_spec_273": 0.4107, "minus_floor_of_practical_237_2": 0.4727, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 17984, "min_ns": 15712, "gbs": 91.10, "of_spec_273": 0.3337, "of_practical_237_2": 0.3841, "minus_floor_ns": 14560, "minus_floor_gbs": 112.53, "minus_floor_of_spec_273": 0.4122, "minus_floor_of_practical_237_2": 0.4744, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 62592, "min_ns": 34144, "gbs": 141.35, "of_spec_273": 0.5178, "of_practical_237_2": 0.5959, "minus_floor_ns": 59168, "minus_floor_gbs": 149.53, "minus_floor_of_spec_273": 0.5477, "minus_floor_of_practical_237_2": 0.6304, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 42368, "min_ns": 31648, "gbs": 104.41, "of_spec_273": 0.3825, "of_practical_237_2": 0.4402, "minus_floor_ns": 38944, "minus_floor_gbs": 113.59, "minus_floor_of_spec_273": 0.4161, "minus_floor_of_practical_237_2": 0.4789, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1.meta new file mode 100644 index 000000000..f17d52dcf --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:26Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +279 MHz, [N/A], 37, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2.json new file mode 100644 index 000000000..bcf5048e2 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 2, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.520, "min_us": 3.264}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 22240, "min_ns": 19968, "gbs": 110.50, "of_spec_273": 0.4048, "of_practical_237_2": 0.4659, "minus_floor_ns": 18720, "minus_floor_gbs": 131.28, "minus_floor_of_spec_273": 0.4809, "minus_floor_of_practical_237_2": 0.5535, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 17504, "min_ns": 15072, "gbs": 93.60, "of_spec_273": 0.3429, "of_practical_237_2": 0.3946, "minus_floor_ns": 13984, "minus_floor_gbs": 117.16, "minus_floor_of_spec_273": 0.4292, "minus_floor_of_practical_237_2": 0.4939, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 55456, "min_ns": 32032, "gbs": 159.54, "of_spec_273": 0.5844, "of_practical_237_2": 0.6726, "minus_floor_ns": 51936, "minus_floor_gbs": 170.35, "minus_floor_of_spec_273": 0.6240, "minus_floor_of_practical_237_2": 0.7182, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 43808, "min_ns": 32320, "gbs": 100.98, "of_spec_273": 0.3699, "of_practical_237_2": 0.4257, "minus_floor_ns": 40288, "minus_floor_gbs": 109.80, "minus_floor_of_spec_273": 0.4022, "minus_floor_of_practical_237_2": 0.4629, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2.meta new file mode 100644 index 000000000..94f13bb44 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-2.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:28Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +806 MHz, [N/A], 38, 5 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3.json new file mode 100644 index 000000000..cc5af2f22 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 2, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.456, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 21888, "min_ns": 19488, "gbs": 112.28, "of_spec_273": 0.4113, "of_practical_237_2": 0.4734, "minus_floor_ns": 18432, "minus_floor_gbs": 133.33, "minus_floor_of_spec_273": 0.4884, "minus_floor_of_practical_237_2": 0.5621, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 17376, "min_ns": 15392, "gbs": 94.29, "of_spec_273": 0.3454, "of_practical_237_2": 0.3975, "minus_floor_ns": 13920, "minus_floor_gbs": 117.70, "minus_floor_of_spec_273": 0.4311, "minus_floor_of_practical_237_2": 0.4962, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 54048, "min_ns": 33824, "gbs": 163.69, "of_spec_273": 0.5996, "of_practical_237_2": 0.6901, "minus_floor_ns": 50592, "minus_floor_gbs": 174.88, "minus_floor_of_spec_273": 0.6406, "minus_floor_of_practical_237_2": 0.7373, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 30176, "min_ns": 26080, "gbs": 146.60, "of_spec_273": 0.5370, "of_practical_237_2": 0.6180, "minus_floor_ns": 26720, "minus_floor_gbs": 165.56, "minus_floor_of_spec_273": 0.6064, "minus_floor_of_practical_237_2": 0.6980, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3.meta new file mode 100644 index 000000000..156c20dc9 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-3.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:31Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 37, 5 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4.json new file mode 100644 index 000000000..cf46d77b7 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 2, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 21888, "min_ns": 19392, "gbs": 112.28, "of_spec_273": 0.4113, "of_practical_237_2": 0.4734, "minus_floor_ns": 18464, "minus_floor_gbs": 133.10, "minus_floor_of_spec_273": 0.4876, "minus_floor_of_practical_237_2": 0.5611, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 17248, "min_ns": 15200, "gbs": 94.99, "of_spec_273": 0.3480, "of_practical_237_2": 0.4005, "minus_floor_ns": 13824, "minus_floor_gbs": 118.52, "minus_floor_of_spec_273": 0.4341, "minus_floor_of_practical_237_2": 0.4997, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 54752, "min_ns": 31776, "gbs": 161.59, "of_spec_273": 0.5919, "of_practical_237_2": 0.6812, "minus_floor_ns": 51328, "minus_floor_gbs": 172.37, "minus_floor_of_spec_273": 0.6314, "minus_floor_of_practical_237_2": 0.7267, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29696, "min_ns": 24064, "gbs": 148.97, "of_spec_273": 0.5457, "of_practical_237_2": 0.6280, "minus_floor_ns": 26272, "minus_floor_gbs": 168.38, "minus_floor_of_spec_273": 0.6168, "minus_floor_of_practical_237_2": 0.7099, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4.meta new file mode 100644 index 000000000..8cfedf6dd --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-4.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:33Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 38, 4 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5.json new file mode 100644 index 000000000..9993181bf --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 5, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.392, "min_us": 3.136}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24640, "min_ns": 21408, "gbs": 99.74, "of_spec_273": 0.3653, "of_practical_237_2": 0.4205, "minus_floor_ns": 21248, "minus_floor_gbs": 115.66, "minus_floor_of_spec_273": 0.4237, "minus_floor_of_practical_237_2": 0.4876, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 21568, "min_ns": 16448, "gbs": 75.96, "of_spec_273": 0.2783, "of_practical_237_2": 0.3203, "minus_floor_ns": 18176, "minus_floor_gbs": 90.14, "minus_floor_of_spec_273": 0.3302, "minus_floor_of_practical_237_2": 0.3800, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 55200, "min_ns": 32256, "gbs": 160.28, "of_spec_273": 0.5871, "of_practical_237_2": 0.6757, "minus_floor_ns": 51808, "minus_floor_gbs": 170.77, "minus_floor_of_spec_273": 0.6255, "minus_floor_of_practical_237_2": 0.7199, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 31584, "min_ns": 26272, "gbs": 140.06, "of_spec_273": 0.5130, "of_practical_237_2": 0.5905, "minus_floor_ns": 28192, "minus_floor_gbs": 156.91, "minus_floor_of_spec_273": 0.5748, "minus_floor_of_practical_237_2": 0.6615, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5.meta new file mode 100644 index 000000000..cc24726cf --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/depth-5.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:35Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +253 MHz, [N/A], 37, 4 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1.json new file mode 100644 index 000000000..f8fceae26 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.488, "min_us": 3.328}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 16192, "min_ns": 14592, "gbs": 151.78, "of_spec_273": 0.5560, "of_practical_237_2": 0.6399, "minus_floor_ns": 12704, "minus_floor_gbs": 193.45, "minus_floor_of_spec_273": 0.7086, "minus_floor_of_practical_237_2": 0.8156, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13536, "min_ns": 12768, "gbs": 121.04, "of_spec_273": 0.4434, "of_practical_237_2": 0.5103, "minus_floor_ns": 10048, "minus_floor_gbs": 163.06, "minus_floor_of_spec_273": 0.5973, "minus_floor_of_practical_237_2": 0.6874, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 43488, "min_ns": 38048, "gbs": 203.44, "of_spec_273": 0.7452, "of_practical_237_2": 0.8577, "minus_floor_ns": 40000, "minus_floor_gbs": 221.18, "minus_floor_of_spec_273": 0.8102, "minus_floor_of_practical_237_2": 0.9325, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 28768, "min_ns": 25888, "gbs": 153.77, "of_spec_273": 0.5633, "of_practical_237_2": 0.6483, "minus_floor_ns": 25280, "minus_floor_gbs": 174.99, "minus_floor_of_spec_273": 0.6410, "minus_floor_of_practical_237_2": 0.7377, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 2, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1.meta new file mode 100644 index 000000000..2724d4d2f --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:46:47Z +5b94c89188932bf45f036daba897c3491069c650612d02cb34c7a5d2b72bea4c /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/fix +208 MHz, [N/A], 52, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1.json new file mode 100644 index 000000000..af79acc00 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.680, "min_us": 3.424}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 15360, "min_ns": 14720, "gbs": 160.00, "of_spec_273": 0.5861, "of_practical_237_2": 0.6745, "minus_floor_ns": 11680, "minus_floor_gbs": 210.41, "minus_floor_of_spec_273": 0.7707, "minus_floor_of_practical_237_2": 0.8871, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13376, "min_ns": 13120, "gbs": 122.49, "of_spec_273": 0.4487, "of_practical_237_2": 0.5164, "minus_floor_ns": 9696, "minus_floor_gbs": 168.98, "minus_floor_of_spec_273": 0.6190, "minus_floor_of_practical_237_2": 0.7124, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 42816, "min_ns": 22720, "gbs": 206.64, "of_spec_273": 0.7569, "of_practical_237_2": 0.8711, "minus_floor_ns": 39136, "minus_floor_gbs": 226.07, "minus_floor_of_spec_273": 0.8281, "minus_floor_of_practical_237_2": 0.9531, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 27904, "min_ns": 21760, "gbs": 158.53, "of_spec_273": 0.5807, "of_practical_237_2": 0.6683, "minus_floor_ns": 24224, "minus_floor_gbs": 182.62, "minus_floor_of_spec_273": 0.6689, "minus_floor_of_practical_237_2": 0.7699, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1.meta new file mode 100644 index 000000000..b0159114c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/fix2-1.meta @@ -0,0 +1,5 @@ +2026-10-16T03:03:07Z +2619f439b5084e72e3e501587b1afcb66a2863ea6100a5cdc163004822b26068 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/fix2 +208 MHz, [N/A], 45, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline.json new file mode 100644 index 000000000..25b3f1040 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.648, "min_us": 3.232}, + "hot_diagnostic": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 18304, "min_ns": 14816, "gbs": 134.27, "of_spec_273": 0.4918, "of_practical_237_2": 0.5660, "minus_floor_ns": 14656, "minus_floor_gbs": 167.69, "minus_floor_of_spec_273": 0.6142, "minus_floor_of_practical_237_2": 0.7069, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 14816, "min_ns": 10944, "gbs": 110.58, "of_spec_273": 0.4051, "of_practical_237_2": 0.4662, "minus_floor_ns": 11168, "minus_floor_gbs": 146.70, "minus_floor_of_spec_273": 0.5374, "minus_floor_of_practical_237_2": 0.6185, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 31488, "min_ns": 28256, "gbs": 280.98, "of_spec_273": 1.0292, "of_practical_237_2": 1.1846, "minus_floor_ns": 27840, "minus_floor_gbs": 317.79, "minus_floor_of_spec_273": 1.1641, "minus_floor_of_practical_237_2": 1.3398, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 23072, "min_ns": 20288, "gbs": 191.73, "of_spec_273": 0.7023, "of_practical_237_2": 0.8083, "minus_floor_ns": 19424, "minus_floor_gbs": 227.74, "minus_floor_of_spec_273": 0.8342, "minus_floor_of_practical_237_2": 0.9601, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 5, "failed": 0, "verdict": "PASS" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline.meta new file mode 100644 index 000000000..63eaa22cd --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/hot-baseline.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:25Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +806 MHz, [N/A], 37, 4 % +negative_exit=1 +exit=0 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1-negative.json new file mode 100644 index 000000000..3d3add2ea --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1920, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1.json new file mode 100644 index 000000000..2ded25f9f --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.360, "min_us": 3.168}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 27456, "min_ns": 23424, "gbs": 89.51, "of_spec_273": 0.3279, "of_practical_237_2": 0.3774, "minus_floor_ns": 24096, "minus_floor_gbs": 101.99, "minus_floor_of_spec_273": 0.3736, "minus_floor_of_practical_237_2": 0.4300, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 23872, "min_ns": 18560, "gbs": 68.63, "of_spec_273": 0.2514, "of_practical_237_2": 0.2893, "minus_floor_ns": 20512, "minus_floor_gbs": 79.88, "minus_floor_of_spec_273": 0.2926, "minus_floor_of_practical_237_2": 0.3367, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 53568, "min_ns": 36480, "gbs": 165.16, "of_spec_273": 0.6050, "of_practical_237_2": 0.6963, "minus_floor_ns": 50208, "minus_floor_gbs": 176.21, "minus_floor_of_spec_273": 0.6455, "minus_floor_of_practical_237_2": 0.7429, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 27616, "min_ns": 24320, "gbs": 160.19, "of_spec_273": 0.5868, "of_practical_237_2": 0.6753, "minus_floor_ns": 24256, "minus_floor_gbs": 182.37, "minus_floor_of_spec_273": 0.6680, "minus_floor_of_practical_237_2": 0.7689, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 3, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1.meta new file mode 100644 index 000000000..813cfcbd1 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/load-probe-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:15:19Z +70270ed3ca2808d25e8829e6208aee00e9ce970c6b36b0f92be989beb3c08f0b /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/load-probe +208 MHz, [N/A], 37, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1.json new file mode 100644 index 000000000..8913096a7 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.456, "min_us": 3.328}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 23040, "min_ns": 19872, "gbs": 106.67, "of_spec_273": 0.3907, "of_practical_237_2": 0.4497, "minus_floor_ns": 19584, "minus_floor_gbs": 125.49, "minus_floor_of_spec_273": 0.4597, "minus_floor_of_practical_237_2": 0.5290, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15776, "min_ns": 12640, "gbs": 103.85, "of_spec_273": 0.3804, "of_practical_237_2": 0.4378, "minus_floor_ns": 12320, "minus_floor_gbs": 132.99, "minus_floor_of_spec_273": 0.4871, "minus_floor_of_practical_237_2": 0.5607, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 52000, "min_ns": 35072, "gbs": 170.14, "of_spec_273": 0.6232, "of_practical_237_2": 0.7173, "minus_floor_ns": 48544, "minus_floor_gbs": 182.25, "minus_floor_of_spec_273": 0.6676, "minus_floor_of_practical_237_2": 0.7684, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 28160, "min_ns": 24416, "gbs": 157.09, "of_spec_273": 0.5754, "of_practical_237_2": 0.6623, "minus_floor_ns": 24704, "minus_floor_gbs": 179.07, "minus_floor_of_spec_273": 0.6559, "minus_floor_of_practical_237_2": 0.7549, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1.meta new file mode 100644 index 000000000..ac010a03d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:13:34Z +aed1a98750e5bea267a091ca4a0bb44eab1e22b7a47fd3e5be0f70da859c2a85 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/no-readwait +208 MHz, [N/A], 37, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot.json new file mode 100644 index 000000000..f97aff493 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.392, "min_us": 3.232}, + "hot_diagnostic": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 18496, "min_ns": 14432, "gbs": 132.87, "of_spec_273": 0.4867, "of_practical_237_2": 0.5602, "minus_floor_ns": 15104, "minus_floor_gbs": 162.71, "minus_floor_of_spec_273": 0.5960, "minus_floor_of_practical_237_2": 0.6860, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15072, "min_ns": 10144, "gbs": 108.70, "of_spec_273": 0.3982, "of_practical_237_2": 0.4583, "minus_floor_ns": 11680, "minus_floor_gbs": 140.27, "minus_floor_of_spec_273": 0.5138, "minus_floor_of_practical_237_2": 0.5914, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 31648, "min_ns": 28256, "gbs": 279.56, "of_spec_273": 1.0240, "of_practical_237_2": 1.1786, "minus_floor_ns": 28256, "minus_floor_gbs": 313.11, "minus_floor_of_spec_273": 1.1469, "minus_floor_of_practical_237_2": 1.3200, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 22400, "min_ns": 19872, "gbs": 197.49, "of_spec_273": 0.7234, "of_practical_237_2": 0.8326, "minus_floor_ns": 19008, "minus_floor_gbs": 232.73, "minus_floor_of_spec_273": 0.8525, "minus_floor_of_practical_237_2": 0.9811, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 5, "failed": 0, "verdict": "PASS" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot.meta new file mode 100644 index 000000000..24bf04651 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/no-readwait-hot.meta @@ -0,0 +1,5 @@ +2026-10-16T02:13:36Z +aed1a98750e5bea267a091ca4a0bb44eab1e22b7a47fd3e5be0f70da859c2a85 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/no-readwait +253 MHz, [N/A], 37, 4 % +negative_exit=1 +exit=0 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/plan.md b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/plan.md new file mode 100644 index 000000000..374705014 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/plan.md @@ -0,0 +1,81 @@ +# KT1 speed investigation +DOCS READ: NVIDIA Best Practices 13.4 section 10.2.1: "the data access unit is 32-byte regardless of whether global loads are cached in L1 or not." nvos.h:1114-1118: "For system memory this will not be coherent with direct CPU mappings." DOCS SILENT on GB10 SASS scheduling. +SYMPTOM: Four L2-defeated ternary GEMV shapes miss existing bandwidth gates. +1. Freeze original sources and binary from origin/main 8edeab5e; pin physics 6d7cf0d4 and driver 580.173.02. +2. Baseline five runs of existing --bw-only gate, with forced mutant 2 negative control in each run. Same output slices, input seed, allocations and measured path. +3. One-variable experiments: load width/layout, rows/warps/CTA count, depth, staging/compute schedule. Predictions recorded before each experiment; repeat promising variants five times. Hot runs diagnostic only. +4. Fix, host and simulator tests, full chip correctness (115500 rows), mutants, five cold speed runs. Compare both measured floor and original fixed 3424 ns to avoid moving the gate. +5. Archive every variant and receipt, seal this exact folder, publish one PR without merging. +CAMERA: Existing JSON records time, bytes, parity, gate failures after launches; source/binary hashes accompany each experiment. No timing-path logging. +NEGATIVE CONTROL: Forced mutant 2 must exit 1 with 1919/3840 wrong scaled rows; final full suite also exercises mutants 1 and 3. Existing poison before each launch and oracle after each list retained. +RULES: <=20 minute quietlock run windows, yield to other lanes; no killing others; no port 18092; no Python/CUDA/third-party engines. +## Deviations +Initial recursive file discovery was overly broad; narrowed to relevant directories. The scaffold inspects stale ~/workspace/omega, so appended explicit pins of the actual worktree and linked physics. +## Results +Pending. + +Baseline-1 reproduces all four failures (fractions .4741/.5410/.7491/.6913); forced wrong segment map fails as expected. Remaining repeats and shape experiments now use quietlock run -- quietlock hold: discovered run alone checks the flag but does not acquire it, first run had check only and is retained, not used as the five locked baseline repeats. +Ranked predictions before variants: +1. Grid tail: 3840 rows require 240 CTAs at R1/W8 but cap160 forces half the blocks through a second unit; raising just CTA cap improves it if launch work imbalance matters. +2. Memory issue parallelism: D10 at K2560 vs D9 at K6912 issues narrow per-row loads; widening and/or depth changes improve cold if outstanding requests are insufficient. +3. Instruction/staging cost: hot speed sets a compute floor; reducing scalar staging stores or independent instruction stalls helps hot and cold together. +4. Occupancy: lowering warps or registers changes active blocks; results should depend on shape and SM distribution. +5. Output serialization: independent uncached output slices may add a store/translation penalty; diagnostic shared output timing can test this, but cannot replace per-launch verified outputs for the gate. + +First sweeps: CTA, warp, depth and block-layout variants all still fail. Hot baseline misses both smaller gates too, so memory translation alone cannot explain the gap. Next single-variable probe: K_VAR_MORE currently waits for the previous load's source-read barrier before issuing another independent load. Remove only that wait within load groups; keep write/read scoreboard assignment and the final wait. No load group changes its address or reuses a destination before the existing drain. Prediction: faster cold/hot if artificial load serialization matters. Source copy, host/simulator and chip negative controls required before credit. + +no-readwait probe improves only modestly; all gates still fail in first run, no accepted claim yet. Next: replace only the dot/unpack arithmetic with sum-of-packed-word checksum; preserve all global weight loads, activation staging and shared loads, reduction and output topology. Host reference explicitly becomes packed-word checksum for this diagnostic binary only, and its records are NOT ternary correctness evidence. If throughput still misses gates, arithmetic cannot be the dominant limiter. Forced wrong-segment control remains red. Registers may decrease due dead arithmetic temporaries: that biases this probe toward faster execution, so persistent slowness is stronger evidence against arithmetic as main cause. + +Packed checksum probe still misses the small-shape gates and is even slower there; 13824 unchanged, 6912 slightly faster. This is inconsistent with simple instruction count being dominant. Next output-address control restores original ternary arithmetic and shares output addresses (diagnostic ONLY, never gate evidence) to test the reported previous-worker difference. Also sample clocks during the tiny bursts: all pre-run clocks have been 208 MHz, so dynamic ramp-up remains unmeasured, not excluded. + +## Continuation (Fable 5.1, 2026-10-15 21:3x local, after Astra's usage limit) +DOCS READ (added): CUDA Programming Guide appendices, clock()/clock64(): "return a per-multiprocessor counter value that increments each clock cycle". S2R ids SR_CLOCKLO 0x50, SR_GLOBALTIMERLO 0x52 (0x52 already used by src/runtime/rx_resident_gpu.c:141). nvidia-smi -q: P8, SM 208 MHz, applications clock 2418 MHz, max 3003 MHz. DOCS SILENT on GB10 clock ramp policy and ramp time. +Ground re-read: 111 nvidia-smi samples at ~20 ms during the stamps run never read above 227 MHz (runs/clocks-stamps.csv). Per-launch stamps show no trend along a list (lists last ~1 ms). The word table (0.92) is one 657 MB launch of 3 ms, 20 reps back to back: a sustained load, not a 25 us burst. Hot diagnostic fits time = a + b*bytes with a ~ 7.4 us at k 2560 and ~ 9.2 us at k 6912 beyond the launch floor: a per-launch serial cost that grows with k, which is what a slow SM clock would inflate. +Prediction P6 (clock), ranked first now: the SM clock stays near 208 MHz during these lists; the per-launch serial chain (x staging, first load, one unit's arithmetic, store) at 208 MHz is the fixed cost that sinks the small shapes. If true: (i) an in-kernel camera (SR_CLOCKLO delta / SR_GLOBALTIMERLO delta for CTA 0 warp 0) reads 200-300 MHz in the baseline lists; (ii) a list 20x longer shows per-launch time falling along the list as the clock ramps, and the camera shows the MHz rising; (iii) the camera itself must not change the stamps (clockcam at mult 1 within baseline spread). If the camera reads > 1500 MHz in the baseline lists, P6 is dead and the cause is in the kernel. +Negative control for the camera: a value outside [100, 3100] MHz or a poison word prints UNKNOWN; forced mutant 2 stays red in every run. +Variants: clockcam (baseline + camera, diagnostic only, writes 2 words past row n of each output slice; slice stride widened by 8 words in the diagnostic test), then clockcam --copies-mult 20 (one variable: list length). + +### Result: clock camera (clockcam-1, clockcam-m16) +[OBSERVED runs/clockcam-1-cam.csv] In-kernel SR_CLOCKLO/SR_GLOBALTIMERLO ratio for CTA 0: median 2563-2574 MHz on every shape including the 8x256 floor launches (850 launches, 0 UNKNOWN; a few launches read 546-1456 MHz, consistent with CTA 0's warp being time-sliced, as the CUDA docs warn). nvidia-smi at 20 ms sampled 208-273 MHz through the same run. P6 (clock stays idle) is DEAD: the SM runs at ~2.56 GHz during the launches; nvidia-smi's clock reading misses microsecond bursts. Camera cost: clockcam-1 stamps are inside the baseline spread (0.486/0.558/0.761/0.663). +[OBSERVED] CTA 0 lifetime vs stamp interval: 8x256 1.0 of 3.7 us (so ~2.7 us of the floor is outside any CTA); 3840x2560 14.6 of 25.1 us; 2560x2560 10.4 of 16.1; 2560x6912 16.1 of 31.9; 13824x2560 44.9 of 52.7. On 2560x6912 every CTA has identical work, yet CTA 0 covers only half the launch: either CTAs start late (launch ramp) or finish very unevenly. +clockcam-m16 (16x lists): 3840 and 2560x2560 lists of 656/992 launches failed the oracle check (list too long for the cmdlist or the test, UNKNOWN which; not pursued; 13824 at 192 launches ran, 0.671, no speedup from the longer list). Not evidence either way beyond: longer lists do not help. +Next camera (P7, timeline): per CTA, thread 0 records globaltimer at start, after x staging, at end. Prediction: if CTAs start spread over many us, the launch ramp is the fixed cost; if they start together but staging takes several us, x staging is; if lifetimes are very unequal, memory service is unfair. + +### Result: timeline camera (timeline-1, timeline-hot, timeline-nostore-1) +[OBSERVED runs/timeline-1-cam.csv] All 160 CTAs start within 0.3-0.45 us on the k 2560 shapes (no launch ramp). x staging (uncached x load, unpack, STS, bar) takes 2.3-3.2 us median, up to 5-6 us, in every CTA, cold and hot: the first ~3 us of every launch move no weights. CTA lifetimes are very unequal (3840x2560: median 11.8 us, max 25 us): the strided unit map gives 80 CTAs two units per warp and 80 CTAs one. 2560x6912: CTA starts spread over 19-22 us: with 13,824 B shared memory per CTA the 160 CTAs do not all fit at once and run in waves (QMD word 36 keeps the SM shared-memory config fields as they were; resident capacity UNKNOWN). +[OBSERVED] The timeline camera itself slowed every shape by 5-10 us (2560x2560 16.1 -> 26.0 us; hot 14.8 -> 25.0), the clock camera (CTA 0 only) did not. timeline-nostore-1 (same binary minus the four 4-byte uncached camera stores per CTA, registers and S2Rs kept): back to baseline, 24.0/15.3/51.3/31.5 us (0.504/0.585/0.781/0.665). So 640 small uncached stores from 160 CTAs cost ~10 us. [INFERRED, high] Consecutive uncached stores from one thread to one line serialise at the uncached write round trip (~2.5 us each). The kernel's own output path is one 8-byte uncached store per unit per warp (2 adjacent words), 1920 of them for 3840 rows, spread through the launch: cost UNKNOWN until probed. +Next probes (diagnostic, results not checked, API poison check disabled in the probe build only; forced mutant 2 stays checked): P8 probe-nostore (i32 output STG replaced by an STS to shared: upper bound of the output-store cost), P9 probe-nox (x LDG.128 replaced by constants: upper bound of the x round-trip cost). Predictions: if P8 saves >= 5 us on 2560x2560 the output path is the lead and the fix is full-line coalesced stores through shared memory; if P9 saves ~2.5 us the staging round trip must overlap the first weight loads. + +### Result: probes (probe-nostore-1, probe-nox-1; diagnostic, results unchecked) +[OBSERVED runs/probe-nostore-1.json] Output STG replaced by a shared store: 3840x2560 25.1 -> 15.7 us (0.841), 2560x2560 16.2 -> 13.5 (0.687), 13824x2560 53.2 -> 42.0 (0.967), 2560x6912 30.4 -> 25.1 (0.861). The per-row GPU-uncached stores are the main cost on three shapes. +[OBSERVED runs/probe-nox-1.json] x not loaded: 23.6 / 15.6 / 50.4 / 27.4 us: the x round trip is worth 0.6 to 2.6 us, second order. +FIX (worktree tern/kt1-speed, src/omega_blackwell_codegen_tern.c + .h): single-chunk kernels park each round's 2RW results in shared memory (two slot sets alternating by round, one CTA barrier per round; all warps of a CTA take the same rounds, a warp past U recomputes U-1 and its rows are never stored) and warp 0 writes the round with one coalesced STG. Host battery 56/56 and simulator battery 34/34 (bounds-checked, grids and warp orders, mutants 1/2/3 caught) pass on the fixed code. Prediction: cold fractions move toward the probe-nostore figures; the 2560x2560 gate (0.759) may still miss because 1280 units over 1280 warps is one round and the x round trip plus one DRAM round trip remain serial. + +### Result: fix-1 (coalesced output, cold, 5 reps) and evidence-store-fix/ (red + main phases) +[OBSERVED runs/fix-1.json] 3840x2560 16.19 us (0.816 PASS), 2560x2560 13.54 (0.687 FAIL), 13824x2560 43.49 (0.933 PASS), 2560x6912 28.77 (0.738 FAIL). Negative control (forced mutant 2) red. +[OBSERVED evidence-store-fix/main.log] correctness 0 rows differing on every battery (random 20000 rows, MA grid 49932 rows, BitNet shapes x 2 layouts, f32 q|k|v); red phase: mutants 1, 3, 2 each exit 1. Cold in that run: 0.852 / 0.727 / 0.972 / 0.880. The 2560x6912 figure swings 0.74 to 0.88 between runs (waves, see UNKNOWN below); 2560x2560 sits at the probe-nostore ceiling (0.69 to 0.73): the x round trip is now the serial cost there. + +### Prediction P10 (variable 2: overlap the x round trip with the first weight round trip) +Change (worktree): the warp's first unit's weight loads are issued before the x load, which follows without waiting for them +(scoreboard rule: the x arithmetic waits for both); the K loop skips its loads once (predicated region on a flag). To keep +the register count flat the row-major loads use immediate offsets (LDG.E imm, same 24-bit field as the LDG.E.64/128 words +already in the encoder; simulator mirrors it): peak 54 registers, declared 56 (unchanged), 676 instructions (was 658). +The x staging clamps its word index instead of predicating (no lane reads past x). Host 56/56 and simulator 34/34 PASS, +every spec variant generates (/tmp/kt1stats). +Prediction: each shape loses about one memory round trip per CTA (1 to 2.5 us): 2560x2560 11.0 to 12.5 us (0.76 to 0.84), +3840x2560 14 to 15 us, 13824 42 to 43, 2560x6912 unchanged within its swing. If 2560x2560 does not move, the serial cost is +not the x round trip (the pre-launch x arrival or the first-touch of the uncached weights would be the next candidates). +Negative control: forced mutant 2 must stay red; correctness 0 rows differing with the new load encoding. + +### Result: fix2-1 (prefetch + coalesced output, cold, 5 reps) and evidence-fix2/ (red + main) +[OBSERVED runs/fix2-1.json] 3840x2560 15.36 us (0.887 PASS), 2560x2560 13.38 (0.712 FAIL), 13824x2560 42.82 (0.953 PASS), +2560x6912 27.90 (0.770 PASS). Negative control red. evidence-fix2/main.log: 0 rows differing on every battery with the +immediate-offset loads; mutants 1, 3, 2 red. Cold in that run: 0.854 / 0.646 / 0.953 / 0.809. +P10 verdict: PARTLY WRONG. Three shapes gained 0.7 to 0.9 us per launch (3840: 16.19 -> 15.36; 13824: 43.49 -> 42.82; +6912: 28.77 -> 27.90), 2560x2560 did not move (13.54 -> 13.38, within noise; 12.9 to 14.4 across runs). So at +2560x2560 the x round trip is not the serial cost. What remains there, floor taken out: 9.7 us for 1.64 MB where the +practical limit needs 6.9 us; about 2.8 us unexplained, against 1.3 us at 3840 and 1.8 us at 13824. The 2560x2560 +launch is one round (1280 units over 1280 warps): every warp issues its ten loads at once and the whole launch is one +burst with no steady state. UNKNOWN: the mechanism (DRAM pipeline fill and drain for a single burst, address +translation on first touch, or something else). Not pursued further here; two variables are enough for one PR. +Prefetch kept: no regression on any shape, registers flat, correctness proven on the chip. diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/prefetch-dirty-tree-main.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/prefetch-dirty-tree-main.log new file mode 100644 index 000000000..d6a07a68c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/prefetch-dirty-tree-main.log @@ -0,0 +1,17 @@ +chip: random rows 20000, rows differing from oma_rz_oracle 0 +chip: MA grid 36 points (49932 rows), rows differing 0 +chip: BitNet shapes x 2 layouts, rows differing 0 +chip: rows checked against oma_rz_oracle 115500 +chip: mutant 1 caught (512 of 512 rows differ from oma_rz_oracle) +chip: mutant 3 caught (511 of 512 rows differ from oma_rz_oracle) +chip: f32 q|k|v segments, rows differing from the host formula 0 +chip: mutant 2 caught (1919 of 3840 rows take the wrong scale) +chip: in-list launch floor (8 x 256, 512 B) median 3.71 us, min 3.30 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 15.84 us per launch -> 155.2 GB/s = 0.568 of 273 spec, 0.654 of 237.2 practical; minus the launch floor 12.13 us -> 202.6 GB/s (0.854 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 14.40 us per launch -> 113.8 GB/s = 0.417 of 273 spec, 0.480 of 237.2 practical; minus the launch floor 10.69 us -> 153.3 GB/s (0.646 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 153.3 (113.8 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 42.85 us per launch -> 206.5 GB/s = 0.756 of 273 spec, 0.870 of 237.2 practical; minus the launch floor 39.14 us -> 226.1 GB/s (0.953 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 26.75 us per launch -> 165.4 GB/s = 0.606 of 273 spec, 0.697 of 237.2 practical; minus the launch floor 23.04 us -> 192.0 GB/s (0.809 of 237.2) +receipt: /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/evidence-fix2/receipt-main.json +gpu_tern_test: 68 checks, 1 failed: FAIL +main exit 1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1.json new file mode 100644 index 000000000..e6d0a774b --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.424, "min_us": 3.232}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 15744, "min_ns": 14560, "gbs": 156.10, "of_spec_273": 0.5718, "of_practical_237_2": 0.6581, "minus_floor_ns": 12320, "minus_floor_gbs": 199.48, "minus_floor_of_spec_273": 0.7307, "minus_floor_of_practical_237_2": 0.8410, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13472, "min_ns": 12704, "gbs": 121.62, "of_spec_273": 0.4455, "of_practical_237_2": 0.5127, "minus_floor_ns": 10048, "minus_floor_gbs": 163.06, "minus_floor_of_spec_273": 0.5973, "minus_floor_of_practical_237_2": 0.6874, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 42016, "min_ns": 22912, "gbs": 210.57, "of_spec_273": 0.7713, "of_practical_237_2": 0.8877, "minus_floor_ns": 38592, "minus_floor_gbs": 229.25, "minus_floor_of_spec_273": 0.8398, "minus_floor_of_practical_237_2": 0.9665, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 25088, "min_ns": 19136, "gbs": 176.33, "of_spec_273": 0.6459, "of_practical_237_2": 0.7434, "minus_floor_ns": 21664, "minus_floor_gbs": 204.19, "minus_floor_of_spec_273": 0.7480, "minus_floor_of_practical_237_2": 0.8609, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1.meta new file mode 100644 index 000000000..7ff75ece7 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nostore-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:41:42Z +672536718eeaccf735269cfcb5175faeb1d85a891b4f0af9c5d8cf92075f0339 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/probe-nostore +208 MHz, [N/A], 48, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1-negative.json new file mode 100644 index 000000000..107a32523 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 3839, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1.json new file mode 100644 index 000000000..728413f2b --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.136, "min_us": 2.944}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 23648, "min_ns": 19136, "gbs": 103.92, "of_spec_273": 0.3807, "of_practical_237_2": 0.4381, "minus_floor_ns": 20512, "minus_floor_gbs": 119.81, "minus_floor_of_spec_273": 0.4389, "minus_floor_of_practical_237_2": 0.5051, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15616, "min_ns": 12480, "gbs": 104.92, "of_spec_273": 0.3843, "of_practical_237_2": 0.4423, "minus_floor_ns": 12480, "minus_floor_gbs": 131.28, "minus_floor_of_spec_273": 0.4809, "minus_floor_of_practical_237_2": 0.5535, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 50432, "min_ns": 30592, "gbs": 175.43, "of_spec_273": 0.6426, "of_practical_237_2": 0.7396, "minus_floor_ns": 47296, "minus_floor_gbs": 187.06, "minus_floor_of_spec_273": 0.6852, "minus_floor_of_practical_237_2": 0.7886, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 27392, "min_ns": 16832, "gbs": 161.50, "of_spec_273": 0.5916, "of_practical_237_2": 0.6808, "minus_floor_ns": 24256, "minus_floor_gbs": 182.37, "minus_floor_of_spec_273": 0.6680, "minus_floor_of_practical_237_2": 0.7689, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 3, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1.meta new file mode 100644 index 000000000..6d7e557a9 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/probe-nox-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:41:44Z +e5ea1b95afff8efd566c203272d8aaccb8af408445f49302ece1533179d982cf /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/probe-nox +208 MHz, [N/A], 48, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2.json new file mode 100644 index 000000000..7b087b41a --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 2, "warps": 8, "depth": 5, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.904, "min_us": 3.616}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 29504, "min_ns": 23552, "gbs": 83.30, "of_spec_273": 0.3051, "of_practical_237_2": 0.3512, "minus_floor_ns": 25600, "minus_floor_gbs": 96.00, "minus_floor_of_spec_273": 0.3516, "minus_floor_of_practical_237_2": 0.4047, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 22496, "min_ns": 16288, "gbs": 72.83, "of_spec_273": 0.2668, "of_practical_237_2": 0.3070, "minus_floor_ns": 18592, "minus_floor_gbs": 88.12, "minus_floor_of_spec_273": 0.3228, "minus_floor_of_practical_237_2": 0.3715, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 65536, "min_ns": 32416, "gbs": 135.00, "of_spec_273": 0.4945, "of_practical_237_2": 0.5691, "minus_floor_ns": 61632, "minus_floor_gbs": 143.55, "minus_floor_of_spec_273": 0.5258, "minus_floor_of_practical_237_2": 0.6052, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 35712, "min_ns": 25344, "gbs": 123.87, "of_spec_273": 0.4537, "of_practical_237_2": 0.5222, "minus_floor_ns": 31808, "minus_floor_gbs": 139.07, "minus_floor_of_spec_273": 0.5094, "minus_floor_of_practical_237_2": 0.5863, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2.meta new file mode 100644 index 000000000..645387914 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/rows-2.meta @@ -0,0 +1,5 @@ +2026-10-16T02:12:37Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +260 MHz, [N/A], 38, 4 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/run-cam.sh b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/run-cam.sh new file mode 100755 index 000000000..cc2de6284 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/run-cam.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# diagnostic wrapper: run-one.sh with the camera csv prefix set to the run name +set -u +D=/home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed +name=$1; shift +export KT1_DIAG_PREFIX="$D/runs/$name" +nvidia-smi --query-gpu=timestamp,clocks.sm,temperature.gpu,utilization.gpu,power.draw --format=csv,noheader -lms 20 > "$D/runs/$name-smi.csv" 2>&1 & +smi=$! +"$D/run-one.sh" "$name" "$@" +rc=$? +kill $smi 2>/dev/null; wait $smi 2>/dev/null +exit $rc diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/run-one.sh b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/run-one.sh new file mode 100755 index 000000000..f677be534 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/run-one.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -u +D=/home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed +name=$1; bin=$2; shift 2 +out="$D/runs/$name" +test ! -e "$out.json" || exit 2 +{ date -u +%FT%TZ; sha256sum "$bin"; nvidia-smi --query-gpu=clocks.sm,clocks.mem,temperature.gpu,utilization.gpu --format=csv,noheader; } > "$out.meta" +"$bin" --mutant 2 --no-bw --out "$out-negative.json" > "$out-negative.log" 2>&1 +neg=$? +echo "negative_exit=$neg" >> "$out.meta" +[ "$neg" = 1 ] && jq -e '.forced_mutant_2_differing > 0' "$out-negative.json" >/dev/null || exit 3 +"$bin" --bw-only --reps 5 "$@" --out "$out.json" > "$out.log" 2>&1 +rc=$? +echo "exit=$rc" >> "$out.meta" +jq -c '{floor:.launch_floor_in_list, cold:[.cold[]? | {n,k,median_ns,minus_floor_of_practical_237_2,pass}]}' "$out.json" +echo "$name exit=$rc negative=$neg" diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1.json new file mode 100644 index 000000000..55b27d19e --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.456, "min_us": 3.264}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24288, "min_ns": 19680, "gbs": 101.19, "of_spec_273": 0.3706, "of_practical_237_2": 0.4266, "minus_floor_ns": 20832, "minus_floor_gbs": 117.97, "minus_floor_of_spec_273": 0.4321, "minus_floor_of_practical_237_2": 0.4974, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15776, "min_ns": 13952, "gbs": 103.85, "of_spec_273": 0.3804, "of_practical_237_2": 0.4378, "minus_floor_ns": 12320, "minus_floor_gbs": 132.99, "minus_floor_of_spec_273": 0.4871, "minus_floor_of_practical_237_2": 0.5607, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 55232, "min_ns": 34624, "gbs": 160.19, "of_spec_273": 0.5868, "of_practical_237_2": 0.6753, "minus_floor_ns": 51776, "minus_floor_gbs": 170.88, "minus_floor_of_spec_273": 0.6259, "minus_floor_of_practical_237_2": 0.7204, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29280, "min_ns": 25792, "gbs": 151.08, "of_spec_273": 0.5534, "of_practical_237_2": 0.6369, "minus_floor_ns": 25824, "minus_floor_gbs": 171.30, "minus_floor_of_spec_273": 0.6275, "minus_floor_of_practical_237_2": 0.7222, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1.meta new file mode 100644 index 000000000..56d755752 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/shared-output-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:16:11Z +c2f824b57489d44ed14b5c8e822676bae6545d143632a91fd660d1ab1abc63b5 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/shared-output +208 MHz, [N/A], 38, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1.json new file mode 100644 index 000000000..687f83b47 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.456, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24576, "min_ns": 20544, "gbs": 100.00, "of_spec_273": 0.3663, "of_practical_237_2": 0.4216, "minus_floor_ns": 21120, "minus_floor_gbs": 116.36, "minus_floor_of_spec_273": 0.4262, "minus_floor_of_practical_237_2": 0.4906, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16192, "min_ns": 13728, "gbs": 101.19, "of_spec_273": 0.3706, "of_practical_237_2": 0.4266, "minus_floor_ns": 12736, "minus_floor_gbs": 128.64, "minus_floor_of_spec_273": 0.4712, "minus_floor_of_practical_237_2": 0.5423, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 51904, "min_ns": 32000, "gbs": 170.46, "of_spec_273": 0.6244, "of_practical_237_2": 0.7186, "minus_floor_ns": 48448, "minus_floor_gbs": 182.62, "minus_floor_of_spec_273": 0.6689, "minus_floor_of_practical_237_2": 0.7699, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29472, "min_ns": 24288, "gbs": 150.10, "of_spec_273": 0.5498, "of_practical_237_2": 0.6328, "minus_floor_ns": 26016, "minus_floor_gbs": 170.04, "minus_floor_of_spec_273": 0.6228, "minus_floor_of_practical_237_2": 0.7169, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1.meta new file mode 100644 index 000000000..f187ea027 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/stamps-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:16:35Z +8032b98b675322d9063fc149b423490b95917d9f48923b86ac89fee5d0ea4dcc /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/stamps +208 MHz, [N/A], 39, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/store-fix-only-main.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/store-fix-only-main.log new file mode 100644 index 000000000..b232c435c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/store-fix-only-main.log @@ -0,0 +1,17 @@ +chip: random rows 20000, rows differing from oma_rz_oracle 0 +chip: MA grid 36 points (49932 rows), rows differing 0 +chip: BitNet shapes x 2 layouts, rows differing 0 +chip: rows checked against oma_rz_oracle 115500 +chip: mutant 1 caught (512 of 512 rows differ from oma_rz_oracle) +chip: mutant 3 caught (511 of 512 rows differ from oma_rz_oracle) +chip: f32 q|k|v segments, rows differing from the host formula 0 +chip: mutant 2 caught (1919 of 3840 rows take the wrong scale) +chip: in-list launch floor (8 x 256, 512 B) median 3.42 us, min 3.33 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 15.58 us per launch -> 157.7 GB/s = 0.578 of 273 spec, 0.665 of 237.2 practical; minus the launch floor 12.16 us -> 202.1 GB/s (0.852 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 12.93 us per launch -> 126.7 GB/s = 0.464 of 273 spec, 0.534 of 237.2 practical; minus the launch floor 9.50 us -> 172.4 GB/s (0.727 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 172.4 (126.7 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 41.79 us per launch -> 211.7 GB/s = 0.775 of 273 spec, 0.892 of 237.2 practical; minus the launch floor 38.37 us -> 230.6 GB/s (0.972 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 24.61 us per launch -> 179.8 GB/s = 0.658 of 273 spec, 0.758 of 237.2 practical; minus the launch floor 21.18 us -> 208.8 GB/s (0.880 of 237.2) +receipt: /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/evidence-store-fix/receipt-main.json +gpu_tern_test: 68 checks, 1 failed: FAIL +main exit 1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1.json new file mode 100644 index 000000000..b3e0c4b55 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.968, "min_us": 3.648}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 33760, "min_ns": 28320, "gbs": 72.80, "of_spec_273": 0.2667, "of_practical_237_2": 0.3069, "minus_floor_ns": 29792, "minus_floor_gbs": 82.49, "minus_floor_of_spec_273": 0.3022, "minus_floor_of_practical_237_2": 0.3478, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 25984, "min_ns": 20032, "gbs": 63.05, "of_spec_273": 0.2310, "of_practical_237_2": 0.2658, "minus_floor_ns": 22016, "minus_floor_gbs": 74.42, "minus_floor_of_spec_273": 0.2726, "minus_floor_of_practical_237_2": 0.3137, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 61824, "min_ns": 38624, "gbs": 143.11, "of_spec_273": 0.5242, "of_practical_237_2": 0.6033, "minus_floor_ns": 57856, "minus_floor_gbs": 152.92, "minus_floor_of_spec_273": 0.5601, "minus_floor_of_practical_237_2": 0.6447, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 39456, "min_ns": 29472, "gbs": 112.12, "of_spec_273": 0.4107, "of_practical_237_2": 0.4727, "minus_floor_ns": 35488, "minus_floor_gbs": 124.65, "minus_floor_of_spec_273": 0.4566, "minus_floor_of_practical_237_2": 0.5255, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1.meta new file mode 100644 index 000000000..e3d1ed81c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:32:09Z +ea57bbba1c69f6e318cb36b60f058ae23bbcf61f1152d84ddbf764424d740b32 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/timeline +208 MHz, [N/A], 43, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot.json new file mode 100644 index 000000000..b013a898d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.808, "min_us": 3.648}, + "hot_diagnostic": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 27168, "min_ns": 22624, "gbs": 90.46, "of_spec_273": 0.3314, "of_practical_237_2": 0.3814, "minus_floor_ns": 23360, "minus_floor_gbs": 105.21, "minus_floor_of_spec_273": 0.3854, "minus_floor_of_practical_237_2": 0.4435, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 24992, "min_ns": 19840, "gbs": 65.56, "of_spec_273": 0.2401, "of_practical_237_2": 0.2764, "minus_floor_ns": 21184, "minus_floor_gbs": 77.34, "minus_floor_of_spec_273": 0.2833, "minus_floor_of_practical_237_2": 0.3261, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 36544, "min_ns": 31840, "gbs": 242.10, "of_spec_273": 0.8868, "of_practical_237_2": 1.0207, "minus_floor_ns": 32736, "minus_floor_gbs": 270.26, "minus_floor_of_spec_273": 0.9900, "minus_floor_of_practical_237_2": 1.1394, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 30080, "min_ns": 25216, "gbs": 147.06, "of_spec_273": 0.5387, "of_practical_237_2": 0.6200, "minus_floor_ns": 26272, "minus_floor_gbs": 168.38, "minus_floor_of_spec_273": 0.6168, "minus_floor_of_practical_237_2": 0.7099, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 5, "failed": 0, "verdict": "PASS" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot.meta new file mode 100644 index 000000000..c10b78684 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-hot.meta @@ -0,0 +1,5 @@ +2026-10-16T02:32:11Z +ea57bbba1c69f6e318cb36b60f058ae23bbcf61f1152d84ddbf764424d740b32 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/timeline +279 MHz, [N/A], 43, 0 % +negative_exit=1 +exit=0 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1.json new file mode 100644 index 000000000..7e55654bc --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.488, "min_us": 3.296}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24032, "min_ns": 20672, "gbs": 102.26, "of_spec_273": 0.3746, "of_practical_237_2": 0.4311, "minus_floor_ns": 20544, "minus_floor_gbs": 119.63, "minus_floor_of_spec_273": 0.4382, "minus_floor_of_practical_237_2": 0.5043, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 15296, "min_ns": 13760, "gbs": 107.11, "of_spec_273": 0.3924, "of_practical_237_2": 0.4516, "minus_floor_ns": 11808, "minus_floor_gbs": 138.75, "minus_floor_of_spec_273": 0.5083, "minus_floor_of_practical_237_2": 0.5850, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 51264, "min_ns": 31424, "gbs": 172.58, "of_spec_273": 0.6322, "of_practical_237_2": 0.7276, "minus_floor_ns": 47776, "minus_floor_gbs": 185.18, "minus_floor_of_spec_273": 0.6783, "minus_floor_of_practical_237_2": 0.7807, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 31520, "min_ns": 29408, "gbs": 140.35, "of_spec_273": 0.5141, "of_practical_237_2": 0.5917, "minus_floor_ns": 28032, "minus_floor_gbs": 157.81, "minus_floor_of_spec_273": 0.5781, "minus_floor_of_practical_237_2": 0.6653, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1.meta new file mode 100644 index 000000000..e12634977 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/timeline-nostore-1.meta @@ -0,0 +1,5 @@ +2026-10-16T02:39:03Z +c5f7d679de4a0e5b3caeda59f7b259f70c59cff339268688c4bc1cfead801d23 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/timeline-nostore +208 MHz, [N/A], 49, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16.json new file mode 100644 index 000000000..ab1930969 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 16, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.488, "min_us": 3.200}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 24416, "min_ns": 19360, "gbs": 100.66, "of_spec_273": 0.3687, "of_practical_237_2": 0.4243, "minus_floor_ns": 20928, "minus_floor_gbs": 117.43, "minus_floor_of_spec_273": 0.4302, "minus_floor_of_practical_237_2": 0.4951, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 16544, "min_ns": 13504, "gbs": 99.03, "of_spec_273": 0.3628, "of_practical_237_2": 0.4175, "minus_floor_ns": 13056, "minus_floor_gbs": 125.49, "minus_floor_of_spec_273": 0.4597, "minus_floor_of_practical_237_2": 0.5290, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 60992, "min_ns": 47584, "gbs": 145.06, "of_spec_273": 0.5313, "of_practical_237_2": 0.6115, "minus_floor_ns": 57504, "minus_floor_gbs": 153.86, "minus_floor_of_spec_273": 0.5636, "minus_floor_of_practical_237_2": 0.6486, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 29984, "min_ns": 27072, "gbs": 147.53, "of_spec_273": 0.5404, "of_practical_237_2": 0.6220, "minus_floor_ns": 26496, "minus_floor_gbs": 166.96, "minus_floor_of_spec_273": 0.6116, "minus_floor_of_practical_237_2": 0.7039, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16.meta new file mode 100644 index 000000000..94b8cdd0a --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-16.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:37Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +208 MHz, [N/A], 39, 5 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4-negative.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4-negative.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4-negative.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4.json new file mode 100644 index 000000000..418dc6aa7 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 4, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.584, "min_us": 3.136}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 29312, "min_ns": 23680, "gbs": 83.84, "of_spec_273": 0.3071, "of_practical_237_2": 0.3535, "minus_floor_ns": 25728, "minus_floor_gbs": 95.52, "minus_floor_of_spec_273": 0.3499, "minus_floor_of_practical_237_2": 0.4027, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 24576, "min_ns": 20736, "gbs": 66.67, "of_spec_273": 0.2442, "of_practical_237_2": 0.2811, "minus_floor_ns": 20992, "minus_floor_gbs": 78.05, "minus_floor_of_spec_273": 0.2859, "minus_floor_of_practical_237_2": 0.3290, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 61056, "min_ns": 56672, "gbs": 144.91, "of_spec_273": 0.5308, "of_practical_237_2": 0.6109, "minus_floor_ns": 57472, "minus_floor_gbs": 153.94, "minus_floor_of_spec_273": 0.5639, "minus_floor_of_practical_237_2": 0.6490, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 39296, "min_ns": 35712, "gbs": 112.57, "of_spec_273": 0.4124, "of_practical_237_2": 0.4746, "minus_floor_ns": 35712, "minus_floor_gbs": 123.87, "minus_floor_of_spec_273": 0.4537, "minus_floor_of_practical_237_2": 0.5222, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false} + ], + "checks": 9, "failed": 4, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4.meta b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4.meta new file mode 100644 index 000000000..b6a7468bc --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/investigation/warps-4.meta @@ -0,0 +1,5 @@ +2026-10-16T02:10:36Z +c31927d7750f944bbed204477b55cda572880eee5793d8b4c6154829875395e8 /home/drakestapleton/workspace/investigations/2026-10-16-kt1-speed/baseline +260 MHz, [N/A], 40, 0 % +negative_exit=1 +exit=1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/launch-cost.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/launch-cost.log new file mode 100644 index 000000000..ea15015fa --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/launch-cost.log @@ -0,0 +1,63 @@ +ok: m=1 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=1 barrier=wfi+inval_all span_us=163.7 per_launch_us=168.7 first_launch_us=163.7 elapsed_us=168.7 GB/s=199.0 fixed_per_extra_launch_us=0.00 +ok: m=2 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=2 barrier=wfi+inval_all span_us=219.8 per_launch_us=112.3 first_launch_us=89.1 elapsed_us=224.7 GB/s=149.4 fixed_per_extra_launch_us=56.02 +ok: m=4 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=4 barrier=wfi+inval_all span_us=278.1 per_launch_us=70.8 first_launch_us=62.3 elapsed_us=283.1 GB/s=118.6 fixed_per_extra_launch_us=38.13 +ok: m=8 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=8 barrier=wfi+inval_all span_us=373.6 per_launch_us=47.3 first_launch_us=44.7 elapsed_us=378.6 GB/s=88.7 fixed_per_extra_launch_us=29.99 +ok: m=16 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=16 barrier=wfi+inval_all span_us=599.5 per_launch_us=37.8 first_launch_us=46.0 elapsed_us=604.4 GB/s=55.5 fixed_per_extra_launch_us=29.05 +ok: m=1 barrier=wfi_only: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=1 barrier=wfi_only span_us=153.1 per_launch_us=158.1 first_launch_us=153.1 elapsed_us=158.1 GB/s=212.2 fixed_per_extra_launch_us=0.00 +ok: m=2 barrier=wfi_only: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=2 barrier=wfi_only span_us=188.8 per_launch_us=98.3 first_launch_us=97.1 elapsed_us=196.6 GB/s=170.7 fixed_per_extra_launch_us=38.50 +ok: m=4 barrier=wfi_only: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=4 barrier=wfi_only span_us=260.1 per_launch_us=66.3 first_launch_us=63.7 elapsed_us=265.2 GB/s=126.6 fixed_per_extra_launch_us=35.68 +ok: m=8 barrier=wfi_only: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=8 barrier=wfi_only span_us=385.9 per_launch_us=48.9 first_launch_us=48.4 elapsed_us=390.9 GB/s=85.9 fixed_per_extra_launch_us=33.25 +ok: m=16 barrier=wfi_only: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=16 barrier=wfi_only span_us=605.8 per_launch_us=38.2 first_launch_us=46.2 elapsed_us=610.7 GB/s=55.0 fixed_per_extra_launch_us=30.17 +ok: m=1 barrier=wfi+inval_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=1 barrier=wfi+inval_data span_us=163.4 per_launch_us=168.4 first_launch_us=163.4 elapsed_us=168.4 GB/s=199.3 fixed_per_extra_launch_us=0.00 +ok: m=2 barrier=wfi+inval_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=2 barrier=wfi+inval_data span_us=192.1 per_launch_us=98.5 first_launch_us=100.9 elapsed_us=197.0 GB/s=170.4 fixed_per_extra_launch_us=28.62 +ok: m=4 barrier=wfi+inval_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=4 barrier=wfi+inval_data span_us=278.4 per_launch_us=70.9 first_launch_us=57.8 elapsed_us=283.4 GB/s=118.4 fixed_per_extra_launch_us=38.35 +ok: m=8 barrier=wfi+inval_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=8 barrier=wfi+inval_data span_us=374.2 per_launch_us=47.4 first_launch_us=45.9 elapsed_us=379.1 GB/s=88.5 fixed_per_extra_launch_us=30.11 +ok: m=16 barrier=wfi+inval_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=16 barrier=wfi+inval_data span_us=599.6 per_launch_us=37.8 first_launch_us=47.1 elapsed_us=604.5 GB/s=55.5 fixed_per_extra_launch_us=29.08 +ok: m=1 barrier=flush_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=1 barrier=flush_data span_us=161.0 per_launch_us=165.6 first_launch_us=161.0 elapsed_us=165.6 GB/s=202.7 fixed_per_extra_launch_us=0.00 +ok: m=2 barrier=flush_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=2 barrier=flush_data span_us=194.3 per_launch_us=99.6 first_launch_us=93.4 elapsed_us=199.2 GB/s=168.5 fixed_per_extra_launch_us=33.62 +ok: m=4 barrier=flush_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=4 barrier=flush_data span_us=269.4 per_launch_us=68.6 first_launch_us=61.4 elapsed_us=274.3 GB/s=122.4 fixed_per_extra_launch_us=36.21 +ok: m=8 barrier=flush_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=8 barrier=flush_data span_us=389.4 per_launch_us=49.3 first_launch_us=49.3 elapsed_us=394.2 GB/s=85.1 fixed_per_extra_launch_us=32.65 +ok: m=16 barrier=flush_data: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=16 barrier=flush_data span_us=602.0 per_launch_us=37.9 first_launch_us=47.7 elapsed_us=606.9 GB/s=55.3 fixed_per_extra_launch_us=29.42 +ok: m=1 barrier=none: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=1 barrier=none span_us=0.0 per_launch_us=204.0 first_launch_us=0.0 elapsed_us=204.0 GB/s=164.5 fixed_per_extra_launch_us=0.00 +ok: m=2 barrier=none: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=2 barrier=none span_us=0.0 per_launch_us=82.0 first_launch_us=0.0 elapsed_us=164.0 GB/s=204.6 fixed_per_extra_launch_us=-40.02 +ok: m=4 barrier=none: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=4 barrier=none span_us=0.0 per_launch_us=50.2 first_launch_us=0.0 elapsed_us=200.6 GB/s=167.3 fixed_per_extra_launch_us=-1.13 +ok: m=8 barrier=none: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=8 barrier=none span_us=0.0 per_launch_us=28.3 first_launch_us=0.0 elapsed_us=226.6 GB/s=148.1 fixed_per_extra_launch_us=3.23 +ok: m=16 barrier=none: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=16 barrier=none span_us=0.0 per_launch_us=14.1 first_launch_us=0.0 elapsed_us=226.3 GB/s=148.3 fixed_per_extra_launch_us=1.48 +ok: m=1 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=1 barrier=wfi+inval_all span_us=148.9 per_launch_us=153.8 first_launch_us=148.9 elapsed_us=153.8 GB/s=218.2 fixed_per_extra_launch_us=0.00 +ok: m=2 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=2 barrier=wfi+inval_all span_us=194.9 per_launch_us=99.9 first_launch_us=102.4 elapsed_us=199.9 GB/s=167.9 fixed_per_extra_launch_us=46.10 +ok: m=4 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=4 barrier=wfi+inval_all span_us=247.6 per_launch_us=63.1 first_launch_us=58.6 elapsed_us=252.4 GB/s=132.9 fixed_per_extra_launch_us=32.89 +ok: m=8 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=8 barrier=wfi+inval_all span_us=391.9 per_launch_us=49.7 first_launch_us=56.3 elapsed_us=397.4 GB/s=84.5 fixed_per_extra_launch_us=34.80 +ok: m=16 barrier=wfi+inval_all: 20 reps ran, y bit-identical to the one-launch-at-a-time reference on every rep +COST m=16 barrier=wfi+inval_all span_us=644.4 per_launch_us=40.6 first_launch_us=46.6 elapsed_us=649.5 GB/s=51.7 fixed_per_extra_launch_us=33.04 +ok: negative control: dropped launch 1 named by submit (rc -1, first_missing 1) +gpu_launch_cost_test: 31 checks, 0 failed: PASS +launch-cost exit 0 (recorded) diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/main.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/main.log new file mode 100644 index 000000000..0509365ef --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/main.log @@ -0,0 +1,17 @@ +chip: random rows 20000, rows differing from oma_rz_oracle 0 +chip: MA grid 36 points (49932 rows), rows differing 0 +chip: BitNet shapes x 2 layouts, rows differing 0 +chip: rows checked against oma_rz_oracle 115500 +chip: mutant 1 caught (512 of 512 rows differ from oma_rz_oracle) +chip: mutant 3 caught (511 of 512 rows differ from oma_rz_oracle) +chip: f32 q|k|v segments, rows differing from the host formula 0 +chip: mutant 2 caught (1919 of 3840 rows take the wrong scale) +chip: in-list launch floor (8 x 256, 512 B) median 3.74 us, min 3.46 us +chip: cold 3840x2560 (2457600 B x 41 launches = 96.1 MiB per list): 15.30 us per launch -> 160.7 GB/s = 0.589 of 273 spec, 0.677 of 237.2 practical; minus the launch floor 11.55 us -> 212.7 GB/s (0.897 of 237.2) +chip: cold 2560x2560 (1638400 B x 62 launches = 96.9 MiB per list): 13.34 us per launch -> 122.8 GB/s = 0.450 of 273 spec, 0.518 of 237.2 practical; minus the launch floor 9.60 us -> 170.7 GB/s (0.720 of 237.2) +FAIL: cold GB/s minus the launch floor at 2560x2560: 170.7 (122.8 with it), gate >= 180 +chip: cold 13824x2560 (8847360 B x 12 launches = 101.2 MiB per list): 42.59 us per launch -> 207.7 GB/s = 0.761 of 273 spec, 0.876 of 237.2 practical; minus the launch floor 38.85 us -> 227.7 GB/s (0.960 of 237.2) +chip: cold 2560x6912 (4423680 B x 23 launches = 97.0 MiB per list): 26.27 us per launch -> 168.4 GB/s = 0.617 of 273 spec, 0.710 of 237.2 practical; minus the launch floor 22.53 us -> 196.4 GB/s (0.828 of 237.2) +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-main.json +gpu_tern_test: 68 checks, 1 failed: FAIL +main exit 1 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-attn-20-5.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-attn-20-5.json new file mode 100644 index 000000000..ad0fe2893 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-attn-20-5.json @@ -0,0 +1 @@ +{"test":"gpu_decode_attn_test","q_heads":20,"kv_heads":5,"head_dim":128,"kernel_q_heads":32,"kernel_kv_heads":4,"reasons":["head layout fixed at 32 query / 4 KV heads (8 per KV head); asked 20 / 5 (4 per KV head)","fused q|k|v input fixed at 5120 words; the asked layout needs 3840","per-head q_norm / k_norm is built in (Qwen3); a model without QK norm needs a kernel without it"],"needed":"KT3 decode attention for this geometry","verdict":"REFUSED"} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-1.json new file mode 100644 index 000000000..eefd12082 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-1.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.680, "min_us": 3.488}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 16320, "min_ns": 15616, "gbs": 150.59, "of_spec_273": 0.5516, "of_practical_237_2": 0.6349, "minus_floor_ns": 12640, "minus_floor_gbs": 194.43, "minus_floor_of_spec_273": 0.7122, "minus_floor_of_practical_237_2": 0.8197, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13248, "min_ns": 12960, "gbs": 123.67, "of_spec_273": 0.4530, "of_practical_237_2": 0.5214, "minus_floor_ns": 9568, "minus_floor_gbs": 171.24, "minus_floor_of_spec_273": 0.6272, "minus_floor_of_practical_237_2": 0.7219, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 42720, "min_ns": 22848, "gbs": 207.10, "of_spec_273": 0.7586, "of_practical_237_2": 0.8731, "minus_floor_ns": 39040, "minus_floor_gbs": 226.62, "minus_floor_of_spec_273": 0.8301, "minus_floor_of_practical_237_2": 0.9554, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 26624, "min_ns": 22752, "gbs": 166.15, "of_spec_273": 0.6086, "of_practical_237_2": 0.7005, "minus_floor_ns": 22944, "minus_floor_gbs": 192.80, "minus_floor_of_spec_273": 0.7062, "minus_floor_of_practical_237_2": 0.8128, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-2.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-2.json new file mode 100644 index 000000000..dc4561ffd --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-2.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.840, "min_us": 3.456}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 15264, "min_ns": 14528, "gbs": 161.01, "of_spec_273": 0.5898, "of_practical_237_2": 0.6788, "minus_floor_ns": 11424, "minus_floor_gbs": 215.13, "minus_floor_of_spec_273": 0.7880, "minus_floor_of_practical_237_2": 0.9069, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13280, "min_ns": 13024, "gbs": 123.37, "of_spec_273": 0.4519, "of_practical_237_2": 0.5201, "minus_floor_ns": 9440, "minus_floor_gbs": 173.56, "minus_floor_of_spec_273": 0.6357, "minus_floor_of_practical_237_2": 0.7317, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 43040, "min_ns": 41760, "gbs": 205.56, "of_spec_273": 0.7530, "of_practical_237_2": 0.8666, "minus_floor_ns": 39200, "minus_floor_gbs": 225.70, "minus_floor_of_spec_273": 0.8267, "minus_floor_of_practical_237_2": 0.9515, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 28128, "min_ns": 25312, "gbs": 157.27, "of_spec_273": 0.5761, "of_practical_237_2": 0.6630, "minus_floor_ns": 24288, "minus_floor_gbs": 182.13, "minus_floor_of_spec_273": 0.6672, "minus_floor_of_practical_237_2": 0.7679, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-3.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-3.json new file mode 100644 index 000000000..30e62b7a8 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-3.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.712, "min_us": 3.424}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 15232, "min_ns": 14464, "gbs": 161.34, "of_spec_273": 0.5910, "of_practical_237_2": 0.6802, "minus_floor_ns": 11520, "minus_floor_gbs": 213.33, "minus_floor_of_spec_273": 0.7814, "minus_floor_of_practical_237_2": 0.8994, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13344, "min_ns": 12928, "gbs": 122.78, "of_spec_273": 0.4498, "of_practical_237_2": 0.5176, "minus_floor_ns": 9632, "minus_floor_gbs": 170.10, "minus_floor_of_spec_273": 0.6231, "minus_floor_of_practical_237_2": 0.7171, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 43232, "min_ns": 23040, "gbs": 204.65, "of_spec_273": 0.7496, "of_practical_237_2": 0.8628, "minus_floor_ns": 39520, "minus_floor_gbs": 223.87, "minus_floor_of_spec_273": 0.8200, "minus_floor_of_practical_237_2": 0.9438, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 25888, "min_ns": 20480, "gbs": 170.88, "of_spec_273": 0.6259, "of_practical_237_2": 0.7204, "minus_floor_ns": 22176, "minus_floor_gbs": 199.48, "minus_floor_of_spec_273": 0.7307, "minus_floor_of_practical_237_2": 0.8410, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-4.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-4.json new file mode 100644 index 000000000..9189fd2c7 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-4.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.616, "min_us": 3.392}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 15744, "min_ns": 15360, "gbs": 156.10, "of_spec_273": 0.5718, "of_practical_237_2": 0.6581, "minus_floor_ns": 12128, "minus_floor_gbs": 202.64, "minus_floor_of_spec_273": 0.7423, "minus_floor_of_practical_237_2": 0.8543, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13312, "min_ns": 13024, "gbs": 123.08, "of_spec_273": 0.4508, "of_practical_237_2": 0.5189, "minus_floor_ns": 9696, "minus_floor_gbs": 168.98, "minus_floor_of_spec_273": 0.6190, "minus_floor_of_practical_237_2": 0.7124, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 42112, "min_ns": 21888, "gbs": 210.09, "of_spec_273": 0.7696, "of_practical_237_2": 0.8857, "minus_floor_ns": 38496, "minus_floor_gbs": 229.83, "minus_floor_of_spec_273": 0.8419, "minus_floor_of_practical_237_2": 0.9689, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 25536, "min_ns": 21312, "gbs": 173.23, "of_spec_273": 0.6346, "of_practical_237_2": 0.7303, "minus_floor_ns": 21920, "minus_floor_gbs": 201.81, "minus_floor_of_spec_273": 0.7392, "minus_floor_of_practical_237_2": 0.8508, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-5.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-5.json new file mode 100644 index 000000000..4408f5b6c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-cold-5.json @@ -0,0 +1,14 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "launch_floor_in_list": {"median_us": 3.584, "min_us": 3.456}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 16192, "min_ns": 15520, "gbs": 151.78, "of_spec_273": 0.5560, "of_practical_237_2": 0.6399, "minus_floor_ns": 12608, "minus_floor_gbs": 194.92, "minus_floor_of_spec_273": 0.7140, "minus_floor_of_practical_237_2": 0.8218, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13376, "min_ns": 13088, "gbs": 122.49, "of_spec_273": 0.4487, "of_practical_237_2": 0.5164, "minus_floor_ns": 9792, "minus_floor_gbs": 167.32, "minus_floor_of_spec_273": 0.6129, "minus_floor_of_practical_237_2": 0.7054, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 43008, "min_ns": 22752, "gbs": 205.71, "of_spec_273": 0.7535, "of_practical_237_2": 0.8673, "minus_floor_ns": 39424, "minus_floor_gbs": 224.42, "minus_floor_of_spec_273": 0.8220, "minus_floor_of_practical_237_2": 0.9461, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 25376, "min_ns": 20704, "gbs": 174.33, "of_spec_273": 0.6386, "of_practical_237_2": 0.7349, "minus_floor_ns": 21792, "minus_floor_gbs": 203.00, "minus_floor_of_spec_273": 0.7436, "minus_floor_of_practical_237_2": 0.8558, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 9, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-launch-cost.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-launch-cost.json new file mode 100644 index 000000000..d15158037 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-launch-cost.json @@ -0,0 +1 @@ +{"test":"OMEGA_GPU_LAUNCH_COST","n":16384,"k":2048,"bytes":33562624,"reps":20,"points":[{"m":1,"barrier":"wfi+inval_all","span_ns":163680,"first_launch_ns":163680,"elapsed_ns":168673,"gbps":198.98,"fixed_per_extra_launch_us":0.00,"identical":1},{"m":2,"barrier":"wfi+inval_all","span_ns":219776,"first_launch_ns":89088,"elapsed_ns":224690,"gbps":149.37,"fixed_per_extra_launch_us":56.02,"identical":1},{"m":4,"barrier":"wfi+inval_all","span_ns":278144,"first_launch_ns":62304,"elapsed_ns":283074,"gbps":118.56,"fixed_per_extra_launch_us":38.13,"identical":1},{"m":8,"barrier":"wfi+inval_all","span_ns":373568,"first_launch_ns":44736,"elapsed_ns":378595,"gbps":88.65,"fixed_per_extra_launch_us":29.99,"identical":1},{"m":16,"barrier":"wfi+inval_all","span_ns":599488,"first_launch_ns":46016,"elapsed_ns":604436,"gbps":55.53,"fixed_per_extra_launch_us":29.05,"identical":1},{"m":1,"barrier":"wfi_only","span_ns":153120,"first_launch_ns":153120,"elapsed_ns":158129,"gbps":212.25,"fixed_per_extra_launch_us":0.00,"identical":1},{"m":2,"barrier":"wfi_only","span_ns":188800,"first_launch_ns":97120,"elapsed_ns":196625,"gbps":170.69,"fixed_per_extra_launch_us":38.50,"identical":1},{"m":4,"barrier":"wfi_only","span_ns":260064,"first_launch_ns":63712,"elapsed_ns":265154,"gbps":126.58,"fixed_per_extra_launch_us":35.68,"identical":1},{"m":8,"barrier":"wfi_only","span_ns":385888,"first_launch_ns":48352,"elapsed_ns":390882,"gbps":85.86,"fixed_per_extra_launch_us":33.25,"identical":1},{"m":16,"barrier":"wfi_only","span_ns":605824,"first_launch_ns":46208,"elapsed_ns":610708,"gbps":54.96,"fixed_per_extra_launch_us":30.17,"identical":1},{"m":1,"barrier":"wfi+inval_data","span_ns":163424,"first_launch_ns":163424,"elapsed_ns":168385,"gbps":199.32,"fixed_per_extra_launch_us":0.00,"identical":1},{"m":2,"barrier":"wfi+inval_data","span_ns":192096,"first_launch_ns":100864,"elapsed_ns":197009,"gbps":170.36,"fixed_per_extra_launch_us":28.62,"identical":1},{"m":4,"barrier":"wfi+inval_data","span_ns":278432,"first_launch_ns":57760,"elapsed_ns":283426,"gbps":118.42,"fixed_per_extra_launch_us":38.35,"identical":1},{"m":8,"barrier":"wfi+inval_data","span_ns":374176,"first_launch_ns":45888,"elapsed_ns":379123,"gbps":88.53,"fixed_per_extra_launch_us":30.11,"identical":1},{"m":16,"barrier":"wfi+inval_data","span_ns":599552,"first_launch_ns":47072,"elapsed_ns":604533,"gbps":55.52,"fixed_per_extra_launch_us":29.08,"identical":1},{"m":1,"barrier":"flush_data","span_ns":160992,"first_launch_ns":160992,"elapsed_ns":165617,"gbps":202.65,"fixed_per_extra_launch_us":0.00,"identical":1},{"m":2,"barrier":"flush_data","span_ns":194304,"first_launch_ns":93376,"elapsed_ns":199233,"gbps":168.46,"fixed_per_extra_launch_us":33.62,"identical":1},{"m":4,"barrier":"flush_data","span_ns":269376,"first_launch_ns":61440,"elapsed_ns":274258,"gbps":122.38,"fixed_per_extra_launch_us":36.21,"identical":1},{"m":8,"barrier":"flush_data","span_ns":389376,"first_launch_ns":49280,"elapsed_ns":394194,"gbps":85.14,"fixed_per_extra_launch_us":32.65,"identical":1},{"m":16,"barrier":"flush_data","span_ns":601952,"first_launch_ns":47712,"elapsed_ns":606932,"gbps":55.30,"fixed_per_extra_launch_us":29.42,"identical":1},{"m":1,"barrier":"none","span_ns":0,"first_launch_ns":0,"elapsed_ns":204034,"gbps":164.50,"fixed_per_extra_launch_us":0.00,"identical":1},{"m":2,"barrier":"none","span_ns":0,"first_launch_ns":0,"elapsed_ns":164017,"gbps":204.63,"fixed_per_extra_launch_us":-40.02,"identical":1},{"m":4,"barrier":"none","span_ns":0,"first_launch_ns":0,"elapsed_ns":200642,"gbps":167.28,"fixed_per_extra_launch_us":-1.13,"identical":1},{"m":8,"barrier":"none","span_ns":0,"first_launch_ns":0,"elapsed_ns":226641,"gbps":148.09,"fixed_per_extra_launch_us":3.23,"identical":1},{"m":16,"barrier":"none","span_ns":0,"first_launch_ns":0,"elapsed_ns":226289,"gbps":148.32,"fixed_per_extra_launch_us":1.48,"identical":1},{"m":1,"barrier":"wfi+inval_all","span_ns":148864,"first_launch_ns":148864,"elapsed_ns":153793,"gbps":218.23,"fixed_per_extra_launch_us":0.00,"identical":1},{"m":2,"barrier":"wfi+inval_all","span_ns":194944,"first_launch_ns":102368,"elapsed_ns":199889,"gbps":167.91,"fixed_per_extra_launch_us":46.10,"identical":1},{"m":4,"barrier":"wfi+inval_all","span_ns":247616,"first_launch_ns":58560,"elapsed_ns":252450,"gbps":132.95,"fixed_per_extra_launch_us":32.89,"identical":1},{"m":8,"barrier":"wfi+inval_all","span_ns":391904,"first_launch_ns":56320,"elapsed_ns":397379,"gbps":84.46,"fixed_per_extra_launch_us":34.80,"identical":1},{"m":16,"barrier":"wfi+inval_all","span_ns":644416,"first_launch_ns":46624,"elapsed_ns":649461,"gbps":51.68,"fixed_per_extra_launch_us":33.04,"identical":1}],"checks":31,"failed":0,"verdict":"PASS"} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-main.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-main.json new file mode 100644 index 000000000..664ca4e03 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-main.json @@ -0,0 +1,21 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 0, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "random_rows": {"rows": 20000, "differing": 0}, + "ma_grid": {"points": 36, "rows": 49932, "differing": 0}, + "bitnet_shapes": {"layouts": 2, "differing": 0}, + "mutant_1": {"rows": 512, "differing": 512, "caught": true}, + "mutant_3": {"rows": 512, "differing": 511, "caught": true}, + "f32_qkv": {"rows": 3840, "differing": 0}, + "mutant_2": {"rows": 3840, "differing": 1919, "caught": true}, + "launch_floor_in_list": {"median_us": 3.744, "min_us": 3.456}, + "cold": [ + {"n": 3840, "k": 2560, "bytes": 2457600, "copies": 41, "median_ns": 15296, "min_ns": 14752, "gbs": 160.67, "of_spec_273": 0.5885, "of_practical_237_2": 0.6774, "minus_floor_ns": 11552, "minus_floor_gbs": 212.74, "minus_floor_of_spec_273": 0.7793, "minus_floor_of_practical_237_2": 0.8969, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 2560, "bytes": 1638400, "copies": 62, "median_ns": 13344, "min_ns": 13024, "gbs": 122.78, "of_spec_273": 0.4498, "of_practical_237_2": 0.5176, "minus_floor_ns": 9600, "minus_floor_gbs": 170.67, "minus_floor_of_spec_273": 0.6252, "minus_floor_of_practical_237_2": 0.7195, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": false}, + {"n": 13824, "k": 2560, "bytes": 8847360, "copies": 12, "median_ns": 42592, "min_ns": 37760, "gbs": 207.72, "of_spec_273": 0.7609, "of_practical_237_2": 0.8757, "minus_floor_ns": 38848, "minus_floor_gbs": 227.74, "minus_floor_of_spec_273": 0.8342, "minus_floor_of_practical_237_2": 0.9601, "gate_gbs": 200, "gate_on": "minus_floor_gbs", "pass": true}, + {"n": 2560, "k": 6912, "bytes": 4423680, "copies": 23, "median_ns": 26272, "min_ns": 24352, "gbs": 168.38, "of_spec_273": 0.6168, "of_practical_237_2": 0.7099, "minus_floor_ns": 22528, "minus_floor_gbs": 196.36, "minus_floor_of_spec_273": 0.7193, "minus_floor_of_practical_237_2": 0.8278, "gate_gbs": 180, "gate_on": "minus_floor_gbs", "pass": true} + ], + "checks": 68, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant1.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant1.json new file mode 100644 index 000000000..abf7a7ab4 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant1.json @@ -0,0 +1,10 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 1, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "random_rows": {"rows": 20000, "differing": 19999}, + "ma_grid": {"points": 36, "rows": 49932, "differing": 49925}, + "bitnet_shapes": {"layouts": 2, "differing": 45566}, + "checks": 55, "failed": 55, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant2.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant2.json new file mode 100644 index 000000000..a2f51e015 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant2.json @@ -0,0 +1,8 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 2, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "forced_mutant_2_differing": 1919, + "checks": 1, "failed": 1, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant3.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant3.json new file mode 100644 index 000000000..3d1c97427 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant3.json @@ -0,0 +1,10 @@ +{ + "test": "gpu_tern_test", + "stage": "TERN-T0 KT1", + "mutant_forced": 3, + "shape_k2560": {"layout": 0, "rows": 1, "warps": 8, "depth": 10, "ctas": 160}, + "random_rows": {"rows": 20000, "differing": 19992}, + "ma_grid": {"points": 36, "rows": 49932, "differing": 49905}, + "bitnet_shapes": {"layouts": 2, "differing": 45542}, + "checks": 55, "failed": 55, "verdict": "FAIL" +} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-table-bf16.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-table-bf16.json new file mode 100644 index 000000000..58301d8c4 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-table-bf16.json @@ -0,0 +1 @@ +{"receipt":"OMEGA_GPU_BF16_GEMV_V1","n":128256,"k":2560,"reps":20,"evict":1,"spin_us":2000,"points":[{"point":"parity","rows_bad":0,"worst_rel":2.087e-08,"argmax_chip":59784,"argmax_oracle":59784},{"point":"timing","rows":1,"warps":16,"depth":10,"ctas":96,"reps":20,"chip_median_ns":3031445,"call_median_ns":3126326,"weight_bytes":656670720,"chip_gbps":216.62,"call_gbps":210.05,"marker":1145324612},{"point":"mutant 1","caught":1},{"point":"mutant 2","caught":1},{"point":"mutant 3","caught":1}],"checks":12,"failed":0,"verdict":"PASS"} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-table-fp8.json b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-table-fp8.json new file mode 100644 index 000000000..19127102c --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-table-fp8.json @@ -0,0 +1 @@ +{"test":"OMEGA_GPU_FP8_GEMV","points":[{"name":"one-hot conversion","rc":"OK","exact_rows":256,"of":256},{"name":"custom 128256x2560","experts":1,"n":128256,"k":2560,"groups":1,"x_rows":1,"rc":"OK","bad":0,"worst_rel":3.338e-08,"second_call_identical":1,"variant":1,"grid_x":256,"grid_y":1,"lane_bytes":16,"rows_per_warp":1,"warps_per_cta":8,"depth":0,"bytes":328415520,"upload_ms":140.62,"chip_median_ns":1530747,"gbps_chip":214.55,"call_median_ns":1609787,"gbps_call":204.01,"reps":20,"marker":1145324612,"evict":1},{"name":"custom 128256x2560 mutant 1","caught":1,"rc":"OK","bad":128246,"worst_rel":2.492e-01},{"name":"custom 128256x2560 mutant 2","caught":1,"rc":"OK","bad":128234,"worst_rel":2.130e-01},{"name":"custom 128256x2560 mutant 4","caught":1,"rc":"OK","bad":128246,"worst_rel":2.492e-01}],"checks":5,"failed":0,"device_opens":1,"verdict":"OMEGA_GPU_FP8_GEMV_PASS"} diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant1.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant1.log new file mode 100644 index 000000000..15401d4f0 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant1.log @@ -0,0 +1,62 @@ +FAIL: random tensor 0 (2000 x 16384, sparsity 0.378): 1999 rows differ from oma_rz_oracle +FAIL: random tensor 1 (2000 x 5120, sparsity 0.124): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 2 (2000 x 2048, sparsity 0.550): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 3 (2000 x 7168, sparsity 0.384): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 4 (2000 x 4096, sparsity 0.426): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 5 (2000 x 9216, sparsity 0.020): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 6 (2000 x 6144, sparsity 0.750): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 7 (2000 x 11264, sparsity 0.992): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 8 (2000 x 8192, sparsity 0.674): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 9 (2000 x 13312, sparsity 0.108): 2000 rows differ from oma_rz_oracle +chip: random rows 20000, rows differing from oma_rz_oracle 19999 +FAIL: MA grid width 1024 rows 1 sparsity 0.0: 1 rows differ +FAIL: MA grid width 1024 rows 1 sparsity 0.3: 1 rows differ +FAIL: MA grid width 1024 rows 1 sparsity 0.6: 1 rows differ +FAIL: MA grid width 1024 rows 1 sparsity 0.9: 1 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.0: 64 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.3: 64 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.6: 64 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.9: 64 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.0: 4095 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.3: 4095 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.6: 4095 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.9: 4095 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.0: 1 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.3: 1 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.6: 1 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.9: 1 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.0: 64 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.3: 64 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.6: 64 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.9: 64 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.0: 4096 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.3: 4096 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.6: 4095 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.9: 4095 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.0: 1 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.3: 1 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.6: 1 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.9: 1 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.0: 64 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.3: 64 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.6: 64 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.9: 64 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.0: 4095 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.3: 4096 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.6: 4096 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.9: 4096 rows differ +chip: MA grid 36 points (49932 rows), rows differing 49925 +FAIL: BitNet shape 3840x2560 layout 0: 3840 rows differ +FAIL: BitNet shape 2560x2560 layout 0: 2560 rows differ +FAIL: BitNet shape 13824x2560 layout 0: 13823 rows differ +FAIL: BitNet shape 2560x6912 layout 0: 2560 rows differ +FAIL: BitNet shape 3840x2560 layout 1: 3840 rows differ +FAIL: BitNet shape 2560x2560 layout 1: 2560 rows differ +FAIL: BitNet shape 13824x2560 layout 1: 13823 rows differ +FAIL: BitNet shape 2560x6912 layout 1: 2560 rows differ +chip: BitNet shapes x 2 layouts, rows differing 45566 +FAIL: extremes (|y| = 128 * 16384): OK, 32 rows differ +chip: rows checked against oma_rz_oracle 115500 +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant1.json +gpu_tern_test: 55 checks, 55 failed: FAIL +mutant 1 exit 1 (must be 1: FAIL) diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant2.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant2.log new file mode 100644 index 000000000..9074acd04 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant2.log @@ -0,0 +1,4 @@ +FAIL: f32 q|k|v with mutant 2 forced: OK, 1919 of 3840 rows differ from ((float)y * a) * scale[seg] +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant2.json +gpu_tern_test: 1 checks, 1 failed: FAIL +mutant 2 exit 1 (must be 1: FAIL) diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant3.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant3.log new file mode 100644 index 000000000..7b0663dfc --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/red-mutant3.log @@ -0,0 +1,62 @@ +FAIL: random tensor 0 (2000 x 16384, sparsity 0.378): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 1 (2000 x 5120, sparsity 0.124): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 2 (2000 x 2048, sparsity 0.550): 1998 rows differ from oma_rz_oracle +FAIL: random tensor 3 (2000 x 7168, sparsity 0.384): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 4 (2000 x 4096, sparsity 0.426): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 5 (2000 x 9216, sparsity 0.020): 1999 rows differ from oma_rz_oracle +FAIL: random tensor 6 (2000 x 6144, sparsity 0.750): 1997 rows differ from oma_rz_oracle +FAIL: random tensor 7 (2000 x 11264, sparsity 0.992): 1999 rows differ from oma_rz_oracle +FAIL: random tensor 8 (2000 x 8192, sparsity 0.674): 2000 rows differ from oma_rz_oracle +FAIL: random tensor 9 (2000 x 13312, sparsity 0.108): 1999 rows differ from oma_rz_oracle +chip: random rows 20000, rows differing from oma_rz_oracle 19992 +FAIL: MA grid width 1024 rows 1 sparsity 0.0: 1 rows differ +FAIL: MA grid width 1024 rows 1 sparsity 0.3: 1 rows differ +FAIL: MA grid width 1024 rows 1 sparsity 0.6: 1 rows differ +FAIL: MA grid width 1024 rows 1 sparsity 0.9: 1 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.0: 63 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.3: 64 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.6: 64 rows differ +FAIL: MA grid width 1024 rows 64 sparsity 0.9: 64 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.0: 4089 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.3: 4096 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.6: 4090 rows differ +FAIL: MA grid width 1024 rows 4096 sparsity 0.9: 4092 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.0: 1 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.3: 1 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.6: 1 rows differ +FAIL: MA grid width 4096 rows 1 sparsity 0.9: 1 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.0: 64 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.3: 64 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.6: 64 rows differ +FAIL: MA grid width 4096 rows 64 sparsity 0.9: 64 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.0: 4095 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.3: 4096 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.6: 4094 rows differ +FAIL: MA grid width 4096 rows 4096 sparsity 0.9: 4094 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.0: 1 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.3: 1 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.6: 1 rows differ +FAIL: MA grid width 16384 rows 1 sparsity 0.9: 1 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.0: 64 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.3: 64 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.6: 64 rows differ +FAIL: MA grid width 16384 rows 64 sparsity 0.9: 64 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.0: 4096 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.3: 4095 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.6: 4093 rows differ +FAIL: MA grid width 16384 rows 4096 sparsity 0.9: 4096 rows differ +chip: MA grid 36 points (49932 rows), rows differing 49905 +FAIL: BitNet shape 3840x2560 layout 0: 3836 rows differ +FAIL: BitNet shape 2560x2560 layout 0: 2560 rows differ +FAIL: BitNet shape 13824x2560 layout 0: 13816 rows differ +FAIL: BitNet shape 2560x6912 layout 0: 2559 rows differ +FAIL: BitNet shape 3840x2560 layout 1: 3836 rows differ +FAIL: BitNet shape 2560x2560 layout 1: 2560 rows differ +FAIL: BitNet shape 13824x2560 layout 1: 13816 rows differ +FAIL: BitNet shape 2560x6912 layout 1: 2559 rows differ +chip: BitNet shapes x 2 layouts, rows differing 45542 +FAIL: extremes (|y| = 128 * 16384): OK, 32 rows differ +chip: rows checked against oma_rz_oracle 115500 +receipt: evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/receipt-red-mutant3.json +gpu_tern_test: 55 checks, 55 failed: FAIL +mutant 3 exit 1 (must be 1: FAIL) diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/sim.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/sim.log new file mode 100644 index 000000000..1823bbbdd --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/sim.log @@ -0,0 +1,5 @@ +sim: 14 int32 points x 2 orders bit-equal to oma_rz_oracle (211018 warp issues) +sim: mutant 1 caught (16 of 16 rows differ) +sim: mutant 3 caught (16 of 16 rows differ) +sim: mutant 2 caught (24 of 48 rows take the wrong scale) +gpu_tern_test: 34 checks, 0 failed: PASS diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/table-bf16.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/table-bf16.log new file mode 100644 index 000000000..3fef4138d --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/table-bf16.log @@ -0,0 +1,10 @@ +upload 128256 x 2560 bf16 (657 MB): rc=OK 313 ms () +parity: 0 of 128256 rows differ from the f32 emulation (bit compare); worst error vs double oracle 2.09e-08 of the term scale (y 2.346); argmax chip 59784 oracle 59784 +second call: bit-identical +bf16-x entry: bit-identical to the emulation +timing (medians of 20, evict 1): rows 1 warps 16 depth 10 ctas 96: chip 3031.4 us = 216.6 GB/s on 657 MB; call 3126.3 us = 210.0 GB/s +chip mutant 1: caught (4096 of 4096 rows differ) +chip mutant 2: caught (4096 of 4096 rows differ) +chip mutant 3: caught (4096 of 4096 rows differ) +gpu_bf16_gemv_test: 12 checks, 0 failed: PASS +table-bf16 exit 0 diff --git a/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/table-fp8.log b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/table-fp8.log new file mode 100644 index 000000000..91b4dece0 --- /dev/null +++ b/evidence/TERN-T0-KT1-SPEED-d58a46a0-20261016T0305Z/table-fp8.log @@ -0,0 +1,7 @@ +chip one-hot conversion: rc=OK 256/256 rows exact (subnormal codes 0x01..0x07 included: no flush to zero) +chip custom 128256x2560 variant=1 rc=OK bad=0 worst_rel=3.338e-08 grid=256x1 lb=16 rows=1 warps=8 depth=0 bytes=328415520 upload=140.6ms chip_med=1530.7us (214.5 GB/s) call_med=1609.8us (204.0 GB/s) reps=20 +chip custom 128256x2560 mutant 1: caught (rc=OK bad=128246 worst_rel=2.492e-01) +chip custom 128256x2560 mutant 2: caught (rc=OK bad=128234 worst_rel=2.130e-01) +chip custom 128256x2560 mutant 4: caught (rc=OK bad=128246 worst_rel=2.492e-01) +gpu_fp8_api_test: 5 checks, 0 failed: PASS +table-fp8 exit 0 diff --git a/evidence/TGEMM-CUT1-5b10b824/SHA256SUMS b/evidence/TGEMM-CUT1-5b10b824/SHA256SUMS new file mode 100644 index 000000000..6464a30a2 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/SHA256SUMS @@ -0,0 +1,12 @@ +edf6f8091f2369aa77659c17cb406a04eb3565d0eabaf807f6d81b99e137291a build.log +6b26f0221cbc10cd6e2668605eebcdbf04b1ec884c9ffc44687a9c57a20ce6f2 host-only.log +9f5d94811922b62f06605cfefe1e634092a3140b1b5ade153a3e19564d3d8d00 k50304.log +b4cdd71a7b4ef90a772cd2b500232d7167f7fa4f501757715b2558f1ce106a08 main.log +96afe3614b461111e57a63f29ec70b98ac5a5ae5c15c642cf30605421657d9a4 n2304.log +e82612c2d7427002bacebb779b7193b3b47425b9607367d6e5547c5e7ca8f741 peak.log +f2ad0847bc310fdb18b124e8d12d66d821933b5b1a6f00cb05f9cdba853ee616 peak-window1.log +14416b6d582df6562d1038e18e7ea77e6f08bf0fa18ecaf8c730b09f27f05953 rt2.log +710bdc08fcfb08adfaf566752e1c9219575f710d3708d2aab7447b2c7e469d95 sim.log +2c1c11249d9aae7d903c5fff98fa2292436d423f50dac91445e14d5f5bf4f36c warps8.log +bfbdaa6b61a5933fd2784c4417177b40da2d4dc2c8ba4942ac02a54af523bc1e device.txt +c9270adb061de9dbccaac44b77c8fd49827aa74040bfda7f8ccd50ebf8017739 yardstick.txt diff --git a/evidence/TGEMM-CUT1-5b10b824/build.log b/evidence/TGEMM-CUT1-5b10b824/build.log new file mode 100644 index 000000000..52d025796 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/build.log @@ -0,0 +1 @@ +make: 'build/gpu_tc_peak_test' is up to date. diff --git a/evidence/TGEMM-CUT1-5b10b824/device.txt b/evidence/TGEMM-CUT1-5b10b824/device.txt new file mode 100644 index 000000000..a82a6bcd7 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/device.txt @@ -0,0 +1,6 @@ +start 2026-10-16T02:52:13Z omega=5b10b82445c984ae91e3709bc2151a2ec9abde5c branch=train/tgemm-cut1 dirty=1 physics=/home/drakestapleton/workspace/physics-own30b-k physics_commit=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf +Linux spark-b87b 7.0.0-1019-nvidia #19~24.04.2-Ubuntu SMP PREEMPT_DYNAMIC Sun Sep 6 18:35:11 UTC 2 aarch64 aarch64 aarch64 GNU/Linux +NVIDIA GB10, 580.173.02, 208 MHz, 3003 MHz, 47 + total used free shared buff/cache available +Mem: 121 15 14 2 96 106 +end 2026-10-16T02:56:02Z diff --git a/evidence/TGEMM-CUT1-5b10b824/host-only.log b/evidence/TGEMM-CUT1-5b10b824/host-only.log new file mode 100644 index 000000000..37a71bb15 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/host-only.log @@ -0,0 +1,9 @@ +spec k 2304 n 768 rt 8 ct 2 warps 16 kc 32 aqn 1: built, 800 instructions, peak 125, declared 128, shared 16384 B -> fits (production) +spec k 768 n 3072 rt 8 ct 2 warps 16 kc 32 aqn 1: built, 800 instructions, peak 125, declared 128, shared 16384 B -> fits (production) +spec k 50304 n 768 rt 4 ct 2 warps 8 kc 32 aqn 1: built, 552 instructions, peak 93, declared 96, shared 8192 B -> fits (production) +spec k 768 n 2304 rt 4 ct 2 warps 16 kc 32 aqn 2: built, 527 instructions, peak 96, declared 104, shared 8192 B -> fits +spec k 768 n 768 rt 4 ct 2 warps 16 kc 32 aqn 1: built, 527 instructions, peak 92, declared 96, shared 8192 B -> fits +spec k 768 n 768 rt 4 ct 2 warps 8 kc 32 aqn 1: built, 552 instructions, peak 93, declared 96, shared 8192 B -> fits +spec k 768 n 768 rt 2 ct 2 warps 8 kc 32 aqn 1: built, 403 instructions, peak 76, declared 80, shared 4096 B -> fits +spec k 768 n 768 rt 8 ct 2 warps 8 kc 32 aqn 1: REFUSED, 0 instructions, peak 0, declared 8, shared 16384 B -> DOES NOT FIT +GPU_TGEMM: PASS diff --git a/evidence/TGEMM-CUT1-5b10b824/k50304.log b/evidence/TGEMM-CUT1-5b10b824/k50304.log new file mode 100644 index 000000000..43477833c --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/k50304.log @@ -0,0 +1,8 @@ +TGEMM 1024x768x50304 uncached rt 8 warps 16 tiles 8 grid_x 3: reference 0 of 786432 outside 1e-5 (worst 4.11e-06), 786432 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 34.4 s) +TGEMM 1024x768x50304 uncached: chip median 5.093 ms (min 5.054) = 15.53 TFLOPS = 13.2% of peak 117.26; whole call median 5.096 ms = 15.52 TFLOPS = 13.2% +TGEMM 1024x768x50304 mutant 4: caught +TGEMM 1024x768x50304 mutant 1: caught +TGEMM 1024x768x50304 cached rt 8 warps 16 tiles 8 grid_x 3: reference 0 of 786432 outside 1e-5 (worst 4.13e-06), 786432 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 33.6 s) +TGEMM 1024x768x50304 cached: chip median 2.498 ms (min 2.485) = 31.67 TFLOPS = 27.0% of peak 117.26; whole call median 2.499 ms = 31.66 TFLOPS = 27.0% +GPU_TGEMM: PASS +--shape 1024x768x50304 exit 0 (informational) diff --git a/evidence/TGEMM-CUT1-5b10b824/main.log b/evidence/TGEMM-CUT1-5b10b824/main.log new file mode 100644 index 000000000..60de933e1 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/main.log @@ -0,0 +1,26 @@ +TGEMM 8192x768x2304 uncached rt 8 warps 16 tiles 64 grid_x 3: reference 0 of 6291456 outside 1e-5 (worst 1.16e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 11.0 s) +TGEMM 8192x768x2304 uncached: chip median 1.715 ms (min 1.708) = 16.90 TFLOPS = 14.4% of peak 117.26; whole call median 1.722 ms = 16.84 TFLOPS = 14.4% +TGEMM 8192x768x2304 mutant 4: caught +TGEMM 8192x768x2304 mutant 1: caught +TGEMM 8192x768x2304 cached rt 8 warps 16 tiles 64 grid_x 3: reference 0 of 6291456 outside 1e-5 (worst 1.12e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 10.7 s) +TGEMM 8192x768x2304 cached: chip median 0.556 ms (min 0.554) = 52.15 TFLOPS = 44.5% of peak 117.26; whole call median 0.556 ms = 52.11 TFLOPS = 44.4% GATE ok +TGEMM 8192x768x768 uncached rt 8 warps 16 tiles 64 grid_x 3: reference 0 of 6291456 outside 1e-5 (worst 6.92e-07), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 3.8 s) +TGEMM 8192x768x768 uncached: chip median 0.519 ms (min 0.516) = 18.63 TFLOPS = 15.9% of peak 117.26; whole call median 0.519 ms = 18.61 TFLOPS = 15.9% +TGEMM 8192x768x768 mutant 4: caught +TGEMM 8192x768x768 mutant 1: caught +TGEMM 8192x768x768 cached rt 8 warps 16 tiles 64 grid_x 3: reference 0 of 6291456 outside 1e-5 (worst 7.32e-07), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 3.8 s) +TGEMM 8192x768x768 cached: chip median 0.277 ms (min 0.276) = 34.90 TFLOPS = 29.8% of peak 117.26; whole call median 0.277 ms = 34.83 TFLOPS = 29.7% GATE ok +TGEMM 8192x768x3072 uncached rt 8 warps 16 tiles 64 grid_x 3: reference 0 of 6291456 outside 1e-5 (worst 1.23e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 14.6 s) +TGEMM 8192x768x3072 uncached: chip median 2.328 ms (min 2.283) = 16.60 TFLOPS = 14.2% of peak 117.26; whole call median 2.337 ms = 16.54 TFLOPS = 14.1% +TGEMM 8192x768x3072 mutant 4: caught +TGEMM 8192x768x3072 mutant 1: caught +TGEMM 8192x768x3072 cached rt 8 warps 16 tiles 64 grid_x 3: reference 0 of 6291456 outside 1e-5 (worst 1.37e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 13.5 s) +TGEMM 8192x768x3072 cached: chip median 0.700 ms (min 0.697) = 55.20 TFLOPS = 47.1% of peak 117.26; whole call median 0.701 ms = 55.14 TFLOPS = 47.0% GATE ok +TGEMM 8192x3072x768 uncached rt 8 warps 16 tiles 64 grid_x 12: reference 0 of 25165824 outside 1e-5 (worst 7.27e-07), 25165824 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 16.4 s) +TGEMM 8192x3072x768 uncached: chip median 2.701 ms (min 2.654) = 14.31 TFLOPS = 12.2% of peak 117.26; whole call median 2.741 ms = 14.10 TFLOPS = 12.0% +TGEMM 8192x3072x768 mutant 4: caught +TGEMM 8192x3072x768 mutant 1: caught +TGEMM 8192x3072x768 cached rt 8 warps 16 tiles 64 grid_x 12: reference 0 of 25165824 outside 1e-5 (worst 7.22e-07), 25165824 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 15.9 s) +TGEMM 8192x3072x768 cached: chip median 1.011 ms (min 1.005) = 38.25 TFLOPS = 32.6% of peak 117.26; whole call median 1.011 ms = 38.23 TFLOPS = 32.6% GATE ok +GPU_TGEMM: PASS +GPU_TGEMM_CHIP: PASS diff --git a/evidence/TGEMM-CUT1-5b10b824/n2304.log b/evidence/TGEMM-CUT1-5b10b824/n2304.log new file mode 100644 index 000000000..9e6a90002 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/n2304.log @@ -0,0 +1,8 @@ +TGEMM 8192x2304x768 uncached rt 8 warps 16 tiles 64 grid_x 9: reference 0 of 18874368 outside 1e-5 (worst 7.14e-07), 18874368 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 12.0 s) +TGEMM 8192x2304x768 uncached: chip median 1.891 ms (min 1.876) = 15.33 TFLOPS = 13.1% of peak 117.26; whole call median 1.895 ms = 15.30 TFLOPS = 13.0% +TGEMM 8192x2304x768 mutant 4: caught +TGEMM 8192x2304x768 mutant 1: caught +TGEMM 8192x2304x768 cached rt 8 warps 16 tiles 64 grid_x 9: reference 0 of 18874368 outside 1e-5 (worst 7.65e-07), 18874368 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 12.2 s) +TGEMM 8192x2304x768 cached: chip median 0.703 ms (min 0.699) = 41.25 TFLOPS = 35.2% of peak 117.26; whole call median 0.704 ms = 41.21 TFLOPS = 35.1% +GPU_TGEMM: PASS +--shape 8192x2304x768 exit 0 (informational) diff --git a/evidence/TGEMM-CUT1-5b10b824/peak-window1.log b/evidence/TGEMM-CUT1-5b10b824/peak-window1.log new file mode 100644 index 000000000..d1aeb52dd --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/peak-window1.log @@ -0,0 +1,18 @@ +start 2026-10-16T02:15:08Z omega=c95ab6d43f5eda6ad7f7835c3e29fff46a9c07b9 branch=train/tgemm-cut1 dirty=0 +208 MHz, 3003 MHz, 37, 0 % +sim chains 8: ran, peak 48 registers, 93 instructions, 0 wrong +sim chains 16: ran, peak 80 registers, 165 instructions, 0 wrong +peak stall 8 chains 16 threads 128 ctas 192 (declared 88): median 1835.2 us, 112.34 TFLOPS, 0 wrong values +peak stall 4 chains 16 threads 128 ctas 192 (declared 88): median 1839.8 us, 112.06 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 128 ctas 192 (declared 88): median 2039.4 us, 101.09 TFLOPS, 0 wrong values +peak stall 2 chains 8 threads 128 ctas 192 (declared 56): median 1017.3 us, 101.33 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 256 ctas 192 (declared 88): median 3670.3 us, 112.34 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 128 ctas 384 (declared 88): median 3467.5 us, 118.91 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 512 ctas 96 (declared 88): median 4083.7 us, 100.97 TFLOPS, 0 wrong values +peak stall 4 chains 8 threads 256 ctas 384 (declared 56): median 3566.1 us, 115.62 TFLOPS, 0 wrong values +peak stall 1 chains 16 threads 256 ctas 384 (declared 88): median 6835.5 us, 120.64 TFLOPS, 0 wrong values +bw distinct bytes per CTA, 1024 KB per CTA, 384 CTAs: median 1738.5 us, 231.6 GB/s delivered (384 MB distinct), 0 wrong +bw SAME bytes for every CTA, 1024 KB per CTA, 384 CTAs: median 1438.3 us, 279.9 GB/s delivered (1 MB distinct), 0 wrong +bw distinct bytes per CTA, 256 KB per CTA, 384 CTAs: median 411.0 us, 244.9 GB/s delivered (96 MB distinct), 0 wrong +bw SAME bytes for every CTA, 256 KB per CTA, 384 CTAs: median 410.3 us, 245.3 GB/s delivered (0 MB distinct), 0 wrong +GPU_TC_PEAK: PASS diff --git a/evidence/TGEMM-CUT1-5b10b824/peak.log b/evidence/TGEMM-CUT1-5b10b824/peak.log new file mode 100644 index 000000000..6dc3c104e --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/peak.log @@ -0,0 +1,16 @@ +sim chains 8: ran, peak 48 registers, 93 instructions, 0 wrong +sim chains 16: ran, peak 80 registers, 165 instructions, 0 wrong +peak stall 8 chains 16 threads 128 ctas 192 (declared 88): median 1938.7 us, 106.34 TFLOPS, 0 wrong values +peak stall 4 chains 16 threads 128 ctas 192 (declared 88): median 1936.7 us, 106.45 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 128 ctas 192 (declared 88): median 1937.0 us, 106.43 TFLOPS, 0 wrong values +peak stall 2 chains 8 threads 128 ctas 192 (declared 56): median 978.5 us, 105.35 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 256 ctas 192 (declared 88): median 3672.0 us, 112.29 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 128 ctas 384 (declared 88): median 3554.4 us, 116.00 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 512 ctas 96 (declared 88): median 4278.6 us, 96.37 TFLOPS, 0 wrong values +peak stall 4 chains 8 threads 256 ctas 384 (declared 56): median 3565.7 us, 115.63 TFLOPS, 0 wrong values +peak stall 1 chains 16 threads 256 ctas 384 (declared 88): median 7032.5 us, 117.26 TFLOPS, 0 wrong values +bw distinct bytes per CTA, 1024 KB per CTA, 384 CTAs: median 1635.2 us, 246.2 GB/s delivered (384 MB distinct), 0 wrong +bw SAME bytes for every CTA, 1024 KB per CTA, 384 CTAs: median 1438.2 us, 280.0 GB/s delivered (1 MB distinct), 0 wrong +bw distinct bytes per CTA, 256 KB per CTA, 384 CTAs: median 409.6 us, 245.8 GB/s delivered (96 MB distinct), 0 wrong +bw SAME bytes for every CTA, 256 KB per CTA, 384 CTAs: median 410.0 us, 245.5 GB/s delivered (0 MB distinct), 0 wrong +GPU_TC_PEAK: PASS diff --git a/evidence/TGEMM-CUT1-5b10b824/rt2.log b/evidence/TGEMM-CUT1-5b10b824/rt2.log new file mode 100644 index 000000000..75889a229 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/rt2.log @@ -0,0 +1,5 @@ +shape 8192x768x2304 setup: CHIP_FAIL (m16_native_create_channel: RM_ALLOC class 0xcec0 status 0x51) +TGEMM 8192x768x2304 cached rt 2 warps 8 tiles 256 grid_x 6: reference 0 of 6291456 outside 1e-5 (worst 1.12e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 13.7 s) +TGEMM 8192x768x2304 cached: chip median 0.822 ms (min 0.818) = 35.28 TFLOPS = 30.1% of peak 117.26; whole call median 0.822 ms = 35.25 TFLOPS = 30.1% +GPU_TGEMM: FAIL +--shape 8192x768x2304 --shape-knob 2 8 1 exit 1 (informational) diff --git a/evidence/TGEMM-CUT1-5b10b824/sim.log b/evidence/TGEMM-CUT1-5b10b824/sim.log new file mode 100644 index 000000000..8faec3694 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/sim.log @@ -0,0 +1,15 @@ +sim case 0 (M 128 N 512 K 256 rt 4 warps 16 aqn 1 blocks 0..1) order 0: ran, 0 of 65536 differ +sim case 0 (M 128 N 512 K 256 rt 4 warps 16 aqn 1 blocks 0..1) order 1: ran, 0 of 65536 differ +sim case 0 mutant 1: caught +sim case 0 mutant 2: caught +sim case 0 mutant 3: caught +sim case 0 mutant 4: caught +sim case 1 (M 64 N 256 K 384 rt 2 warps 8 aqn 1 blocks 1..2) order 0: ran, 0 of 16384 differ +sim case 1 (M 64 N 256 K 384 rt 2 warps 8 aqn 1 blocks 1..2) order 1: ran, 0 of 16384 differ +sim case 2 (M 128 N 256 K 128 rt 4 warps 16 aqn 2 blocks 0..0) order 0: ran, 0 of 32768 differ +sim case 2 (M 128 N 256 K 128 rt 4 warps 16 aqn 2 blocks 0..0) order 1: ran, 0 of 32768 differ +sim case 3 (M 128 N 256 K 256 rt 4 warps 8 aqn 2 blocks 0..1) order 0: ran, 0 of 32768 differ +sim case 3 (M 128 N 256 K 256 rt 4 warps 8 aqn 2 blocks 0..1) order 1: ran, 0 of 32768 differ +sim case 4 (M 256 N 512 K 128 rt 8 warps 16 aqn 1 blocks 0..0) order 0: ran, 0 of 131072 differ +sim case 4 (M 256 N 512 K 128 rt 8 warps 16 aqn 1 blocks 0..0) order 1: ran, 0 of 131072 differ +GPU_TGEMM: PASS diff --git a/evidence/TGEMM-CUT1-5b10b824/warps8.log b/evidence/TGEMM-CUT1-5b10b824/warps8.log new file mode 100644 index 000000000..162f5f816 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/warps8.log @@ -0,0 +1,8 @@ +TGEMM 8192x768x2304 uncached rt 4 warps 8 tiles 128 grid_x 6: reference 0 of 6291456 outside 1e-5 (worst 1.16e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 12.4 s) +TGEMM 8192x768x2304 uncached: chip median 3.174 ms (min 3.132) = 9.14 TFLOPS = 7.8% of peak 117.26; whole call median 3.234 ms = 8.96 TFLOPS = 7.6% +TGEMM 8192x768x2304 mutant 4: caught +TGEMM 8192x768x2304 mutant 1: caught +TGEMM 8192x768x2304 cached rt 4 warps 8 tiles 128 grid_x 6: reference 0 of 6291456 outside 1e-5 (worst 1.12e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 12.9 s) +TGEMM 8192x768x2304 cached: chip median 0.664 ms (min 0.655) = 43.65 TFLOPS = 37.2% of peak 117.26; whole call median 0.665 ms = 43.59 TFLOPS = 37.2% +GPU_TGEMM: PASS +--shape 8192x768x2304 --shape-knob 4 8 1 exit 0 (informational) diff --git a/evidence/TGEMM-CUT1-5b10b824/yardstick.txt b/evidence/TGEMM-CUT1-5b10b824/yardstick.txt new file mode 100644 index 000000000..f06a97f74 --- /dev/null +++ b/evidence/TGEMM-CUT1-5b10b824/yardstick.txt @@ -0,0 +1 @@ +yardstick: bf16 HMMA dense peak 117.26 TFLOPS (best 'peak' line of peak.log) diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/SHA256SUMS b/evidence/TGEMM-CUT1-FIX-403d5cf5/SHA256SUMS new file mode 100644 index 000000000..bfc838e60 --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/SHA256SUMS @@ -0,0 +1,6 @@ +df0f5393b37f2289da43ab52d5847e328b5cf81d2c29cb34341ea09fdd81fe8d build.log +738ffc4ce041c175d6df20abc31974f0e5c0d89e0545a0ae608ae92185041cb3 n50304.log +de9f2a081e312c7f1c330815efae373612e2743f5ba0debbff75fad18364f1dd peak.log +78babe9837f429907aed330816fe1ccfe41939df1952bbb9830af46ea2c919e3 rt2.log +cebde958ba723d6d52905eac7e02153f5975074d1a83e1db4effb701f4b27005 device.txt +8e449b75ee90911a333252c5f5339722515d5d6dc51676a3ebe8dadeda894134 yardstick.txt diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/build.log b/evidence/TGEMM-CUT1-FIX-403d5cf5/build.log new file mode 100644 index 000000000..5666d03e6 --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/build.log @@ -0,0 +1,2 @@ +cc -std=gnu11 -Wall -Wextra -Werror -MMD -MP -D_GNU_SOURCE -O2 -Isrc -I/home/drakestapleton/workspace/physics-own30b-k/m16 -I/home/drakestapleton/workspace/physics-own30b-k/nvrm -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/kernel-open/common/inc -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o build/gpu_tgemm_test tests/gpu_tgemm_test.c build/libomega_gpu.a -lpthread -lm +cc -std=gnu11 -Wall -Wextra -Werror -MMD -MP -D_GNU_SOURCE -O2 -Isrc -I/home/drakestapleton/workspace/physics-own30b-k/m16 -I/home/drakestapleton/workspace/physics-own30b-k/nvrm -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/kernel-open/common/inc -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm -I/home/drakestapleton/workspace/physics-own30b-k/third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o build/gpu_tc_peak_test tests/gpu_tc_peak_test.c build/libomega_gpu.a -lpthread -lm diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/device.txt b/evidence/TGEMM-CUT1-FIX-403d5cf5/device.txt new file mode 100644 index 000000000..c1ef92776 --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/device.txt @@ -0,0 +1,4 @@ +start 2026-10-16T05:38:19Z omega=403d5cf594568204a37757e174bbb0cff5952e42 branch=train/tgemm-cut1 dirty=0 +Linux spark-b87b 7.0.0-1019-nvidia #19~24.04.2-Ubuntu SMP PREEMPT_DYNAMIC Sun Sep 6 18:35:11 UTC 2 aarch64 aarch64 aarch64 GNU/Linux +NVIDIA GB10, 580.173.02, 208 MHz, 3003 MHz, 44 +end 2026-10-16T05:39:44Z diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/n50304.log b/evidence/TGEMM-CUT1-FIX-403d5cf5/n50304.log new file mode 100644 index 000000000..76ca3d1bb --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/n50304.log @@ -0,0 +1,8 @@ +TGEMM 1024x50304x768 uncached rt 4 warps 8 tiles 16 grid_x 393: reference 0 of 51511296 outside 1e-5 (worst 7.79e-07), 51511296 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 30.0 s) +TGEMM 1024x50304x768 uncached: chip median 8.725 ms (min 8.585) = 9.07 TFLOPS = 7.5% of peak 120.16; whole call median 8.743 ms = 9.05 TFLOPS = 7.5% +TGEMM 1024x50304x768 mutant 4: caught +TGEMM 1024x50304x768 mutant 1: caught +TGEMM 1024x50304x768 cached rt 4 warps 8 tiles 16 grid_x 393: reference 0 of 51511296 outside 1e-5 (worst 7.42e-07), 51511296 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 30.2 s) +TGEMM 1024x50304x768 cached: chip median 6.962 ms (min 6.858) = 11.36 TFLOPS = 9.5% of peak 120.16; whole call median 6.963 ms = 11.36 TFLOPS = 9.5% +GPU_TGEMM: PASS +exit 0 (informational) diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/peak.log b/evidence/TGEMM-CUT1-FIX-403d5cf5/peak.log new file mode 100644 index 000000000..249faf184 --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/peak.log @@ -0,0 +1,16 @@ +sim chains 8: ran, peak 48 registers, 93 instructions, 0 wrong +sim chains 16: ran, peak 80 registers, 165 instructions, 0 wrong +peak stall 8 chains 16 threads 128 ctas 192 (declared 88): median 1938.6 us, 106.34 TFLOPS, 0 wrong values +peak stall 4 chains 16 threads 128 ctas 192 (declared 88): median 1930.0 us, 106.82 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 128 ctas 192 (declared 88): median 1856.2 us, 111.07 TFLOPS, 0 wrong values +peak stall 2 chains 8 threads 128 ctas 192 (declared 56): median 1005.4 us, 102.53 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 256 ctas 192 (declared 88): median 3641.6 us, 113.22 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 128 ctas 384 (declared 88): median 3486.8 us, 118.25 TFLOPS, 0 wrong values +peak stall 2 chains 16 threads 512 ctas 96 (declared 88): median 4036.1 us, 102.16 TFLOPS, 0 wrong values +peak stall 4 chains 8 threads 256 ctas 384 (declared 56): median 3552.4 us, 116.07 TFLOPS, 0 wrong values +peak stall 1 chains 16 threads 256 ctas 384 (declared 88): median 6863.0 us, 120.16 TFLOPS, 0 wrong values +bw distinct bytes per CTA, 1024 KB per CTA, 384 CTAs: median 1724.7 us, 233.5 GB/s delivered (384 MB distinct), 0 wrong +bw SAME bytes for every CTA, 1024 KB per CTA, 384 CTAs: median 1028.2 us, 391.6 GB/s delivered (1 MB distinct), 0 wrong +bw distinct bytes per CTA, 256 KB per CTA, 384 CTAs: median 409.6 us, 245.7 GB/s delivered (96 MB distinct), 0 wrong +bw SAME bytes for every CTA, 256 KB per CTA, 384 CTAs: median 422.8 us, 238.1 GB/s delivered (0 MB distinct), 0 wrong +GPU_TC_PEAK: PASS diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/rt2.log b/evidence/TGEMM-CUT1-FIX-403d5cf5/rt2.log new file mode 100644 index 000000000..6389816fa --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/rt2.log @@ -0,0 +1,8 @@ +TGEMM 8192x768x2304 uncached rt 2 warps 8 tiles 256 grid_x 6: reference 0 of 6291456 outside 1e-5 (worst 1.16e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 11.0 s) +TGEMM 8192x768x2304 uncached: chip median 5.385 ms (min 5.276) = 5.38 TFLOPS = 4.5% of peak 120.16; whole call median 5.390 ms = 5.38 TFLOPS = 4.5% +TGEMM 8192x768x2304 mutant 4: caught +TGEMM 8192x768x2304 mutant 1: caught +TGEMM 8192x768x2304 cached rt 2 warps 8 tiles 256 grid_x 6: reference 0 of 6291456 outside 1e-5 (worst 1.12e-06), 6291456 bit-identical to the emulation, repeats identical yes, poison left 0 (reference 10.8 s) +TGEMM 8192x768x2304 cached: chip median 0.807 ms (min 0.802) = 35.92 TFLOPS = 29.9% of peak 120.16; whole call median 0.808 ms = 35.89 TFLOPS = 29.9% +GPU_TGEMM: PASS +exit 0 (informational) diff --git a/evidence/TGEMM-CUT1-FIX-403d5cf5/yardstick.txt b/evidence/TGEMM-CUT1-FIX-403d5cf5/yardstick.txt new file mode 100644 index 000000000..8eea0d146 --- /dev/null +++ b/evidence/TGEMM-CUT1-FIX-403d5cf5/yardstick.txt @@ -0,0 +1 @@ +yardstick: bf16 HMMA dense peak 120.16 TFLOPS (best 'peak' line of peak.log) diff --git a/mk/.crumb b/mk/.crumb index cd51a1c73..abd66bef7 100644 --- a/mk/.crumb +++ b/mk/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-16T02:24:36Z", + "compiled_at": "2026-10-20T20:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:e7d38c87a51c3c0ee6e3b18419ef4a01d95029de12ac9bf69eb672654f0ace55", + "digest": "sha256:d5fe276ca62f3f8876724766f78440adda126428d768d1c49532b0175a829b0e", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 71, - "generated_at_commit": "ccf021b944b0128a537dfd3dd301e6d83eefa311", - "source_tree": "sha256:e7a2b37daa8149cb73da719737df82c74a61685b4076bf2c5b4e0c26bee61dc7" + "files": 73, + "generated_at_commit": "738552e3f036b757e740f1dbfa1c4e7de069f63c", + "source_tree": "sha256:a0303df19725e15825e14521e3aa319328de9cba2316c9a571ade53f7d8be10a" }, "owner_lane": "", "provenance": { diff --git a/mk/dgraph-receipt.mk b/mk/dgraph-receipt.mk new file mode 100644 index 000000000..429bbbc92 --- /dev/null +++ b/mk/dgraph-receipt.mk @@ -0,0 +1,35 @@ +# Decode-graph performance receipt (aien-architecture#233, lane P1): tools/dgraph_receipt.c turns an +# existing decode-graph chip run (tools/run_gpu_decode_graph_chip.sh evidence) into one commit-bound +# receipt "omega-decode-graph-receipt/1" and checks such receipts. Host only: links nothing of +# libomega_gpu and no GPU header. Spec: docs/perf/DECODE_GRAPH_RECEIPT.md. Picked up by +# `-include mk/*.mk`; not part of `all` or `test`; run by tests/gates/run.sh chip-tool-selftests. +# make dgraph-receipt build/dgraph_receipt/dgraph_receipt +# make test-dgraph-receipt golden receipts regenerated from evidence/, checker accepts them, +# every negative fixture refused for its named reason (plain + ASan/UBSan) +ifndef DGRAPH_RECEIPT_MK +DGRAPH_RECEIPT_MK := 1 +.PHONY: dgraph-receipt test-dgraph-receipt +DGR_DIR = $(OUT_DIR)/dgraph_receipt +DGR_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 +DGR_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all + +dgraph-receipt: $(DGR_DIR)/dgraph_receipt + +$(DGR_DIR)/dgraph_receipt: tools/dgraph_receipt.c + @mkdir -p $(DGR_DIR) + $(CC) $(DGR_CFLAGS) -o $@ tools/dgraph_receipt.c + +$(DGR_DIR)/dgraph_receipt_asan: tools/dgraph_receipt.c + @mkdir -p $(DGR_DIR) + $(CC) $(DGR_CFLAGS) $(DGR_ASAN) -o $@ tools/dgraph_receipt.c + +# independent strict-JSON check of the golden receipts (tools/json_canon.c, the M19R helper) +$(DGR_DIR)/json_canon: tools/json_canon.c src/sha256.c src/sha256.h + @mkdir -p $(DGR_DIR) + $(CC) $(DGR_CFLAGS) -Isrc -o $@ tools/json_canon.c src/sha256.c + +test-dgraph-receipt: $(DGR_DIR)/dgraph_receipt $(DGR_DIR)/dgraph_receipt_asan $(DGR_DIR)/json_canon + sh tests/dgraph_receipt/run.sh $(DGR_DIR)/dgraph_receipt $(DGR_DIR)/json_canon $(DGR_DIR)/work + sh tests/dgraph_receipt/run.sh $(DGR_DIR)/dgraph_receipt_asan $(DGR_DIR)/json_canon $(DGR_DIR)/work-asan + +endif diff --git a/mk/fabric.mk b/mk/fabric.mk index eaeb9a49a..f2ba2d8ec 100644 --- a/mk/fabric.mk +++ b/mk/fabric.mk @@ -11,7 +11,18 @@ # through src/runtime/rx_capq.h and links the same objects test-capability-graph # links (rx_capq.o, rx_graph.o, the pinned AIENOS capability library). # +# Heterogeneous compute (aienix#6, omega#536): fab_work.c (PST1 task envelope, +# HTK1 request, HTR1 receipt, requester state machine, executor idempotence +# journal), fab_route.c (pre-dispatch route check, steps 1-3 of the dispatcher) +# and fab_auth_ed25519.c (FabAuth over the vendored AIENOS Ed25519) are +# PRODUCTION-buildable: FAB_PROD_SRCS compiles without AIEN_TEST_BUILD and +# fab-work-purity checks them (the signer may reference only aienos_ed25519_*). +# # test-fabric purity check, then the exit-gate test plain and with ASan/UBSan +# test-fabric-work fab-work-purity, then tests/fabric/fab_work_test.c (PST1 vectors from +# aien-protocols PR #36, HTK1/HTR1 goldens, matmul oracle, state-machine +# negatives, Ed25519 membership) plain and ASan/UBSan, then +# tests/fabric/fab_work_procs.sh (requester and executor as two OS processes) # fabric-purity fabric objects reference no authority, World, socket or process call # fabric-receipt digest-named receipt under evidence/F5-0 (clean tree only) # test-fabric-living Lane 13: a second machine's Skill found and used by the @@ -21,14 +32,17 @@ # same scenario runs inside the R13 test-build variant. ifndef FABRIC_MK FABRIC_MK := 1 -.PHONY: test-fabric test-fabric-living fabric-purity fabric-receipt +.PHONY: test-fabric test-fabric-work test-fabric-living fabric-purity fab-work-purity fabric-receipt FAB_DIR = $(OUT_DIR)/fabric -FAB_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -Isrc -Isrc/runtime -Isrc/fabric \ - -DAIEN_TEST_BUILD=1 +FAB_PROD_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -Isrc -Isrc/runtime -Isrc/fabric +FAB_CFLAGS = $(FAB_PROD_CFLAGS) -DAIEN_TEST_BUILD=1 FAB_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all FAB_SRCS = src/fabric/fabric.c src/fabric/fab_hmac.c src/fabric/fab_loopback.c -FAB_LIVING_SRCS = $(FAB_SRCS) src/fabric/fab_dispatch.c +FAB_PROD_SRCS = src/fabric/fab_work.c src/fabric/fab_route.c src/fabric/fab_auth_ed25519.c +FAB_SIG_SRCS = src/searchtrace/sig/ed25519.c src/searchtrace/sig/sha512.c src/searchtrace/sig/ct.c +FAB_LIVING_SRCS = $(FAB_SRCS) src/fabric/fab_dispatch.c src/fabric/fab_route.c FAB_HDRS = src/fabric/fabric.h src/fabric/fab_hmac.h src/fabric/fab_loopback.h src/fabric/fab_dispatch.h \ + src/fabric/fab_work.h src/fabric/fab_route.h src/fabric/fab_auth_ed25519.h \ src/runtime/rx_skillroute.h \ src/runtime/rx_capq.h src/runtime/aien_machine_id.h src/runtime/rx_jspace.h # Routing discovers and carries records; it never grants authority, never @@ -43,10 +57,27 @@ $(FAB_DIR)/%.o: src/fabric/%.c $(FAB_HDRS) @mkdir -p $(FAB_DIR) $(CC) $(FAB_CFLAGS) -c -o $@ $< -fabric-purity: $(FAB_DIR)/fabric.o $(FAB_DIR)/fab_hmac.o $(FAB_DIR)/fab_loopback.o $(FAB_DIR)/fab_dispatch.o +fabric-purity: $(FAB_DIR)/fabric.o $(FAB_DIR)/fab_hmac.o $(FAB_DIR)/fab_loopback.o $(FAB_DIR)/fab_dispatch.o $(FAB_DIR)/fab_route.o @if nm -u $^ | grep -E $(FAB_FORBIDDEN) ; then \ echo "fabric object references an operation the Fabric must not have"; exit 1; fi - @echo "fabric-purity: fabric.o, fab_hmac.o, fab_loopback.o and fab_dispatch.o reference no forbidden symbol" + @echo "fabric-purity: fabric.o, fab_hmac.o, fab_loopback.o, fab_dispatch.o and fab_route.o reference no forbidden symbol" + +# Production objects: compiled WITHOUT AIEN_TEST_BUILD (so a test-only header +# dragged in would refuse), same forbidden list, plus no file/heap/clock call; +# the Ed25519 signer may reference only the vendored aienos_ed25519_* functions. +$(FAB_DIR)/prod/%.o: src/fabric/%.c $(FAB_HDRS) + @mkdir -p $(FAB_DIR)/prod + $(CC) $(FAB_PROD_CFLAGS) -c -o $@ $< + +FAB_WORK_FORBIDDEN = ' U (rx_caproot_|rx_world_|rx_aegis|argus_|ag_cap|socket$$|connect$$|bind$$|listen$$|accept$$|sendto$$|recvfrom$$|fork$$|exec|system$$|dlopen$$|mmap$$|malloc$$|calloc$$|free$$|fopen$$|open$$|read$$|write$$|time$$|clock_gettime$$|getenv$$)' +fab-work-purity: $(FAB_DIR)/prod/fab_work.o $(FAB_DIR)/prod/fab_route.o $(FAB_DIR)/prod/fab_auth_ed25519.o + @if nm -u $^ | grep -E $(FAB_WORK_FORBIDDEN) ; then \ + echo "fab_work/fab_route/fab_auth_ed25519 object references an operation it must not have"; exit 1; fi + @if nm -u $(FAB_DIR)/prod/fab_work.o $(FAB_DIR)/prod/fab_route.o | grep -E ' U aienos_' ; then \ + echo "fab_work.o / fab_route.o must not reference AIENOS authority code"; exit 1; fi + @if nm -u $(FAB_DIR)/prod/fab_auth_ed25519.o | grep -E ' U aienos_' | grep -vE ' U aienos_ed25519_(sign|verify|public_key)$$' ; then \ + echo "fab_auth_ed25519.o may reference only aienos_ed25519_sign/verify/public_key"; exit 1; fi + @echo "fab-work-purity: fab_work.o, fab_route.o and fab_auth_ed25519.o build without AIEN_TEST_BUILD and reference no forbidden symbol" test-fabric: fabric-purity @$(MAKE) --no-print-directory $(RX_CAPQ_OBJ) $(RX_GRAPH_OBJ) $(AIENOS_CAP_LIB) @@ -59,6 +90,21 @@ test-fabric: fabric-purity $(abspath $(FAB_DIR)/fabric_test_asan) > $(FAB_DIR)/asan.out @grep -q '^F5_0_FABRIC_LOOPBACK_PASS$$' $(FAB_DIR)/asan.out && echo "test-fabric: ASan/UBSan run PASS" +# Same link set as test-fabric minus omega_evidence.c (GPU header; nothing in the +# fabric set references it): this is the set a hosted worker compiles too. +FAB_WORK_LINK_SRCS = $(filter-out src/omega_evidence.c,$(FAB_LINK_SRCS)) +FAB_WORK_TEST_SRCS = tests/fabric/fab_work_test.c $(FAB_SRCS) $(FAB_PROD_SRCS) $(FAB_SIG_SRCS) $(FAB_WORK_LINK_SRCS) +test-fabric-work: fab-work-purity fabric-purity + @$(MAKE) --no-print-directory $(RX_CAPQ_OBJ) $(RX_GRAPH_OBJ) $(RX_SKILLROUTE_OBJ) $(AIENOS_CAP_LIB) + $(CC) $(CFLAGS) $(FAB_CFLAGS) -pthread -o $(FAB_DIR)/fab_work_test $(FAB_WORK_TEST_SRCS) \ + $(RX_SKILLROUTE_OBJ) $(RX_CAPQ_OBJ) $(RX_GRAPH_OBJ) $(AIENOS_CAP_LIB) -lm + $(CC) $(CFLAGS) $(FAB_CFLAGS) $(FAB_ASAN) -pthread -o $(FAB_DIR)/fab_work_test_asan $(FAB_WORK_TEST_SRCS) \ + $(RX_SKILLROUTE_OBJ) $(RX_CAPQ_OBJ) $(RX_GRAPH_OBJ) $(AIENOS_CAP_LIB) -lm + $(abspath $(FAB_DIR)/fab_work_test) tests/fabric/vectors/pst + $(abspath $(FAB_DIR)/fab_work_test_asan) tests/fabric/vectors/pst > $(FAB_DIR)/work_asan.out + @grep -q '^FAB_WORK_PASS$$' $(FAB_DIR)/work_asan.out && echo "test-fabric-work: ASan/UBSan run PASS" + tests/fabric/fab_work_procs.sh $(abspath $(FAB_DIR)/fab_work_test) $(abspath $(FAB_DIR)) + test-fabric-living: fabric-purity @$(MAKE) --no-print-directory $(RX_CAPQ_OBJ) $(RX_GRAPH_OBJ) $(RX_SKILLROUTE_OBJ) $(OUT_DIR)/rx_cortex.o $(AIENOS_CAP_LIB) $(CC) $(CFLAGS) $(FAB_CFLAGS) -Itests/runtime -Itests/fabric -pthread -o $(FAB_DIR)/fabric_living_test \ diff --git a/mk/omega-mufu-ftz.mk b/mk/omega-mufu-ftz.mk new file mode 100644 index 000000000..89ff2604b --- /dev/null +++ b/mk/omega-mufu-ftz.mk @@ -0,0 +1,19 @@ +# MUFU flush rule (omega #462): the GB10 MUFU unit (EX2 / RCP / RSQ) flushes a subnormal input or result to a +# sign-preserving zero. tests/bw_mufu_ftz.h is the one host model of it; every warp simulator and SwiGLU host reference +# routes through it. test-mufu-ftz runs the helper unit test, then one MUFU instruction through each simulator's +# ws_lane_exec (bw_warp_sim.h, _k, _pa, _tc). Picked up by `-include mk/*.mk`. Host only: opens no device, needs no +# physics headers, takes no chip lock. The attention test's own per-thread simulator is checked by +# `gpu_attention_test --host-only` (test-gpu-attention). +MUFU_FTZ_SIMS := bw_warp_sim bw_warp_sim_k bw_warp_sim_pa bw_warp_sim_tc +MUFU_FTZ_CFLAGS := -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -ffp-contract=off -Isrc -Itests +.PHONY: test-mufu-ftz +$(OUT_DIR)/test_mufu_ftz_helper: tests/bw_mufu_ftz_test.c tests/bw_mufu_ftz.h + @mkdir -p $(OUT_DIR) + gcc $(MUFU_FTZ_CFLAGS) -o $@ tests/bw_mufu_ftz_test.c -lm +$(OUT_DIR)/test_mufu_ftz_%: tests/bw_mufu_ftz_test.c tests/bw_mufu_ftz.h tests/%.h tests/bw_hmma_model.h tests/bw_qmma_model.h src/omega_blackwell_codegen.h + @mkdir -p $(OUT_DIR) + gcc $(MUFU_FTZ_CFLAGS) -DWS_SIM_HDR='"$*.h"' -o $@ tests/bw_mufu_ftz_test.c -lm +test-mufu-ftz: $(OUT_DIR)/test_mufu_ftz_helper $(addprefix $(OUT_DIR)/test_mufu_ftz_,$(MUFU_FTZ_SIMS)) + ./$(OUT_DIR)/test_mufu_ftz_helper + @for s in $(MUFU_FTZ_SIMS); do ./$(OUT_DIR)/test_mufu_ftz_$$s || exit 1; done + @echo "test-mufu-ftz: PASS (helper + $(words $(MUFU_FTZ_SIMS)) simulators)" diff --git a/spec/.crumb b/spec/.crumb index e63063df8..ee304997c 100644 --- a/spec/.crumb +++ b/spec/.crumb @@ -20,14 +20,14 @@ } ], "children_root": "sha256:6834a3241647d3a098283d4eafedbdb1428dfa4d834f9ed5f22025b6d2303093", - "compiled_at": "2026-10-16T07:53:23Z", + "compiled_at": "2026-10-16T20:22:58Z", "compiler": "crumb-compile/1", - "digest": "sha256:6327473d41e10acbf43be0918d3557509322bfd7d6e075e114c79c2600a47305", + "digest": "sha256:2dd4730b7e14e1b215d011c074e28a3b69a1d9abc96f0208bf21afee4c7d4b1e", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 58, - "generated_at_commit": "4197e0bb49ad1e67d9dac37f259246470ffecedc", - "source_tree": "sha256:2130510e8275fd1ae1fdf6078a82521c7ac2fe0ea6ada8a9d1156f0f2ba191fd" + "generated_at_commit": "209199bb756158699fab4c196cbfb38ffc3549fd", + "source_tree": "sha256:d03dc3ae7798494790fc798d58f1b02d0dc323b826c10acd28e2c61cff4e3e32" }, "owner_lane": "", "provenance": { diff --git a/spec/one-layer-receipts.md b/spec/one-layer-receipts.md index a5653e9fb..27a56d24a 100644 --- a/spec/one-layer-receipts.md +++ b/spec/one-layer-receipts.md @@ -170,6 +170,24 @@ function: valid types and operands; well-formed control flow; every use defined ownership, arena, pool and handle discipline (a may-set analysis that rejects definite errors); every loop reducible and bounded by a guarded counter with a constant limit of at most 10^6. +Known limits of that ownership flow (omega#465). "Accepted" means the program passes the rules +above, not "well-owned". Two shapes are accepted today: + +- An owner leaked on some paths only. `C2-OWN-LEAK` fires at a return only when the owner is live + on every path into it, so a program that releases an owner on one branch and returns on the other + without releasing it is accepted. This is what keeps drop-flag guarded releases (OSC-3 item 3) + from being refused. +- A mutable borrow copied. `MOV` binds a `mut` source to a `mut` destination (`bindable` in + `c2_check.c`) and no rule tracks how many mutable borrows of one owner are live, so two live + writers of one array are accepted. `C2-CALL-ALIAS` refuses only one register passed twice to a + call and written. + +Neither shape breaks memory safety by itself: a leak frees nothing early, and two writers through +copied mutable borrows still go through bounds-checked accesses to an owner that is alive (the two +reproducers in omega#465 were checked with glyph, omega_emit and checker2 on 2026-10-15). Front ends +that want "well-owned" must refuse these shapes themselves until checker2 gains a some-path leak +rule and an exclusive mutable borrow rule; that choice is open in omega#465. + ## 10. Evidence class 2: LRAT proofs Property `no-trap-except-requires` of a function F: for every argument value, a run of F that diff --git a/src/.crumb b/src/.crumb index 4fe5298a4..c41690205 100644 --- a/src/.crumb +++ b/src/.crumb @@ -103,8 +103,8 @@ "purpose": "Directory src/estimation. Purpose not yet described by a human." }, { - "digest": "330c407ff51bfd684e062707c055f58f325f5af16fe9764889aec3a7ffeb31ac", - "last_commit": "3108fc2f", + "digest": "a8ef795e9fd9a70eb3d06ab2a6619c7064a395fce80e4b5a6d402d9117acf1f0", + "last_commit": "0e7bcb60", "name": "fabric", "purpose": "Directory src/fabric. Purpose not yet described by a human." }, @@ -175,21 +175,21 @@ "purpose": "Directory src/turing. Purpose not yet described by a human." }, { - "digest": "daf5e5e90c1ccb4c089220a6545844dbe4078a233f1777e8145b74f1bf5dd5fe", - "last_commit": "40d1ea37", + "digest": "11575b0cfcbad20d6128d1b5c18a4bd691877ad970fba9f03b0df5665e3fb75f", + "last_commit": "31e40e29", "name": "visor", "purpose": "Directory src/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9", - "compiled_at": "2026-10-16T07:33:43Z", + "children_root": "sha256:2bc50191b565f16ea8d616313728f165b0c90455bf7573b7d87107fe8c9d53ee", + "compiled_at": "2026-10-20T20:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:dfa36de2ac8649f66f80587abea51a7f166285ee0b92e0e09774c98689055250", + "digest": "sha256:c53df5dd6e20fd9d6106288146c04ffe1690ac17c031027fc31f429fa565fb4c", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 537, - "generated_at_commit": "1d481ab853a14d3c11eff926ce1e25993085f76a", - "source_tree": "sha256:200c9243151691313acb5f86d3e9cb3058f1a1b92ece2a255b3340b691dfb894" + "files": 548, + "generated_at_commit": "738552e3f036b757e740f1dbfa1c4e7de069f63c", + "source_tree": "sha256:56fd240342334c63dd180c4db16db1511e6b7e0748073eeeb2bf799115ce73a8" }, "owner_lane": "", "provenance": { diff --git a/src/fabric/.crumb b/src/fabric/.crumb index 43cb951ff..d9ccb007b 100644 --- a/src/fabric/.crumb +++ b/src/fabric/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T13:47:05Z", + "compiled_at": "2026-10-18T09:08:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:330c407ff51bfd684e062707c055f58f325f5af16fe9764889aec3a7ffeb31ac", + "digest": "sha256:a8ef795e9fd9a70eb3d06ab2a6619c7064a395fce80e4b5a6d402d9117acf1f0", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 8, - "generated_at_commit": "834ee93e4314a42c1127a2fcda8b29cf3b511245", - "source_tree": "sha256:70af8e151260272941d4e69988659ee0b5017d270b3b8c13a9a6ec974522d02b" + "files": 15, + "generated_at_commit": "eaacacd62040249f5633daf9fa6674e7f2f9d027", + "source_tree": "sha256:ece762657b3c1791ff25a582a0ff334d5cf4932cc5d2062620535f9f8bac0364" }, "owner_lane": "", "provenance": { diff --git a/src/fabric/README.md b/src/fabric/README.md new file mode 100644 index 000000000..8deba5ecb --- /dev/null +++ b/src/fabric/README.md @@ -0,0 +1,74 @@ +# Omega Fabric (`src/fabric/`) + +The Fabric is how separate AIEN machines agree on who is a member, what each one +offers, and how work is handed from one machine to another. Everything here is +plain C with no dynamic allocation, no clocks and no files, so the same code can +run on a coordinator, inside a hosted worker, and later inside AIENOS. + +## What is in this folder + +| File | Role | Builds into production? | +| --- | --- | --- | +| `fabric.h` / `fabric.c` | F5-0 membership: signed JOIN / RENEW / ADVERTISE / LEAVE, leases, generations, replay refusal | yes | +| `fab_auth_ed25519.h` / `.c` | Ed25519 identity for the Fabric: a machine is its public key, and its machine id is derived from that key | yes | +| `fab_route.h` / `.c` | The check a coordinator runs before sending work: pump the Fabric, revalidate the Skill route, require a live remote owner | yes | +| `fab_work.h` / `.c` | Work hand-off: the PST1 message reader and writer, the HTK1 task and HTR1 receipt codecs, the requester state machine and the executor's durable journal | yes | +| `fab_hmac.h` / `.c` | HMAC stand-in authenticator | test only | +| `fab_loopback.h` / `.c` | In-process loopback transport | test only | +| `fab_dispatch.h` / `.c` | Simulated-machine dispatcher (steps 1-3 are `fab_route.c`; only the procedure table lives here) | test only | + +"Test only" files carry an `aien_test_build_*` marker and are refused from any +production binary by `tools/r16_prod_hygiene.sh`. + +## Work hand-off (heterogeneous compute, aienix#6 and omega#536) + +A **requester** sends a PST1 `request` carrying an HTK1 task. An **executor** +answers with `accepted`, `running` and then exactly one terminal message: +`completed` (with the result digest and an HTR1 receipt), `failed` (with a +reason code) or `cancelled`. Every answer is checked against the task id, the +idempotence key and a rising ordinal; anything out of order, from the wrong side, +or for an unknown task is refused and counted. + +Two task kinds are allowlisted today, both with exact recomputable answers: + +- **matmul_i64_seeded**: an N by N integer matrix product on inputs generated from + a seed by splitmix64. The result is the SHA-256 of the big-endian product. +- **tokenize_fixture**: run a pinned tokenizer over a slice of a pinned fixture + (codec and bounds only in this step; the executor does not run it yet). + +The executor journals a task's terminal before it sends it. The same task bytes +asked again replay the journaled answer without re-running; different bytes under +the same key are refused with code 7. A requester that loses the session marks +the task UNCERTAIN and leaves that state only through a signed `resume_snapshot`. + +Nothing in this folder opens a socket. Transports are supplied by the caller +(`FabTransport`), so the loopback test, the two-process pipe test and a real +network adapter all exercise the same code. Loopback and pipes are not a network +and are never reported as one. + +## Tests + +``` +make test-fabric # F5-0 membership, loopback +make test-fabric-work # PST1 vectors, HTK1/HTR1 goldens, matmul oracle, state machines, + # Ed25519 membership, then the same binary under AddressSanitizer, + # then requester and executor as two OS processes over pipes +make test-fabric-living # living-system phase gates +make fabric-purity fab-work-purity # no forbidden symbols in the production objects +``` + +`test-fabric-work` needs the pinned AIENOS capability library; point +`AIENOS_LOCK_REPO` at a checkout holding the locked commit if the default +sibling path is absent. The PST1 vectors in `tests/fabric/vectors/pst/` come from +the protocols repository and are checked byte for byte against `expected.txt`. + +The matmul oracle digests (seed, size, SHA-256 of the product) are recorded in +`tests/fabric/fab_work_test.c` so an independent implementation can reproduce +them. + +## Limits + +This folder proves codec, state machine and journal behaviour in one process and +across a process boundary. It does not by itself prove a second physical machine +ran anything: that evidence comes from the hosted worker adapter and the +three-machine qualification in the benchmarks repository. diff --git a/src/fabric/fab_auth_ed25519.c b/src/fabric/fab_auth_ed25519.c new file mode 100644 index 000000000..282d607ff --- /dev/null +++ b/src/fabric/fab_auth_ed25519.c @@ -0,0 +1,74 @@ +/* fab_auth_ed25519.c -- Ed25519 FabAuth over the vendored AIENOS signing code. */ +#include "fab_auth_ed25519.h" +#include "searchtrace/sig/aienos_sig.h" + +#include + +int fab_ed_machine_id(const uint8_t pk[32], AienMachineId *out) { + if (!pk || !out) return FAB_E_ARG; + return aien_mid_derive(AIEN_MID_ROOT_PROVISIONED, pk, 32, out) == AIEN_MID_OK ? FAB_OK : FAB_E_ARG; +} + +const uint8_t *fab_ed_auth_pk_of(const FabEdAuth *a, const AienMachineId *id) { + if (!a || !id) return NULL; + if (aien_mid_equal(&a->self, id)) return a->pk; + for (uint32_t i = 0; i < a->n; i++) + if (aien_mid_equal(&a->peer[i].id, id)) return a->peer[i].pk; + return NULL; +} + +static int ed_sign(void *ctx, const uint8_t *msg, size_t len, uint8_t sig[FAB_SIG_BYTES]) { + const FabEdAuth *a = ctx; + if (!a || !sig || (!msg && len)) return FAB_E_ARG; + return aienos_ed25519_sign(sig, msg, len, a->sk) == AIENOS_SIG_OK ? FAB_OK : FAB_E_AUTH; +} + +static int ed_verify(void *ctx, const AienMachineId *claimed, const uint8_t *msg, size_t len, + const uint8_t sig[FAB_SIG_BYTES]) { + const FabEdAuth *a = ctx; + if (!a || !claimed || !sig || (!msg && len)) return FAB_E_ARG; + const uint8_t *pk = fab_ed_auth_pk_of(a, claimed); + if (!pk) return FAB_E_AUTH; /* not enrolled here: never a silent accept */ + return aienos_ed25519_verify(sig, msg, len, pk) == AIENOS_SIG_OK ? FAB_OK : FAB_E_AUTH; +} + +int fab_ed_auth_init(FabEdAuth *a, const uint8_t sk[32]) { + if (!a || !sk) return FAB_E_ARG; + memset(a, 0, sizeof *a); + memcpy(a->sk, sk, 32); + if (aienos_ed25519_public_key(a->pk, a->sk) != AIENOS_SIG_OK || + fab_ed_machine_id(a->pk, &a->self) != FAB_OK) { + fab_ed_auth_wipe(a); + return FAB_E_ARG; + } + a->auth.ctx = a; + a->auth.sign = ed_sign; + a->auth.verify = ed_verify; + return FAB_OK; +} + +int fab_ed_auth_add_peer(FabEdAuth *a, const uint8_t pk[32]) { + if (!a || !pk) return FAB_E_ARG; + if (a->n >= FAB_ED_MAX_PEERS) return FAB_E_FULL; + FabEdPeer p; + memcpy(p.pk, pk, 32); + if (fab_ed_machine_id(p.pk, &p.id) != FAB_OK) return FAB_E_ARG; + if (fab_ed_auth_pk_of(a, &p.id)) return FAB_E_ARG; /* duplicate, or our own key */ + a->peer[a->n++] = p; + return FAB_OK; +} + +int fab_ed_auth_roster(const FabEdAuth *a, AienMachineId *ids, uint32_t cap, uint32_t *n) { + if (!a || !ids || !n) return FAB_E_ARG; + if (cap < a->n + 1u) return FAB_E_FULL; + ids[0] = a->self; + for (uint32_t i = 0; i < a->n; i++) ids[i + 1] = a->peer[i].id; + *n = a->n + 1u; + return FAB_OK; +} + +void fab_ed_auth_wipe(FabEdAuth *a) { + if (!a) return; + volatile uint8_t *p = (volatile uint8_t *)a; + for (size_t i = 0; i < sizeof *a; i++) p[i] = 0; +} diff --git a/src/fabric/fab_auth_ed25519.h b/src/fabric/fab_auth_ed25519.h new file mode 100644 index 000000000..5dd6dd3dd --- /dev/null +++ b/src/fabric/fab_auth_ed25519.h @@ -0,0 +1,68 @@ +/* + * fab_auth_ed25519.h -- the Fabric signer for real machines (aienix#6, omega#536). + * + * FabAuth (fabric.h) is an interface: fabric.c signs every message it seals and + * verifies every message it receives through it, naming the claimed sender by + * its AienMachineId. F5-0 ships only an HMAC stand-in (fab_hmac.h, test build). + * This file is the production signer: Ed25519 over the exact AFAB bytes, with + * the signing code the repository already vendors from AIENOS + * (src/searchtrace/sig/, aienos native/sig @913b962; see PROVENANCE.txt there). + * No new cryptography is written here. + * + * Identity: one 32-byte Ed25519 seed per machine (RFC 8032 secret key). The + * machine's canonical identity is derived from its public key, + * AienMachineId = aien_mid_derive(AIEN_MID_ROOT_PROVISIONED, pk, 32), + * so a roster entry is the public key alone; the id is never typed by hand. + * Class: lab-provisioned. This is not TRUST-1 owner enrolment (AIEN_MID_ROOT_ + * HARDWARE); a receipt made under such a key must say identity_class=lab. + * + * verify(claimed, msg, sig): the claimed id must be this node's own id or one + * of the enrolled peers; its public key verifies the signature. Anything else + * is a refusal (nonzero). fabric.c has already checked the roster before it + * asks, so an unknown id here is FAB_E_AUTH, never a silent accept. + * + * The seed stays in this struct only; fab_ed_auth_wipe zeroes it. Nothing here + * reads a file, opens a socket or prints: the caller loads the seed bytes. + */ +#ifndef FAB_AUTH_ED25519_H +#define FAB_AUTH_ED25519_H + +#include "fabric.h" + +#define FAB_ED_MAX_PEERS 64u + +typedef struct { + AienMachineId id; + uint8_t pk[32]; +} FabEdPeer; + +typedef struct { + uint8_t sk[32]; /* this machine's seed; wiped by fab_ed_auth_wipe */ + uint8_t pk[32]; + AienMachineId self; + uint32_t n; + FabEdPeer peer[FAB_ED_MAX_PEERS]; + FabAuth auth; /* points back at this signer */ +} FabEdAuth; + +/* The canonical machine id of a public key. FAB_E_ARG on a null pointer. */ +int fab_ed_machine_id(const uint8_t pk[32], AienMachineId *out); + +/* Loads the seed, derives pk and self. The peer list starts empty. */ +int fab_ed_auth_init(FabEdAuth *a, const uint8_t sk[32]); + +/* Enrols a peer by public key (its id is derived). FAB_E_FULL when the list + * is full, FAB_E_ARG for a duplicate or for this machine's own key. */ +int fab_ed_auth_add_peer(FabEdAuth *a, const uint8_t pk[32]); + +/* Writes self + every peer into ids (the FabRoster a node is configured with). + * FAB_E_FULL when cap is too small; *n is the count written. */ +int fab_ed_auth_roster(const FabEdAuth *a, AienMachineId *ids, uint32_t cap, uint32_t *n); + +/* The public key enrolled for `id`, or NULL. */ +const uint8_t *fab_ed_auth_pk_of(const FabEdAuth *a, const AienMachineId *id); + +/* Zeroes the seed and the struct. */ +void fab_ed_auth_wipe(FabEdAuth *a); + +#endif /* FAB_AUTH_ED25519_H */ diff --git a/src/fabric/fab_dispatch.c b/src/fabric/fab_dispatch.c index b84e6c55a..0b95d2a02 100644 --- a/src/fabric/fab_dispatch.c +++ b/src/fabric/fab_dispatch.c @@ -1,5 +1,9 @@ -/* fab_dispatch.c -- Fabric dispatch of remote composition candidates (fab_dispatch.h). */ +/* fab_dispatch.c -- Fabric dispatch of remote composition candidates (fab_dispatch.h). + * Steps 1-3 (pump, route revalidation, live remote member) are fab_route.c, the + * production-buildable check a real coordinator runs before it sends; only + * step 4 (the simulated procedure table) lives here. */ #include "fab_dispatch.h" +#include "fab_route.h" #include @@ -41,18 +45,7 @@ int fab_dispatch_add(FabDispatch *d, const AienMachineId *m, const AgSkillTable /* Caller holds the lock. */ static int pump_locked(FabDispatch *d, uint64_t now_us) { - int n = 0; - FabVerdict v; - for (;;) { - int rc = fab_poll(d->node, now_us, &v); - if (rc < 0) return rc; - if (rc == 0) break; - n++; - d->polled++; - if (v.code != FAB_OK) d->refused_msgs++; - } - (void)fab_tick(d->node, now_us); - return n; + return fab_route_pump(d->node, now_us, &d->polled, &d->refused_msgs); } int fab_dispatch_pump(FabDispatch *d, uint64_t now_us) { @@ -75,22 +68,21 @@ int fab_dispatch_run(void *ctx, const SrRouter *router, const SrRoute *route, ui if (!d || !d->node) return FAB_DX_ARG; pthread_mutex_lock(&d->mu); int rc; - if (!router || !route || !result || router->graph != d->node->cfg.catalog) { - rc = refuse(d, FAB_DX_ARG); - goto out; - } - if (pump_locked(d, now_us) < 0) { rc = refuse(d, FAB_DX_TRANSPORT); goto out; } - if (sr_route_check(router, route, now_us) != SR_E_REMOTE) { rc = refuse(d, FAB_DX_ROUTE); goto out; } - if (!route->target_known) { rc = refuse(d, FAB_DX_TARGET); goto out; } - JsHome home; - if (fab_home(d->node, &route->target, now_us, &home) != FAB_OK || - home.locality != JS_HOME_REMOTE_OWNED) { - rc = refuse(d, FAB_DX_NOT_MEMBER); - goto out; + if (!result) { rc = refuse(d, FAB_DX_ARG); goto out; } + /* Steps 1-3: fab_route.c (shared with the production coordinator). */ + AienMachineId target; + switch (fab_route_check(d->node, router, route, now_us, &target, &d->polled, &d->refused_msgs)) { + case FAB_RT_OK: break; + case FAB_RT_ARG: rc = refuse(d, FAB_DX_ARG); goto out; + case FAB_RT_TRANSPORT: rc = refuse(d, FAB_DX_TRANSPORT); goto out; + case FAB_RT_ROUTE: rc = refuse(d, FAB_DX_ROUTE); goto out; + case FAB_RT_TARGET: rc = refuse(d, FAB_DX_TARGET); goto out; + default: rc = refuse(d, FAB_DX_NOT_MEMBER); goto out; } + /* Step 4 (loopback stand-in only): the simulated machine's procedure table. */ const FabExecutor *ex = NULL; for (uint32_t i = 0; i < d->n_exec && !ex; i++) - if (aien_mid_equal(&d->exec[i].machine, &route->target)) ex = &d->exec[i]; + if (aien_mid_equal(&d->exec[i].machine, &target)) ex = &d->exec[i]; const AgSkill *s = NULL; for (uint32_t i = 0; ex && i < ex->skills->n && !s; i++) if (ex->skills->skill[i].id == route->chosen.skill_id) s = &ex->skills->skill[i]; diff --git a/src/fabric/fab_route.c b/src/fabric/fab_route.c new file mode 100644 index 000000000..50cd6e411 --- /dev/null +++ b/src/fabric/fab_route.c @@ -0,0 +1,43 @@ +/* fab_route.c -- pre-dispatch route checks (fab_route.h). */ +#include "fab_route.h" + +int fab_route_pump(FabNode *n, uint64_t now_us, uint64_t *polled, uint64_t *refused_msgs) { + if (!n) return FAB_E_ARG; + int applied = 0; + FabVerdict v; + for (;;) { + int rc = fab_poll(n, now_us, &v); + if (rc < 0) return rc; + if (rc == 0) break; + applied++; + if (polled) (*polled)++; + if (v.code != FAB_OK && refused_msgs) (*refused_msgs)++; + } + (void)fab_tick(n, now_us); + return applied; +} + +int fab_route_check(FabNode *n, const SrRouter *router, const SrRoute *route, uint64_t now_us, + AienMachineId *target, uint64_t *polled, uint64_t *refused_msgs) { + if (!n || !router || !route || !target || router->graph != n->cfg.catalog) return FAB_RT_ARG; + if (fab_route_pump(n, now_us, polled, refused_msgs) < 0) return FAB_RT_TRANSPORT; + if (sr_route_check(router, route, now_us) != SR_E_REMOTE) return FAB_RT_ROUTE; + if (!route->target_known) return FAB_RT_TARGET; + JsHome home; + if (fab_home(n, &route->target, now_us, &home) != FAB_OK || home.locality != JS_HOME_REMOTE_OWNED) + return FAB_RT_NOT_MEMBER; + *target = route->target; + return FAB_RT_OK; +} + +const char *fab_route_strerror(int code) { + switch (code) { + case FAB_RT_OK: return "ok"; + case FAB_RT_ARG: return "bad call or foreign graph"; + case FAB_RT_TRANSPORT: return "fabric transport error while pumping"; + case FAB_RT_ROUTE: return "route no longer remote (withdrawn, stale or lease ended)"; + case FAB_RT_TARGET: return "route has no canonical target machine"; + case FAB_RT_NOT_MEMBER: return "target is not a live remote member"; + default: return "unknown fab_route code"; + } +} diff --git a/src/fabric/fab_route.h b/src/fabric/fab_route.h new file mode 100644 index 000000000..151268c8d --- /dev/null +++ b/src/fabric/fab_route.h @@ -0,0 +1,50 @@ +/* + * fab_route.h -- the checks a Fabric node makes before it sends work to a + * remote machine (aienix#6, omega#536). Production-buildable. + * + * These are steps 1 to 3 of fab_dispatch.h, lifted out of the test-only + * in-process dispatcher so a real coordinator can run them before it hands a + * task to the transport. Step 4 of the dispatcher (the simulated procedure + * table) is NOT here and is never promoted: whether the remote machine ran + * what it advertised is answered by the executor's receipt (fab_work.h HTR1, + * implementation_digest against the advertised skill_digest), not by this + * process. + * + * 1. fab_route_pump: apply waiting Fabric traffic and the clock, so a LEAVE + * or an ended lease withdraws the machine's entries first; + * 2. the route must still be SR_E_REMOTE under sr_route_check (entry live, + * same generation, version and digest, machine identity unchanged); + * 3. the route's machine must be a live member of this node whose home is + * JS_HOME_REMOTE_OWNED: never the local machine, never a lost one. + * Any failure refuses and names why. The caller holds whatever lock protects + * the node; this file takes none (fab_dispatch.c keeps its own). + */ +#ifndef FAB_ROUTE_H +#define FAB_ROUTE_H + +#include "fabric.h" +#include "runtime/rx_skillroute.h" + +enum { + FAB_RT_OK = 0, + FAB_RT_ARG, /* bad call, or the router's graph is not this node's catalog */ + FAB_RT_TRANSPORT, /* applying waiting Fabric traffic failed */ + FAB_RT_ROUTE, /* sr_route_check is no longer SR_E_REMOTE */ + FAB_RT_TARGET, /* route has no canonical target machine */ + FAB_RT_NOT_MEMBER, /* target is not a live remote member of this node */ + FAB_RT_N +}; + +/* Step 1. Applies every waiting message, then the clock. Returns the number of + * messages applied, or <0 (a FAB_E_* transport code). polled / refused_msgs, + * when given, are increased by the messages seen / refused. */ +int fab_route_pump(FabNode *n, uint64_t now_us, uint64_t *polled, uint64_t *refused_msgs); + +/* Steps 1 to 3. FAB_RT_OK with *target = the live remote machine to send to, + * else the FAB_RT_* refusal (target untouched). */ +int fab_route_check(FabNode *n, const SrRouter *router, const SrRoute *route, uint64_t now_us, + AienMachineId *target, uint64_t *polled, uint64_t *refused_msgs); + +const char *fab_route_strerror(int code); + +#endif /* FAB_ROUTE_H */ diff --git a/src/fabric/fab_work.c b/src/fabric/fab_work.c new file mode 100644 index 000000000..ca47fbecb --- /dev/null +++ b/src/fabric/fab_work.c @@ -0,0 +1,696 @@ +/* fab_work.c -- PST1 / HTK1 / HTR1 codec, requester state machine, executor journal (fab_work.h). */ +#include "fab_work.h" +#include "sha256.h" + +#include +#include + +/* ---- byte helpers (big-endian on the wire) ---- */ +static uint16_t g16(const uint8_t *p) { return (uint16_t)((p[0] << 8) | p[1]); } +static uint32_t g32(const uint8_t *p) { return ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) | ((uint32_t)p[2] << 8) | p[3]; } +static uint64_t g64(const uint8_t *p) { return ((uint64_t)g32(p) << 32) | g32(p + 4); } +static void p16(uint8_t *p, uint16_t v) { p[0] = (uint8_t)(v >> 8); p[1] = (uint8_t)v; } +static void p32(uint8_t *p, uint32_t v) { p[0] = (uint8_t)(v >> 24); p[1] = (uint8_t)(v >> 16); p[2] = (uint8_t)(v >> 8); p[3] = (uint8_t)v; } +static void p64(uint8_t *p, uint64_t v) { p32(p, (uint32_t)(v >> 32)); p32(p + 4, (uint32_t)v); } +static int all_zero(const uint8_t *p, size_t n) { uint8_t a = 0; for (size_t i = 0; i < n; i++) a |= p[i]; return a == 0; } + +/* ================= PST1 ================= */ +enum { + O_MAGIC = 0, O_VERSION = 4, O_TYPE = 5, O_RES0 = 6, O_CAUSE = 8, O_ORIGIN = 40, + O_OBJECTIVE = 72, O_SUBJECT = 104, O_PARENT = 136, O_TASK = 152, O_IDEM = 168, + O_ORDINAL = 184, O_EFFECT = 188, O_RES1 = 189, O_PLEN = 190, O_DIGEST = 192 +}; + +static const char *const pst_names[PST_CODE_COUNT] = { + "OK", "PST_BAD_MAGIC", "PST_BAD_VERSION", "PST_DOWNGRADE", "PST_BAD_TYPE", + "PST_WRONG_SIDE", "PST_BAD_LENGTH", "PST_TRAILING_BYTES", "PST_RESERVED_NONZERO", + "PST_NO_CAUSE", "PST_NO_TASK", "PST_NO_OBJECTIVE", "PST_DIGEST_MISMATCH", + "PST_BAD_EFFECT_CLASS", "PST_SUBJECT_MISMATCH" +}; + +const char *pst_code_name(int code) { + return code >= 0 && code < PST_CODE_COUNT ? pst_names[code] : "PST_UNKNOWN_CODE"; +} + +/* Field rules shared by decode (on the wire bytes) and encode (on the struct): + * steps 3, 4, 8, 9, 10 and 11 of SPEC.md section 4.1. */ +static int pst_field_rules(uint8_t version, uint8_t type, uint8_t effect, const uint8_t *cause, + const uint8_t *task, const uint8_t *idem, const uint8_t *objective) { + if (version < PST_VERSION) return PST_DOWNGRADE; + if (version > PST_VERSION) return PST_BAD_VERSION; + if (type == 0 || type > PST_MAX_TYPE) return PST_BAD_TYPE; + if (effect > PST_EFFECT_EFFECT) return PST_BAD_EFFECT_CLASS; + if (all_zero(cause, 32)) return PST_NO_CAUSE; + if (all_zero(task, 16)) return PST_NO_TASK; + if (all_zero(idem, 16)) return PST_NO_TASK; + if (type == PST_T_REQUEST && all_zero(objective, 32)) return PST_NO_OBJECTIVE; + return PST_OK; +} + +int pst_decode(const uint8_t *b, size_t n, PstMsg *m) { + if (!b || !m) return PST_BAD_LENGTH; + memset(m, 0, sizeof *m); + /* 1. length bounds */ + if (n < PST_HDR) return PST_BAD_LENGTH; + if (n > PST_MAX_MSG) return PST_BAD_LENGTH; + /* 2. magic */ + if (memcmp(b + O_MAGIC, "PST1", 4) != 0) return PST_BAD_MAGIC; + /* 3. version 4. type (field rules continue below after the length checks, as the checker orders them) */ + if (b[O_VERSION] < PST_VERSION) return PST_DOWNGRADE; + if (b[O_VERSION] > PST_VERSION) return PST_BAD_VERSION; + if (b[O_TYPE] == 0 || b[O_TYPE] > PST_MAX_TYPE) return PST_BAD_TYPE; + /* 5. reserved */ + if (!all_zero(b + O_RES0, 2)) return PST_RESERVED_NONZERO; + if (b[O_RES1] != 0) return PST_RESERVED_NONZERO; + /* 6, 7. payload length against the bytes present */ + m->payload_len = g16(b + O_PLEN); + size_t body = n - PST_HDR; + if (body < m->payload_len) return PST_BAD_LENGTH; + if (body > m->payload_len) return PST_TRAILING_BYTES; + /* 8..11. field rules */ + int rc = pst_field_rules(b[O_VERSION], b[O_TYPE], b[O_EFFECT], b + O_CAUSE, b + O_TASK, b + O_IDEM, b + O_OBJECTIVE); + if (rc != PST_OK) return rc; + /* 12. payload digest */ + uint8_t d[32]; + sha256_hash(b + PST_HDR, m->payload_len, d); + if (memcmp(d, b + O_DIGEST, 32) != 0) return PST_DIGEST_MISMATCH; + + m->version = b[O_VERSION]; + m->type = b[O_TYPE]; + memcpy(m->cause, b + O_CAUSE, 32); + memcpy(m->origin, b + O_ORIGIN, 32); + memcpy(m->objective, b + O_OBJECTIVE, 32); + memcpy(m->subject, b + O_SUBJECT, 32); + memcpy(m->parent, b + O_PARENT, 16); + memcpy(m->task, b + O_TASK, 16); + memcpy(m->idem, b + O_IDEM, 16); + m->ordinal = g32(b + O_ORDINAL); + m->effect = b[O_EFFECT]; + memcpy(m->digest, d, 32); + m->payload = b + PST_HDR; + return PST_OK; +} + +int pst_encode(const PstMsg *m, const uint8_t *payload, size_t payload_len, + uint8_t *out, size_t cap, size_t *out_len) { + if (!m || !out || !out_len || (!payload && payload_len)) return PST_BAD_LENGTH; + if (payload_len > PST_MAX_PAY || cap < PST_HDR + payload_len) return PST_BAD_LENGTH; + int rc = pst_field_rules(m->version, m->type, m->effect, m->cause, m->task, m->idem, m->objective); + if (rc != PST_OK) return rc; + memset(out, 0, PST_HDR); + memcpy(out + O_MAGIC, "PST1", 4); + out[O_VERSION] = m->version; + out[O_TYPE] = m->type; + memcpy(out + O_CAUSE, m->cause, 32); + memcpy(out + O_ORIGIN, m->origin, 32); + memcpy(out + O_OBJECTIVE, m->objective, 32); + memcpy(out + O_SUBJECT, m->subject, 32); + memcpy(out + O_PARENT, m->parent, 16); + memcpy(out + O_TASK, m->task, 16); + memcpy(out + O_IDEM, m->idem, 16); + p32(out + O_ORDINAL, m->ordinal); + out[O_EFFECT] = m->effect; + p16(out + O_PLEN, (uint16_t)payload_len); + sha256_hash(payload ? payload : out, payload_len, out + O_DIGEST); /* out: any pointer for len 0 */ + if (payload_len) memcpy(out + PST_HDR, payload, payload_len); + *out_len = PST_HDR + payload_len; + return PST_OK; +} + +int pst_side_of(uint8_t type) { + if (type == 0 || type > PST_MAX_TYPE) return 0; + return (type == PST_T_REQUEST || type == PST_T_CANCEL_REQUEST || type == PST_T_RESUME_REQUEST) + ? PST_ROLE_REQUESTER : PST_ROLE_EXECUTOR; +} + +int pst_side_check(uint8_t type, int sender_role) { + int s = pst_side_of(type); + return s && s == sender_role ? PST_OK : PST_WRONG_SIDE; +} + +static char *hexw(char *o, const uint8_t *p, size_t n) { + static const char hx[] = "0123456789abcdef"; + for (size_t i = 0; i < n; i++) { *o++ = hx[p[i] >> 4]; *o++ = hx[p[i] & 15]; } + *o = 0; + return o; +} + +void pst_verdict_line(int code, const PstMsg *m, char *buf, size_t cap) { + char c[65], o[65], ob[65], s[65], pa[33], t[33], k[33], d[65]; + if (!buf || !cap) return; + if (code != PST_OK || !m) { + snprintf(buf, cap, "refuse %s", pst_code_name(code)); + return; + } + hexw(c, m->cause, 32); hexw(o, m->origin, 32); hexw(ob, m->objective, 32); hexw(s, m->subject, 32); + hexw(pa, m->parent, 16); hexw(t, m->task, 16); hexw(k, m->idem, 16); hexw(d, m->digest, 32); + snprintf(buf, cap, "ok type=%u version=%u cause=%s origin=%s objective=%s subject=%s parent=%s task=%s idem=%s ordinal=%lu effect=%u len=%u digest=%s", + m->type, m->version, c, o, ob, s, pa, t, k, (unsigned long)m->ordinal, m->effect, m->payload_len, d); +} + +/* ================= HTK1 ================= */ +static const char *const htk_names[HTK_CODE_COUNT] = { + "HTK_OK", "HTK_BAD_MAGIC", "HTK_BAD_VERSION", "HTK_BAD_KIND", "HTK_RESERVED_NONZERO", + "HTK_BAD_LENGTH", "HTK_BAD_BOUNDS", "HTK_INPUT_DIGEST_MISMATCH" +}; +const char *htk_code_name(int code) { return code >= 0 && code < HTK_CODE_COUNT ? htk_names[code] : "HTK_UNKNOWN_CODE"; } + +static size_t htk_param_len(uint8_t kind) { + if (kind == HTK_KIND_MATMUL_I64_SEEDED) return 12; + if (kind == HTK_KIND_TOKENIZE_FIXTURE) return 72; + return 0; +} + +size_t htk_input_bytes(const HtkTask *t, uint8_t out[HTK_INPUT_MAX]) { + if (!t || !out) return 0; + if (t->kind == HTK_KIND_MATMUL_I64_SEEDED) { + memcpy(out, "HTK1-MATMUL", 11); + p32(out + 11, t->matmul.n); + p64(out + 15, t->matmul.seed); + return 23; + } + if (t->kind == HTK_KIND_TOKENIZE_FIXTURE) { + memcpy(out, t->tok.fixture_digest, 32); + p32(out + 32, t->tok.offset); + p32(out + 36, t->tok.length); + memcpy(out + 40, t->tok.tokenizer_digest, 32); + return 72; + } + return 0; +} + +void htk_input_digest(const HtkTask *t, uint8_t out[32]) { + uint8_t in[HTK_INPUT_MAX]; + size_t n = htk_input_bytes(t, in); + sha256_hash(in, n, out); +} + +uint64_t htk_result_bytes(const HtkTask *t) { + if (t && t->kind == HTK_KIND_MATMUL_I64_SEEDED) return (uint64_t)t->matmul.n * t->matmul.n * 8u; + return 0; +} + +static int htk_bounds(const HtkTask *t) { + if (t->deadline_ms == 0 || t->deadline_ms > HTK_DEADLINE_MS_MAX) return HTK_BAD_BOUNDS; + if (t->max_out_bytes == 0 || t->max_out_bytes > HTK_OUT_BYTES_MAX) return HTK_BAD_BOUNDS; + if (t->kind == HTK_KIND_MATMUL_I64_SEEDED) { + if (t->matmul.n == 0 || t->matmul.n > HTK_MATMUL_N_MAX) return HTK_BAD_BOUNDS; + } else if (t->kind == HTK_KIND_TOKENIZE_FIXTURE) { + if (t->tok.length == 0 || t->tok.length > HTK_TOKENIZE_LEN_MAX) return HTK_BAD_BOUNDS; + if ((uint64_t)t->tok.offset + t->tok.length > UINT32_MAX) return HTK_BAD_BOUNDS; + } else { + return HTK_BAD_KIND; + } + return HTK_OK; +} + +int htk_encode(const HtkTask *t, uint8_t *out, size_t cap, size_t *len) { + if (!t || !out || !len) return HTK_BAD_LENGTH; + size_t pl = htk_param_len(t->kind); + if (!pl) return HTK_BAD_KIND; + if (cap < HTK_HDR + pl) return HTK_BAD_LENGTH; + int rc = htk_bounds(t); + if (rc != HTK_OK) return rc; + memset(out, 0, HTK_HDR + pl); + memcpy(out, "HTK1", 4); + out[4] = 1; + out[5] = t->kind; + p32(out + 8, t->deadline_ms); + p32(out + 12, t->max_out_bytes); + p64(out + 16, t->max_mem_bytes); + p32(out + 24, t->max_in_bytes); + p32(out + 28, t->threads); + htk_input_digest(t, out + 32); + if (t->kind == HTK_KIND_MATMUL_I64_SEEDED) { + p32(out + 64, t->matmul.n); + p64(out + 68, t->matmul.seed); + } else { + memcpy(out + 64, t->tok.fixture_digest, 32); + p32(out + 96, t->tok.offset); + p32(out + 100, t->tok.length); + memcpy(out + 104, t->tok.tokenizer_digest, 32); + } + *len = HTK_HDR + pl; + return HTK_OK; +} + +int htk_decode(const uint8_t *b, size_t n, HtkTask *t) { + if (!b || !t) return HTK_BAD_LENGTH; + memset(t, 0, sizeof *t); + if (n < HTK_HDR) return HTK_BAD_LENGTH; + if (memcmp(b, "HTK1", 4) != 0) return HTK_BAD_MAGIC; + if (b[4] != 1) return HTK_BAD_VERSION; + size_t pl = htk_param_len(b[5]); + if (!pl) return HTK_BAD_KIND; + if (!all_zero(b + 6, 2)) return HTK_RESERVED_NONZERO; + if (n != HTK_HDR + pl) return HTK_BAD_LENGTH; + t->kind = b[5]; + t->deadline_ms = g32(b + 8); + t->max_out_bytes = g32(b + 12); + t->max_mem_bytes = g64(b + 16); + t->max_in_bytes = g32(b + 24); + t->threads = g32(b + 28); + memcpy(t->input_digest, b + 32, 32); + if (t->kind == HTK_KIND_MATMUL_I64_SEEDED) { + t->matmul.n = g32(b + 64); + t->matmul.seed = g64(b + 68); + } else { + memcpy(t->tok.fixture_digest, b + 64, 32); + t->tok.offset = g32(b + 96); + t->tok.length = g32(b + 100); + memcpy(t->tok.tokenizer_digest, b + 104, 32); + } + int rc = htk_bounds(t); + if (rc != HTK_OK) return rc; + uint8_t d[32]; + htk_input_digest(t, d); + if (memcmp(d, t->input_digest, 32) != 0) return HTK_INPUT_DIGEST_MISMATCH; + return HTK_OK; +} + +uint64_t htk_splitmix(uint64_t seed, uint64_t stream, uint64_t index) { + uint64_t z = seed + (index + 1u) * 0x9E3779B97F4A7C15ull + stream * 0xD1B54A32D192ED03ull; + z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ull; + z = (z ^ (z >> 27)) * 0x94D049BB133111EBull; + return z ^ (z >> 31); +} + +int htk_matmul_i64(uint32_t n, uint64_t seed, int64_t *c) { + if (!c || n == 0 || n > HTK_MATMUL_N_MAX) return HTK_BAD_BOUNDS; + for (uint32_t i = 0; i < n; i++) + for (uint32_t j = 0; j < n; j++) { + uint64_t acc = 0; /* wrapping i64 == wrapping u64 bit-for-bit */ + for (uint32_t k = 0; k < n; k++) { + uint64_t a = htk_splitmix(seed, 0, (uint64_t)i * n + k); + uint64_t b = htk_splitmix(seed, 1, (uint64_t)k * n + j); + acc += a * b; + } + c[(size_t)i * n + j] = (int64_t)acc; + } + return HTK_OK; +} + +void htk_matmul_result_bytes(uint32_t n, const int64_t *c, uint8_t *out) { + size_t total = (size_t)n * n; + for (size_t i = 0; i < total; i++) p64(out + 8 * i, (uint64_t)c[i]); +} + +int htk_matmul_result_digest(uint32_t n, uint64_t seed, int64_t *scratch, uint8_t out[32]) { + if (!scratch || !out) return HTK_BAD_BOUNDS; + int rc = htk_matmul_i64(n, seed, scratch); + if (rc != HTK_OK) return rc; + htk_matmul_result_bytes(n, scratch, (uint8_t *)scratch); /* in place: 8 bytes per value */ + sha256_hash((const uint8_t *)scratch, (size_t)n * n * 8u, out); + return HTK_OK; +} + +/* ================= HTR1 ================= */ +static const char *const htr_names[HTR_CODE_COUNT] = { + "HTR_OK", "HTR_BAD_MAGIC", "HTR_BAD_VERSION", "HTR_BAD_LENGTH", "HTR_RESERVED_NONZERO", + "HTR_BAD_FLAGS", "HTR_BAD_MACHINE", "HTR_BAD_KIND" +}; +const char *htr_code_name(int code) { return code >= 0 && code < HTR_CODE_COUNT ? htr_names[code] : "HTR_UNKNOWN_CODE"; } + +int htr_encode(const HtrReceipt *r, uint8_t out[HTR_BYTES]) { + if (!r || !out) return HTR_BAD_LENGTH; + if (r->version != 1) return HTR_BAD_VERSION; + if (!htk_param_len(r->kind)) return HTR_BAD_KIND; + if (r->flags & ~3u) return HTR_BAD_FLAGS; + memset(out, 0, HTR_BYTES); + memcpy(out, "HTR1", 4); + out[4] = r->version; + out[5] = r->kind; + p16(out + 6, r->flags); + memcpy(out + 8, r->run_id, 16); + if (aien_mid_encode(&r->executor, out + 24) != AIEN_MID_OK) return HTR_BAD_MACHINE; + memcpy(out + 68, r->implementation_digest, 32); + memcpy(out + 100, r->input_digest, 32); + memcpy(out + 132, r->result_digest, 32); + p64(out + 164, r->t_accept_us); + p64(out + 172, r->t_start_us); + p64(out + 180, r->t_end_us); + p64(out + 188, r->cpu_ns); + p64(out + 196, r->peak_rss_bytes); + p16(out + 204, r->threads_used); + memcpy(out + 208, r->os_arch, HTR_OS_ARCH); + memcpy(out + 224, r->identity_class, 4); + return HTR_OK; +} + +int htr_decode(const uint8_t *b, size_t n, HtrReceipt *r) { + if (!b || !r) return HTR_BAD_LENGTH; + memset(r, 0, sizeof *r); + if (n != HTR_BYTES) return HTR_BAD_LENGTH; + if (memcmp(b, "HTR1", 4) != 0) return HTR_BAD_MAGIC; + if (b[4] != 1) return HTR_BAD_VERSION; + if (!htk_param_len(b[5])) return HTR_BAD_KIND; + uint16_t flags = g16(b + 6); + if (flags & ~3u) return HTR_BAD_FLAGS; + if (!all_zero(b + 206, 2)) return HTR_RESERVED_NONZERO; + if (aien_mid_decode(b + 24, AIEN_MID_RECORD_BYTES, &r->executor) != AIEN_MID_OK) return HTR_BAD_MACHINE; + r->version = b[4]; + r->kind = b[5]; + r->flags = flags; + memcpy(r->run_id, b + 8, 16); + memcpy(r->implementation_digest, b + 68, 32); + memcpy(r->input_digest, b + 100, 32); + memcpy(r->result_digest, b + 132, 32); + r->t_accept_us = g64(b + 164); + r->t_start_us = g64(b + 172); + r->t_end_us = g64(b + 180); + r->cpu_ns = g64(b + 188); + r->peak_rss_bytes = g64(b + 196); + r->threads_used = g16(b + 204); + memcpy(r->os_arch, b + 208, HTR_OS_ARCH); + memcpy(r->identity_class, b + 224, 4); + return HTR_OK; +} + +void htr_reference(const uint8_t *bytes, size_t len, uint8_t out[32]) { sha256_hash(bytes, len, out); } + +/* ================= payloads ================= */ +int fw_completed_payload(const uint8_t result_digest[32], const HtrReceipt *r, + uint8_t *out, size_t cap, size_t *len) { + if (!result_digest || !out || !len) return -1; + size_t need = 32u + (r ? HTR_BYTES : 0u); + if (cap < need) return -1; + memcpy(out, result_digest, 32); + if (r && htr_encode(r, out + 32) != HTR_OK) return -1; + *len = need; + return 0; +} + +int fw_failed_payload(uint16_t code, const char *reason, uint8_t *out, size_t cap, size_t *len) { + if (!out || !len || cap < 2) return -1; + size_t rl = reason ? strlen(reason) : 0; + if (rl > FW_REASON_MAX) rl = FW_REASON_MAX; + if (cap < 2 + rl) return -1; + p16(out, code); + if (rl) memcpy(out + 2, reason, rl); + *len = 2 + rl; + return 0; +} + +/* ================= requester ================= */ +static const char *const req_names[FW_R_N] = { + "ok", "wrong side", "unknown task", "ordinal", "already terminal", "state", "bad payload", + "receipt peer", "receipt input", "result digest", "unsupported type", "full" +}; +const char *fw_req_code_name(int code) { return code >= 0 && code < FW_R_N ? req_names[code] : "?"; } + +int fw_state_terminal(uint32_t s) { return s == FW_ST_COMPLETED || s == FW_ST_FAILED || s == FW_ST_CANCELLED; } + +const char *fw_state_name(uint32_t s) { + switch (s) { + case FW_ST_SENT: return "SENT"; + case FW_ST_ACCEPTED: return "ACCEPTED"; + case FW_ST_RUNNING: return "RUNNING"; + case FW_ST_COMPLETED: return "COMPLETED"; + case FW_ST_FAILED: return "FAILED"; + case FW_ST_CANCELLED: return "CANCELLED"; + case FW_ST_UNCERTAIN: return "UNCERTAIN"; + default: return "?"; + } +} + +void fw_req_init(FwRequester *r) { if (r) memset(r, 0, sizeof *r); } + +FwTask *fw_req_find(FwRequester *r, const uint8_t task[16]) { + if (!r || !task) return NULL; + for (uint32_t i = 0; i < r->n; i++) + if (memcmp(r->t[i].task, task, 16) == 0) return &r->t[i]; + return NULL; +} + +int fw_req_send(FwRequester *r, const uint8_t task[16], const uint8_t idem[16], + const uint8_t input_digest[32], uint64_t deadline_us) { + if (!r || !task || !idem || !input_digest) return FW_R_BAD_PAYLOAD; + if (fw_req_find(r, task)) return FW_R_STATE; + if (r->n >= FW_MAX_TASKS) return FW_R_FULL; + FwTask *t = &r->t[r->n++]; + memset(t, 0, sizeof *t); + memcpy(t->task, task, 16); + memcpy(t->idem, idem, 16); + memcpy(t->input_digest, input_digest, 32); + t->deadline_us = deadline_us; + t->state = FW_ST_SENT; + return FW_R_OK; +} + +static int req_refuse(FwRequester *r, int why) { + r->refused[why]++; + r->last_refusal = why; + return why; +} + +/* Applies a terminal payload (completed / failed / cancelled bytes) to t. */ +static int apply_terminal(FwTask *t, uint8_t type, const uint8_t *p, size_t len, const AienMachineId *peer) { + if (type == PST_T_COMPLETED) { + if (len < 32) return FW_R_BAD_PAYLOAD; + if (len != 32 && len != 32 + HTR_BYTES) return FW_R_BAD_PAYLOAD; + HtrReceipt rc; + if (len == 32 + HTR_BYTES) { + if (htr_decode(p + 32, HTR_BYTES, &rc) != HTR_OK) return FW_R_BAD_PAYLOAD; + if (!aien_mid_equal(&rc.executor, peer)) return FW_R_RECEIPT_PEER; + if (memcmp(rc.input_digest, t->input_digest, 32) != 0) return FW_R_RECEIPT_INPUT; + if (memcmp(rc.result_digest, p, 32) != 0) return FW_R_RESULT_DIGEST; + t->receipt = rc; + t->has_receipt = 1; + htr_reference(p + 32, HTR_BYTES, t->receipt_reference); + t->has_receipt_reference = 1; + } + memcpy(t->result_digest, p, 32); + t->state = FW_ST_COMPLETED; + return FW_R_OK; + } + if (type == PST_T_FAILED) { + if (len < 2 || len > 2 + FW_REASON_MAX) return FW_R_BAD_PAYLOAD; + t->fail_code = g16(p); + t->state = FW_ST_FAILED; + return FW_R_OK; + } + if (type == PST_T_CANCELLED) { + if (len != 0) return FW_R_BAD_PAYLOAD; + t->state = FW_ST_CANCELLED; + return FW_R_OK; + } + return FW_R_BAD_PAYLOAD; +} + +int fw_req_receive(FwRequester *r, const PstMsg *m, const AienMachineId *peer, uint64_t now_us) { + if (!r || !m || !peer) return FW_R_BAD_PAYLOAD; + if (pst_side_check(m->type, PST_ROLE_EXECUTOR) != PST_OK) return req_refuse(r, FW_R_WRONG_SIDE); + FwTask *t = fw_req_find(r, m->task); + if (!t || memcmp(t->idem, m->idem, 16) != 0) return req_refuse(r, FW_R_UNKNOWN_TASK); + if (m->type == PST_T_TEXT_CHUNK || m->type == PST_T_WAITING_FOR_APPROVAL) return req_refuse(r, FW_R_UNSUPPORTED); + if (m->ordinal != t->next_ordinal) return req_refuse(r, FW_R_ORDINAL); + if (fw_state_terminal(t->state) && m->type != PST_T_RECEIPT_REFERENCE) return req_refuse(r, FW_R_TERMINAL); + + /* A copy: nothing in t changes unless the message is accepted. */ + FwTask c = *t; + int rc = FW_R_OK; + switch (m->type) { + case PST_T_ACCEPTED: + if (c.state != FW_ST_SENT) rc = FW_R_STATE; else c.state = FW_ST_ACCEPTED; + break; + case PST_T_QUEUED: + if (c.state != FW_ST_SENT && c.state != FW_ST_ACCEPTED) rc = FW_R_STATE; else c.state = FW_ST_ACCEPTED; + break; + case PST_T_RUNNING: + if (c.state != FW_ST_SENT && c.state != FW_ST_ACCEPTED) rc = FW_R_STATE; else c.state = FW_ST_RUNNING; + break; + case PST_T_COMPLETED: + case PST_T_FAILED: + case PST_T_CANCELLED: + if (c.state == FW_ST_UNCERTAIN) rc = FW_R_STATE; /* only a resume_snapshot leaves UNCERTAIN */ + else rc = apply_terminal(&c, m->type, m->payload, m->payload_len, peer); + break; + case PST_T_UNCERTAIN_AFTER_DISCONNECT: + if (m->payload_len) rc = FW_R_BAD_PAYLOAD; else c.state = FW_ST_UNCERTAIN; + break; + case PST_T_RESUME_SNAPSHOT: + if (c.state != FW_ST_UNCERTAIN) { rc = FW_R_STATE; break; } + if (m->payload_len < 1) { rc = FW_R_BAD_PAYLOAD; break; } + if (m->payload[0] == 0) { + if (m->payload_len != 1) rc = FW_R_BAD_PAYLOAD; else c.resume_unknown = 1; + } else { + rc = apply_terminal(&c, m->payload[0], m->payload + 1, m->payload_len - 1u, peer); + } + break; + case PST_T_RECEIPT_REFERENCE: + if (m->payload_len != 32) { rc = FW_R_BAD_PAYLOAD; break; } + if (c.has_receipt_reference && memcmp(c.receipt_reference, m->payload, 32) != 0) { rc = FW_R_RESULT_DIGEST; break; } + memcpy(c.receipt_reference, m->payload, 32); + c.has_receipt_reference = 1; + break; + default: + rc = FW_R_UNSUPPORTED; + } + if (rc != FW_R_OK) return req_refuse(r, rc); + c.next_ordinal = m->ordinal + 1u; + *t = c; + r->applied++; + (void)now_us; + return FW_R_OK; +} + +int fw_req_session_lost(FwRequester *r) { + if (!r) return 0; + int n = 0; + for (uint32_t i = 0; i < r->n; i++) + if (!fw_state_terminal(r->t[i].state) && r->t[i].state != FW_ST_UNCERTAIN) { r->t[i].state = FW_ST_UNCERTAIN; n++; } + return n; +} + +int fw_req_tick(FwRequester *r, uint64_t now_us) { + if (!r) return 0; + int n = 0; + for (uint32_t i = 0; i < r->n; i++) { + FwTask *t = &r->t[i]; + if (!fw_state_terminal(t->state) && t->state != FW_ST_UNCERTAIN && now_us > t->deadline_us) { + t->state = FW_ST_UNCERTAIN; + n++; + } + } + return n; +} + +int fw_req_verify_result(const FwTask *t, const uint8_t *result, size_t len) { + if (!t || (!result && len)) return FW_R_BAD_PAYLOAD; + if (t->state != FW_ST_COMPLETED) return FW_R_STATE; + uint8_t d[32]; + sha256_hash(result, len, d); + return memcmp(d, t->result_digest, 32) == 0 ? FW_R_OK : FW_R_RESULT_DIGEST; +} + +/* ================= executor ================= */ +static const char *const exec_names[FW_X_N] = { + "ok", "wrong side", "bad HTK1", "unknown kind", "bounds", "duplicate with different bytes", "journal store" +}; +const char *fw_exec_code_name(int code) { return code >= 0 && code < FW_X_N ? exec_names[code] : "?"; } + +int fw_exec_init(FwExecutor *x, const FwJournalStore *store) { + if (!x || !store || !store->append) return FW_X_STORE; + memset(x, 0, sizeof *x); + x->store = store; + return FW_X_OK; +} + +const FwJournalEntry *fw_exec_lookup(const FwExecutor *x, const uint8_t task[16], const uint8_t idem[16]) { + if (!x || !task || !idem) return NULL; + for (uint32_t i = 0; i < x->count; i++) { + const FwJournalEntry *e = &x->e[(x->head + FW_JOURNAL_ENTRIES - 1u - i) % FW_JOURNAL_ENTRIES]; + if (memcmp(e->task, task, 16) == 0 && memcmp(e->idem, idem, 16) == 0) return e; + } + return NULL; +} + +static void ring_put(FwExecutor *x, const FwJournalEntry *e) { + x->e[x->head] = *e; + x->head = (x->head + 1u) % FW_JOURNAL_ENTRIES; + if (x->count < FW_JOURNAL_ENTRIES) x->count++; +} + +int fw_journal_encode(const FwJournalEntry *e, uint8_t out[FW_JOURNAL_ENTRY_BYTES]) { + if (!e || !out) return -1; + if (e->terminal_type != PST_T_COMPLETED && e->terminal_type != PST_T_FAILED && e->terminal_type != PST_T_CANCELLED) return -1; + memset(out, 0, FW_JOURNAL_ENTRY_BYTES); + memcpy(out, e->task, 16); + memcpy(out + 16, e->idem, 16); + memcpy(out + 32, e->htk_digest, 32); + out[64] = e->terminal_type; + p16(out + 65, e->fail_code); + out[67] = e->has_receipt ? 1 : 0; + memcpy(out + 68, e->result_digest, 32); + if (e->has_receipt && htr_encode(&e->receipt, out + 100) != HTR_OK) return -1; + return 0; +} + +int fw_journal_decode(const uint8_t *b, size_t n, FwJournalEntry *e) { + if (!b || !e || n != FW_JOURNAL_ENTRY_BYTES) return -1; + memset(e, 0, sizeof *e); + memcpy(e->task, b, 16); + memcpy(e->idem, b + 16, 16); + memcpy(e->htk_digest, b + 32, 32); + e->terminal_type = b[64]; + if (e->terminal_type != PST_T_COMPLETED && e->terminal_type != PST_T_FAILED && e->terminal_type != PST_T_CANCELLED) return -1; + e->fail_code = g16(b + 65); + if (b[67] > 1) return -1; + e->has_receipt = b[67]; + memcpy(e->result_digest, b + 68, 32); + if (e->has_receipt && htr_decode(b + 100, HTR_BYTES, &e->receipt) != HTR_OK) return -1; + return 0; +} + +int fw_exec_load(FwExecutor *x, const uint8_t *rec, size_t len) { + if (!x) return FW_X_STORE; + FwJournalEntry e; + if (fw_journal_decode(rec, len, &e) != 0) return FW_X_STORE; + ring_put(x, &e); + return FW_X_OK; +} + +static int exec_refuse(FwExecutor *x, int why, uint16_t code, uint16_t *fail_code) { + x->refused[why]++; + if (fail_code) *fail_code = code; + return FW_ADMIT_REFUSE; +} + +int fw_exec_admit(FwExecutor *x, const PstMsg *m, const FwExecLimits *lim, HtkTask *task, + const FwJournalEntry **replay, uint16_t *fail_code) { + if (!x || !m || !lim || !task || !replay || !fail_code) return FW_ADMIT_REFUSE; + *replay = NULL; + *fail_code = 0; + if (m->type != PST_T_REQUEST) return exec_refuse(x, FW_X_WRONG_SIDE, 0, fail_code); + /* Idempotence first: a repeat is answered from the journal whatever the limits are now. */ + const FwJournalEntry *j = fw_exec_lookup(x, m->task, m->idem); + if (j) { + if (memcmp(j->htk_digest, m->digest, 32) == 0) { *replay = j; x->replayed++; return FW_ADMIT_REPLAY; } + return exec_refuse(x, FW_X_DUPLICATE_DIFFERENT, FW_FAIL_DUPLICATE_DIFFERENT, fail_code); + } + int rc = htk_decode(m->payload, m->payload_len, task); + if (rc == HTK_BAD_KIND) return exec_refuse(x, FW_X_KIND, FW_FAIL_UNKNOWN_KIND, fail_code); + if (rc == HTK_BAD_BOUNDS) return exec_refuse(x, FW_X_BOUNDS, FW_FAIL_BOUNDS, fail_code); + if (rc != HTK_OK) return exec_refuse(x, FW_X_BAD_HTK, FW_FAIL_INTERNAL, fail_code); + if (m->effect != PST_EFFECT_COMPUTE) return exec_refuse(x, FW_X_BAD_HTK, FW_FAIL_INTERNAL, fail_code); + if (!(lim->kinds & (1u << task->kind))) return exec_refuse(x, FW_X_KIND, FW_FAIL_UNKNOWN_KIND, fail_code); + uint32_t out_cap = lim->max_out_bytes_cap ? lim->max_out_bytes_cap : HTK_OUT_BYTES_MAX; + uint32_t dl_cap = lim->deadline_ms_cap ? lim->deadline_ms_cap : HTK_DEADLINE_MS_MAX; + if (task->threads > lim->cpus) return exec_refuse(x, FW_X_BOUNDS, FW_FAIL_BOUNDS, fail_code); + if (lim->mem_bytes && task->max_mem_bytes > lim->mem_bytes) return exec_refuse(x, FW_X_BOUNDS, FW_FAIL_BOUNDS, fail_code); + if (task->max_out_bytes > out_cap || task->deadline_ms > dl_cap) return exec_refuse(x, FW_X_BOUNDS, FW_FAIL_BOUNDS, fail_code); + uint64_t need = htk_result_bytes(task); + if (need && need > task->max_out_bytes) return exec_refuse(x, FW_X_BOUNDS, FW_FAIL_BOUNDS, fail_code); + x->admitted++; + return FW_ADMIT_RUN; +} + +int fw_exec_record(FwExecutor *x, const FwJournalEntry *e) { + if (!x || !e || !x->store) return FW_X_STORE; + uint8_t rec[FW_JOURNAL_ENTRY_BYTES]; + if (fw_journal_encode(e, rec) != 0) return FW_X_STORE; + if (x->store->append(x->store->ctx, rec, sizeof rec) != 0) { x->refused[FW_X_STORE]++; return FW_X_STORE; } + ring_put(x, e); + x->recorded++; + return FW_X_OK; +} + +int fw_terminal_payload(const FwJournalEntry *e, const char *reason, uint8_t *out, size_t cap, size_t *len) { + if (!e || !out || !len) return -1; + switch (e->terminal_type) { + case PST_T_COMPLETED: return fw_completed_payload(e->result_digest, e->has_receipt ? &e->receipt : NULL, out, cap, len); + case PST_T_FAILED: return fw_failed_payload(e->fail_code, reason, out, cap, len); + case PST_T_CANCELLED: *len = 0; return 0; + default: return -1; + } +} + +int fw_resume_snapshot_payload(const FwJournalEntry *e, uint8_t *out, size_t cap, size_t *len) { + if (!out || !len || cap < 1) return -1; + if (!e) { out[0] = 0; *len = 1; return 0; } + out[0] = e->terminal_type; + size_t inner = 0; + if (fw_terminal_payload(e, NULL, out + 1, cap - 1, &inner) != 0) return -1; + *len = 1 + inner; + return 0; +} diff --git a/src/fabric/fab_work.h b/src/fabric/fab_work.h new file mode 100644 index 000000000..8c5cf2640 --- /dev/null +++ b/src/fabric/fab_work.h @@ -0,0 +1,322 @@ +/* + * fab_work.h -- the work message of the heterogeneous compute program + * (aienix#6, omega#536): PST1 task envelope, HTK1 task request, HTR1 receipt, + * the requester's task state machine and the executor's idempotence journal. + * Production-buildable. No socket, file, process or clock call lives here: + * the caller moves bytes and supplies time. + * + * Wire stack (contract 2026-10-18 D1): UDP -> AIENOS M6-B (aienos_sec.h) -> + * M6-A frame (aienos_ctl.h, <= 1024 bytes) -> one message told apart by its + * first four bytes: "AFAB" (fabric.h) or "PST1" (this file). The peer and the + * session are facts the transport proved; no field here names them, and a + * receipt whose executor id disagrees with the session peer is refused. + * + * PST1 (aien-protocols specs/pi-spark-task/SPEC.md, wire version 1): the + * 224-byte header and the single-message checks are decoded here in the exact + * order and with the exact codes of the reference checker + * (specs/pi-spark-task/tools/pst_verify.c); tests/fabric/vectors/pst/ holds + * that checker's vectors and this decoder must give the same verdict line for + * every one. Roles: the REQUESTER sends request, cancel_request and + * resume_request (the spec's "Pi side"); the EXECUTOR sends every other type. + * + * HTK1 (request payload, effect_class 1 COMPUTE), big-endian: + * 0 4 "HTK1" 4 1 version 1 5 1 kind 6 2 reserved 0 + * 8 4 deadline_ms (1..600000) 12 4 max_out_bytes (1..64 MiB) + * 16 8 max_mem_bytes 24 4 max_in_bytes 28 4 threads (0 = executor's choice) + * 32 32 input_digest = SHA-256(canonical input bytes of the kind) + * 64 .. kind 1 MATMUL_I64_SEEDED: u32 n (1..512), u64 seed (12 bytes) + * kind 2 TOKENIZE_FIXTURE: 32 fixture_digest, u32 offset, u32 length (<= 1 MiB), + * 32 tokenizer_digest (72 bytes) + * kind 1 input bytes = "HTK1-MATMUL" | u32 n | u64 seed; + * A[i][j] = splitmix(seed, stream 0, i*n+j), B[i][j] = splitmix(seed, stream 1, i*n+j) as i64, + * C = A x B in wrapping i64; result bytes = C row-major, each i64 big-endian. + * kind 2 input bytes = fixture_digest | offset | length | tokenizer_digest; result bytes = token ids u32 BE + * (sovereign-core BitNetTokenizer::encode, bos=false). The tokenizer itself is not in this repo. + * splitmix(seed, stream, index): z = seed + (index+1)*0x9E3779B97F4A7C15 + stream*0xD1B54A32D192ED03; + * z = (z ^ z>>30)*0xBF58476D1CE4E5B9; z = (z ^ z>>27)*0x94D049BB133111EB; return z ^ z>>31 (all wrapping) + * + * HTR1 (receipt; the bytes after the 32-byte result digest in `completed`; + * named by receipt_reference = SHA-256(HTR1 bytes)), big-endian, 228 bytes: + * 0 4 "HTR1" 4 1 version 1 5 1 kind 6 2 flags (bits 0-1 sandbox: 0 none, 1 OS user, 2 namespaces; rest 0) + * 8 16 run_id 24 44 executor machine id record 68 32 implementation_digest + * 100 32 input_digest 132 32 result_digest 164 8 t_accept_us 172 8 t_start_us 180 8 t_end_us + * 188 8 cpu_ns 196 8 peak_rss_bytes 204 2 threads_used 206 2 reserved 0 + * 208 16 os_arch (NUL padded) 224 4 identity_class ("lab" or "own", NUL padded) + * `failed` payload: u16 code | UTF-8 reason (<= 200 bytes). Codes FW_FAIL_*. + * + * Requester state (D6): SENT -> ACCEPTED -> RUNNING -> COMPLETED | FAILED | CANCELLED; + * any non-terminal state + session lost or deadline passed -> UNCERTAIN, which only + * a resume_snapshot can leave. Executor ordinals per task start at 0 and rise by + * one; anything else is refused and counted, state unchanged. A second terminal + * is refused. Executor (D7): key (task_id, idempotence_key); a repeat with the + * same HTK1 bytes replays the journaled terminal, a repeat with other bytes is + * `failed` code 7; the journal store must report durable before a terminal may + * be sent (fw_exec_record fails otherwise and nothing is sent). + */ +#ifndef FAB_WORK_H +#define FAB_WORK_H + +#include "runtime/aien_machine_id.h" + +#include +#include + +/* ---- PST1 ---- */ +#define PST_HDR 224u +#define PST_MAX_PAY 800u +#define PST_MAX_MSG 1024u +#define PST_VERSION 1u +#define PST_MAX_TYPE 14u + +enum { + PST_T_REQUEST = 1, PST_T_ACCEPTED, PST_T_QUEUED, PST_T_RUNNING, PST_T_TEXT_CHUNK, + PST_T_WAITING_FOR_APPROVAL, PST_T_COMPLETED, PST_T_FAILED, PST_T_CANCELLED, + PST_T_UNCERTAIN_AFTER_DISCONNECT, PST_T_RESUME_SNAPSHOT, PST_T_RECEIPT_REFERENCE, + PST_T_CANCEL_REQUEST, PST_T_RESUME_REQUEST +}; +enum { PST_EFFECT_NONE = 0, PST_EFFECT_COMPUTE = 1, PST_EFFECT_EFFECT = 2 }; +enum { + PST_OK = 0, PST_BAD_MAGIC, PST_BAD_VERSION, PST_DOWNGRADE, PST_BAD_TYPE, + PST_WRONG_SIDE, PST_BAD_LENGTH, PST_TRAILING_BYTES, PST_RESERVED_NONZERO, + PST_NO_CAUSE, PST_NO_TASK, PST_NO_OBJECTIVE, PST_DIGEST_MISMATCH, + PST_BAD_EFFECT_CLASS, PST_SUBJECT_MISMATCH, PST_CODE_COUNT +}; +enum { PST_ROLE_REQUESTER = 1, PST_ROLE_EXECUTOR = 2 }; + +typedef struct { + uint8_t version, type; + uint8_t cause[32], origin[32], objective[32], subject[32]; + uint8_t parent[16], task[16], idem[16]; + uint32_t ordinal; + uint8_t effect; + uint16_t payload_len; + uint8_t digest[32]; + const uint8_t *payload; /* decode: points into the caller's buffer */ +} PstMsg; + +/* Decodes and checks one message in the spec's order. PST_OK or the first refusal. */ +int pst_decode(const uint8_t *b, size_t n, PstMsg *m); +/* Writes header + payload (digest computed here). The header fields are + * checked with the decode rules first. cap >= PST_HDR + payload_len. */ +int pst_encode(const PstMsg *m, const uint8_t *payload, size_t payload_len, + uint8_t *out, size_t cap, size_t *out_len); +/* The role that sends this type (PST_ROLE_*), 0 for an unknown type. */ +int pst_side_of(uint8_t type); +/* PST_OK when `sender_role` may send `type`, else PST_WRONG_SIDE. */ +int pst_side_check(uint8_t type, int sender_role); +const char *pst_code_name(int code); +/* The reference checker's verdict line ("ok type=... digest=..." or "refuse PST_..."). */ +void pst_verdict_line(int code, const PstMsg *m, char *buf, size_t cap); + +/* ---- HTK1 ---- */ +#define HTK_HDR 64u +#define HTK_MAX_BYTES (HTK_HDR + 72u) +#define HTK_INPUT_MAX 72u +#define HTK_KIND_MATMUL_I64_SEEDED 1u +#define HTK_KIND_TOKENIZE_FIXTURE 2u +#define HTK_MATMUL_N_MAX 512u +#define HTK_TOKENIZE_LEN_MAX (1u << 20) +#define HTK_DEADLINE_MS_MAX 600000u +#define HTK_OUT_BYTES_MAX (64u << 20) +enum { + HTK_OK = 0, HTK_BAD_MAGIC, HTK_BAD_VERSION, HTK_BAD_KIND, HTK_RESERVED_NONZERO, + HTK_BAD_LENGTH, HTK_BAD_BOUNDS, HTK_INPUT_DIGEST_MISMATCH, HTK_CODE_COUNT +}; + +typedef struct { + uint8_t kind; + uint32_t deadline_ms, max_out_bytes; + uint64_t max_mem_bytes; + uint32_t max_in_bytes, threads; + uint8_t input_digest[32]; + struct { uint32_t n; uint64_t seed; } matmul; /* kind 1 */ + struct { uint8_t fixture_digest[32]; uint32_t offset, length; uint8_t tokenizer_digest[32]; } tok; /* kind 2 */ +} HtkTask; + +/* Canonical input bytes of the task (digest preimage). Returns their length, 0 for an unknown kind. */ +size_t htk_input_bytes(const HtkTask *t, uint8_t out[HTK_INPUT_MAX]); +void htk_input_digest(const HtkTask *t, uint8_t out[32]); +/* Checks bounds, writes the bytes; input_digest is computed here (t->input_digest is ignored). */ +int htk_encode(const HtkTask *t, uint8_t *out, size_t cap, size_t *len); +/* Checks magic, version, kind, reserved, length, bounds, then input_digest. */ +int htk_decode(const uint8_t *b, size_t n, HtkTask *t); +/* Result size the kind defines (kind 1: n*n*8), 0 when the kind leaves it to the executor. */ +uint64_t htk_result_bytes(const HtkTask *t); +const char *htk_code_name(int code); + +/* The matmul definition (normative in C; the worker and the benchmarks oracle + * re-implement it independently and must reproduce the digests). */ +uint64_t htk_splitmix(uint64_t seed, uint64_t stream, uint64_t index); +/* c holds n*n values on return. HTK_BAD_BOUNDS for n outside 1..512. */ +int htk_matmul_i64(uint32_t n, uint64_t seed, int64_t *c); +/* Result bytes: row-major, each i64 big-endian; out holds n*n*8 bytes. */ +void htk_matmul_result_bytes(uint32_t n, const int64_t *c, uint8_t *out); +/* Runs the matmul into scratch (n*n i64) and digests its result bytes in place. */ +int htk_matmul_result_digest(uint32_t n, uint64_t seed, int64_t *scratch, uint8_t out[32]); + +/* ---- HTR1 ---- */ +#define HTR_BYTES 228u +#define HTR_MAX_BYTES 768u +#define HTR_OS_ARCH 16u +enum { HTR_OK = 0, HTR_BAD_MAGIC, HTR_BAD_VERSION, HTR_BAD_LENGTH, HTR_RESERVED_NONZERO, + HTR_BAD_FLAGS, HTR_BAD_MACHINE, HTR_BAD_KIND, HTR_CODE_COUNT }; +enum { HTR_SANDBOX_NONE = 0, HTR_SANDBOX_OS_USER = 1, HTR_SANDBOX_NAMESPACES = 2 }; + +typedef struct { + uint8_t version, kind; + uint16_t flags; + uint8_t run_id[16]; + AienMachineId executor; + uint8_t implementation_digest[32], input_digest[32], result_digest[32]; + uint64_t t_accept_us, t_start_us, t_end_us, cpu_ns, peak_rss_bytes; + uint16_t threads_used; + char os_arch[HTR_OS_ARCH]; /* NUL padded, not necessarily terminated */ + char identity_class[4]; /* "lab" or "own", NUL padded */ +} HtrReceipt; + +int htr_encode(const HtrReceipt *r, uint8_t out[HTR_BYTES]); +int htr_decode(const uint8_t *b, size_t n, HtrReceipt *r); +/* receipt_reference = SHA-256 of the receipt bytes. */ +void htr_reference(const uint8_t *bytes, size_t len, uint8_t out[32]); +const char *htr_code_name(int code); + +/* ---- failure codes (failed payload: u16 code | reason) ---- */ +enum { + FW_FAIL_BOUNDS = 1, FW_FAIL_UNKNOWN_KIND = 2, FW_FAIL_DEADLINE = 3, FW_FAIL_MEMORY = 4, + FW_FAIL_CANCELLED_BEFORE_START = 5, FW_FAIL_INTERNAL = 6, FW_FAIL_DUPLICATE_DIFFERENT = 7 +}; +#define FW_REASON_MAX 200u +/* completed payload: result_digest | HTR1 (r may be NULL: digest only). */ +int fw_completed_payload(const uint8_t result_digest[32], const HtrReceipt *r, + uint8_t *out, size_t cap, size_t *len); +int fw_failed_payload(uint16_t code, const char *reason, uint8_t *out, size_t cap, size_t *len); + +/* ---- requester ---- */ +#define FW_MAX_TASKS 32u +enum { FW_ST_SENT = 1, FW_ST_ACCEPTED, FW_ST_RUNNING, FW_ST_COMPLETED, FW_ST_FAILED, + FW_ST_CANCELLED, FW_ST_UNCERTAIN }; +enum { + FW_R_OK = 0, + FW_R_WRONG_SIDE, /* a requester-side type arrived */ + FW_R_UNKNOWN_TASK, /* task id / idempotence key not ours */ + FW_R_ORDINAL, /* not the next ordinal for this task */ + FW_R_TERMINAL, /* task already terminal (duplicate terminal, late message) */ + FW_R_STATE, /* type not allowed in the task's current state */ + FW_R_BAD_PAYLOAD, /* payload too short or undecodable for the type */ + FW_R_RECEIPT_PEER, /* receipt executor id is not the session peer */ + FW_R_RECEIPT_INPUT, /* receipt input_digest is not the task's */ + FW_R_RESULT_DIGEST, /* receipt result_digest differs from the completed digest, or result bytes differ */ + FW_R_UNSUPPORTED, /* a type HTK work does not use (text_chunk, waiting_for_approval) */ + FW_R_FULL, + FW_R_N +}; + +typedef struct { + uint8_t task[16], idem[16]; + uint32_t state; + uint32_t next_ordinal; /* executor ordinal expected next */ + uint64_t deadline_us; /* absolute; passing it non-terminal -> UNCERTAIN */ + uint8_t input_digest[32]; + uint8_t result_digest[32]; + uint8_t has_receipt; + HtrReceipt receipt; + uint8_t has_receipt_reference; + uint8_t receipt_reference[32]; + uint16_t fail_code; + uint8_t resume_unknown; /* resume_snapshot said the executor never journaled it */ +} FwTask; + +typedef struct { + uint32_t n; + FwTask t[FW_MAX_TASKS]; + uint64_t applied; + uint64_t refused[FW_R_N]; + int last_refusal; +} FwRequester; + +void fw_req_init(FwRequester *r); +/* Registers a sent request. FW_R_FULL, or FW_R_STATE for a task id already held. */ +int fw_req_send(FwRequester *r, const uint8_t task[16], const uint8_t idem[16], + const uint8_t input_digest[32], uint64_t deadline_us); +FwTask *fw_req_find(FwRequester *r, const uint8_t task[16]); +/* Applies one decoded executor message received on the session with `peer`. FW_R_*. */ +int fw_req_receive(FwRequester *r, const PstMsg *m, const AienMachineId *peer, uint64_t now_us); +/* Every non-terminal task -> UNCERTAIN. Returns how many changed. */ +int fw_req_session_lost(FwRequester *r); +/* Non-terminal tasks past their deadline -> UNCERTAIN. Returns how many changed. */ +int fw_req_tick(FwRequester *r, uint64_t now_us); +/* FW_R_OK when the task is COMPLETED and SHA-256(result) is its result digest. */ +int fw_req_verify_result(const FwTask *t, const uint8_t *result, size_t len); +int fw_state_terminal(uint32_t state); +const char *fw_state_name(uint32_t state); +const char *fw_req_code_name(int code); + +/* ---- executor ---- */ +#define FW_JOURNAL_ENTRIES 256u +#define FW_JOURNAL_ENTRY_BYTES (16u + 16u + 32u + 1u + 2u + 1u + 32u + HTR_BYTES) /* 328 */ +enum { FW_ADMIT_RUN = 0, FW_ADMIT_REPLAY = 1, FW_ADMIT_REFUSE = 2 }; +enum { + FW_X_OK = 0, + FW_X_WRONG_SIDE, /* not a request: refuse without reply (session rule) */ + FW_X_BAD_HTK, /* HTK1 undecodable -> failed code 6 */ + FW_X_KIND, /* unknown kind -> failed code 2 */ + FW_X_BOUNDS, /* outside this executor's limits -> failed code 1 */ + FW_X_DUPLICATE_DIFFERENT,/* same key, other bytes -> failed code 7 */ + FW_X_STORE, /* journal store refused: nothing may be sent */ + FW_X_N +}; + +typedef struct { + uint8_t task[16], idem[16]; + uint8_t htk_digest[32]; /* SHA-256 of the request payload (HTK1 bytes) */ + uint8_t terminal_type; /* PST_T_COMPLETED, PST_T_FAILED or PST_T_CANCELLED */ + uint16_t fail_code; + uint8_t has_receipt; + uint8_t result_digest[32]; + HtrReceipt receipt; +} FwJournalEntry; + +/* Durable append. 0 only once the record is on stable storage. */ +typedef struct { + void *ctx; + int (*append)(void *ctx, const uint8_t *rec, size_t len); +} FwJournalStore; + +typedef struct { + uint32_t cpus; /* threads > cpus is refused */ + uint64_t mem_bytes; /* max_mem_bytes above this is refused */ + uint32_t max_out_bytes_cap; /* 0 = HTK_OUT_BYTES_MAX */ + uint32_t deadline_ms_cap; /* 0 = HTK_DEADLINE_MS_MAX */ + uint32_t kinds; /* bit (1<append must return 0, then it is held. + * FW_X_STORE (nonzero) means nothing was journaled and nothing may be sent. */ +int fw_exec_record(FwExecutor *x, const FwJournalEntry *e); +int fw_journal_encode(const FwJournalEntry *e, uint8_t out[FW_JOURNAL_ENTRY_BYTES]); +int fw_journal_decode(const uint8_t *b, size_t n, FwJournalEntry *e); +/* The payload of the terminal message for a journal entry (completed: digest|HTR1; + * failed: code|reason; cancelled: empty). */ +int fw_terminal_payload(const FwJournalEntry *e, const char *reason, uint8_t *out, size_t cap, size_t *len); +/* resume_snapshot payload: u8 terminal_type (0 = unknown task) | terminal payload. */ +int fw_resume_snapshot_payload(const FwJournalEntry *e, uint8_t *out, size_t cap, size_t *len); +const char *fw_exec_code_name(int code); + +#endif /* FAB_WORK_H */ diff --git a/src/omega_blackwell_codegen.c b/src/omega_blackwell_codegen.c index b09fa1e54..bcaddbf7a 100644 --- a/src/omega_blackwell_codegen.c +++ b/src/omega_blackwell_codegen.c @@ -380,13 +380,17 @@ static int encode_single_insn(const BlackwellIRInsn *insn, const OmegaRegAlloc * } break; - case BW_IR_LDG_E: - /* LDG.E Rd, desc[URd][Ra.64] */ + case BW_IR_LDG_E: { + /* LDG.E Rd, desc[URd][Ra.64+imm]: the 32-bit size (4) of the LDG.E.64 / LDG.E.128 words below; imm as there + * (signed 24-bit byte offset at bits 40..63, w[1] bits 8..31), unchanged words when imm is 0. */ + int32_t off = (int32_t)insn->imm; + if (off < -(1 << 23) || off >= (1 << 23)) return -1; w[0] = 0x7981 | ((uint32_t)(dst & 0xff) << 16) | ((uint32_t)(src1 & 0xff) << 24); - w[1] = (uint32_t)(ureg & 0xff); + w[1] = (uint32_t)(ureg & 0xff) | (((uint32_t)off & 0xffffffU) << 8); w[2] = 0x0c1e1900; w[3] = insn->control ? insn->control : 0x000f2200; break; + } case BW_IR_STG_E: { /* STG.E desc[URd][Ra.64+imm], Rb. imm = signed 24-bit byte offset at bits 40..63 (w[1] bits @@ -529,6 +533,17 @@ static int encode_single_insn(const BlackwellIRInsn *insn, const OmegaRegAlloc * w[3] = insn->control ? insn->control : 0x00321e00; break; + case BW_IR_ATOMG_ADD_F32_STRONG_SYS: + case BW_IR_ATOMG_ADD_F32_STRONG_GPU: + /* ATOMG.E.ADD.F32.FTZ.RN.STRONG.{SYS,GPU} PT, Rd|RZ, desc[UR][Ra.64], Rb (omega_blackwell_verify_codegen_fixtures_atomf32). + * Float opcode 0x9a3; w2 bit 26 selects the desc[] form, type 9 (w2 bits 9..12) is F32.FTZ.RN, order (w2 bits + * 13..16) 0xa = SYS, 0x7 = GPU. No destination vreg encodes RZ (the generic default 0 would clobber R0). */ + w[0] = 0x79a3 | ((uint32_t)(insn->dst_vreg < 0 ? 0xff : (dst & 0xff)) << 16) | ((uint32_t)(src1 & 0xff) << 24); + w[1] = (uint32_t)(src2 & 0xff) | 0x80000000u; + w[2] = (insn->op == BW_IR_ATOMG_ADD_F32_STRONG_GPU ? 0x0c1ef300u : 0x0c1f5300u) | (uint32_t)(ureg & 0xff); + w[3] = insn->control ? insn->control : 0x00321e00; + break; + case BW_IR_ISETP_GE_U32: /* ISETP.GE.U32.AND P0, PT, Ra, Rb, PT. Checked with nvdisasm -b SM121. */ w[0] = 0x720c | ((uint32_t)(src1 & 0xff) << 24); @@ -649,6 +664,24 @@ static int encode_single_insn(const BlackwellIRInsn *insn, const OmegaRegAlloc * w[3] = insn->control ? insn->control : 0x000e2400; break; + case BW_IR_SHFL_BFLY: + /* SHFL.BFLY PT, Rd, Ra, lane, 0x1f: SHFL.DOWN with bit 58 (w[1] bit 26) set + * (omega_blackwell_verify_codegen_fixtures_bfly_f2fp) */ + w[0] = 0x7f89U | ((uint32_t)(dst & 0xff) << 16) | ((uint32_t)(src1 & 0xff) << 24); + w[1] = 0x0c001f00U | (((uint32_t)insn->imm & 0x1f) << 21); + w[2] = 0x000e0000; + w[3] = insn->control ? insn->control : 0x000e2400; + break; + + case BW_IR_F2FP_BF16_PACK: + /* F2FP.BF16.F32.PACK_AB Rd, Ra, Rb (omega_blackwell_verify_codegen_fixtures_bfly_f2fp). The default control + * is FMNMX's: the kernels emitted this as a patched FMNMX_MAX before R5 and their bytes must not move. */ + w[0] = 0x723eU | ((uint32_t)(dst & 0xff) << 16) | ((uint32_t)(src1 & 0xff) << 24); + w[1] = (uint32_t)(src2 & 0xff); + w[2] = 0x000010ff; + w[3] = insn->control ? insn->control : 0x004fc400; + break; + case BW_IR_LDS: /* LDS Rd, [Ra] */ w[0] = 0x7984U | ((uint32_t)(dst & 0xff) << 16) | ((uint32_t)(src1 & 0xff) << 24); @@ -963,6 +996,86 @@ int omega_blackwell_verify_codegen_fixtures_reconv(void) { return 0; } + +/* Training R5 (2026-10-15): golden words for SHFL.BFLY and F2FP.BF16.F32.PACK_AB, the two instructions the prefill + * kernels emitted as placeholders patched after encoding until R5. Oracle: nvcc 13.0.88 -arch=sm_121, cuobjdump -sass, + * sealed in evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/fa_ops.{cu,sass} (low 64-bit word, then high; the top + * 23 bits of the high word are the control word and are not compared): + * SHFL.BFLY PT, R5, R0, 0x1, 0x1f ; 0x0c201f0000057f89 0x004e2800000e0000 + * SHFL.BFLY PT, R7, R8, 0x1, 0x1f ; 0x0c201f0008077f89 0x008e6200000e0000 + * SHFL.BFLY PT, R4, R9, 0x2, 0x1f ; 0x0c401f0009047f89 0x000e2800000e0000 + * SHFL.BFLY PT, R6, R11, 0x2, 0x1f ; 0x0c401f000b067f89 0x000e6200000e0000 + * F2FP.BF16.F32.PACK_AB R9, R3, R0 ; 0x000000000309723e 0x000fe200000010ff + * F2FP.BF16.F32.PACK_AB R13, R13, R10 ; 0x0000000a0d0d723e 0x000fe400000010ff + * SHFL.BFLY is SHFL.DOWN (oracle words in omega_numeric.c, lanes 16 .. 1) with bit 58 set (Mesa NAK mode field 58..59: Idx 0, + * Up 1, Down 2, Bfly 3; same lane field 53..57); the lane check below covers every lane 0 .. 31 against that rule. 0 = all good. */ +int omega_blackwell_verify_codegen_fixtures_bfly_f2fp(void) { + static const struct { + BlackwellIROpcode op; int d, a, b; uint32_t imm; uint32_t w0, w1, w2; const char *text; + } fx[] = { + { BW_IR_SHFL_BFLY, 5, 0, -1, 1, 0x00057f89U, 0x0c201f00U, 0x000e0000U, "SHFL.BFLY PT, R5, R0, 0x1, 0x1f" }, + { BW_IR_SHFL_BFLY, 7, 8, -1, 1, 0x08077f89U, 0x0c201f00U, 0x000e0000U, "SHFL.BFLY PT, R7, R8, 0x1, 0x1f" }, + { BW_IR_SHFL_BFLY, 4, 9, -1, 2, 0x09047f89U, 0x0c401f00U, 0x000e0000U, "SHFL.BFLY PT, R4, R9, 0x2, 0x1f" }, + { BW_IR_SHFL_BFLY, 6, 11, -1, 2, 0x0b067f89U, 0x0c401f00U, 0x000e0000U, "SHFL.BFLY PT, R6, R11, 0x2, 0x1f" }, + { BW_IR_F2FP_BF16_PACK, 9, 3, 0, 0, 0x0309723eU, 0x00000000U, 0x000010ffU, "F2FP.BF16.F32.PACK_AB R9, R3, R0" }, + { BW_IR_F2FP_BF16_PACK, 13, 13, 10, 0, 0x0d0d723eU, 0x0000000aU, 0x000010ffU, "F2FP.BF16.F32.PACK_AB R13, R13, R10" }, + }; + uint32_t w[4]; + for (int i = 0; i < (int)(sizeof fx / sizeof fx[0]); i++) { + BlackwellIRInsn in; + memset(&in, 0, sizeof in); + in.op = fx[i].op; in.dst_vreg = fx[i].d; in.src1_vreg = fx[i].a; in.src2_vreg = fx[i].b; + in.src3_vreg = -1; in.ureg = -1; in.imm = fx[i].imm; + if (omega_blackwell_encode_one(&in, w) != 0) return -(2 * i + 1); + if (w[0] != fx[i].w0 || w[1] != fx[i].w1 || w[2] != fx[i].w2) return -(2 * i + 2); + } + for (uint32_t lane = 0; lane < 32; lane++) { + BlackwellIRInsn in; uint32_t d[4]; + memset(&in, 0, sizeof in); + in.op = BW_IR_SHFL_DOWN; in.dst_vreg = 9; in.src1_vreg = 2; in.src2_vreg = in.src3_vreg = in.ureg = -1; in.imm = lane; + if (omega_blackwell_encode_one(&in, d) != 0) return -100; + in.op = BW_IR_SHFL_BFLY; + if (omega_blackwell_encode_one(&in, w) != 0) return -101; + if (w[0] != d[0] || w[1] != (d[1] | 0x04000000U) || w[2] != d[2] || w[3] != d[3]) return -102; + } + return 0; +} + +/* Training R5 part 2: f32 global atomic add. Starting map from Mesa NAK sm70_encode.rs (a08a0b9, sm >= 90 float ATOMG; + * Mesa ranges are half-open): opcode 0x9a3, op 87..90 (Add 0, Min 2, Max 4), type 73..76 (F32 = 9, which is .FTZ.RN; + * 12 decodes as .RN without FTZ), order 77..80 (Strong System 0xa, Strong GPU 0x7), pred-dst 81..83 = PT, eviction + * 84..86 = 1, bit 63 = Ra.64, bit 91 = UR form. Then every word below was decoded offline with nvdisasm -b SM121 + * (CUDA 13.0) to the text shown. Where Mesa and the decoder disagree the decoder (and the chip probe) win: this word + * sets bit 90 (w2 bit 26), which falls inside Mesa's op field, yet it decodes as .ADD with desc[UR][R.64]; without it + * the same word decodes as [R.64+UR]. (Bit 88 decodes as .MIN, so the op field is there.) + * 0x80000005020479a3 0x00321e000c1f5306 ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, R4, desc[UR6][R2.64], R5 ; + * 0x800000070a0979a3 0x00321e000c1f5304 ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, R9, desc[UR4][R10.64], R7 ; + * 0x8000000502ff79a3 0x00321e000c1f5306 ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, RZ, desc[UR6][R2.64], R5 ; + * 0x80000005020479a3 0x00321e000c1ef306 ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, R4, desc[UR6][R2.64], R5 ; + * 0x800000070a0979a3 0x00321e000c1ef304 ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, R9, desc[UR4][R10.64], R7 ; + * 0x8000000502ff79a3 0x00321e000c1ef306 ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, RZ, desc[UR6][R2.64], R5 ; + * Rows with d = -1 (no destination vreg) must encode RZ, not R0. Chip proof: tests/gpu_atomf32_probe_test.c. 0 = all good. */ +int omega_blackwell_verify_codegen_fixtures_atomf32(void) { + static const struct { BlackwellIROpcode op; int d, a, b, u; uint32_t w0, w1, w2; } fx[] = { + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 4, 2, 5, 6, 0x020479a3U, 0x80000005U, 0x0c1f5306U }, + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 9, 10, 7, 4, 0x0a0979a3U, 0x80000007U, 0x0c1f5304U }, + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 255, 2, 5, 6, 0x02ff79a3U, 0x80000005U, 0x0c1f5306U }, + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, -1, 2, 5, 6, 0x02ff79a3U, 0x80000005U, 0x0c1f5306U }, + { BW_IR_ATOMG_ADD_F32_STRONG_GPU, 4, 2, 5, 6, 0x020479a3U, 0x80000005U, 0x0c1ef306U }, + { BW_IR_ATOMG_ADD_F32_STRONG_GPU, 9, 10, 7, 4, 0x0a0979a3U, 0x80000007U, 0x0c1ef304U }, + { BW_IR_ATOMG_ADD_F32_STRONG_GPU, -1, 2, 5, 6, 0x02ff79a3U, 0x80000005U, 0x0c1ef306U }, + }; + uint32_t w[4]; + for (int i = 0; i < (int)(sizeof fx / sizeof fx[0]); i++) { + BlackwellIRInsn in; + memset(&in, 0, sizeof in); + in.op = fx[i].op; in.dst_vreg = fx[i].d; in.src1_vreg = fx[i].a; in.src2_vreg = fx[i].b; + in.src3_vreg = -1; in.ureg = fx[i].u; + if (omega_blackwell_encode_one(&in, w) != 0) return -(2 * i + 1); + if (w[0] != fx[i].w0 || w[1] != fx[i].w1 || w[2] != fx[i].w2 || w[3] != 0x00321e00U) return -(2 * i + 2); + } + return 0; +} /* FB-1 cut 4: word-level fixtures for the four additive ops (checked against the * nvdisasm decodes recorded in docs/numeric/FB1_CUT4_ELEMENTWISE.md). 0 = all good. */ int omega_blackwell_verify_codegen_fixtures_fb1cut4(void) { diff --git a/src/omega_blackwell_codegen.h b/src/omega_blackwell_codegen.h index cc36e237d..d0ebb9c38 100644 --- a/src/omega_blackwell_codegen.h +++ b/src/omega_blackwell_codegen.h @@ -100,7 +100,23 @@ typedef enum { BW_IR_LDG_E_128, /* LDG.E.128 Rd..Rd+3, desc[URd][Ra.64+imm] */ /* Batched attention loads (2026-10-12). Words matched against nvcc 13.0.88 -arch=sm_121 * (omega_blackwell_verify_codegen_fixtures_fragmm). imm = unsigned byte offset < 2^23; dst an aligned quad. */ - BW_IR_LDS128 /* LDS.128 Rd..Rd+3, [Ra+imm] */ + BW_IR_LDS128, /* LDS.128 Rd..Rd+3, [Ra+imm] */ + /* Training R5 (2026-10-15), additive: native entries for the two instructions the prefill kernels used to emit as + * placeholders patched after encoding. Words: omega_blackwell_verify_codegen_fixtures_bfly_f2fp. */ + BW_IR_SHFL_BFLY, /* SHFL.BFLY PT, Rd, Ra, imm & 31, 0x1f: Rd = Ra of lane (lane ^ imm) */ + BW_IR_F2FP_BF16_PACK, /* F2FP.BF16.F32.PACK_AB Rd, Ra, Rb: Rd = bf16_rn(Ra) << 16 | bf16_rn(Rb) (fixed latency) */ + /* Training R5 part 2 (2026-10-15), additive: f32 global atomic add, the float twins of BW_IR_ATOMG_ADD_STRONG_SYS. + * Flush-to-zero like every f32 global atomic add (CUDA Programming Guide: "equivalent to PTX add.rn.ftz.f32"). + * dst_vreg < 0 encodes RZ: the add happens and the old value is dropped (no register is written). + * Two scopes, same arithmetic: + * .STRONG.SYS for a word the CPU (or another agent) may watch while the kernel runs: host-visible memory. + * .STRONG.GPU for a word only this GPU touches during the kernel and reads in a later launch, e.g. a gradient + * accumulated in device memory. This is the scope nvcc gives atomicAdd. + * nvcc's no-return form is REDG; Mesa's sm90 float REDG layout (opcode 0x9a6) does not decode on SM121 in any variant + * tried, so ATOMG with RZ is the no-return form here. Words: omega_blackwell_verify_codegen_fixtures_atomf32; + * chip probe: tests/gpu_atomf32_probe_test.c. */ + BW_IR_ATOMG_ADD_F32_STRONG_SYS, /* ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS PT, Rd|RZ, desc[UR][Ra.64], Rb: Rd = old, mem += Rb */ + BW_IR_ATOMG_ADD_F32_STRONG_GPU /* ATOMG.E.ADD.F32.FTZ.RN.STRONG.GPU PT, Rd|RZ, desc[UR][Ra.64], Rb: Rd = old, mem += Rb */ } BlackwellIROpcode; /* Barrier (reconvergence) registers: the sm_121 BSSY/BSYNC words carry a 4-bit barrier id @@ -320,6 +336,14 @@ int omega_blackwell_verify_codegen_fixtures_fragmm(void); * encoder's refusals (negative delta, barrier id > 15). 0 = pass. */ int omega_blackwell_verify_codegen_fixtures_reconv(void); +/* Training R5: golden words for SHFL.BFLY and F2FP.BF16.F32.PACK_AB (nvcc 13.0.88 sm_121 oracle sealed in + * evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z), plus SHFL.BFLY = SHFL.DOWN with bit 58 for every lane. 0 = pass. */ +int omega_blackwell_verify_codegen_fixtures_bfly_f2fp(void); + +/* Training R5 part 2: golden words for ATOMG.E.ADD.F32.FTZ.RN.STRONG.SYS and .STRONG.GPU, with and without a destination + * (decoded with nvdisasm -b SM121; no nvcc). 0 = pass. */ +int omega_blackwell_verify_codegen_fixtures_atomf32(void); + /* omega #308: encodes one instruction with a given physical register map of * identity (vreg n -> Rn) so offline tools can disassemble single words. 0 = ok. */ int omega_blackwell_encode_one(const BlackwellIRInsn *insn, uint32_t w[4]); diff --git a/src/omega_blackwell_codegen_pattn.c b/src/omega_blackwell_codegen_pattn.c index 676f84998..40fe0973f 100644 --- a/src/omega_blackwell_codegen_pattn.c +++ b/src/omega_blackwell_codegen_pattn.c @@ -28,7 +28,6 @@ typedef struct { int err; int open_start[MAX_LOOPS]; int depth; - uint32_t placeholders; } Em; static void emit(Em *e, BlackwellIRInsn in, int kind) { @@ -104,12 +103,11 @@ static void lds32(Em *e, Op d, int addr, int first) { BlackwellIRInsn i = I0(BW_ static void sts32(Em *e, int addr, Op val) { BlackwellIRInsn i = I0(BW_IR_STS32); i.src1_vreg = addr; i.src2_vreg = val.v; i.src2_subreg = (uint8_t)val.s; emit(e, i, K_STORE); } static void bar_sync(Em *e) { emit(e, I0(BW_IR_BAR_SYNC), K_SYNC); } static void shfl_down(Em *e, int d, int a, uint32_t off) { BlackwellIRInsn i = I0(BW_IR_SHFL_DOWN); i.dst_vreg = d; i.src1_vreg = a; i.imm = off; emit(e, i, K_VAR); } -/* SHFL.BFLY placeholder (omega_blackwell_codegen_tc.h), patched after encoding */ -static void shfl_bfly(Em *e, int d, int a, uint32_t lanes) { shfl_down(e, d, a, OMEGA_TC_MARK_BFLY | (lanes & 31u)); e->placeholders++; } -/* F2FP.BF16.F32.PACK_AB placeholder: d = bf16_rn(hi) << 16 | bf16_rn(lo) */ +static void shfl_bfly(Em *e, int d, int a, uint32_t lanes) { BlackwellIRInsn i = I0(BW_IR_SHFL_BFLY); i.dst_vreg = d; i.src1_vreg = a; i.imm = lanes & 31u; emit(e, i, K_VAR); } +/* F2FP.BF16.F32.PACK_AB: d = bf16_rn(hi) << 16 | bf16_rn(lo) */ static void f2fp(Em *e, Op d, Op hi, Op lo) { - BlackwellIRInsn i = I0(BW_IR_FMNMX_MAX); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = hi.v; i.src1_subreg = (uint8_t)hi.s; - i.src2_vreg = lo.v; i.src2_subreg = (uint8_t)lo.s; i.imm = OMEGA_TC_MARK_F2FP; emit(e, i, K_FIXED); e->placeholders++; + BlackwellIRInsn i = I0(BW_IR_F2FP_BF16_PACK); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = hi.v; i.src1_subreg = (uint8_t)hi.s; + i.src2_vreg = lo.v; i.src2_subreg = (uint8_t)lo.s; emit(e, i, K_FIXED); } static void isetp_ge_u32(Em *e, int a, int b) { BlackwellIRInsn i = I0(BW_IR_ISETP_GE_U32); i.src1_vreg = a; i.src2_vreg = b; emit(e, i, K_PRED); } static void bra_if_p0(Em *e, int target) { BlackwellIRInsn i = I0(BW_IR_BRA); i.predicate_p0 = true; i.imm = (uint32_t)(target - here(e)); emit(e, i, K_BRA); } @@ -541,18 +539,10 @@ int omega_blackwell_codegen_prefill_attn_prog(const OmegaPrefillAttnSpec *spec, return 0; } -int omega_prefill_attn_prog_stats(const OmegaPrefillAttnSpec *spec, uint32_t *insns, uint32_t *gprs, uint32_t *placeholders) { +int omega_prefill_attn_prog_stats(const OmegaPrefillAttnSpec *spec, uint32_t *insns, uint32_t *gprs) { static BlackwellIRProgram p; if (omega_blackwell_codegen_prefill_attn_prog(spec, &p) != 0) return -1; if (insns) *insns = (uint32_t)p.count; if (gprs) *gprs = p.regalloc.peak_gpr_usage; - if (placeholders) { - uint32_t n = 0; - for (size_t i = 0; i < p.count; i++) { - const BlackwellIRInsn *in = &p.insns[i]; - if ((in->op == BW_IR_SHFL_DOWN && (in->imm & OMEGA_TC_MARK_BFLY)) || (in->op == BW_IR_FMNMX_MAX && in->imm == OMEGA_TC_MARK_F2FP)) n++; - } - *placeholders = n; - } return 0; } diff --git a/src/omega_blackwell_codegen_pattn.h b/src/omega_blackwell_codegen_pattn.h index 09add123e..9f516dfea 100644 --- a/src/omega_blackwell_codegen_pattn.h +++ b/src/omega_blackwell_codegen_pattn.h @@ -3,8 +3,8 @@ /* * omega_blackwell_codegen_pattn: causal prefill attention for Qwen3-30B-A3B on tensor cores (OWN-30B L1 attention, * 2026-10-13). One launch per chunk of up to 64 consecutive tokens of one layer. New file; uses the opcodes of - * omega_blackwell_codegen.h plus the SHFL.BFLY and F2FP.BF16.F32.PACK_AB placeholders of omega_blackwell_codegen_tc.h - * (patched after encoding with omega_tc_patch_code). + * omega_blackwell_codegen.h only (SHFL.BFLY and F2FP.BF16.F32.PACK_AB are native encoder entries since training R5; + * before R5 they were placeholders patched after encoding). * * Grid (ceil(mc / W), 4): CTA (cx, cy) serves KV head cy and the chunk tokens cx*W .. cx*W+W-1 (W = warps, 4 or 8). * Row tile = 16 query rows = 2 tokens x the 8 query heads of the group: row g (0..7) = token 2*tile, head cy*8+g; @@ -77,7 +77,7 @@ typedef struct { int omega_pattn_spec_ok(const OmegaPrefillAttnSpec *spec); /* Builds the register-allocated IR program. 0 ok, -1 refused or over BW_MAX_IR_INSNS / BW_MAX_VREGS. */ int omega_blackwell_codegen_prefill_attn_prog(const OmegaPrefillAttnSpec *spec, BlackwellIRProgram *prog); -/* Instruction, peak-register and placeholder counts (host, no device). */ -int omega_prefill_attn_prog_stats(const OmegaPrefillAttnSpec *spec, uint32_t *insns, uint32_t *gprs, uint32_t *placeholders); +/* Instruction and peak-register counts (host, no device). */ +int omega_prefill_attn_prog_stats(const OmegaPrefillAttnSpec *spec, uint32_t *insns, uint32_t *gprs); #endif diff --git a/src/omega_blackwell_codegen_tc.c b/src/omega_blackwell_codegen_tc.c index 1b7f55dfd..c0b19c04e 100644 --- a/src/omega_blackwell_codegen_tc.c +++ b/src/omega_blackwell_codegen_tc.c @@ -225,61 +225,6 @@ int omega_blackwell_codegen_tcgemm_prog(const OmegaTcGemmSpec *spec, BlackwellIR return omega_bw_regalloc_solve(prog); } -/* ---------------------------------------------------------------- placeholder opcodes (header: OMEGA_TC_MARK_*) */ - -static uint32_t rd32(const uint8_t *p) { return (uint32_t)p[0] | (uint32_t)p[1] << 8 | (uint32_t)p[2] << 16 | (uint32_t)p[3] << 24; } -static void wr32(uint8_t *p, uint32_t v) { p[0] = (uint8_t)v; p[1] = (uint8_t)(v >> 8); p[2] = (uint8_t)(v >> 16); p[3] = (uint8_t)(v >> 24); } -int omega_tc_patch_code(const BlackwellIRProgram *prog, uint8_t *code, size_t len) { - if (!prog || !code || len < prog->count * 16u) return -1; - int n = 0; - for (size_t i = 0; i < prog->count; i++) { - const BlackwellIRInsn *in = &prog->insns[i]; uint8_t *w = code + i * 16u; - if (in->op == BW_IR_SHFL_DOWN && (in->imm & OMEGA_TC_MARK_BFLY)) { - uint32_t w0 = rd32(w), w1 = rd32(w + 4); - if ((w0 & 0xffffu) != 0x7f89u || (w1 & 0xfc0000ffu) != 0x08000000u || (w1 & 0x0000ff00u) != 0x1f00u) return -1; - wr32(w + 4, w1 | 0x04000000u); n++; - } else if (in->op == BW_IR_FMNMX_MAX && in->imm == OMEGA_TC_MARK_F2FP) { - uint32_t w0 = rd32(w), w1 = rd32(w + 4), w2 = rd32(w + 8); - if ((w0 & 0xffffu) != 0x7209u || (w1 & 0xffffff00u) != 0 || w2 != 0x07800000u) return -1; - wr32(w, (w0 & 0xffff0000u) | 0x723eu); wr32(w + 8, 0x000010ffu); n++; - } - } - return n; -} - -int omega_tc_patch_selftest(char *msg, size_t msgn) { - static BlackwellIRProgram p; static uint8_t buf[64 * 16]; size_t len = 0; - omega_bw_ir_init(&p); - Em em; memset(&em, 0, sizeof em); em.p = &p; Em *e = &em; - int udesc = UV64(e), py = V64(e), tid = V(e), a = V(e), b = V(e), c = V(e), d = V(e); - if (e->err) { omega_gpu_fmt(msg, msgn, "vregs"); return -1; } - ldcu64(e, udesc, 0x358); ldc64(e, py, 0x380); s2r(e, tid, BW_SR_TID_X); - shfl_bfly(e, a, tid, 1); shfl_bfly(e, b, a, 2); shfl_down(e, c, b, 1); - f2fp_pack(e, d, a, c); - imadw(e, py, tid, 4u, py); stg(e, py, 0, d, udesc); stg(e, py, 128, b, udesc); - tail(e); - if (e->err || omega_bw_regalloc_solve(&p) != 0 || omega_bw_encode_program(&p, buf, sizeof buf, &len) != 0) { omega_gpu_fmt(msg, msgn, "build/encode failed"); return -1; } - int np = omega_tc_patch_code(&p, buf, len); - if (np != 3) { omega_gpu_fmt(msg, msgn, "patched %d placeholders, expected 3", np); return -1; } - int seen = 0; - for (size_t i = 0; i < p.count; i++) { - const uint8_t *w = buf + i * 16u; uint32_t w0 = rd32(w), w1 = rd32(w + 4), w2 = rd32(w + 8); - const BlackwellIRInsn *in = &p.insns[i]; - if (in->op == BW_IR_SHFL_DOWN) { - /* oracle words with the register bytes (16..31 of word 0) masked: BFLY lane 1 0x0c201f00, lane 2 0x0c401f00; DOWN 1 0x08201f00 */ - uint32_t lane = in->imm & 31u, want = ((in->imm & OMEGA_TC_MARK_BFLY) ? 0x0c001f00u : 0x08001f00u) | lane << 21; - if ((w0 & 0xffffu) != 0x7f89u || w1 != want || w2 != 0x000e0000u) { omega_gpu_fmt(msg, msgn, "SHFL word %zu: %08x %08x %08x", i, w0, w1, w2); return -1; } - seen++; - } else if (in->op == BW_IR_FMNMX_MAX) { - if ((w0 & 0xffffu) != 0x723eu || (w1 & 0xffffff00u) != 0 || w2 != 0x000010ffu) { omega_gpu_fmt(msg, msgn, "F2FP word %zu: %08x %08x %08x", i, w0, w1, w2); return -1; } - seen++; - } - } - if (seen != 4) { omega_gpu_fmt(msg, msgn, "saw %d of 4 checked words", seen); return -1; } - omega_gpu_fmt(msg, msgn, "SHFL.BFLY x2, SHFL.DOWN x1, F2FP.BF16.F32.PACK_AB x1 match the oracle bits"); - return 0; -} - int omega_blackwell_codegen_tc_peak_prog(uint32_t iters, uint32_t chains, uint32_t stall, uint32_t threads, BlackwellIRProgram *prog) { if (!prog || iters == 0 || chains == 0 || chains > 16 || stall == 0 || stall > 15 || threads == 0 || threads % 32 || threads > 1024) return -1; omega_bw_ir_init(prog); diff --git a/src/omega_blackwell_codegen_tc.h b/src/omega_blackwell_codegen_tc.h index cc5c8e563..1fc530d05 100644 --- a/src/omega_blackwell_codegen_tc.h +++ b/src/omega_blackwell_codegen_tc.h @@ -81,21 +81,9 @@ int omega_blackwell_codegen_tc_peak_prog(uint32_t iters, uint32_t chains, uint32 * CTA distinct (DRAM); groups = 1: every CTA the same bytes (shows any cache reuse of these buffers). */ int omega_blackwell_codegen_tc_bw_prog(uint32_t iters, uint32_t groups, uint32_t threads, BlackwellIRProgram *prog); -/* ---- opcodes the shared encoder lacks, emitted as same-footprint placeholders and patched after encoding ---- - * SHFL.BFLY PT, Rd, Ra, lane, 0x1f: a BW_IR_SHFL_DOWN whose imm carries OMEGA_TC_MARK_BFLY; the patch sets bit 26 of word 1 - * (nvcc 13.0.88 sm_121 oracle, investigations/2026-10-13-t3-mma-oracle/attn/fa_ops.sass: SHFL.BFLY PT, R5, R0, 0x1, 0x1f = - * 0x0c201f0000057f89 / 0x004e2800000e0000; the shared encoder's SHFL.DOWN word 1 is 0x08001f00 | lane << 21). - * F2FP.BF16.F32.PACK_AB Rd, Ra, Rb (Rd = bf16_rn(Ra) << 16 | bf16_rn(Rb)): a BW_IR_FMNMX_MAX whose imm is OMEGA_TC_MARK_F2FP; - * the patch rewrites the opcode to 0x723e and word 2 to 0x000010ff (oracle: F2FP.BF16.F32.PACK_AB R9, R3, R0 = - * 0x000000000309723e / 0x000fe200000010ff; registers stay at Rd 16..23, Ra 24..31, Rb 32..39 as FMNMX). F2FP needs no - * scoreboard in the oracle (fixed latency), as FMNMX. */ -#define OMEGA_TC_MARK_BFLY 0x80000000u -#define OMEGA_TC_MARK_F2FP 0x46320000u -/* patch the encoded code (len bytes, one 16-byte word per IR instruction); returns the number patched or -1 on a word that - * does not hold the expected placeholder bits */ -int omega_tc_patch_code(const BlackwellIRProgram *prog, uint8_t *code, size_t len); -/* encoder self-test: placeholders encoded and patched against the oracle words (register fields excluded); 0 = pass */ -int omega_tc_patch_selftest(char *msg, size_t msgn); +/* SHFL.BFLY and F2FP.BF16.F32.PACK_AB were placeholders patched after encoding (omega_tc_patch_code) until training R5; + * they are now native encoder entries (BW_IR_SHFL_BFLY, BW_IR_F2FP_BF16_PACK, golden words in + * omega_blackwell_verify_codegen_fixtures_bfly_f2fp) and the emitted bytes are unchanged. */ #ifdef __cplusplus } diff --git a/src/omega_blackwell_codegen_tern.c b/src/omega_blackwell_codegen_tern.c index 370564e89..9fcb52c8e 100644 --- a/src/omega_blackwell_codegen_tern.c +++ b/src/omega_blackwell_codegen_tern.c @@ -75,10 +75,14 @@ static void andi(Em *e, int d, int a, unsigned asub, uint32_t imm) { BlackwellIR static void ldg_wide(Em *e, BlackwellIROpcode op, int d, int addr64, uint32_t imm, int udesc, int first) { BlackwellIRInsn i = I0(op); i.dst_vreg = d; i.src1_vreg = addr64; i.imm = imm; i.ureg = udesc; emit(e, i, first ? K_VAR : K_VAR_MORE); } -static void ldg32(Em *e, int d, int addr64, int udesc, int first) { BlackwellIRInsn i = I0(BW_IR_LDG_E); i.dst_vreg = d; i.src1_vreg = addr64; i.ureg = udesc; emit(e, i, first ? K_VAR : K_VAR_MORE); } +static void ldg32(Em *e, int d, int addr64, uint32_t imm, int udesc, int first) { + BlackwellIRInsn i = I0(BW_IR_LDG_E); i.dst_vreg = d; i.src1_vreg = addr64; i.imm = imm; i.ureg = udesc; emit(e, i, first ? K_VAR : K_VAR_MORE); +} static void stg(Em *e, int addr64, uint32_t imm, int val, int udesc) { BlackwellIRInsn i = I0(BW_IR_STG_E); i.src1_vreg = addr64; i.src2_vreg = val; i.imm = imm; i.ureg = udesc; emit(e, i, K_STORE); } static void lds128(Em *e, int d128, int addr, uint32_t imm, int first) { BlackwellIRInsn i = I0(BW_IR_LDS128); i.dst_vreg = d128; i.src1_vreg = addr; i.imm = imm; emit(e, i, first ? K_VAR : K_VAR_MORE); } +static void lds32(Em *e, int d, int addr) { BlackwellIRInsn i = I0(BW_IR_LDS32); i.dst_vreg = d; i.src1_vreg = addr; emit(e, i, K_VAR); } static void sts32(Em *e, int addr, int val) { BlackwellIRInsn i = I0(BW_IR_STS32); i.src1_vreg = addr; i.src2_vreg = val; emit(e, i, K_STORE); } +static void xorr(Em *e, int d, int a, int b) { BlackwellIRInsn i = I0(BW_IR_LOP3_XOR); i.dst_vreg = d; i.src1_vreg = a; i.src2_vreg = b; emit(e, i, K_FIXED); } static void bar_sync(Em *e) { emit(e, I0(BW_IR_BAR_SYNC), K_SYNC); } static void fmul(Em *e, int d, int a, int b) { BlackwellIRInsn i = I0(BW_IR_FMUL); i.dst_vreg = d; i.src1_vreg = a; i.src2_vreg = b; emit(e, i, K_FIXED); } static void i2f(Em *e, int d, int a) { BlackwellIRInsn i = I0(BW_IR_I2FP); i.dst_vreg = d; i.src1_vreg = a; emit(e, i, K_FIXED); } @@ -129,12 +133,24 @@ int omega_tern_gemv_spec_ok(const OmegaTernGemvSpec *s) { if (s->depth == 0 || s->depth > 16 || ksc % s->depth || s->rows * s->depth > 16u) return 0; if (s->epi != OMEGA_TERN_EPI_I32 && s->epi != OMEGA_TERN_EPI_F32) return 0; if (s->epi == OMEGA_TERN_EPI_F32 && nch != 1) return 0; - if (s->mutant < 0 || s->mutant > 3) return 0; + if (s->mutant < 0 || s->mutant > 5) return 0; return 1; } uint32_t omega_tern_gemv_steps(const OmegaTernGemvSpec *s) { return omega_tern_gemv_spec_ok(s) ? s->k / 256u : 0; } +/* Output path. Chip finding (investigation 2026-10-16-kt1-speed, probe-nostore): one small GPU-uncached store per unit per + * warp cost 9 to 11 us per launch at 3840 x 2560 and 13824 x 2560, more than a third of the launch. So a single-chunk + * kernel gathers each round's 2 R W results in shared memory (two slot sets, alternating by round, one CTA barrier per + * round) and warp 0 writes them as one coalesced store of 2 R W consecutive words. Chunked kernels (k > 8192) keep the + * per-row store because they accumulate y in place across chunks. */ +int omega_tern_gemv_coalesced_out(const OmegaTernGemvSpec *s) { + if (!omega_tern_gemv_spec_ok(s) || omega_tern_gemv_chunks(s) != 1 || 2u * s->rows * s->warps > 32u) return 0; /* warp 0 stores the round */ + return s->k * 2u + 2u * omega_tern_gemv_out_slot_bytes(s) <= OMEGA_TERN_SHARED_MAX; +} +uint32_t omega_tern_gemv_out_slot_bytes(const OmegaTernGemvSpec *s) { return s ? 2u * s->rows * s->warps * 4u : 0; } uint32_t omega_tern_gemv_shared_bytes(const OmegaTernGemvSpec *s) { - return omega_tern_gemv_spec_ok(s) ? (s->k / omega_tern_gemv_chunks(s)) * 2u : 0; + if (!omega_tern_gemv_spec_ok(s)) return 0; + const uint32_t x_bytes = (s->k / omega_tern_gemv_chunks(s)) * 2u; + return omega_tern_gemv_coalesced_out(s) ? x_bytes + 2u * omega_tern_gemv_out_slot_bytes(s) : x_bytes; } uint64_t omega_tern_word_offset(uint32_t layout, uint32_t R, uint32_t k, uint32_t r, uint32_t c) { @@ -213,6 +229,28 @@ static int tern_schedule_stalls(BlackwellIRProgram *p) { } return 0; } +/* Every weight load of one K iteration (D steps) from the lane pointer pw, issued back to back with immediate offsets + * (block: one wide load per step; row-major: one 32-bit load per row and step). */ +static void weight_loads(Em *e, int block, uint32_t R, uint32_t D, const int *wq, int wr[4][16], int pw, uint32_t step_bytes, + uint32_t row_bytes, int udesc) { + if (block) { + for (uint32_t d = 0; d < D; d++) ldg_wide(e, R == 4 ? BW_IR_LDG_E_128 : BW_IR_LDG_E_64, wq[d], pw, d * step_bytes, udesc, d == 0); + return; + } + for (uint32_t r = 0; r < R; r++) for (uint32_t d = 0; d < D; d++) ldg32(e, wr[r][d], pw, r * row_bytes + d * step_bytes, udesc, r == 0 && d == 0); +} + +/* x staging address of word c, clamped to KWC - 1 so no lane reads past x (clamped lanes rewrite that word's staged values, + * identical bytes to the same place): cc = c < KWC ? c : KWC - 1, pxa = px + 16 cc, sb = 32 cc. kwm1 holds KWC - 1. */ +static void x_stage_addr(Em *e, int c, int kwm1, int one, int px, int cc, int pxa, int sb, int va, int vb) { + imadi(e, va, kwm1, 0, 0xffffffffu, c); /* c - (KWC - 1) */ + imadi(e, vb, one, 0, 0xffffffffu, va); /* c - KWC */ + shr(e, vb, vb, 0, 31); /* 1 if c < KWC */ + imadr(e, cc, vb, va, 0, kwm1); /* c < KWC ? c : KWC - 1 */ + imadw(e, pxa, cc, 16u, px); + imadi(e, sb, cc, 0, 32u, NOREG); +} + int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, BlackwellIRProgram *prog) { if (!omega_tern_gemv_spec_ok(spec) || !prog) return -1; const uint32_t K = spec->k, R = spec->rows, W = spec->warps, D = spec->depth, TH = 32u * W; @@ -258,28 +296,53 @@ int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, Blackw else { imadi(e, lo, l, 0, 4u, NOREG); imadi(e, lo, h, 0, R * row_bytes, lo); } imadw(e, pl, lo, 1, pwb); /* this lane's weight pointer in unit 0, chunk 0 */ movi(e, k0, 0x80008000u); - if (f32) ldg32(e, asv, pas, udesc, 1); + if (f32) ldg32(e, asv, pas, 0, udesc, 1); if (NCH > 1) { movi(e, chc, NCH); movrz(e, mul); } + /* ---- per-unit registers ---- */ + int rowbase = V(e), pw = V64(e), xlc = V(e), cnt = V(e); + int T[4], wq[16], wr[4][16], xs[8], Ut[4], P[4], M[4], ap[4], am[4]; + int row = V(e), okr = V(e), skip = V(e), yv = V(e), f = V(e), wsv = V(e), pya = V64(e), pwsa = V64(e), sum = V(e); + for (uint32_t r = 0; r < R; r++) { T[r] = V(e); Ut[r] = V(e); P[r] = V(e); M[r] = V(e); ap[r] = V(e); am[r] = V(e); } + if (block) { for (uint32_t d = 0; d < D; d++) wq[d] = R == 4 ? V128(e) : V64(e); } + else for (uint32_t r = 0; r < R; r++) for (uint32_t d = 0; d < D; d++) wr[r][d] = V(e); + for (uint32_t i = 0; i < (D <= 4u ? 2u * D : 2u); i++) xs[i] = V128(e); + /* prefetch flag (single chunk): 1 while this warp's first K iteration already has its weights in flight */ + const int pre = NCH == 1; + int pf = NOREG, pu = NOREG; + if (pre) { pf = V(e); pu = V(e); } + if (e->err) return -1; + /* ---- chunk loop (NCH > 1 only for k > OMEGA_TERN_CHUNK_MAX): x staged per chunk, y accumulated in place ---- */ const int L_c = here(e); if (NCH > 1) { loop_begin(e); bar_sync(e); } - /* ---- stage x: per word c of the chunk, X_j = x[16c+j] * 65536 + x[16c+j+8] (j < 8), 32 bytes ---- */ + /* ---- stage x: per word c of the chunk, X_j = x[16c+j] * 65536 + x[16c+j+8] (j < 8), 32 bytes. + * Single chunk: the weight loads of this warp's first unit (clamped to U - 1, always inside the tensor) go out first + * and the x load follows without waiting for them, so the x round trip and the first weight round trip overlap; the + * first instruction that uses x then waits for both. The K loop skips its loads once while pf is set. Measured + * (investigation 2026-10-16-kt1-speed): x staging alone took 2.3 to 3.2 us of every CTA before any weight moved. ---- */ { const uint32_t rounds = (KWC + TH - 1) / TH; - int c = V(e), kwr = V(e), rc = V(e), pxa = V64(e), xq = V128(e), sb = V(e), va = V(e), vb = V(e), X = V(e), sad = V(e); + int c = V(e), kwm1 = V(e), rc = V(e), cc = V(e), pxa = V64(e), xq = V128(e), sb = V(e), va = V(e), vb = V(e), X = V(e), sad = V(e); if (e->err) return -1; - movi(e, kwr, KWC); + movi(e, kwm1, KWC - 1u); imadi(e, c, tid, 0, 1, NOREG); movi(e, rc, rounds); + x_stage_addr(e, c, kwm1, one, px, cc, pxa, sb, va, vb); + if (pre) { + imadi(e, pu, ureg, 0, 0xffffffffu, u0); /* u0 - U */ + shr(e, pf, pu, 0, 31); /* 1 if u0 < U */ + imadi(e, pu, one, 0, 1, pu); /* u0 - U + 1 */ + imadi(e, t, one, 0, 0xffffffffu, ureg); /* U - 1 */ + imadr(e, pu, pf, pu, 0, t); /* u0 < U ? u0 : U - 1 */ + imadw(e, pw, pu, 2u * R * row_bytes, pl); + movi(e, pf, 1); + weight_loads(e, block, R, D, wq, wr, pw, step_bytes, row_bytes, udesc); + } const int L_s = here(e); loop_begin(e); - isetp_ge_u32(e, c, kwr); - Region rg = region_begin(e); - imadw(e, pxa, c, 16u, px); - ldg_wide(e, BW_IR_LDG_E_128, xq, pxa, 0, udesc, 1); - imadi(e, sb, c, 0, 32u, NOREG); + ldg_wide(e, BW_IR_LDG_E_128, xq, pxa, 0, udesc, !pre); /* behind the prefetch: no wait for its data */ for (uint32_t j = 0; j < 8; j++) { const unsigned sh = 8u * (j & 3u); int src[2] = { va, vb }; const unsigned sub[2] = { j >> 2, 2u + (j >> 2) }; @@ -294,33 +357,51 @@ int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, Blackw imadi(e, sad, one, 0, 4u * j, sb); sts32(e, sad, X); } - region_end(e, rg); imadi(e, c, one, 0, TH, c); imadi(e, rc, one, 0, 0xffffffffu, rc); + x_stage_addr(e, c, kwm1, one, px, cc, pxa, sb, va, vb); /* next round (unused after the last) */ isetp_ge_u32(e, rc, one); bra_if_p0(e, L_s); loop_end(e); bar_sync(e); } - /* ---- per-unit registers ---- */ - int rowbase = V(e), pw = V64(e), xlc = V(e), cnt = V(e); - int T[4], wq[16], wr[4][16], wa[4][16], xs[8], Ut[4], P[4], M[4], ap[4], am[4]; - int row = V(e), okr = V(e), skip = V(e), yv = V(e), f = V(e), wsv = V(e), pya = V64(e), pwsa = V64(e), sum = V(e); - for (uint32_t r = 0; r < R; r++) { T[r] = V(e); Ut[r] = V(e); P[r] = V(e); M[r] = V(e); ap[r] = V(e); am[r] = V(e); } - if (block) { for (uint32_t d = 0; d < D; d++) wq[d] = R == 4 ? V128(e) : V64(e); } - else for (uint32_t r = 0; r < R; r++) for (uint32_t d = 0; d < D; d++) { wr[r][d] = V(e); wa[r][d] = V64(e); } - for (uint32_t i = 0; i < (D <= 4u ? 2u * D : 2u); i++) xs[i] = V128(e); - if (e->err) return -1; + /* ---- coalesced output (single chunk): per-CTA round variables, see the header ---- */ + const int coal = omega_tern_gemv_coalesced_out(spec); + const uint32_t slot_bytes = omega_tern_gemv_out_slot_bytes(spec), x_bytes = KC * 2u, nrow = 2u * R * W; + int uc = NOREG, ueff = NOREG, um1 = NOREG, negU = NOREG, okw = NOREG, tu = NOREG, lg0 = NOREG, sbase = NOREG, stog = NOREG; + int so = NOREG, sa = NOREG, wl1 = NOREG, val = NOREG; + if (coal) { + uc = V(e); ueff = V(e); um1 = V(e); negU = V(e); okw = V(e); tu = V(e); lg0 = V(e); sbase = V(e); stog = V(e); + so = V(e); sa = V(e); wl1 = V(e); val = V(e); + if (e->err) return -1; + imadi(e, lg0, nzl1, 0, 1, NOREG); imadi(e, lg0, one, 0, 0xffffffffu, lg0); /* (l > 0) */ + imadi(e, um1, one, 0, 0xffffffffu, ureg); /* U - 1 */ + imadi(e, negU, ureg, 0, 0xffffffffu, NOREG); /* -U */ + movi(e, sbase, x_bytes); /* slot set of this round (alternates) */ + movi(e, stog, spec->mutant == 4 ? 0u : slot_bytes); /* mutant 4: one slot set, the round race the second set prevents */ + imadi(e, so, warp, 0, 2u * R * 4u, NOREG); imadi(e, so, h, 0, R * 4u, so); /* this half-warp's slot: (2 warp + h) R words */ + imadi(e, tu, lane, 0, 0xffffffffu, NOREG); imadi(e, tu, one, 0, nrow - 1u, tu); shr(e, tu, tu, 0, 31); /* 1 if lane >= 2 R W */ + imadi(e, wl1, warp, 0, 1, tu); imadi(e, wl1, one, 0, 1, wl1); /* warp + (lane >= 2 R W) + 1 */ + imadi(e, uc, cx, 0, W, NOREG); /* first unit of this CTA's round (uniform over the CTA) */ + } /* ---- unit loop ---- */ imadi(e, u, u0, 0, 1, NOREG); const int L_u = here(e); loop_begin(e); - isetp_ge_u32(e, u, ureg); + isetp_ge_u32(e, coal ? uc : u, ureg); /* coalesced: the whole CTA leaves together (barriers inside) */ const int bra_end = bra_if_p0_fwd(e); - imadi(e, rowbase, u, 0, 2u * R, hR); - imadw(e, pw, u, 2u * R * row_bytes, pl); + if (coal) { + /* a warp past the last unit recomputes unit U - 1; its rows are >= n_padded >= n and are never stored */ + imadi(e, tu, u, 0, 1, negU); /* u - U */ + shr(e, okw, tu, 0, 31); /* 1 if u < U */ + imadi(e, tu, one, 0, 1, tu); /* u - U + 1 */ + if (spec->mutant == 5) imadi(e, ueff, u, 0, 1, NOREG); /* mutant 5: no clamp, a warp past U reads past the tensor */ + else imadr(e, ueff, okw, tu, 0, um1); /* u < U ? u : U - 1 */ + } else ueff = u; + imadi(e, rowbase, ueff, 0, 2u * R, hR); + imadw(e, pw, ueff, 2u * R * row_bytes, pl); imadi(e, xlc, xl, 0, 1, NOREG); for (uint32_t r = 0; r < R; r++) movrz(e, T[r]); movi(e, cnt, KSC / D); @@ -333,14 +414,18 @@ int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, Blackw const int lds_up = D <= 4u; const int L_k = here(e); loop_begin(e); - if (block) { - for (uint32_t d = 0; d < D; d++) ldg_wide(e, R == 4 ? BW_IR_LDG_E_128 : BW_IR_LDG_E_64, wq[d], pw, d * step_bytes, udesc, d == 0); + if (pre) { + /* the prefetched first iteration skips its loads (pf set); the staged x reads go out before the predicate */ + if (lds_up) for (uint32_t d = 0; d < D; d++) for (uint32_t i = 0; i < 2; i++) lds128(e, xs[2u * d + i], xlc, d * 512u + 16u * i, d == 0 && i == 0); + isetp_ge_u32(e, pf, one); + Region rl = region_begin(e); + weight_loads(e, block, R, D, wq, wr, pw, step_bytes, row_bytes, udesc); + region_end(e, rl); + movi(e, pf, 0); } else { - for (uint32_t r = 0; r < R; r++) for (uint32_t d = 0; d < D; d++) imadw(e, wa[r][d], one, r * row_bytes + d * step_bytes, pw); - int first = 1; - for (uint32_t r = 0; r < R; r++) for (uint32_t d = 0; d < D; d++) { ldg32(e, wr[r][d], wa[r][d], udesc, first); first = 0; } + weight_loads(e, block, R, D, wq, wr, pw, step_bytes, row_bytes, udesc); + if (lds_up) for (uint32_t d = 0; d < D; d++) for (uint32_t i = 0; i < 2; i++) lds128(e, xs[2u * d + i], xlc, d * 512u + 16u * i, 0); } - if (lds_up) for (uint32_t d = 0; d < D; d++) for (uint32_t i = 0; i < 2; i++) lds128(e, xs[2u * d + i], xlc, d * 512u + 16u * i, 0); for (uint32_t d = 0; d < D; d++) { const int *xd = lds_up ? &xs[2u * d] : xs; if (!lds_up) for (uint32_t i = 0; i < 2; i++) lds128(e, xs[i], xlc, d * 512u + 16u * i, i == 0); @@ -366,7 +451,50 @@ int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, Blackw /* ---- half-warp reduction (lanes 0 and 16 hold the sums), lane l == 0 stores rows < n ---- */ for (uint32_t r = 0; r < R; r++) for (uint32_t o = 8; o >= 1; o /= 2) { shfl_down(e, t, T[r], o); imadi(e, T[r], t, 0, 1, T[r]); } - for (uint32_t r = 0; r < R; r++) { + if (coal) { + /* lane l == 0 of each half-warp: finish its R rows and park them in this round's slot set */ + isetp_ge_u32(e, lg0, one); + Region rs = region_begin(e); + imadi(e, sa, sbase, 0, 1, so); /* sbase + so */ + for (uint32_t r = 0; r < R; r++) { + imadi(e, yv, one, 0, 0u - KSC * (1u << 18), T[r]); /* y = T - KSC * 2^18 (mod 2^32, exact) */ + if (f32) { + imadi(e, row, one, 0, r, rowbase); + for (int i = 0; i < 3; i++) { + imadi(e, t, row, 0, 1, nb[i]); + shr(e, t, t, 0, 31); /* 1 if row < b_i */ + if (i == 0) imadi(e, sum, t, 0, 1, NOREG); else imadi(e, sum, t, 0, 1, sum); + } + imadw(e, pwsa, sum, 4u, pws); /* ws_rev[boundaries above row] = w_scale[seg] */ + ldg32(e, wsv, pwsa, 0, udesc, 1); + i2f(e, f, yv); + fmul(e, f, f, asv); + fmul(e, f, f, wsv); + if (r) imadi(e, sa, one, 0, 4u, sa); + sts32(e, sa, f); + } else { + if (r) imadi(e, sa, one, 0, 4u, sa); + sts32(e, sa, yv); + } + } + region_end(e, rs); + bar_sync(e); + /* warp 0, lanes < 2 R W: row = 2 R uc + lane, stored when < n, as one coalesced STG */ + imadi(e, row, uc, 0, 2u * R, lane); + imadi(e, okr, row, 0, 1, negn); + shr(e, okr, okr, 0, 31); /* 1 if row < n */ + imadi(e, skip, okr, 0, 0xffffffffu, wl1); /* warp + (lane >= 2 R W) + 1 - (row < n): 0 only for a store */ + isetp_ge_u32(e, skip, one); + Region rg = region_begin(e); + imadi(e, sa, lane, 0, 4u, sbase); + lds32(e, val, sa); + imadw(e, pya, row, 4u, py); + stg(e, pya, 0, val, udesc); + region_end(e, rg); + xorr(e, sbase, sbase, stog); /* next round parks in the other slot set */ + imadi(e, uc, stride, 0, 1, uc); + } + for (uint32_t r = 0; r < R && !coal; r++) { imadi(e, row, one, 0, r, rowbase); imadi(e, okr, row, 0, 1, negn); shr(e, okr, okr, 0, 31); /* 1 if row < n */ @@ -375,7 +503,7 @@ int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, Blackw Region rg = region_begin(e); imadi(e, yv, one, 0, 0u - KSC * (1u << 18), T[r]); /* y = T - KSC * 2^18 (mod 2^32, exact) */ imadw(e, pya, row, 4u, py); - if (NCH > 1) { ldg32(e, prev, pya, udesc, 1); imadr(e, yv, prev, mul, 0, yv); } /* + earlier chunks */ + if (NCH > 1) { ldg32(e, prev, pya, 0, udesc, 1); imadr(e, yv, prev, mul, 0, yv); } /* + earlier chunks */ if (f32) { for (int i = 0; i < 3; i++) { imadi(e, t, row, 0, 1, nb[i]); @@ -383,7 +511,7 @@ int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, Blackw if (i == 0) imadi(e, sum, t, 0, 1, NOREG); else imadi(e, sum, t, 0, 1, sum); } imadw(e, pwsa, sum, 4u, pws); /* ws_rev[boundaries above row] = w_scale[seg] */ - ldg32(e, wsv, pwsa, udesc, 1); + ldg32(e, wsv, pwsa, 0, udesc, 1); i2f(e, f, yv); fmul(e, f, f, asv); fmul(e, f, f, wsv); diff --git a/src/omega_blackwell_codegen_tern.h b/src/omega_blackwell_codegen_tern.h index 3fdf221e8..10c0cc9ae 100644 --- a/src/omega_blackwell_codegen_tern.h +++ b/src/omega_blackwell_codegen_tern.h @@ -36,6 +36,14 @@ * k % 512 == 0). With two chunks each lane l == 0 adds the earlier chunk's int32 y it stored itself (same thread, same * address, program order); the f32 epilogue is refused there. * + * Output path (single chunk, omega_tern_gemv_coalesced_out): every warp of a CTA works on consecutive units in a round + * (unit = CTA * W + warp + round * stride, all warps of a CTA take the same number of rounds; a warp past the last unit + * recomputes unit U - 1 and its rows fall at or beyond n_padded, never stored). Lane l == 0 of each half-warp writes the + * row's result into a shared slot, one CTA barrier, then warp 0 lanes 0 .. 2 R W - 1 store the round's 2 R W consecutive + * rows (those < n) with one coalesced STG. Two slot sets alternate by round so one barrier per round suffices. Measured + * reason (investigation 2026-10-16-kt1-speed): the per-row 4-byte GPU-uncached stores cost 9 to 11 us per launch. + * Chunked kernels keep the per-row store. + * * Epilogue: * OMEGA_TERN_EPI_I32 (0): y int32. * OMEGA_TERN_EPI_F32 (1): y f32 = ((float)y_int * a_scale) * w_scale[seg(r)], two round-to-nearest FMULs in that order. @@ -52,7 +60,8 @@ * 0x3b0 negn u32 -n (store rows < n) 0x3b4, 0x3b8, 0x3bc: -b0, -b1, -b2 * * mutant (tests only): 1 flips the planes (the staged X_j are negated: plus acts as minus, y becomes -y), 2 is host-side only - * (the API maps segments as ws_idx = r / (n / segments)), 3 drops pair j = 7 (trits 7 and 15 of every word). + * (the API maps segments as ws_idx = r / (n / segments)), 3 drops pair j = 7 (trits 7 and 15 of every word), 4 uses one + * output slot set (the round race, simulator with a reversed warp order), 5 drops the unit clamp of the coalesced path. */ #include #include "omega_blackwell_codegen.h" @@ -89,13 +98,16 @@ typedef struct { uint32_t warps; /* 1 .. 32 */ uint32_t depth; /* K steps per loop iteration: divides chunk / 256; rows * depth <= 16 */ uint32_t epi; /* OMEGA_TERN_EPI_* */ - int mutant; /* 0 production; 1, 3 kernel mutants (2 is host-side, kernel identical to 0) */ + int mutant; /* 0 production; 1, 3, 4, 5 kernel mutants (2 is host-side, kernel identical to 0) */ } OmegaTernGemvSpec; int omega_blackwell_codegen_tern_gemv_prog(const OmegaTernGemvSpec *spec, BlackwellIRProgram *prog); int omega_tern_gemv_spec_ok(const OmegaTernGemvSpec *spec); uint32_t omega_tern_gemv_steps(const OmegaTernGemvSpec *spec); /* k / 256 (0 when refused) */ -uint32_t omega_tern_gemv_shared_bytes(const OmegaTernGemvSpec *spec); /* 2 * chunk width */ +uint32_t omega_tern_gemv_shared_bytes(const OmegaTernGemvSpec *spec); /* 2 * chunk width, plus two output slot sets when coalesced */ +int omega_tern_gemv_coalesced_out(const OmegaTernGemvSpec *spec); /* 1 when the round's rows leave through shared memory in one store */ +uint32_t omega_tern_gemv_out_slot_bytes(const OmegaTernGemvSpec *spec); /* 2 * rows * warps * 4: one slot set */ +#define OMEGA_TERN_SHARED_MAX 16384u /* OMEGA_BW_QMD_MAX_SHARED_BYTES */ uint32_t omega_tern_gemv_chunks(const OmegaTernGemvSpec *spec); /* x chunks: 1 for k <= 8192, else 2 */ int omega_tern_gemv_prog_stats(const OmegaTernGemvSpec *spec, uint32_t *insns, uint32_t *gprs); diff --git a/src/omega_blackwell_codegen_tgemm.c b/src/omega_blackwell_codegen_tgemm.c new file mode 100644 index 000000000..12a2fc80b --- /dev/null +++ b/src/omega_blackwell_codegen_tgemm.c @@ -0,0 +1,217 @@ +/* omega_blackwell_codegen_tgemm.c: device-resident bf16 training GEMM (trainer lane E1, cut 1: NN, F32 overwrite). See the + * header. The K loop, staging and scheduling follow omega_blackwell_codegen_tc2.c (chip gate OWN30B-L1G-GEMM-1e76e728). */ +#include "omega_blackwell_codegen_tgemm.h" +#include "omega_bw_em.h" + +int omega_tgemm_spec_ok(const OmegaTgemmSpec *s) { + if (!s) return 0; + if (s->k < 128u || s->k > 65536u || s->k % 128u) return 0; + if (s->rt != 2 && s->rt != 4 && s->rt != 8) return 0; + if (s->ct != 2) return 0; /* the paired column tiles share one B word per lane */ + if (s->warps != 8 && s->warps != 16) return 0; + if (s->kc != 32) return 0; + if (s->aqn != 1 && s->aqn != 2) return 0; + if (s->layout != OMEGA_TGEMM_LAYOUT_NN || s->epi != OMEGA_TGEMM_EPI_F32) return 0; + const uint32_t span = s->warps * 8u * s->ct; + if (s->n == 0 || s->n % span || s->n >= (1u << 17)) return 0; + if ((16u * s->rt * (s->kc / 4u)) % (32u * s->warps)) return 0; /* whole LDG.64 staging pieces per thread */ + { /* the pieces of one thread are RJ rows apart: constant load offsets that must stay under the encoder's 2^23 */ + const uint32_t RJ = 32u * s->warps / (s->kc / 4u), nj = 16u * s->rt * (s->kc / 4u) / (32u * s->warps); + if (RJ % 16u) return 0; + if ((uint64_t)(nj - 1u) * RJ * s->k * 2u + (128u / s->kc - 1u) * s->kc * 2u >= (1u << 23)) return 0; + } + if (2u * 16u * s->rt * s->kc * 2u > 16384u) return 0; /* QMD shared cap */ + if (32u * span > 2u * 16u * s->rt * s->kc * 2u) return 0; /* an 8-row output pass must fit the staging buffers */ + if ((8u * span) % (32u * s->warps)) return 0; + if (s->mutant < 0 || s->mutant > 5) return 0; + return 1; +} +uint32_t omega_tgemm_shared_bytes(const OmegaTgemmSpec *s) { return omega_tgemm_spec_ok(s) ? 2u * 16u * s->rt * s->kc * 2u : 0u; } +uint32_t omega_tgemm_span(const OmegaTgemmSpec *s) { return omega_tgemm_spec_ok(s) ? s->warps * 8u * s->ct : 0u; } +uint32_t omega_tgemm_bm(const OmegaTgemmSpec *s) { return omega_tgemm_spec_ok(s) ? 16u * s->rt : 0u; } + +/* d = lut(a[asub], b[bsub], c) */ +static void lop3s(Em *e, int d, int a, unsigned asub, int b, unsigned bsub, int c, uint32_t lut) { + BlackwellIRInsn i = I0(BW_IR_LOP3_LUT); i.dst_vreg = d; i.src1_vreg = a; i.src1_subreg = (uint8_t)asub; i.src2_vreg = b; i.src2_subreg = (uint8_t)bsub; i.src3_vreg = c; i.imm = lut; emit(e, i, K_FIXED); +} +/* d[dsub] = a * imm + c */ +static void imadi_d(Em *e, int d, unsigned dsub, int a, uint32_t imm, int c) { + BlackwellIRInsn i = I0(BW_IR_IMAD); i.dst_vreg = d; i.dst_subreg = (uint8_t)dsub; i.src1_vreg = a; i.imm = imm; i.src3_vreg = c; emit(e, i, K_FIXED); +} +/* d[dsub] = a >> imm (SHF.R.U32.HI) */ +static void shr_d(Em *e, int d, unsigned dsub, int a, uint32_t imm) { + BlackwellIRInsn i = I0(BW_IR_SHF_R); i.dst_vreg = d; i.dst_subreg = (uint8_t)dsub; i.src1_vreg = a; i.imm = imm; emit(e, i, K_FIXED); +} +/* d[dsub] = a[asub] + b */ +static void iadd_d(Em *e, int d, unsigned dsub, int a, unsigned asub, int b) { + BlackwellIRInsn i = I0(BW_IR_IADD3); i.dst_vreg = d; i.dst_subreg = (uint8_t)dsub; i.src1_vreg = a; i.src1_subreg = (uint8_t)asub; i.src2_vreg = b; emit(e, i, K_FIXED); +} +static void sts32_sub(Em *e, int addr, int val, unsigned sub) { + BlackwellIRInsn st = I0(BW_IR_STS32); st.src1_vreg = addr; st.src2_vreg = val; st.src2_subreg = (uint8_t)sub; emit(e, st, K_STORE); +} + +int omega_blackwell_codegen_tgemm_prog(const OmegaTgemmSpec *spec, BlackwellIRProgram *prog) { + if (!omega_tgemm_spec_ok(spec) || !prog) return -1; + const uint32_t K = spec->k, N = spec->n, RT = spec->rt, CT = spec->ct, W = spec->warps, T = 32u * W, KC = spec->kc, AQN = spec->aqn; + const uint32_t BM = 16u * RT, SPAN = W * 8u * CT, NS = KC / 16u /* HMMA steps per chunk */, NCH = 128u / KC /* chunks per block */; + const uint32_t PPR = KC / 4u /* LDG.64 pieces per row of a chunk */, NJ = BM * PPR / T, BUF = BM * KC * 2u; + omega_bw_ir_init(prog); + Em em; memset(&em, 0, sizeof em); em.p = prog; + Em *e = &em; + + /* ---- prologue: arguments, ids, tile entry ---- */ + int udesc = UV64(e), ptab = V64(e), pa = V64(e), pbb = V64(e); + int tid = V(e), cx = V(e), cy = V(e), warp = V(e), lane = V(e), g = V(e), tq = V(e), one = V(e), tent = V64(e); + int rk = V64(e) /* row0, kb0 */, nkb = V64(e) /* nkb, pad */; + int n0w = V(e), tmp = V(e), tmp2 = V(e), pb = V64(e), la = V(e), msel = V(e); + if (e->err) return -1; + ldcu64(e, udesc, 0x358); + ldc64(e, ptab, 0x380); ldc64(e, pa, 0x388); ldc64(e, pbb, 0x390); + s2r(e, tid, BW_SR_TID_X); s2r(e, cx, BW_SR_CTAID_X); s2r(e, cy, BW_SR_CTAID_Y); + movi(e, one, 1); + shr(e, warp, tid, 0, 5); andi(e, lane, tid, 0, 31); shr(e, g, lane, 0, 2); andi(e, tq, lane, 0, 3); + imadw(e, tent, cy, OMEGA_TGEMM_TILE_BYTES, ptab); + ldg_wide(e, BW_IR_LDG_E_64, rk, tent, 8, udesc, 1); + ldg_wide(e, BW_IR_LDG_E_64, nkb, tent, 16, udesc, 0); + /* this warp's first output column n0w; B fragment pointer: row kb0 * 128 + 8 t, column n0w + 4 (g / 2) */ + imadi(e, n0w, cx, 0, SPAN, NOREG); imadi(e, tmp, warp, 0, 8u * CT, NOREG); iadd(e, n0w, n0w, tmp); + imadi(e, tmp, rk, 1, 128u, NOREG); imadi(e, tmp, tq, 0, 8u, tmp); imadi(e, tmp, tmp, 0, N, n0w); + shr(e, tmp2, g, 0, 1); imadi(e, tmp, tmp2, 0, 4u, tmp); imadw(e, pb, tmp, 2u, pbb); + /* half-word select mask: odd g takes the high word of its 8 B row bytes (mutant 4 swaps the parity) */ + andi(e, tmp, g, 0, 1); if (spec->mutant == 4) imadi(e, tmp, tmp, 0, 0xffffffffu, one); + imadi(e, msel, tmp, 0, 0xffffffffu, NOREG); + imadi(e, la, lane, 0, 16u, NOREG); + + /* ---- staging assignment: piece = tid + jj * T -> row r = piece / PPR, pp = piece % PPR (4 bf16 at k 4 pp) ---- */ + /* piece jj of a thread is piece 0 moved RJ = T / PPR rows down: the same pp, row + jj RJ, so one address register and one + * shared offset serve all pieces (constant byte offsets jj * RJ * K * 2 on the load, jj * (RJ / 16) * NS * 512 on the store) */ + const uint32_t RJ = T / PPR, GXJ = RJ * K * 2u, SAJ = (RJ / 16u) * NS * 512u; + int gx = V64(e), sa = V(e), r = V(e), pp = V(e), hh = V(e); + if (e->err) return -1; + { + shr(e, r, tid, 0, (uint32_t)log2u(PPR)); andi(e, pp, tid, 0, PPR - 1u); + /* global: a + ((row0 + r) * K + kb0 * 128 + 4 pp) * 2 */ + iadd(e, tmp, rk, r); imadw(e, gx, tmp, K * 2u, pa); + imadi(e, tmp, rk, 1, 256u, NOREG); imadi(e, tmp, pp, 0, 8u, tmp); imadw(e, gx, tmp, 1, gx); + /* shared: (r / 16) * NS * 512 + (pp & 1) * 512 + (4 (r % 8) + pp / 2) * 16 + 4 ((r / 8) & 1) */ + shr(e, tmp, r, 0, 4); imadi(e, tmp, tmp, 0, NS * 512u, NOREG); + andi(e, tmp2, pp, 0, 1); imadi(e, tmp, tmp2, 0, 512u, tmp); + andi(e, tmp2, r, 0, 7); imadi(e, tmp2, tmp2, 0, 4u, NOREG); shr(e, hh, pp, 0, 1); iadd(e, tmp2, tmp2, hh); imadi(e, tmp, tmp2, 0, 16u, tmp); + shr(e, hh, r, 0, 3); andi(e, hh, hh, 0, 1); imadi(e, sa, hh, 0, 4u, tmp); + } + + /* ---- loop-wide registers ---- */ + int acc[16], bq[2][8], stgr[8], aq[2], wsel[2], bE = V64(e), bO = V64(e), tw = V(e), cntk = V(e); + for (uint32_t x = 0; x < RT * CT; x++) acc[x] = V128(e); + for (unsigned set = 0; set < 2; set++) for (uint32_t j = 0; j < 4u * NS; j++) bq[set][j] = V64(e); + for (uint32_t jj = 0; jj < NJ; jj++) stgr[jj] = V64(e); + for (uint32_t q = 0; q < AQN; q++) aq[q] = V128(e); + for (unsigned j = 0; j < 2; j++) wsel[j] = V(e); + if (e->err) return -1; + + /* A pieces of chunk c (immediate c * KC * 2) and the B rows of the chunk (pb points at its row kb0 * 128 + chunk * KC + 8 t) */ + #define ISSUE(set, sb, chunk) do { \ + for (uint32_t jj = 0; jj < NJ; jj++) ldw_pf(e, BW_IR_LDG_E_64, stgr[jj], gx, jj * GXJ + (chunk) * KC * 2u, udesc, (sb)); \ + for (uint32_t s = 0; s < NS; s++) for (uint32_t j = 0; j < 4; j++) ldw_pf(e, BW_IR_LDG_E_64, bq[set][s * 4u + j], pb, (4u * s + j) * N * 2u, udesc, (sb)); } while (0) + #define STAGE(buf) do { for (uint32_t jj = 0; jj < NJ; jj++) { \ + imadi(e, tmp, one, 0, (buf) + jj * SAJ, sa); sts32_sub(e, tmp, stgr[jj], 0); \ + imadi(e, tmp, one, 0, (buf) + jj * SAJ + 8u, sa); sts32_sub(e, tmp, stgr[jj], 1); } bar_sync(e); } while (0) + /* B fragments of step s: W_j = half word (g % 2) of row word j (LOP3 select); E: (W0.lo, W1.lo), (W2.lo, W3.lo) by + * IMAD W1 * 2^16 + (W0 & 0xffff); O: (W0.hi, W1.hi), (W2.hi, W3.hi) by (W0 >> 16) + (W1 & 0xffff0000). (IMAD.HI.U32 would do + * the O half in one instruction, but its Rc is a 64-bit pair on the chip: odd columns came back wrong, first chip run.) */ + #define BFRAG(set, s) do { for (unsigned h = 0; h < 2; h++) { \ + for (unsigned j = 0; j < 2; j++) lop3s(e, wsel[j], bq[set][(s) * 4u + 2 * h + j], 0, bq[set][(s) * 4u + 2 * h + j], 1, msel, 0xd8u); \ + andi(e, tw, wsel[0], 0, 0xffffu); imadi_d(e, bE, h, wsel[1], 0x10000u, tw); \ + andi(e, tw, wsel[1], 0, 0xffff0000u); shr_d(e, bO, h, wsel[0], 16u); iadd_d(e, bO, h, bO, h, tw); } } while (0) + #define COMPUTE(buf, set, last) do { \ + for (uint32_t s = 0; s < NS; s++) { \ + if (spec->mutant == 1 && (last) && s == NS - 1u) break; \ + BFRAG(set, s); \ + for (uint32_t i0 = 0; i0 < RT; i0 += AQN) { \ + const uint32_t nb = RT - i0 < AQN ? RT - i0 : AQN; \ + for (uint32_t q = 0; q < nb; q++) { uint32_t i = i0 + q, ii = spec->mutant == 3 ? (i ^ 1u) : i; \ + lds128(e, aq[q], la, (buf) + (ii * NS + s) * 512u, q == 0); } \ + for (uint32_t q = 0; q < nb; q++) { const uint32_t x = (i0 + q) * CT; \ + hmma(e, acc[x], aq[q], bE, acc[x], 8); hmma(e, acc[x + 1], aq[q], bO, acc[x + 1], 8); } \ + } \ + } } while (0) + + for (uint32_t x = 0; x < RT * CT; x++) for (unsigned q = 0; q < 4; q++) { BlackwellIRInsn mz = I0(BW_IR_MOV_RZ); mz.dst_vreg = acc[x]; mz.dst_subreg = (uint8_t)q; emit(e, mz, K_FIXED); } + ISSUE(0, 3u, 0u); + consume(e, 3); + STAGE(0u); + imadi(e, cntk, nkb, 0, 1, NOREG); + + /* ---- K loop: one 128-wide block (NCH chunks) per iteration; sets and buffers alternate per chunk (NCH even) ---- */ + const int L_k = here(e); + loop_begin(e); + for (uint32_t c = 0; c < NCH; c++) { + const unsigned cur = c & 1u, nxt = cur ^ 1u; /* set / buffer holding chunk c; the other receives chunk c + 1 */ + const uint32_t cbuf = cur ? BUF : 0u, nbuf = nxt ? BUF : 0u; + if (c + 1u < NCH) { + imadw(e, pb, one, KC * N * 2u, pb); /* B rows of chunk c + 1 */ + ISSUE(nxt, nxt ? 4u : 3u, c + 1u); + } else { + /* the next block's chunk 0: advance only when a block follows (nf = cntk != 1); the last iteration re-reads its own */ + int nf = V(e); if (e->err) return -1; + imadi(e, nf, one, 0, 0xfffffffeu, cntk); shr(e, nf, nf, 0, 31); imadi(e, nf, nf, 0, 0xffffffffu, one); + imadw(e, gx, nf, spec->mutant == 2 ? 0u : 256u, gx); + imadw(e, pb, nf, KC * N * 2u, pb); + ISSUE(nxt, nxt ? 4u : 3u, 0u); + } + COMPUTE(cbuf, cur, c + 1u == NCH); + consume(e, nxt ? 4u : 3u); + STAGE(nbuf); + } + imadi(e, cntk, one, 0, 0xffffffffu, cntk); + isetp_ge_u32(e, cntk, one); + bra_if_p0(e, L_k); + loop_end(e); + #undef ISSUE + #undef STAGE + #undef BFRAG + #undef COMPUTE + + /* ---- epilogue: the HMMA results must have settled. The tile goes out through shared memory in 8-row passes so that every + * warp store writes 128 contiguous bytes: storing straight from the fragment layout (a lane owns 16 bytes per row, one 4-byte + * STG per word) touched 16 half-filled sectors per instruction and cost more than half of the kernel time at K 768 + * (chip probe: the no-store mutant 5 ran 8192x768x768 in 0.150 ms against 0.334 ms). Addresses in fresh registers. ---- */ + nop(e, 15); nop(e, 14); + { + const uint32_t RJ2 = T / SPAN /* rows per read step */, NJ2 = 8u * SPAN / T /* words per thread per pass */; + int tid2 = V(e), cx2 = V(e), cy2 = V(e), lane2 = V(e), g2 = V(e), tq2 = V(e), warp2 = V(e), tab2 = V64(e), ten2 = V64(e), cva2 = V64(e), rk2 = V64(e); + int onee = V(e), p0 = V64(e), pp2 = V64(e), sw[4], sr[4], rd[4]; + for (unsigned w = 0; w < 4; w++) sw[w] = V(e); + for (uint32_t j = 0; j < NJ2; j++) { sr[j] = V(e); rd[j] = V(e); } + if (e->err) return -1; + ldc64(e, tab2, 0x380); + s2r(e, tid2, BW_SR_TID_X); s2r(e, cx2, BW_SR_CTAID_X); s2r(e, cy2, BW_SR_CTAID_Y); + imadw(e, ten2, cy2, OMEGA_TGEMM_TILE_BYTES, tab2); + ldg_wide(e, BW_IR_LDG_E_64, cva2, ten2, 0, udesc, 1); + ldg_wide(e, BW_IR_LDG_E_64, rk2, ten2, 8, udesc, 0); + andi(e, lane2, tid2, 0, 31); shr(e, g2, lane2, 0, 2); andi(e, tq2, lane2, 0, 3); shr(e, warp2, tid2, 0, 5); movi(e, onee, 1); + /* the lane's four slots of a pass: (g * SPAN + warp * 16 + 4 t + w) * 4 (row g of the pass, the warp's columns) */ + imadi(e, tmp, g2, 0, SPAN, NOREG); imadi(e, tmp, warp2, 0, 16u, tmp); imadi(e, tmp, tq2, 0, 4u, tmp); imadi(e, tmp2, tmp, 0, 4u, NOREG); + for (unsigned w = 0; w < 4; w++) imadi(e, sw[w], onee, 0, 4u * w, tmp2); + /* the thread's read slots: word q = tid + T j (consecutive lanes, consecutive words): row q / SPAN = tid / SPAN + j RJ2 */ + for (uint32_t j = 0; j < NJ2; j++) { imadi(e, tmp, onee, 0, j * T, tid2); imadi(e, sr[j], tmp, 0, 4u, NOREG); } + /* p0 = c + ((row0 + tid / SPAN) * N + cx * SPAN + tid % SPAN) * 4; pass (i, h) adds (16 i + 8 h) rows, read step j adds j RJ2 rows */ + shr(e, tmp, tid2, 0, (uint32_t)log2u(SPAN)); iadd(e, tmp, rk2, tmp); imadi(e, tmp, tmp, 0, N, NOREG); + imadi(e, tmp2, cx2, 0, SPAN, tmp); andi(e, tmp, tid2, 0, SPAN - 1u); iadd(e, tmp, tmp, tmp2); imadw(e, p0, tmp, 4u, cva2); + for (uint32_t i = 0; i < RT; i++) for (unsigned h = 0; h < 2; h++) { + if (spec->mutant == 5) continue; /* timing probe only: no output */ + bar_sync(e); /* the previous pass's reads (or the K loop's last LDS) are complete before the slots are rewritten */ + for (unsigned w = 0; w < 4; w++) sts32_sub(e, sw[w], acc[i * CT + (w & 1u)], 2u * h + (w >> 1)); + bar_sync(e); + for (uint32_t j = 0; j < NJ2; j++) { BlackwellIRInsn ld = I0(BW_IR_LDS32); ld.dst_vreg = rd[j]; ld.src1_vreg = sr[j]; emit(e, ld, j == 0 ? K_VAR : K_VAR_MORE); } + imadw(e, pp2, onee, (16u * i + 8u * h) * N * 4u, p0); + for (uint32_t j = 0; j < NJ2; j++) stg(e, pp2, j * RJ2 * N * 4u, rd[j], udesc); + } + } + tail(e); + if (e->err) return -1; + if (prog->count > OMEGA_TGEMM_MAX_INSNS) return -1; + if (omega_bw_regalloc_solve(prog) != 0) return -1; + if (!omega_bw_gpr_declared_ok(omega_bw_gpr_declared(prog->regalloc.peak_gpr_usage), prog->regalloc.peak_gpr_usage) || omega_bw_gpr_declared(prog->regalloc.peak_gpr_usage) > 128u) return -1; + return 0; +} diff --git a/src/omega_blackwell_codegen_tgemm.h b/src/omega_blackwell_codegen_tgemm.h new file mode 100644 index 000000000..abf9d30af --- /dev/null +++ b/src/omega_blackwell_codegen_tgemm.h @@ -0,0 +1,67 @@ +#ifndef OMEGA_BLACKWELL_CODEGEN_TGEMM_H +#define OMEGA_BLACKWELL_CODEGEN_TGEMM_H +/* + * omega_blackwell_codegen_tgemm: device-resident bf16 training GEMM on the tensor cores (trainer lane E1, 2026-10-16). + * New file. C[M][N] (f32, row-major) = A[M][K] (bf16, row-major) x B[K][N] (bf16, row-major): the NN layout of the + * trainer's forward Linear (Y = X W^T with W stored transposed), no per-call host pack. Fragment layout, emitter rules, + * scheduling (ldw_pf scoreboards 3/4, hmma stall 8, nop 15 + nop 14 before the first accumulator read) and the double- + * buffered shared staging are the chip-proven ones of omega_blackwell_codegen_tc2 (OWN30B-L1G-GEMM-1e76e728). + * + * K is walked in 128-wide blocks of four 32-wide chunks. Inside a 32-wide chunk lane t (lane % 4) of every HMMA owns + * k = 8t + {0..7}: HMMA step s (0, 1) of the chunk puts k = 8t + 4s + {0, 1} at fragment positions (2t, 2t + 1) and + * k = 8t + 4s + {2, 3} at (2t + 8, 2t + 9). The 16-term HMMA sum is order independent (tests/bw_hmma_model.h), so any + * consistent lane -> k assignment is exact; this one makes every A row word and every B row word contiguous in memory. + * - A tile (16 rt rows x 32 k): LDG.E.64 pieces (4 bf16 of one row), STS32 x 2 into the lane's fragment slot of the + * staging buffer (per row tile i and step s: 32 lanes x 16 bytes at (i * 2 + s) * 512), BAR.SYNC, LDS.128 per row tile. + * Two buffers of 16 rt x 32 x 2 bytes: 2048 rt bytes of shared (rt 8: 16 KB, the QMD cap). + * - B (K x N, N contiguous): each lane loads its B fragment rows straight from global: per step four LDG.E.64 at rows + * k = 8t + 4s + j, columns n0w + 4 (g / 2) .. + 3 (the lane needs the half word (g % 2) of them, selected with one LOP3 + * per row word; lanes g, g ^ 1 touch the same 8 bytes, so no extra L2 sectors), then IMAD / IMAD.HI.U32 pack the two + * column tiles: tile E = the warp's even physical columns (n0w + 2 g), tile O = the odd ones (n0w + 2 g + 1). + * Two register sets (scoreboards 3 and 4) alternate per chunk so the next chunk's B is in flight during the HMMAs. + * - Epilogue F32: the tile leaves through shared memory in 8-row passes (lane (g, t) parks its words E.c, O.c of row g at the + * pass columns n0w + 4 t .. + 3, BAR.SYNC, then thread tid reads words tid + T j and stores them: every warp STG writes 128 + * contiguous bytes). Storing straight from the fragment layout with 4-byte STG touched 16 half-filled sectors per + * instruction and cost more than half of the kernel time at K 768 (chip probe, no-store mutant 5). Store immediates stay + * under the encoder's 2^23 for N up to 2^17 (50304: the lm_head gradient). + * + * Tile table entry (32 bytes, ctaid.y): { c_va u64 (output base for this tile's K part), row0 u32, kb0 u32 (first 128-block), + * nkb u32 (blocks, >= 1), pad u32, pad u64 }. Constant bank 0 (cbank + 0x380): tiles u64, a u64, b u64. + * Grid: grid_x = n / span (span = warps * 8 * ct), grid_y = tiles; CTA 32 * warps threads; rows of a tile are always + * 16 rt (the caller pads M to a multiple of the tile height). + * mutant (tests only): 1 drops HMMA step 1 of the last chunk of every block, 2 never advances the A pointer to the next + * block, 3 row tile i reads tile i ^ 1, 4 swaps the column parity (tile E takes the odd columns), 5 stores nothing (timing probe). + */ +#include +#include "omega_blackwell_codegen.h" + +#ifdef __cplusplus +extern "C" { +#endif +enum { OMEGA_TGEMM_LAYOUT_NN = 0 }; +enum { OMEGA_TGEMM_EPI_F32 = 0 }; +typedef struct { + uint32_t k; /* multiple of 128, 128 .. 65536 (the per-tile K range is kb0 .. kb0 + nkb blocks of 128) */ + uint32_t n; /* output width, a multiple of span, < 2^17 */ + uint32_t rt; /* row tiles of 16 per CTA: 2, 4 or 8 */ + uint32_t ct; /* column tiles of 8 per warp: 2 */ + uint32_t warps; /* 8 or 16 */ + uint32_t kc; /* k per chunk: 32 */ + uint32_t aqn; /* A fragments in flight: 1 or 2 */ + uint32_t layout; /* OMEGA_TGEMM_LAYOUT_* */ + uint32_t epi; /* OMEGA_TGEMM_EPI_* */ + int mutant; +} OmegaTgemmSpec; +#define OMEGA_TGEMM_ARGS_WORDS 6u +#define OMEGA_TGEMM_TILE_BYTES 32u +#define OMEGA_TGEMM_MAX_INSNS 1000u +int omega_tgemm_spec_ok(const OmegaTgemmSpec *s); +uint32_t omega_tgemm_shared_bytes(const OmegaTgemmSpec *s); +uint32_t omega_tgemm_span(const OmegaTgemmSpec *s); +uint32_t omega_tgemm_bm(const OmegaTgemmSpec *s); /* rows per tile */ +/* -1: refused (spec, emitter, allocator, or more than OMEGA_TGEMM_MAX_INSNS instructions / 128 declared registers) */ +int omega_blackwell_codegen_tgemm_prog(const OmegaTgemmSpec *s, BlackwellIRProgram *prog); +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/omega_bw_em.h b/src/omega_bw_em.h index e72c743e0..e43dc0db5 100644 --- a/src/omega_bw_em.h +++ b/src/omega_bw_em.h @@ -140,6 +140,6 @@ static void nop(Em *e, uint32_t stall) { } static void lop3(Em *e, int d, int a, int b, int c, uint32_t lut) { BlackwellIRInsn i = I0(BW_IR_LOP3_LUT); i.dst_vreg = d; i.src1_vreg = a; i.src2_vreg = b; i.src3_vreg = c; i.imm = lut; emit(e, i, K_FIXED); } static void iadd(Em *e, int d, int a, int b) { BlackwellIRInsn i = I0(BW_IR_IADD3); i.dst_vreg = d; i.src1_vreg = a; i.src2_vreg = b; emit(e, i, K_FIXED); } -static void shfl_bfly(Em *e, int d, int a, uint32_t lane) { shfl_down(e, d, a, OMEGA_TC_MARK_BFLY | (lane & 31u)); } -static void f2fp_pack(Em *e, int d, int hi, int lo) { BlackwellIRInsn i = I0(BW_IR_FMNMX_MAX); i.dst_vreg = d; i.src1_vreg = hi; i.src2_vreg = lo; i.imm = OMEGA_TC_MARK_F2FP; emit(e, i, K_FIXED); } +static void shfl_bfly(Em *e, int d, int a, uint32_t lane) { BlackwellIRInsn i = I0(BW_IR_SHFL_BFLY); i.dst_vreg = d; i.src1_vreg = a; i.imm = lane & 31u; emit(e, i, K_VAR); } +static void f2fp_pack(Em *e, int d, int hi, int lo) { BlackwellIRInsn i = I0(BW_IR_F2FP_BF16_PACK); i.dst_vreg = d; i.src1_vreg = hi; i.src2_vreg = lo; emit(e, i, K_FIXED); } #endif diff --git a/src/omega_gpu_decode_graph.c b/src/omega_gpu_decode_graph.c index 5a07c7bb6..e84b5c7da 100644 --- a/src/omega_gpu_decode_graph.c +++ b/src/omega_gpu_decode_graph.c @@ -226,7 +226,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); diff --git a/src/omega_gpu_fp8_api.c b/src/omega_gpu_fp8_api.c index 199dab47a..597ea5c07 100644 --- a/src/omega_gpu_fp8_api.c +++ b/src/omega_gpu_fp8_api.c @@ -88,7 +88,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) ---- */ @@ -267,12 +267,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/src/omega_gpu_fp8_pack.c b/src/omega_gpu_fp8_pack.c index 2b67ea271..4c41db560 100644 --- a/src/omega_gpu_fp8_pack.c +++ b/src/omega_gpu_fp8_pack.c @@ -7,7 +7,8 @@ #include "omega_gpu_fp8_api.h" #include "omega_blackwell_codegen_moe.h" #include "omega_blackwell_matmul.h" -#include +#include "omega_gpu_hostmath.h" /* omega_hostmath_pow2f: exact 2^e without libm (omega#471) */ +#include /* NAN, fabsf, fabs: compiler builtins, no libm reference (checked by test-gpu-libm-free) */ #include float omega_fp8_e4m3_ref(uint8_t b) { @@ -15,8 +16,8 @@ float omega_fp8_e4m3_ref(uint8_t b) { float mantissa = (float)(b & 0x07); float sign = (b & 0x80) ? -1.0f : 1.0f; if (exponent == 0x0f && (b & 0x07) == 0x07) return NAN; /* 0x7f / 0xff */ - if (exponent == 0) return sign * mantissa * ldexpf(1.0f, -9); - return sign * (1.0f + mantissa / 8.0f) * ldexpf(1.0f, exponent - 7); + if (exponent == 0) return sign * mantissa * omega_hostmath_pow2f(-9); + return sign * (1.0f + mantissa / 8.0f) * omega_hostmath_pow2f(exponent - 7); } uint32_t omega_fp8_e4m3_kernel_bits(uint8_t b) { @@ -33,7 +34,7 @@ size_t omega_fp8_pack_scan_nan(const uint8_t *w, size_t count, size_t *first) { } int omega_fp8_pack_scales(const uint16_t *bf16, size_t count, float *out, int mutant_no_fold) { - const float fold = mutant_no_fold ? 1.0f : ldexpf(1.0f, OMEGA_FP8_SCALE_EXP); + const float fold = mutant_no_fold ? 1.0f : omega_hostmath_pow2f(OMEGA_FP8_SCALE_EXP); for (size_t i = 0; i < count; i++) { float s = omega_bf16_to_fp32(bf16[i]); if (!(fabsf(s) <= 3.0e38f)) return -1; /* NaN or inf scale */ @@ -45,12 +46,12 @@ int omega_fp8_pack_scales(const uint16_t *bf16, size_t count, float *out, int mu } void omega_fp8_pack_x_f32(const float *x, uint32_t k, float *out) { - const float fold = ldexpf(1.0f, OMEGA_FP8_X_EXP); + const float fold = omega_hostmath_pow2f(OMEGA_FP8_X_EXP); for (uint32_t i = 0; i < k; i++) out[i] = x[i] * fold; } void omega_fp8_pack_x_bf16(const uint16_t *x, uint32_t k, float *out) { - const float fold = ldexpf(1.0f, OMEGA_FP8_X_EXP); + const float fold = omega_hostmath_pow2f(OMEGA_FP8_X_EXP); for (uint32_t i = 0; i < k; i++) out[i] = omega_bf16_to_fp32(x[i]) * fold; } diff --git a/src/omega_gpu_hostmath.c b/src/omega_gpu_hostmath.c index e042023c9..403780f4f 100644 --- a/src/omega_gpu_hostmath.c +++ b/src/omega_gpu_hostmath.c @@ -80,3 +80,14 @@ void omega_hostmath_sincos(double a, double *s, double *c) { default: *s = -cr; *c = sr; break; } } + +float omega_hostmath_pow2f(int e) { + uint32_t u; + if (e > 127) u = 0x7f800000u; /* +inf, as ldexpf overflows */ + else if (e >= -126) u = (uint32_t)(e + 127) << 23; /* normal: biased exponent, zero mantissa */ + else if (e >= -149) u = (uint32_t)1 << (e + 149); /* subnormal: one mantissa bit */ + else u = 0; /* 2^-150 and below round to +0 (ties to even) */ + float f; + memcpy(&f, &u, 4); + return f; +} diff --git a/src/omega_gpu_hostmath.h b/src/omega_gpu_hostmath.h index 50f0ecef5..6430e614b 100644 --- a/src/omega_gpu_hostmath.h +++ b/src/omega_gpu_hostmath.h @@ -12,9 +12,13 @@ * pow(b, e): b > 0 finite; exp(e * log(b)). Relative error about |e * log b| * 2^-52. * sincos(a): valid for |a| < 2^20 * pi/2 (about 1.6e6; the RoPE table needs pos < 65536). Three-part * Cody-Waite reduction with the fdlibm pi/2 pieces, series to r^16. Absolute error about 1e-16. + * pow2f(e): the float 2^e for any int e, built from its bit pattern (omega#471): +inf above 127, the + * subnormal 2^e for -149 <= e < -126, +0 below -149. Bit-identical to ldexpf(1.0f, e) for every + * int e (tests/gpu_libm_free_test.c checks -400..400 plus INT_MIN and INT_MAX). */ double omega_hostmath_log(double x); double omega_hostmath_exp(double y); double omega_hostmath_pow(double base, double e); void omega_hostmath_sincos(double a, double *s, double *c); +float omega_hostmath_pow2f(int e); #endif diff --git a/src/omega_gpu_prefill.c b/src/omega_gpu_prefill.c index 9cea0025b..7e4ffa61f 100644 --- a/src/omega_gpu_prefill.c +++ b/src/omega_gpu_prefill.c @@ -91,7 +91,6 @@ int omega_gpu_pf_kernel_locked(const OmegaPfKey *key, OmegaPfGen gen, OmegaPfKer if (omega_gpu_session_alloc_code(need, &code) != 0) { omega_gpu_host_free(prog); return OMEGA_GPU_PF_CHIP_FAIL; } OmegaBlackwellKernel kernel; cg = omega_blackwell_kernel_encode_into(prog, code.cpu, need, &kernel); - if (cg == 0 && omega_tc_patch_code(prog, code.cpu, need) < 0) cg = -1; if (cg == 0 && omega_qmma_patch_code(prog, code.cpu, need) < 0) cg = -1; omega_gpu_host_free(prog); if (cg != 0 || kernel.code_size != need) { omega_gpu_session_free(&code); omega_gpu_session_set_error("prefill encode failed"); return OMEGA_GPU_PF_CODEGEN_FAIL; } diff --git a/src/omega_gpu_prefill_attn_api.c b/src/omega_gpu_prefill_attn_api.c index 9bef1d426..e3c934a6f 100644 --- a/src/omega_gpu_prefill_attn_api.c +++ b/src/omega_gpu_prefill_attn_api.c @@ -2,8 +2,6 @@ * omega_gpu_prefill_attn_api.c: chunked launches of the tensor-core causal prefill attention (see the header). * Session use mirrors omega_gpu_decode_attn_api.c: buffers from omega_gpu_session_alloc (GPU-uncached, host-visible), * sync_to_gpu after host writes, sync_to_cpu before host reads, one omega_gpu_session_launch per chunk. - * The kernel uses the SHFL.BFLY / F2FP placeholders of omega_blackwell_codegen_tc.h: the code is patched after encoding - * and the patch count must equal the program's placeholder count. */ #include "omega_gpu_prefill_attn_api.h" #include "omega_blackwell_codegen_tc.h" @@ -128,18 +126,16 @@ static int copy_locked(uint64_t dst, uint64_t src, size_t bytes, uint64_t *ns) { } #endif -size_t omega_gpu_prefill_attn_encode(const OmegaPrefillAttnSpec *spec, uint8_t *code, size_t cap, uint32_t *gprs, int *patched) { +size_t omega_gpu_prefill_attn_encode(const OmegaPrefillAttnSpec *spec, uint8_t *code, size_t cap, uint32_t *gprs) { BlackwellIRProgram *prog = omega_gpu_host_calloc(1, sizeof *prog); if (!prog) return 0; size_t need = 0; if (omega_blackwell_codegen_prefill_attn_prog(spec, prog) == 0) need = omega_bw_program_code_bytes(prog); OmegaBlackwellKernel k; if (need == 0 || need > cap || omega_blackwell_kernel_encode_into(prog, code, cap, &k) != 0) { omega_gpu_host_free(prog); return 0; } - int np = omega_tc_patch_code(prog, code, need); if (gprs) *gprs = k.gpr_count; - if (patched) *patched = np; omega_gpu_host_free(prog); - return np < 0 ? 0 : need; + return need; } static int kernel_for(const OmegaPrefillAttnSpec *spec, Slot **out, bool *hit) { @@ -153,19 +149,12 @@ static int kernel_for(const OmegaPrefillAttnSpec *spec, Slot **out, bool *hit) { size_t need = cg == 0 ? omega_bw_program_code_bytes(prog) : 0; if (cg != 0 || need == 0) { omega_gpu_host_free(prog); omega_gpu_session_set_error("prefill attn codegen refused the spec"); return OMEGA_GPU_DATTN_CODEGEN_FAIL; } if ((uint64_t)32u * spec->warps * omega_bw_gpr_declared(prog->regalloc.peak_gpr_usage) > 65536u) { omega_gpu_host_free(prog); omega_gpu_session_set_error("prefill attn: register file"); return OMEGA_GPU_DATTN_TOO_LARGE; } - uint32_t expect = 0; - for (size_t i = 0; i < prog->count; i++) { - const BlackwellIRInsn *in = &prog->insns[i]; - if ((in->op == BW_IR_SHFL_DOWN && (in->imm & OMEGA_TC_MARK_BFLY)) || (in->op == BW_IR_FMNMX_MAX && in->imm == OMEGA_TC_MARK_F2FP)) expect++; - } OmegaGpuMem code; if (omega_gpu_session_alloc_code(need, &code) != 0) { omega_gpu_host_free(prog); return OMEGA_GPU_DATTN_CHIP_FAIL; } OmegaBlackwellKernel kernel; cg = omega_blackwell_kernel_encode_into(prog, code.cpu, need, &kernel); - int np = cg == 0 ? omega_tc_patch_code(prog, code.cpu, need) : -1; omega_gpu_host_free(prog); if (cg != 0 || !kernel.code || kernel.code_size != need) { omega_gpu_session_free(&code); omega_gpu_session_set_error("prefill attn encode"); return OMEGA_GPU_DATTN_CODEGEN_FAIL; } - if (np < 0 || (uint32_t)np != expect) { omega_gpu_session_free(&code); omega_gpu_session_set_error("prefill attn: placeholder patch count mismatch"); return OMEGA_GPU_DATTN_CODEGEN_FAIL; } if (omega_gpu_session_sync_to_gpu(&code) != 0) { omega_gpu_session_free(&code); return OMEGA_GPU_DATTN_CHIP_FAIL; } memset(s, 0, sizeof *s); s->valid = true; s->spec = *spec; s->kernel = kernel; s->code = code; diff --git a/src/omega_gpu_prefill_attn_api.h b/src/omega_gpu_prefill_attn_api.h index f241a7f4d..cc490ff1f 100644 --- a/src/omega_gpu_prefill_attn_api.h +++ b/src/omega_gpu_prefill_attn_api.h @@ -72,7 +72,7 @@ int omega_gpu_prefill_attn_kv_mirror_available(void); uint32_t omega_gpu_prefill_attn_test_launch_ns(uint64_t *ns, uint32_t cap); #define OMEGA_GPU_PATTN_HOST_PASS 1024u /* host entry: tokens per staged pass in split mode */ -/* host: build + encode + patch the kernel for a spec into code (cap bytes); returns the code size or 0 (tests) */ -size_t omega_gpu_prefill_attn_encode(const OmegaPrefillAttnSpec *spec, uint8_t *code, size_t cap, uint32_t *gprs, int *patched); +/* host: build + encode the kernel for a spec into code (cap bytes); returns the code size or 0 (tests) */ +size_t omega_gpu_prefill_attn_encode(const OmegaPrefillAttnSpec *spec, uint8_t *code, size_t cap, uint32_t *gprs); #endif diff --git a/src/omega_gpu_tgemm_api.c b/src/omega_gpu_tgemm_api.c new file mode 100644 index 000000000..4c8021a57 --- /dev/null +++ b/src/omega_gpu_tgemm_api.c @@ -0,0 +1,82 @@ +/* omega_gpu_tgemm_api.c: the trainer's device-resident bf16 GEMM (lane E1, cut 1). See the header. */ +#include "omega_gpu_tgemm_api.h" +#include "omega_gpu_prefill.h" +#include + +#define TG_TIMEOUT_MS 20000u /* the prefill module's launch limits (private there; same values) */ +#define TG_SPIN_US 200000u +static struct { uint32_t rt, warps, aqn; int mutant; OmegaGpuMem tab; } g; +void omega_gpu_tgemm_set_shape(uint32_t rt, uint32_t warps, uint32_t aqn) { g.rt = rt; g.warps = warps; g.aqn = aqn; } +void omega_gpu_tgemm_test_set_mutant(int m) { g.mutant = m; } +uint32_t omega_gpu_tgemm_bm(uint32_t n) { if (g.rt) return 16u * g.rt; const uint32_t w = g.warps ? g.warps : (n % 256u ? 8u : 16u); return w == 16u ? 128u : 64u; } /* mirrors omega_gpu_tgemm_spec */ +_Static_assert(sizeof(OmegaTgemmTile) == OMEGA_TGEMM_TILE_BYTES, "tile entry"); + +int omega_gpu_tgemm_spec(const OmegaTgemmCall *c, OmegaTgemmSpec *out) { + if (!c || !out) return OMEGA_GPU_PF_BAD_ARGS; + OmegaTgemmSpec s; memset(&s, 0, sizeof s); + s.k = c->k; s.n = c->n; s.rt = g.rt ? g.rt : 8u; s.ct = 2; s.kc = 32; s.aqn = g.aqn ? g.aqn : 1u; s.layout = c->layout; s.epi = c->epi; s.mutant = g.mutant; + s.warps = g.warps ? g.warps : (c->n % 256u ? 8u : 16u); + if (!g.rt) s.rt = s.warps == 16u ? 8u : 4u; /* chip sweep TGEMM-CUT1: rt 8 x 16 warps fastest on every gate shape; rt 8 x 8 warps does not fit the register file */ + if (!omega_tgemm_spec_ok(&s)) return OMEGA_GPU_PF_BAD_ARGS; + if (c->m == 0 || c->m % omega_tgemm_bm(&s) || !c->a_va || !c->b_va || !c->c_va) return OMEGA_GPU_PF_BAD_ARGS; + if (c->m / omega_tgemm_bm(&s) > 65535u) return OMEGA_GPU_PF_TOO_LARGE; + if ((uint64_t)c->m * c->n >= (1ull << 32)) return OMEGA_GPU_PF_TOO_LARGE; /* the kernel forms row * n + col in 32 bits before the wide scale (review of PR 487) */ + *out = s; + return OMEGA_GPU_PF_OK; +} + +uint32_t omega_gpu_tgemm_tiles(const OmegaTgemmCall *c, OmegaTgemmTile *tab, uint32_t max) { + OmegaTgemmSpec s; + if (!tab || omega_gpu_tgemm_spec(c, &s) != OMEGA_GPU_PF_OK) return 0; + const uint32_t bm = omega_tgemm_bm(&s), nt = c->m / bm; + if (nt > max) return 0; + for (uint32_t t = 0; t < nt; t++) { tab[t].c_va = c->c_va; tab[t].row0 = t * bm; tab[t].kb0 = 0; tab[t].nkb = c->k / 128u; tab[t].pad = 0; tab[t].pad2 = 0; } + return nt; +} + +static int gen_tgemm(const OmegaPfKey *key, void *prog) { OmegaTgemmSpec s; memcpy(&s, key->words, sizeof s); return omega_blackwell_codegen_tgemm_prog(&s, prog); } + +int omega_gpu_tgemm_fill_launch_locked(const OmegaTgemmCall *c, uint64_t tiles_va, uint32_t ntiles, OmegaGpuLaunch *L, uint32_t *args) { + OmegaTgemmSpec s; + if (!L || !args || !tiles_va || !ntiles) return OMEGA_GPU_PF_BAD_ARGS; + int rc = omega_gpu_tgemm_spec(c, &s); + if (rc != OMEGA_GPU_PF_OK) return rc; + OmegaPfKey key; memset(&key, 0, sizeof key); key.kind = OMEGA_TGEMM_KIND; memcpy(key.words, &s, sizeof s); + _Static_assert(sizeof(OmegaTgemmSpec) <= sizeof key.words, "spec fits the key"); + OmegaPfKernel k; + rc = omega_gpu_pf_kernel_locked(&key, gen_tgemm, &k); + if (rc != OMEGA_GPU_PF_OK) return rc; + const uint32_t threads = 32u * s.warps; + if ((uint64_t)threads * k.gpr_declared > 65536u) return OMEGA_GPU_PF_TOO_LARGE; + if (!omega_bw_gpr_declared_ok(k.gpr_declared, k.gpr_peak)) return OMEGA_GPU_PF_CHIP_FAIL; + const uint64_t va[3] = { tiles_va, c->a_va, c->b_va }; + for (int i = 0; i < 3; i++) { args[2 * i] = (uint32_t)va[i]; args[2 * i + 1] = (uint32_t)(va[i] >> 32); } + memset(L, 0, sizeof *L); + L->code_va = k.code_va; L->gpr_count = k.gpr_declared; L->threads_x = threads; L->threads_y = 1; + L->grid_x = c->n / omega_tgemm_span(&s); L->grid_y = ntiles; L->num_elements = (size_t)threads * L->grid_x * L->grid_y; + L->args = args; L->n_args = OMEGA_TGEMM_ARGS_WORDS; L->timeout_ms = TG_TIMEOUT_MS; L->shared_bytes = omega_tgemm_shared_bytes(&s); L->spin_us = TG_SPIN_US; + return OMEGA_GPU_PF_OK; +} + +int omega_gpu_tgemm(const OmegaTgemmCall *c, uint64_t *ns) { + OmegaTgemmSpec s; + int rc = omega_gpu_tgemm_spec(c, &s); + if (rc != OMEGA_GPU_PF_OK) return rc; + const uint32_t nt = c->m / omega_tgemm_bm(&s); + const size_t need = ((size_t)nt * OMEGA_TGEMM_TILE_BYTES + 4095u) & ~(size_t)4095u; + OmegaGpuLaunch L; uint32_t args[OMEGA_TGEMM_ARGS_WORDS]; + /* the module table is shared state: (re)built only under the session lock, which also serializes the launch that reads it */ + omega_gpu_session_lock(); + rc = omega_gpu_pf_open_locked(); + if (rc == OMEGA_GPU_PF_OK && g.tab.size < need) { omega_gpu_session_free(&g.tab); if (omega_gpu_session_alloc(need, &g.tab) != 0) rc = OMEGA_GPU_PF_CHIP_FAIL; } + if (rc == OMEGA_GPU_PF_OK && omega_gpu_tgemm_tiles(c, g.tab.cpu, nt) != nt) rc = OMEGA_GPU_PF_BAD_ARGS; + if (rc == OMEGA_GPU_PF_OK && omega_gpu_session_sync_to_gpu(&g.tab) != 0) rc = OMEGA_GPU_PF_CHIP_FAIL; + if (rc == OMEGA_GPU_PF_OK) rc = omega_gpu_tgemm_fill_launch_locked(c, g.tab.va, nt, &L, args); + if (rc == OMEGA_GPU_PF_OK) { + uint64_t t = 0; + if (omega_gpu_session_launch(&L, &t, NULL) != 0) rc = OMEGA_GPU_PF_CHIP_FAIL; + else if (ns) *ns += t; + } + omega_gpu_session_unlock(); + return rc; +} diff --git a/src/omega_gpu_tgemm_api.h b/src/omega_gpu_tgemm_api.h new file mode 100644 index 000000000..ab8f39a72 --- /dev/null +++ b/src/omega_gpu_tgemm_api.h @@ -0,0 +1,48 @@ +#ifndef OMEGA_GPU_TGEMM_API_H +#define OMEGA_GPU_TGEMM_API_H +/* + * omega_gpu_tgemm_api: the trainer's device-resident bf16 GEMM (lane E1, 2026-10-16). New file. + * C[m][n] f32 = A[m][k] bf16 x B[k][n] bf16, all three row-major and already resident on the GPU (no host pack per call). + * Kernels: omega_blackwell_codegen_tgemm.h, cached through the prefill module's resident-kernel cache (omega_gpu_prefill.h, + * kind OMEGA_TGEMM_KIND). Return codes are the prefill module's (OMEGA_GPU_PF_OK, _BAD_ARGS, _TOO_LARGE, _CHIP_FAIL). + * Memory rule (trainer plan R-8): buffers from omega_gpu_pf_alloc_dev are GPU-cached and must never be read or written by the + * CPU; the tile table is a host (uncached) buffer the CPU fills and the session syncs. + * Limits: m a multiple of the tile height (omega_gpu_tgemm_bm), n a multiple of the span (warps * 16), k a multiple of 128, + * m / bm <= 65535 tiles, m * n < 2^32 (32-bit row arithmetic in the kernel). omega_gpu_tgemm serializes on the session lock; the + * module's tile table is rebuilt under it. + */ +#include +#include "omega_gpu_session.h" +#include "omega_blackwell_codegen_tgemm.h" + +#ifdef __cplusplus +extern "C" { +#endif +#define OMEGA_TGEMM_KIND 0x60u +typedef struct { + uint32_t layout; /* OMEGA_TGEMM_LAYOUT_* */ + uint32_t epi; /* OMEGA_TGEMM_EPI_* */ + uint32_t m, n, k; + uint64_t a_va, b_va, c_va; +} OmegaTgemmCall; +typedef struct { uint64_t c_va; uint32_t row0, kb0, nkb, pad; uint64_t pad2; } OmegaTgemmTile; + +/* the kernel spec the current knobs pick for a call (BAD_ARGS when the call cannot be served) */ +int omega_gpu_tgemm_spec(const OmegaTgemmCall *c, OmegaTgemmSpec *out); +uint32_t omega_gpu_tgemm_bm(uint32_t n); /* rows per tile the current knobs pick for width n (what m must be a multiple of) */ +/* tile table for a call: one entry per bm rows; returns the count (0: refused or more than max) */ +uint32_t omega_gpu_tgemm_tiles(const OmegaTgemmCall *c, OmegaTgemmTile *tab, uint32_t max); +/* synchronous: builds the table in a module-owned host buffer, launches, waits; chip ns added to *ns when given */ +int omega_gpu_tgemm(const OmegaTgemmCall *c, uint64_t *ns); +/* non-blocking: lock held and device open (omega_gpu_pf_open_locked); fills *L for omega_gpu_cmdlist_add with the resident + * kernel, the grid and args[OMEGA_TGEMM_ARGS_WORDS] (the caller's array; L->args points at it, so it must outlive the add). + * tiles_va: a GPU-visible table of ntiles entries already synced. Caller-built entries must have nkb >= 1 (the kernel's block + * counter is unsigned: nkb 0 would run until the timeout) and kb0 * 128 * n < 2^32 (32-bit row arithmetic). */ +int omega_gpu_tgemm_fill_launch_locked(const OmegaTgemmCall *c, uint64_t tiles_va, uint32_t ntiles, OmegaGpuLaunch *L, uint32_t *args); +/* knobs: rt (2/4/8), warps (8/16), aqn (1/2); 0 keeps the default (rt 4, warps 16, aqn 1; warps 8 when n % 256 != 0) */ +void omega_gpu_tgemm_set_shape(uint32_t rt, uint32_t warps, uint32_t aqn); +void omega_gpu_tgemm_test_set_mutant(int m); +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/visor/.crumb b/src/visor/.crumb index d94290b61..2cd4a3cdb 100644 --- a/src/visor/.crumb +++ b/src/visor/.crumb @@ -14,20 +14,20 @@ "children": [ { "digest": "698c7acaafd2fdfc36c30117f7cda86aaacb21a3333d6a6f737a3bed1c990761", - "last_commit": "a56d21c", + "last_commit": "a56d21c1", "name": "rx", "purpose": "Directory src/visor/rx. Purpose not yet described by a human." } ], "children_root": "sha256:426a1b15679ed802080b03079613c322df3821181536f0f66596d50c63a2f7cb", - "compiled_at": "2026-10-04T13:47:05Z", + "compiled_at": "2026-10-17T00:22:30Z", "compiler": "crumb-compile/1", - "digest": "sha256:daf5e5e90c1ccb4c089220a6545844dbe4078a233f1777e8145b74f1bf5dd5fe", + "digest": "sha256:11575b0cfcbad20d6128d1b5c18a4bd691877ad970fba9f03b0df5665e3fb75f", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 21, - "generated_at_commit": "834ee93e4314a42c1127a2fcda8b29cf3b511245", - "source_tree": "sha256:a1963f6ba709fb4f1c6175371d26b0f5a8de6d51809035b7320204c2908c2d08" + "generated_at_commit": "3aaa2d879f6592bdd6fa31823820879a4fed48f0", + "source_tree": "sha256:083843b6110f98e7c70f75dc2a6e584bca081b1f239cc717210f6cd64ee9fbf9" }, "owner_lane": "", "provenance": { diff --git a/src/visor/visor_evidence.c b/src/visor/visor_evidence.c index 609aa7071..77bfe94ba 100644 --- a/src/visor/visor_evidence.c +++ b/src/visor/visor_evidence.c @@ -441,11 +441,29 @@ int visor_evidence_load(const char *path, VisorEvidenceRecord *out) { /* ------------------------------------------------------------------ */ /* Directory walk (sorted, deterministic) */ /* ------------------------------------------------------------------ */ -#define VISOR_EVIDENCE_MAX_FILES 1024 -static char g_paths[VISOR_EVIDENCE_MAX_FILES][256]; -static size_t g_npaths; +/* omega#404: the walk keeps every regular file (it used to stop at 1024 in readdir order, so with a large evidence/ + * tree the verdict depended on the filesystem). The list grows on the heap and is sorted after the walk, so the + * result is the same for any directory order. VISOR_EVIDENCE_MAX_FILES is only a runaway guard far above any real + * tree (11078 files at 2026-10-16); reaching it, or failing to grow the list, marks the view truncated. */ +#define VISOR_EVIDENCE_MAX_FILES (1u << 20) +typedef char VisorPath[256]; +static VisorPath *g_paths; +static size_t g_npaths, g_paths_cap; static bool g_paths_overflow; +static bool push_path(const char *p) { + if (g_npaths >= VISOR_EVIDENCE_MAX_FILES) return false; + if (g_npaths == g_paths_cap) { + size_t cap = g_paths_cap ? g_paths_cap * 2 : 1024; + VisorPath *grown = realloc(g_paths, cap * sizeof(VisorPath)); + if (!grown) return false; + g_paths = grown; + g_paths_cap = cap; + } + memcpy(g_paths[g_npaths++], p, sizeof(VisorPath)); + return true; +} + static void walk(const char *dir, int depth) { if (depth > 8) return; DIR *d = opendir(dir); @@ -460,8 +478,7 @@ static void walk(const char *dir, int depth) { if (lstat(p, &st) != 0) continue; if (S_ISDIR(st.st_mode)) { walk(p, depth + 1); continue; } if (!S_ISREG(st.st_mode)) continue; /* symlinks and devices are not followed */ - if (g_npaths >= VISOR_EVIDENCE_MAX_FILES) { g_paths_overflow = true; continue; } - memcpy(g_paths[g_npaths++], p, sizeof(p)); + if (!push_path(p)) g_paths_overflow = true; } closedir(d); } @@ -474,7 +491,7 @@ static int collect(const char *root) { g_npaths = 0; g_paths_overflow = false; walk(root, 0); - qsort(g_paths, g_npaths, sizeof(g_paths[0]), cmp_path); + if (g_npaths > 1) qsort(g_paths, g_npaths, sizeof(g_paths[0]), cmp_path); return 0; } diff --git a/tests/.crumb b/tests/.crumb index bd5535a8b..0f6fb0d54 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -169,8 +169,8 @@ "purpose": "Directory tests/estimation. Purpose not yet described by a human." }, { - "digest": "de2bc4e310a257dbd21cc5c9624641b137b1b4487d8876cb52469aea2af5b904", - "last_commit": "3108fc2f", + "digest": "404b5b92d56766565a54dba73720cda8b6a6f2dcf155764d1a2dc47457d4c559", + "last_commit": "0e7bcb60", "name": "fabric", "purpose": "Directory tests/fabric. Purpose not yet described by a human." }, @@ -289,21 +289,21 @@ "purpose": "Directory tests/turing. Purpose not yet described by a human." }, { - "digest": "3f19e3034ff999211cb13ab8995ca6c38d0d8e1f5bfbbbd621caaa08412d3f1f", - "last_commit": "fed4f077", + "digest": "a4bd83d8b29b76464c0ac4be84bd12097b14d1164dfd84b63acf57cc2a6d1ab0", + "last_commit": "31e40e29", "name": "visor", "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], - "children_root": "sha256:ddc3618190458bc5073e3bee67ffccc68a2ee9f065f2cb0d86545386a29fddf8", - "compiled_at": "2026-10-16T19:04:20Z", + "children_root": "sha256:97df402aad3a96d8252ce4dbb7d3462c933ba16d54b1cef613548ec2e174fadd", + "compiled_at": "2026-10-20T20:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:4eb9d4d76234448c0ed691f0aeb9c90d785f8a47b1b1291d728bbe3e1509dc10", + "digest": "sha256:e443c7f6ef7d29a6d70c4aa0cb9193678f8a9a7bd49704167061d60dfaf707ca", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", - "files": 1270, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:e6c4f0021d383ba2e59da0d85d06a0b98170f6d188289c891b5745200548e6fc" + "files": 1336, + "generated_at_commit": "738552e3f036b757e740f1dbfa1c4e7de069f63c", + "source_tree": "sha256:222ed767ace3be7cd0efa0a112bfc80c82cdbd3a6464a8b948767fdd994eee96" }, "owner_lane": "", "provenance": { diff --git a/tests/bw_mufu_ftz.h b/tests/bw_mufu_ftz.h new file mode 100644 index 000000000..e1263c4c6 --- /dev/null +++ b/tests/bw_mufu_ftz.h @@ -0,0 +1,34 @@ +/* bw_mufu_ftz.h: the GB10 MUFU unit's flush-to-zero rule, shared by every host model of it (omega #462). + * + * MUFU (the SASS EX2 / RCP / RSQ unit) flushes a subnormal result to a sign-preserving zero. Chip-observed on GB10: the + * SwiGLU reciprocal 1 / (2^t + 1) for t in (126, 128) came back as +-0 on all 101 of 101 differing elements (evidence + * OWN30B-L1G-PFGEMM-SWIGLU-FTZ-df9bd9c4, gpu_pfgemm_test host red test). Doc-inferred, not separately chip-observed: the + * input flush and the EX2 / RSQ cases follow the same rule, PTX ISA 9.7.3.13 (rcp) and 9.7.3.21 (ex2) "flushes subnormal + * inputs and results to sign-preserving zero" for the .ftz form, which is what the bare MUFU we emit is (the non-ftz PTX + * variants are ptxas sequences around MUFU; NVIDIA publishes no SASS semantics). Limit: the chip's MUFU is approximate + * (RCP 1 ulp, EX2 2 ulp), the model flushes a correctly rounded IEEE result, so right at the subnormal boundary the two + * can disagree 0 versus nonzero. + * + * Users: tests/bw_warp_sim.h, bw_warp_sim_k.h, bw_warp_sim_pa.h, bw_warp_sim_tc.h (MUFU cases), the attention test's own + * per-thread simulator (gpu_attention_test.c) and the pfgemm / qgemm SwiGLU host references. omega_numeric.c has its own + * ftz() on the library side. Self-contained (no simulator state) so any of them can include it, in any order. */ +#ifndef BW_MUFU_FTZ_H +#define BW_MUFU_FTZ_H + +#include +#include +#include + +/* A subnormal (exponent field 0, mantissa nonzero) becomes a zero of the same sign; zeros, normals, inf and NaN pass. */ +static inline float ws_mufu_ftz(float f) { + uint32_t u; memcpy(&u, &f, 4); + if ((u & 0x7f800000u) == 0u) u &= 0x80000000u; + memcpy(&f, &u, 4); + return f; +} +/* The three MUFU functions the codegen emits: input flushed, IEEE f32 function, result flushed. */ +static inline float ws_mufu_ex2(float x) { return ws_mufu_ftz(exp2f(ws_mufu_ftz(x))); } +static inline float ws_mufu_rcp(float x) { return ws_mufu_ftz(1.0f / ws_mufu_ftz(x)); } +static inline float ws_mufu_rsq(float x) { return ws_mufu_ftz(1.0f / sqrtf(ws_mufu_ftz(x))); } + +#endif diff --git a/tests/bw_mufu_ftz_test.c b/tests/bw_mufu_ftz_test.c new file mode 100644 index 000000000..573ce0732 --- /dev/null +++ b/tests/bw_mufu_ftz_test.c @@ -0,0 +1,96 @@ +/* bw_mufu_ftz_test.c: the MUFU flush rule (tests/bw_mufu_ftz.h, omega #462) and every warp simulator's MUFU cases. + * + * Built once per model (Makefile test-mufu-ftz): + * no WS_SIM_HDR the helper itself: subnormal -> sign-preserving zero; zeros, normals, inf, NaN pass + * -DWS_SIM_HDR='"bw_warp_sim.h"' (and _k, _pa, _tc) one MUFU instruction through that simulator's ws_lane_exec + * The simulator cases expect the chip rule: a subnormal input or result is a zero of the same sign. Before #462 the + * first three simulators returned the IEEE subnormal (RCP of 1.5 * 2^127, EX2 of -130) and the IEEE finite value for a + * subnormal input (RCP / RSQ of 2^-127, 2^-140), and fail here. Unreachable: an RSQ result can never be subnormal + * (1 / sqrt(x) >= 2^-64 for every finite f32 x), so RSQ only exercises the input flush. */ +#ifdef WS_SIM_HDR +#include WS_SIM_HDR /* the simulator under test; it must get its MUFU rule from bw_mufu_ftz.h */ +#else +#include "bw_mufu_ftz.h" +#endif +#include +#include +#include +#include + +static int g_checks, g_failed; +__attribute__((unused)) static uint32_t f2u(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } +static float u2f(uint32_t u) { float f; memcpy(&f, &u, 4); return f; } +/* expect bits exactly, or any NaN when want is a NaN */ +static void expect(const char *what, uint32_t in, uint32_t got, uint32_t want) { + int nan = (want & 0x7fffffffu) > 0x7f800000u, ok = nan ? (got & 0x7fffffffu) > 0x7f800000u : got == want; + g_checks++; + if (!ok) { g_failed++; printf("FAIL: %s(0x%08x) = 0x%08x (%g), want 0x%08x (%g)\n", what, in, got, u2f(got), want, u2f(want)); } +} + +#ifndef WS_SIM_HDR +#define MODEL "helper" +static void run_model(void) { + /* every subnormal of both signs, sampled across the whole mantissa range, plus its extremes */ + for (uint32_t m = 1; m < 0x800000u; m += (m < 64 || m > 0x7fffc0u) ? 1u : 4093u) { + expect("ftz", m, f2u(ws_mufu_ftz(u2f(m))), 0x00000000u); + expect("ftz", 0x80000000u | m, f2u(ws_mufu_ftz(u2f(0x80000000u | m))), 0x80000000u); + } + static const uint32_t pass[] = { 0x00000000u, 0x80000000u, 0x00800000u, 0x80800000u, 0x3f800000u, 0xbf800000u, + 0x7f7fffffu, 0xff7fffffu, 0x7f800000u, 0xff800000u, 0x7fc00000u, 0xffc00000u, 0x7f800001u, 0x00ffffffu }; + for (size_t i = 0; i < sizeof pass / sizeof pass[0]; i++) expect("ftz", pass[i], f2u(ws_mufu_ftz(u2f(pass[i]))), pass[i]); + /* the three functions, same table the simulators use below */ + expect("ex2", f2u(-130.0f), f2u(ws_mufu_ex2(-130.0f)), 0x00000000u); + expect("rcp", 0xff400000u, f2u(ws_mufu_rcp(u2f(0xff400000u))), 0x80000000u); + expect("rsq", 0x00000200u, f2u(ws_mufu_rsq(u2f(0x00000200u))), 0x7f800000u); +} +#else +#define MODEL WS_SIM_HDR +static BlackwellIRProgram g_prog; +static uint32_t sim_mufu(BlackwellIROpcode op, uint32_t x) { + static WsSim s; static WsLane l; + memset(&s, 0, sizeof s); memset(&l, 0, sizeof l); + BlackwellIRInsn in; memset(&in, 0, sizeof in); + in.op = op; in.dst_vreg = 0; in.src1_vreg = 1; in.src2_vreg = -1; in.src3_vreg = -1; in.ureg = -1; + s.p = &g_prog; l.r[1] = x; l.r[0] = 0xdeadbeefu; + ws_lane_exec(&s, &l, &in, 0, 0, 0, 0); + return l.r[0]; +} +static void run_model(void) { + (void)ws_run; /* the warp scheduler is not under test here */ + g_prog.regalloc.vreg_to_phys[0] = 0; g_prog.regalloc.vreg_to_phys[1] = 1; + static const struct { BlackwellIROpcode op; const char *name; uint32_t in, want; } c[] = { + /* subnormal result -> sign-preserving zero (IEEE: 0x00080000, 0x00155555 / 0x80155555) */ + { BW_IR_MUFU_EX2, "EX2", 0xc3020000u /* -130 */, 0x00000000u }, + { BW_IR_MUFU_EX2, "EX2", 0xc2fe0000u /* -127 */, 0x00000000u }, + { BW_IR_MUFU_RCP, "RCP", 0x7f400000u /* 1.5 * 2^127 */, 0x00000000u }, + { BW_IR_MUFU_RCP, "RCP", 0xff400000u /* -1.5 * 2^127 */, 0x80000000u }, + /* subnormal input -> treated as a zero of the same sign (IEEE: 2^127, -2^127, 2^70) */ + { BW_IR_MUFU_RCP, "RCP", 0x00400000u /* 2^-127 */, 0x7f800000u }, + { BW_IR_MUFU_RCP, "RCP", 0x80400000u /* -2^-127 */, 0xff800000u }, + { BW_IR_MUFU_RSQ, "RSQ", 0x00000200u /* 2^-140 */, 0x7f800000u }, + { BW_IR_MUFU_EX2, "EX2", 0x80000200u /* -2^-140 */, 0x3f800000u }, + /* controls: unchanged by the flush */ + { BW_IR_MUFU_EX2, "EX2", 0xc2fc0000u /* -126 -> smallest normal */, 0x00800000u }, + { BW_IR_MUFU_EX2, "EX2", 0x40400000u /* 3 */, 0x41000000u }, + { BW_IR_MUFU_EX2, "EX2", 0xff800000u /* -inf */, 0x00000000u }, + { BW_IR_MUFU_EX2, "EX2", 0x7f800000u /* +inf */, 0x7f800000u }, + { BW_IR_MUFU_EX2, "EX2", 0x7fc00000u /* NaN */, 0x7fc00000u }, + { BW_IR_MUFU_RCP, "RCP", 0x7e800000u /* 2^126 -> smallest normal */, 0x00800000u }, + { BW_IR_MUFU_RCP, "RCP", 0x40000000u /* 2 */, 0x3f000000u }, + { BW_IR_MUFU_RCP, "RCP", 0x80000000u /* -0 */, 0xff800000u }, + { BW_IR_MUFU_RCP, "RCP", 0xff800000u /* -inf */, 0x80000000u }, + { BW_IR_MUFU_RCP, "RCP", 0x7fc00000u /* NaN */, 0x7fc00000u }, + { BW_IR_MUFU_RSQ, "RSQ", 0x40800000u /* 4 */, 0x3f000000u }, + { BW_IR_MUFU_RSQ, "RSQ", 0x00800000u /* 2^-126 */, 0x5f000000u }, + { BW_IR_MUFU_RSQ, "RSQ", 0x7f800000u /* +inf */, 0x00000000u }, + { BW_IR_MUFU_RSQ, "RSQ", 0x80000000u /* -0 */, 0xff800000u }, + }; + for (size_t i = 0; i < sizeof c / sizeof c[0]; i++) expect(c[i].name, c[i].in, sim_mufu(c[i].op, c[i].in), c[i].want); +} +#endif + +int main(void) { + run_model(); + printf("%s: mufu-ftz %s: %d checks, %d failed\n", g_failed ? "FAIL" : "PASS", MODEL, g_checks, g_failed); + return g_failed ? 1 : 0; +} diff --git a/tests/bw_warp_sim.h b/tests/bw_warp_sim.h index 3e98e8545..c010be5ba 100644 --- a/tests/bw_warp_sim.h +++ b/tests/bw_warp_sim.h @@ -33,12 +33,13 @@ * nobody wrote shows up in the oracle comparison. * * Per-lane ALU semantics are those of the two earlier simulators (tests/gpu_attention_test.c, - * bench/prime_race/tests/gb10_sieve_host_test.c). EX2 and RCP are exact here; the chip's - * are approximate. LDCU64 (memory descriptor) is not modelled. */ + * bench/prime_race/tests/gb10_sieve_host_test.c). MUFU EX2 / RCP / RSQ are the correctly + * rounded IEEE value with the chip's subnormal flush (bw_mufu_ftz.h); the chip's are approximate. LDCU64 (memory descriptor) is not modelled. */ #ifndef BW_WARP_SIM_H #define BW_WARP_SIM_H #include "omega_blackwell_codegen.h" +#include "bw_mufu_ftz.h" /* MUFU EX2 / RCP / RSQ: the chip's flush of subnormal inputs and results (omega #462) */ #include #include #include @@ -160,9 +161,9 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_FFMA: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaf(ws_u2f(a), ws_u2f(b), ws_u2f(c))), p); break; case BW_IR_FMNMX_MAX: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaxf(ws_u2f(a), ws_u2f(b))), p); break; case BW_IR_FMNMX_MIN: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fminf(ws_u2f(a), ws_u2f(b))), p); break; - case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(exp2f(ws_u2f(a))), p); break; - case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(1.0f / ws_u2f(a)), p); break; - case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(1.0f / sqrtf(ws_u2f(a))), p); break; + case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ex2(ws_u2f(a))), p); break; + case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rcp(ws_u2f(a))), p); break; + case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rsq(ws_u2f(a))), p); break; default: ws_fail(s, WS_E_OP, pc, "opcode not modelled"); return; } } diff --git a/tests/bw_warp_sim_k.h b/tests/bw_warp_sim_k.h index 676b29344..bd47e13c2 100644 --- a/tests/bw_warp_sim_k.h +++ b/tests/bw_warp_sim_k.h @@ -33,8 +33,8 @@ * nobody wrote shows up in the oracle comparison. * * Per-lane ALU semantics are those of the two earlier simulators (tests/gpu_attention_test.c, - * bench/prime_race/tests/gb10_sieve_host_test.c). EX2 and RCP are exact here; the chip's - * are approximate. LDCU64 (memory descriptor) is not modelled. */ + * bench/prime_race/tests/gb10_sieve_host_test.c). MUFU EX2 / RCP / RSQ are the correctly + * rounded IEEE value with the chip's subnormal flush (bw_mufu_ftz.h); the chip's are approximate. LDCU64 (memory descriptor) is not modelled. */ #ifndef BW_WARP_SIM_K_H #define BW_WARP_SIM_K_H /* bw_warp_sim_k.h (OWN-30B cut 8, 2026-10-13): tests/bw_warp_sim.h plus the system-scope opcodes the decode attention @@ -42,6 +42,7 @@ * The simulator runs CTAs one after another, so an atomic counter sees every earlier CTA's add. */ #include "omega_blackwell_codegen.h" +#include "bw_mufu_ftz.h" /* MUFU EX2 / RCP / RSQ: the chip's flush of subnormal inputs and results (omega #462) */ #include #include #include @@ -89,6 +90,7 @@ typedef struct { uint32_t smem_bytes; WsRange ranges[WS_MAX_RANGES]; int nranges; /* when > 0, every global access must fall in one */ int order; /* 0 = lowest pc first, 1 = highest pc first */ + uint32_t warp_sched; /* warp visit order per barrier phase: 0 ascending, 1 descending, else a seed for a fresh shuffle each phase */ int trace; /* print every issue of warp 0 of CTA (0,0) */ /* results */ int err; int err_pc; char msg[200]; @@ -153,7 +155,7 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_LOP3_XOR: ws_wrs(l, in->dst_vreg, in->dst_subreg, a ^ b, p); break; case BW_IR_LOP3_LUT: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_lut3(in->imm & 0xff, a, b, c), p); break; case BW_IR_ISETP_GE_U32: l->p0 = a >= b; break; - case BW_IR_LDG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } + case BW_IR_LDG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p) + (uint64_t)(int64_t)(int32_t)in->imm; if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } case BW_IR_LDG_E_U16: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 2, pc)) return; uint16_t x; memcpy(&x, (const void *)(uintptr_t)ad, 2); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } case BW_IR_STG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; memcpy((void *)(uintptr_t)ad, &b, 4); break; } case BW_IR_LDG_E_64: case BW_IR_LDG_E_128: { unsigned n = in->op == BW_IR_LDG_E_64 ? 8u : 16u; uint64_t ad = ws_rd64(l, in->src1_vreg, p) + (uint64_t)(int64_t)(int32_t)in->imm; if (!ws_mem_ok(s, ad, n, pc)) { if (getenv("WS_DBG")) fprintf(stderr, " tid %u cx %u cy %u\n", tid, cx, cy); return; } if (ad & (n - 1)) { ws_fail(s, WS_E_MEM, pc, "wide global load not naturally aligned"); return; } uint32_t x[4]; memcpy(x, (const void *)(uintptr_t)ad, n); for (unsigned i = 0; i < n / 4; i++) ws_wrs(l, in->dst_vreg, i, x[i], p); break; } @@ -167,9 +169,9 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_FFMA: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaf(ws_u2f(a), ws_u2f(b), ws_u2f(c))), p); break; case BW_IR_FMNMX_MAX: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaxf(ws_u2f(a), ws_u2f(b))), p); break; case BW_IR_FMNMX_MIN: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fminf(ws_u2f(a), ws_u2f(b))), p); break; - case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(exp2f(ws_u2f(a))), p); break; - case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(1.0f / ws_u2f(a)), p); break; - case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(1.0f / sqrtf(ws_u2f(a))), p); break; + case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ex2(ws_u2f(a))), p); break; + case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rcp(ws_u2f(a))), p); break; + case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rsq(ws_u2f(a))), p); break; case BW_IR_LDG_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } case BW_IR_STG_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; memcpy((void *)(uintptr_t)ad, &b, 4); break; } case BW_IR_ATOMG_ADD_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t old; memcpy(&old, (const void *)(uintptr_t)ad, 4); uint32_t nw = old + b; memcpy((void *)(uintptr_t)ad, &nw, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, old, p); break; } @@ -309,9 +311,16 @@ static int ws_run(WsSim *s, uint32_t grid_x, uint32_t grid_y) { /* Barrier phases: every warp runs until all of its fragments are parked at BAR.SYNC or it * has finished (exited lanes do not hold the barrier up: INFERRED, see WS_E_BAR_SPLIT). * Then every parked fragment is released and the next phase starts. */ + uint32_t rng = s->warp_sched; for (int phase = 0; ; phase++) { int parked = 0; - for (uint32_t w = 0; w < nw && !s->err; w++) { + /* visit order: the chip gives no order between warps, so a slot or barrier mistake that the fixed order hides + * must show under the reversed or a shuffled one */ + uint32_t vis[WS_MAX_WARPS]; + for (uint32_t i = 0; i < nw; i++) vis[i] = s->warp_sched == 1 ? nw - 1u - i : i; + if (s->warp_sched > 1) for (uint32_t i = nw - 1u; i > 0; i--) { rng = rng * 1664525u + 1013904223u; uint32_t j = (rng >> 8) % (i + 1u); uint32_t t = vis[i]; vis[i] = vis[j]; vis[j] = t; } + for (uint32_t vi = 0; vi < nw && !s->err; vi++) { + const uint32_t w = vis[vi]; if (warps[w].nfrag == 0) continue; int r = ws_run_warp(s, &warps[w], w, cx, cy, trace && w == 0); if (r < 0) break; diff --git a/tests/bw_warp_sim_pa.h b/tests/bw_warp_sim_pa.h index 7657df020..2543d2a19 100644 --- a/tests/bw_warp_sim_pa.h +++ b/tests/bw_warp_sim_pa.h @@ -33,8 +33,8 @@ * nobody wrote shows up in the oracle comparison. * * Per-lane ALU semantics are those of the two earlier simulators (tests/gpu_attention_test.c, - * bench/prime_race/tests/gb10_sieve_host_test.c). EX2 and RCP are exact here; the chip's - * are approximate. LDCU64 (memory descriptor) is not modelled. */ + * bench/prime_race/tests/gb10_sieve_host_test.c). MUFU EX2 / RCP / RSQ are the correctly + * rounded IEEE value with the chip's subnormal flush (bw_mufu_ftz.h); the chip's are approximate. LDCU64 (memory descriptor) is not modelled. */ #ifndef BW_WARP_SIM_PA_H /* bw_warp_sim_pa.h (OWN-30B L1 attention, 2026-10-13): bw_warp_sim_tc.h with the HMMA operands read at their sub-register * offsets (src1/src2/src3_subreg; the encoder adds them to the physical register, bw_warp_sim_tc.h ignored them). The @@ -49,6 +49,7 @@ * encoder emits and bw_warp_sim_k.h ignored. Timing (stall counts, scoreboards) is not modelled. */ #include "omega_blackwell_codegen.h" +#include "bw_mufu_ftz.h" /* MUFU EX2 / RCP / RSQ: the chip's flush of subnormal inputs and results (omega #462) */ #include "bw_hmma_model.h" #include "omega_blackwell_codegen_tc.h" #include @@ -174,13 +175,13 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_FSUB: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) - ws_u2f(b)), p); break; case BW_IR_FMUL: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) * ws_u2f(b)), p); break; case BW_IR_FFMA: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaf(ws_u2f(a), ws_u2f(b), ws_u2f(c))), p); break; + case BW_IR_F2FP_BF16_PACK: ws_wrs(l, in->dst_vreg, in->dst_subreg, (ws_bf16_rn(a) << 16) | ws_bf16_rn(b), p); break; /* F2FP.BF16.F32.PACK_AB */ case BW_IR_FMNMX_MAX: - if (in->imm == OMEGA_TC_MARK_F2FP) { ws_wrs(l, in->dst_vreg, in->dst_subreg, (ws_bf16_rn(a) << 16) | ws_bf16_rn(b), p); break; } /* F2FP.BF16.F32.PACK_AB placeholder */ ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaxf(ws_u2f(a), ws_u2f(b))), p); break; case BW_IR_FMNMX_MIN: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fminf(ws_u2f(a), ws_u2f(b))), p); break; - case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(exp2f(ws_u2f(a))), p); break; - case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(1.0f / ws_u2f(a)), p); break; - case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(1.0f / sqrtf(ws_u2f(a))), p); break; + case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ex2(ws_u2f(a))), p); break; + case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rcp(ws_u2f(a))), p); break; + case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rsq(ws_u2f(a))), p); break; case BW_IR_LDG_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } case BW_IR_STG_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; memcpy((void *)(uintptr_t)ad, &b, 4); break; } case BW_IR_ATOMG_ADD_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t old; memcpy(&old, (const void *)(uintptr_t)ad, 4); uint32_t nw = old + b; memcpy((void *)(uintptr_t)ad, &nw, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, old, p); break; } @@ -280,13 +281,13 @@ static int ws_run_warp(WsSim *s, WsWarp *w, uint32_t warp, uint32_t cx, uint32_t } break; } - case BW_IR_SHFL_DOWN: { + case BW_IR_SHFL_DOWN: case BW_IR_SHFL_BFLY: { if (w->exited) { ws_fail(s, WS_E_SHFL_EXITED, pc, "SHFL on a warp with exited lanes"); return -1; } if (mask != live) { ws_fail(s, WS_E_SHFL_SPLIT, pc, "SHFL on a split warp"); return -1; } uint32_t src[WS_WARP]; for (int L = 0; L < WS_WARP; L++) src[L] = ws_rd(&w->lane[L], in->src1_vreg, p); for (int L = 0; L < WS_WARP; L++) { - int from = (in->imm & OMEGA_TC_MARK_BFLY) ? (L ^ (int)(in->imm & 31)) : L + (int)(in->imm & 31); /* BFLY placeholder (omega_blackwell_codegen_tc.h) */ + int from = in->op == BW_IR_SHFL_BFLY ? (L ^ (int)(in->imm & 31)) : L + (int)(in->imm & 31); ws_wr(&w->lane[L], in->dst_vreg, from < WS_WARP ? src[from] : src[L], p); } f->pc = pc + 1; diff --git a/tests/bw_warp_sim_tc.h b/tests/bw_warp_sim_tc.h index 703a8b6b0..f2a637ae7 100644 --- a/tests/bw_warp_sim_tc.h +++ b/tests/bw_warp_sim_tc.h @@ -33,8 +33,8 @@ * nobody wrote shows up in the oracle comparison. * * Per-lane ALU semantics are those of the two earlier simulators (tests/gpu_attention_test.c, - * bench/prime_race/tests/gb10_sieve_host_test.c). EX2 and RCP are exact here; the chip's - * are approximate. LDCU64 (memory descriptor) is not modelled. */ + * bench/prime_race/tests/gb10_sieve_host_test.c). MUFU EX2 / RCP / RSQ are the correctly + * rounded IEEE value with the chip's subnormal flush (bw_mufu_ftz.h); the chip's are approximate. LDCU64 (memory descriptor) is not modelled. */ #ifndef BW_WARP_SIM_TC_H #define BW_WARP_SIM_TC_H /* bw_warp_sim_k.h (OWN-30B cut 8, 2026-10-13): tests/bw_warp_sim.h plus the system-scope opcodes the decode attention @@ -46,6 +46,7 @@ * encoder emits and bw_warp_sim_k.h ignored. Timing (stall counts, scoreboards) is not modelled. */ #include "omega_blackwell_codegen.h" +#include "bw_mufu_ftz.h" /* MUFU EX2 / RCP / RSQ: the chip's flush of subnormal inputs and results (omega #462) */ #include "bw_hmma_model.h" #include "omega_blackwell_codegen_tc.h" #include "omega_blackwell_codegen_qmma.h" @@ -125,16 +126,7 @@ static void ws_wrs(WsLane *l, int v, unsigned sub, uint32_t x, const BlackwellIR static float ws_u2f(uint32_t u) { float f; memcpy(&f, &u, 4); return f; } static uint32_t ws_f2u(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } static uint32_t ws_bf16_rn(uint32_t u) { if ((u & 0x7fffffffu) > 0x7f800000u) return 0x7fc0u; return (u + 0x7fffu + ((u >> 16) & 1u)) >> 16; } /* f32 bits -> bf16 bits, round to nearest even */ -/* MUFU (the SASS EX2 / RCP / RSQ unit) flushes a subnormal result to a sign-preserving zero. Chip-observed on GB10: the SwiGLU - * reciprocal 1 / (2^t + 1) for t in (126, 128) came back as +-0 on all 101 of 101 differing elements (evidence - * OWN30B-L1G-PFGEMM-SWIGLU-FTZ-df9bd9c4, gpu_pfgemm_test host red test). Doc-inferred, not separately chip-observed: the input flush - * and the EX2 / RSQ cases follow the same rule, PTX ISA 9.7.3.13 (rcp) and 9.7.3.21 (ex2) "flushes subnormal inputs and results to - * sign-preserving zero" for the .ftz form, which is what the bare MUFU we emit is (the non-ftz PTX variants are ptxas sequences around - * MUFU; NVIDIA publishes no SASS semantics). Limit: the chip's MUFU is approximate (RCP 1 ulp, EX2 2 ulp), the model flushes a correctly - * rounded IEEE result, so right at the subnormal boundary the two can disagree 0 versus nonzero. This simulator and the pfgemm reference - * go through this helper; bw_warp_sim.h, bw_warp_sim_k.h, bw_warp_sim_pa.h and gpu_attention_test.c still model MUFU as IEEE (issue filed - * with PR #461). omega_numeric.c has its own ftz() on the library side. */ -static float ws_mufu_ftz(float f) { uint32_t u = ws_f2u(f); if ((u & 0x7f800000u) == 0u) u &= 0x80000000u; return ws_u2f(u); } +/* MUFU EX2 / RCP / RSQ: the flush rule and its evidence live in bw_mufu_ftz.h (shared by every simulator, omega #462). */ static uint32_t ws_lut3(uint32_t lut, uint32_t a, uint32_t b, uint32_t c) { uint32_t r = 0; for (int i = 0; i < 8; i++) if (lut >> i & 1) r |= ((i & 4) ? a : ~a) & ((i & 2) ? b : ~b) & ((i & 1) ? c : ~c); @@ -185,17 +177,19 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_FSUB: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) - ws_u2f(b)), p); break; case BW_IR_FMUL: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) * ws_u2f(b)), p); break; case BW_IR_FFMA: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaf(ws_u2f(a), ws_u2f(b), ws_u2f(c))), p); break; + case BW_IR_F2FP_BF16_PACK: ws_wrs(l, in->dst_vreg, in->dst_subreg, (ws_bf16_rn(a) << 16) | ws_bf16_rn(b), p); break; /* F2FP.BF16.F32.PACK_AB */ case BW_IR_FMNMX_MAX: - if (in->imm == OMEGA_TC_MARK_F2FP) { ws_wrs(l, in->dst_vreg, in->dst_subreg, (ws_bf16_rn(a) << 16) | ws_bf16_rn(b), p); break; } /* F2FP.BF16.F32.PACK_AB placeholder */ if (in->imm == OMEGA_QMMA_MARK_F2E4) { ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)qm_e4m3_rne_sat(ws_u2f(a)) << 8 | qm_e4m3_rne_sat(ws_u2f(b)), p); break; } /* F2FP.SATFINITE.E4M3 placeholder (NaN not modelled) */ ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaxf(ws_u2f(a), ws_u2f(b))), p); break; case BW_IR_FMNMX_MIN: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fminf(ws_u2f(a), ws_u2f(b))), p); break; - case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ftz(exp2f(ws_mufu_ftz(ws_u2f(a))))), p); break; - case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ftz(1.0f / ws_mufu_ftz(ws_u2f(a)))), p); break; - case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ftz(1.0f / sqrtf(ws_mufu_ftz(ws_u2f(a))))), p); break; + case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_ex2(ws_u2f(a))), p); break; + case BW_IR_MUFU_RCP: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rcp(ws_u2f(a))), p); break; + case BW_IR_MUFU_RSQ: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_mufu_rsq(ws_u2f(a))), p); break; case BW_IR_LDG_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } case BW_IR_STG_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; memcpy((void *)(uintptr_t)ad, &b, 4); break; } case BW_IR_ATOMG_ADD_STRONG_SYS: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t old; memcpy(&old, (const void *)(uintptr_t)ad, 4); uint32_t nw = old + b; memcpy((void *)(uintptr_t)ad, &nw, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, old, p); break; } + /* f32 atomic add, flush-to-zero on both inputs and the result (PTX add.rn.ftz.f32); returns the old word */ + case BW_IR_ATOMG_ADD_F32_STRONG_SYS: case BW_IR_ATOMG_ADD_F32_STRONG_GPU: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t old; memcpy(&old, (const void *)(uintptr_t)ad, 4); uint32_t nw = ws_f2u(ws_mufu_ftz(ws_mufu_ftz(ws_u2f(old)) + ws_mufu_ftz(ws_u2f(b)))); memcpy((void *)(uintptr_t)ad, &nw, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, old, p); break; } case BW_IR_MEMBAR_ALL_SYS: break; default: ws_fail(s, WS_E_OP, pc, "opcode not modelled"); return; } @@ -292,13 +286,13 @@ static int ws_run_warp(WsSim *s, WsWarp *w, uint32_t warp, uint32_t cx, uint32_t } break; } - case BW_IR_SHFL_DOWN: { + case BW_IR_SHFL_DOWN: case BW_IR_SHFL_BFLY: { if (w->exited) { ws_fail(s, WS_E_SHFL_EXITED, pc, "SHFL on a warp with exited lanes"); return -1; } if (mask != live) { ws_fail(s, WS_E_SHFL_SPLIT, pc, "SHFL on a split warp"); return -1; } uint32_t src[WS_WARP]; for (int L = 0; L < WS_WARP; L++) src[L] = ws_rd(&w->lane[L], in->src1_vreg, p); for (int L = 0; L < WS_WARP; L++) { - int from = (in->imm & OMEGA_TC_MARK_BFLY) ? (L ^ (int)(in->imm & 31)) : L + (int)(in->imm & 31); /* BFLY placeholder (omega_blackwell_codegen_tc.h) */ + int from = in->op == BW_IR_SHFL_BFLY ? (L ^ (int)(in->imm & 31)) : L + (int)(in->imm & 31); ws_wr(&w->lane[L], in->dst_vreg, from < WS_WARP ? src[from] : src[L], p); } f->pc = pc + 1; diff --git a/tests/dgraph_receipt/fixtures/good-historical-710d438c-main.json b/tests/dgraph_receipt/fixtures/good-historical-710d438c-main.json new file mode 100644 index 000000000..e172971a0 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/good-historical-710d438c-main.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/good-historical-710d438c-prefetch.json b/tests/dgraph_receipt/fixtures/good-historical-710d438c-prefetch.json new file mode 100644 index 000000000..05fe68a58 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/good-historical-710d438c-prefetch.json @@ -0,0 +1,183 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch, started 2026-10-15T00:56:37Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:56:37Z", + "ended_utc": "2026-10-15T00:56:51Z", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 10, + "tokens_note": "10 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": true, + "prefetch": true, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_l2d_prefetch_chip.sh EVIDENCE_DIR (run 4-cached-prefetch: --cached-weights --prefetch --reps 10)", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/build.log (46 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 10 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 10, + "graph": { + "launches": 24, + "submits": 1, + "total_ns": 4075907, + "chip_ns": 4072931, + "record_ns": 2657, + "host_overhead_ns": 2976, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 24, + "submits": 24, + "total_ns": 5542421, + "chip_ns": 5531221, + "host_overhead_ns": 11200, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 24, + "span_ns": 3956640, + "chip_ns": 3972850, + "unattributed_ns": 16210, + "stage_sum_ns": 3956640, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 6016 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 133984 + }, + { + "kind": "attn", + "launches": 4, + "device_ns": 231008 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 87904 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10528 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 49088 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 292832 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6656 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 176672 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19136 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2926400 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 16416 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 24 per flush_each token); spans never overlap each other", + "stages": "serial partition with 2 independent launches: prefetch on, each layer's o_proj prefetch is marked independent (no barrier before it) and tagged attn, so its stamp is the front-end time while the attention may still run; the attn stage is the attention+prefetch window and the stages still add up to span_ns", + "overlap_measurable": false, + "reason": "an overlapped window is visible (the attn stage holds attention + prefetch), but no counter splits it, so how much of the two launches overlapped is not measurable from these counters" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/receipt-4-cached-prefetch.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/4-cached-prefetch.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/good-not-run-278b6c3c.json b/tests/dgraph_receipt/fixtures/good-not-run-278b6c3c.json new file mode 100644 index 000000000..83ab16f73 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/good-not-run-278b6c3c.json @@ -0,0 +1,57 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "NOT_RUN", + "status_note": "example NOT_RUN receipt: a decode-graph chip run at omega main 278b6c3c that has not been made (aien-architecture#233 runs host-only and takes no GPU lock)", + "run_verdict": "NOT_RUN", + "not_run_reason": "no chip run under aien-architecture#233: hardware runs need a separately approved attended run on the GB10", + "source": { + "repo": "aien-spark/omega", + "commit": "278b6c3c5840e5f13472a2f60f50542d81c3821e", + "dirty": false + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20 + }, + "hardware": { + "host": "spark-b87b", + "gpu": "NVIDIA GB10" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main" + }, + "per_token": null, + "stamped_token": null, + "aggregate": { + "available": false, + "reason": "nothing was measured" + }, + "serial_vs_overlap": { + "chip_ns": "not measured", + "stages": "not measured", + "overlap_measurable": false, + "reason": "nothing was measured" + }, + "methodology": { + "device_clock": "GPU PTIMER ns (omega_gpu_cmdlist.h stamps), when a run is made", + "host_clock": "omega_gpu_session_now_ns(), CLOCK_MONOTONIC on Linux, when a run is made", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\" (host clock)", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"" + } + }, + "evidence": [ + "tools/run_gpu_decode_graph_chip.sh", + "docs/perf/DECODE_GRAPH_RECEIPT.md" + ], + "limitations": [ + "NOT_RUN: carries no numbers and supports no performance claim" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-commit-nonhex.json b/tests/dgraph_receipt/fixtures/neg-commit-nonhex.json new file mode 100644 index 000000000..1472d80f3 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-commit-nonhex.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554g", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-commit-short.json b/tests/dgraph_receipt/fixtures/neg-commit-short.json new file mode 100644 index 000000000..4758750ce --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-commit-short.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438c", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-evidence-absolute.json b/tests/dgraph_receipt/fixtures/neg-evidence-absolute.json new file mode 100644 index 000000000..f0ef26be0 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-evidence-absolute.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "/home/drakestapleton/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-evidence-missing.json b/tests/dgraph_receipt/fixtures/neg-evidence-missing.json new file mode 100644 index 000000000..05c82fbd9 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-evidence-missing.json @@ -0,0 +1,185 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/no-such-run.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-invalid-json.json b/tests/dgraph_receipt/fixtures/neg-invalid-json.json new file mode 100644 index 000000000..cf9aa4be8 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-invalid-json.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +}, diff --git a/tests/dgraph_receipt/fixtures/neg-missing-counter.json b/tests/dgraph_receipt/fixtures/neg-missing-counter.json new file mode 100644 index 000000000..f66b9b236 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-missing-counter.json @@ -0,0 +1,183 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-missing-gpu.json b/tests/dgraph_receipt/fixtures/neg-missing-gpu.json new file mode 100644 index 000000000..298b21d9e --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-missing-gpu.json @@ -0,0 +1,183 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-notrun-with-measurements.json b/tests/dgraph_receipt/fixtures/neg-notrun-with-measurements.json new file mode 100644 index 000000000..f7f61300e --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-notrun-with-measurements.json @@ -0,0 +1,185 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "NOT_RUN", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "NOT_RUN", + "not_run_reason": "chip not available", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-overhead-mismatch.json b/tests/dgraph_receipt/fixtures/neg-overhead-mismatch.json new file mode 100644 index 000000000..c701e36ba --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-overhead-mismatch.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3281, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-placeholder-empty.json b/tests/dgraph_receipt/fixtures/neg-placeholder-empty.json new file mode 100644 index 000000000..753262aad --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-placeholder-empty.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-placeholder-tbd.json b/tests/dgraph_receipt/fixtures/neg-placeholder-tbd.json new file mode 100644 index 000000000..54deab908 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-placeholder-tbd.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "TBD", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-placeholder-unknown.json b/tests/dgraph_receipt/fixtures/neg-placeholder-unknown.json new file mode 100644 index 000000000..a78d0842d --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-placeholder-unknown.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "unknown", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-schema.json b/tests/dgraph_receipt/fixtures/neg-schema.json new file mode 100644 index 000000000..f560751a7 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-schema.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/2", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-sems-done-wrong.json b/tests/dgraph_receipt/fixtures/neg-sems-done-wrong.json new file mode 100644 index 000000000..0a05256c2 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-sems-done-wrong.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": 21, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-span-exceeds-chip.json b/tests/dgraph_receipt/fixtures/neg-span-exceeds-chip.json new file mode 100644 index 000000000..5b5fcc276 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-span-exceeds-chip.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 5000000, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-stage-partition.json b/tests/dgraph_receipt/fixtures/neg-stage-partition.json new file mode 100644 index 000000000..5aca60a46 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-stage-partition.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989569, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15969 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-stage-sum-mismatch.json b/tests/dgraph_receipt/fixtures/neg-stage-sum-mismatch.json new file mode 100644 index 000000000..20b2d4e2c --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-stage-sum-mismatch.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15969 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-status-enum.json b/tests/dgraph_receipt/fixtures/neg-status-enum.json new file mode 100644 index 000000000..1008855d8 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-status-enum.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "PASSED", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-unattributed-mismatch.json b/tests/dgraph_receipt/fixtures/neg-unattributed-mismatch.json new file mode 100644 index 000000000..853122bb8 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-unattributed-mismatch.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 0, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-unknown-field.json b/tests/dgraph_receipt/fixtures/neg-unknown-field.json new file mode 100644 index 000000000..c158bdf5d --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-unknown-field.json @@ -0,0 +1,185 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "speedup": "2x", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-verified-dirty.json b/tests/dgraph_receipt/fixtures/neg-verified-dirty.json new file mode 100644 index 000000000..bb1088d20 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-verified-dirty.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "VERIFIED", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": true, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 20, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 20, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/fixtures/neg-zero-tokens.json b/tests/dgraph_receipt/fixtures/neg-zero-tokens.json new file mode 100644 index 000000000..9476542e0 --- /dev/null +++ b/tests/dgraph_receipt/fixtures/neg-zero-tokens.json @@ -0,0 +1,184 @@ +{ + "schema": "omega-decode-graph-receipt/1", + "status": "HISTORICAL", + "status_note": "reproduced from an existing evidence run (evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph, started 2026-10-15T00:55:40Z) by tools/dgraph_receipt.c; the chip was not run to make this receipt", + "run_verdict": "PASS", + "source": { + "repo": "aien-spark/omega", + "commit": "710d438cac6c1159b4ca2b39af49812ce08f554b", + "dirty": false, + "dirty_basis": "device.txt dirty=0 (git status --porcelain line count at run start)", + "branch": "HEAD", + "physics_commit": "6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf" + }, + "run": { + "started_utc": "2026-10-15T00:55:40Z", + "ended_utc": "2026-10-15T00:55:42Z", + "runner_mode": "main", + "test_checks": "13 checks, 0 failed" + }, + "workload": { + "model": "synthetic Qwen3-30B-A3B-shaped decode step, random weights", + "precision": "FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations", + "mode": "decode, one token per command list (omega_gpu_decode_graph_token), batch 1", + "tokens": 0, + "tokens_note": "20 timed graph tokens (the test's --reps), every one the same step at position 300; plus one stamped token", + "layers": 2, + "vocab": 151936, + "pos": 300, + "cached_weights": false, + "prefetch": false, + "red_mutant": false, + "barrier": "0 (wfi+inval_all)", + "fp8_variant": 1 + }, + "hardware": { + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "gpu": "NVIDIA GB10", + "driver": "580.173.02", + "basis": "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start" + }, + "build": { + "runner": "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main", + "binary_sha256": "4a8a7aa373b9c04ae3f4343a2f45738a57662ad79609f6af99b64f8173028eec", + "library_sha256": "6a6cb4df479ddbcc5cd4ef0fda1aea968832b2b70be2ff3312051c3e9921aad5", + "compile_command_note": "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log (0 bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256" + }, + "per_token": { + "statistic": "median over 20 tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", + "tokens": 0, + "graph": { + "launches": 22, + "submits": 1, + "total_ns": 3978675, + "chip_ns": 3975395, + "record_ns": 2464, + "host_overhead_ns": 3280, + "sems_done": null, + "sems_done_note": "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)" + }, + "flush_each": { + "launches": 22, + "submits": 22, + "total_ns": 5337477, + "chip_ns": 5326613, + "host_overhead_ns": 10864, + "sems_done": null, + "sems_done_note": "as for graph: not recorded, implied by the PASS verdict", + "identical_to_graph": true, + "note": "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run" + } + }, + "stamped_token": { + "launches": 22, + "span_ns": 3989568, + "chip_ns": 4076853, + "unattributed_ns": 87285, + "stage_sum_ns": 3989568, + "note": "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)", + "stages": [ + { + "kind": "norm", + "launches": 1, + "device_ns": 15968 + }, + { + "kind": "qkv", + "launches": 2, + "device_ns": 167744 + }, + { + "kind": "attn", + "launches": 2, + "device_ns": 145440 + }, + { + "kind": "o_proj", + "launches": 2, + "device_ns": 121504 + }, + { + "kind": "res_add", + "launches": 2, + "device_ns": 10304 + }, + { + "kind": "router", + "launches": 2, + "device_ns": 72288 + }, + { + "kind": "gate_up", + "launches": 2, + "device_ns": 329184 + }, + { + "kind": "swiglu", + "launches": 2, + "device_ns": 6752 + }, + { + "kind": "down", + "launches": 2, + "device_ns": 172960 + }, + { + "kind": "combine_norm", + "launches": 2, + "device_ns": 19584 + }, + { + "kind": "lm_head", + "launches": 1, + "device_ns": 2912960 + }, + { + "kind": "argmax", + "launches": 2, + "device_ns": 14880 + } + ] + }, + "aggregate": { + "available": false, + "reason": "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)" + }, + "serial_vs_overlap": { + "chip_ns": "serial: the sum over the token's submissions of one host-clock span each (1 submission per graph token, 22 per flush_each token); spans never overlap each other", + "stages": "serial partition: barrier 0 (wfi+inval_all) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", + "overlap_measurable": false, + "reason": "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns" + }, + "methodology": { + "device_clock": "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages", + "host_clock": "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns", + "counters": { + "launches": "omega_gpu_decode_graph.h: \"launches recorded for the token\"", + "submits": "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\"", + "chip_ns": "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency", + "record_ns": "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\"", + "total_ns": "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\"", + "sems_done": "omega_gpu_decode_graph.h: \"launch semaphores found DONE\"", + "stamps": "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)", + "host_overhead_ns": "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span" + }, + "source": "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256" + }, + "evidence": [ + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/receipt-main.json", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/main.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/device.txt", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/binaries.sha256", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph/build.log", + "evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md" + ], + "limitations": [ + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files" + ] +} diff --git a/tests/dgraph_receipt/negatives.txt b/tests/dgraph_receipt/negatives.txt new file mode 100644 index 000000000..f7942334b --- /dev/null +++ b/tests/dgraph_receipt/negatives.txt @@ -0,0 +1,23 @@ +# negative fixtures: file | good receipt it was cut from (by one edit) | reason the checker must name +neg-commit-short.json|good-historical-710d438c-main.json|field source.commit "710d438c" is not 40 lowercase hex digits +neg-commit-nonhex.json|good-historical-710d438c-main.json|is not 40 lowercase hex digits +neg-missing-gpu.json|good-historical-710d438c-main.json|missing field hardware.gpu +neg-missing-counter.json|good-historical-710d438c-main.json|missing field methodology.counters.chip_ns +neg-overhead-mismatch.json|good-historical-710d438c-main.json|derived graph.host_overhead_ns = 3281 but total_ns - chip_ns = 3280 +neg-stage-sum-mismatch.json|good-historical-710d438c-main.json|but the stages add up to 3989569 +neg-stage-partition.json|good-historical-710d438c-main.json|stamped_token.stage_sum_ns 3989569 differs from span_ns 3989568 +neg-unattributed-mismatch.json|good-historical-710d438c-main.json|derived stamped_token.unattributed_ns = 0 but chip_ns - span_ns = 87285 +neg-span-exceeds-chip.json|good-historical-710d438c-main.json|exceeds chip_ns +neg-placeholder-tbd.json|good-historical-710d438c-main.json|placeholder value "TBD" at receipt.workload.model +neg-placeholder-unknown.json|good-historical-710d438c-main.json|placeholder value "unknown" at receipt.hardware.host +neg-placeholder-empty.json|good-historical-710d438c-main.json|placeholder value "" at receipt.workload.precision +neg-zero-tokens.json|good-historical-710d438c-main.json|field workload.tokens = 0 is below 1 +neg-status-enum.json|good-historical-710d438c-main.json|status "PASSED" is not one of +neg-verified-dirty.json|good-historical-710d438c-main.json|a dirty tree cannot be verified +neg-evidence-missing.json|good-historical-710d438c-main.json|does not exist under +neg-evidence-absolute.json|good-historical-710d438c-main.json|must be repo-relative +neg-schema.json|good-historical-710d438c-main.json|schema "omega-decode-graph-receipt/2" +neg-unknown-field.json|good-historical-710d438c-main.json|unknown top-level field speedup +neg-sems-done-wrong.json|good-historical-710d438c-main.json|must equal launches or be null +neg-notrun-with-measurements.json|good-historical-710d438c-main.json|must carry per_token and stamped_token as null +neg-invalid-json.json|good-historical-710d438c-main.json|invalid JSON diff --git a/tests/dgraph_receipt/run.sh b/tests/dgraph_receipt/run.sh new file mode 100644 index 000000000..a304a98bd --- /dev/null +++ b/tests/dgraph_receipt/run.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# tests/dgraph_receipt/run.sh TOOL JSON_CANON WORKDIR: host-only tests of tools/dgraph_receipt.c +# (aien-architecture#233 P1, spec docs/perf/DECODE_GRAPH_RECEIPT.md). No GPU, reads evidence/ only. +# 1. regenerate each golden receipt from its evidence run and compare byte for byte with fixtures/ +# 2. the checker accepts every golden receipt (and the hand-written NOT_RUN one), json_canon agrees +# it is strict JSON, and every evidence path exists in this tree +# 3. every negative fixture in negatives.txt is refused, for the reason named there, and differs +# from the good receipt it was cut from (a negative identical to a good one proves nothing) +# 4. the generator refuses bad input (missing flag, log without settings, stats/log from two runs) +# Run from the repo root (the Makefile does). Exit 0 only when every case holds. +set -u +TOOL="${1:?tool}"; CANON="${2:?json_canon}"; WORK="${3:?workdir}" +T=tests/dgraph_receipt; F=$T/fixtures +rm -rf "$WORK"; mkdir -p "$WORK" +fails=0; cases=0 +ok() { cases=$((cases + 1)); echo "ok: $*"; } +bad() { cases=$((cases + 1)); fails=$((fails + 1)); echo "FAIL: $*"; } + +MODEL="synthetic Qwen3-30B-A3B-shaped decode step, random weights" +PREC="FP8 e4m3 weights (qkv, o, gate_up, down), BF16 lm_head, f32 activations" +MODE="decode, one token per command list (omega_gpu_decode_graph_token), batch 1" + +# golden 1: decode_graph main at omega main 710d438c (clean tree), uncached weights, prefetch off +R1=evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/decode_graph +gen_main() { + "$TOOL" --run-dir "$R1" --stats "$R1/receipt-main.json" --log "$R1/main.log" --status HISTORICAL --repo aien-spark/omega \ + --model "$MODEL" --precision "$PREC" --mode "$MODE" --runner "tools/run_gpu_decode_graph_chip.sh EVIDENCE_DIR main" \ + --evidence evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md "$@" +} +# golden 2: the same base, GPU-cached weights with the W-L2d prefetch on (independent launches) +R2=evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/gates/l2d_prefetch +gen_prefetch() { + "$TOOL" --run-dir "$R2" --stats "$R2/receipt-4-cached-prefetch.json" --log "$R2/4-cached-prefetch.log" --status HISTORICAL \ + --repo aien-spark/omega --model "$MODEL" --precision "$PREC" --mode "$MODE" \ + --runner "tools/run_gpu_l2d_prefetch_chip.sh EVIDENCE_DIR (run 4-cached-prefetch: --cached-weights --prefetch --reps 10)" \ + --evidence evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/NOTES.md "$@" +} + +# 1 + 2: golden receipts +for g in main prefetch; do + golden="$F/good-historical-710d438c-$g.json" + if "gen_$g" --out "$WORK/$g.json" 2> "$WORK/$g.err"; then + if cmp -s "$WORK/$g.json" "$golden"; then ok "golden $g regenerated byte for byte from evidence"; else bad "golden $g differs from $golden"; diff "$golden" "$WORK/$g.json" | head -20; fi + else bad "generator failed on golden $g: $(cat "$WORK/$g.err")"; fi +done +for good in "$F"/good-*.json; do + if out=$("$TOOL" --check "$good" --evidence-root .); then ok "checker accepts $good"; else bad "checker refused $good: $out"; fi + if "$CANON" --check < "$good"; then ok "json_canon: $good is strict JSON"; else bad "json_canon refused $good"; fi +done +# the receipts carry the evidence numbers unchanged (independent of the tool: grep both files) +for pair in "C_total:graph total_ns" "C_chip:graph chip_ns" "span_ns:stamped span_ns"; do + key=${pair%%:*} + want=$(grep -o "\"$key\":[0-9]*" "$R1/receipt-main.json" | head -n 1 | cut -d: -f2) + case "$key" in C_total) f=total_ns ;; C_chip) f=chip_ns ;; *) f=span_ns ;; esac + got=$(grep -o "\"$f\": [0-9]*" "$F/good-historical-710d438c-main.json" | head -n 1 | cut -d' ' -f2) + if [ -n "$want" ] && [ "$want" = "$got" ]; then ok "${pair#*:} $got equals evidence $key"; else bad "${pair#*:} $got vs evidence $key $want"; fi +done + +# 3: negative fixtures (file, the good receipt it was cut from, expected reason) +while IFS='|' read -r name base reason; do + case "$name" in ''|'#'*) continue ;; esac + n="$F/$name" + if [ ! -f "$n" ]; then bad "negative $name missing"; continue; fi + if cmp -s "$n" "$F/$base"; then bad "negative $name is identical to $base"; continue; fi + out=$("$TOOL" --check "$n" --evidence-root .); rc=$? + if [ $rc = 1 ] && printf '%s' "$out" | grep -qF -- "$reason"; then ok "refused $name ($reason)" + else bad "negative $name: exit $rc, wanted 1 with \"$reason\", got: $out"; fi +done < "$T/negatives.txt" + +# 4: generator refusals (nothing written) +"$TOOL" --run-dir "$R1" --stats "$R1/receipt-main.json" --log "$R1/main.log" --repo aien-spark/omega --model m --precision p --mode d \ + --runner r --out "$WORK/x1.json" 2> /dev/null +rc=$?; if [ $rc = 2 ] && [ ! -e "$WORK/x1.json" ]; then ok "generator: missing --status is a usage error"; else bad "generator: missing --status gave exit $rc"; fi +head -n 0 "$R1/main.log" > "$WORK/empty.log" +"$TOOL" --run-dir "$R1" --stats "$R1/receipt-main.json" --log "$WORK/empty.log" --status HISTORICAL --repo aien-spark/omega --model m \ + --precision p --mode d --runner r --out "$WORK/x3.json" 2> "$WORK/x3.err" +rc=$?; if [ $rc = 2 ] && [ ! -e "$WORK/x3.json" ] && grep -q 'dgraph prefetch' "$WORK/x3.err"; then ok "generator: log without the run's settings refused"; else bad "generator: settings-less log gave exit $rc"; fi +"$TOOL" --run-dir "$R1" --stats "$R1/receipt-main.json" --log "$R2/4-cached-prefetch.log" --status HISTORICAL --repo aien-spark/omega \ + --model m --precision p --mode d --runner r --out "$WORK/x4.json" 2> "$WORK/x4.err" +rc=$?; if [ $rc = 2 ] && [ ! -e "$WORK/x4.json" ] && grep -q 'not the same run' "$WORK/x4.err"; then ok "generator: stats and log from two runs refused"; else bad "generator: mixed runs gave exit $rc"; fi +gen_main --status TBD --out "$WORK/x5.json" 2> /dev/null +rc=$? +if [ $rc = 2 ]; then ok "generator: a repeated --status is a usage error"; else bad "generator: repeated --status gave exit $rc"; fi +"$TOOL" --run-dir "$R1" --stats "$R1/receipt-main.json" --log "$R1/main.log" --status DONE --repo aien-spark/omega --model m \ + --precision p --mode d --runner r --out "$WORK/x6.json" 2> "$WORK/x6.err" +rc=$?; if [ $rc = 1 ] && [ ! -e "$WORK/x6.json" ] && grep -q 'fails its own check' "$WORK/x6.err"; then ok "generator: status outside the enum never written"; else bad "generator: status DONE gave exit $rc"; fi + +echo "dgraph_receipt tests: $cases cases, $fails failed" +[ $fails = 0 ] diff --git a/tests/fabric/.crumb b/tests/fabric/.crumb index 5d3475864..3aa3eb9e8 100644 --- a/tests/fabric/.crumb +++ b/tests/fabric/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T13:47:05Z", + "compiled_at": "2026-10-18T09:08:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:de2bc4e310a257dbd21cc5c9624641b137b1b4487d8876cb52469aea2af5b904", + "digest": "sha256:404b5b92d56766565a54dba73720cda8b6a6f2dcf155764d1a2dc47457d4c559", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 4, - "generated_at_commit": "834ee93e4314a42c1127a2fcda8b29cf3b511245", - "source_tree": "sha256:463c877d4596ca9fa0ea5ef4ea41eebcb48ce3dea75a1c1a023589fd38fa81f6" + "files": 33, + "generated_at_commit": "eaacacd62040249f5633daf9fa6674e7f2f9d027", + "source_tree": "sha256:892a27883938062c71f889d596177118babe3debeed35f8d9bbc580d25e0d910" }, "owner_lane": "", "provenance": { diff --git a/tests/fabric/fab_work_procs.sh b/tests/fabric/fab_work_procs.sh new file mode 100755 index 000000000..4abc2ebd4 --- /dev/null +++ b/tests/fabric/fab_work_procs.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# fab_work_procs.sh -- requester and executor as two separate OS processes +# joined by two pipes (aienix#6 phase 2, step "separate process"). Not a +# network, not M6-A/M6-B: it proves the message codec, the state machines and +# the executor's durable journal work across a process boundary, nothing more. +# +# fab_work_procs.sh +# Prints FAB_WORK_PROCS_PASS on success. +set -eu +BIN=$1 +DIR=$2 +mkdir -p "$DIR/procs" +J="$DIR/procs/executor.journal" +rm -f "$J" "$DIR/procs/req2exec" "$DIR/procs/exec2req" +mkfifo "$DIR/procs/req2exec" "$DIR/procs/exec2req" +PEER=$("$BIN" --peer-id) + +# Open order matters with named pipes: the executor opens req2exec for reading +# first, so the requester must open req2exec for writing before it opens +# exec2req for reading, or both sides block in open() forever. +"$BIN" --executor "$J" < "$DIR/procs/req2exec" > "$DIR/procs/exec2req" 2> "$DIR/procs/executor.err" & +EXEC_PID=$! +set +e +"$BIN" --requester "$PEER" > "$DIR/procs/req2exec" < "$DIR/procs/exec2req" 2> "$DIR/procs/requester.err" +REQ_RC=$? +wait "$EXEC_PID" +EXEC_RC=$? +set -e +cat "$DIR/procs/executor.err" "$DIR/procs/requester.err" +if [ "$REQ_RC" -ne 0 ] || [ "$EXEC_RC" -ne 0 ]; then + echo "fab_work_procs: requester rc=$REQ_RC executor rc=$EXEC_RC" + exit 1 +fi +# The journal holds exactly the entries the executor journaled: one completed +# (328 bytes); the replay and the code-7 refusal added none. +SIZE=$(wc -c < "$J") +if [ "$SIZE" -ne 328 ]; then + echo "fab_work_procs: journal is $SIZE bytes, expected 328 (one entry)" + exit 1 +fi +# The two processes were distinct: the executor's pid is not ours. +if [ "$EXEC_PID" -eq "$$" ]; then echo "fab_work_procs: executor ran in this process"; exit 1; fi +echo "fab_work_procs: requester pid $$ (shell), executor pid $EXEC_PID, journal $SIZE bytes" +echo "FAB_WORK_PROCS_PASS" diff --git a/tests/fabric/fab_work_test.c b/tests/fabric/fab_work_test.c new file mode 100644 index 000000000..c373bfd35 --- /dev/null +++ b/tests/fabric/fab_work_test.c @@ -0,0 +1,840 @@ +/* + * fab_work_test.c -- conformance and negative tests for fab_work.h, + * fab_auth_ed25519.h and fab_route.h (aienix#6, omega#536). + * + * fab_work_test [VECTOR_DIR] in-process suite; prints FAB_WORK_PASS + * fab_work_test --emit DIR writes the HTK1/HTR1 golden vectors + * fab_work_test --oracle prints the matmul oracle digests + * fab_work_test --executor JOURNAL one executor process: PST1 frames on stdin/stdout + * fab_work_test --requester PEERHEX one requester process: drives an executor over stdin/stdout + * + * Frame on a pipe: u16 big-endian length, then that many bytes (one PST1 + * message). Two OS processes over pipes prove "separate process"; they are + * not a network, not M6-A/M6-B, and qualify nothing physical. + */ +#include "fabric.h" +#include "fab_auth_ed25519.h" +#include "fab_loopback.h" +#include "fab_route.h" +#include "fab_work.h" +#include "searchtrace/sig/aienos_sig.h" +#include "sha256.h" + +#include +#include +#include +#include + +static int checks, failures; +#define CHECK(c, ...) do { checks++; if (!(c)) { failures++; \ + fprintf(stderr, "FAIL %s:%d: ", __FILE__, __LINE__); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } } while (0) + +static void hex(const uint8_t *b, size_t n, char *out) { + static const char hx[] = "0123456789abcdef"; + for (size_t i = 0; i < n; i++) { out[2 * i] = hx[b[i] >> 4]; out[2 * i + 1] = hx[b[i] & 15]; } + out[2 * n] = 0; +} +static int unhex(const char *s, uint8_t *out, size_t n) { + if (strlen(s) != 2 * n) return -1; + for (size_t i = 0; i < n; i++) { + unsigned v; + if (sscanf(s + 2 * i, "%2x", &v) != 1) return -1; + out[i] = (uint8_t)v; + } + return 0; +} +static void fill(uint8_t *b, size_t n, const char *label) { + uint8_t d[32]; + sha256_hash((const uint8_t *)label, strlen(label), d); + for (size_t i = 0; i < n; i++) b[i] = d[i % 32]; +} +static void put16(uint8_t *p, uint16_t v) { p[0] = (uint8_t)(v >> 8); p[1] = (uint8_t)v; } +static uint16_t get16(const uint8_t *p) { return (uint16_t)((p[0] << 8) | p[1]); } + +/* ---- 1. PST1 vectors: same verdict line as protocols tools/pst_verify.c ---- */ +static void test_pst_vectors(const char *dir) { + char path[2048]; + snprintf(path, sizeof path, "%s/expected.txt", dir); + FILE *f = fopen(path, "r"); + CHECK(f != NULL, "open %s", path); + if (!f) return; + char line[1024]; + int n_vec = 0; + while (fgets(line, sizeof line, f)) { + if (line[0] == '#' || line[0] == '\n') continue; + char *sp = strchr(line, ' '); + if (!sp) continue; + *sp = 0; + char *want = sp + 1; + want[strcspn(want, "\n")] = 0; + snprintf(path, sizeof path, "%s/%s", dir, line); + FILE *v = fopen(path, "rb"); + CHECK(v != NULL, "open vector %s", path); + if (!v) continue; + uint8_t buf[PST_MAX_MSG + 64]; + size_t n = fread(buf, 1, sizeof buf, v); + fclose(v); + PstMsg m; + int code = pst_decode(buf, n, &m); + char got[1024]; + pst_verdict_line(code, &m, got, sizeof got); + CHECK(strcmp(got, want) == 0, "%s:\n want %s\n got %s", line, want, got); + n_vec++; + } + fclose(f); + CHECK(n_vec == 23, "23 vectors, saw %d", n_vec); + printf("pst1 vectors: %d checked against expected.txt\n", n_vec); +} + +/* ---- 2. HTK1 / HTR1 goldens ---- */ +static void sample_matmul(HtkTask *t) { + memset(t, 0, sizeof *t); + t->kind = HTK_KIND_MATMUL_I64_SEEDED; + t->deadline_ms = 30000; + t->max_out_bytes = 128; + t->max_mem_bytes = 64u << 20; + t->max_in_bytes = 0; + t->threads = 0; + t->matmul.n = 4; + t->matmul.seed = 1; +} +static void sample_tok(HtkTask *t) { + memset(t, 0, sizeof *t); + t->kind = HTK_KIND_TOKENIZE_FIXTURE; + t->deadline_ms = 60000; + t->max_out_bytes = 1u << 20; + t->max_mem_bytes = 512u << 20; + t->max_in_bytes = 4096; + t->threads = 1; + fill(t->tok.fixture_digest, 32, "fixture"); + t->tok.offset = 0; + t->tok.length = 4096; + fill(t->tok.tokenizer_digest, 32, "tokenizer"); +} +static AienMachineId test_machine(const char *label) { + uint8_t sk[32], pk[32]; + AienMachineId id; + fill(sk, 32, label); + aienos_ed25519_public_key(pk, sk); + fab_ed_machine_id(pk, &id); + return id; +} +static void sample_receipt(HtrReceipt *r) { + memset(r, 0, sizeof *r); + r->version = 1; + r->kind = HTK_KIND_MATMUL_I64_SEEDED; + r->flags = HTR_SANDBOX_OS_USER; + fill(r->run_id, 16, "run"); + r->executor = test_machine("het-test-executor"); + fill(r->implementation_digest, 32, "impl"); + HtkTask t; + sample_matmul(&t); + htk_input_digest(&t, r->input_digest); + fill(r->result_digest, 32, "result"); + r->t_accept_us = 1000; r->t_start_us = 1500; r->t_end_us = 9000; + r->cpu_ns = 7000000; r->peak_rss_bytes = 2u << 20; r->threads_used = 1; + memcpy(r->os_arch, "linux-aarch64", 13); + memcpy(r->identity_class, "lab", 3); +} +static size_t read_file(const char *path, uint8_t *buf, size_t cap) { + FILE *f = fopen(path, "rb"); + if (!f) return 0; + size_t n = fread(buf, 1, cap, f); + fclose(f); + return n; +} +static int write_file(const char *path, const uint8_t *b, size_t n) { + FILE *f = fopen(path, "wb"); + if (!f) return -1; + int ok = fwrite(b, 1, n, f) == n; + return fclose(f) == 0 && ok ? 0 : -1; +} +typedef struct { const char *name; uint8_t b[PST_MAX_PAY]; size_t n; } Golden; +static int goldens(Golden g[3]) { + HtkTask t; + sample_matmul(&t); + g[0].name = "htk1-matmul-n4-seed1.bin"; + if (htk_encode(&t, g[0].b, sizeof g[0].b, &g[0].n) != HTK_OK) return -1; + sample_tok(&t); + g[1].name = "htk1-tokenize-fixture.bin"; + if (htk_encode(&t, g[1].b, sizeof g[1].b, &g[1].n) != HTK_OK) return -1; + HtrReceipt r; + sample_receipt(&r); + g[2].name = "htr1-sample.bin"; + if (htr_encode(&r, g[2].b) != HTR_OK) return -1; + g[2].n = HTR_BYTES; + return 0; +} +static int emit(const char *dir) { + Golden g[3]; + if (goldens(g) != 0) return 1; + for (int i = 0; i < 3; i++) { + char path[1024]; + snprintf(path, sizeof path, "%s/%s", dir, g[i].name); + if (write_file(path, g[i].b, g[i].n) != 0) { perror(path); return 1; } + printf("wrote %s (%zu bytes)\n", path, g[i].n); + } + return 0; +} +static void test_goldens(const char *dir) { + Golden g[3]; + CHECK(goldens(g) == 0, "goldens encode"); + for (int i = 0; i < 3; i++) { + char path[1024]; + uint8_t buf[PST_MAX_PAY]; + snprintf(path, sizeof path, "%s/../%s", dir, g[i].name); + size_t n = read_file(path, buf, sizeof buf); + CHECK(n == g[i].n && memcmp(buf, g[i].b, n) == 0, "golden %s differs from encode (%zu vs %zu bytes)", g[i].name, n, g[i].n); + } + HtkTask t, u; + sample_matmul(&t); + CHECK(htk_decode(g[0].b, g[0].n, &u) == HTK_OK && u.kind == 1 && u.matmul.n == 4 && u.matmul.seed == 1 && + u.deadline_ms == 30000 && u.max_out_bytes == 128, "htk1 matmul roundtrip"); + sample_tok(&t); + CHECK(htk_decode(g[1].b, g[1].n, &u) == HTK_OK && u.kind == 2 && u.tok.length == 4096 && + memcmp(u.tok.tokenizer_digest, t.tok.tokenizer_digest, 32) == 0, "htk1 tokenize roundtrip"); + HtrReceipt r, s; + sample_receipt(&r); + CHECK(htr_decode(g[2].b, HTR_BYTES, &s) == HTR_OK && aien_mid_equal(&s.executor, &r.executor) && + s.t_end_us == 9000 && s.threads_used == 1 && memcmp(s.os_arch, "linux-aarch64", 13) == 0 && + memcmp(s.identity_class, "lab", 3) == 0 && s.flags == HTR_SANDBOX_OS_USER, "htr1 roundtrip"); + /* negatives on the codecs */ + uint8_t b[PST_MAX_PAY]; + memcpy(b, g[0].b, g[0].n); + b[5] = 9; CHECK(htk_decode(b, g[0].n, &u) == HTK_BAD_KIND, "htk unknown kind"); + memcpy(b, g[0].b, g[0].n); b[6] = 1; CHECK(htk_decode(b, g[0].n, &u) == HTK_RESERVED_NONZERO, "htk reserved"); + memcpy(b, g[0].b, g[0].n); b[4] = 2; CHECK(htk_decode(b, g[0].n, &u) == HTK_BAD_VERSION, "htk version"); + memcpy(b, g[0].b, g[0].n); CHECK(htk_decode(b, g[0].n - 1, &u) == HTK_BAD_LENGTH, "htk short"); + memcpy(b, g[0].b, g[0].n); b[66] = 3; CHECK(htk_decode(b, g[0].n, &u) == HTK_BAD_BOUNDS, "htk n=0x0304 > 512 is bounds"); + memcpy(b, g[0].b, g[0].n); b[75] = 2; CHECK(htk_decode(b, g[0].n, &u) == HTK_INPUT_DIGEST_MISMATCH, "htk seed changed, digest stale"); + memcpy(b, g[0].b, g[0].n); b[11] = 0; b[10] = 0; b[9] = 0; b[8] = 0; CHECK(htk_decode(b, g[0].n, &u) == HTK_BAD_BOUNDS, "htk deadline 0"); + memcpy(b, g[2].b, HTR_BYTES); b[7] = 4; CHECK(htr_decode(b, HTR_BYTES, &s) == HTR_BAD_FLAGS, "htr flags"); + memcpy(b, g[2].b, HTR_BYTES); b[207] = 1; CHECK(htr_decode(b, HTR_BYTES, &s) == HTR_RESERVED_NONZERO, "htr reserved"); + memcpy(b, g[2].b, HTR_BYTES); b[24] ^= 0xff; CHECK(htr_decode(b, HTR_BYTES, &s) == HTR_BAD_MACHINE, "htr machine record"); + CHECK(htr_decode(g[2].b, HTR_BYTES - 1, &s) == HTR_BAD_LENGTH, "htr short"); + printf("htk1/htr1 goldens: 3 files match, roundtrips and 11 negatives\n"); +} + +/* ---- 3. matmul oracle ---- */ +typedef struct { uint32_t n; uint64_t seed; const char *digest; } Oracle; +/* Computed by this implementation on 2026-10-18 (first run); the benchmarks lane's + * independent oracle and the Rust worker must reproduce them, or the definition is unclear. */ +static const Oracle oracle[3] = { + { 4, 1, "705d18096163be46e7cc44b757fe26787ed059045954ff99a2a94c6e575607cb" }, + { 64, 7, "f0d209befe915f5f624d48b784c3acd10f51ef2df8f41e0f92580e3770ae07d0" }, + { 256, 42, "74f59d70c133f9573943edf21b781e4e19c57e9ab6c822036542e8209c9211cc" }, +}; +static int64_t scratch[HTK_MATMUL_N_MAX * HTK_MATMUL_N_MAX]; +static void print_oracle(void) { + for (int i = 0; i < 3; i++) { + uint8_t d[32]; + char h[65]; + htk_matmul_result_digest(oracle[i].n, oracle[i].seed, scratch, d); + hex(d, 32, h); + printf("matmul n=%u seed=%llu result_digest=%s\n", oracle[i].n, (unsigned long long)oracle[i].seed, h); + } +} +static void test_oracle(void) { + /* The definition is pinned by hand values first: n=1 is a single product. */ + int64_t one; + CHECK(htk_matmul_i64(1, 5, &one) == HTK_OK, "n=1"); + uint64_t a = htk_splitmix(5, 0, 0), b = htk_splitmix(5, 1, 0); + CHECK((uint64_t)one == a * b, "n=1 is a*b wrapping"); + CHECK(htk_splitmix(0, 0, 0) != htk_splitmix(0, 1, 0), "streams differ"); + CHECK(htk_matmul_i64(0, 1, scratch) == HTK_BAD_BOUNDS && htk_matmul_i64(513, 1, scratch) == HTK_BAD_BOUNDS, "n bounds"); + for (int i = 0; i < 3; i++) { + uint8_t d[32]; + char h[65]; + CHECK(htk_matmul_result_digest(oracle[i].n, oracle[i].seed, scratch, d) == HTK_OK, "digest n=%u", oracle[i].n); + hex(d, 32, h); + CHECK(strcmp(h, oracle[i].digest) == 0, "oracle n=%u seed=%llu: want %s got %s", oracle[i].n, + (unsigned long long)oracle[i].seed, oracle[i].digest, h); + } + printf("matmul oracle: 3 digests reproduced\n"); +} + +/* ---- in-memory executor used by the unit tests and the --executor process ---- */ +typedef struct { FILE *f; int fail_next; uint64_t appended; } MemStore; +static int store_append(void *ctx, const uint8_t *rec, size_t len) { + MemStore *s = ctx; + if (s->fail_next) { s->fail_next = 0; return -1; } + if (s->f) { + if (fwrite(rec, 1, len, s->f) != len || fflush(s->f) != 0 || fsync(fileno(s->f)) != 0) return -1; + } + s->appended++; + return 0; +} + +typedef struct { + FwExecutor x; + FwExecLimits lim; + MemStore store_ctx; + FwJournalStore store; + AienMachineId self; + uint8_t impl_digest[32]; + uint32_t ordinal[FW_MAX_TASKS]; /* per-task send ordinal, keyed by task slot below */ + uint8_t task_ids[FW_MAX_TASKS][16]; + uint32_t n_tasks; + uint64_t now_us; +} Exec; + +static uint32_t exec_slot(Exec *e, const uint8_t task[16]) { + for (uint32_t i = 0; i < e->n_tasks; i++) if (memcmp(e->task_ids[i], task, 16) == 0) return i; + uint32_t i = e->n_tasks < FW_MAX_TASKS ? e->n_tasks++ : FW_MAX_TASKS - 1; + memcpy(e->task_ids[i], task, 16); + e->ordinal[i] = 0; + return i; +} +static void exec_init(Exec *e, FILE *journal) { + memset(e, 0, sizeof *e); + e->store_ctx.f = journal; + e->store.ctx = &e->store_ctx; + e->store.append = store_append; + fw_exec_init(&e->x, &e->store); + e->lim.cpus = 4; + e->lim.mem_bytes = 1ull << 30; + e->lim.kinds = 1u << HTK_KIND_MATMUL_I64_SEEDED; /* the C test executor serves matmul only */ + e->self = test_machine("het-test-executor"); + fill(e->impl_digest, 32, "fab_work_test executor"); + e->now_us = 1000000; +} +/* Builds one executor->requester message for task m with the given type/payload. */ +static size_t exec_msg(Exec *e, const PstMsg *req, uint8_t type, const uint8_t *pl, size_t pn, uint8_t *out, size_t cap) { + PstMsg m = *req; + m.type = type; + m.ordinal = e->ordinal[exec_slot(e, req->task)]++; + size_t n = 0; + if (pst_encode(&m, pl, pn, out, cap, &n) != PST_OK) return 0; + return n; +} +/* Handles one decoded request; writes 0..3 reply messages into out (each length-prefixed u16). */ +static size_t exec_handle(Exec *e, const PstMsg *req, uint8_t *out, size_t cap) { + size_t used = 0; + uint8_t pl[PST_MAX_PAY]; + size_t pn = 0; +#define EMIT(type, p, n) do { \ + size_t _m = exec_msg(e, req, (type), (p), (n), out + used + 2, cap - used - 2); \ + if (!_m) return used; \ + put16(out + used, (uint16_t)_m); \ + used += 2 + _m; \ + } while (0) + if (req->type == PST_T_RESUME_REQUEST) { + const FwJournalEntry *j = fw_exec_lookup(&e->x, req->task, req->idem); + fw_resume_snapshot_payload(j, pl, sizeof pl, &pn); + EMIT(PST_T_RESUME_SNAPSHOT, pl, pn); + return used; + } + HtkTask t; + const FwJournalEntry *replay = NULL; + uint16_t code = 0; + int a = fw_exec_admit(&e->x, req, &e->lim, &t, &replay, &code); + if (a == FW_ADMIT_REPLAY) { + fw_terminal_payload(replay, "replayed", pl, sizeof pl, &pn); + EMIT(replay->terminal_type, pl, pn); + return used; + } + if (a == FW_ADMIT_REFUSE) { + if (!code) return 0; /* wrong side: nothing is sent */ + /* A code-7 answer is about the key's existing entry, not a new terminal + * for the key: it is never journaled (the original bytes still replay). */ + if (code != FW_FAIL_DUPLICATE_DIFFERENT) { + FwJournalEntry j = {0}; + memcpy(j.task, req->task, 16); memcpy(j.idem, req->idem, 16); memcpy(j.htk_digest, req->digest, 32); + j.terminal_type = PST_T_FAILED; j.fail_code = code; + if (fw_exec_record(&e->x, &j) != FW_X_OK) return 0; /* not journaled: not sent */ + } + fw_failed_payload(code, fw_exec_code_name(code == FW_FAIL_BOUNDS ? FW_X_BOUNDS : code == FW_FAIL_UNKNOWN_KIND ? FW_X_KIND : code == FW_FAIL_DUPLICATE_DIFFERENT ? FW_X_DUPLICATE_DIFFERENT : FW_X_BAD_HTK), pl, sizeof pl, &pn); + EMIT(PST_T_FAILED, pl, pn); + return used; + } + EMIT(PST_T_ACCEPTED, NULL, 0); + EMIT(PST_T_RUNNING, NULL, 0); + uint64_t t_accept = e->now_us, t_start = e->now_us + 10; + uint8_t rd[32]; + htk_matmul_result_digest(t.matmul.n, t.matmul.seed, scratch, rd); + e->now_us += 1000; + HtrReceipt r = {0}; + r.version = 1; r.kind = t.kind; r.flags = HTR_SANDBOX_NONE; + fill(r.run_id, 16, "run-id"); r.run_id[15] = (uint8_t)e->x.recorded; + r.executor = e->self; + memcpy(r.implementation_digest, e->impl_digest, 32); + memcpy(r.input_digest, t.input_digest, 32); + memcpy(r.result_digest, rd, 32); + r.t_accept_us = t_accept; r.t_start_us = t_start; r.t_end_us = e->now_us; + r.cpu_ns = 1000 * 1000; r.peak_rss_bytes = sizeof scratch; r.threads_used = 1; + memcpy(r.os_arch, "linux-test", 10); + memcpy(r.identity_class, "lab", 3); + FwJournalEntry j = {0}; + memcpy(j.task, req->task, 16); memcpy(j.idem, req->idem, 16); memcpy(j.htk_digest, req->digest, 32); + j.terminal_type = PST_T_COMPLETED; j.has_receipt = 1; j.receipt = r; memcpy(j.result_digest, rd, 32); + if (fw_exec_record(&e->x, &j) != FW_X_OK) return used; /* journal refused: no terminal is sent */ + fw_terminal_payload(&j, NULL, pl, sizeof pl, &pn); + EMIT(PST_T_COMPLETED, pl, pn); +#undef EMIT + return used; +} + +/* ---- requester side helpers ---- */ +static PstMsg make_request(const char *task_label, const char *idem_label, const HtkTask *t, uint8_t *pl, size_t *pn) { + PstMsg m; + memset(&m, 0, sizeof m); + m.version = 1; m.type = PST_T_REQUEST; m.effect = PST_EFFECT_COMPUTE; + fill(m.cause, 32, "cause"); fill(m.origin, 32, "origin"); fill(m.objective, 32, "objective"); fill(m.subject, 32, "subject"); + fill(m.task, 16, task_label); fill(m.idem, 16, idem_label); + CHECK(htk_encode(t, pl, PST_MAX_PAY, pn) == HTK_OK, "encode htk"); + return m; +} +/* Feeds every length-prefixed message in buf to the requester; returns the last code. */ +static int feed(FwRequester *r, const uint8_t *buf, size_t n, const AienMachineId *peer, int *count) { + int last = FW_R_OK; + size_t off = 0; + while (off + 2 <= n) { + uint16_t len = get16(buf + off); + PstMsg m; + CHECK(pst_decode(buf + off + 2, len, &m) == PST_OK, "reply decodes"); + last = fw_req_receive(r, &m, peer, 0); + if (count) (*count)++; + off += 2 + len; + } + return last; +} + +/* ---- 4. requester <-> executor in one process, with the named negatives ---- */ +static void test_state_machines(void) { + Exec e; + exec_init(&e, NULL); + FwRequester r; + fw_req_init(&r); + AienMachineId peer = e.self, stranger = test_machine("stranger"); + uint8_t pl[PST_MAX_PAY], msg[PST_MAX_MSG], replies[8 * PST_MAX_MSG]; + size_t pn, mn, rn; + HtkTask t; + sample_matmul(&t); + + /* happy path: request -> accepted, running, completed(HTR1); result verifies */ + PstMsg q = make_request("task-1", "idem-1", &t, pl, &pn); + uint8_t in_digest[32]; + htk_input_digest(&t, in_digest); + CHECK(fw_req_send(&r, q.task, q.idem, in_digest, 5000000) == FW_R_OK, "send"); + CHECK(pst_encode(&q, pl, pn, msg, sizeof msg, &mn) == PST_OK, "encode request"); + PstMsg qd; + CHECK(pst_decode(msg, mn, &qd) == PST_OK, "request decodes"); + CHECK(pst_side_check(qd.type, PST_ROLE_REQUESTER) == PST_OK && pst_side_check(qd.type, PST_ROLE_EXECUTOR) == PST_WRONG_SIDE, "side rule"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + int cnt = 0; + CHECK(feed(&r, replies, rn, &peer, &cnt) == FW_R_OK && cnt == 3, "3 replies applied (%d)", cnt); + FwTask *ft = fw_req_find(&r, q.task); + CHECK(ft && ft->state == FW_ST_COMPLETED && ft->has_receipt && ft->next_ordinal == 3, "COMPLETED with receipt"); + uint8_t want[32]; + htk_matmul_result_digest(4, 1, scratch, want); + CHECK(memcmp(ft->result_digest, want, 32) == 0, "result digest is the oracle's"); + uint8_t result[128]; + htk_matmul_i64(4, 1, scratch); + htk_matmul_result_bytes(4, scratch, result); + CHECK(fw_req_verify_result(ft, result, 128) == FW_R_OK, "result bytes verify"); + result[3] ^= 1; + CHECK(fw_req_verify_result(ft, result, 128) == FW_R_RESULT_DIGEST, "NEG wrong result bytes refused"); + + /* NEG duplicate terminal */ + size_t last_off = 0, off = 0; + while (off + 2 <= rn) { last_off = off; off += 2u + get16(replies + off); } + PstMsg dup; + CHECK(pst_decode(replies + last_off + 2, get16(replies + last_off), &dup) == PST_OK, "dup decodes"); + CHECK(fw_req_receive(&r, &dup, &peer, 0) == FW_R_ORDINAL, "NEG replayed completed refused (ordinal)"); + dup.ordinal = 3; + CHECK(fw_req_receive(&r, &dup, &peer, 0) == FW_R_TERMINAL, "NEG second terminal refused"); + CHECK(ft->state == FW_ST_COMPLETED && ft->next_ordinal == 3, "state unchanged"); + + /* NEG reordered ordinal + receipt from the wrong peer, on a second task */ + PstMsg q2 = make_request("task-2", "idem-2", &t, pl, &pn); + CHECK(fw_req_send(&r, q2.task, q2.idem, in_digest, 5000000) == FW_R_OK, "send 2"); + CHECK(pst_encode(&q2, pl, pn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 2"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + uint16_t l0 = get16(replies); + PstMsg m1, m2; + CHECK(pst_decode(replies + 2 + l0 + 2, get16(replies + 2 + l0), &m1) == PST_OK, "running decodes"); + CHECK(fw_req_receive(&r, &m1, &peer, 0) == FW_R_ORDINAL, "NEG ordinal 1 before 0 refused"); + off = 2u + l0 + 2u + get16(replies + 2 + l0); + CHECK(pst_decode(replies + off + 2, get16(replies + off), &m2) == PST_OK, "completed decodes"); + PstMsg m0; + CHECK(pst_decode(replies + 2, l0, &m0) == PST_OK && fw_req_receive(&r, &m0, &peer, 0) == FW_R_OK, "accepted ok"); + CHECK(fw_req_receive(&r, &m1, &peer, 0) == FW_R_OK, "running ok in order"); + CHECK(fw_req_receive(&r, &m2, &stranger, 0) == FW_R_RECEIPT_PEER, "NEG receipt executor != session peer"); + CHECK(fw_req_find(&r, q2.task)->state == FW_ST_RUNNING, "still RUNNING after refusal"); + /* NEG receipt result digest differs from the completed digest */ + uint8_t tampered[PST_MAX_MSG]; + memcpy(tampered, replies + off + 2, get16(replies + off)); + tampered[PST_HDR + 32 + 132] ^= 1; /* HTR1.result_digest inside the payload */ + sha256_hash(tampered + PST_HDR, m2.payload_len, tampered + 192); /* keep PST1 digest valid */ + PstMsg m2t; + CHECK(pst_decode(tampered, get16(replies + off), &m2t) == PST_OK, "tampered decodes as PST1"); + CHECK(fw_req_receive(&r, &m2t, &peer, 0) == FW_R_RESULT_DIGEST, "NEG receipt digest != completed digest"); + CHECK(fw_req_receive(&r, &m2, &peer, 0) == FW_R_OK && fw_req_find(&r, q2.task)->state == FW_ST_COMPLETED, "genuine completed ok"); + + /* NEG unknown task, wrong side at the requester */ + PstMsg stray = m0; + fill(stray.task, 16, "nobody"); + CHECK(fw_req_receive(&r, &stray, &peer, 0) == FW_R_UNKNOWN_TASK, "NEG unknown task"); + PstMsg ws = m0; ws.type = PST_T_CANCEL_REQUEST; + CHECK(fw_req_receive(&r, &ws, &peer, 0) == FW_R_WRONG_SIDE, "NEG requester-side type refused"); + + /* NEG oversized frame */ + uint8_t big[PST_MAX_MSG + 1]; + memset(big, 0, sizeof big); + PstMsg bm; + CHECK(pst_decode(big, sizeof big, &bm) == PST_BAD_LENGTH, "NEG 1025-byte frame refused"); + CHECK(pst_encode(&q, pl, PST_MAX_PAY + 1, big, sizeof big, &mn) == PST_BAD_LENGTH, "NEG 801-byte payload refused at encode"); + + /* NEG unknown kind at the executor -> failed code 2 */ + HtkTask bad = t; + uint8_t rawpl[PST_MAX_PAY]; + size_t rawn; + CHECK(htk_encode(&bad, rawpl, sizeof rawpl, &rawn) == HTK_OK, "raw"); + rawpl[5] = 7; + PstMsg q3 = make_request("task-3", "idem-3", &t, pl, &pn); + CHECK(pst_encode(&q3, rawpl, rawn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 3"); + CHECK(fw_req_send(&r, q3.task, q3.idem, in_digest, 5000000) == FW_R_OK, "send 3"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + CHECK(feed(&r, replies, rn, &peer, NULL) == FW_R_OK && fw_req_find(&r, q3.task)->state == FW_ST_FAILED && + fw_req_find(&r, q3.task)->fail_code == FW_FAIL_UNKNOWN_KIND, "NEG unknown kind -> failed 2"); + /* kind 2 is well-formed but this executor does not serve it -> also code 2 */ + HtkTask tk; sample_tok(&tk); + PstMsg q3b = make_request("task-3b", "idem-3b", &tk, pl, &pn); + CHECK(pst_encode(&q3b, pl, pn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 3b"); + CHECK(fw_req_send(&r, q3b.task, q3b.idem, in_digest, 5000000) == FW_R_OK, "send 3b"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + CHECK(feed(&r, replies, rn, &peer, NULL) == FW_R_OK && fw_req_find(&r, q3b.task)->fail_code == FW_FAIL_UNKNOWN_KIND, "NEG unserved kind -> failed 2"); + + /* NEG bounds exceeded -> failed code 1 (threads above the executor's cpus; result larger than max_out) */ + HtkTask tb = t; tb.threads = 64; + PstMsg q4 = make_request("task-4", "idem-4", &tb, pl, &pn); + CHECK(pst_encode(&q4, pl, pn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 4"); + CHECK(fw_req_send(&r, q4.task, q4.idem, in_digest, 5000000) == FW_R_OK, "send 4"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + CHECK(feed(&r, replies, rn, &peer, NULL) == FW_R_OK && fw_req_find(&r, q4.task)->fail_code == FW_FAIL_BOUNDS, "NEG threads > cpus -> failed 1"); + HtkTask tc = t; tc.max_out_bytes = 64; /* n=4 needs 128 */ + PstMsg q4b = make_request("task-4b", "idem-4b", &tc, pl, &pn); + CHECK(pst_encode(&q4b, pl, pn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 4b"); + CHECK(fw_req_send(&r, q4b.task, q4b.idem, in_digest, 5000000) == FW_R_OK, "send 4b"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + CHECK(feed(&r, replies, rn, &peer, NULL) == FW_R_OK && fw_req_find(&r, q4b.task)->fail_code == FW_FAIL_BOUNDS, "NEG max_out too small -> failed 1"); + + /* idempotence: same bytes replayed from the journal (no re-run), different bytes -> code 7 */ + uint64_t admitted = e.x.admitted; + CHECK(pst_encode(&q, pl, pn, msg, sizeof msg, &mn) == PST_OK, "re-encode task-1"); + sample_matmul(&t); + CHECK(htk_encode(&t, pl, PST_MAX_PAY, &pn) == HTK_OK && pst_encode(&q, pl, pn, msg, sizeof msg, &mn) == PST_OK && + pst_decode(msg, mn, &qd) == PST_OK, "task-1 again"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + PstMsg rp; + CHECK(rn > 2 && pst_decode(replies + 2, get16(replies), &rp) == PST_OK && rp.type == PST_T_COMPLETED && + rp.payload_len == 32 + HTR_BYTES && memcmp(rp.payload, want, 32) == 0, "replay returns the journaled completed"); + CHECK(e.x.admitted == admitted && e.x.replayed == 1, "no re-run on replay"); + HtkTask td = t; td.matmul.seed = 2; + CHECK(htk_encode(&td, pl, PST_MAX_PAY, &pn) == HTK_OK && pst_encode(&q, pl, pn, msg, sizeof msg, &mn) == PST_OK && + pst_decode(msg, mn, &qd) == PST_OK, "task-1 other bytes"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + CHECK(rn > 2 && pst_decode(replies + 2, get16(replies), &rp) == PST_OK && rp.type == PST_T_FAILED && + get16(rp.payload) == FW_FAIL_DUPLICATE_DIFFERENT, "NEG repeat with different bytes -> failed 7"); + + /* NEG journal store refuses: nothing is sent */ + HtkTask te = t; te.matmul.seed = 99; + PstMsg q5 = make_request("task-5", "idem-5", &te, pl, &pn); + CHECK(pst_encode(&q5, pl, pn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 5"); + e.store_ctx.fail_next = 1; + rn = exec_handle(&e, &qd, replies, sizeof replies); + cnt = 0; off = 0; + while (off + 2 <= rn) { cnt++; off += 2u + get16(replies + off); } + CHECK(cnt == 2 && e.x.refused[FW_X_STORE] == 1 && fw_exec_lookup(&e.x, q5.task, q5.idem) == NULL, + "NEG store failure: accepted+running sent, no terminal, nothing journaled (%d msgs)", cnt); + + /* NEG session drop before terminal -> UNCERTAIN; resume_snapshot resolves it */ + HtkTask tf = t; tf.matmul.seed = 3; + uint8_t in6[32]; + htk_input_digest(&tf, in6); + PstMsg q6 = make_request("task-6", "idem-6", &tf, pl, &pn); + CHECK(fw_req_send(&r, q6.task, q6.idem, in6, 5000000) == FW_R_OK, "send 6"); + CHECK(pst_encode(&q6, pl, pn, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "req 6"); + rn = exec_handle(&e, &qd, replies, sizeof replies); /* executor finished, replies "lost" */ + CHECK(fw_req_session_lost(&r) == 1 && fw_req_find(&r, q6.task)->state == FW_ST_UNCERTAIN, "NEG session lost -> UNCERTAIN"); + PstMsg lost; + CHECK(pst_decode(replies + 2, get16(replies), &lost) == PST_OK && fw_req_receive(&r, &lost, &peer, 0) == FW_R_STATE, + "late accepted refused in UNCERTAIN"); + PstMsg rr = q6; rr.type = PST_T_RESUME_REQUEST; rr.ordinal = 1; + CHECK(pst_encode(&rr, NULL, 0, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "resume_request"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + PstMsg snap; + CHECK(pst_decode(replies + 2, get16(replies), &snap) == PST_OK && snap.type == PST_T_RESUME_SNAPSHOT, "snapshot"); + /* the executor's ordinals for task-6 continued at 3 (accepted, running, completed were sent); fast-forward the requester */ + fw_req_find(&r, q6.task)->next_ordinal = snap.ordinal; + CHECK(fw_req_receive(&r, &snap, &peer, 0) == FW_R_OK && fw_req_find(&r, q6.task)->state == FW_ST_COMPLETED && + fw_req_find(&r, q6.task)->has_receipt, "resume_snapshot -> COMPLETED with receipt"); + /* unknown task in a snapshot stays UNCERTAIN with the flag */ + PstMsg q7 = make_request("task-7", "idem-7", &tf, pl, &pn); + CHECK(fw_req_send(&r, q7.task, q7.idem, in6, 5000000) == FW_R_OK && fw_req_session_lost(&r) == 1, "task-7 uncertain"); + PstMsg rr7 = q7; rr7.type = PST_T_RESUME_REQUEST; + CHECK(pst_encode(&rr7, NULL, 0, msg, sizeof msg, &mn) == PST_OK && pst_decode(msg, mn, &qd) == PST_OK, "resume 7"); + rn = exec_handle(&e, &qd, replies, sizeof replies); + CHECK(pst_decode(replies + 2, get16(replies), &snap) == PST_OK && snap.payload_len == 1 && snap.payload[0] == 0, "unknown snapshot"); + CHECK(fw_req_receive(&r, &snap, &peer, 0) == FW_R_OK && fw_req_find(&r, q7.task)->state == FW_ST_UNCERTAIN && + fw_req_find(&r, q7.task)->resume_unknown == 1, "unknown task stays UNCERTAIN, flagged"); + + /* NEG deadline passed -> UNCERTAIN */ + PstMsg q8 = make_request("task-8", "idem-8", &t, pl, &pn); + CHECK(fw_req_send(&r, q8.task, q8.idem, in_digest, 2000) == FW_R_OK, "send 8"); + CHECK(fw_req_tick(&r, 1999) == 0 && fw_req_tick(&r, 2001) == 1 && fw_req_find(&r, q8.task)->state == FW_ST_UNCERTAIN, + "NEG deadline passed -> UNCERTAIN"); + + /* journal entries survive a reload (encode/decode) */ + uint8_t rec[FW_JOURNAL_ENTRY_BYTES]; + const FwJournalEntry *je = fw_exec_lookup(&e.x, q.task, q.idem); + FwJournalEntry back; + CHECK(je && fw_journal_encode(je, rec) == 0 && fw_journal_decode(rec, sizeof rec, &back) == 0 && + memcmp(&back.result_digest, je->result_digest, 32) == 0 && back.has_receipt && + aien_mid_equal(&back.receipt.executor, &e.self), "journal entry roundtrip"); + FwExecutor x2; + CHECK(fw_exec_init(&x2, &e.store) == FW_X_OK && fw_exec_load(&x2, rec, sizeof rec) == FW_X_OK && + fw_exec_lookup(&x2, q.task, q.idem) != NULL, "journal reload"); + rec[64] = 5; + CHECK(fw_exec_load(&x2, rec, sizeof rec) == FW_X_STORE, "NEG corrupt journal entry refused"); + printf("state machines: happy path, idempotence, UNCERTAIN/resume and %d-check negative set\n", checks); +} + +/* ---- 5. Ed25519 Fabric membership over the loopback ---- */ +#define LEASE 1000000ull +typedef struct { + uint8_t sk[4][32]; + FabEdAuth auth[4]; + AienMachineId roster_ids[3]; + FabRoster roster; + FabLoop loop; + AienMachineId slots[4][8]; + AienMachineIndex index[4]; + CqCatalog cat[4]; + FabNode node[4]; +} EdHouse; + +static void ed_house_init(EdHouse *h) { + memset(h, 0, sizeof *h); + const char *labels[4] = { "het-seed-A", "het-seed-B", "het-seed-C", "het-seed-D" }; + for (int i = 0; i < 4; i++) { + fill(h->sk[i], 32, labels[i]); + CHECK(fab_ed_auth_init(&h->auth[i], h->sk[i]) == FAB_OK, "ed init"); + } + /* A, B, C enrol each other; D is nobody. */ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + if (i != j) CHECK(fab_ed_auth_add_peer(&h->auth[i], h->auth[j].pk) == FAB_OK, "add peer"); + CHECK(fab_ed_auth_add_peer(&h->auth[0], h->auth[1].pk) == FAB_E_ARG, "duplicate peer refused"); + CHECK(fab_ed_auth_add_peer(&h->auth[0], h->auth[0].pk) == FAB_E_ARG, "own key as peer refused"); + uint32_t n = 0; + CHECK(fab_ed_auth_roster(&h->auth[0], h->roster_ids, 3, &n) == FAB_OK && n == 3, "roster"); + h->roster.n = 3; + h->roster.ids = h->roster_ids; + fab_loop_init(&h->loop); + for (int i = 0; i < 4; i++) CHECK(fab_loop_add(&h->loop, &h->auth[i].self) == FAB_OK, "loop add"); + for (int i = 0; i < 4; i++) { + aien_mid_index_init(&h->index[i], h->slots[i], 8); + CqCatalog *c = &h->cat[i]; + CHECK(cq_catalog_init_canonical(c, &h->index[i], &h->auth[i].self, 8, 16) == CQ_OK, "catalog"); + uint32_t dom = CQ_SRC(CQ_SRC_GRAPH) | CQ_SRC(CQ_SRC_FABRIC); + CHECK(cq_op_define(c, 1, 0, dom) == CQ_OK, "op"); + FabConfig cfg = { h->auth[i].self, &h->roster, c, &h->loop.transport, &h->auth[i].auth, LEASE, 1, NULL, 0 }; + CHECK(fab_node_init(&h->node[i], &cfg) == FAB_OK, "node init %d", i); + } +} +static void drain(FabNode *n, uint64_t now) { FabVerdict v; while (fab_poll(n, now, &v) > 0) {} } +/* The newest message waiting in `to`'s loopback box (broadcast seals one copy per + * destination, so loop.last is the copy to the last roster peer, not to A). */ +static size_t last_to(const FabLoop *l, const AienMachineId *to, uint8_t *out) { + for (uint32_t i = 0; i < l->n; i++) { + const FabLoopBox *b = &l->box[i]; + if (!aien_mid_equal(&b->id, to) || b->count == 0) continue; + const FabLoopMsg *m = &b->q[(b->head + b->count - 1u) % FAB_LOOP_DEPTH]; + memcpy(out, m->b, m->len); + return m->len; + } + return 0; +} + +static void test_ed25519_fabric(void) { + static EdHouse h; + ed_house_init(&h); + uint64_t now = 10; + FabVerdict v; + uint8_t join1[FAB_MSG_MAX], join2[FAB_MSG_MAX]; + size_t n1, n2; + + const AienMachineId *A = &h.auth[0].self; + /* B joins at generation 1: keep A's copy of the bytes before it is applied */ + CHECK(fab_join(&h.node[1], LEASE, now) == FAB_OK, "B join gen 1"); + n1 = last_to(&h.loop, A, join1); + CHECK(n1 == FAB_HDR_BYTES + FAB_JOIN_BODY + FAB_SIG_BYTES, "JOIN to A is %zu bytes", n1); + drain(&h.node[0], now); drain(&h.node[2], now); /* A, C see the gen-1 JOIN now */ + CHECK(fab_member_live(&h.node[0], &h.auth[1].self, now), "A holds B live after signed JOIN"); + /* B restarts at generation 2 */ + CHECK(fab_node_set_generation(&h.node[1], 2) == FAB_OK && fab_join(&h.node[1], LEASE, now) == FAB_OK, "B join gen 2"); + n2 = last_to(&h.loop, A, join2); + drain(&h.node[0], now); drain(&h.node[2], now); + CHECK(fab_receive(&h.node[0], join2, n2, now, &v) < 0 && v.code == FAB_E_REPLAY, + "NEG replay of the gen-2 JOIN refused: %s", fab_strerror(v.code)); + CHECK(fab_receive(&h.node[0], join1, n1, now, &v) < 0 && v.code == FAB_E_STALE_GEN, + "NEG stale generation refused: %s", fab_strerror(v.code)); + + /* NEG forged: A's copy of a genuine B message with a fresh timestamp, signed by D's key */ + uint8_t forged[FAB_MSG_MAX]; + size_t nf = n2; + memcpy(forged, join2, nf); + forged[FAB_HDR_BYTES - 8] ^= 1; /* sent_us differs: not a byte replay */ + aienos_ed25519_sign(forged + nf - 64, forged, nf - 64, h.sk[3]); + int rc = fab_receive(&h.node[0], forged, nf, now, &v); + CHECK(rc < 0 && v.code == FAB_E_AUTH, "NEG wrong key refused: %s", fab_strerror(v.code)); + /* altered bytes under the genuine signature are refused the same way */ + memcpy(forged, join2, nf); + forged[FAB_HDR_BYTES + 3] ^= 1; + rc = fab_receive(&h.node[0], forged, nf, now, &v); + CHECK(rc < 0 && v.code == FAB_E_AUTH, "NEG altered body refused: %s", fab_strerror(v.code)); + + /* NEG unknown machine: D (not on A's roster) joins */ + CHECK(fab_join(&h.node[3], LEASE, now) == FAB_OK, "D join sends"); + uint8_t joind[FAB_MSG_MAX]; + size_t nd = last_to(&h.loop, A, joind); + rc = fab_receive(&h.node[0], joind, nd, now, &v); + CHECK(rc < 0 && v.code == FAB_E_NOT_ENROLLED, "NEG unknown machine refused: %s", fab_strerror(v.code)); + drain(&h.node[0], now); drain(&h.node[1], now); drain(&h.node[2], now); + CHECK(!fab_member_live(&h.node[0], &h.auth[3].self, now), "D never live at A"); + + /* positive: C joins and advertises, A sees it live; lease ends -> not live */ + CHECK(fab_join(&h.node[2], LEASE, now) == FAB_OK, "C join"); + drain(&h.node[0], now); + CHECK(fab_member_live(&h.node[0], &h.auth[2].self, now) && fab_member_live(&h.node[0], &h.auth[1].self, now), "B and C live at A"); + (void)fab_tick(&h.node[0], now + LEASE + 1); + CHECK(!fab_member_live(&h.node[0], &h.auth[2].self, now + LEASE + 1), "lease ended -> not live"); + /* a route check cannot name a non-member: fab_route_check with a null router is FAB_RT_ARG */ + AienMachineId tgt; + CHECK(fab_route_check(&h.node[0], NULL, NULL, now, &tgt, NULL, NULL) == FAB_RT_ARG, "route check arg"); + CHECK(fab_route_pump(&h.node[0], now, NULL, NULL) == 0, "pump empty"); + for (int i = 0; i < 4; i++) fab_ed_auth_wipe(&h.auth[i]); + uint8_t z[sizeof h.auth[0].sk] = {0}; + CHECK(memcmp(h.auth[0].sk, z, 32) == 0, "seed wiped"); + printf("ed25519 fabric: signed JOIN accepted; forged key, unknown machine, stale generation, replay refused\n"); +} + +/* ---- two-process mode over pipes ---- */ +static int read_frame(FILE *in, uint8_t *buf, size_t cap, size_t *len) { + uint8_t l[2]; + if (fread(l, 1, 2, in) != 2) return 0; + size_t n = get16(l); + if (n > cap) return -1; + if (fread(buf, 1, n, in) != n) return -1; + *len = n; + return 1; +} +static int write_frames(FILE *out, const uint8_t *buf, size_t n) { + if (fwrite(buf, 1, n, out) != n) return -1; + return fflush(out); +} +static int run_executor(const char *journal_path) { + FILE *j = fopen(journal_path, "ab"); + if (!j) { perror(journal_path); return 2; } + Exec e; + exec_init(&e, j); + uint8_t in[PST_MAX_MSG], replies[8 * PST_MAX_MSG]; + size_t n; + int rc; + uint64_t frames = 0, refused = 0; + while ((rc = read_frame(stdin, in, sizeof in, &n)) == 1) { + frames++; + PstMsg m; + int c = pst_decode(in, n, &m); + if (c != PST_OK) { refused++; fprintf(stderr, "executor: refuse %s\n", pst_code_name(c)); continue; } + size_t rn = exec_handle(&e, &m, replies, sizeof replies); + if (write_frames(stdout, replies, rn) != 0) return 3; + } + fclose(j); + fprintf(stderr, "executor: frames=%llu refused=%llu admitted=%llu replayed=%llu journaled=%llu\n", + (unsigned long long)frames, (unsigned long long)refused, (unsigned long long)e.x.admitted, + (unsigned long long)e.x.replayed, (unsigned long long)e.x.recorded); + return rc < 0 ? 4 : 0; +} +static int run_requester(const char *peer_hex) { + uint8_t rec[AIEN_MID_RECORD_BYTES]; + AienMachineId peer; + if (unhex(peer_hex, rec, sizeof rec) != 0 || aien_mid_decode(rec, sizeof rec, &peer) != AIEN_MID_OK) { + fprintf(stderr, "requester: bad peer id\n"); + return 2; + } + FwRequester r; + fw_req_init(&r); + HtkTask t; + sample_matmul(&t); + t.matmul.n = 64; t.matmul.seed = 7; t.max_out_bytes = 64 * 64 * 8; + uint8_t pl[PST_MAX_PAY], msg[PST_MAX_MSG], frame[2 + PST_MAX_MSG], in[PST_MAX_MSG], want[32], in_digest[32]; + size_t pn, mn, n; + PstMsg q = make_request("proc-task-1", "proc-idem-1", &t, pl, &pn); + htk_input_digest(&t, in_digest); + htk_matmul_result_digest(64, 7, scratch, want); + if (fw_req_send(&r, q.task, q.idem, in_digest, 60000000) != FW_R_OK) return 3; + if (pst_encode(&q, pl, pn, msg, sizeof msg, &mn) != PST_OK) return 3; + put16(frame, (uint16_t)mn); memcpy(frame + 2, msg, mn); + if (write_frames(stdout, frame, 2 + mn) != 0) return 3; + int got = 0; + FwTask *ft = fw_req_find(&r, q.task); + while (!fw_state_terminal(ft->state) && read_frame(stdin, in, sizeof in, &n) == 1) { + PstMsg m; + if (pst_decode(in, n, &m) != PST_OK) { fprintf(stderr, "requester: undecodable reply\n"); return 4; } + int c = fw_req_receive(&r, &m, &peer, 0); + if (c != FW_R_OK) { fprintf(stderr, "requester: refused %s\n", fw_req_code_name(c)); return 4; } + got++; + } + if (ft->state != FW_ST_COMPLETED || !ft->has_receipt) { fprintf(stderr, "requester: not completed (%s)\n", fw_state_name(ft->state)); return 5; } + if (memcmp(ft->result_digest, want, 32) != 0) { fprintf(stderr, "requester: result digest is not the oracle's\n"); return 6; } + /* replay the same request: the executor must answer from its journal with the same terminal */ + if (write_frames(stdout, frame, 2 + mn) != 0) return 3; + if (read_frame(stdin, in, sizeof in, &n) != 1) return 7; + PstMsg rp; + if (pst_decode(in, n, &rp) != PST_OK || rp.type != PST_T_COMPLETED || memcmp(rp.payload, want, 32) != 0) { + fprintf(stderr, "requester: replay did not return the journaled completed\n"); return 7; + } + /* same key, other bytes: failed 7 */ + t.matmul.seed = 8; + if (htk_encode(&t, pl, sizeof pl, &pn) != HTK_OK || pst_encode(&q, pl, pn, msg, sizeof msg, &mn) != PST_OK) return 3; + put16(frame, (uint16_t)mn); memcpy(frame + 2, msg, mn); + if (write_frames(stdout, frame, 2 + mn) != 0) return 3; + if (read_frame(stdin, in, sizeof in, &n) != 1) return 8; + if (pst_decode(in, n, &rp) != PST_OK || rp.type != PST_T_FAILED || get16(rp.payload) != FW_FAIL_DUPLICATE_DIFFERENT) { + fprintf(stderr, "requester: different bytes under the same key were not refused with code 7\n"); return 8; + } + char h[65]; + hex(ft->receipt_reference, 32, h); + fprintf(stderr, "requester: COMPLETED after %d messages; receipt_reference=%s os_arch=%.16s identity_class=%.4s\n", + got, h, ft->receipt.os_arch, ft->receipt.identity_class); + fprintf(stderr, "FAB_WORK_PROCS_REQUESTER_PASS\n"); + return 0; +} + +int main(int argc, char **argv) { + if (argc >= 3 && strcmp(argv[1], "--emit") == 0) return emit(argv[2]); + if (argc >= 2 && strcmp(argv[1], "--oracle") == 0) { print_oracle(); return 0; } + if (argc >= 3 && strcmp(argv[1], "--executor") == 0) return run_executor(argv[2]); + if (argc >= 3 && strcmp(argv[1], "--requester") == 0) return run_requester(argv[2]); + if (argc >= 2 && strcmp(argv[1], "--peer-id") == 0) { + AienMachineId id = test_machine("het-test-executor"); + uint8_t rec[AIEN_MID_RECORD_BYTES]; + char h[2 * AIEN_MID_RECORD_BYTES + 1]; + aien_mid_encode(&id, rec); + hex(rec, sizeof rec, h); + printf("%s\n", h); + return 0; + } + const char *dir = argc >= 2 ? argv[1] : "tests/fabric/vectors/pst"; + test_pst_vectors(dir); + test_goldens(dir); + test_oracle(); + test_state_machines(); + test_ed25519_fabric(); + printf("checks=%d failures=%d\n", checks, failures); + if (failures) return 1; + printf("FAB_WORK_PASS\n"); + return 0; +} diff --git a/tests/fabric/vectors/htk1-matmul-n4-seed1.bin b/tests/fabric/vectors/htk1-matmul-n4-seed1.bin new file mode 100644 index 000000000..17a6118d6 Binary files /dev/null and b/tests/fabric/vectors/htk1-matmul-n4-seed1.bin differ diff --git a/tests/fabric/vectors/htk1-tokenize-fixture.bin b/tests/fabric/vectors/htk1-tokenize-fixture.bin new file mode 100644 index 000000000..7fc36e3f9 Binary files /dev/null and b/tests/fabric/vectors/htk1-tokenize-fixture.bin differ diff --git a/tests/fabric/vectors/htr1-sample.bin b/tests/fabric/vectors/htr1-sample.bin new file mode 100644 index 000000000..66f7a29dc Binary files /dev/null and b/tests/fabric/vectors/htr1-sample.bin differ diff --git a/tests/fabric/vectors/pst/bad-digest.pst b/tests/fabric/vectors/pst/bad-digest.pst new file mode 100644 index 000000000..8737c844d Binary files /dev/null and b/tests/fabric/vectors/pst/bad-digest.pst differ diff --git a/tests/fabric/vectors/pst/bad-effect-class.pst b/tests/fabric/vectors/pst/bad-effect-class.pst new file mode 100644 index 000000000..5982fa8d2 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-effect-class.pst differ diff --git a/tests/fabric/vectors/pst/bad-length-empty-file.pst b/tests/fabric/vectors/pst/bad-length-empty-file.pst new file mode 100644 index 000000000..e69de29bb diff --git a/tests/fabric/vectors/pst/bad-length-mismatch.pst b/tests/fabric/vectors/pst/bad-length-mismatch.pst new file mode 100644 index 000000000..846f7f271 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-length-mismatch.pst differ diff --git a/tests/fabric/vectors/pst/bad-length-over-1024.pst b/tests/fabric/vectors/pst/bad-length-over-1024.pst new file mode 100644 index 000000000..4c0525243 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-length-over-1024.pst differ diff --git a/tests/fabric/vectors/pst/bad-length-short-header.pst b/tests/fabric/vectors/pst/bad-length-short-header.pst new file mode 100644 index 000000000..29fc12f8c Binary files /dev/null and b/tests/fabric/vectors/pst/bad-length-short-header.pst differ diff --git a/tests/fabric/vectors/pst/bad-magic.pst b/tests/fabric/vectors/pst/bad-magic.pst new file mode 100644 index 000000000..519369b22 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-magic.pst differ diff --git a/tests/fabric/vectors/pst/bad-no-cause.pst b/tests/fabric/vectors/pst/bad-no-cause.pst new file mode 100644 index 000000000..971e0e53c Binary files /dev/null and b/tests/fabric/vectors/pst/bad-no-cause.pst differ diff --git a/tests/fabric/vectors/pst/bad-no-idempotence-key.pst b/tests/fabric/vectors/pst/bad-no-idempotence-key.pst new file mode 100644 index 000000000..e958e0db3 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-no-idempotence-key.pst differ diff --git a/tests/fabric/vectors/pst/bad-no-task-id.pst b/tests/fabric/vectors/pst/bad-no-task-id.pst new file mode 100644 index 000000000..e882c8b65 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-no-task-id.pst differ diff --git a/tests/fabric/vectors/pst/bad-payload-len-over-800.pst b/tests/fabric/vectors/pst/bad-payload-len-over-800.pst new file mode 100644 index 000000000..630f57af6 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-payload-len-over-800.pst differ diff --git a/tests/fabric/vectors/pst/bad-request-no-objective.pst b/tests/fabric/vectors/pst/bad-request-no-objective.pst new file mode 100644 index 000000000..b471c1d5d Binary files /dev/null and b/tests/fabric/vectors/pst/bad-request-no-objective.pst differ diff --git a/tests/fabric/vectors/pst/bad-reserved0.pst b/tests/fabric/vectors/pst/bad-reserved0.pst new file mode 100644 index 000000000..9d1a3bf84 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-reserved0.pst differ diff --git a/tests/fabric/vectors/pst/bad-reserved1.pst b/tests/fabric/vectors/pst/bad-reserved1.pst new file mode 100644 index 000000000..dbb6b8d2e Binary files /dev/null and b/tests/fabric/vectors/pst/bad-reserved1.pst differ diff --git a/tests/fabric/vectors/pst/bad-trailing-byte.pst b/tests/fabric/vectors/pst/bad-trailing-byte.pst new file mode 100644 index 000000000..4a957d099 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-trailing-byte.pst differ diff --git a/tests/fabric/vectors/pst/bad-type-unknown.pst b/tests/fabric/vectors/pst/bad-type-unknown.pst new file mode 100644 index 000000000..400b0bbb7 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-type-unknown.pst differ diff --git a/tests/fabric/vectors/pst/bad-type-zero.pst b/tests/fabric/vectors/pst/bad-type-zero.pst new file mode 100644 index 000000000..98cded056 Binary files /dev/null and b/tests/fabric/vectors/pst/bad-type-zero.pst differ diff --git a/tests/fabric/vectors/pst/bad-version-downgrade.pst b/tests/fabric/vectors/pst/bad-version-downgrade.pst new file mode 100644 index 000000000..dafe08c4a Binary files /dev/null and b/tests/fabric/vectors/pst/bad-version-downgrade.pst differ diff --git a/tests/fabric/vectors/pst/bad-version-unknown.pst b/tests/fabric/vectors/pst/bad-version-unknown.pst new file mode 100644 index 000000000..3fc9c4a3e Binary files /dev/null and b/tests/fabric/vectors/pst/bad-version-unknown.pst differ diff --git a/tests/fabric/vectors/pst/expected.txt b/tests/fabric/vectors/pst/expected.txt new file mode 100644 index 000000000..11fae5d1d --- /dev/null +++ b/tests/fabric/vectors/pst/expected.txt @@ -0,0 +1,29 @@ +# PST1 single-message vectors. Spec: ../SPEC.md (Draft v0.1, wire version 1). +# Line: , verdict line as printed by tools/pst_verify.c: +# ok type=T version=V cause=H64 origin=H64 objective=H64 subject=H64 parent=H32 +# task=H32 idem=H32 ordinal=N effect=E len=L digest=H64 (one line) +# refuse +# Generated by tools/pst_verify.c --make-vectors; do not edit by hand. +ok-request.pst ok type=1 version=1 cause=c1c8cfd6dde4ebf2f900070e151c232a31383f464d545b626970777e858c939a origin=0a11181f262d343b424950575e656c737a81888f969da4abb2b9c0c7ced5dce3 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 subject=5b626970777e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d34 parent=00000000000000000000000000000000 task=7a81888f969da4abb2b9c0c7ced5dce3 idem=1d242b323940474e555c636a71787f86 ordinal=0 effect=1 len=49 digest=e57392a27132b97e2cbfaa4b04ad3446cab722297cf48ce22c7c2fb787940cc6 +ok-accepted-empty.pst ok type=2 version=1 cause=c1c8cfd6dde4ebf2f900070e151c232a31383f464d545b626970777e858c939a origin=0a11181f262d343b424950575e656c737a81888f969da4abb2b9c0c7ced5dce3 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 subject=5b626970777e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d34 parent=00000000000000000000000000000000 task=7a81888f969da4abb2b9c0c7ced5dce3 idem=1d242b323940474e555c636a71787f86 ordinal=1 effect=1 len=0 digest=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +ok-text-chunk-1024.pst ok type=5 version=1 cause=c1c8cfd6dde4ebf2f900070e151c232a31383f464d545b626970777e858c939a origin=0a11181f262d343b424950575e656c737a81888f969da4abb2b9c0c7ced5dce3 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 subject=5b626970777e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d34 parent=9ea5acb3bac1c8cfd6dde4ebf2f90007 task=7a81888f969da4abb2b9c0c7ced5dce3 idem=1d242b323940474e555c636a71787f86 ordinal=7 effect=0 len=800 digest=20885ae2150992180a94350ef60c6d8a1599899bcd2752d3392f8ad591ddd8b1 +ok-resume-request-max-ordinal.pst ok type=14 version=1 cause=c1c8cfd6dde4ebf2f900070e151c232a31383f464d545b626970777e858c939a origin=0a11181f262d343b424950575e656c737a81888f969da4abb2b9c0c7ced5dce3 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 subject=5b626970777e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d34 parent=00000000000000000000000000000000 task=7a81888f969da4abb2b9c0c7ced5dce3 idem=1d242b323940474e555c636a71787f86 ordinal=4294967295 effect=2 len=0 digest=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 +bad-length-short-header.pst refuse PST_BAD_LENGTH +bad-length-empty-file.pst refuse PST_BAD_LENGTH +bad-length-over-1024.pst refuse PST_BAD_LENGTH +bad-magic.pst refuse PST_BAD_MAGIC +bad-version-unknown.pst refuse PST_BAD_VERSION +bad-version-downgrade.pst refuse PST_DOWNGRADE +bad-type-zero.pst refuse PST_BAD_TYPE +bad-type-unknown.pst refuse PST_BAD_TYPE +bad-reserved0.pst refuse PST_RESERVED_NONZERO +bad-reserved1.pst refuse PST_RESERVED_NONZERO +bad-length-mismatch.pst refuse PST_BAD_LENGTH +bad-payload-len-over-800.pst refuse PST_BAD_LENGTH +bad-trailing-byte.pst refuse PST_TRAILING_BYTES +bad-effect-class.pst refuse PST_BAD_EFFECT_CLASS +bad-no-cause.pst refuse PST_NO_CAUSE +bad-no-task-id.pst refuse PST_NO_TASK +bad-no-idempotence-key.pst refuse PST_NO_TASK +bad-request-no-objective.pst refuse PST_NO_OBJECTIVE +bad-digest.pst refuse PST_DIGEST_MISMATCH diff --git a/tests/fabric/vectors/pst/ok-accepted-empty.pst b/tests/fabric/vectors/pst/ok-accepted-empty.pst new file mode 100644 index 000000000..92bd34916 Binary files /dev/null and b/tests/fabric/vectors/pst/ok-accepted-empty.pst differ diff --git a/tests/fabric/vectors/pst/ok-request.pst b/tests/fabric/vectors/pst/ok-request.pst new file mode 100644 index 000000000..685b25808 Binary files /dev/null and b/tests/fabric/vectors/pst/ok-request.pst differ diff --git a/tests/fabric/vectors/pst/ok-resume-request-max-ordinal.pst b/tests/fabric/vectors/pst/ok-resume-request-max-ordinal.pst new file mode 100644 index 000000000..5daa99c2e Binary files /dev/null and b/tests/fabric/vectors/pst/ok-resume-request-max-ordinal.pst differ diff --git a/tests/fabric/vectors/pst/ok-text-chunk-1024.pst b/tests/fabric/vectors/pst/ok-text-chunk-1024.pst new file mode 100644 index 000000000..9ad712980 Binary files /dev/null and b/tests/fabric/vectors/pst/ok-text-chunk-1024.pst differ diff --git a/tests/gates/omega-atomf32-probe-host.gate b/tests/gates/omega-atomf32-probe-host.gate new file mode 100644 index 000000000..6d6070630 --- /dev/null +++ b/tests/gates/omega-atomf32-probe-host.gate @@ -0,0 +1,26 @@ +# tests/gates/omega-atomf32-probe-host.gate +# Mirrors hosted: host-suites-2.yml gpu-engine job, step "f32 global atomic add probe in the warp simulator (host, no device; the chip run is by hand)" with physics-src at physics.lock: make test-atomf32-probe-host; host only +gate: OMEGA-ATOMF32-PROBE-HOST +manifest_version: 2 +owner: omega +requires: + - host +inputs: + - Makefile + - mk/ + - src/ + - tests/gpu_atomf32_probe_test.c + - tests/bw_warp_sim_tc.h + - tests/bw_hmma_model.h + - tests/bw_qmma_model.h + - physics.lock + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["atomf32-probe-host"] +expects: + exit: 0 + verdict: PASS +timeout: 15m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/omega-chip-tool-selftests.gate b/tests/gates/omega-chip-tool-selftests.gate index 190c6abc3..8d3e32d27 100644 --- a/tests/gates/omega-chip-tool-selftests.gate +++ b/tests/gates/omega-chip-tool-selftests.gate @@ -1,5 +1,5 @@ # tests/gates/omega-chip-tool-selftests.gate -# Mirrors hosted: host-suites.yml chip-tool-selftests: test-m19r-qualify test-gate14-combine test-window-lane-guard test-unwritten-trap-host test-ldst-host (omega #425; replaces the chip-only OMEGA-M19R-QUALIFY and OMEGA-GATE14-COMBINE manifests: both targets are host-only self-tests) +# Mirrors hosted: host-suites.yml chip-tool-selftests: test-m19r-qualify test-gate14-combine test-window-lane-guard test-unwritten-trap-host test-ldst-host test-dgraph-receipt (omega #425; dgraph receipt: aien-architecture#233; replaces the chip-only OMEGA-M19R-QUALIFY and OMEGA-GATE14-COMBINE manifests: both targets are host-only self-tests) gate: OMEGA-CHIP-TOOL-SELFTESTS manifest_version: 2 owner: omega @@ -11,6 +11,8 @@ inputs: - src/ - tests/ - tools/ + - docs/perf/ + - evidence/OWN30B-REQUAL-MAIN-710d438c-20261015/ - tests/gates/ run: exec: tests/gates/run.sh diff --git a/tests/gates/omega-gpu-attention.gate b/tests/gates/omega-gpu-attention.gate new file mode 100644 index 000000000..35a0752b5 --- /dev/null +++ b/tests/gates/omega-gpu-attention.gate @@ -0,0 +1,24 @@ +# tests/gates/omega-gpu-attention.gate +# Mirrors hosted: host-suites-3.yml gpu-attention (omega#470) with physics-src at physics.lock: attention host tiers at head_dim 64 and 128 (refusals, codegen, register bound, nvdisasm listing, both warp simulators, sweep); 6 PASS lines, no FAIL; host only, no chip +gate: OMEGA-GPU-ATTENTION +manifest_version: 2 +owner: omega +requires: + - host +inputs: + - Makefile + - mk/ + - src/ + - tests/gpu_attention_test.c + - tests/bw_warp_sim.h + - physics.lock + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["gpu-attention"] +expects: + exit: 0 + verdict: PASS +timeout: 20m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/omega-gpu-libm-free.gate b/tests/gates/omega-gpu-libm-free.gate new file mode 100644 index 000000000..eaf65fe0b --- /dev/null +++ b/tests/gates/omega-gpu-libm-free.gate @@ -0,0 +1,23 @@ +# tests/gates/omega-gpu-libm-free.gate +# Mirrors hosted: host-suites-3.yml gpu-libm-free (omega#471) with physics-src at physics.lock: libomega_gpu.a has no libm reference and the libm-free replacements are bit-identical (host only, no chip; ~3 s on the Spark) +gate: OMEGA-GPU-LIBM-FREE +manifest_version: 2 +owner: omega +requires: + - host +inputs: + - Makefile + - mk/ + - src/ + - tests/gpu_libm_free_test.c + - physics.lock + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["gpu-libm-free"] +expects: + exit: 0 + verdict: PASS +timeout: 15m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/omega-gpu-tern.gate b/tests/gates/omega-gpu-tern.gate new file mode 100644 index 000000000..9b099baa9 --- /dev/null +++ b/tests/gates/omega-gpu-tern.gate @@ -0,0 +1,24 @@ +# tests/gates/omega-gpu-tern.gate +# Mirrors hosted: pr-smoke.yml smoke job, "KT1 ternary GEMV, host battery and warp simulator (no chip)" with physics-src at physics.lock: make test-gpu-tern, exactly 2 "checks, 0 failed: PASS" lines, no FAIL; host only +gate: OMEGA-GPU-TERN +manifest_version: 2 +owner: omega +requires: + - host +inputs: + - Makefile + - mk/ + - src/ + - tests/gpu_tern_test.c + - tests/bw_warp_sim_k.h + - physics.lock + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["gpu-tern"] +expects: + exit: 0 + verdict: PASS +timeout: 15m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/omega-gpu-tgemm.gate b/tests/gates/omega-gpu-tgemm.gate new file mode 100644 index 000000000..2d4363cf9 --- /dev/null +++ b/tests/gates/omega-gpu-tgemm.gate @@ -0,0 +1,26 @@ +# tests/gates/omega-gpu-tgemm.gate +# Mirrors hosted: pr-smoke.yml smoke job, "Training GEMM host proofs (budgets and warp simulator, no GPU)" with physics-src at physics.lock: make test-gpu-tgemm, exactly 2 "GPU_TGEMM: PASS" lines; host only +gate: OMEGA-GPU-TGEMM +manifest_version: 2 +owner: omega +requires: + - host +inputs: + - Makefile + - mk/ + - src/ + - tests/gpu_tgemm_test.c + - tests/bw_hmma_model.h + - tests/bw_warp_sim_tc.h + - tests/bw_qmma_model.h + - physics.lock + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["gpu-tgemm"] +expects: + exit: 0 + verdict: PASS +timeout: 15m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/omega-numeric-cpu.gate b/tests/gates/omega-numeric-cpu.gate index 5d1ea7294..cc4f7ddd7 100644 --- a/tests/gates/omega-numeric-cpu.gate +++ b/tests/gates/omega-numeric-cpu.gate @@ -1,5 +1,5 @@ # tests/gates/omega-numeric-cpu.gate -# Mirrors hosted: host-suites.yml numeric-cpu: test-numeric-cpu test-numeric-qualify test-e1-combine test-chipwait-campaign test-gpu-wait test-gpu-wait-mutants test-gpu-code-alloc (hosted 63 s) +# Mirrors hosted: host-suites.yml numeric-cpu: test-numeric-cpu test-numeric-qualify test-e1-combine test-chipwait-campaign test-gpu-wait test-gpu-wait-mutants test-gpu-code-alloc test-mufu-ftz (hosted 63 s before test-mufu-ftz) gate: OMEGA-NUMERIC-CPU manifest_version: 2 owner: omega @@ -12,6 +12,14 @@ inputs: - tests/test_omega_numeric.c - tests/numeric_oracle.h - tests/run_numeric_gates.sh + - tests/bw_mufu_ftz.h + - tests/bw_mufu_ftz_test.c + - tests/bw_warp_sim.h + - tests/bw_warp_sim_k.h + - tests/bw_warp_sim_pa.h + - tests/bw_warp_sim_tc.h + - tests/bw_hmma_model.h + - tests/bw_qmma_model.h - tools/ - tests/gates/ run: diff --git a/tests/gates/run.sh b/tests/gates/run.sh index 6c5c918d5..0bdb0483b 100755 --- a/tests/gates/run.sh +++ b/tests/gates/run.sh @@ -90,6 +90,12 @@ case "$step" in grep -E 'TOTAL GATES: ([0-9]+) \| PASSED: \1 \| FAILED: 0' build/base.log ! grep -qE 'FAILED: [1-9]|\[FAIL\]|\(FAIL\)' build/base.log ;; + gpu-tgemm) # pr-smoke.yml smoke job, "Training GEMM host proofs" step: physics-src at physics.lock; + # budgets and warp simulator, no GPU + physics_pin; set -o pipefail; mkdir -p build + make test-gpu-tgemm | tee build/tgemm.log + test "$(grep -c '^GPU_TGEMM: PASS' build/tgemm.log)" = 2 + ;; language) # pr-smoke.yml and host-suites-3.yml (same command) set -o pipefail; mkdir -p build make $NOPHYS test-language | tee build/lang.log @@ -104,16 +110,23 @@ case "$step" in ! grep -q '^FAIL' build/transc.log obs mutants_killed 10 ;; + gpu-tern) # pr-smoke.yml smoke job, KT1 ternary GEMV step: physics-src at physics.lock; host battery + # and warp simulator, no chip + physics_pin; set -o pipefail; mkdir -p build + make test-gpu-tern | tee build/tern.log + test "$(grep -cE '^gpu_tern_test: [0-9]+ checks, 0 failed: PASS$' build/tern.log)" -eq 2 + ! grep -q '^FAIL' build/tern.log + ;; # host-suites.yml searchtrace) make $NOPHYS test-searchtrace ;; estimation) for t in test-estimation test-est-tools test-estimation-v3 test-est3c-tools; do make $NOPHYS $t; done ;; ans) make $NOPHYS test-inertial-alignment ;; - numeric-cpu) for t in test-numeric-cpu test-numeric-qualify test-e1-combine test-chipwait-campaign test-gpu-wait test-gpu-wait-mutants test-gpu-code-alloc; do make $NOPHYS $t; done ;; + numeric-cpu) for t in test-numeric-cpu test-numeric-qualify test-e1-combine test-chipwait-campaign test-gpu-wait test-gpu-wait-mutants test-gpu-code-alloc test-mufu-ftz; do make $NOPHYS $t; done ;; train) make $NOPHYS test-train ;; compiler) make $NOPHYS test-compiler-quick; make $NOPHYS test-compiler-full ;; one-layer-acceptance) make $NOPHYS test-one-layer-acceptance ;; physics0) make $NOPHYS physics0-test ;; - chip-tool-selftests) for t in test-m19r-qualify test-gate14-combine test-window-lane-guard test-unwritten-trap-host test-ldst-host; do make $NOPHYS $t; done ;; + chip-tool-selftests) for t in test-m19r-qualify test-gate14-combine test-window-lane-guard test-unwritten-trap-host test-ldst-host test-dgraph-receipt; do make $NOPHYS $t; done ;; # host-suites-2.yml visor) aienos_pin; make $NOPHYS test-visor ;; turing) make $NOPHYS test-turing; make $NOPHYS test-turing-exp001-a test-turing-exp001-coders; make $NOPHYS test-turing-verify-indep; make $NOPHYS test-turing-qcont test-turing-qrecord ;; @@ -146,6 +159,9 @@ 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 ;; + atomf32-probe-host) # host-suites-2.yml gpu-engine job, "f32 global atomic add probe in the warp simulator" step: + # physics-src at physics.lock; host, no device (the chip run is by hand) + physics_pin; make test-atomf32-probe-host ;; # host-suites-3.yml numeric-lifecycle) make $NOPHYS test-numeric-lifecycle ;; numeric-transc-digest) @@ -154,7 +170,21 @@ case "$step" in n=$(grep -c 'matches frozen digest' build/digest.log); obs frozen_digests_matched "$n" test "$n" -ge 1 ;; + gpu-attention) # host-suites-3.yml gpu-attention (omega#470): physics-src at physics.lock, lock check on; + # host-only, sim and sweep tiers, nothing touches a GPU (the Spark has nvdisasm, so the + # listing check runs here where the hosted runner printed "skipped") + physics_pin; set -o pipefail; mkdir -p build + make -j"$(nproc)" test-gpu-attention | tee build/attn.log + test "$(grep -cE '^PASS: [0-9]+ checks, 0 failed$' build/attn.log)" -eq 6 + ! grep -qE '^FAIL' build/attn.log + ;; numeric-transc-full) make $NOPHYS test-numeric-transc-full ;; + gpu-libm-free) # host-suites-3.yml gpu-libm-free (omega#471): physics-src at physics.lock, lock check on + physics_pin; set -o pipefail; mkdir -p build + make -j"$(nproc)" test-gpu-libm-free | tee build/libm.log + grep -q '^test-gpu-libm-free: PASS$' build/libm.log + ! grep -q '^FAIL' build/libm.log + ;; m6|m7|m8|m9|m10|m11|m12|m13|m14|m15|m17|m5|m19|m19r-qualify|gate14-combine) physics_pin; set -o pipefail; mkdir -p build make "test-$step" | tee "build/gate-$step.log" @@ -165,13 +195,16 @@ case "$step" in pin physics-src-6d7cf0d physics 6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf export PHYSICS_COMMIT=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf PHYSICS_DIR="$PINS/physics-src-6d7cf0d" aienos_pin; set -o pipefail; mkdir -p build - make test-r3 test-r7 test-r16-operator-authority-misuse test-r8 test-r9 test-r12 test-rx-emergency test-action-graph test-state-projection test-capability-query test-capability-graph test-skillroute-compose test-semantic-comm test-cognitive-routing test-sem-incremental test-cortex test-jspace-prod test-composition test-composition-attach-asan test-composition-gate test-fabric test-fabric-living + make test-r3 test-r7 test-r16-operator-authority-misuse test-r8 test-r9 test-r12 test-rx-emergency test-action-graph test-state-projection test-capability-query test-capability-graph test-skillroute-compose test-semantic-comm test-cognitive-routing test-sem-incremental test-cortex test-jspace-prod test-composition test-composition-attach-asan test-composition-gate test-fabric test-fabric-work test-fabric-living make test-machine-identity make test-effect-cap64 | tee build/effect-cap64.log grep -q '^OMEGA_EFFECT_CAP64_PASS$' build/effect-cap64.log receipt omega_state_projection_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_STATE_PROJECTION_PASS": "PASS"' receipt rx_action_graph_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_ACTION_GRAPH_IR_PASS": "PASS"' - receipt omega_incremental_semantics_receipt.json '"OMEGA_INCREMENTAL_SEMANTICS_PASS": "HOST_PASS_ENERGY_UNMEASURED"' '"false_hits": 0,' + # omega#404 ruling: PASS (energy meter present, e.g. aien_spbm hwmon on the Spark) and HOST_PASS_ENERGY_UNMEASURED + # (no meter, the hosted runner) both pass; which one is recorded as an observation. PASS_UNBOUND and FAIL do not. + receipt omega_incremental_semantics_receipt.json '"OMEGA_INCREMENTAL_SEMANTICS_PASS": "\(PASS\|HOST_PASS_ENERGY_UNMEASURED\)"' '"false_hits": 0,' + obs incremental_semantics_verdict "$(grep -o '"OMEGA_INCREMENTAL_SEMANTICS_PASS": "[A-Z_]*"' "$(find build/qual-runs -name omega_incremental_semantics_receipt.json -type f -newer "$STEP_MARK" | head -n 1)" | sed 's/.*: //')" receipt rx_capability_query_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_CAPABILITY_QUERY_PASS": "PASS"' receipt rx_semantic_comm_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_SEMANTIC_COMMUNICATION_PASS": "PASS"' receipt rx_cognitive_routing_receipt.json '"failures": 0,' '"candidate_bound": true,' '"OMEGA_COGNITIVE_ROUTING_PASS": "PASS"' diff --git a/tests/gpu_atomf32_probe_test.c b/tests/gpu_atomf32_probe_test.c new file mode 100644 index 000000000..83846edf2 --- /dev/null +++ b/tests/gpu_atomf32_probe_test.c @@ -0,0 +1,155 @@ +/* gpu_atomf32_probe_test.c (training R5 part 2, 2026-10-15): do the f32 global atomic adds add right on GB10? + * One kernel shape: every thread atomically adds the f32 argument v to one word (start value s) and stores what it got + * back (or, in the no-destination form, its own thread index). Because every thread adds the same v, the sequence of + * values the word takes is fixed whatever order the threads land in: o0 = s, o(k+1) = ftz(ftz(ok) + ftz(v)) rounded to + * nearest even. Each case checks the final word against o(n) bit for bit and the returned old values against + * { o0 .. o(n-1) } as a multiset (no update lost or doubled). Cases: + * 0 .STRONG.SYS 131072 x add 1.0 from 0 exact sums + * 1 .STRONG.SYS 131072 x add -0.25 from 0 exact sums, negative + * 2 .STRONG.SYS 32 x add 2^-125 to the subnormal 2^-140 FTZ: 0x03800000; no FTZ: 0x03800008; a no-op: 0x00000200 + * 3 .STRONG.SYS 32 x add 1.0 to 2^24 + 2 nearest-even: 2^24 + 4; toward zero: 2^24 + 2 (= no-op) + * 4 .STRONG.GPU 131072 x add 1.0 from 0 + * 5 .STRONG.GPU no destination (RZ): 131072 x add 1.0; each thread then stores its index, which must survive + * 6 CONTROL: the integer ATOMG.ADD on the 1.0f bits must FAIL the same check (proves the check can say no) + * --host-only every case in the warp simulator (small grids) + * (default) the chip, one short window; --cases DIGITS picks cases and their order + * Throughput (printed for the large cases only; 32 adds only measure the launch) is every thread on ONE word in + * GPU-uncached host-visible memory: a contention measurement, not a training figure and not the hardware ceiling. Verdict line last: "GPU_ATOMF32_PROBE: PASS|FAIL". */ +/* omega_bw_em.h names two helpers fadd and ffma, which collide with C23 math.h (pulled in by the simulator) */ +#define fadd omega_em_fadd +#define ffma omega_em_ffma +#include "omega_bw_em.h" +#undef fadd +#undef ffma +#include "omega_gpu_session.h" +#include "bw_warp_sim_tc.h" +#include +#include +#include + +typedef struct { BlackwellIROpcode op; int has_dst; uint32_t threads, grid, start, v; const char *name; int control; } Case; +static const Case cs[] = { + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 1, 256, 512, 0x00000000u, 0x3f800000u, "SYS add 1.0 from 0", 0 }, + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 1, 256, 512, 0x00000000u, 0xbe800000u, "SYS add -0.25 from 0", 0 }, + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 1, 32, 1, 0x00000200u, 0x01000000u, "SYS add 2^-125 to subnormal 2^-140 (FTZ)", 0 }, + { BW_IR_ATOMG_ADD_F32_STRONG_SYS, 1, 32, 1, 0x4b800001u, 0x3f800000u, "SYS add 1.0 to 2^24+2 (round to nearest even)", 0 }, + { BW_IR_ATOMG_ADD_F32_STRONG_GPU, 1, 256, 512, 0x00000000u, 0x3f800000u, "GPU add 1.0 from 0", 0 }, + { BW_IR_ATOMG_ADD_F32_STRONG_GPU, 0, 256, 512, 0x00000000u, 0x3f800000u, "GPU add 1.0 from 0, no destination (RZ)", 0 }, + { BW_IR_ATOMG_ADD_STRONG_SYS, 1, 256, 512, 0x00000000u, 0x3f800000u, "CONTROL integer ATOMG.ADD of 1.0f bits", 1 }, +}; +#define NCASES (sizeof cs / sizeof cs[0]) + +/* args: word (u64 at 0x380), output array (u64 at 0x388), v bits (u32 at 0x390) */ +static int atomf32_prog(const Case *c, uint32_t threads, BlackwellIRProgram *prog) { + omega_bw_ir_init(prog); + Em em; memset(&em, 0, sizeof em); em.p = prog; Em *e = &em; + int udesc = UV64(e), pw = V64(e), po = V64(e), val = V(e), tid = V(e), cta = V(e), t = V(e), old = c->has_dst ? V(e) : NOREG; + if (e->err) return -1; + ldcu64(e, udesc, 0x358); ldc64(e, pw, 0x380); ldc64(e, po, 0x388); ldc32(e, val, 0x390); + s2r(e, tid, BW_SR_TID_X); s2r(e, cta, BW_SR_CTAID_X); + imadi(e, t, cta, 0, threads, tid); imadw(e, po, t, 4u, po); + BlackwellIRInsn a = I0(c->op); a.dst_vreg = old; a.src1_vreg = pw; a.src2_vreg = val; a.ureg = udesc; + emit(e, a, K_VAR); + stg(e, po, 0, c->has_dst ? old : t, udesc); /* no destination: t was live across the atomic and must be intact */ + tail(e); + if (e->err) return -1; + return omega_bw_regalloc_solve(prog); +} + +static float u2f(uint32_t u) { float f; memcpy(&f, &u, 4); return f; } +static uint32_t f2u(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } +static uint32_t ftz(uint32_t u) { return (u & 0x7f800000u) == 0u ? (u & 0x80000000u) : u; } +static int cmp_u32(const void *a, const void *b) { uint32_t x = *(const uint32_t *)a, y = *(const uint32_t *)b; return x < y ? -1 : x > y; } + +/* the reference: want[0 .. n-1] = old values (sorted), returns o(n). with_ftz = 0 gives the no-FTZ alternative. */ +static uint32_t reference(uint32_t s, uint32_t v, size_t n, uint32_t *want, int with_ftz) { + uint32_t o = s; + for (size_t k = 0; k < n; k++) { + if (want) want[k] = o; + o = with_ftz ? ftz(f2u(u2f(ftz(o)) + u2f(ftz(v)))) : f2u(u2f(o) + u2f(v)); + } + if (want) qsort(want, n, 4, cmp_u32); + return o; +} + +/* faults: final word, then every output slot (old values as a sorted multiset, or the thread index if no destination) */ +static size_t check(const Case *c, uint32_t word, uint32_t *out, size_t n, uint32_t *want, uint32_t *wfinal) { + *wfinal = reference(c->start, c->v, n, want, 1); + size_t bad = word != *wfinal; + if (c->has_dst) { qsort(out, n, 4, cmp_u32); for (size_t i = 0; i < n; i++) bad += out[i] != want[i]; } + else for (size_t i = 0; i < n; i++) bad += out[i] != (uint32_t)i; + return bad; +} + +static void report(const char *where, const Case *c, size_t n, uint32_t word, uint32_t wfinal, size_t bad, uint64_t ns) { + uint32_t noftz = reference(c->start, c->v, n, NULL, 0); + printf("%s %s x %zu: word 0x%08x = %.9g (want 0x%08x", where, c->name, n, word, (double)u2f(word), wfinal); + if (noftz != wfinal) printf(", no-FTZ would be 0x%08x", noftz); + if (c->start != wfinal) printf(", a no-op would leave 0x%08x", c->start); + printf("), %zu faults", bad); + if (ns && n >= 4096) printf(", %.1f us = %.2f M adds/s, all on one word in uncached host-visible memory (contention, not a ceiling)", + ns / 1e3, (double)n * 1e3 / (double)ns); + printf("\n"); + if (c->control) printf(" control %s: the check %s the wrong arithmetic\n", bad ? "ok" : "BROKEN", bad ? "caught" : "missed"); +} + +static int verdict(const Case *c, size_t bad) { return c->control ? bad == 0 : bad != 0; } + +static int host_only(void) { + static BlackwellIRProgram p; static uint32_t word, out[2 * 64], want[2 * 64]; int fail = 0; + for (size_t i = 0; i < NCASES; i++) { + const Case *c = &cs[i]; const uint32_t T = c->threads < 64 ? c->threads : 64, G = c->grid < 2 ? c->grid : 2; const size_t n = (size_t)T * G; + if (atomf32_prog(c, T, &p) != 0) { printf("sim %s: codegen refused\n", c->name); fail++; continue; } + static WsSim s; memset(&s, 0, sizeof s); s.p = &p; s.threads = T; + word = c->start; memset(out, 0xee, sizeof out); + uint64_t wa = (uintptr_t)&word, oa = (uintptr_t)out; + s.cbank[0x380 / 4] = (uint32_t)wa; s.cbank[0x384 / 4] = (uint32_t)(wa >> 32); + s.cbank[0x388 / 4] = (uint32_t)oa; s.cbank[0x38c / 4] = (uint32_t)(oa >> 32); s.cbank[0x390 / 4] = c->v; + s.ranges[0].lo = wa; s.ranges[0].hi = wa + 4; s.ranges[1].lo = oa; s.ranges[1].hi = oa + 4u * n; s.nranges = 2; + int err = ws_run(&s, G, 1); uint32_t wf = 0; + size_t bad = err ? 1 : check(c, word, out, n, want, &wf); + if (err) printf("sim %s: %s\n", c->name, s.msg); else report("sim", c, n, word, wf, bad, 0); + if (err || verdict(c, bad)) fail++; + } + return fail; +} + +int main(int argc, char **argv) { + int fail = host_only(); + if (argc > 1 && !strcmp(argv[1], "--host-only")) { printf("GPU_ATOMF32_PROBE: %s\n", fail ? "FAIL" : "PASS"); return fail ? 1 : 0; } + if (fail) { printf("GPU_ATOMF32_PROBE: FAIL\n"); return 1; } + const char *order = argc > 2 && !strcmp(argv[1], "--cases") ? argv[2] : "0123456"; + const size_t nmax = 256u * 512u; + uint32_t *want = malloc(nmax * 4u), *got = malloc(nmax * 4u); + omega_gpu_session_lock(); + if (!want || !got || !omega_gpu_session_open()) { printf("open failed: %s\n", omega_gpu_session_last_error()); omega_gpu_session_unlock(); free(want); free(got); return 1; } + static BlackwellIRProgram p; + for (const char *q = order; *q && !fail; q++) { + const size_t i = (size_t)(*q - '0'); + if (i >= NCASES) { printf("bad case %c\n", *q); fail++; break; } + const Case *c = &cs[i]; const size_t n = (size_t)c->threads * c->grid; + OmegaGpuMem code = { 0 }, wm = { 0 }, om = { 0 }; OmegaBlackwellKernel k; + if (atomf32_prog(c, c->threads, &p) != 0) { printf("codegen refused\n"); fail++; break; } + size_t need = omega_bw_program_code_bytes(&p); + if (omega_gpu_session_alloc_code(need, &code) != 0 || omega_blackwell_kernel_encode_into(&p, code.cpu, need, &k) != 0 || omega_gpu_session_sync_to_gpu(&code) != 0 || + omega_gpu_session_alloc(4096, &wm) != 0 || omega_gpu_session_alloc(n * 4u, &om) != 0) { printf("upload failed: %s\n", omega_gpu_session_last_error()); fail++; break; } + uint32_t *w = wm.cpu, *o = om.cpu; uint64_t ns = 0; + w[0] = c->start; memset(o, 0xee, n * 4u); + uint32_t args[5] = { (uint32_t)wm.va, (uint32_t)(wm.va >> 32), (uint32_t)om.va, (uint32_t)(om.va >> 32), c->v }; + OmegaGpuLaunch L = { .code_va = code.va, .gpr_count = omega_bw_gpr_declared(p.regalloc.peak_gpr_usage), .threads_x = c->threads, .threads_y = 1, + .grid_x = c->grid, .grid_y = 1, .num_elements = n, .args = args, .n_args = 5, .timeout_ms = 20000 }; + if (omega_gpu_session_sync_to_gpu(&wm) != 0 || omega_gpu_session_sync_to_gpu(&om) != 0 || omega_gpu_session_launch(&L, &ns, NULL) != 0 || + omega_gpu_session_sync_to_cpu(&wm) != 0 || omega_gpu_session_sync_to_cpu(&om) != 0) { printf("launch failed: %s\n", omega_gpu_session_last_error()); fail++; } + else { + memcpy(got, o, n * 4u); uint32_t wf = 0; + size_t bad = check(c, w[0], got, n, want, &wf); + report("chip", c, n, w[0], wf, bad, ns); + if (verdict(c, bad)) fail++; + } + omega_gpu_session_free(&code); omega_gpu_session_free(&wm); omega_gpu_session_free(&om); + } + omega_gpu_session_unlock(); + free(want); free(got); + printf("GPU_ATOMF32_PROBE: %s\n", fail ? "FAIL" : "PASS"); + return fail ? 1 : 0; +} diff --git a/tests/gpu_attention_test.c b/tests/gpu_attention_test.c index 45790315a..b7a783a2f 100644 --- a/tests/gpu_attention_test.c +++ b/tests/gpu_attention_test.c @@ -45,6 +45,11 @@ static int g_checks, g_failed; static int g_sim_mode; /* --sim: the host simulator never opens the device */ static int g_divergent; /* --divergent (omega #308 R2): the j >= ctx branch inside a BSSY/BSYNC region */ static uint32_t g_hd = 64; /* --hd 128: the whole battery at head_dim 128 (Qwen3-4B shapes); both simulators size the CTA from it */ +/* Host-only register bound (omega#470). hd 64 kernels are the program from before cut K (#417 keeps them byte-identical, + * see the hd64 digest pins) and stay under 64. hd 128 follows AT_GPR_BUDGET in src/omega_gpu_attention_api.c (96 since + * cut K, chip battery 225/225): the codegen refuses any kernel above it and every launch declares exactly that many + * registers, so a peak under it changes nothing on the chip. The pinned-digest check further down uses the same 96. */ +#define ATTN_GPR_BOUND (g_hd == 64 ? 64u : 96u) #define CHECK(cond, ...) do { g_checks++; if (!(cond)) { g_failed++; printf("FAIL: "); printf(__VA_ARGS__); printf("\n"); } } while (0) static uint32_t lcg(uint32_t *s) { *s = *s * 1664525u + 1013904223u; return *s; } @@ -130,6 +135,18 @@ static size_t compare(const float *got, const float *want, size_t n, double rel, } /* ------------------------------------------------------------- host only */ +/* One instruction line of an nvdisasm listing: leading blanks, then the byte offset as a hex comment, "/" "*" hex "*" "/". + * omega#470: the old test matched the text "/" "*" "0", which stops at offset 0x1000, so every listing looked cut off at + * 256 instructions and any opcode first emitted past 4 KiB (the hd 128 kernels are 512 and 624 instructions) was missed. */ +static bool is_sass_insn_line(const char *line) { + while (*line == ' ' || *line == '\t') line++; + if (line[0] != '/' || line[1] != '*') return false; + const char *p = line + 2; + int digits = 0; + while ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) { p++; digits++; } + return digits >= 4 && p[0] == '*' && p[1] == '/'; +} + static int nvdisasm_check(bool f32, const char *name, const char *const *must, int n_must) { const char *nv = "/usr/local/cuda/bin/nvdisasm"; if (access(nv, X_OK) != 0) { printf("nvdisasm: not present, listing check skipped for %s\n", name); return 0; } @@ -142,11 +159,12 @@ static int nvdisasm_check(bool f32, const char *name, const char *const *must, i fwrite(k.code, 1, k.code_size, f); fclose(f); snprintf(cmd, sizeof cmd, "%s -b SM121 %s > %s 2>&1", nv, bin, lst); int rc = system(cmd); + const int want_insns = (int)(k.code_size / 16); /* every 16-byte slot, padding included, is one listing line */ free(k.code); FILE *l = fopen(lst, "r"); if (!l) return -1; char line[512]; int seen[16] = {0}; int bad = 0, insns = 0; while (fgets(line, sizeof line, l)) { - if (!strstr(line, "/*0")) continue; + if (!is_sass_insn_line(line)) continue; insns++; if (strstr(line, "?") || strstr(line, "error")) bad++; for (int i = 0; i < n_must; i++) if (strstr(line, must[i])) seen[i] = 1; @@ -154,9 +172,9 @@ static int nvdisasm_check(bool f32, const char *name, const char *const *must, i fclose(l); int miss = 0; for (int i = 0; i < n_must; i++) if (!seen[i]) { printf(" %s: nvdisasm listing lacks %s\n", name, must[i]); miss++; } - printf("nvdisasm %s: rc=%d insns=%d undecodable=%d missing=%d (%s)\n", name, rc, insns, bad, miss, lst); + printf("nvdisasm %s: rc=%d insns=%d of %d undecodable=%d missing=%d (%s)\n", name, rc, insns, want_insns, bad, miss, lst); unlink(bin); - return (rc == 0 && bad == 0 && miss == 0) ? 0 : -1; + return (rc == 0 && insns == want_insns && bad == 0 && miss == 0) ? 0 : -1; } static OmegaGpuKvLayout layout_for(uint32_t num_blocks, uint32_t bs, uint32_t layers, uint32_t nkv, uint32_t hd) { @@ -198,7 +216,7 @@ static void host_only(void) { const char *name = f32 ? "gqa_f32" : "paged_bf16"; OmegaBlackwellKernel k; memset(&k, 0, sizeof k); int rc = omega_gpu_attention_codegen_hd(f32 != 0, f32 ? 12 : 4, 3, g_hd, &k); - CHECK(rc == OMEGA_GPU_ATTN_OK && k.code_size > 0 && k.gpr_count <= 64, "%s kernel generated (rc %s, %zu insns, %u gprs)", name, omega_gpu_attention_rc_name(rc), k.insn_count, k.gpr_count); + CHECK(rc == OMEGA_GPU_ATTN_OK && k.code_size > 0 && k.gpr_count <= ATTN_GPR_BOUND, "%s kernel generated (rc %s, %zu insns, %u gprs)", name, omega_gpu_attention_rc_name(rc), k.insn_count, k.gpr_count); printf("codegen %s: %zu insns, %u gprs, %u ugprs\n", name, k.insn_count, k.gpr_count, k.uniform_gpr_count); /* every mutant (1 .. COUNT-1) is a distinct kernel: different from the baseline and from * every other mutant, named, and inside the register budget */ @@ -208,7 +226,7 @@ static void host_only(void) { omega_gpu_attention_test_set_mutant((OmegaGpuAttnMutant)m); memset(&k, 0, sizeof k); int mrc = omega_gpu_attention_codegen_hd(f32 != 0, f32 ? 12 : 4, 3, g_hd, &k); - CHECK(mrc == OMEGA_GPU_ATTN_OK && k.gpr_count <= 64, "%s mutant %s generated (rc %s, %u gprs)", name, omega_gpu_attention_mutant_name((OmegaGpuAttnMutant)m), omega_gpu_attention_rc_name(mrc), k.gpr_count); + CHECK(mrc == OMEGA_GPU_ATTN_OK && k.gpr_count <= ATTN_GPR_BOUND, "%s mutant %s generated (rc %s, %u gprs)", name, omega_gpu_attention_mutant_name((OmegaGpuAttnMutant)m), omega_gpu_attention_rc_name(mrc), k.gpr_count); CHECK(strcmp(omega_gpu_attention_mutant_name((OmegaGpuAttnMutant)m), "?") != 0, "mutant %d has a name", m); memcpy(digests[m], k.code_digest, 32); free(k.code); @@ -736,8 +754,8 @@ static int sim_step(SimThr *t, const BlackwellIRProgram *p, uint32_t tid, uint32 case BW_IR_FMUL: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(u2f(a) * u2f(b)), p); break; case BW_IR_FFMA: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(fmaf(u2f(a), u2f(b), u2f(c))), p); break; case BW_IR_FMNMX_MAX: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(fmaxf(u2f(a), u2f(b))), p); break; - case BW_IR_MUFU_EX2: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(exp2f(u2f(a))), p); break; - case BW_IR_MUFU_RCP: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(1.0f / u2f(a)), p); break; + case BW_IR_MUFU_EX2: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(ws_mufu_ex2(u2f(a))), p); break; /* bw_mufu_ftz.h (#462) */ + case BW_IR_MUFU_RCP: wrs(t, in->dst_vreg, in->dst_subreg, f2u_(ws_mufu_rcp(u2f(a))), p); break; default: g_sim_err = 100 + (int)in->op; t->done = 1; return 0; } if (g_trace && tid == 0 && cx == g_trace_cx && cy == 0 && g_trace_launch == 1) { uint32_t dv = rd(t, in->dst_vreg, p); printf("T pc=%d op=%d dst=v%d(r%d)=%08x f=%g p0=%d a=%08x b=%08x c=%08x\n", t->pc, (int)in->op, in->dst_vreg, in->dst_vreg >= 0 ? p->regalloc.vreg_to_phys[in->dst_vreg] : -1, dv, u2f(dv), t->p0, a, b, c); } @@ -745,6 +763,30 @@ static int sim_step(SimThr *t, const BlackwellIRProgram *p, uint32_t tid, uint32 } g_sim_err = 4; t->done = 1; return 0; } +/* omega #462: this per-thread simulator's MUFU cases follow the chip's flush rule (tests/bw_mufu_ftz.h). One MUFU then + * EXIT through sim_step: a subnormal EX2 / RCP result is a zero of the same sign, a subnormal RCP input is a zero (so the + * result is an infinity), normals unchanged. Reachable in the kernel: softmax EX2 of a score more than 126 below the + * running max (log2 units) is subnormal in IEEE and 0 on the chip. */ +static void mufu_ftz_sim_check(void) { + static BlackwellIRProgram p; + static const struct { BlackwellIROpcode op; uint32_t in, want; } c[] = { + { BW_IR_MUFU_EX2, 0xc3020000u /* -130 */, 0x00000000u }, { BW_IR_MUFU_EX2, 0xc2fc0000u /* -126 */, 0x00800000u }, + { BW_IR_MUFU_RCP, 0x7f400000u /* 1.5 * 2^127 */, 0x00000000u }, { BW_IR_MUFU_RCP, 0xff400000u, 0x80000000u }, + { BW_IR_MUFU_RCP, 0x00400000u /* 2^-127 */, 0x7f800000u }, { BW_IR_MUFU_RCP, 0x7e800000u /* 2^126 */, 0x00800000u }, + }; + memset(&p, 0, sizeof p); + p.count = 2; p.regalloc.vreg_to_phys[0] = 0; p.regalloc.vreg_to_phys[1] = 1; + for (int i = 0; i < 2; i++) { p.insns[i].dst_vreg = p.insns[i].src1_vreg = p.insns[i].src2_vreg = p.insns[i].src3_vreg = p.insns[i].ureg = -1; } + p.insns[1].op = BW_IR_EXIT; + for (size_t i = 0; i < sizeof c / sizeof c[0]; i++) { + SimThr t; memset(&t, 0, sizeof t); + p.insns[0].op = c[i].op; p.insns[0].dst_vreg = 0; p.insns[0].src1_vreg = 1; + t.r[1] = c[i].in; t.r[0] = 0xdeadbeefu; g_sim_err = 0; + sim_step(&t, &p, 0, 0, 0); + CHECK(g_sim_err == 0 && t.r[0] == c[i].want, "attention sim MUFU %s(0x%08x) = 0x%08x, chip rule 0x%08x (omega #462)", + c[i].op == BW_IR_MUFU_EX2 ? "EX2" : "RCP", c[i].in, t.r[0], c[i].want); + } +} static int sim_launch(const void *progv, const OmegaGpuAttnLaunch *L, OmegaGpuAttnInfo *info) { const BlackwellIRProgram *p = progv; memset(sim_cbank, 0, sizeof sim_cbank); @@ -1172,7 +1214,7 @@ int main(int argc, char **argv) { if (g_divergent) omega_gpu_attention_test_set_divergent(1); if (sim) { g_sim_mode = 1; omega_gpu_attention_test_set_simulator(g_divergent ? ws_attn_launch : sim_launch); } if (sim && g_divergent && !host) divergent_negative_control(); - if (host) { host_only(); hd_codegen_checks(); } + if (host) { host_only(); hd_codegen_checks(); mufu_ftz_sim_check(); } else if (split_timing_mode) { if (split_timing(out_path) != 0) return 2; } else if (timing_mode) { if (timing(out_path) != 0) return 2; } else if (sweep_mode) { if (sweep(out_path) != 0) return 2; } diff --git a/tests/gpu_fp8gemm_test.c b/tests/gpu_fp8gemm_test.c index 691d3df40..f2279e345 100644 --- a/tests/gpu_fp8gemm_test.c +++ b/tests/gpu_fp8gemm_test.c @@ -47,7 +47,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/gpu_libm_free_test.c b/tests/gpu_libm_free_test.c new file mode 100644 index 000000000..52672a2a3 --- /dev/null +++ b/tests/gpu_libm_free_test.c @@ -0,0 +1,136 @@ +/* gpu_libm_free_test: omega#471. libomega_gpu.a must not reference libm. The FP8 host packer used ldexpf(1.0f, e) + * for its exact powers of two; it now uses omega_hostmath_pow2f(e), built from the bit pattern. This test links -lm + * and proves the replacement changes no output bit: + * 1. omega_hostmath_pow2f(e) == ldexpf(1.0f, e) bit for bit, for every e in -400..400 and INT_MIN, INT_MAX + * (covers +inf, every normal, every subnormal and the round-to-zero tail). + * 2. omega_fp8_e4m3_ref(b) == the ldexpf reference for all 256 bytes. + * 3. omega_fp8_pack_scales, both fold modes, == the ldexpf reference (return code and bits) for all 65536 bf16 codes. + * 4. omega_fp8_pack_x_bf16 == the ldexpf reference for all 65536 bf16 codes. + * 5. omega_fp8_pack_x_f32 == the ldexpf reference for all 2^32 f32 bit patterns. + * The reference functions below are the pre-#471 code, verbatim except for their names. + * The archive symbol check (no libm-exported name among the archive's undefined symbols) is the shell half of + * `make test-gpu-libm-free`. */ +#include "omega_gpu_fp8_api.h" +#include "omega_gpu_hostmath.h" +#include "omega_blackwell_codegen_moe.h" +#include "omega_blackwell_matmul.h" +#include +#include +#include +#include +#include +#include + +static uint32_t fbits(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } + +static float ref_e4m3(uint8_t b) { + int exponent = (b >> 3) & 0x0f; + float mantissa = (float)(b & 0x07); + float sign = (b & 0x80) ? -1.0f : 1.0f; + if (exponent == 0x0f && (b & 0x07) == 0x07) return NAN; /* 0x7f / 0xff */ + if (exponent == 0) return sign * mantissa * ldexpf(1.0f, -9); + return sign * (1.0f + mantissa / 8.0f) * ldexpf(1.0f, exponent - 7); +} + +static int ref_pack_scales(const uint16_t *bf16, size_t count, float *out, int mutant_no_fold) { + const float fold = mutant_no_fold ? 1.0f : ldexpf(1.0f, OMEGA_FP8_SCALE_EXP); + for (size_t i = 0; i < count; i++) { + float s = omega_bf16_to_fp32(bf16[i]); + if (!(fabsf(s) <= 3.0e38f)) return -1; /* NaN or inf scale */ + float f = s * fold; + if (!(fabsf(f) <= 3.0e38f)) return -1; /* fold overflow */ + out[i] = f; + } + return 0; +} + +static void ref_pack_x_f32(const float *x, uint32_t k, float *out) { + const float fold = ldexpf(1.0f, OMEGA_FP8_X_EXP); + for (uint32_t i = 0; i < k; i++) out[i] = x[i] * fold; +} + +static void ref_pack_x_bf16(const uint16_t *x, uint32_t k, float *out) { + const float fold = ldexpf(1.0f, OMEGA_FP8_X_EXP); + for (uint32_t i = 0; i < k; i++) out[i] = omega_bf16_to_fp32(x[i]) * fold; +} + +static int failures = 0; +static void check(int ok, const char *what) { + printf("%s %s\n", ok ? "PASS" : "FAIL", what); + if (!ok) failures++; +} + +int main(void) { + /* 1. the helper itself, over its whole behaviour range */ + { + int bad = 0, n = 0; + for (int e = -400; e <= 400; e++, n++) { + volatile int ve = e; /* keep ldexpf a real libm call, not a folded constant */ + if (fbits(omega_hostmath_pow2f(e)) != fbits(ldexpf(1.0f, ve))) { + if (bad < 5) fprintf(stderr, "pow2f(%d) = %08x, ldexpf = %08x\n", e, + fbits(omega_hostmath_pow2f(e)), fbits(ldexpf(1.0f, ve))); + bad++; + } + } + const int edge[2] = {INT_MIN, INT_MAX}; + for (int i = 0; i < 2; i++, n++) { + volatile int ve = edge[i]; + if (fbits(omega_hostmath_pow2f(edge[i])) != fbits(ldexpf(1.0f, ve))) bad++; + } + char msg[128]; + snprintf(msg, sizeof msg, "pow2f == ldexpf(1, e) for e in -400..400, INT_MIN, INT_MAX (%d exponents)", n); + check(bad == 0, msg); + } + /* 2. e4m3 reference conversion, all 256 bytes */ + { + int bad = 0; + for (int b = 0; b < 256; b++) + if (fbits(omega_fp8_e4m3_ref((uint8_t)b)) != fbits(ref_e4m3((uint8_t)b))) bad++; + check(bad == 0, "omega_fp8_e4m3_ref bit-identical for all 256 e4m3 bytes"); + } + /* 3 and 4. every bf16 code, one at a time so each refusal is compared on its own */ + { + int bad_s = 0, bad_x = 0, refused = 0; + for (uint32_t c = 0; c < 65536; c++) { + uint16_t v = (uint16_t)c; + for (int mutant = 0; mutant < 2; mutant++) { + float a = 0.0f, r = 0.0f; + int ra = omega_fp8_pack_scales(&v, 1, &a, mutant); + int rr = ref_pack_scales(&v, 1, &r, mutant); + if (ra != rr || (ra == 0 && fbits(a) != fbits(r))) bad_s++; + if (ra != 0) refused++; + } + float a = 0.0f, r = 0.0f; + omega_fp8_pack_x_bf16(&v, 1, &a); + ref_pack_x_bf16(&v, 1, &r); + if (fbits(a) != fbits(r)) bad_x++; + } + char msg[160]; + snprintf(msg, sizeof msg, + "omega_fp8_pack_scales identical (code and bits) for all 65536 bf16 codes x 2 fold modes (%d refusals, same in both)", + refused); + check(bad_s == 0, msg); + check(bad_x == 0, "omega_fp8_pack_x_bf16 bit-identical for all 65536 bf16 codes"); + } + /* 5. every f32 bit pattern through the f32 stager, in chunks */ + { + enum { CHUNK = 1 << 16 }; + float *in = malloc(CHUNK * sizeof(float)), *a = malloc(CHUNK * sizeof(float)), *r = malloc(CHUNK * sizeof(float)); + if (!in || !a || !r) { fprintf(stderr, "out of memory\n"); return 2; } + uint64_t bad = 0; + for (uint64_t base = 0; base < (1ull << 32); base += CHUNK) { + for (uint32_t i = 0; i < CHUNK; i++) { + uint32_t u = (uint32_t)(base + i); + memcpy(&in[i], &u, 4); + } + omega_fp8_pack_x_f32(in, CHUNK, a); + ref_pack_x_f32(in, CHUNK, r); + if (memcmp(a, r, CHUNK * sizeof(float)) != 0) + for (uint32_t i = 0; i < CHUNK; i++) bad += fbits(a[i]) != fbits(r[i]); + } + free(in); free(a); free(r); + check(bad == 0, "omega_fp8_pack_x_f32 bit-identical for all 2^32 f32 bit patterns"); + } + printf("gpu_libm_free_test: %s (%d failing checks)\n", failures ? "FAIL" : "PASS", failures); + return failures ? 1 : 0; +} diff --git a/tests/gpu_pfgemm_test.c b/tests/gpu_pfgemm_test.c index c2a4fc096..c4dff9b74 100644 --- a/tests/gpu_pfgemm_test.c +++ b/tests/gpu_pfgemm_test.c @@ -79,11 +79,11 @@ static float emu_phys(const Prob *p, uint32_t i, uint32_t c) { return acc * R(KB); #undef R } -/* the kernel's epilogue arithmetic: MUFU.EX2, FADD, MUFU.RCP, FMUL x 3, F2FP. The two MUFU results pass through ws_mufu_ftz - * (bw_warp_sim_tc.h): the chip's MUFU flushes a subnormal result to a sign-preserving zero, so for t = -g log2 e in (126, 128) +/* the kernel's epilogue arithmetic: MUFU.EX2, FADD, MUFU.RCP, FMUL x 3, F2FP. The two MUFU ops go through ws_mufu_ex2 / ws_mufu_rcp + * (bw_mufu_ftz.h, omega #462): the chip's MUFU flushes a subnormal result to a sign-preserving zero, so for t = -g log2 e in (126, 128) * (g in (-88.72, -87.34)) the reciprocal is +-0 and the activation is +-0, not the 2^-56-ish product an IEEE 1/d would give. */ static uint16_t swiglu_bits(float g, float u) { - float t = g * u2f(0xbfb8aa3bu), ex = ws_mufu_ftz(exp2f(ws_mufu_ftz(t))), d = ex + 1.0f, r = ws_mufu_ftz(1.0f / ws_mufu_ftz(d)), o = g * r; + float t = g * u2f(0xbfb8aa3bu), ex = ws_mufu_ex2(t), d = ex + 1.0f, r = ws_mufu_rcp(d), o = g * r; o = o * u; o = o * u2f(0x5f800000u); return bf16_rn(o); } diff --git a/tests/gpu_prefill_attn_test.c b/tests/gpu_prefill_attn_test.c index 6daaa012c..97c9c8f0f 100644 --- a/tests/gpu_prefill_attn_test.c +++ b/tests/gpu_prefill_attn_test.c @@ -78,7 +78,7 @@ static void emu_rows(const float *qkv_row, const float *kn, float eps, uint32_t for (unsigned i = 0; i < 128; i++) x[i] = qkv_row[4096 + gk * 128 + i]; for (unsigned L = 0; L < 32; L++) { float a = x[4 * L] * x[4 * L]; for (unsigned i = 1; i < 4; i++) a = fmaf(x[4 * L + i], x[4 * L + i], a); sq[L] = a; } for (unsigned o = 16; o >= 1; o /= 2) { float nx[32]; for (unsigned L = 0; L < 32; L++) nx[L] = sq[L] + (L + o < 32 ? sq[L + o] : sq[L]); memcpy(sq, nx, sizeof sq); } - float rs = 1.0f / sqrtf(fmaf(sq[0], u2f(0x3c000000u), eps)); + float rs = ws_mufu_rsq(fmaf(sq[0], u2f(0x3c000000u), eps)); /* MUFU.RSQ, bw_mufu_ftz.h (#462); eps > 0 keeps it normal */ for (unsigned i = 0; i < 128; i++) { x[i] = x[i] * rs; x[i] = x[i] * kn[i]; } float y[128]; for (unsigned i = 0; i < 128; i++) { @@ -148,24 +148,23 @@ static void rows_vs_emu(const Case *c, const uint16_t *kc, const uint16_t *vc, s /* ------------------------------------------------------------- host only */ static void host_only(void) { - char msg[200]; - CHECK(omega_tc_patch_selftest(msg, sizeof msg) == 0, "placeholder self-test: %s", msg); + CHECK(omega_blackwell_verify_codegen_fixtures_bfly_f2fp() == 0, "SHFL.BFLY / F2FP.BF16 golden words (rc %d)", omega_blackwell_verify_codegen_fixtures_bfly_f2fp()); for (uint32_t w = 4; w <= 8; w += 4) for (uint32_t md = 0; md <= 2; md++) for (int m = 0; m <= 4; m++) { - OmegaPrefillAttnSpec s = { w, m, md, 0 }; uint32_t n = 0, gp = 0, ph = 0; - int rc = omega_prefill_attn_prog_stats(&s, &n, &gp, &ph); + OmegaPrefillAttnSpec s = { w, m, md, 0 }; uint32_t n = 0, gp = 0; + int rc = omega_prefill_attn_prog_stats(&s, &n, &gp); CHECK(rc == 0 && n <= 1024 && omega_bw_gpr_declared(gp) <= 128, "codegen warps %u mode %u mutant %d: rc %d insns %u gprs %u", w, md, m, rc, n, gp); - static uint8_t code[1024 * 16]; uint32_t kg = 0; int np = -1; - size_t sz = omega_gpu_prefill_attn_encode(&s, code, sizeof code, &kg, &np); - CHECK(sz > 0 && np == (int)ph, "encode+patch warps %u mode %u mutant %d: size %zu patched %d of %u", w, md, m, sz, np, ph); - if (rc == 0 && m == 0) printf("codegen warps %u mode %u: %u instructions, %u registers (declared %u, %u threads -> %u of 65536), %u placeholders patched\n", - w, md, n, gp, omega_bw_gpr_declared(gp), 32 * w, 32 * w * omega_bw_gpr_declared(gp), ph); + static uint8_t code[1024 * 16]; uint32_t kg = 0; + size_t sz = omega_gpu_prefill_attn_encode(&s, code, sizeof code, &kg); + CHECK(sz == 16u * ((n + 7u) & ~7u) && kg > 0, "encode warps %u mode %u mutant %d: size %zu for %u instructions", w, md, m, sz, n); + if (rc == 0 && m == 0) printf("codegen warps %u mode %u: %u instructions, %u registers (declared %u, %u threads -> %u of 65536)\n", + w, md, n, gp, omega_bw_gpr_declared(gp), 32 * w, 32 * w * omega_bw_gpr_declared(gp)); } - { OmegaPrefillAttnSpec s = { 2, 0, 0, 0 }; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL, NULL) != 0, "warps 2 refused"); - s.warps = 8; s.mutant = 5; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL, NULL) != 0, "mutant 5 refused"); - s.mutant = 0; s.mode = 3; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL, NULL) != 0, "mode 3 refused"); - s.mode = OMEGA_PATTN_MODE_ATTEND; s.mirror = 1; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL, NULL) != 0, "mirror outside APPEND refused"); - s.mode = OMEGA_PATTN_MODE_APPEND; uint32_t n = 0, gp = 0, ph = 0; - CHECK(omega_prefill_attn_prog_stats(&s, &n, &gp, &ph) == 0 && n <= 1024 && omega_bw_gpr_declared(gp) <= 128, "APPEND + mirror in budget: %u insns %u gprs", n, gp); + { OmegaPrefillAttnSpec s = { 2, 0, 0, 0 }; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL) != 0, "warps 2 refused"); + s.warps = 8; s.mutant = 5; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL) != 0, "mutant 5 refused"); + s.mutant = 0; s.mode = 3; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL) != 0, "mode 3 refused"); + s.mode = OMEGA_PATTN_MODE_ATTEND; s.mirror = 1; CHECK(omega_prefill_attn_prog_stats(&s, NULL, NULL) != 0, "mirror outside APPEND refused"); + s.mode = OMEGA_PATTN_MODE_APPEND; uint32_t n = 0, gp = 0; + CHECK(omega_prefill_attn_prog_stats(&s, &n, &gp) == 0 && n <= 1024 && omega_bw_gpr_declared(gp) <= 128, "APPEND + mirror in budget: %u insns %u gprs", n, gp); printf("codegen warps 8 APPEND + mirror: %u instructions, %u registers\n", n, gp); } CHECK(omega_gpu_prefill_attn(NULL, 0, 0, 1, NULL, EPS, 1.0f, NULL, NULL) == OMEGA_GPU_DATTN_BAD_ARGS, "NULL cache refused"); CHECK(OMEGA_PATTN_SHARED_BYTES <= 16384u, "shared memory within the QMD cap"); diff --git a/tests/gpu_qgemm_test.c b/tests/gpu_qgemm_test.c index 5e209a733..5578bb6a0 100644 --- a/tests/gpu_qgemm_test.c +++ b/tests/gpu_qgemm_test.c @@ -204,8 +204,12 @@ static float qemu_phys(const QProb *p, uint32_t i, uint32_t c) { } return acc; } +/* the kernel's SwiGLU epilogue (omega_blackwell_codegen_qg.c: FMNMX t-cap, MUFU.EX2, MUFU.RCP). Both MUFU results go + * through the chip's flush rule (tests/bw_mufu_ftz.h, omega #462). Not observable with the t-cap: t <= 125 keeps + * 1 / (2^t + 1) >= 2^-125 normal, and an EX2 result below 2^-126 (t < -126) rounds to the same d = 1.0 after the +1 as + * its flushed zero; qg_host checks this bit for bit. Removing the cap (issue #462) is a separate chip-gated change. */ static uint16_t qswiglu_bits(float g, float u) { - float t = fminf(g * u2f(0xbfb8aa3bu), 125.0f), ex = exp2f(t), d = ex + 1.0f, r = 1.0f / d, o = g * r; + float t = fminf(g * u2f(0xbfb8aa3bu), 125.0f), ex = ws_mufu_ex2(t), d = ex + 1.0f, r = ws_mufu_rcp(d), o = g * r; o = o * u; return bf16_rn(o); } @@ -246,8 +250,26 @@ static size_t qcompare(const QProb *p, const void *y, const uint32_t *rows, uint return bad; } +/* omega #462: with the t-cap the MUFU flush never changes a SwiGLU output bit. Compare qswiglu_bits against the IEEE + * form over every g in [80, 110] and [-110, -80] (the EX2-subnormal window t in (-150, -126] and the cap t = 125, both + * signs) plus a stride-65537 sample of all f32. Not a red test: there is no input for which the two differ. */ +static int qg_mufu_ftz_unobservable(void) { + uint64_t n = 0, diff = 0; + const float us[2] = { 1.0f, -3.0f }; + for (int pass = 0; pass < 3; pass++) { + uint64_t lo = pass == 0 ? f2u(80.0f) : pass == 1 ? f2u(-80.0f) : 0, hi = pass == 0 ? f2u(110.0f) : pass == 1 ? f2u(-110.0f) : 0xffffffffull, step = pass == 2 ? 65537 : 1; + for (uint64_t b = lo; b <= hi; b += step) { + float g = u2f((uint32_t)b); + if (isnan(g)) continue; + float t = fminf(g * u2f(0xbfb8aa3bu), 125.0f), r = 1.0f / (exp2f(t) + 1.0f); + for (int k = 0; k < 2; k++) { n++; if (bf16_rn((g * r) * us[k]) != qswiglu_bits(g, us[k])) diff++; } + } + } + printf("%s qgemm SwiGLU: MUFU flush vs IEEE, %llu inputs, %llu differ (t-cap keeps it unobservable, #462)\n", diff ? "FAIL" : "PASS", (unsigned long long)n, (unsigned long long)diff); + return diff ? 1 : 0; +} static int qg_host(void) { - int fail = 0; + int fail = qg_mufu_ftz_unobservable(); for (uint32_t layout = 0; layout < 3; layout += 2) { QProb p; qprob_make(&p, 3, 256, 384, 40, 17, layout, 0, 0); double worst = 0; diff --git a/tests/gpu_tcgemm_test.c b/tests/gpu_tcgemm_test.c index aaddd094d..d34c49da2 100644 --- a/tests/gpu_tcgemm_test.c +++ b/tests/gpu_tcgemm_test.c @@ -108,7 +108,7 @@ static int host_only(void) { unsigned e = (c >> 3) & 15, m = c & 7; double v = e ? ldexp(1.0 + m / 8.0, (int)e - 7) : ldexp(m / 8.0, -6); if (c & 0x80) v = -v; if ((double)u2f((uint32_t)omega_tcgemm_w_bf16((uint8_t)c) << 16) != ldexp(v, -120)) { printf("decode code %02x wrong\n", c); fail++; } } - { char pm[200]; int pr = omega_tc_patch_selftest(pm, sizeof pm); printf("placeholder patch self-test: %s (%s)\n", pr ? "FAIL" : "ok", pm); if (pr) fail++; } + { int pr = omega_blackwell_verify_codegen_fixtures_bfly_f2fp(); printf("SHFL.BFLY / F2FP.BF16 golden words: %s (rc %d)\n", pr ? "FAIL" : "ok", pr); if (pr) fail++; } /* production shapes: instructions and registers (declared = peak + 2 rounded to 8 <= 128; 32 * warps * declared <= 65536) */ static const OmegaTcGemmSpec shapes[] = { { 2048, 4, 2, 8, 0 }, { 768, 4, 2, 8, 0 }, { 4096, 4, 2, 8, 0 }, { 2048, 4, 1, 8, 0 }, { 2048, 2, 2, 4, 0 }, { 2048, 4, 2, 4, 0 }, { 768, 4, 2, 4, 0 }, diff --git a/tests/gpu_tern_test.c b/tests/gpu_tern_test.c index ba0a5830f..605dff58d 100644 --- a/tests/gpu_tern_test.c +++ b/tests/gpu_tern_test.c @@ -228,6 +228,7 @@ static void host_battery(void) { /* ------------------------------------------------------------- simulator */ static uint64_t g_sim_issues; /* Runs spec on the simulator; y_out n words. bounds: the boundaries to pass (NULL: one segment). */ +static uint32_t g_sim_wsched; /* warp visit order per barrier phase (WsSim.warp_sched): 0 ascending, 1 descending, else a shuffle seed */ static int sim_run(const OmegaTernGemvSpec *spec, uint32_t n, const int8_t *w, const int8_t *x, const uint32_t *bounds, const float *scale4, float a, uint32_t grid_x, int order, uint32_t *y_out, char *msg, size_t msgn) { static BlackwellIRProgram prog; @@ -248,7 +249,7 @@ static int sim_run(const OmegaTernGemvSpec *spec, uint32_t n, const int8_t *w, c uint8_t *smem = aligned_alloc(16, sh); for (uint32_t i = 0; i < n; i++) y[i] = 0xdeadbeefu; WsSim s; memset(&s, 0, sizeof s); - s.p = &prog; s.threads = 32u * spec->warps; s.order = order; s.smem = smem; s.smem_bytes = sh; + s.p = &prog; s.threads = 32u * spec->warps; s.order = order; s.warp_sched = g_sim_wsched; s.smem = smem; s.smem_bytes = sh; uint64_t A[5] = { (uintptr_t)pk, (uintptr_t)xd, (uintptr_t)y, (uintptr_t)ws, (uintptr_t)as }; for (unsigned i = 0; i < 5; i++) { s.cbank[(OMEGA_TERN_ARG_W + 8 * i) / 4] = (uint32_t)A[i]; s.cbank[(OMEGA_TERN_ARG_W + 8 * i) / 4 + 1] = (uint32_t)(A[i] >> 32); } s.cbank[OMEGA_TERN_ARG_U / 4] = np / (2u * spec->rows); @@ -291,14 +292,42 @@ static void sim_battery(void) { { 512, 16, 1, 2, 2, 2, 1 }, { 1024, 37, 1, 4, 2, 4, 3 }, { 2560, 32, 1, 4, 4, 2, 1 }, { 2560, 8, 1, 2, 1, 5, 1 }, { 768, 64, 1, 4, 2, 1, 2 }, { 8704, 16, 0, 2, 1, 1, 1 }, { 8704, 16, 1, 2, 2, 1, 1 }, { 2560, 20, 0, 1, 2, 10, 2 }, { 6912, 9, 0, 1, 2, 9, 1 }, { 16384, 8, 0, 1, 1, 16, 1 }, /* the API defaults (row-major, rows 1) */ + { 1024, 18, 0, 1, 5, 2, 1 }, /* coalesced path: 12 units (24 padded rows) over 5 warps = 2 full rounds and a partial one, 2 K iterations */ + { 512, 64, 0, 1, 2, 2, 1 }, /* coalesced path: 32 units over 2 warps = 16 rounds through the two slot sets */ }; + const uint32_t wscheds[3] = { 0, 1, 12345u }; for (unsigned i = 0; i < sizeof pts / sizeof pts[0]; i++) - for (int order = 0; order < 2; order++) { - long bad = sim_i32(pts[i].k, pts[i].n, pts[i].layout, pts[i].rows, pts[i].warps, pts[i].depth, pts[i].grid, 0, 100u + i, order); - CHECK(bad == 0, "sim k %u n %u layout %u rows %u warps %u depth %u grid %u order %d: %ld rows differ from oma_rz_oracle", - pts[i].k, pts[i].n, pts[i].layout, pts[i].rows, pts[i].warps, pts[i].depth, pts[i].grid, order, bad); - } - printf("sim: %u int32 points x 2 orders bit-equal to oma_rz_oracle (%" PRIu64 " warp issues)\n", (unsigned)(sizeof pts / sizeof pts[0]), g_sim_issues); + for (int order = 0; order < 2; order++) + for (int ws = 0; ws < 3; ws++) { + g_sim_wsched = wscheds[ws]; + long bad = sim_i32(pts[i].k, pts[i].n, pts[i].layout, pts[i].rows, pts[i].warps, pts[i].depth, pts[i].grid, 0, 100u + i, order); + CHECK(bad == 0, "sim k %u n %u layout %u rows %u warps %u depth %u grid %u order %d warp order %u: %ld rows differ from oma_rz_oracle", + pts[i].k, pts[i].n, pts[i].layout, pts[i].rows, pts[i].warps, pts[i].depth, pts[i].grid, order, wscheds[ws], bad); + } + g_sim_wsched = 0; + printf("sim: %u int32 points x 2 fragment orders x 3 warp orders bit-equal to oma_rz_oracle (%" PRIu64 " warp issues)\n", + (unsigned)(sizeof pts / sizeof pts[0]), g_sim_issues); + /* the second output slot set: with one set (mutant 4) a warp that reaches the next round before warp 0 has stored + * this one overwrites its slot. The ascending warp order hides it (warp 0 always runs first), the descending and + * shuffled orders must catch it; the production kernel must stay exact under all three. */ + { + long hidden = -1, caught_desc = -1, caught_shuf = -1; + g_sim_wsched = 0; hidden = sim_i32(512, 64, 0, 1, 2, 2, 1, 4, 500u, 0); + g_sim_wsched = 1; caught_desc = sim_i32(512, 64, 0, 1, 2, 2, 1, 4, 500u, 0); + g_sim_wsched = 12345u; caught_shuf = sim_i32(512, 64, 0, 1, 2, 2, 1, 4, 500u, 0); + g_sim_wsched = 0; + CHECK(caught_desc != 0, "sim mutant 4 (one slot set) not caught under the descending warp order"); + CHECK(caught_shuf != 0, "sim mutant 4 (one slot set) not caught under the shuffled warp order"); + printf("sim: mutant 4 (one slot set): ascending warp order %ld rows differ (the order that hid it), descending %ld, shuffled %ld\n", + hidden, caught_desc, caught_shuf); + } + /* the unit clamp: without it (mutant 5) the warps of a partial last round read past the tensor (the simulator refuses + * the access, -1) or store wrong rows */ + { + long bad = sim_i32(1024, 18, 0, 1, 5, 2, 1, 5, 501u, 0); + CHECK(bad != 0, "sim mutant 5 (no unit clamp) not caught on a partial last round"); + if (bad != 0) printf("sim: mutant 5 (no unit clamp) caught (%s)\n", bad < 0 ? "out-of-range access refused" : "rows differ"); + } /* extremes: x all -128 / 127 with all-+1 and all--1 rows */ { const uint32_t k = 1024, n = 8; @@ -475,7 +504,7 @@ static uint32_t g_shape[8][2]; static int g_shape_n; static uint64_t cold_ns(uint32_t n, uint32_t k, uint32_t copies, uint32_t reps, uint64_t *bytes_out, uint64_t *min_out) { int8_t *w = make_w((size_t)n * k, 1.0 / 3.0, 555u + n + k), *x = make_x(k, 556); int32_t *ref = oracle(w, n, k, x), *y = malloc((size_t)n * 4); - OmegaGpuTernTensor **ts = calloc(copies, sizeof *ts); + OmegaGpuTernTensor **ts = calloc(copies, sizeof(OmegaGpuTernTensor *)); uint64_t *d = calloc((size_t)copies * reps, 8), med = 0; size_t nd = 0; OmegaGpuCmdList *cl = NULL; OmegaGpuMem xd, yd; memset(&xd, 0, sizeof xd); memset(&yd, 0, sizeof yd); int ok = 1; diff --git a/tests/gpu_tgemm_test.c b/tests/gpu_tgemm_test.c new file mode 100644 index 000000000..76ebc6ade --- /dev/null +++ b/tests/gpu_tgemm_test.c @@ -0,0 +1,271 @@ +/* gpu_tgemm_test.c (trainer lane E1, 2026-10-16): device-resident bf16 training GEMM (omega_blackwell_codegen_tgemm.h, + * omega_gpu_tgemm_api.h). C[M][N] f32 = A[M][K] bf16 x B[K][N] bf16, row-major, NN. + * --host-only budgets of the production specs: instructions, allocator peak and declared registers (refused past 1000 / 128) + * --sim the kernel in the warp simulator (both fragment orders) bit-identical to the C emulation of the HMMA chain + * (tests/bw_hmma_model.h, GB10 member) over the whole output, tile K ranges (kb0, nkb), mutants 1-4 caught + * --chip (caller holds the GB10 quiet lock) every output against a double reference over the same bf16-rounded inputs + * (|got - ref| / max(sum |terms|, 1e-6) < 1e-5: the rule of gpu_matmul_api_test.c), first with uncached (host) + * buffers, then with GPU-cached device buffers (trainer rule R-8); bit-identical repeats, poison scan (every output + * written), negative control (mutant 4 differs), medians of chip time and whole-call time, TFLOPS and percent of + * the measured bf16 HMMA peak (--peak, default 117.26: evidence TGEMM-CUT1-5b10b824/peak.log, the gate window; + * peak-window1.log of the same day read 120.64; probe gpu_tc_peak_test) + * Verdict line last: "GPU_TGEMM: PASS|FAIL". */ +#include "omega_blackwell_codegen_tgemm.h" +#include "omega_gpu_tgemm_api.h" +#include "omega_gpu_prefill.h" +#include "bw_hmma_model.h" +#include "bw_warp_sim_tc.h" +#include +#include +#include +#include +#include +#include +#include + +static const HmmaModel GB10 = { 16, 2, 0, 2, 0 }; +static uint64_t rng = 0x243f6a8885a308d3ull; +static uint32_t rnd(void) { rng ^= rng << 13; rng ^= rng >> 7; rng ^= rng << 17; return (uint32_t)(rng >> 16); } +static float frnd(void) { return ((float)(rnd() & 0xffffff) / 16777216.0f) * 2.0f - 1.0f; } +static float u2f(uint32_t u) { float f; memcpy(&f, &u, 4); return f; } +static uint32_t f2u(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } +static uint16_t bf16_rn(float f) { uint32_t u = f2u(f); if ((u & 0x7fffffffu) > 0x7f800000u) return 0x7fc0u; return (uint16_t)((u + 0x7fffu + ((u >> 16) & 1u)) >> 16); } +static float bf(uint16_t h) { return u2f((uint32_t)h << 16); } +static double now_ns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (double)t.tv_sec * 1e9 + (double)t.tv_nsec; } + +typedef struct { uint32_t M, N, K; uint16_t *a, *b; } Prob; +static void prob_make(Prob *p, uint32_t M, uint32_t N, uint32_t K) { + p->M = M; p->N = N; p->K = K; + p->a = malloc((size_t)M * K * 2); p->b = malloc((size_t)K * N * 2); + for (size_t i = 0; i < (size_t)M * K; i++) p->a[i] = bf16_rn(frnd() * (rnd() % 16 == 0 ? 8.0f : 1.0f)); + for (size_t i = 0; i < (size_t)K * N; i++) p->b[i] = bf16_rn(frnd() * (rnd() % 16 == 0 ? 8.0f : 1.0f)); +} +static void prob_free(Prob *p) { free(p->a); free(p->b); } + +/* the kernel's arithmetic for output (i, c) over blocks kb0 .. kb0 + nkb - 1: one fused 16-term HMMA per (32-k group, step) */ +static float emu(const Prob *p, uint32_t i, uint32_t c, uint32_t kb0, uint32_t nkb) { + float acc = 0.0f; + for (uint32_t G = kb0 * 4u; G < (kb0 + nkb) * 4u; G++) for (uint32_t s = 0; s < 2; s++) { + float a[16], b[16]; int m = 0; + for (uint32_t t = 0; t < 4; t++) for (uint32_t j = 0; j < 4; j++) { + const uint32_t k = G * 32u + 8u * t + 4u * s + j; + a[m] = bf(p->a[(size_t)i * p->K + k]); b[m] = bf(p->b[(size_t)k * p->N + c]); m++; + } + acc = hm_dot16(&GB10, a, b, acc); + } + return acc; +} + +static int host_only(void) { + int fail = 0; + static const struct { OmegaTgemmSpec s; int production; } specs[] = { + { { 2304, 768, 8, 2, 16, 32, 1, 0, 0, 0 }, 1 }, { { 768, 3072, 8, 2, 16, 32, 1, 0, 0, 0 }, 1 }, { { 768, 50304, 4, 2, 8, 32, 1, 0, 0, 0 }, 1 } /* lm_head forward: n % 256 != 0 picks rt 4 x 8 warps */, { { 50304, 768, 4, 2, 8, 32, 1, 0, 0, 0 }, 0 }, + { { 768, 2304, 4, 2, 16, 32, 2, 0, 0, 0 }, 0 }, { { 768, 768, 4, 2, 16, 32, 1, 0, 0, 0 }, 0 }, { { 768, 768, 4, 2, 8, 32, 1, 0, 0, 0 }, 0 }, { { 768, 768, 2, 2, 8, 32, 1, 0, 0, 0 }, 0 }, + { { 768, 768, 8, 2, 8, 32, 1, 0, 0, 0 }, 0 }, + }; + static BlackwellIRProgram prog; + for (size_t i = 0; i < sizeof specs / sizeof specs[0]; i++) { + const OmegaTgemmSpec *s = &specs[i].s; + int rc = omega_blackwell_codegen_tgemm_prog(s, &prog); + uint32_t peak = rc == 0 ? prog.regalloc.peak_gpr_usage : 0, decl = omega_bw_gpr_declared(peak); + int ok = rc == 0 && prog.count <= OMEGA_TGEMM_MAX_INSNS && decl <= 128u && 32u * s->warps * decl <= 65536u; + printf("spec k %u n %u rt %u ct %u warps %u kc %u aqn %u: %s, %zu instructions, peak %u, declared %u, shared %u B -> %s%s\n", s->k, s->n, s->rt, s->ct, s->warps, s->kc, s->aqn, + rc ? "REFUSED" : "built", rc ? (size_t)0 : prog.count, peak, decl, omega_tgemm_shared_bytes(s), ok ? "fits" : "DOES NOT FIT", specs[i].production ? " (production)" : ""); + if (!ok && specs[i].production) fail++; + } + return fail; +} + +typedef struct { uint32_t M, N, K, rt, warps, aqn, kb0, nkb; } SimCase; +static int sim_run(const Prob *p, const SimCase *c, int mutant, int order, float *y, char *msg, size_t msgn) { + static BlackwellIRProgram prog; + OmegaTgemmSpec sp = { p->K, p->N, c->rt, 2, c->warps, 32, c->aqn, OMEGA_TGEMM_LAYOUT_NN, OMEGA_TGEMM_EPI_F32, mutant }; + if (omega_blackwell_codegen_tgemm_prog(&sp, &prog) != 0) { snprintf(msg, msgn, "codegen refused (spec_ok %d)", omega_tgemm_spec_ok(&sp)); return -1; } + const uint32_t bm = omega_tgemm_bm(&sp), span = omega_tgemm_span(&sp), nt = p->M / bm; + OmegaTgemmTile *tiles = calloc(nt, sizeof *tiles); + for (uint32_t t = 0; t < nt; t++) { tiles[t].c_va = (uintptr_t)y; tiles[t].row0 = t * bm; tiles[t].kb0 = c->kb0; tiles[t].nkb = c->nkb; } + memset(y, 0xee, (size_t)p->M * p->N * 4); + uint8_t *smem = malloc(omega_tgemm_shared_bytes(&sp)); + static WsSim s; memset(&s, 0, sizeof s); + s.p = &prog; s.threads = 32u * sp.warps; s.smem = smem; s.smem_bytes = omega_tgemm_shared_bytes(&sp); s.order = order; + const uint64_t a[3] = { (uintptr_t)tiles, (uintptr_t)p->a, (uintptr_t)p->b }; + for (int i = 0; i < 3; i++) { s.cbank[(0x380 + 8 * i) / 4] = (uint32_t)a[i]; s.cbank[(0x380 + 8 * i) / 4 + 1] = (uint32_t)(a[i] >> 32); } + s.ranges[0].lo = (uintptr_t)tiles; s.ranges[0].hi = (uintptr_t)(tiles + nt); + s.ranges[1].lo = (uintptr_t)p->a; s.ranges[1].hi = (uintptr_t)(p->a + (size_t)p->M * p->K); + s.ranges[2].lo = (uintptr_t)p->b; s.ranges[2].hi = (uintptr_t)(p->b + (size_t)p->K * p->N); + s.ranges[3].lo = (uintptr_t)y; s.ranges[3].hi = (uintptr_t)(y + (size_t)p->M * p->N); + s.nranges = 4; + int err = ws_run(&s, p->N / span, nt); + if (err) snprintf(msg, msgn, "simulator %s", s.msg); + free(tiles); free(smem); + return err ? -1 : 0; +} +static size_t sim_compare(const Prob *p, const float *y, uint32_t kb0, uint32_t nkb) { + size_t bad = 0; + for (uint32_t i = 0; i < p->M; i++) for (uint32_t c = 0; c < p->N; c++) { + const float want = emu(p, i, c, kb0, nkb); + if (f2u(y[(size_t)i * p->N + c]) != f2u(want)) { if (getenv("TGDBG") && bad < 8) printf(" row %u col %u got %.9g want %.9g\n", i, c, y[(size_t)i * p->N + c], want); bad++; } + } + return bad; +} +static int sim_tests(void) { + int fail = 0; char msg[256]; + static const SimCase cs[] = { + { 128, 512, 256, 4, 16, 1, 0, 2 }, { 64, 256, 384, 2, 8, 1, 1, 2 }, { 128, 256, 128, 4, 16, 2, 0, 1 }, { 128, 256, 256, 4, 8, 2, 0, 2 }, { 256, 512, 128, 8, 16, 1, 0, 1 }, + }; + for (size_t c = 0; c < sizeof cs / sizeof cs[0]; c++) { + Prob p; prob_make(&p, cs[c].M, cs[c].N, cs[c].K); + float *y = malloc((size_t)p.M * p.N * 4); + for (int order = 0; order < 2; order++) { + int rc = sim_run(&p, &cs[c], 0, order, y, msg, sizeof msg); + size_t bad = rc ? 0 : sim_compare(&p, y, cs[c].kb0, cs[c].nkb); + printf("sim case %zu (M %u N %u K %u rt %u warps %u aqn %u blocks %u..%u) order %d: %s, %zu of %zu differ\n", c, p.M, p.N, p.K, cs[c].rt, cs[c].warps, cs[c].aqn, + cs[c].kb0, cs[c].kb0 + cs[c].nkb - 1, order, rc ? msg : "ran", bad, (size_t)p.M * p.N); + if (rc || bad) fail++; + } + if (c == 0) for (int m = 1; m <= 4; m++) { + int rc = sim_run(&p, &cs[c], m, 0, y, msg, sizeof msg); + size_t bad = rc ? 0 : sim_compare(&p, y, cs[c].kb0, cs[c].nkb); + printf("sim case %zu mutant %d: %s\n", c, m, rc ? msg : bad ? "caught" : "NOT CAUGHT"); + if (rc || !bad) fail++; + } + free(y); prob_free(&p); + } + return fail; +} + +/* ---- chip: double reference over the bf16 inputs, threaded over rows ---- */ +typedef struct { const Prob *p; const float *y; uint32_t r0, r1; size_t bad, emu_same; double worst; size_t bc4[4], br8[2], brt[4], bw[16], nan, shown; } RefJob; +static void *ref_rows(void *arg) { + RefJob *j = arg; const Prob *p = j->p; + double *col = malloc((size_t)p->N * 16); + for (uint32_t i = j->r0; i < j->r1; i++) { + memset(col, 0, (size_t)p->N * 16); + const uint16_t *ar = p->a + (size_t)i * p->K; + for (uint32_t k = 0; k < p->K; k++) { + const double av = bf(ar[k]); const uint16_t *br = p->b + (size_t)k * p->N; + for (uint32_t c = 0; c < p->N; c++) { const double t = av * (double)bf(br[c]); col[2 * c] += t; col[2 * c + 1] += fabs(t); } + } + for (uint32_t c = 0; c < p->N; c++) { + const float got = j->y[(size_t)i * p->N + c]; + const double scale = col[2 * c + 1] > 1e-6 ? col[2 * c + 1] : 1e-6, rel = fabs((double)got - col[2 * c]) / scale; + if (!(rel < 1e-5)) { j->bad++; j->bc4[c % 4]++; j->br8[(i >> 3) & 1]++; j->brt[(i >> 4) & 3]++; j->bw[(c % 256) / 16]++; j->nan += isnan(got) || isinf(got); + if (getenv("TGDBG") && j->shown < 6) { j->shown++; printf(" bad row %u col %u got %.9g ref %.9g emu %.9g\n", i, c, got, col[2 * c], emu(p, i, c, 0, p->K / 128u)); } } + if (rel > j->worst) j->worst = rel; + if (f2u(got) == f2u(emu(p, i, c, 0, p->K / 128u))) j->emu_same++; + } + } + free(col); + return NULL; +} +static size_t ref_check(const Prob *p, const float *y, size_t *emu_same, double *worst) { + long nproc = sysconf(_SC_NPROCESSORS_ONLN); int nt = nproc < 1 ? 1 : nproc > 32 ? 32 : (int)nproc; + pthread_t th[32]; RefJob jobs[32]; memset(jobs, 0, sizeof jobs); + for (int t = 0; t < nt; t++) { jobs[t].p = p; jobs[t].y = y; jobs[t].r0 = (uint32_t)((uint64_t)p->M * t / nt); jobs[t].r1 = (uint32_t)((uint64_t)p->M * (t + 1) / nt); pthread_create(&th[t], NULL, ref_rows, &jobs[t]); } + size_t bad = 0; *emu_same = 0; *worst = 0; + for (int t = 0; t < nt; t++) { pthread_join(th[t], NULL); bad += jobs[t].bad; *emu_same += jobs[t].emu_same; if (jobs[t].worst > *worst) *worst = jobs[t].worst; } + if (getenv("TGDBG") && bad) { size_t c4[4] = { 0 }, r8[2] = { 0 }, rt[4] = { 0 }, w[16] = { 0 }, nn = 0; + for (int t = 0; t < nt; t++) { for (int q = 0; q < 4; q++) { c4[q] += jobs[t].bc4[q]; rt[q] += jobs[t].brt[q]; } for (int q = 0; q < 2; q++) r8[q] += jobs[t].br8[q]; for (int q = 0; q < 16; q++) w[q] += jobs[t].bw[q]; nn += jobs[t].nan; } + printf(" bad by col%%4: %zu %zu %zu %zu; by row half: %zu %zu; by row tile: %zu %zu %zu %zu; nan/inf %zu\n bad by warp:", c4[0], c4[1], c4[2], c4[3], r8[0], r8[1], rt[0], rt[1], rt[2], rt[3], nn); + for (int q = 0; q < 16; q++) printf(" %zu", w[q]); + printf("\n"); } + return bad; +} +static int cmp_d(const void *a, const void *b) { double x = *(const double *)a, y = *(const double *)b; return x < y ? -1 : x > y; } + +static int chip_shape(uint32_t M, uint32_t N, uint32_t K, int cached, int reps, double peak, double gate_pct) { + Prob p; prob_make(&p, M, N, K); + const size_t ab = (size_t)M * K * 2, bb = (size_t)K * N * 2, cb = (size_t)M * N * 4; + OmegaGpuMem ad = { 0 }, bd = { 0 }, cd = { 0 }; + int rc = cached ? omega_gpu_pf_alloc_dev(ab, &ad) : omega_gpu_pf_alloc_host(ab, &ad); + if (!rc) rc = cached ? omega_gpu_pf_alloc_dev(bb, &bd) : omega_gpu_pf_alloc_host(bb, &bd); + if (!rc) rc = cached ? omega_gpu_pf_alloc_dev(cb, &cd) : omega_gpu_pf_alloc_host(cb, &cd); + if (!rc) rc = omega_gpu_pf_upload(&ad, 0, p.a, ab); + if (!rc) rc = omega_gpu_pf_upload(&bd, 0, p.b, bb); + uint8_t *poison = malloc(cb); memset(poison, 0xff, cb); + float *y1 = malloc(cb), *y2 = malloc(cb); + if (!rc) rc = omega_gpu_pf_upload(&cd, 0, poison, cb); + if (rc) { + printf("shape %ux%ux%u setup: %s (%s)\n", M, N, K, omega_gpu_pf_rc_name(rc), omega_gpu_session_last_error()); + free(poison); free(y1); free(y2); omega_gpu_pf_free(&ad); omega_gpu_pf_free(&bd); omega_gpu_pf_free(&cd); prob_free(&p); + return 1; + } + OmegaTgemmCall call = { OMEGA_TGEMM_LAYOUT_NN, OMEGA_TGEMM_EPI_F32, M, N, K, ad.va, bd.va, cd.va }; + OmegaTgemmSpec sp; + if (omega_gpu_tgemm_spec(&call, &sp) != 0) { + printf("shape %ux%ux%u: spec refused\n", M, N, K); + free(poison); free(y1); free(y2); omega_gpu_pf_free(&ad); omega_gpu_pf_free(&bd); omega_gpu_pf_free(&cd); prob_free(&p); + return 1; + } + const char *kind = cached ? "cached" : "uncached"; + int fail = 0; + if (reps > 64) reps = 64; + double chip[64], wall[64]; + for (int r = 0; r < reps && !rc; r++) { uint64_t ns = 0; const double t0 = now_ns(); rc = omega_gpu_tgemm(&call, &ns); wall[r] = now_ns() - t0; chip[r] = (double)ns; } + if (!rc) rc = omega_gpu_pf_download(&cd, 0, y1, cb); + if (!rc) rc = omega_gpu_pf_upload(&cd, 0, poison, cb); + if (!rc) rc = omega_gpu_tgemm(&call, NULL); + if (!rc) rc = omega_gpu_pf_download(&cd, 0, y2, cb); + if (rc) { printf("shape %ux%ux%u %s run: %s (%s)\n", M, N, K, kind, omega_gpu_pf_rc_name(rc), omega_gpu_session_last_error()); fail++; } + else { + size_t left = 0; for (size_t i = 0; i < (size_t)M * N; i++) left += f2u(y1[i]) == 0xffffffffu; + const int same = !memcmp(y1, y2, cb); + size_t emu_same = 0; double worst = 0; + const double t0 = now_ns(); + const size_t bad = ref_check(&p, y1, &emu_same, &worst); + qsort(chip, reps, 8, cmp_d); qsort(wall, reps, 8, cmp_d); + const double fl = 2.0 * M * N * K, mc = chip[reps / 2], mw = wall[reps / 2], tc = fl / mc / 1e3, tw = fl / mw / 1e3; + printf("TGEMM %ux%ux%u %s rt %u warps %u tiles %u grid_x %u: reference %zu of %zu outside 1e-5 (worst %.3g), %zu bit-identical to the emulation, repeats identical %s, poison left %zu (reference %.1f s)\n", + M, N, K, kind, sp.rt, sp.warps, M / omega_tgemm_bm(&sp), N / omega_tgemm_span(&sp), bad, (size_t)M * N, worst, emu_same, same ? "yes" : "NO", left, (now_ns() - t0) / 1e9); + printf("TGEMM %ux%ux%u %s: chip median %.3f ms (min %.3f) = %.2f TFLOPS = %.1f%% of peak %.2f; whole call median %.3f ms = %.2f TFLOPS = %.1f%%%s\n", + M, N, K, kind, mc / 1e6, chip[0] / 1e6, tc, 100.0 * tc / peak, peak, mw / 1e6, tw, 100.0 * tw / peak, cached && gate_pct > 0 ? (100.0 * tc / peak >= gate_pct ? " GATE ok" : " GATE FAIL") : ""); + if (bad || !same || left) fail++; + if (cached && gate_pct > 0 && !(100.0 * tc / peak >= gate_pct)) fail++; /* the gate is on device-resident (GPU-cached) buffers; the uncached pass is the correctness-first step (R-8) */ + if (!cached) { /* negative control: the parity-swapped kernel must give a different result (a comparison that cannot fail is no comparison) */ + for (int m = 4; m >= 1; m -= 3) { + omega_gpu_tgemm_test_set_mutant(m); + int mrc = omega_gpu_tgemm(&call, NULL); + omega_gpu_tgemm_test_set_mutant(0); + if (!mrc) mrc = omega_gpu_pf_download(&cd, 0, y2, cb); + const int diff = !mrc && memcmp(y1, y2, cb) != 0; + printf("TGEMM %ux%ux%u mutant %d: %s\n", M, N, K, m, mrc ? "launch failed" : diff ? "caught" : "NOT CAUGHT"); + if (!diff) fail++; + } + } + } + free(poison); free(y1); free(y2); + omega_gpu_pf_free(&ad); omega_gpu_pf_free(&bd); omega_gpu_pf_free(&cd); + prob_free(&p); + return fail; +} + +int main(int argc, char **argv) { + int host = 1, sim = 1, chip = 0, reps = 7, cached_only = 0, uncached_only = 0; double peak = 117.26, gate = 0; const char *shape = NULL; + for (int i = 1; i < argc; i++) { + if (!strcmp(argv[i], "--host-only")) sim = 0; + else if (!strcmp(argv[i], "--sim")) host = 0; + else if (!strcmp(argv[i], "--chip")) { chip = 1; host = 0; sim = 0; } + else if (!strcmp(argv[i], "--shape") && i + 1 < argc) shape = argv[++i]; + else if (!strcmp(argv[i], "--reps") && i + 1 < argc) reps = atoi(argv[++i]); + else if (!strcmp(argv[i], "--peak") && i + 1 < argc) peak = atof(argv[++i]); + else if (!strcmp(argv[i], "--gate") && i + 1 < argc) gate = atof(argv[++i]); + else if (!strcmp(argv[i], "--cached-only")) cached_only = 1; + else if (!strcmp(argv[i], "--mutant") && i + 1 < argc) omega_gpu_tgemm_test_set_mutant(atoi(argv[++i])); /* timing probes: results are wrong on purpose */ + else if (!strcmp(argv[i], "--uncached-only")) uncached_only = 1; + else if (!strcmp(argv[i], "--shape-knob") && i + 3 < argc) { omega_gpu_tgemm_set_shape((uint32_t)atoi(argv[i + 1]), (uint32_t)atoi(argv[i + 2]), (uint32_t)atoi(argv[i + 3])); i += 3; } + } + int fail = 0; + if (host) fail += host_only(); + if (sim) fail += sim_tests(); + if (chip) { + static const char *gate_shapes[] = { "8192x768x2304", "8192x768x768", "8192x768x3072", "8192x3072x768" }; + for (size_t s = 0; s < (shape ? 1u : sizeof gate_shapes / sizeof gate_shapes[0]); s++) { + unsigned M = 0, N = 0, K = 0; + if (sscanf(shape ? shape : gate_shapes[s], "%ux%ux%u", &M, &N, &K) != 3) { printf("bad shape\n"); fail++; break; } + if (!cached_only) fail += chip_shape(M, N, K, 0, reps, peak, gate); + if (!uncached_only) fail += chip_shape(M, N, K, 1, reps, peak, gate); + } + } + printf("GPU_TGEMM: %s\n", fail ? "FAIL" : "PASS"); + return fail ? 1 : 0; +} diff --git a/tests/test_omega_codegen_freestanding.c b/tests/test_omega_codegen_freestanding.c index 47e246cdf..0f80e8f1f 100644 --- a/tests/test_omega_codegen_freestanding.c +++ b/tests/test_omega_codegen_freestanding.c @@ -178,6 +178,8 @@ static void golden_fixtures(void) { CHECK(omega_blackwell_verify_codegen_fixtures_intops() == 0, "intops golden words"); CHECK(omega_blackwell_verify_codegen_fixtures_fragmm() == 0, "fragmm golden words"); CHECK(omega_blackwell_verify_codegen_fixtures_reconv() == 0, "reconv golden words"); + CHECK(omega_blackwell_verify_codegen_fixtures_bfly_f2fp() == 0, "SHFL.BFLY / F2FP.BF16 golden words (rc %d)", omega_blackwell_verify_codegen_fixtures_bfly_f2fp()); + CHECK(omega_blackwell_verify_codegen_fixtures_atomf32() == 0, "ATOMG.E.ADD.F32 golden words (rc %d)", omega_blackwell_verify_codegen_fixtures_atomf32()); CHECK(omega_blackwell_test_regalloc_bounds() == 0, "regalloc bounds"); } diff --git a/tests/visor/.crumb b/tests/visor/.crumb index da6a0aabf..f606bc1ed 100644 --- a/tests/visor/.crumb +++ b/tests/visor/.crumb @@ -22,26 +22,26 @@ "children": [ { "digest": "5ada929bcb152309d4e3cbcf5dc197eab94972fd64efca8b471046a3a89ab6cd", - "last_commit": "59c24b2", + "last_commit": "59c24b22", "name": "qualification", "purpose": "Directory tests/visor/qualification. Purpose not yet described by a human." }, { "digest": "19402f2edf2008cb5b961c4a369f9b962d18ebe2076a102b0e30aba7f6cda306", - "last_commit": "aa78c3f", + "last_commit": "aa78c3f2", "name": "sessions", "purpose": "Directory tests/visor/sessions. Purpose not yet described by a human." } ], "children_root": "sha256:0703c3283bea47ee0bfc6c0bbd8ec55bacd2487c17e31d0d80d1fb90aa592bb5", - "compiled_at": "2026-10-04T13:47:05Z", + "compiled_at": "2026-10-17T00:22:30Z", "compiler": "crumb-compile/1", - "digest": "sha256:3f19e3034ff999211cb13ab8995ca6c38d0d8e1f5bfbbbd621caaa08412d3f1f", + "digest": "sha256:a4bd83d8b29b76464c0ac4be84bd12097b14d1164dfd84b63acf57cc2a6d1ab0", "evidence_files": 8, "evidence_root": "sha256:a2c4aaddc14ed3b6aae059061c23683b4ccf0562046ec883b40f14014fbce670", "files": 33, - "generated_at_commit": "834ee93e4314a42c1127a2fcda8b29cf3b511245", - "source_tree": "sha256:faf6defc59051772c110d364658a03690cfb8928749e63a3935e164b0b524598" + "generated_at_commit": "3aaa2d879f6592bdd6fa31823820879a4fed48f0", + "source_tree": "sha256:db8f9440816d8e121bff76dd2dbaf741ed70f5700d6d820f0a3dd4b66b3fd750" }, "owner_lane": "", "provenance": { diff --git a/tests/visor/test_visor_evidence.c b/tests/visor/test_visor_evidence.c index 90dbb320d..e5ec261ce 100644 --- a/tests/visor/test_visor_evidence.c +++ b/tests/visor/test_visor_evidence.c @@ -1,7 +1,10 @@ /* Lane 4: visor_evidence tests (fixtures + read-only pass over the real evidence/ tree). * Run from the repo root. Prints "PASS n/n" on success. */ #include +#include #include +#include +#include #include "omega_canonical.h" #include "visor_evidence.h" @@ -14,6 +17,36 @@ static int g_total, g_pass; static VisorEvidenceView v, v2; static char txt_a[65536], txt_b[65536], js[65536]; +/* omega#404: a tree larger than the old 1024-file walk cap. 1500 non-JSON files plus one parseable receipt named to + * sort last: every file must be scanned, the receipt must be found, and nothing is truncated, whatever order the + * filesystem returns. The old walk stopped at 1024 files in readdir order (red: scanned 1024, truncated). */ +static void check_large_tree(void) { + char root[] = "/tmp/visor_evidence_large_XXXXXX"; + if (!mkdtemp(root)) { CHECK(0, "large tree: mkdtemp"); return; } + char p[512]; + enum { NFILES = 1500 }; + int made = 0; + for (int i = 0; i < NFILES; ++i) { + snprintf(p, sizeof p, "%s/f%04d.txt", root, i); + FILE *f = fopen(p, "w"); + if (f) { fputs("not a receipt\n", f); fclose(f); made++; } + } + static char buf[65536]; + size_t n = 0; + FILE *src = fopen(FIX "/HOST/host_run_receipt.json", "rb"); + if (src) { n = fread(buf, 1, sizeof buf, src); fclose(src); } + snprintf(p, sizeof p, "%s/zzz_last_receipt.json", root); + FILE *dst = fopen(p, "wb"); + if (dst) { fwrite(buf, 1, n, dst); fclose(dst); } + CHECK(made == NFILES && n > 0 && dst, "large tree built (1500 files + 1 receipt)"); + CHECK(visor_evidence_scan(root, &v) == 0 && v.scanned == NFILES + 1 && v.matched == 1 && v.count == 1 && + v.unparsed == NFILES && !v.truncated, "large tree: every file scanned, receipt found, not truncated"); + CHECK(v.count == 1 && strstr(v.items[0].path, "zzz_last_receipt.json"), "large tree: the last-sorted receipt is the match"); + for (int i = 0; i < NFILES; ++i) { snprintf(p, sizeof p, "%s/f%04d.txt", root, i); unlink(p); } + snprintf(p, sizeof p, "%s/zzz_last_receipt.json", root); unlink(p); + rmdir(root); +} + static const VisorEvidenceRecord *find(const VisorEvidenceView *view, const char *suffix) { size_t L = strlen(suffix); for (size_t i = 0; i < view->count; ++i) { @@ -99,6 +132,8 @@ int main(void) { CHECK(visor_evidence_format_json(&v, js, sizeof(js)) > 0 && js[0] == '{' && strstr(js, "\"scope\":\"QEMU\""), "json"); CHECK(visor_evidence_format_text(&v, txt_b, 32) == -1, "truncation fails closed"); + check_large_tree(); + /* --- real evidence/ tree, read-only: format coverage and no upgrade --- */ if (visor_evidence_scan("evidence", &v) == 0) { CHECK(v.scanned >= 70 && v.count == VISOR_EVIDENCE_MAX_ITEMS && v.truncated && v.matched >= 50, diff --git a/tools/.crumb b/tools/.crumb index 8cf70bcac..312337f13 100644 --- a/tools/.crumb +++ b/tools/.crumb @@ -62,14 +62,14 @@ } ], "children_root": "sha256:e1f826c2beb8604bb0dcba49575f7c6b48cf5488c40b616b212fda2ed70c62ee", - "compiled_at": "2026-10-16T19:04:20Z", + "compiled_at": "2026-10-20T20:54:39Z", "compiler": "crumb-compile/1", - "digest": "sha256:566a123ba248da906e3c42430b73decd7c3ec030a4fd26c909d265aa9bf67db9", + "digest": "sha256:9352e55d6b0ccb416f48edf2d9d37fb66477335b51c8dbb4b5a84d7c33091e29", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 284, - "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426", - "source_tree": "sha256:eee0218ae5c8d003fa0a585291551799e81e6c329a7f5db1295e771a75aee167" + "files": 287, + "generated_at_commit": "738552e3f036b757e740f1dbfa1c4e7de069f63c", + "source_tree": "sha256:eecdee0a81e4a9c4d1e819b3d47dd3d78f28b97dc0f49ab8bb0a56cf8a16197c" }, "owner_lane": "", "provenance": { diff --git a/tools/dgraph_receipt.c b/tools/dgraph_receipt.c new file mode 100644 index 000000000..69a1b92ec --- /dev/null +++ b/tools/dgraph_receipt.c @@ -0,0 +1,825 @@ +/* + * dgraph_receipt.c -- decode-graph performance receipt (aien-architecture#233, lane P1). Host only. + * + * Turns one existing run of the decode-graph chip test (tests/gpu_decode_graph_test.c, driven by + * tools/run_gpu_decode_graph_chip.sh) into ONE machine-readable, commit-bound receipt + * "omega-decode-graph-receipt/1", and checks such receipts. It reads files only: no GPU, no + * libomega_gpu, no new counters. Every number it writes is either copied from the run's own files + * or derived from them by a rule the checker re-applies. Spec: docs/perf/DECODE_GRAPH_RECEIPT.md. + * + * dgraph_receipt --run-dir DIR --stats FILE --log FILE --status STATUS --repo OWNER/NAME + * --model TEXT --precision TEXT --mode TEXT --runner TEXT [--evidence PATH]... + * [--out FILE] + * DIR holds the runner's device.txt, binaries.sha256 and build.log; FILE (stats) is the test's + * --out JSON; the log is the test's stdout (its "dgraph prefetch" and "fp8 knobs" lines). + * The receipt is checked before it is written; a receipt the checker refuses is never written. + * dgraph_receipt --check FILE [--evidence-root DIR] + * exit 0 and "dgraph_receipt: OK FILE" when the receipt passes; exit 1 and + * "dgraph_receipt: REJECT FILE: " otherwise. With --evidence-root every evidence path + * must exist under DIR. + * Exit 2: usage or unreadable input. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SCHEMA "omega-decode-graph-receipt/1" +#define MAX_INPUT (4u << 20) +#define MAX_DEPTH 32 + +/* ------------------------------------------------------------------ JSON reader (strict) */ +typedef enum { J_NULL, J_BOOL, J_NUM, J_STR, J_ARR, J_OBJ } JType; +typedef struct JV { + JType t; + int b; /* J_BOOL */ + int is_int; /* J_NUM: literal had no '.', 'e', 'E' and fits int64 */ + int64_t i; + double d; + char *s; /* J_STR (NUL-terminated, no embedded NUL accepted) */ + size_t n; /* J_ARR / J_OBJ element count */ + struct JV **v; + char **k; /* J_OBJ keys */ +} JV; + +typedef struct { const char *p, *end; char err[160]; } Parser; + +static void *xmalloc(size_t n) { void *p = malloc(n ? n : 1); if (!p) { fputs("dgraph_receipt: out of memory\n", stderr); exit(2); } return p; } +static void *xrealloc(void *p, size_t n) { p = realloc(p, n ? n : 1); if (!p) { fputs("dgraph_receipt: out of memory\n", stderr); exit(2); } return p; } + +static void jfree(JV *v) { + if (!v) return; + for (size_t i = 0; i < v->n; i++) { jfree(v->v[i]); if (v->k) free(v->k[i]); } + free(v->v); free(v->k); free(v->s); free(v); +} + +static void perr(Parser *P, const char *m) { if (!P->err[0]) snprintf(P->err, sizeof P->err, "invalid JSON: %s", m); } +static void skip_ws(Parser *P) { while (P->p < P->end && (*P->p == ' ' || *P->p == '\t' || *P->p == '\n' || *P->p == '\r')) P->p++; } +static JV *jnew(JType t) { JV *v = xmalloc(sizeof *v); memset(v, 0, sizeof *v); v->t = t; return v; } + +static int hexv(char c) { return c >= '0' && c <= '9' ? c - '0' : c >= 'a' && c <= 'f' ? c - 'a' + 10 : c >= 'A' && c <= 'F' ? c - 'A' + 10 : -1; } +static int read_hex4(Parser *P, unsigned *out) { + if (P->end - P->p < 4) return -1; + unsigned u = 0; + for (int i = 0; i < 4; i++) { int h = hexv(P->p[i]); if (h < 0) return -1; u = u * 16u + (unsigned)h; } + P->p += 4; *out = u; return 0; +} +static void put_utf8(char **b, size_t *n, size_t *cap, unsigned cp) { + if (*n + 5 > *cap) { *cap = *cap * 2 + 8; *b = xrealloc(*b, *cap); } + if (cp < 0x80) (*b)[(*n)++] = (char)cp; + else if (cp < 0x800) { (*b)[(*n)++] = (char)(0xC0 | (cp >> 6)); (*b)[(*n)++] = (char)(0x80 | (cp & 0x3F)); } + else if (cp < 0x10000) { (*b)[(*n)++] = (char)(0xE0 | (cp >> 12)); (*b)[(*n)++] = (char)(0x80 | ((cp >> 6) & 0x3F)); (*b)[(*n)++] = (char)(0x80 | (cp & 0x3F)); } + else { (*b)[(*n)++] = (char)(0xF0 | (cp >> 18)); (*b)[(*n)++] = (char)(0x80 | ((cp >> 12) & 0x3F)); (*b)[(*n)++] = (char)(0x80 | ((cp >> 6) & 0x3F)); (*b)[(*n)++] = (char)(0x80 | (cp & 0x3F)); } +} + +static char *parse_str(Parser *P) { + if (P->p >= P->end || *P->p != '"') { perr(P, "expected string"); return NULL; } + P->p++; + size_t n = 0, cap = 32; char *b = xmalloc(cap); + while (P->p < P->end && *P->p != '"') { + unsigned char c = (unsigned char)*P->p++; + if (c < 0x20) { perr(P, "control character in string"); free(b); return NULL; } + if (c == '\\') { + if (P->p >= P->end) break; + char e = *P->p++; unsigned cp; + switch (e) { + case '"': cp = '"'; break; case '\\': cp = '\\'; break; case '/': cp = '/'; break; + case 'b': cp = 8; break; case 'f': cp = 12; break; case 'n': cp = 10; break; case 'r': cp = 13; break; case 't': cp = 9; break; + case 'u': + if (read_hex4(P, &cp)) { perr(P, "bad \\u escape"); free(b); return NULL; } + if (cp >= 0xD800 && cp < 0xDC00) { + unsigned lo; + if (P->end - P->p < 6 || P->p[0] != '\\' || P->p[1] != 'u') { perr(P, "lone surrogate"); free(b); return NULL; } + P->p += 2; + if (read_hex4(P, &lo) || lo < 0xDC00 || lo > 0xDFFF) { perr(P, "lone surrogate"); free(b); return NULL; } + cp = 0x10000 + ((cp - 0xD800) << 10) + (lo - 0xDC00); + } else if (cp >= 0xDC00 && cp <= 0xDFFF) { perr(P, "lone surrogate"); free(b); return NULL; } + if (cp == 0) { perr(P, "NUL in string"); free(b); return NULL; } + break; + default: perr(P, "bad escape"); free(b); return NULL; + } + put_utf8(&b, &n, &cap, cp); + } else { + if (n + 2 > cap) { cap *= 2; b = xrealloc(b, cap); } + b[n++] = (char)c; + } + } + if (P->p >= P->end) { perr(P, "unterminated string"); free(b); return NULL; } + P->p++; + b[n] = 0; + return b; +} + +static JV *parse_val(Parser *P, int depth); + +static JV *parse_num(Parser *P) { + const char *s = P->p; int frac = 0; + if (P->p < P->end && *P->p == '-') P->p++; + if (P->p >= P->end || !isdigit((unsigned char)*P->p)) { perr(P, "bad number"); return NULL; } + if (*P->p == '0') P->p++; else while (P->p < P->end && isdigit((unsigned char)*P->p)) P->p++; + if (P->p < P->end && *P->p == '.') { + frac = 1; P->p++; + if (P->p >= P->end || !isdigit((unsigned char)*P->p)) { perr(P, "bad number"); return NULL; } + while (P->p < P->end && isdigit((unsigned char)*P->p)) P->p++; + } + if (P->p < P->end && (*P->p == 'e' || *P->p == 'E')) { + frac = 1; P->p++; + if (P->p < P->end && (*P->p == '+' || *P->p == '-')) P->p++; + if (P->p >= P->end || !isdigit((unsigned char)*P->p)) { perr(P, "bad number"); return NULL; } + while (P->p < P->end && isdigit((unsigned char)*P->p)) P->p++; + } + char tmp[64]; size_t len = (size_t)(P->p - s); + if (len >= sizeof tmp) { perr(P, "number too long"); return NULL; } + memcpy(tmp, s, len); tmp[len] = 0; + JV *v = jnew(J_NUM); + v->d = strtod(tmp, NULL); + if (!frac) { errno = 0; long long ll = strtoll(tmp, NULL, 10); if (errno == 0) { v->is_int = 1; v->i = ll; } } + return v; +} + +static JV *parse_val(Parser *P, int depth) { + if (depth > MAX_DEPTH) { perr(P, "nested too deep"); return NULL; } + skip_ws(P); + if (P->p >= P->end) { perr(P, "unexpected end"); return NULL; } + char c = *P->p; + if (c == '{' || c == '[') { + const int obj = c == '{'; + JV *v = jnew(obj ? J_OBJ : J_ARR); P->p++; + skip_ws(P); + if (P->p < P->end && *P->p == (obj ? '}' : ']')) { P->p++; return v; } + for (;;) { + char *key = NULL; + if (obj) { + skip_ws(P); + key = parse_str(P); + if (!key) { jfree(v); return NULL; } + for (size_t i = 0; i < v->n; i++) if (!strcmp(v->k[i], key)) { perr(P, "duplicate key"); free(key); jfree(v); return NULL; } + skip_ws(P); + if (P->p >= P->end || *P->p != ':') { perr(P, "expected ':'"); free(key); jfree(v); return NULL; } + P->p++; + } + JV *e = parse_val(P, depth + 1); + if (!e) { free(key); jfree(v); return NULL; } + /* v->v and v->k are arrays of POINTERS (JV *, char *): the element size is the pointer size, not sizeof(JV). + * Under-sizing would overflow on the 2nd element; tests/dgraph_receipt/run.sh parses wide objects and arrays under ASan. */ + v->v = xrealloc(v->v, (v->n + 1) * sizeof *v->v); + if (obj) { v->k = xrealloc(v->k, (v->n + 1) * sizeof *v->k); v->k[v->n] = key; } + v->v[v->n++] = e; + skip_ws(P); + if (P->p < P->end && *P->p == ',') { P->p++; continue; } + if (P->p < P->end && *P->p == (obj ? '}' : ']')) { P->p++; return v; } + perr(P, obj ? "expected ',' or '}'" : "expected ',' or ']'"); jfree(v); return NULL; + } + } + if (c == '"') { char *s = parse_str(P); if (!s) return NULL; JV *v = jnew(J_STR); v->s = s; return v; } + if (c == '-' || isdigit((unsigned char)c)) return parse_num(P); + if (P->end - P->p >= 4 && !memcmp(P->p, "true", 4)) { P->p += 4; JV *v = jnew(J_BOOL); v->b = 1; return v; } + if (P->end - P->p >= 5 && !memcmp(P->p, "false", 5)) { P->p += 5; return jnew(J_BOOL); } + if (P->end - P->p >= 4 && !memcmp(P->p, "null", 4)) { P->p += 4; return jnew(J_NULL); } + perr(P, "unexpected character"); + return NULL; +} + +static JV *jparse(const char *buf, size_t n, char *err, size_t cap) { + Parser P; P.p = buf; P.end = buf + n; P.err[0] = 0; + if (memchr(buf, 0, n)) { snprintf(err, cap, "invalid JSON: NUL byte"); return NULL; } + JV *v = parse_val(&P, 0); + if (v) { skip_ws(&P); if (P.p != P.end) { perr(&P, "trailing data"); jfree(v); v = NULL; } } + if (!v) snprintf(err, cap, "%s", P.err); + return v; +} + +static JV *jget(const JV *o, const char *k) { + if (!o || o->t != J_OBJ) return NULL; + for (size_t i = 0; i < o->n; i++) if (!strcmp(o->k[i], k)) return o->v[i]; + return NULL; +} +/* dotted path: "timeline.span_ns" */ +static JV *jpath(const JV *o, const char *path) { + char tmp[128]; snprintf(tmp, sizeof tmp, "%s", path); + const JV *cur = o; + for (char *save = NULL, *tok = strtok_r(tmp, ".", &save); tok; tok = strtok_r(NULL, ".", &save)) { cur = jget(cur, tok); if (!cur) return NULL; } + return (JV *)cur; +} + +/* ------------------------------------------------------------------ files */ +static char *read_file(const char *path, size_t *len) { + FILE *f = fopen(path, "rb"); + if (!f) return NULL; + size_t cap = 4096, n = 0; char *b = xmalloc(cap + 1); + for (;;) { + if (n == cap) { if (cap >= MAX_INPUT) { fclose(f); free(b); errno = EFBIG; return NULL; } cap *= 2; b = xrealloc(b, cap + 1); } + size_t r = fread(b + n, 1, cap - n, f); + n += r; + if (r == 0) break; + } + int bad = ferror(f); fclose(f); + if (bad) { free(b); return NULL; } + b[n] = 0; if (len) *len = n; + return b; +} + +static char *join(const char *dir, const char *name) { + size_t a = strlen(dir), b = strlen(name); + char *r = xmalloc(a + b + 2); + memcpy(r, dir, a); r[a] = '/'; memcpy(r + a + 1, name, b + 1); + if (a && dir[a - 1] == '/') memmove(r + a, r + a + 1, b + 1); + return r; +} + +/* ------------------------------------------------------------------ JSON writer (pretty, fixed key order) */ +typedef struct { FILE *f; int depth; int first[MAX_DEPTH + 2]; } W; +static void w_indent(W *w) { fputc('\n', w->f); for (int i = 0; i < w->depth; i++) fputs(" ", w->f); } +static void w_str(W *w, const char *s) { + fputc('"', w->f); + for (const unsigned char *p = (const unsigned char *)s; *p; p++) { + if (*p == '"' || *p == '\\') { fputc('\\', w->f); fputc(*p, w->f); } + else if (*p == '\n') fputs("\\n", w->f); + else if (*p == '\t') fputs("\\t", w->f); + else if (*p < 0x20) fprintf(w->f, "\\u%04x", *p); + else fputc(*p, w->f); + } + fputc('"', w->f); +} +static void w_key(W *w, const char *k) { + if (!w->first[w->depth]) fputc(',', w->f); + w->first[w->depth] = 0; + w_indent(w); + if (k) { w_str(w, k); fputs(": ", w->f); } +} +static void w_open(W *w, const char *k, char c) { w_key(w, k); fputc(c, w->f); w->depth++; w->first[w->depth] = 1; } +static void w_close(W *w, char c) { int empty = w->first[w->depth]; w->depth--; if (!empty) w_indent(w); fputc(c, w->f); } +static void kv_s(W *w, const char *k, const char *v) { w_key(w, k); w_str(w, v); } +static void kv_i(W *w, const char *k, int64_t v) { w_key(w, k); fprintf(w->f, "%" PRId64, v); } +static void kv_b(W *w, const char *k, int v) { w_key(w, k); fputs(v ? "true" : "false", w->f); } +static void kv_null(W *w, const char *k) { w_key(w, k); fputs("null", w->f); } +static void kv_fmt(W *w, const char *k, const char *fmt, ...) { + char b[1024]; va_list ap; va_start(ap, fmt); vsnprintf(b, sizeof b, fmt, ap); va_end(ap); kv_s(w, k, b); +} + +/* ------------------------------------------------------------------ checker */ +static const char *const STATUSES[] = { "VERIFIED", "EXPERIMENTAL", "HISTORICAL", "NOT_RUN", "FAIL", "SUPERSEDED" }; +static const char *const TOP_KEYS[] = { "schema", "status", "status_note", "run_verdict", "not_run_reason", "source", "run", "workload", "hardware", + "build", "per_token", "stamped_token", "aggregate", "serial_vs_overlap", "methodology", "evidence", "limitations" }; + +typedef struct { char *msg; size_t cap; int bad; } Err; +static int rej(Err *e, const char *fmt, ...) { + if (!e->bad) { va_list ap; va_start(ap, fmt); vsnprintf(e->msg, e->cap, fmt, ap); va_end(ap); e->bad = 1; } + return -1; +} + +static int is_placeholder(const char *s) { + while (*s == ' ' || *s == '\t') s++; + size_t n = strlen(s); + while (n && (s[n - 1] == ' ' || s[n - 1] == '\t')) n--; + if (n == 0) return 1; + static const char *const P[] = { "tbd", "tba", "todo", "fixme", "unknown", "unk", "n/a", "na", "none", "null", "nil", "placeholder", "xxx", "?", "??", "???", "-", "...", "", "" }; + for (size_t i = 0; i < sizeof P / sizeof P[0]; i++) if (strlen(P[i]) == n && !strncasecmp(s, P[i], n)) return 1; + return 0; +} +/* every string (value and key) anywhere in the document */ +static int scan_placeholders(const JV *v, const char *where, Err *e) { + if (v->t == J_STR && is_placeholder(v->s)) return rej(e, "placeholder value \"%s\" at %s", v->s, where); + for (size_t i = 0; i < v->n; i++) { + char sub[256]; + if (v->t == J_OBJ) { + if (is_placeholder(v->k[i])) return rej(e, "placeholder key \"%s\" in %s", v->k[i], where); + snprintf(sub, sizeof sub, "%s.%s", where, v->k[i]); + } else snprintf(sub, sizeof sub, "%s[%zu]", where, i); + if (scan_placeholders(v->v[i], sub, e)) return -1; + } + return 0; +} + +static const JV *need(const JV *o, const char *path, JType t, Err *e) { + const JV *v = jpath(o, path); + if (!v) { rej(e, "missing field %s", path); return NULL; } + if (v->t != t) { rej(e, "field %s has the wrong type", path); return NULL; } + return v; +} +static const char *need_s(const JV *o, const char *path, Err *e) { const JV *v = need(o, path, J_STR, e); return v ? v->s : NULL; } +static int need_i(const JV *o, const char *path, int64_t min, int64_t *out, Err *e) { + const JV *v = need(o, path, J_NUM, e); + if (!v) return -1; + if (!v->is_int) return rej(e, "field %s is not an integer", path); + if (v->i < min) return rej(e, "field %s = %" PRId64 " is below %" PRId64, path, v->i, min); + if (out) *out = v->i; + return 0; +} +static int need_b(const JV *o, const char *path, int *out, Err *e) { const JV *v = need(o, path, J_BOOL, e); if (!v) return -1; if (out) *out = v->b; return 0; } +static int is_hex(const char *s, size_t n) { + if (strlen(s) != n) return 0; + for (size_t i = 0; i < n; i++) if (!((s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'f'))) return 0; + return 1; +} +static int need_hex(const JV *o, const char *path, size_t n, Err *e) { + const char *s = need_s(o, path, e); + if (!s) return -1; + if (!is_hex(s, n)) return rej(e, "field %s \"%s\" is not %zu lowercase hex digits", path, s, n); + return 0; +} +static int need_str_list(const JV *o, const char *path, Err *e) { + const JV *a = need(o, path, J_ARR, e); + if (!a) return -1; + if (a->n == 0) return rej(e, "field %s is an empty list", path); + for (size_t i = 0; i < a->n; i++) if (a->v[i]->t != J_STR) return rej(e, "field %s[%zu] is not a string", path, i); + return 0; +} + +/* the derived-number rules (also used by the generator, so both sides apply the same rule) */ +static int check_overhead(const JV *sec, const char *name, Err *e) { + char p[96]; int64_t tot, chip, oh; + snprintf(p, sizeof p, "%s.total_ns", name); if (need_i(sec, p, 0, &tot, e)) return -1; + snprintf(p, sizeof p, "%s.chip_ns", name); if (need_i(sec, p, 0, &chip, e)) return -1; + snprintf(p, sizeof p, "%s.host_overhead_ns", name); if (need_i(sec, p, INT64_MIN, &oh, e)) return -1; + if (oh != tot - chip) return rej(e, "derived %s.host_overhead_ns = %" PRId64 " but total_ns - chip_ns = %" PRId64, name, oh, tot - chip); + int64_t l, s; + snprintf(p, sizeof p, "%s.launches", name); if (need_i(sec, p, 1, &l, e)) return -1; + snprintf(p, sizeof p, "%s.submits", name); if (need_i(sec, p, 1, &s, e)) return -1; + if (s > l) return rej(e, "%s.submits %" PRId64 " exceeds launches %" PRId64, name, s, l); + snprintf(p, sizeof p, "%s.sems_done", name); + const JV *sd = jpath(sec, p); + if (!sd) return rej(e, "missing field per_token.%s", p); + if (sd->t == J_NULL) { snprintf(p, sizeof p, "%s.sems_done_note", name); if (!need_s(sec, p, e)) return -1; } + else if (sd->t != J_NUM || !sd->is_int || sd->i != l) return rej(e, "per_token.%s must equal launches or be null with a note", p); + return 0; +} + +static int check_measurements(const JV *r, Err *e) { + const JV *pt = need(r, "per_token", J_OBJ, e); + if (!pt) return -1; + if (!need_s(pt, "statistic", e)) return -1; + int64_t tokens, tok_meas; + if (need_i(r, "workload.tokens", 1, &tokens, e)) return -1; + if (need_i(pt, "tokens", 1, &tok_meas, e)) return -1; + if (tok_meas != tokens) return rej(e, "per_token.tokens %" PRId64 " differs from workload.tokens %" PRId64, tok_meas, tokens); + if (!need(pt, "graph", J_OBJ, e) || check_overhead(pt, "graph", e)) return -1; + if (need_i(pt, "graph.record_ns", 0, NULL, e)) return -1; + if (!need(pt, "flush_each", J_OBJ, e) || check_overhead(pt, "flush_each", e)) return -1; + if (need_b(pt, "flush_each.identical_to_graph", NULL, e)) return -1; + + const JV *st = need(r, "stamped_token", J_OBJ, e); + if (!st) return -1; + int64_t sl, span, chip, un, sum; + if (need_i(st, "launches", 1, &sl, e) || need_i(st, "span_ns", 1, &span, e) || need_i(st, "chip_ns", 1, &chip, e) || + need_i(st, "unattributed_ns", INT64_MIN, &un, e) || need_i(st, "stage_sum_ns", 0, &sum, e)) return -1; + if (span > chip) return rej(e, "stamped_token.span_ns %" PRId64 " (device) exceeds chip_ns %" PRId64 " (the host span that contains it)", span, chip); + if (un != chip - span) return rej(e, "derived stamped_token.unattributed_ns = %" PRId64 " but chip_ns - span_ns = %" PRId64, un, chip - span); + const JV *stages = need(st, "stages", J_ARR, e); + if (!stages) return -1; + if (stages->n == 0) return rej(e, "stamped_token.stages is empty"); + int64_t ssum = 0, lsum = 0; + for (size_t i = 0; i < stages->n; i++) { + const JV *g = stages->v[i]; int64_t gl, gn; + if (g->t != J_OBJ) return rej(e, "stamped_token.stages[%zu] is not an object", i); + if (!need_s(g, "kind", e) || need_i(g, "launches", 1, &gl, e) || need_i(g, "device_ns", 0, &gn, e)) return -1; + ssum += gn; lsum += gl; + } + if (ssum != sum) return rej(e, "derived stamped_token.stage_sum_ns = %" PRId64 " but the stages add up to %" PRId64, sum, ssum); + if (sum != span) return rej(e, "stamped_token.stage_sum_ns %" PRId64 " differs from span_ns %" PRId64 " (consecutive stamps must partition the span)", sum, span); + if (lsum != sl) return rej(e, "stamped_token stages count %" PRId64 " launches, launches = %" PRId64, lsum, sl); + int64_t gl; if (need_i(pt, "graph.launches", 1, &gl, e)) return -1; + if (gl != sl) return rej(e, "stamped_token.launches %" PRId64 " differs from per_token.graph.launches %" PRId64, sl, gl); + return 0; +} + +static int check_receipt(const JV *r, const char *evroot, Err *e) { + if (r->t != J_OBJ) return rej(e, "receipt is not a JSON object"); + for (size_t i = 0; i < r->n; i++) { + int ok = 0; + for (size_t j = 0; j < sizeof TOP_KEYS / sizeof TOP_KEYS[0]; j++) if (!strcmp(r->k[i], TOP_KEYS[j])) ok = 1; + if (!ok) return rej(e, "unknown top-level field %s", r->k[i]); + } + const char *schema = need_s(r, "schema", e); + if (!schema) return -1; + if (strcmp(schema, SCHEMA)) return rej(e, "schema \"%s\" is not \"" SCHEMA "\"", schema); + if (scan_placeholders(r, "receipt", e)) return -1; + const char *status = need_s(r, "status", e); + if (!status) return -1; + int known = 0; + for (size_t i = 0; i < sizeof STATUSES / sizeof STATUSES[0]; i++) if (!strcmp(status, STATUSES[i])) known = 1; + if (!known) return rej(e, "status \"%s\" is not one of VERIFIED EXPERIMENTAL HISTORICAL NOT_RUN FAIL SUPERSEDED", status); + if (!need_s(r, "status_note", e)) return -1; + const char *verdict = need_s(r, "run_verdict", e); + if (!verdict) return -1; + if (strcmp(verdict, "PASS") && strcmp(verdict, "FAIL") && strcmp(verdict, "NOT_RUN")) return rej(e, "run_verdict \"%s\" is not PASS, FAIL or NOT_RUN", verdict); + + /* source: commit-bound */ + if (!need(r, "source", J_OBJ, e) || !need_s(r, "source.repo", e) || need_hex(r, "source.commit", 40, e)) return -1; + const char *repo = need_s(r, "source.repo", e); + if (!strchr(repo, '/') || repo[0] == '/' || strchr(repo, ' ')) return rej(e, "source.repo \"%s\" is not OWNER/NAME", repo); + int dirty; if (need_b(r, "source.dirty", &dirty, e)) return -1; + + /* status rules */ + const int not_run = !strcmp(status, "NOT_RUN"); + if (not_run != !strcmp(verdict, "NOT_RUN")) return rej(e, "status NOT_RUN and run_verdict NOT_RUN go together (status %s, run_verdict %s)", status, verdict); + if (!strcmp(status, "VERIFIED") && dirty) return rej(e, "status VERIFIED with source.dirty true: a dirty tree cannot be verified"); + if ((!strcmp(status, "VERIFIED") || !strcmp(status, "EXPERIMENTAL")) && strcmp(verdict, "PASS")) return rej(e, "status %s needs run_verdict PASS (got %s)", status, verdict); + + /* workload, hardware, build */ + if (!need(r, "workload", J_OBJ, e) || !need_s(r, "workload.model", e) || !need_s(r, "workload.precision", e) || !need_s(r, "workload.mode", e) || + need_i(r, "workload.tokens", 1, NULL, e)) return -1; + if (!need(r, "hardware", J_OBJ, e) || !need_s(r, "hardware.host", e) || !need_s(r, "hardware.gpu", e)) return -1; + if (!need(r, "build", J_OBJ, e) || !need_s(r, "build.runner", e)) return -1; + + /* measurements: present for a run, absent (null) for NOT_RUN */ + const JV *pt = jget(r, "per_token"), *st = jget(r, "stamped_token"); + if (not_run) { + if (!need_s(r, "not_run_reason", e)) return -1; + if (!pt || pt->t != J_NULL || !st || st->t != J_NULL) return rej(e, "status NOT_RUN must carry per_token and stamped_token as null (nothing was measured)"); + } else { + if (jget(r, "not_run_reason")) return rej(e, "not_run_reason is only for status NOT_RUN"); + if (need_hex(r, "build.binary_sha256", 64, e) || need_hex(r, "build.library_sha256", 64, e)) return -1; + if (check_measurements(r, e)) return -1; + } + if (!need(r, "aggregate", J_OBJ, e)) return -1; + if (!need(r, "serial_vs_overlap", J_OBJ, e) || !need_s(r, "serial_vs_overlap.chip_ns", e) || !need_s(r, "serial_vs_overlap.stages", e) || + need_b(r, "serial_vs_overlap.overlap_measurable", NULL, e) || !need_s(r, "serial_vs_overlap.reason", e)) return -1; + if (!need(r, "methodology", J_OBJ, e) || !need_s(r, "methodology.device_clock", e) || !need_s(r, "methodology.host_clock", e) || + !need(r, "methodology.counters", J_OBJ, e)) return -1; + static const char *const CTR[] = { "launches", "submits", "chip_ns", "record_ns", "total_ns", "sems_done", "stamps" }; + for (size_t i = 0; i < sizeof CTR / sizeof CTR[0]; i++) { char p[64]; snprintf(p, sizeof p, "methodology.counters.%s", CTR[i]); if (!need_s(r, p, e)) return -1; } + if (need_str_list(r, "evidence", e) || need_str_list(r, "limitations", e)) return -1; + const JV *ev = jget(r, "evidence"); + for (size_t i = 0; i < ev->n; i++) { + const char *p = ev->v[i]->s; + if (p[0] == '/' || strstr(p, "..") || strstr(p, "//")) return rej(e, "evidence path \"%s\" must be repo-relative without '..'", p); + if (evroot) { + char *full = join(evroot, p); struct stat sb; int ok = stat(full, &sb) == 0; + free(full); + if (!ok) return rej(e, "evidence path \"%s\" does not exist under %s", p, evroot); + } + } + return 0; +} + +static int check_buffer(const char *buf, size_t n, const char *evroot, char *msg, size_t cap) { + JV *r = jparse(buf, n, msg, cap); + if (!r) return -1; + Err e = { msg, cap, 0 }; + int rc = check_receipt(r, evroot, &e); + jfree(r); + return rc; +} + +/* ------------------------------------------------------------------ generator inputs */ +typedef struct { + char started[64], ended[64], runner_mode[64], commit[64], branch[128], physics_commit[64]; + long dirty; + char host[128], kernel[128], gpu[128], driver[64]; +} Device; + +/* device.txt as tools/run_gpu_decode_graph_chip.sh writes it: "start mode=M omega=SHA branch=B dirty=N physics=P + * physics_commit=SHA", then uname -a, nvidia-smi name,driver (absent when no GPU answered), free -g, "end ..." */ +static int read_device(const char *path, Device *d, char *err, size_t cap) { + char *txt = read_file(path, NULL); + if (!txt) { snprintf(err, cap, "cannot read %s", path); return -1; } + memset(d, 0, sizeof *d); d->dirty = -1; + for (char *save = NULL, *line = strtok_r(txt, "\n", &save); line; line = strtok_r(NULL, "\n", &save)) { + if (!strncmp(line, "start ", 6)) { + char *s2 = NULL; int first = 1; + for (char *t = strtok_r(line + 6, " ", &s2); t; t = strtok_r(NULL, " ", &s2)) { + if (first) { snprintf(d->started, sizeof d->started, "%s", t); first = 0; continue; } + char *eq = strchr(t, '='); if (!eq) continue; *eq = 0; const char *v = eq + 1; + if (!strcmp(t, "mode")) snprintf(d->runner_mode, sizeof d->runner_mode, "%s", v); + else if (!strcmp(t, "omega")) snprintf(d->commit, sizeof d->commit, "%s", v); + else if (!strcmp(t, "branch")) snprintf(d->branch, sizeof d->branch, "%s", v); + else if (!strcmp(t, "dirty")) { char *end; d->dirty = strtol(v, &end, 10); if (*end || d->dirty < 0) d->dirty = -1; } + else if (!strcmp(t, "physics_commit")) snprintf(d->physics_commit, sizeof d->physics_commit, "%s", v); + } + } else if (!strncmp(line, "end ", 4)) { + char *sp = strchr(line + 4, ' '); if (sp) *sp = 0; + snprintf(d->ended, sizeof d->ended, "%s", line + 4); + } else if (!strncmp(line, "Linux ", 6)) { + char *s2 = NULL; strtok_r(line, " ", &s2); + char *h = strtok_r(NULL, " ", &s2), *k = strtok_r(NULL, " ", &s2); + if (h) snprintf(d->host, sizeof d->host, "%s", h); + if (k) snprintf(d->kernel, sizeof d->kernel, "%s", k); + } else if (!strncmp(line, "NVIDIA", 6) && !d->gpu[0]) { + char *c = strstr(line, ", "); + if (c) { *c = 0; snprintf(d->driver, sizeof d->driver, "%s", c + 2); } + snprintf(d->gpu, sizeof d->gpu, "%s", line); + } + } + free(txt); + if (!d->started[0] || !d->commit[0] || d->dirty < 0 || !d->host[0]) { snprintf(err, cap, "%s lacks the runner's start line (omega=, dirty=) or the uname line", path); return -1; } + if (!d->gpu[0]) { snprintf(d->gpu, sizeof d->gpu, "none_detected"); snprintf(d->driver, sizeof d->driver, "none_detected"); } + return 0; +} + +static int ends_with(const char *s, size_t n, const char *suf) { size_t m = strlen(suf); return n >= m && !memcmp(s + n - m, suf, m); } + +/* binaries.sha256: " ./build/gpu_decode_graph_test" and " build/libomega_gpu.a" */ +static int read_binaries(const char *path, char *bin, char *lib, char *err, size_t cap) { + char *txt = read_file(path, NULL); + if (!txt) { snprintf(err, cap, "cannot read %s", path); return -1; } + bin[0] = lib[0] = 0; + for (char *save = NULL, *line = strtok_r(txt, "\n", &save); line; line = strtok_r(NULL, "\n", &save)) { + char sha[65]; if (strlen(line) < 66) continue; + memcpy(sha, line, 64); sha[64] = 0; + const char *name = line + 64; while (*name == ' ' || *name == '*') name++; + if (!is_hex(sha, 64)) continue; + size_t nl = strlen(name); + if (ends_with(name, nl, "/gpu_decode_graph_test")) memcpy(bin, sha, 65); + else if (ends_with(name, nl, "/libomega_gpu.a")) memcpy(lib, sha, 65); + } + free(txt); + if (!bin[0] || !lib[0]) { snprintf(err, cap, "%s lacks the sha256 of gpu_decode_graph_test or libomega_gpu.a", path); return -1; } + return 0; +} + +typedef struct { int prefetch, red, fp8_variant, barrier, cached; char barrier_name[64]; } Knobs; +/* the test's first lines: "dgraph prefetch P (red R)" and "fp8 knobs: variant V barrier B (NAME) ... cached C" */ +static int read_knobs(const char *path, Knobs *k, char *err, size_t cap) { + char *txt = read_file(path, NULL); + if (!txt) { snprintf(err, cap, "cannot read %s", path); return -1; } + int have_pf = 0, have_fp8 = 0; + for (char *save = NULL, *line = strtok_r(txt, "\n", &save); line; line = strtok_r(NULL, "\n", &save)) { + if (!have_pf && sscanf(line, "dgraph prefetch %d (red %d)", &k->prefetch, &k->red) == 2) have_pf = 1; + else if (!have_fp8 && sscanf(line, "fp8 knobs: variant %d barrier %d (%63[^)])", &k->fp8_variant, &k->barrier, k->barrier_name) == 3) { + const char *c = strstr(line, " cached "); + if (c && sscanf(c, " cached %d", &k->cached) == 1) have_fp8 = 1; + } + } + free(txt); + if (!have_pf || !have_fp8) { + snprintf(err, cap, "%s lacks the \"dgraph prefetch\" or \"fp8 knobs\" line: the receipt needs the run's barrier and prefetch settings", path); + return -1; + } + return 0; +} + +static int sget(const JV *s, const char *path, int64_t *out, char *err, size_t cap) { + const JV *v = jpath(s, path); + if (!v || v->t != J_NUM || !v->is_int || v->i < 0) { snprintf(err, cap, "stats file: %s missing or not a non-negative integer", path); return -1; } + *out = v->i; return 0; +} + +/* ------------------------------------------------------------------ generator */ +typedef struct { + const char *run_dir, *stats, *log, *status, *repo, *model, *precision, *mode, *runner, *out; + const char *evidence[32]; int n_evidence; +} Args; + +static const char *STAMP_KINDS[] = { "norm", "qkv", "attn", "o_proj", "res_add", "router", "gate_up", "swiglu", "down", "combine_norm", "lm_head", "argmax" }; + +static int generate(const Args *a) { + char err[512]; + size_t sn; char *sbuf = read_file(a->stats, &sn); + if (!sbuf) { fprintf(stderr, "dgraph_receipt: cannot read %s\n", a->stats); return 2; } + JV *s = jparse(sbuf, sn, err, sizeof err); + free(sbuf); + if (!s) { fprintf(stderr, "dgraph_receipt: %s: %s\n", a->stats, err); return 2; } + char *dev_p = join(a->run_dir, "device.txt"), *bin_p = join(a->run_dir, "binaries.sha256"), *blog_p = join(a->run_dir, "build.log"); + Device d; Knobs k; memset(&k, 0, sizeof k); + char bin[65], lib[65]; + int rc = 2; + if (read_device(dev_p, &d, err, sizeof err) || read_binaries(bin_p, bin, lib, err, sizeof err) || read_knobs(a->log, &k, err, sizeof err)) goto fail; + + int64_t layers, vocab, pos, reps, red, cached, cl, cs, tl, span, tchip, mt, mc, mr, bt, bc, bl, bs, bid, checks, failed; + if (sget(s, "layers", &layers, err, sizeof err) || sget(s, "vocab", &vocab, err, sizeof err) || sget(s, "pos", &pos, err, sizeof err) || + sget(s, "reps", &reps, err, sizeof err) || sget(s, "red", &red, err, sizeof err) || sget(s, "cached_weights", &cached, err, sizeof err) || + sget(s, "C.launches", &cl, err, sizeof err) || sget(s, "C.submits", &cs, err, sizeof err) || + sget(s, "timeline.launches", &tl, err, sizeof err) || sget(s, "timeline.span_ns", &span, err, sizeof err) || sget(s, "timeline.chip_ns", &tchip, err, sizeof err) || + sget(s, "median_ns.C_total", &mt, err, sizeof err) || sget(s, "median_ns.C_chip", &mc, err, sizeof err) || sget(s, "median_ns.C_record", &mr, err, sizeof err) || + sget(s, "median_ns.B_total", &bt, err, sizeof err) || sget(s, "median_ns.B_chip", &bc, err, sizeof err) || + sget(s, "B.launches", &bl, err, sizeof err) || sget(s, "B.submits", &bs, err, sizeof err) || sget(s, "B.identical", &bid, err, sizeof err) || + sget(s, "checks", &checks, err, sizeof err) || sget(s, "failed", &failed, err, sizeof err)) goto fail; + const JV *verdict = jget(s, "verdict"), *pk = jpath(s, "timeline.per_kind_ns"); + if (!verdict || verdict->t != J_STR || (strcmp(verdict->s, "PASS") && strcmp(verdict->s, "FAIL"))) { snprintf(err, sizeof err, "stats file: verdict missing or not PASS/FAIL"); goto fail; } + if (!pk || pk->t != J_OBJ || pk->n == 0) { snprintf(err, sizeof err, "stats file: timeline.per_kind_ns missing or empty"); goto fail; } + if (cached != k.cached || red != k.red) { snprintf(err, sizeof err, "stats file and log disagree (cached %" PRId64 "/%d, red %" PRId64 "/%d): not the same run", cached, k.cached, red, k.red); goto fail; } + if (!strcmp(verdict->s, "PASS") && failed != 0) { snprintf(err, sizeof err, "stats file: verdict PASS with failed %" PRId64, failed); goto fail; } + for (size_t i = 0; i < pk->n; i++) { + const JV *e = pk->v[i]; + if (e->t != J_ARR || e->n != 2 || e->v[0]->t != J_NUM || !e->v[0]->is_int || e->v[1]->t != J_NUM || !e->v[1]->is_int || e->v[0]->i < 1 || e->v[1]->i < 0) { + snprintf(err, sizeof err, "stats file: timeline.per_kind_ns.%s is not [launches, ns]", pk->k[i]); goto fail; + } + int ok = 0; for (size_t j = 0; j < sizeof STAMP_KINDS / sizeof STAMP_KINDS[0]; j++) if (!strcmp(pk->k[i], STAMP_KINDS[j])) ok = 1; + if (!ok) { snprintf(err, sizeof err, "stats file: unknown stage kind %s", pk->k[i]); goto fail; } + } + + const int indep = k.prefetch ? (int)layers : 0; /* omega_gpu_decode_graph.c record_layer: one independent o_proj prefetch per layer */ + char *buf = NULL; size_t blen = 0; + FILE *mf = open_memstream(&buf, &blen); + if (!mf) { snprintf(err, sizeof err, "open_memstream failed"); goto fail; } + W w; memset(&w, 0, sizeof w); w.f = mf; w.first[0] = 1; + w.depth = 0; fputc('{', mf); w.depth = 1; w.first[1] = 1; + + kv_s(&w, "schema", SCHEMA); + kv_s(&w, "status", a->status); + if (!strcmp(a->status, "HISTORICAL")) + kv_fmt(&w, "status_note", "reproduced from an existing evidence run (%s, started %s) by tools/dgraph_receipt.c; the chip was not run to make this receipt", a->run_dir, d.started); + else + kv_fmt(&w, "status_note", "status %s set by the operator for the run in %s (started %s)", a->status, a->run_dir, d.started); + kv_s(&w, "run_verdict", verdict->s); + + w_open(&w, "source", '{'); + kv_s(&w, "repo", a->repo); kv_s(&w, "commit", d.commit); kv_b(&w, "dirty", d.dirty != 0); + kv_fmt(&w, "dirty_basis", "device.txt dirty=%ld (git status --porcelain line count at run start)", d.dirty); + if (d.branch[0]) kv_s(&w, "branch", d.branch); + if (d.physics_commit[0]) kv_s(&w, "physics_commit", d.physics_commit); + w_close(&w, '}'); + + w_open(&w, "run", '{'); + kv_s(&w, "started_utc", d.started); + if (d.ended[0]) kv_s(&w, "ended_utc", d.ended); + if (d.runner_mode[0]) kv_s(&w, "runner_mode", d.runner_mode); + kv_fmt(&w, "test_checks", "%" PRId64 " checks, %" PRId64 " failed", checks, failed); + w_close(&w, '}'); + + w_open(&w, "workload", '{'); + kv_s(&w, "model", a->model); kv_s(&w, "precision", a->precision); kv_s(&w, "mode", a->mode); + kv_i(&w, "tokens", reps); + kv_fmt(&w, "tokens_note", "%" PRId64 " timed graph tokens (the test's --reps), every one the same step at position %" PRId64 "; plus one stamped token", reps, pos); + kv_i(&w, "layers", layers); kv_i(&w, "vocab", vocab); kv_i(&w, "pos", pos); + kv_b(&w, "cached_weights", cached != 0); kv_b(&w, "prefetch", k.prefetch != 0); kv_b(&w, "red_mutant", red != 0); + kv_fmt(&w, "barrier", "%d (%s)", k.barrier, k.barrier_name); + kv_i(&w, "fp8_variant", k.fp8_variant); + w_close(&w, '}'); + + w_open(&w, "hardware", '{'); + kv_s(&w, "host", d.host); if (d.kernel[0]) kv_s(&w, "kernel", d.kernel); + kv_s(&w, "gpu", d.gpu); kv_s(&w, "driver", d.driver); + kv_s(&w, "basis", "device.txt: uname -a and nvidia-smi --query-gpu=name,driver_version at run start"); + w_close(&w, '}'); + + w_open(&w, "build", '{'); + kv_s(&w, "runner", a->runner); + kv_s(&w, "binary_sha256", bin); kv_s(&w, "library_sha256", lib); + { + size_t bn = 0; char *bl_txt = read_file(blog_p, &bn); + char *line = NULL; + if (bl_txt) for (char *save = NULL, *l = strtok_r(bl_txt, "\n", &save); l; l = strtok_r(NULL, "\n", &save)) if (strstr(l, "-o build/gpu_decode_graph_test ")) { line = l; break; } + if (line) kv_s(&w, "compile_command", line); + else kv_fmt(&w, "compile_command_note", "%s (%zu bytes) holds no compile line for build/gpu_decode_graph_test: make did not rebuild it in this run, so the flags are not recorded; the binary is identified by binary_sha256", blog_p, bn); + free(bl_txt); + } + w_close(&w, '}'); + + w_open(&w, "per_token", '{'); + kv_fmt(&w, "statistic", "median over %" PRId64 " tokens (sorted value at index n/2), each field's median taken on its own, so derived differences are differences of medians", reps); + kv_i(&w, "tokens", reps); + w_open(&w, "graph", '{'); + kv_i(&w, "launches", cl); kv_i(&w, "submits", cs); + kv_i(&w, "total_ns", mt); kv_i(&w, "chip_ns", mc); kv_i(&w, "record_ns", mr); kv_i(&w, "host_overhead_ns", mt - mc); + kv_null(&w, "sems_done"); + kv_s(&w, "sems_done_note", "not written by gpu_decode_graph_test; submit_now() in omega_gpu_decode_graph.c fails the token when sems_done != launches, so a PASS run implies sems_done == launches for every timed token (inferred, not a recorded value)"); + w_close(&w, '}'); + w_open(&w, "flush_each", '{'); + kv_i(&w, "launches", bl); kv_i(&w, "submits", bs); + kv_i(&w, "total_ns", bt); kv_i(&w, "chip_ns", bc); kv_i(&w, "host_overhead_ns", bt - bc); + kv_null(&w, "sems_done"); + kv_s(&w, "sems_done_note", "as for graph: not recorded, implied by the PASS verdict"); + kv_b(&w, "identical_to_graph", bid != 0); + kv_s(&w, "note", "the same recorded list submitted one launch per submission (TEST ONLY set_flush_each): the batching comparison inside the same run"); + w_close(&w, '}'); + w_close(&w, '}'); + + w_open(&w, "stamped_token", '{'); + int64_t ssum = 0; + for (size_t i = 0; i < pk->n; i++) ssum += pk->v[i]->v[1]->i; + kv_i(&w, "launches", tl); kv_i(&w, "span_ns", span); kv_i(&w, "chip_ns", tchip); + kv_i(&w, "unattributed_ns", tchip - span); kv_i(&w, "stage_sum_ns", ssum); + kv_s(&w, "note", "one extra token run with set_stamps(1): span_ns and stage times are device PTIMER differences; chip_ns is that token's host-clock submit span; unattributed_ns = chip_ns - span_ns (submit call, front-end start, completion marker and host poll)"); + w_open(&w, "stages", '['); + for (size_t i = 0; i < pk->n; i++) { + w_open(&w, NULL, '{'); + kv_s(&w, "kind", pk->k[i]); kv_i(&w, "launches", pk->v[i]->v[0]->i); kv_i(&w, "device_ns", pk->v[i]->v[1]->i); + w_close(&w, '}'); + } + w_close(&w, ']'); + w_close(&w, '}'); + + w_open(&w, "aggregate", '{'); + kv_b(&w, "available", 0); + kv_s(&w, "reason", "the input receipt carries per-token medians and one stamped token only, no per-token arrays or run totals, so no aggregate sums or percentiles are derived (adding them needs the test to write every token's stats)"); + w_close(&w, '}'); + + w_open(&w, "serial_vs_overlap", '{'); + kv_fmt(&w, "chip_ns", "serial: the sum over the token's submissions of one host-clock span each (%" PRId64 " submission per graph token, %" PRId64 " per flush_each token); spans never overlap each other", cs, bs); + if (indep) + kv_fmt(&w, "stages", "serial partition with %d independent launches: prefetch on, each layer's o_proj prefetch is marked independent (no barrier before it) and tagged attn, so its stamp is the front-end time while the attention may still run; the attn stage is the attention+prefetch window and the stages still add up to span_ns", indep); + else if (k.barrier == 1) + kv_s(&w, "stages", "barrier 1 (none, TEST ONLY): no WAIT_FOR_IDLE before the stamps, so a stage time is a front-end interval, not a launch duration"); + else + kv_fmt(&w, "stages", "serial partition: barrier %d (%s) puts a WAIT_FOR_IDLE before every stamp and prefetch is off, so launches run one after another and the stage times add up exactly to span_ns", k.barrier, k.barrier_name); + kv_b(&w, "overlap_measurable", 0); + kv_s(&w, "reason", indep + ? "an overlapped window is visible (the attn stage holds attention + prefetch), but no counter splits it, so how much of the two launches overlapped is not measurable from these counters" + : "every launch waits for the previous one (WFI) and the host records before it submits, so nothing overlaps to measure; device time inside the host span is span_ns, the rest is unattributed_ns"); + w_close(&w, '}'); + + w_open(&w, "methodology", '{'); + kv_s(&w, "device_clock", "GPU PTIMER ns from compute-class REPORT_SEMAPHORE timestamps (omega_gpu_cmdlist.h: \"out[0] = GPU timestamp (ns, PTIMER) before launch 0, out[i + 1] = after launch i completed (taken after its WAIT_FOR_IDLE)\"); used only by stamped_token span_ns and stages"); + kv_s(&w, "host_clock", "omega_gpu_session_now_ns(): the platform's time_now_ns, CLOCK_MONOTONIC on Linux (omega_gpu_platform_linux.c ref_now_ns); used by chip_ns, record_ns and total_ns"); + w_open(&w, "counters", '{'); + kv_s(&w, "launches", "omega_gpu_decode_graph.h: \"launches recorded for the token\""); + kv_s(&w, "submits", "omega_gpu_decode_graph.h: \"submissions (1 normally; = launches with flush_each)\""); + kv_s(&w, "chip_ns", "omega_gpu_decode_graph.h: \"sum of the list submissions' first-submit-to-last-marker time\". HOST clock, not device time: omega_gpu_cmdlist_submit() reads time_now_ns just before queue_submit and again after both completion marker words were seen and synced, so it holds device execution plus submit, fetch and poll latency"); + kv_s(&w, "record_ns", "omega_gpu_decode_graph.h: \"host: begin_token to the submit (recording)\""); + kv_s(&w, "total_ns", "omega_gpu_decode_graph.h: \"host: begin_token to end_token return\""); + kv_s(&w, "sems_done", "omega_gpu_decode_graph.h: \"launch semaphores found DONE\""); + kv_s(&w, "stamps", "omega_gpu_decode_graph.h: \"Launch i took stamps[i + 1] - stamps[i] ns\"; gpu_decode_graph_test sums them per kind (per_kind_ns)"); + kv_s(&w, "host_overhead_ns", "derived: total_ns - chip_ns, both host clock: recording, attention counter check, output sync, token read and lock, everything outside the submit span"); + w_close(&w, '}'); + kv_s(&w, "source", "numbers copied from the stats file written by tests/gpu_decode_graph_test.c --out; settings from its log; identity from the runner's device.txt and binaries.sha256"); + w_close(&w, '}'); + + w_open(&w, "evidence", '['); + w_key(&w, NULL); w_str(&w, a->stats); + w_key(&w, NULL); w_str(&w, a->log); + w_key(&w, NULL); w_str(&w, dev_p); + w_key(&w, NULL); w_str(&w, bin_p); + w_key(&w, NULL); w_str(&w, blog_p); + for (int i = 0; i < a->n_evidence; i++) { w_key(&w, NULL); w_str(&w, a->evidence[i]); } + w_close(&w, ']'); + + w_open(&w, "limitations", '['); + static const char *const LIM[] = { + "chip_ns is host-clock time around the device work; the only device-clock numbers are the stamped token's span_ns and stages", + "per-token values are independent medians of a synthetic step on random weights (Qwen3-30B-A3B shapes, not a checkpoint), one fixed position, the same token every rep; not a serving or end-to-end tokens-per-second figure", + "the stamped token is a single token: its stage times are one sample, not a distribution", + "sems_done, the command list's own host_ns (method-stream build) and the marker-wait part of chip_ns are not recorded per token", + "no aggregate totals or percentiles: the input has medians only", + "this receipt is not a qualification: it re-expresses an existing run and claims nothing beyond that run's files", + }; + for (size_t i = 0; i < sizeof LIM / sizeof LIM[0]; i++) { w_key(&w, NULL); w_str(&w, LIM[i]); } + if (d.dirty) { w_key(&w, NULL); w_str(&w, "the run's tree was dirty: the commit alone does not reproduce the binary; see worktree.diff in the run directory when present"); } + w_close(&w, ']'); + + w_close(&w, '}'); + fputc('\n', mf); + if (fclose(mf) != 0) { snprintf(err, sizeof err, "writing the receipt failed"); free(buf); goto fail; } + + if (check_buffer(buf, blen, NULL, err, sizeof err)) { + fprintf(stderr, "dgraph_receipt: refusing to write: the receipt fails its own check: %s\n", err); + free(buf); rc = 1; goto out; + } + FILE *o = a->out ? fopen(a->out, "wb") : stdout; + if (!o) { fprintf(stderr, "dgraph_receipt: cannot write %s\n", a->out); free(buf); goto out; } + int wbad = fwrite(buf, 1, blen, o) != blen; + if (a->out) wbad |= fclose(o) != 0; else wbad |= fflush(o) != 0; + free(buf); + if (wbad) { fprintf(stderr, "dgraph_receipt: write failed\n"); goto out; } + rc = 0; + goto out; +fail: + fprintf(stderr, "dgraph_receipt: %s\n", err); +out: + jfree(s); free(dev_p); free(bin_p); free(blog_p); + return rc; +} + +static int usage(void) { + fputs("usage: dgraph_receipt --run-dir DIR --stats FILE --log FILE --status STATUS --repo OWNER/NAME --model TEXT\n" + " --precision TEXT --mode TEXT --runner TEXT [--evidence PATH]... [--out FILE]\n" + " dgraph_receipt --check FILE [--evidence-root DIR]\n", stderr); + return 2; +} + +int main(int argc, char **argv) { + Args a; memset(&a, 0, sizeof a); + const char *check = NULL, *evroot = NULL; + for (int i = 1; i < argc; i++) { + const char *o = argv[i], *v = i + 1 < argc ? argv[i + 1] : NULL; + const char **slot = NULL; + if (!strcmp(o, "--check")) slot = ✓ + else if (!strcmp(o, "--evidence-root")) slot = &evroot; + else if (!strcmp(o, "--run-dir")) slot = &a.run_dir; + else if (!strcmp(o, "--stats")) slot = &a.stats; + else if (!strcmp(o, "--log")) slot = &a.log; + else if (!strcmp(o, "--status")) slot = &a.status; + else if (!strcmp(o, "--repo")) slot = &a.repo; + else if (!strcmp(o, "--model")) slot = &a.model; + else if (!strcmp(o, "--precision")) slot = &a.precision; + else if (!strcmp(o, "--mode")) slot = &a.mode; + else if (!strcmp(o, "--runner")) slot = &a.runner; + else if (!strcmp(o, "--out")) slot = &a.out; + else if (!strcmp(o, "--evidence")) { + if (!v || a.n_evidence == (int)(sizeof a.evidence / sizeof a.evidence[0])) return usage(); + a.evidence[a.n_evidence++] = v; i++; continue; + } else return usage(); + if (!v || *slot) return usage(); + *slot = v; i++; + } + if (check) { + if (a.run_dir || a.stats || a.log || a.status || a.repo || a.model || a.precision || a.mode || a.runner || a.out || a.n_evidence) return usage(); + size_t n; char *buf = read_file(check, &n); + if (!buf) { fprintf(stderr, "dgraph_receipt: cannot read %s\n", check); return 2; } + char msg[512]; + int rc = check_buffer(buf, n, evroot, msg, sizeof msg); + free(buf); + if (rc) { printf("dgraph_receipt: REJECT %s: %s\n", check, msg); return 1; } + printf("dgraph_receipt: OK %s\n", check); + return 0; + } + if (evroot || !a.run_dir || !a.stats || !a.log || !a.status || !a.repo || !a.model || !a.precision || !a.mode || !a.runner) return usage(); + return generate(&a); +} 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 dc09955ea..684078c4b 100755 --- a/tools/run_gpu_bf16_gemv_chip.sh +++ b/tools/run_gpu_bf16_gemv_chip.sh @@ -11,6 +11,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 fd9b6ced7..8b742d495 100755 --- a/tools/run_gpu_cmdlist_chip.sh +++ b/tools/run_gpu_cmdlist_chip.sh @@ -9,6 +9,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 efd644008..2ed7fcef0 100755 --- a/tools/run_gpu_decode_attn_chip.sh +++ b/tools/run_gpu_decode_attn_chip.sh @@ -13,6 +13,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 6b7955bfd..0987e639c 100755 --- a/tools/run_gpu_decode_graph_chip.sh +++ b/tools/run_gpu_decode_graph_chip.sh @@ -11,6 +11,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 98d5ab8ca..4cb0c076b 100755 --- a/tools/run_gpu_fp8_chip.sh +++ b/tools/run_gpu_fp8_chip.sh @@ -12,6 +12,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 496faf5d0..a56304c0e 100755 --- a/tools/run_gpu_fp8_v2_chip.sh +++ b/tools/run_gpu_fp8_v2_chip.sh @@ -10,6 +10,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 1ff2a9d89..a3cb8b242 100755 --- a/tools/run_gpu_fp8gemm_chip.sh +++ b/tools/run_gpu_fp8gemm_chip.sh @@ -12,6 +12,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 6f2c9a52f..463b6a5b6 100755 --- a/tools/run_gpu_l2_stale_chip.sh +++ b/tools/run_gpu_l2_stale_chip.sh @@ -10,6 +10,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 600efae0f..bf92b1edd 100755 --- a/tools/run_gpu_l2d_barrier_chip.sh +++ b/tools/run_gpu_l2d_barrier_chip.sh @@ -8,6 +8,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 67828b21e..e0d3f43af 100755 --- a/tools/run_gpu_l2d_prefetch_chip.sh +++ b/tools/run_gpu_l2d_prefetch_chip.sh @@ -7,6 +7,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 309db8eea..a82b52fbe 100755 --- a/tools/run_gpu_prefill_attn_chip.sh +++ b/tools/run_gpu_prefill_attn_chip.sh @@ -16,6 +16,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 7b7e6770e..8eb998f29 100755 --- a/tools/run_gpu_router_chip.sh +++ b/tools/run_gpu_router_chip.sh @@ -14,6 +14,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 5431204ce..35245cacb 100755 --- a/tools/run_gpu_tcgemm_chip.sh +++ b/tools/run_gpu_tcgemm_chip.sh @@ -6,6 +6,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 391c02ac2..9e2a5ef4d 100755 --- a/tools/run_gpu_tern_chip.sh +++ b/tools/run_gpu_tern_chip.sh @@ -16,6 +16,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_gpu_tgemm_chip.sh b/tools/run_gpu_tgemm_chip.sh new file mode 100755 index 000000000..47b8a52a6 --- /dev/null +++ b/tools/run_gpu_tgemm_chip.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# run_gpu_tgemm_chip.sh EVIDENCE_DIR [PHYSICS_DIR] +# Trainer lane E1 chip gate for the device-resident bf16 training GEMM (omega_gpu_tgemm_api.h, cut 1: NN, F32 overwrite). +# Caller holds the GB10 quiet lock: quietlock run -- tools/run_gpu_tgemm_chip.sh EVID +# 0. host proofs first (never hardware results): --host-only (instruction / register budgets) and --sim (bit-identical to the +# HMMA-chain emulation in both fragment orders, tile K ranges, mutants 1-4 caught) +# 1. yardstick: tests/gpu_tc_peak_test (HMMA.16816.F32.BF16 dense throughput ceiling); the best "peak ..." line's TFLOPS is the +# 100% every percentage below is measured against +# 2. gate: 8192x768x{2304,768,3072} and 8192x3072x768, uncached then GPU-cached buffers: every output within 1e-5 of the +# double reference, repeats bit-identical, poison scan clean, mutants 1 and 4 caught, chip-time TFLOPS >= 25% of the yardstick +# 3. informational, one variable per run: 8192x2304x768, 1024x768x50304 (the lm_head gradient's K; n 768 keeps the default +# rt 8 x 16 warps), 1024x50304x768 (the lm_head forward width: n % 256 != 0 takes the rt 4 x 8 warps path), the gate +# shape forced to rt 4 x 8 warps and to rt 2 x 8 warps +# Verdict line last: "GPU_TGEMM_CHIP: PASS|FAIL". Steps 0 to 2 decide. +set -u +EVID="${1:?evidence dir}"; PHYS="${2:-$HOME/workspace/physics-own30b-k}" +HERE="$(cd "$(dirname "$0")/.." && pwd)" +cd "$HERE" || exit 2 +DIRTY=$(git status --porcelain | wc -l) # before the evidence folder exists (it would count as untracked) +mkdir -p "$EVID" +{ + echo "start $(date -u +%FT%TZ) omega=$(git rev-parse HEAD) branch=$(git rev-parse --abbrev-ref HEAD) dirty=$DIRTY physics=$PHYS physics_commit=$(git -C "$PHYS" rev-parse HEAD)" + uname -a; nvidia-smi --query-gpu=name,driver_version,clocks.sm,clocks.max.sm,temperature.gpu --format=csv,noheader 2>/dev/null; free -g | head -2 +} > "$EVID/device.txt" +make PHYSICS_DIR="$PHYS" -j10 build/gpu_tgemm_test build/gpu_tc_peak_test > "$EVID/build.log" 2>&1 || { echo "GPU_TGEMM_CHIP: FAIL build"; exit 1; } +T=./build/gpu_tgemm_test; fail=0 +$T --host-only 2>&1 | tee "$EVID/host-only.log"; [ "${PIPESTATUS[0]}" = 0 ] || fail=1 +$T --sim 2>&1 | tee "$EVID/sim.log"; [ "${PIPESTATUS[0]}" = 0 ] || fail=1 +timeout 300 ./build/gpu_tc_peak_test --chip 2>&1 | tee "$EVID/peak.log"; [ "${PIPESTATUS[0]}" = 0 ] || fail=1 +PEAK=$(grep '^peak ' "$EVID/peak.log" | sed 's/.*us, \([0-9.]*\) TFLOPS.*/\1/' | sort -g | tail -1) +echo "yardstick: bf16 HMMA dense peak $PEAK TFLOPS (best 'peak' line of peak.log)" | tee "$EVID/yardstick.txt" +if [ -z "$PEAK" ]; then echo "GPU_TGEMM_CHIP: FAIL no yardstick"; exit 1; fi +$T --chip --reps 15 --gate 25 --peak "$PEAK" 2>&1 | tee "$EVID/main.log"; [ "${PIPESTATUS[0]}" = 0 ] || fail=1 +for v in "--shape 8192x2304x768:n2304" "--shape 1024x768x50304:k50304" "--shape 1024x50304x768:n50304" "--shape 8192x768x2304 --shape-knob 4 8 1:warps8" "--shape 8192x768x2304 --shape-knob 2 8 1:rt2"; do + a="${v%%:*}"; n="${v##*:}" + $T --chip --reps 9 --peak "$PEAK" $a 2>&1 | tee "$EVID/$n.log"; echo "$a exit ${PIPESTATUS[0]} (informational)" | tee -a "$EVID/$n.log" +done +echo "end $(date -u +%FT%TZ)" >> "$EVID/device.txt" +(cd "$EVID" && sha256sum *.log *.txt > SHA256SUMS) +if [ $fail = 0 ]; then echo "GPU_TGEMM_CHIP: PASS" | tee -a "$EVID/main.log"; else echo "GPU_TGEMM_CHIP: FAIL" | tee -a "$EVID/main.log"; exit 1; fi diff --git a/tools/run_l1g_chip.sh b/tools/run_l1g_chip.sh index b728f1a12..eb6ef698d 100755 --- a/tools/run_l1g_chip.sh +++ b/tools/run_l1g_chip.sh @@ -7,6 +7,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 7ca1e6402..32e7aad2d 100755 --- a/tools/run_t3_baseline_chip.sh +++ b/tools/run_t3_baseline_chip.sh @@ -6,6 +6,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 {