Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
About Files History Releases Proposed changes Issues For developers
gpu: decode attention head_dim 256 for Qwen3.8-27B (#544)
merged 0e9f07f0c4d3b40f #550 · opened 2026-10-18 13:06 UTC · closed 2026-10-24 17:56 UTC · merged 2026-10-24 17:56 UTC
Imported from GitHub aien-dev/omega-mv#550, by drakestapleton
Base 03d975f7e17e915fd3a52a21c0e7b9be7bc13192 · Head 7bda76611e606b4d2b2f0336b2d2dda56dd950a0
Merged on GitHub as 2ef40a1538c6cf85b39fc511da35cb85f13c5649 ; reachable from main c7acd2607139eedfabeac16b6042cefe8ede431f (observed 2026-11-18T16:35:57Z)
drakestapleton wrote on 2026-10-18 13:06 UTC
Closes omega-mv#544. Stacked on #549 (feat/gdn-prefill); the base must merge first. Do not merge: merges are paused.
What
Decode attention for Qwen3.8-27B's 16 full-attention layers in one launch per layer: 24 query heads over 4 KV heads, head_dim 256, per-head zero-centred RMSNorm on q and k (weights folded to 1 + w by the caller), partial RoPE on the first 64 dims, the new token's K/V appended to the GPU-resident bf16 cache inside the kernel, split-K across CTAs with the last CTA combining. New files only; the 30B's head_dim 128 kernel is untouched (its host and simulator tests still pass).
src/omega_blackwell_codegen_attn256.{h,c}: the kernel. 897 instructions, 108 registers at depth 4, 14896 bytes shared (under the 16 KiB QMD cap). One norm + rope block serves all 8 warps (warps 0..5 build q', warp 6 k_new, warp 7 reloads the raw v); V pass is split by warp pair over the two dim halves.
Partial RoPE by permutation (design decision 1): the engine permutes q, k and the norm weights at load with omega_dattn256_perm_vec so the kernel's standard rotate-half over 256 applies the model's rotate-half within the first 64 dims; the table rotates the first 32 pairs and leaves the rest identity. The permutation is shared by engine and tests and checked against the unpermuted double reference.
src/omega_gpu_decode_attn256_api.{h,c}: cache up to 131072 positions per layer (512 MiB), rope table, norms, partials, launch, record path, cache view for the prefill.
tests/gpu_decode_attn256_test.c: host-only (rope rows, permutation bijection, reference sanity, codegen budget per depth and mutant, refusals), simulator (9 contexts incl. rotary 256, 2 chunks per CTA, mutants 1-5), chip (parity at contexts 1..131072, rows read back, second call identical, out_scale 2^64, mutants 1-5 at context 301, timings).
tools/run_gpu_decode_attn256_chip.sh: the gate.
Chip receipt
evidence/QWEN38-DATTN256-8bb4494e -20261018 / (SHA256SUMS inside), GPU_DECODE_ATTN256_CHIP: PASS:
main 30/30; max-pos 131072 4/4; no-evict 30/30; depth 1 30/30; per-split 1024 29/29.
context 32768: 2.10 ms median per layer, 63.8 GB/s on the 134 MB of K+V streamed (273 GB/s nominal ceiling).
context 131072: 8.69 ms, 61.8 GB/s on 537 MB.
context 8192: 620 us, 54.1 GB/s; context 1024: 144 us.
all five mutants caught at context 301 (bad 899..5666 of 6144 outputs).
Host and simulator passes are never chip results; the verdict is the chip log.
🤖 Generated with Claude Code
Fetch it
A git bundle of the pull request's head, 45684 bytes.
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/0e9f07f0c4d3b40f .bundle -o 0e9f07f0c4d3b40f .bundle
git fetch 0e9f07f0c4d3b40f .bundle refs/pull/550/head
Raw bundle · Diff
Provenance
This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:
github-import 1
aien-dev/omega-mv
550
7bda76611e606b4d2b2f0336b2d2dda56dd950a0
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":550,"url":"https://github.com/aien-dev/omega-mv/pull/550","export_sha256":"7319147b350ad908bf0b731068ec3be7b8dee848041dc862f71455e8e4680140 ","imported_utc":"2026-11-18T16:35:57Z"}
Changes
diff --git a/.crumb b/.crumb
index fcab4771b ..4787696e0 100644
--- a/.crumb
+++ b/.crumb
@@ -77,33 +77,33 @@
"purpose": "Directory spec. Purpose not yet described by a human."
},
{
- "digest": "cceb4d16f88ad5ae07eec048bcfbc84bfe1e011f05d9ead33957479fd6dd23bd ",
- "last_commit": "c480683e ",
+ "digest": "088de32c7f661acdf7e4c352240dd318dc4d01f510983bc90971ac39e23ca9be ",
+ "last_commit": "d146cbde ",
"name": "src",
"purpose": "Directory src. Purpose not yet described by a human."
},
{
- "digest": "edf167b3607974785ec9cb7478d8d26d562cb5c83107322efa79954482d34c39 ",
- "last_commit": "c480683e ",
+ "digest": "6947682ecc9b0f6e6704ae8d7ba4121075d6b219d6317b17acf7fe7b412f3892 ",
+ "last_commit": "d146cbde ",
"name": "tests",
"purpose": "Directory tests. Purpose not yet described by a human."
},
{
- "digest": "566a123ba248da906e3c42430b73decd7c3ec030a4fd26c909d265aa9bf67db9 ",
- "last_commit": "88e24bdd ",
+ "digest": "db3d0e54d63e2ca868e85392d6b71a612b2a49ff95948f9e1f13b1e7072f46e8 ",
+ "last_commit": "d146cbde ",
"name": "tools",
"purpose": "Directory tools. Purpose not yet described by a human."
}
],
- "children_root": "sha256:90a116089dcc944c5cf4999fa010ba497d8d4f377d9ab94dac3d9beab35975a1 ",
- "compiled_at": "2026-10-18T13:02:58Z",
+ "children_root": "sha256:8fe11fe2763ac2e0ccc34bad971867e59b4d2ef6129835906a07f8e5c9d97a04 ",
+ "compiled_at": "2026-10-18T13:07:31Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:e4cc6c5c8876c6c15fccdccb65f48f52ef393c5e9ba1d3cc1eda1aa5de33af70 ",
- "evidence_files": 11170,
- "evidence_root": "sha256:d84334b20a3fd68396eb9a7fc57b8173504a9f62737374661ea71f1ecea5998c ",
- "files": 14157,
- "generated_at_commit": "e7356996557da557d63de0f56558a335b5c25223 ",
- "source_tree": "sha256:045fc88fe0ffb89013c1c839de6438147f6561bde91be68251300db18489e1a8 "
+ "digest": "sha256:9851fb41a577aac6cbabc967fe2ee03883fd3ac15bfb90a1d54df7797b035604 ",
+ "evidence_files": 11188,
+ "evidence_root": "sha256:56b420a42f7e56c28eff90264946fa81efd40deb372e4b3a1c0ec7563c0182d7 ",
+ "files": 14181,
+ "generated_at_commit": "806336b0d63812e6821cb090087cabdc88fd75af ",
+ "source_tree": "sha256:58da3511c25bc84e05a5530afb7bc5b2419f61925d27ef26172f86d531ab3125 "
},
"owner_lane": "",
"provenance": {
diff --git a/Makefile b/Makefile
index 94ed0d8ea ..bc0ef2aa2 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,8 @@ SRCS += src/omega_blackwell_codegen_moe.c src/omega_gpu_fp8_pack.c src/omega_gpu
SRCS += src/omega_blackwell_codegen_moe2.c
# OWN-30B cut 8 (2026-10-13): one-launch decode attention (omega_gpu_decode_attn_api.h), new files only
SRCS += src/omega_blackwell_codegen_attn.c src/omega_gpu_decode_attn_api.c
+# Qwen3.8-27B (omega-mv#544, 2026-10-18): decode attention head_dim 256, new files only
+SRCS += src/omega_blackwell_codegen_attn256.c src/omega_gpu_decode_attn256_api.c
# OWN-30B (2026-10-13): libm-free host math (omega_gpu_hostmath.h) so libomega_gpu.a links without -lm
SRCS += src/omega_gpu_hostmath.c
# OWN-30B cut 8 item 2 (2026-10-13): one-launch MoE router (omega_gpu_router_api.h), new files only
@@ -2490,6 +2492,17 @@ test-gpu-decode-attn: $(GPU_DATTN_TEST)
$(GPU_DATTN_TEST) --host-only
$(GPU_DATTN_TEST) --sim
+# Qwen3.8-27B (omega-mv#544, 2026-10-18): decode attention head_dim 256, 24 q / 4 kv heads, partial RoPE by permutation
+# (omega_gpu_decode_attn256_api.h). test-gpu-decode-attn256 is host-only + simulator; the chip gate is
+# tools/run_gpu_decode_attn256_chip.sh.
+.PHONY: test-gpu-decode-attn256
+GPU_DATTN256_TEST = $(OUT_DIR)/gpu_decode_attn256_test
+$(GPU_DATTN256_TEST): tests/gpu_decode_attn256_test.c tests/bw_warp_sim_k.h src/omega_gpu_decode_attn256_api.h src/omega_blackwell_codegen_attn256.h $(OUT_DIR)/libomega_gpu.a
+ $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_decode_attn256_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
+test-gpu-decode-attn256: $(GPU_DATTN256_TEST)
+ $(GPU_DATTN256_TEST) --host-only
+ $(GPU_DATTN256_TEST) --sim
+
# OWN-30B cut 8 item 2 (2026-10-13): one-launch MoE router (omega_gpu_router_api.h). test-gpu-router is host-only
# (oracle, budgets) plus the warp simulator; the chip gate is tools/run_gpu_router_chip.sh under the GB10 lock.
.PHONY: test-gpu-router
diff --git a/README.md b/README.md
index 3de0ed37b ..3afd93acd 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Research-grade and pre-alpha. Plainly:
- **Omega Systems Core compiler:** OSC-0 is frozen as a design. OSC-1 and OSC-2 are implemented with host receipts and are NOT QUALIFIED. OSC-3 is in progress ([OSC-3-DESIGN](docs/osc/OSC-3-DESIGN.md)). It is not self-hosting and there is no general Omega compiler yet; the old Milestone 6 "self-host" result was a fixed-output self-copy check, not compilation ([note](docs/osc/OSC-1-SELF-HOST-STATEMENT.md)).
- **Reaction runtime:** the R1 to R16 qualification ladder passed on builds that predate the composition modules (omega#126), a historical result. Requalification at `3108fc2 ` recorded R15 FAIL (14 of 16 gates: G1, G15) and R16 FAIL (`evidence/REQUAL-3108fc2 /`); the R16 receipt `22d7a79a ` at `850fc54 ` is invalid as a current claim because its script was later found defective; none of R1 to R16 is requalified on the current candidate, and the ladder rerun is in progress. The R16 loop-site inventory was reconciled on the candidate tree (502 sites, 0 unclassified, 0 stale, PR #279); that is the inventory gate only, not R16. The current living build is IMPLEMENTED / NOT QUALIFIED until re-qualified. Composition, Capability Graph, Skill Router, J-Space and Cortex run on the host; the Fabric interface is a host-only loopback with no network; none of this is on silicon as a qualified system.
- **Numerics (E1):** closed 2026-10-02 on the GB10 chip campaign (Gate 5 26/26 with 47 parity lines, reductions SUM/MAX/MIN/MEAN, nine transcendental ops over all 2^32 inputs each, 148 load/store kernels), consolidated receipt `evidence/E1-CLOSURE/e7851c69d34ac777a9436af16d0bdd5d69264c8528c62d562b600f5d89153061 .json`; exclusions (natural-base EXP/LOG have no GB10 kernel) are listed in [E1_GAP_TABLE](docs/numeric/E1_GAP_TABLE.md).
-- **Qwen3.8-27B kernels (GB10, 2026-10-18):** each one is checked on the chip against a double-precision reference with deliberately broken variants that must fail, and none is joined into a serving engine yet. FP8 matrix-vector and the tensor-core prefill GEMM now take k up to 32768, which covers the 27B down projection at k = 17408 (`evidence/fp8-k32768-20261018 /`, omega#541). The Gated DeltaNet decode step (the recurrent layer used by 48 of the 64 layers) runs as one launch per layer and matches the reference to about 2e-7; it takes 125.7 us per layer, which moves its 6.29 MB of state at 50.1 GB/s against 273 GB/s nominal (`evidence/gdn-decode-20261018 /`, omega#542). The DeltaNet prefill reads a whole prompt in three launches per layer and hands its state to the decode step, which carries on exactly; at 2048 tokens it takes 3.80 us per token per layer, and the recurrent scan in it does about 2.4 trillion operations a second, against a chip peak for that kind of math that has not been measured yet (`evidence/gdn-prefill-20261018 /`, omega#543).
+- **Qwen3.8-27B kernels (GB10, 2026-10-18):** each one is checked on the chip against a double-precision reference with deliberately broken variants that must fail, and none is joined into a serving engine yet. FP8 matrix-vector and the tensor-core prefill GEMM now take k up to 32768, which covers the 27B down projection at k = 17408 (`evidence/fp8-k32768-20261018 /`, omega#541). The Gated DeltaNet decode step (the recurrent layer used by 48 of the 64 layers) runs as one launch per layer and matches the reference to about 2e-7; it takes 125.7 us per layer, which moves its 6.29 MB of state at 50.1 GB/s against 273 GB/s nominal (`evidence/gdn-decode-20261018 /`, omega#542). The DeltaNet prefill reads a whole prompt in three launches per layer and hands its state to the decode step, which carries on exactly; at 2048 tokens it takes 3.80 us per token per layer, and the recurrent scan in it does about 2.4 trillion operations a second, against a chip peak for that kind of math that has not been measured yet (`evidence/gdn-prefill-20261018 /`, omega#543). The full-attention decode step for the other 16 layers (24 query heads over 4 key-value heads, 256 numbers per head, rotation on the first 64 only, done by reordering the numbers once at load) runs as one launch per layer, matches the reference at each tested context (1, 7, 256, 301, 1024, 4096, 8192, 32768 and 131072 tokens) with all five broken variants caught, and at 32768 tokens of context takes 2.10 ms per layer, streaming its 134 MB of cached keys and values at 63.8 GB/s against 273 GB/s nominal (`evidence/QWEN38-DATTN256-8bb4494e -20261018 /`, omega#544).
- **Hardware:** results on the DGX Spark GB10 are tied to the exact commit in each receipt. Host and emulator passes are never reported as hardware qualification.
The live status is owned by [aien-architecture](https://github.com/aien-spark/aien-architecture): [CURRENT_EXECUTION_PLAN.md](https://github.com/aien-spark/aien-architecture/blob/main/CURRENT_EXECUTION_PLAN.md) and [doctrine/ROADMAP.md](https://github.com/aien-spark/aien-architecture/blob/main/doctrine/ROADMAP.md). This file does not restate numbers that drift. Historical milestone receipts (for example Milestone 4, `OMEGA_SEMANTICS`, 12 of 12 gates) stay in `evidence/` unchanged as history.
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /SHA256SUMS b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /SHA256SUMS
new file mode 100644
index 000000000 ..08369a0d3
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /SHA256SUMS
@@ -0,0 +1,17 @@
+11edee77d492127475a53008771395477496a9c5956fe58eb5ff602337cfd6f4 receipt-baseline-matmul.json
+ced0b3b9adbad3b9ed826035cb51e52b1cbb21bc0ad37be22a77ee78d3bee947 receipt-depth1.json
+ba3f4653bd1d7251cb59c6d461dd789d514845dadda3c8e4923477f8e24bed4d receipt-main.json
+2c9947f7cc0ffd0ee72ae1b2da5b3a60cb77c930b20d22f4ce52091585c10d38 receipt-maxpos131072.json
+11cb4785bd9e2f51d1b3c862d8529a2b2fe5439de8187a624ded0c21057a4e9f receipt-noevict.json
+adc063beebb1a98ec748ab67dbe205f8194356e7129cf27fdf96684148b69b6a receipt-persplit1024.json
+9c14ffb5fafee48f0ffe0ecb723ec2eb27f6cec371d46ccb4ca1cc7fef534f04 baseline-matmul.log
+9299283f6a93f7ab1f548b05e42c1ddb693c6fc3ebd54b61f92f7bfd5a11d4e3 build.log
+9c43aeaa9abedec87a68706c954c49f1ebcd640b95488a6de0c27a2e599f460a depth1.log
+c30a35ae85b7af63e7a9def6e61bdc27a9b3533563f0e344641e85bf0d276e7f host-only.log
+f74b53a98eb15dd06a1047fd0f62a75920a82d4aba27a9292cc44ad6756661dd main.log
+1bd9e9d603470e9b4e5f8fe434ef3694d5c2649115eda6d5ada35b12768bf784 maxpos131072.log
+d6ccf81876a786436dc28339ca6f49509a51047335548fee616604da6c5f9978 noevict.log
+e41a28dd857dc1b598a57889b8130f0b5e126da96f625cc827843202a4e3e1d5 persplit1024.log
+9cd5f61596d1fc83d630df3a2456044b0da8d26d1af9ca761c0c3b7a87ea4880 run.log
+be31705118ebd04682f09134ae7443a0debcd370af65baeac2ad54738dbfefce sim.log
+219404de4951ea6723d662f281a9cde12e74da751abe28244f8e5553e77f4dfe device.txt
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /baseline-matmul.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /baseline-matmul.log
new file mode 100644
index 000000000 ..ee0f20f69
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /baseline-matmul.log
@@ -0,0 +1,4 @@
+PASS timing 1x2048x8192 upload_ms=149.1 ok_calls=100 median_ms=0.209 p90_ms=0.212 min_ms=0.169 max_ms=3.471 chip_ns_mean=252944 grid=1024x1 e2e_first=2.36603e-07 e2e_last=2.36603e-07 repeat_mismatch=0
+PASS timing 1x8192x2048 upload_ms=106.3 ok_calls=100 median_ms=0.210 p90_ms=0.311 min_ms=0.202 max_ms=3.161 chip_ns_mean=258955 grid=256x1 e2e_first=5.21488e-07 e2e_last=5.21488e-07 repeat_mismatch=0
+PASS: 4 checks, 0 failed
+baseline exit 0 (recorded)
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /build.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /build.log
new file mode 100644
index 000000000 ..edf91d1fc
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /build.log
@@ -0,0 +1 @@
+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 -o build/gpu_matmul_api_test tests/gpu_matmul_api_test.c build/libomega_gpu.a -lpthread -lm
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /depth1.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /depth1.log
new file mode 100644
index 000000000 ..62f9cd2ca
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /depth1.log
@@ -0,0 +1,16 @@
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 177.4 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=1 kv_bytes=4096 fill=0.0ms chip_med=49.0us (0.1 GB/s) call_med=51.6us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=1 kv_bytes=28672 fill=0.0ms chip_med=56.4us (0.5 GB/s) call_med=59.2us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=1 kv_bytes=1048576 fill=0.1ms chip_med=107.4us (9.8 GB/s) call_med=110.2us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=2x4 per_split=256 depth=1 kv_bytes=1232896 fill=0.1ms chip_med=122.5us (10.1 GB/s) call_med=125.6us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: caught (rc=OK bad=2752 worst=30.582)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2937 worst=78.730)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=256 depth=1 kv_bytes=4194304 fill=0.4ms chip_med=148.7us (28.2 GB/s) call_med=151.5us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=16x4 per_split=256 depth=1 kv_bytes=16777216 fill=1.3ms chip_med=312.8us (53.6 GB/s) call_med=315.7us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=256 depth=1 kv_bytes=33554432 fill=1.8ms chip_med=591.1us (56.8 GB/s) call_med=594.1us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=128x4 per_split=256 depth=1 kv_bytes=134217728 fill=11.4ms chip_med=1863.3us (72.0 GB/s) call_med=1866.0us reps=20
+gpu_decode_attn256_test: 30 checks, 0 failed: PASS
+depth 1 exit 0 (informational)
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /device.txt b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /device.txt
new file mode 100644
index 000000000 ..ac189e88d
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /device.txt
@@ -0,0 +1,6 @@
+start 2026-10-18T12:44:15Z omega=8bb4494e577a10143d036f448fbdf22102cc305b branch=feat/attn-hd256 dirty=1 physics=/home/drakestapleton/workspace/physics-own30b-k physics_commit=6d7cf0d4d8eb2cda7b512100ff6058e25dbb3ddf physics_lock=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
+ total used free shared buff/cache available
+Mem: 121 107 3 0 15 13
+end 2026-10-18T12:44:28Z
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /host-only.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /host-only.log
new file mode 100644
index 000000000 ..fc0fda8ba
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /host-only.log
@@ -0,0 +1,10 @@
+perm rotary 64: bijection, pairs, rope-by-permutation max abs diff 8.31e-08 over 50 positions
+perm rotary 256: bijection, pairs, rope-by-permutation max abs diff 1.08e-07 over 50 positions
+perm rotary 2: bijection, pairs, rope-by-permutation max abs diff 7.09e-08 over 50 positions
+perm rotary 128: bijection, pairs, rope-by-permutation max abs diff 1.05e-07 over 50 positions
+perm rotary 32: bijection, pairs, rope-by-permutation max abs diff 1.05e-07 over 50 positions
+codegen depth 1: 873 instructions, 96 registers (declared 104, 256 threads -> 26624 of 65536)
+codegen depth 2: 881 instructions, 100 registers (declared 104, 256 threads -> 26624 of 65536)
+codegen depth 3: 889 instructions, 104 registers (declared 112, 256 threads -> 28672 of 65536)
+codegen depth 4: 897 instructions, 108 registers (declared 112, 256 threads -> 28672 of 65536)
+gpu_decode_attn256_test: 58 checks, 0 failed: PASS
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /main.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /main.log
new file mode 100644
index 000000000 ..1ea75a207
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /main.log
@@ -0,0 +1,15 @@
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 165.2 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=4096 fill=0.0ms chip_med=52.1us (0.1 GB/s) call_med=55.4us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=28672 fill=0.0ms chip_med=58.0us (0.5 GB/s) call_med=60.9us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=1048576 fill=0.1ms chip_med=109.8us (9.5 GB/s) call_med=112.9us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=2x4 per_split=256 depth=4 kv_bytes=1232896 fill=0.1ms chip_med=120.0us (10.3 GB/s) call_med=122.6us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: caught (rc=OK bad=2752 worst=30.582)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2937 worst=78.730)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=256 depth=4 kv_bytes=4194304 fill=0.2ms chip_med=144.0us (29.1 GB/s) call_med=146.5us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=16x4 per_split=256 depth=4 kv_bytes=16777216 fill=1.1ms chip_med=339.6us (49.4 GB/s) call_med=342.4us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=256 depth=4 kv_bytes=33554432 fill=2.8ms chip_med=619.7us (54.1 GB/s) call_med=624.5us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=128x4 per_split=256 depth=4 kv_bytes=134217728 fill=7.1ms chip_med=2103.2us (63.8 GB/s) call_med=2107.7us reps=20
+gpu_decode_attn256_test: 30 checks, 0 failed: PASS
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /maxpos131072.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /maxpos131072.log
new file mode 100644
index 000000000 ..6cf15cf4c
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /maxpos131072.log
@@ -0,0 +1,4 @@
+cache alloc (1 layer, 131072 positions, 512 MiB): rc=OK 532.1 ms ()
+chip context 131072 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=512x4 per_split=256 depth=4 kv_bytes=536870912 fill=42.4ms chip_med=8691.6us (61.8 GB/s) call_med=8704.7us reps=5
+gpu_decode_attn256_test: 4 checks, 0 failed: PASS
+max-pos 131072 exit 0 (informational)
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /noevict.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /noevict.log
new file mode 100644
index 000000000 ..a2b6dfd80
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /noevict.log
@@ -0,0 +1,16 @@
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 170.4 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=4096 fill=0.0ms chip_med=50.4us (0.1 GB/s) call_med=52.9us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=28672 fill=0.0ms chip_med=54.9us (0.5 GB/s) call_med=57.6us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=1048576 fill=0.1ms chip_med=106.2us (9.9 GB/s) call_med=108.8us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=2x4 per_split=256 depth=4 kv_bytes=1232896 fill=0.1ms chip_med=121.6us (10.1 GB/s) call_med=124.9us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: caught (rc=OK bad=2752 worst=30.582)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2937 worst=78.730)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=256 depth=4 kv_bytes=4194304 fill=0.3ms chip_med=125.5us (33.4 GB/s) call_med=128.4us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=16x4 per_split=256 depth=4 kv_bytes=16777216 fill=0.9ms chip_med=322.3us (52.1 GB/s) call_med=325.1us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=256 depth=4 kv_bytes=33554432 fill=2.5ms chip_med=594.6us (56.4 GB/s) call_med=597.8us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=128x4 per_split=256 depth=4 kv_bytes=134217728 fill=7.6ms chip_med=2107.0us (63.7 GB/s) call_med=2112.8us reps=20
+gpu_decode_attn256_test: 30 checks, 0 failed: PASS
+no-evict exit 0 (informational)
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /persplit1024.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /persplit1024.log
new file mode 100644
index 000000000 ..4e258c530
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /persplit1024.log
@@ -0,0 +1,16 @@
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 183.8 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=4096 fill=0.0ms chip_med=52.4us (0.1 GB/s) call_med=55.8us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=28672 fill=0.0ms chip_med=56.8us (0.5 GB/s) call_med=59.9us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=1048576 fill=0.1ms chip_med=105.6us (9.9 GB/s) call_med=108.3us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=1232896 fill=0.1ms chip_med=131.8us (9.4 GB/s) call_med=134.6us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: inert (1 split, the combine is not exercised)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2969 worst=86.774)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=4194304 fill=0.3ms chip_med=308.9us (13.6 GB/s) call_med=312.7us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=1024 depth=4 kv_bytes=16777216 fill=1.2ms chip_med=362.7us (46.3 GB/s) call_med=365.3us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=8x4 per_split=1024 depth=4 kv_bytes=33554432 fill=1.5ms chip_med=460.9us (72.8 GB/s) call_med=463.6us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=1024 depth=4 kv_bytes=134217728 fill=5.8ms chip_med=1412.2us (95.0 GB/s) call_med=1414.9us reps=20
+gpu_decode_attn256_test: 29 checks, 0 failed: PASS
+per-split 1024 exit 0 (informational)
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-baseline-matmul.json b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-baseline-matmul.json
new file mode 100644
index 000000000 ..937cf5c88
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-baseline-matmul.json
@@ -0,0 +1 @@
+{"schema":"OMEGA_GPU_MATMUL_API_TIMING_V1","cta_budget":1024,"spin_us":0,"calls":100,"shapes":[{"m":1,"k":2048,"n":8192,"pass":true,"upload_ms":149.124,"ok_calls":100,"median_ms":0.2089,"p90_ms":0.2120,"min_ms":0.1691,"max_ms":3.4713,"chip_ns_mean":252944,"grid_x":1024,"grid_y":1,"e2e_first":2.36603e-07,"e2e_last":2.36603e-07,"e2e_bad_first":0,"e2e_bad_last":0,"repeat_mismatch":0},{"m":1,"k":8192,"n":2048,"pass":true,"upload_ms":106.306,"ok_calls":100,"median_ms":0.2096,"p90_ms":0.3107,"min_ms":0.2024,"max_ms":3.1607,"chip_ns_mean":258955,"grid_x":256,"grid_y":1,"e2e_first":5.21488e-07,"e2e_last":5.21488e-07,"e2e_bad_first":0,"e2e_bad_last":0,"repeat_mismatch":0}],"blocked":false,"checks":4,"failed":0,"verdict":"OMEGA_GPU_MATMUL_TIMING_PASS"}
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-depth1.json b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-depth1.json
new file mode 100644
index 000000000 ..91bb4bd5b
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-depth1.json
@@ -0,0 +1 @@
+{"receipt":"OMEGA_GPU_DECODE_ATTN256_V1","reps":20,"evict":1,"max_pos":32768,"rotary_dim":64,"points":[{"name":"context 1","pos":0,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":4096,"fill_ms":0.0,"chip_median_ns":48992,"gb_per_s":0.1,"call_median_ns":51632,"reps":20},{"name":"context 7","pos":6,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":28672,"fill_ms":0.0,"chip_median_ns":56368,"gb_per_s":0.5,"call_median_ns":59183,"reps":20},{"name":"context 256","pos":255,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":1048576 ,"fill_ms":0.1,"chip_median_ns":107423,"gb_per_s":9.8,"call_median_ns":110159,"reps":20},{"name":"context 301 sharp q","pos":300,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":2,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":1232896 ,"fill_ms":0.1,"chip_median_ns":122527,"gb_per_s":10.1,"call_median_ns":125647,"reps":20},{"name":"context 301 sharp q mutant 1","caught":1,"rc":"OK","bad":4815,"worst_of_tol":17.399},{"name":"context 301 sharp q mutant 2","caught":1,"rc":"OK","bad":5666,"worst_of_tol":40.991},{"name":"context 301 sharp q mutant 3","caught":1,"rc":"OK","bad":899,"worst_of_tol":3.363},{"name":"context 301 sharp q mutant 4","caught":1,"rc":"OK","bad":2752,"worst_of_tol":30.582},{"name":"context 301 sharp q mutant 5","caught":1,"rc":"OK","bad":2937,"worst_of_tol":78.730},{"name":"context 1024","pos":1023,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":4,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":4194304 ,"fill_ms":0.4,"chip_median_ns":148735,"gb_per_s":28.2,"call_median_ns":151535,"reps":20},{"name":"context 4096","pos":4095,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":16,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":16777216 ,"fill_ms":1.3,"chip_median_ns":312766,"gb_per_s":53.6,"call_median_ns":315693,"reps":20},{"name":"context 8192","pos":8191,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":32,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":33554432 ,"fill_ms":1.8,"chip_median_ns":591100,"gb_per_s":56.8,"call_median_ns":594076,"reps":20},{"name":"context 32768","pos":32767,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":128,"grid_y":4,"per_split":256,"depth":1,"kv_bytes":134217728 ,"fill_ms":11.4,"chip_median_ns":1863346 ,"gb_per_s":72.0,"call_median_ns":1865954 ,"reps":20}],"checks":30,"failed":0,"device_opens":1,"verdict":"OMEGA_GPU_DECODE_ATTN256_PASS"}
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-main.json b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-main.json
new file mode 100644
index 000000000 ..cf81cc56b
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-main.json
@@ -0,0 +1 @@
+{"receipt":"OMEGA_GPU_DECODE_ATTN256_V1","reps":20,"evict":1,"max_pos":32768,"rotary_dim":64,"points":[{"name":"context 1","pos":0,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":4096,"fill_ms":0.0,"chip_median_ns":52064,"gb_per_s":0.1,"call_median_ns":55423,"reps":20},{"name":"context 7","pos":6,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":28672,"fill_ms":0.0,"chip_median_ns":57983,"gb_per_s":0.5,"call_median_ns":60911,"reps":20},{"name":"context 256","pos":255,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":1048576 ,"fill_ms":0.1,"chip_median_ns":109807,"gb_per_s":9.5,"call_median_ns":112879,"reps":20},{"name":"context 301 sharp q","pos":300,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":2,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":1232896 ,"fill_ms":0.1,"chip_median_ns":119952,"gb_per_s":10.3,"call_median_ns":122608,"reps":20},{"name":"context 301 sharp q mutant 1","caught":1,"rc":"OK","bad":4815,"worst_of_tol":17.399},{"name":"context 301 sharp q mutant 2","caught":1,"rc":"OK","bad":5666,"worst_of_tol":40.991},{"name":"context 301 sharp q mutant 3","caught":1,"rc":"OK","bad":899,"worst_of_tol":3.363},{"name":"context 301 sharp q mutant 4","caught":1,"rc":"OK","bad":2752,"worst_of_tol":30.582},{"name":"context 301 sharp q mutant 5","caught":1,"rc":"OK","bad":2937,"worst_of_tol":78.730},{"name":"context 1024","pos":1023,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":4,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":4194304 ,"fill_ms":0.2,"chip_median_ns":143951,"gb_per_s":29.1,"call_median_ns":146463,"reps":20},{"name":"context 4096","pos":4095,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":16,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":16777216 ,"fill_ms":1.1,"chip_median_ns":339550,"gb_per_s":49.4,"call_median_ns":342350,"reps":20},{"name":"context 8192","pos":8191,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":32,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":33554432 ,"fill_ms":2.8,"chip_median_ns":619724,"gb_per_s":54.1,"call_median_ns":624523,"reps":20},{"name":"context 32768","pos":32767,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":128,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":134217728 ,"fill_ms":7.1,"chip_median_ns":2103248 ,"gb_per_s":63.8,"call_median_ns":2107696 ,"reps":20}],"checks":30,"failed":0,"device_opens":1,"verdict":"OMEGA_GPU_DECODE_ATTN256_PASS"}
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-maxpos131072.json b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-maxpos131072.json
new file mode 100644
index 000000000 ..d2b85c0ba
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-maxpos131072.json
@@ -0,0 +1 @@
+{"receipt":"OMEGA_GPU_DECODE_ATTN256_V1","reps":5,"evict":1,"max_pos":131072,"rotary_dim":64,"points":[{"name":"context 131072","pos":131071,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":512,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":536870912 ,"fill_ms":42.4,"chip_median_ns":8691551 ,"gb_per_s":61.8,"call_median_ns":8704671 ,"reps":5}],"checks":4,"failed":0,"device_opens":1,"verdict":"OMEGA_GPU_DECODE_ATTN256_PASS"}
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-noevict.json b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-noevict.json
new file mode 100644
index 000000000 ..69fd77525
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-noevict.json
@@ -0,0 +1 @@
+{"receipt":"OMEGA_GPU_DECODE_ATTN256_V1","reps":20,"evict":0,"max_pos":32768,"rotary_dim":64,"points":[{"name":"context 1","pos":0,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":4096,"fill_ms":0.0,"chip_median_ns":50367,"gb_per_s":0.1,"call_median_ns":52911,"reps":20},{"name":"context 7","pos":6,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":28672,"fill_ms":0.0,"chip_median_ns":54864,"gb_per_s":0.5,"call_median_ns":57584,"reps":20},{"name":"context 256","pos":255,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":1048576 ,"fill_ms":0.1,"chip_median_ns":106223,"gb_per_s":9.9,"call_median_ns":108799,"reps":20},{"name":"context 301 sharp q","pos":300,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":2,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":1232896 ,"fill_ms":0.1,"chip_median_ns":121599,"gb_per_s":10.1,"call_median_ns":124943,"reps":20},{"name":"context 301 sharp q mutant 1","caught":1,"rc":"OK","bad":4815,"worst_of_tol":17.399},{"name":"context 301 sharp q mutant 2","caught":1,"rc":"OK","bad":5666,"worst_of_tol":40.991},{"name":"context 301 sharp q mutant 3","caught":1,"rc":"OK","bad":899,"worst_of_tol":3.363},{"name":"context 301 sharp q mutant 4","caught":1,"rc":"OK","bad":2752,"worst_of_tol":30.582},{"name":"context 301 sharp q mutant 5","caught":1,"rc":"OK","bad":2937,"worst_of_tol":78.730},{"name":"context 1024","pos":1023,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":4,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":4194304 ,"fill_ms":0.3,"chip_median_ns":125487,"gb_per_s":33.4,"call_median_ns":128351,"reps":20},{"name":"context 4096","pos":4095,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":16,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":16777216 ,"fill_ms":0.9,"chip_median_ns":322270,"gb_per_s":52.1,"call_median_ns":325054,"reps":20},{"name":"context 8192","pos":8191,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":32,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":33554432 ,"fill_ms":2.5,"chip_median_ns":594620,"gb_per_s":56.4,"call_median_ns":597804,"reps":20},{"name":"context 32768","pos":32767,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":128,"grid_y":4,"per_split":256,"depth":4,"kv_bytes":134217728 ,"fill_ms":7.6,"chip_median_ns":2107024 ,"gb_per_s":63.7,"call_median_ns":2112767 ,"reps":20}],"checks":30,"failed":0,"device_opens":1,"verdict":"OMEGA_GPU_DECODE_ATTN256_PASS"}
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-persplit1024.json b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-persplit1024.json
new file mode 100644
index 000000000 ..d265884dc
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /receipt-persplit1024.json
@@ -0,0 +1 @@
+{"receipt":"OMEGA_GPU_DECODE_ATTN256_V1","reps":20,"evict":1,"max_pos":32768,"rotary_dim":64,"points":[{"name":"context 1","pos":0,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":4096,"fill_ms":0.0,"chip_median_ns":52416,"gb_per_s":0.1,"call_median_ns":55760,"reps":20},{"name":"context 7","pos":6,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":28672,"fill_ms":0.0,"chip_median_ns":56831,"gb_per_s":0.5,"call_median_ns":59855,"reps":20},{"name":"context 256","pos":255,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":1048576 ,"fill_ms":0.1,"chip_median_ns":105567,"gb_per_s":9.9,"call_median_ns":108255,"reps":20},{"name":"context 301 sharp q","pos":300,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":1232896 ,"fill_ms":0.1,"chip_median_ns":131823,"gb_per_s":9.4,"call_median_ns":134575,"reps":20},{"name":"context 301 sharp q mutant 1","caught":1,"rc":"OK","bad":4815,"worst_of_tol":17.399},{"name":"context 301 sharp q mutant 2","caught":1,"rc":"OK","bad":5666,"worst_of_tol":40.991},{"name":"context 301 sharp q mutant 3","caught":1,"rc":"OK","bad":899,"worst_of_tol":3.363},{"name":"context 301 sharp q mutant 5","caught":1,"rc":"OK","bad":2969,"worst_of_tol":86.774},{"name":"context 1024","pos":1023,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":1,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":4194304 ,"fill_ms":0.3,"chip_median_ns":308910,"gb_per_s":13.6,"call_median_ns":312749,"reps":20},{"name":"context 4096","pos":4095,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":4,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":16777216 ,"fill_ms":1.2,"chip_median_ns":362669,"gb_per_s":46.3,"call_median_ns":365293,"reps":20},{"name":"context 8192","pos":8191,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":8,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":33554432 ,"fill_ms":1.5,"chip_median_ns":460860,"gb_per_s":72.8,"call_median_ns":463564,"reps":20},{"name":"context 32768","pos":32767,"rc":"OK","bad":0,"worst_of_tol":0.000,"rows":"ok (0 one-ulp k flips)","second_call_identical":1,"grid_x":32,"grid_y":4,"per_split":1024,"depth":4,"kv_bytes":134217728 ,"fill_ms":5.8,"chip_median_ns":1412165 ,"gb_per_s":95.0,"call_median_ns":1414933 ,"reps":20}],"checks":29,"failed":0,"device_opens":1,"verdict":"OMEGA_GPU_DECODE_ATTN256_PASS"}
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /run.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /run.log
new file mode 100644
index 000000000 ..ae3554da2
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /run.log
@@ -0,0 +1,98 @@
+perm rotary 64: bijection, pairs, rope-by-permutation max abs diff 8.31e-08 over 50 positions
+perm rotary 256: bijection, pairs, rope-by-permutation max abs diff 1.08e-07 over 50 positions
+perm rotary 2: bijection, pairs, rope-by-permutation max abs diff 7.09e-08 over 50 positions
+perm rotary 128: bijection, pairs, rope-by-permutation max abs diff 1.05e-07 over 50 positions
+perm rotary 32: bijection, pairs, rope-by-permutation max abs diff 1.05e-07 over 50 positions
+codegen depth 1: 873 instructions, 96 registers (declared 104, 256 threads -> 26624 of 65536)
+codegen depth 2: 881 instructions, 100 registers (declared 104, 256 threads -> 26624 of 65536)
+codegen depth 3: 889 instructions, 104 registers (declared 112, 256 threads -> 28672 of 65536)
+codegen depth 4: 897 instructions, 108 registers (declared 112, 256 threads -> 28672 of 65536)
+gpu_decode_attn256_test: 58 checks, 0 failed: PASS
+sim context 1 depth 1: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 7 depth 2: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 7, sharp q (x4) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 7, full rope (rotary 256) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 256 (full chunk, 1 split) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 257 (2 splits, last holds one position) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 301 (2 splits) depth 3: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 701 (3 splits) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 701 (per_split 512: 2 chunks per CTA) depth 2: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim mutant 1 at context 301: caught (bad=5719 worst=12.743 rows: k slot 0 (model dim 0) chip bfd3 ref 3b51)
+sim mutant 2 at context 301: caught (bad=5674 worst=36.957 rows: ok (0 one-ulp k flips))
+sim mutant 3 at context 301: caught (bad=2028 worst=10.895 rows: v[0] chip 0000 ref 3f41)
+sim mutant 4 at context 301: caught (bad=4068 worst=27.701 rows: ok (0 one-ulp k flips))
+sim mutant 5 at context 301: caught (bad=2979 worst=inf rows: ok (0 one-ulp k flips))
+sim: 10975936 warp issues in total
+gpu_decode_attn256_test: 14 checks, 0 failed: PASS
+PASS timing 1x2048x8192 upload_ms=149.1 ok_calls=100 median_ms=0.209 p90_ms=0.212 min_ms=0.169 max_ms=3.471 chip_ns_mean=252944 grid=1024x1 e2e_first=2.36603e-07 e2e_last=2.36603e-07 repeat_mismatch=0
+PASS timing 1x8192x2048 upload_ms=106.3 ok_calls=100 median_ms=0.210 p90_ms=0.311 min_ms=0.202 max_ms=3.161 chip_ns_mean=258955 grid=256x1 e2e_first=5.21488e-07 e2e_last=5.21488e-07 repeat_mismatch=0
+PASS: 4 checks, 0 failed
+baseline exit 0 (recorded)
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 165.2 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=4096 fill=0.0ms chip_med=52.1us (0.1 GB/s) call_med=55.4us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=28672 fill=0.0ms chip_med=58.0us (0.5 GB/s) call_med=60.9us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=1048576 fill=0.1ms chip_med=109.8us (9.5 GB/s) call_med=112.9us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=2x4 per_split=256 depth=4 kv_bytes=1232896 fill=0.1ms chip_med=120.0us (10.3 GB/s) call_med=122.6us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: caught (rc=OK bad=2752 worst=30.582)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2937 worst=78.730)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=256 depth=4 kv_bytes=4194304 fill=0.2ms chip_med=144.0us (29.1 GB/s) call_med=146.5us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=16x4 per_split=256 depth=4 kv_bytes=16777216 fill=1.1ms chip_med=339.6us (49.4 GB/s) call_med=342.4us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=256 depth=4 kv_bytes=33554432 fill=2.8ms chip_med=619.7us (54.1 GB/s) call_med=624.5us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=128x4 per_split=256 depth=4 kv_bytes=134217728 fill=7.1ms chip_med=2103.2us (63.8 GB/s) call_med=2107.7us reps=20
+gpu_decode_attn256_test: 30 checks, 0 failed: PASS
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 170.4 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=4096 fill=0.0ms chip_med=50.4us (0.1 GB/s) call_med=52.9us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=28672 fill=0.0ms chip_med=54.9us (0.5 GB/s) call_med=57.6us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=4 kv_bytes=1048576 fill=0.1ms chip_med=106.2us (9.9 GB/s) call_med=108.8us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=2x4 per_split=256 depth=4 kv_bytes=1232896 fill=0.1ms chip_med=121.6us (10.1 GB/s) call_med=124.9us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: caught (rc=OK bad=2752 worst=30.582)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2937 worst=78.730)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=256 depth=4 kv_bytes=4194304 fill=0.3ms chip_med=125.5us (33.4 GB/s) call_med=128.4us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=16x4 per_split=256 depth=4 kv_bytes=16777216 fill=0.9ms chip_med=322.3us (52.1 GB/s) call_med=325.1us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=256 depth=4 kv_bytes=33554432 fill=2.5ms chip_med=594.6us (56.4 GB/s) call_med=597.8us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=128x4 per_split=256 depth=4 kv_bytes=134217728 fill=7.6ms chip_med=2107.0us (63.7 GB/s) call_med=2112.8us reps=20
+gpu_decode_attn256_test: 30 checks, 0 failed: PASS
+no-evict exit 0 (informational)
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 177.4 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=1 kv_bytes=4096 fill=0.0ms chip_med=49.0us (0.1 GB/s) call_med=51.6us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=1 kv_bytes=28672 fill=0.0ms chip_med=56.4us (0.5 GB/s) call_med=59.2us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=256 depth=1 kv_bytes=1048576 fill=0.1ms chip_med=107.4us (9.8 GB/s) call_med=110.2us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=2x4 per_split=256 depth=1 kv_bytes=1232896 fill=0.1ms chip_med=122.5us (10.1 GB/s) call_med=125.6us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: caught (rc=OK bad=2752 worst=30.582)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2937 worst=78.730)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=256 depth=1 kv_bytes=4194304 fill=0.4ms chip_med=148.7us (28.2 GB/s) call_med=151.5us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=16x4 per_split=256 depth=1 kv_bytes=16777216 fill=1.3ms chip_med=312.8us (53.6 GB/s) call_med=315.7us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=256 depth=1 kv_bytes=33554432 fill=1.8ms chip_med=591.1us (56.8 GB/s) call_med=594.1us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=128x4 per_split=256 depth=1 kv_bytes=134217728 fill=11.4ms chip_med=1863.3us (72.0 GB/s) call_med=1866.0us reps=20
+gpu_decode_attn256_test: 30 checks, 0 failed: PASS
+depth 1 exit 0 (informational)
+cache alloc (1 layer, 32768 positions, 128 MiB): rc=OK 183.8 ms ()
+chip context 1 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=4096 fill=0.0ms chip_med=52.4us (0.1 GB/s) call_med=55.8us reps=20
+chip context 7 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=28672 fill=0.0ms chip_med=56.8us (0.5 GB/s) call_med=59.9us reps=20
+chip context 256 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=1048576 fill=0.1ms chip_med=105.6us (9.9 GB/s) call_med=108.3us reps=20
+chip context 301 sharp q rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=1232896 fill=0.1ms chip_med=131.8us (9.4 GB/s) call_med=134.6us reps=20
+chip context 301 sharp q mutant 1: caught (rc=OK bad=4815 worst=17.399)
+chip context 301 sharp q mutant 2: caught (rc=OK bad=5666 worst=40.991)
+chip context 301 sharp q mutant 3: caught (rc=OK bad=899 worst=3.363)
+chip context 301 sharp q mutant 4: inert (1 split, the combine is not exercised)
+chip context 301 sharp q mutant 5: caught (rc=OK bad=2969 worst=86.774)
+chip context 1024 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=1x4 per_split=1024 depth=4 kv_bytes=4194304 fill=0.3ms chip_med=308.9us (13.6 GB/s) call_med=312.7us reps=20
+chip context 4096 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=4x4 per_split=1024 depth=4 kv_bytes=16777216 fill=1.2ms chip_med=362.7us (46.3 GB/s) call_med=365.3us reps=20
+chip context 8192 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=8x4 per_split=1024 depth=4 kv_bytes=33554432 fill=1.5ms chip_med=460.9us (72.8 GB/s) call_med=463.6us reps=20
+chip context 32768 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=32x4 per_split=1024 depth=4 kv_bytes=134217728 fill=5.8ms chip_med=1412.2us (95.0 GB/s) call_med=1414.9us reps=20
+gpu_decode_attn256_test: 29 checks, 0 failed: PASS
+per-split 1024 exit 0 (informational)
+cache alloc (1 layer, 131072 positions, 512 MiB): rc=OK 532.1 ms ()
+chip context 131072 rc=OK bad=0 worst=0.000 rows=ok (0 one-ulp k flips) grid=512x4 per_split=256 depth=4 kv_bytes=536870912 fill=42.4ms chip_med=8691.6us (61.8 GB/s) call_med=8704.7us reps=5
+gpu_decode_attn256_test: 4 checks, 0 failed: PASS
+max-pos 131072 exit 0 (informational)
+GPU_DECODE_ATTN256_CHIP: PASS
diff --git a/evidence/QWEN38-DATTN256-8bb4494e -20261018 /sim.log b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /sim.log
new file mode 100644
index 000000000 ..9cb22fe27
--- /dev/null
+++ b/evidence/QWEN38-DATTN256-8bb4494e -20261018 /sim.log
@@ -0,0 +1,16 @@
+sim context 1 depth 1: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 7 depth 2: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 7, sharp q (x4) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 7, full rope (rotary 256) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 256 (full chunk, 1 split) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 257 (2 splits, last holds one position) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 301 (2 splits) depth 3: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 701 (3 splits) depth 4: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim context 701 (per_split 512: 2 chunks per CTA) depth 2: ok bad=0 worst=0.000 rows: ok (0 one-ulp k flips)
+sim mutant 1 at context 301: caught (bad=5719 worst=12.743 rows: k slot 0 (model dim 0) chip bfd3 ref 3b51)
+sim mutant 2 at context 301: caught (bad=5674 worst=36.957 rows: ok (0 one-ulp k flips))
+sim mutant 3 at context 301: caught (bad=2028 worst=10.895 rows: v[0] chip 0000 ref 3f41)
+sim mutant 4 at context 301: caught (bad=4068 worst=27.701 rows: ok (0 one-ulp k flips))
+sim mutant 5 at context 301: caught (bad=2979 worst=inf rows: ok (0 one-ulp k flips))
+sim: 10975936 warp issues in total
+gpu_decode_attn256_test: 14 checks, 0 failed: PASS
diff --git a/src/.crumb b/src/.crumb
index 12f2572a6 ..529800d7a 100644
--- a/src/.crumb
+++ b/src/.crumb
@@ -182,14 +182,14 @@
}
],
"children_root": "sha256:15012a017b26a269feb256b64875ece2912f5f82c57804baafa3777c4fcb80b9 ",
- "compiled_at": "2026-10-18T13:02:58Z",
+ "compiled_at": "2026-10-18T13:06:21Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:cceb4d16f88ad5ae07eec048bcfbc84bfe1e011f05d9ead33957479fd6dd23bd ",
+ "digest": "sha256:088de32c7f661acdf7e4c352240dd318dc4d01f510983bc90971ac39e23ca9be ",
"evidence_files": 0,
"evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 541,
- "generated_at_commit": "e7356996557da557d63de0f56558a335b5c25223 ",
- "source_tree": "sha256:ec2bd9c20737f25d4ca6591930cf08010c775a8e6c06e7e961b95569fe49ccc9 "
+ "files": 545,
+ "generated_at_commit": "c3ab69f66d6b2a2bce7efe425d80b1306e1140ed ",
+ "source_tree": "sha256:b127e0811056ec10f143d76bc46da50d1c6938195e66a34ba717ec7233294f82 "
},
"owner_lane": "",
"provenance": {
diff --git a/src/omega_blackwell_codegen_attn256.c b/src/omega_blackwell_codegen_attn256.c
new file mode 100644
index 000000000 ..4ba877bf9
--- /dev/null
+++ b/src/omega_blackwell_codegen_attn256.c
@@ -0,0 +1,565 @@
+/*
+ * omega_blackwell_codegen_attn256.c: the one-launch decode attention kernel for head_dim 256 (see the header). The
+ * emitter helpers are the ones of omega_blackwell_codegen_attn.c (control words, read barrier on every load, loop
+ * live ranges); the program follows that kernel with the 27B geometry and the dim-split V pass.
+ */
+#include "omega_blackwell_codegen_attn256.h"
+#include "omega_blackwell_codegen_attn.h"
+#include <string.h>
+
+#define CW(stall, wbar, rbar, wait) \
+ (((uint32_t)(stall) << 9) | ((uint32_t)(wbar) << 14) | ((uint32_t)(rbar) << 17) | ((uint32_t)(wait) << 20))
+#define CW_YIELD 0x2000u
+#define SB_NONE 7u
+#define SB_GPR 0u
+#define SB_RD 1u
+#define SB_UGPR 2u
+#define NOREG (-1)
+#define MAX_LOOPS 4
+
+enum { K_FIXED, K_PRED, K_VAR, K_VAR_MORE, K_UVAR, K_STORE, K_SYNC, K_EXIT, K_BRA, K_BSSY, K_BSYNC };
+
+typedef struct {
+ BlackwellIRProgram *p;
+ uint32_t pending;
+ int err;
+ int open_start[MAX_LOOPS];
+ int depth;
+} Em;
+
+static void emit(Em *e, BlackwellIRInsn in, int kind) {
+ uint32_t wait = e->pending;
+ switch (kind) {
+ case K_FIXED: in.control = CW(6, SB_NONE, SB_NONE, wait); e->pending = 0; break;
+ case K_PRED: in.control = CW(14, SB_NONE, SB_NONE, wait); e->pending = 0; break;
+ case K_VAR: in.control = CW(4, SB_GPR, SB_RD, wait) | CW_YIELD; e->pending = (1u << SB_GPR) | (1u << SB_RD); break;
+ case K_VAR_MORE: in.control = CW(4, SB_GPR, SB_RD, (e->pending & (1u << SB_RD))) | CW_YIELD; e->pending |= (1u << SB_GPR) | (1u << SB_RD); break;
+ case K_UVAR: in.control = CW(4, SB_UGPR, SB_NONE, wait) | CW_YIELD; e->pending = 1u << SB_UGPR; break;
+ case K_STORE: in.control = CW(4, SB_NONE, SB_RD, wait) | CW_YIELD; e->pending = 1u << SB_RD; break;
+ case K_SYNC: in.control = CW(6, SB_NONE, SB_NONE, wait); e->pending = 0; break;
+ case K_EXIT: in.control = CW(5, SB_NONE, SB_NONE, wait); e->pending = in.predicate_p0 ? wait : 0; break;
+ case K_BRA: in.control = CW(5, SB_NONE, SB_NONE, wait); e->pending = in.predicate_p0 ? wait : 0; break;
+ case K_BSSY: in.control = CW(1, SB_NONE, SB_NONE, wait) | CW_YIELD; e->pending = 0; break;
+ case K_BSYNC: in.control = CW(5, SB_NONE, SB_NONE, wait) | CW_YIELD; e->pending = 0; break;
+ default: e->err = -1; return;
+ }
+ if (omega_bw_ir_append(e->p, &in) < 0) e->err = -1;
+}
+
+static BlackwellIRInsn I0(BlackwellIROpcode op) {
+ BlackwellIRInsn i; memset(&i, 0, sizeof i);
+ i.op = op; i.dst_vreg = NOREG; i.src1_vreg = NOREG; i.src2_vreg = NOREG; i.src3_vreg = NOREG; i.ureg = NOREG;
+ return i;
+}
+static int V(Em *e) { int v = omega_bw_ir_alloc_vreg(e->p); if (v < 0) e->err = -1; return v; }
+static int V64(Em *e) { int v = omega_bw_ir_alloc_vreg64(e->p); if (v < 0) e->err = -1; return v; }
+static int V128(Em *e) { int v = omega_bw_ir_alloc_vreg128(e->p); if (v < 0) e->err = -1; return v; }
+static int UV64(Em *e) { int v = omega_bw_ir_alloc_uvreg64(e->p); if (v < 0) e->err = -1; return v; }
+static int here(const Em *e) { return (int)e->p->count; }
+
+/* operand with subregister */
+typedef struct { int v; unsigned s; } Op;
+static Op R(int v) { Op o = { v, 0 }; return o; }
+static Op S(int v, unsigned s) { Op o = { v, s }; return o; }
+
+static void ldcu64(Em *e, int ud, uint32_t off) { BlackwellIRInsn i = I0(BW_IR_LDCU64); i.dst_vreg = ud; i.imm = off; i.is_uniform = true; emit(e, i, K_UVAR); }
+static void ldc64(Em *e, int d, uint32_t off) { BlackwellIRInsn i = I0(BW_IR_LDC64); i.dst_vreg = d; i.imm = off; emit(e, i, K_VAR); }
+static void ldc32(Em *e, int d, uint32_t off) { BlackwellIRInsn i = I0(BW_IR_LDC); i.dst_vreg = d; i.imm = off; emit(e, i, K_VAR); }
+static void s2r(Em *e, int d, uint32_t sr) { BlackwellIRInsn i = I0(BW_IR_S2R); i.dst_vreg = d; i.imm = sr; emit(e, i, K_VAR); }
+static void movi(Em *e, int d, uint32_t imm) { BlackwellIRInsn i = I0(BW_IR_MOV_IMM); i.dst_vreg = d; i.imm = imm; emit(e, i, K_FIXED); }
+static void movrz(Em *e, Op d) { BlackwellIRInsn i = I0(BW_IR_MOV_RZ); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; emit(e, i, K_FIXED); }
+/* d = a * imm + c */
+static void imadi(Em *e, Op d, Op a, uint32_t imm, int c) { BlackwellIRInsn i = I0(BW_IR_IMAD); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = a.v; i.src1_subreg = (uint8_t)a.s; i.imm = imm; i.src3_vreg = c; emit(e, i, K_FIXED); }
+/* d = a * b + c (registers) */
+static void imadr(Em *e, int d, int a, int b, int c) { BlackwellIRInsn i = I0(BW_IR_IMAD); i.dst_vreg = d; i.src1_vreg = a; i.src2_vreg = b; i.src3_vreg = c; emit(e, i, K_FIXED); }
+/* d64 = a * imm + c64 */
+static void imadw(Em *e, int d64, int a, uint32_t imm, int c64) { BlackwellIRInsn i = I0(BW_IR_IMAD_WIDE); i.dst_vreg = d64; i.src1_vreg = a; i.imm = imm; i.src3_vreg = c64; emit(e, i, K_FIXED); }
+static void mov(Em *e, Op d, Op a) { imadi(e, d, a, 1u, NOREG); }
+static void shrs(Em *e, int d, Op a, uint32_t imm) { BlackwellIRInsn i = I0(BW_IR_SHF_R); i.dst_vreg = d; i.src1_vreg = a.v; i.src1_subreg = (uint8_t)a.s; i.imm = imm; emit(e, i, K_FIXED); }
+static void shr(Em *e, int d, int a, uint32_t imm) { shrs(e, d, R(a), imm); }
+static void andi(Em *e, Op d, Op a, uint32_t imm) { BlackwellIRInsn i = I0(BW_IR_LOP3_AND); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = a.v; i.src1_subreg = (uint8_t)a.s; i.imm = imm; emit(e, i, K_FIXED); }
+static void xorr(Em *e, Op d, Op a, Op b) { BlackwellIRInsn i = I0(BW_IR_LOP3_XOR); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = a.v; i.src1_subreg = (uint8_t)a.s; i.src2_vreg = b.v; i.src2_subreg = (uint8_t)b.s; 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 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, BlackwellIROpcode op, int d, int addr64, int udesc, int first) { BlackwellIRInsn i = I0(op); i.dst_vreg = d; i.src1_vreg = addr64; i.ureg = udesc; emit(e, i, first ? K_VAR : K_VAR_MORE); }
+static void stg(Em *e, BlackwellIROpcode op, int addr64, Op val, int udesc) { BlackwellIRInsn i = I0(op); i.src1_vreg = addr64; i.src2_vreg = val.v; i.src2_subreg = (uint8_t)val.s; i.ureg = udesc; emit(e, i, K_STORE); }
+static void atom_add(Em *e, int d, int addr64, int val, int udesc) { BlackwellIRInsn i = I0(BW_IR_ATOMG_ADD_STRONG_SYS); i.dst_vreg = d; i.src1_vreg = addr64; i.src2_vreg = val; i.ureg = udesc; emit(e, i, K_VAR); }
+static void membar(Em *e) { emit(e, I0(BW_IR_MEMBAR_ALL_SYS), K_FIXED); }
+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, Op d, int addr, int first) { BlackwellIRInsn i = I0(BW_IR_LDS32); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = addr; emit(e, i, first ? K_VAR : K_VAR_MORE); }
+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 fop(Em *e, BlackwellIROpcode op, Op d, Op a, Op b, Op c) {
+ BlackwellIRInsn i = I0(op); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = a.v; i.src1_subreg = (uint8_t)a.s;
+ i.src2_vreg = b.v; i.src2_subreg = (uint8_t)b.s; i.src3_vreg = c.v; i.src3_subreg = (uint8_t)c.s; emit(e, i, K_FIXED);
+}
+static void fadd(Em *e, Op d, Op a, Op b) { fop(e, BW_IR_FADD, d, a, b, R(NOREG)); }
+static void fsub(Em *e, Op d, Op a, Op b) { fop(e, BW_IR_FSUB, d, a, b, R(NOREG)); }
+static void fmul(Em *e, Op d, Op a, Op b) { fop(e, BW_IR_FMUL, d, a, b, R(NOREG)); }
+static void ffma(Em *e, Op d, Op a, Op b, Op c) { fop(e, BW_IR_FFMA, d, a, b, c); }
+static void fmaxx(Em *e, Op d, Op a, Op b) { fop(e, BW_IR_FMNMX_MAX, d, a, b, R(NOREG)); }
+static void mufu(Em *e, BlackwellIROpcode op, Op d, Op a) { BlackwellIRInsn i = I0(op); i.dst_vreg = d.v; i.dst_subreg = (uint8_t)d.s; i.src1_vreg = a.v; i.src1_subreg = (uint8_t)a.s; emit(e, i, K_VAR); }
+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); }
+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(Em *e, int target) { BlackwellIRInsn i = I0(BW_IR_BRA); i.imm = (uint32_t)(target - here(e)); emit(e, i, K_BRA); }
+static int bra_if_p0_fwd(Em *e) { int at = here(e); BlackwellIRInsn i = I0(BW_IR_BRA); i.predicate_p0 = true; i.imm = 1; emit(e, i, K_BRA); return at; }
+static void patch_bra(Em *e, int at, int target) { if (!e->err) e->p->insns[at].imm = (uint32_t)(target - at); }
+static int bssy_fwd(Em *e) { int at = here(e); BlackwellIRInsn i = I0(BW_IR_BSSY); i.bar_reg = 0; i.imm = 2; emit(e, i, K_BSSY); return at; }
+static void bsync(Em *e) { BlackwellIRInsn i = I0(BW_IR_BSYNC); i.bar_reg = 0; emit(e, i, K_BSYNC); }
+static void exit_k(Em *e) { emit(e, I0(BW_IR_EXIT), K_EXIT); }
+static void tail(Em *e) {
+ exit_k(e);
+ BlackwellIRInsn self = I0(BW_IR_BRA);
+ self.control = 0x000fc000u;
+ if (omega_bw_ir_append(e->p, &self) < 0) e->err = -1;
+}
+static void loop_begin(Em *e) { if (e->depth >= MAX_LOOPS) { e->err = -1; return; } e->open_start[e->depth++] = here(e); }
+static void loop_end(Em *e) {
+ if (e->depth <= 0) { e->err = -1; return; }
+ int start = e->open_start[--e->depth], end = here(e) - 1;
+ OmegaRegAlloc *ra = &e->p->regalloc;
+ for (int v = 0; v < ra->num_vregs; v++) {
+ OmegaLiveInterval *iv = &ra->intervals[v];
+ if (iv->first_def >= 0 && iv->first_def < start && iv->last_use >= start && iv->last_use < end) iv->last_use = end;
+ }
+}
+
+/* A region only some lanes of a warp execute: BSSY ... @P0 BRA join ... BSYNC. P0 true = skip. */
+typedef struct { int bssy, bra; } Region;
+static Region region_skip_if_p0(Em *e) { Region r; r.bssy = bssy_fwd(e); r.bra = bra_if_p0_fwd(e); return r; }
+static void region_end(Em *e, Region r) { int at = here(e); bsync(e); patch_bra(e, r.bra, at); patch_bra(e, r.bssy, at + 1); }
+
+/* bf16 round-to-nearest-even of f32 x into the low 16 bits of d: r = x + 0x7fff + ((x >> 16) & 1); d = r >> 16 */
+static void bf16_of(Em *e, int d, Op x, int c7fff, int t) {
+ shrs(e, t, x, 16);
+ andi(e, R(t), R(t), 1u);
+ iadd(e, t, t, c7fff);
+ fop(e, BW_IR_IADD3, R(d), x, R(t), R(NOREG)); /* IADD3 d = x + t */
+ shr(e, d, d, 16);
+}
+
+static const uint32_t NEG_BIG = 0xF149F2CAu; /* -1e30f */
+
+#define H 6u /* q heads per KV head */
+#define RB OMEGA_DATTN256_ROW_BYTES
+#define PBYTES (OMEGA_DATTN256_PARTIAL_WORDS * 4u)
+
+/* 8 consecutive f32 words (two quads) to shared at base + 0 .. 28 */
+static void sts8(Em *e, int base, int one, int t, int qa, int qb) {
+ for (unsigned i = 0; i < 8; i++) { imadi(e, R(t), R(one), i * 4u, base); sts32(e, t, i < 4 ? S(qa, i) : S(qb, i - 4)); }
+}
+/* sum of squares of 8 values, warp-reduced, broadcast through shared word `addr` (lane 0 writes), rs = RSQ(sum/256 + eps) */
+static void rms_scale(Em *e, int qa, int qb, int sq, int ts, int rs, int addr, int lane, int one, int eps) {
+ fmul(e, R(sq), S(qa, 0), S(qa, 0));
+ for (unsigned i = 1; i < 4; i++) ffma(e, R(sq), S(qa, i), S(qa, i), R(sq));
+ for (unsigned i = 0; i < 4; i++) ffma(e, R(sq), S(qb, i), S(qb, i), R(sq));
+ for (uint32_t o = 16; o >= 1; o /= 2) { shfl_down(e, ts, sq, o); fadd(e, R(sq), R(sq), R(ts)); }
+ isetp_ge_u32(e, lane, one);
+ { Region r = region_skip_if_p0(e); sts32(e, addr, R(sq)); region_end(e, r); }
+ bar_sync(e);
+ lds32(e, R(sq), addr, 1);
+ movi(e, ts, 0x3b800000u); /* 1/256 */
+ ffma(e, R(rs), R(sq), R(ts), R(eps));
+ mufu(e, BW_IR_MUFU_RSQ, R(rs), R(rs));
+}
+
+int omega_blackwell_codegen_decode_attn256_prog(const OmegaDecodeAttn256Spec *spec, BlackwellIRProgram *prog) {
+ if (!spec || !prog || spec->depth < 1 || spec->depth > OMEGA_DATTN256_MAX_DEPTH || spec->mutant < 0 || spec->mutant > 5) return -1;
+ omega_bw_ir_init(prog);
+ Em em; memset(&em, 0, sizeof em); em.p = prog; Em *e = &em;
+ const uint32_t D = spec->depth;
+ const int MUT = spec->mutant;
+
+ /* ---- arguments and identities ---- */
+ int udesc = UV64(e);
+ int pqkv = V64(e), pkc = V64(e), pvc = V64(e), prope = V64(e), pqn = V64(e);
+ int pos = V(e), per = V(e), splits = V(e), kvs = V(e), eps = V(e), qks = V(e);
+ int tid = V(e), cx = V(e), cy = V(e), warp = V(e), lane = V(e), one = V(e), zero = V(e), c7fff = V(e), c16 = V(e);
+ if (e->err) return -1;
+ ldcu64(e, udesc, 0x358);
+ ldc64(e, pqkv, OMEGA_DATTN256_ARG_QKV); ldc64(e, pkc, OMEGA_DATTN256_ARG_KC); ldc64(e, pvc, OMEGA_DATTN256_ARG_VC);
+ ldc64(e, prope, OMEGA_DATTN256_ARG_ROPE); ldc64(e, pqn, OMEGA_DATTN256_ARG_QN); /* k_norm is read at q_norm + 1024 bytes (ARG_KN is informational) */
+ ldc32(e, pos, OMEGA_DATTN256_ARG_POS); ldc32(e, per, OMEGA_DATTN256_ARG_PER_SPLIT); ldc32(e, splits, OMEGA_DATTN256_ARG_SPLITS);
+ ldc32(e, kvs, OMEGA_DATTN256_ARG_KV_STRIDE); ldc32(e, eps, OMEGA_DATTN256_ARG_EPS);
+ ldc32(e, qks, OMEGA_DATTN256_ARG_QK_SCALE);
+ 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); movrz(e, R(zero)); movi(e, c7fff, 0x7fffu); movi(e, c16, 16);
+ shr(e, warp, tid, 5);
+ andi(e, R(lane), R(tid), 31u);
+
+ /* range of this CTA: base = cx * per; end = min(base + per, pos + 1) */
+ int base = V(e), bend = V(e), ctx = V(e), t1 = V(e), t2 = V(e), end = V(e), endm1 = V(e), negendm1 = V(e), splitsm1 = V(e), cyk = V(e);
+ imadr(e, base, cx, per, NOREG);
+ imadi(e, R(bend), R(base), 1u, per);
+ imadi(e, R(ctx), R(pos), 1u, one);
+ imadi(e, R(t1), R(ctx), 0xffffffffu, bend); /* t1 = bend - ctx */
+ imadi(e, R(t2), R(t1), 0xffffffffu, NOREG); /* t2 = ctx - bend */
+ shr(e, t2, t2, 31); /* 1 when bend > ctx */
+ imadr(e, t2, t2, t1, NOREG); /* t2 = over * (bend - ctx) */
+ imadi(e, R(end), R(t2), 0xffffffffu, bend); /* end = bend - t2 */
+ imadi(e, R(endm1), R(one), 0xffffffffu, end);
+ imadi(e, R(negendm1), R(endm1), 0xffffffffu, NOREG);
+ imadi(e, R(splitsm1), R(one), 0xffffffffu, splits);
+ imadr(e, cyk, cy, kvs, NOREG); /* byte offset of this KV head's plane */
+
+ /* ---- prologue: one norm + rope block for all 8 warps. Warp h < 6 builds q'[h] (head cy*6+h, q_norm, * qk_scale);
+ * warp 6 builds k_new (k[cy], k_norm = q_norm + 1024 bytes, scale 1); warp 7 runs the block on v[cy] (the result is
+ * discarded) and reloads the raw v at the store. Warps 6, 7 stage in the s[][] region (unused until the chunk loop). ---- */
+ int qa = V128(e), qb = V128(e), wa = V128(e), wb = V128(e), pa_ = V128(e), pb_ = V128(e);
+ int cosa = V128(e), cosb = V128(e), sina = V128(e), sinb = V128(e);
+ int sq = V(e), ts = V(e), rs = V(e), a0 = V(e), a1 = V(e), ad64 = V64(e), rope64 = V64(e), sgn = V(e), pl = V(e), f = V(e), voff = V(e), qksw = V(e);
+ if (e->err) return -1;
+ movi(e, t1, 5u); imadi(e, R(t1), R(warp), 0xffffffffu, t1); /* 5 - warp */
+ shr(e, f, t1, 31); /* f = 1 for warps 6, 7 */
+ /* byte offset of the vector in qkv: q head cy*6 + warp at (cy*6 + warp)*1024; k[cy] at 24576 + cy*1024 = warp*4096 + cy*1024
+ * for warp 6; v[cy] at 28672 + cy*1024 = warp*4096 + cy*1024 for warp 7 */
+ imadi(e, R(t1), R(cy), H, warp); imadi(e, R(t1), R(t1), 1024u, NOREG);
+ imadi(e, R(t2), R(warp), 4096u, NOREG); imadi(e, R(t2), R(cy), 1024u, t2);
+ imadi(e, R(t2), R(t1), 0xffffffffu, t2); /* off_kv - off_q */
+ imadr(e, voff, f, t2, t1); /* f ? off_kv : off_q */
+ imadi(e, R(voff), R(lane), 32u, voff); /* + this lane's 8 dims */
+ imadw(e, ad64, voff, 1u, pqkv);
+ ldg_wide(e, BW_IR_LDG_E_128, qa, ad64, 0, udesc, 1);
+ ldg_wide(e, BW_IR_LDG_E_128, qb, ad64, 16, udesc, 0);
+ imadi(e, R(t2), R(f), 1024u, NOREG); imadi(e, R(t2), R(lane), 32u, t2); /* q_norm, or k_norm 1024 bytes after it */
+ imadw(e, ad64, t2, 1u, pqn);
+ ldg_wide(e, BW_IR_LDG_E_128, wa, ad64, 0, udesc, 0);
+ ldg_wide(e, BW_IR_LDG_E_128, wb, ad64, 16, udesc, 0);
+ /* rope row for this lane: pair index = (lane & 15) * 8 .. +7 (dims 8i..8i+7 for lanes < 16, dims 128 + 8(i-16) above) */
+ andi(e, R(t2), R(lane), 15u);
+ imadi(e, R(t2), R(t2), 32u, NOREG);
+ imadi(e, R(t2), R(pos), OMEGA_DATTN256_ROPE_ROW_BYTES, t2);
+ imadw(e, rope64, t2, 1u, prope);
+ ldg_wide(e, BW_IR_LDG_E_128, cosa, rope64, 0, udesc, 0);
+ ldg_wide(e, BW_IR_LDG_E_128, cosb, rope64, 16, udesc, 0);
+ ldg_wide(e, BW_IR_LDG_E_128, sina, rope64, 512, udesc, 0);
+ ldg_wide(e, BW_IR_LDG_E_128, sinb, rope64, 528, udesc, 0);
+ /* sign of the sin term: lanes < 16 take x[d] * cos - x[d+128] * sin, lanes >= 16 take x[d] * cos + x[d-128] * sin */
+ imadi(e, R(sgn), R(one), 0xfffffff0u, lane); /* lane - 16 */
+ shr(e, sgn, sgn, 31);
+ imadi(e, R(sgn), R(sgn), 0x80000000u, NOREG);
+ for (unsigned i = 0; i < 4; i++) { xorr(e, S(sina, i), S(sina, i), R(sgn)); xorr(e, S(sinb, i), S(sinb, i), R(sgn)); }
+ xorr(e, R(pl), R(lane), R(c16)); /* partner lane */
+
+ /* RMSNorm of the lane's 8 dims: sum of squares over the warp, broadcast through shared memory */
+ imadi(e, R(a0), R(warp), 4u, NOREG); imadi(e, R(a0), R(one), OMEGA_DATTN256_SM_L, a0);
+ rms_scale(e, qa, qb, sq, ts, rs, a0, lane, one, eps);
+ for (unsigned i = 0; i < 4; i++) { fmul(e, S(qa, i), S(qa, i), R(rs)); fmul(e, S(qa, i), S(qa, i), S(wa, i)); fmul(e, S(qb, i), S(qb, i), R(rs)); fmul(e, S(qb, i), S(qb, i), S(wb, i)); }
+ /* stage, read the partner half, rotate */
+ imadi(e, R(a0), R(warp), 1024u, NOREG); imadi(e, R(a0), R(lane), 32u, a0); /* SM_Q + warp*1024 + lane*32 (SM_Q = 0) */
+ sts8(e, a0, one, t1, qa, qb);
+ bar_sync(e);
+ imadi(e, R(t2), R(warp), 1024u, NOREG); imadi(e, R(t2), R(pl), 32u, t2);
+ lds128(e, pa_, t2, 0, 1); lds128(e, pb_, t2, 16, 0);
+ if (MUT != 1) for (unsigned i = 0; i < 4; i++) {
+ fmul(e, R(ts), S(qa, i), S(cosa, i)); ffma(e, S(qa, i), S(pa_, i), S(sina, i), R(ts));
+ fmul(e, R(ts), S(qb, i), S(cosb, i)); ffma(e, S(qb, i), S(pb_, i), S(sinb, i), R(ts));
+ }
+ /* qksw = qk_scale for the q warps, 1.0f for warps 6, 7 (integer select on the bit patterns) */
+ movi(e, ts, 0x3f800000u); imadi(e, R(ts), R(qks), 0xffffffffu, ts); imadr(e, qksw, f, ts, qks);
+ for (unsigned i = 0; i < 4; i++) { fmul(e, S(qa, i), S(qa, i), R(qksw)); fmul(e, S(qb, i), S(qb, i), R(qksw)); }
+ bar_sync(e); /* every partner read done before q' overwrites the staging */
+ sts8(e, a0, one, t1, qa, qb); /* warps 6, 7 write scratch inside s[][] */
+
+ /* ---- the new token's K (warp 6: the rotated k) and V (warp 7: the raw v), bf16 into the cache by the CTA that owns `pos` ---- */
+ if (MUT != 3) {
+ int sa64 = V64(e), sb64 = V64(e), key = V(e), h0 = V(e), h1 = V(e), tb = V(e);
+ /* key = (splits - 1 - cx) + 1 - f: zero only for warps 6, 7 of the last split */
+ imadi(e, R(t2), R(cx), 0xffffffffu, splitsm1);
+ imadi(e, R(t2), R(one), 1u, t2);
+ imadi(e, R(key), R(f), 0xffffffffu, t2);
+ isetp_ge_u32(e, key, one);
+ int b1 = bra_if_p0_fwd(e);
+ /* cache row address of position pos for this lane: 8 bf16 = 16 bytes per lane; K plane, V plane for warp 7 */
+ imadi(e, R(t1), R(pos), RB, cyk); imadi(e, R(t1), R(lane), 16u, t1);
+ imadw(e, sa64, t1, 1u, pkc);
+ movi(e, t2, 7u); imadi(e, R(t2), R(warp), 0xffffffffu, t2); /* 7 - warp: zero for warp 7 */
+ isetp_ge_u32(e, t2, one);
+ { Region r = region_skip_if_p0(e);
+ imadw(e, sb64, voff, 1u, pqkv);
+ ldg_wide(e, BW_IR_LDG_E_128, qa, sb64, 0, udesc, 1);
+ ldg_wide(e, BW_IR_LDG_E_128, qb, sb64, 16, udesc, 0);
+ imadw(e, sa64, t1, 1u, pvc);
+ region_end(e, r); }
+ for (unsigned w = 0; w < 4; w++) {
+ int src = w < 2 ? qa : qb; unsigned s0 = (2 * w) % 4;
+ bf16_of(e, h0, S(src, s0), c7fff, tb); bf16_of(e, h1, S(src, s0 + 1), c7fff, tb); imadi(e, S(wa, w), R(h1), 65536u, h0);
+ }
+ for (unsigned w = 0; w < 4; w++) { imadw(e, sb64, one, 4u * w, sa64); stg(e, BW_IR_STG_E, sb64, S(wa, w), udesc); }
+ patch_bra(e, b1, here(e));
+ }
+ membar(e);
+ bar_sync(e);
+
+ /* ---- running state ---- */
+ int acc[H], m[H], l[H], sc[H], dl[H], wd[8], mn = V(e);
+ for (unsigned h = 0; h < H; h++) { acc[h] = V128(e); m[h] = V(e); l[h] = V(e); sc[h] = V(e); dl[h] = V(e); }
+ for (unsigned q = 0; q < 8; q++) wd[q] = V(e);
+ int kq[OMEGA_DATTN256_MAX_DEPTH], vq[OMEGA_DATTN256_MAX_DEPTH];
+ for (uint32_t d = 0; d < D; d++) { kq[d] = V128(e); vq[d] = V64(e); }
+ int qa4 = V128(e), qb4 = V128(e);
+ int cb = V(e), tpos = V(e), over = V(e), krow = V64(e), kpf = V64(e), qoff = V(e), j = V(e), sa = V(e), smS = V(e);
+ int n = V(e), vrow = V64(e), vpf = V64(e), pa = V(e), i = V(e), dsum = V(e), hoff = V(e), wp = V(e), negwp = V(e), ccnt = V(e);
+ if (e->err) return -1;
+ for (unsigned h = 0; h < H; h++) { for (unsigned q = 0; q < 4; q++) movrz(e, S(acc[h], q)); movi(e, m[h], NEG_BIG); movrz(e, R(l[h])); }
+ movi(e, smS, OMEGA_DATTN256_SM_S);
+ shr(e, wp, warp, 1); /* warp pair index 0..3 */
+ imadi(e, R(negwp), R(wp), 0xffffffffu, NOREG);
+ andi(e, R(hoff), R(warp), 1u);
+ imadi(e, R(hoff), R(hoff), 256u, NOREG); /* byte offset of this warp's dim half in the row */
+ imadi(e, R(hoff), R(lane), 8u, hoff); /* + 4 bf16 = 8 bytes per lane */
+ if (MUT == 2) imadi(e, R(hoff), R(one), RB, hoff);
+ movi(e, ccnt, 32);
+ mov(e, R(cb), R(base));
+
+ /* ---- chunk loop ---- */
+ const int L_chunk = here(e);
+ loop_begin(e);
+ isetp_ge_u32(e, cb, end);
+ const int bra_done = bra_if_p0_fwd(e);
+ /* score pass: thread = position cb + tid, clamped to end - 1 (clamped lanes compute a score nobody reads) */
+ imadi(e, R(tpos), R(cb), 1u, tid);
+ imadi(e, R(over), R(tpos), 0xffffffffu, endm1); /* endm1 - tpos */
+ shr(e, over, over, 31); /* 1 when tpos > endm1 */
+ imadi(e, R(t1), R(tpos), 1u, negendm1); /* tpos - endm1 */
+ imadr(e, t1, over, t1, NOREG);
+ imadi(e, R(t1), R(t1), 0xffffffffu, tpos); /* clamped position */
+ imadi(e, R(t1), R(t1), RB, cyk);
+ imadw(e, krow, t1, 1u, pkc);
+ for (unsigned h = 0; h < H; h++) movrz(e, R(sc[h]));
+ for (uint32_t d = 0; d < D; d++) ldg_wide(e, BW_IR_LDG_E_128, kq[d], krow, d * 16u, udesc, d == 0);
+ imadw(e, kpf, one, D * 16u, krow);
+ movrz(e, R(qoff)); movrz(e, R(j));
+ const int L_q = here(e);
+ loop_begin(e);
+ isetp_ge_u32(e, j, ccnt);
+ const int bra_qend = bra_if_p0_fwd(e);
+ for (unsigned w = 0; w < 4; w++) { imadi(e, R(wd[2 * w]), S(kq[0], w), 65536u, NOREG); andi(e, R(wd[2 * w + 1]), S(kq[0], w), 0xffff0000u); }
+ for (unsigned h = 0; h < H; h++) {
+ lds128(e, qa4, qoff, h * 1024u, 1); lds128(e, qb4, qoff, h * 1024u + 16u, 0);
+ for (unsigned q = 0; q < 4; q++) ffma(e, R(sc[h]), R(wd[q]), S(qa4, q), R(sc[h]));
+ for (unsigned q = 0; q < 4; q++) ffma(e, R(sc[h]), R(wd[4 + q]), S(qb4, q), R(sc[h]));
+ }
+ for (uint32_t d = 0; d + 1 < D; d++) for (unsigned w = 0; w < 4; w++) mov(e, S(kq[d], w), S(kq[d + 1], w));
+ ldg_wide(e, BW_IR_LDG_E_128, kq[D - 1], kpf, 0, udesc, 1);
+ imadw(e, kpf, one, 16u, kpf);
+ imadi(e, R(qoff), R(one), 32u, qoff);
+ imadi(e, R(j), R(one), 1u, j);
+ bra(e, L_q);
+ loop_end(e);
+ patch_bra(e, bra_qend, here(e));
+ imadi(e, R(sa), R(tid), 32u, smS);
+ for (unsigned h = 0; h < H; h++) { imadi(e, R(t1), R(one), h * 4u, sa); sts32(e, t1, R(sc[h])); }
+ bar_sync(e);
+ /* V pass: this warp's positions cb + wp + 4 i, i < n = max(0, ceil((min(end, cb + 256) - cb - wp) / 4)) */
+ imadi(e, R(t1), R(one), OMEGA_DATTN256_CHUNK, cb); /* cb + 256 */
+ imadi(e, R(t2), R(t1), 0xffffffffu, end); /* end - (cb + 256) */
+ shr(e, over, t2, 31); /* 1 when the chunk is cut short by end */
+ imadr(e, t2, over, t2, t1); /* cend = min(end, cb + 256) */
+ imadi(e, R(t1), R(cb), 0xffffffffu, t2); /* cend - cb */
+ imadi(e, R(t1), R(t1), 1u, negwp); /* x = cend - cb - wp */
+ shr(e, over, t1, 31);
+ imadi(e, R(n), R(one), 3u, t1);
+ shr(e, n, n, 2);
+ imadr(e, t2, over, n, NOREG);
+ imadi(e, R(n), R(t2), 0xffffffffu, n);
+ imadi(e, R(t1), R(cb), 1u, wp);
+ imadi(e, R(t1), R(t1), RB, hoff);
+ imadi(e, R(t1), R(t1), 1u, cyk);
+ imadw(e, vrow, t1, 1u, pvc);
+ for (uint32_t d = 0; d < D; d++) ldg_wide(e, BW_IR_LDG_E_64, vq[d], vrow, d * 4u * RB, udesc, d == 0);
+ imadw(e, vpf, one, D * 4u * RB, vrow);
+ imadi(e, R(pa), R(wp), 32u, smS);
+ movrz(e, R(i));
+ const int L_v = here(e);
+ loop_begin(e);
+ isetp_ge_u32(e, i, n);
+ const int bra_vend = bra_if_p0_fwd(e);
+ imadi(e, R(wd[0]), S(vq[0], 0), 65536u, NOREG); andi(e, R(wd[1]), S(vq[0], 0), 0xffff0000u);
+ imadi(e, R(wd[2]), S(vq[0], 1), 65536u, NOREG); andi(e, R(wd[3]), S(vq[0], 1), 0xffff0000u);
+ lds128(e, qa4, pa, 0, 1); lds128(e, qb4, pa, 16, 0);
+#define SH(h) ((h) < 4 ? S(qa4, (h)) : S(qb4, (h) - 4))
+ for (unsigned h = 0; h < H; h++) { fmaxx(e, R(mn), R(m[h]), SH(h)); fsub(e, R(dl[h]), R(m[h]), R(mn)); mov(e, R(m[h]), R(mn)); } /* dl <= 0; exactly +0 when the max stayed */
+ fadd(e, R(dsum), R(dl[0]), R(dl[1]));
+ for (unsigned h = 2; h < H; h++) fadd(e, R(dsum), R(dsum), R(dl[h]));
+ isetp_ge_u32(e, one, dsum); /* 1 >= bits(dsum): no head's max moved (dsum is +0); a negative dsum has the sign bit */
+ const int bra_nores = bra_if_p0_fwd(e);
+ for (unsigned h = 0; h < H; h++) mufu(e, BW_IR_MUFU_EX2, R(dl[h]), R(dl[h]));
+ for (unsigned h = 0; h < H; h++) { for (unsigned q = 0; q < 4; q++) fmul(e, S(acc[h], q), S(acc[h], q), R(dl[h])); fmul(e, R(l[h]), R(l[h]), R(dl[h])); }
+ patch_bra(e, bra_nores, here(e));
+ for (unsigned h = 0; h < H; h++) { fsub(e, R(dl[h]), SH(h), R(m[h])); mufu(e, BW_IR_MUFU_EX2, R(dl[h]), R(dl[h])); }
+#undef SH
+ for (unsigned h = 0; h < H; h++) { for (unsigned q = 0; q < 4; q++) ffma(e, S(acc[h], q), R(dl[h]), R(wd[q]), S(acc[h], q)); fadd(e, R(l[h]), R(l[h]), R(dl[h])); }
+ for (uint32_t d = 0; d + 1 < D; d++) for (unsigned w = 0; w < 2; w++) mov(e, S(vq[d], w), S(vq[d + 1], w));
+ ldg_wide(e, BW_IR_LDG_E_64, vq[D - 1], vpf, 0, udesc, 1);
+ imadw(e, vpf, one, 4u * RB, vpf);
+ imadi(e, R(pa), R(one), 4u * 32u, pa);
+ imadi(e, R(i), R(one), 1u, i);
+ bra(e, L_v);
+ loop_end(e);
+ patch_bra(e, bra_vend, here(e));
+ bar_sync(e); /* the next score pass overwrites s[][] */
+ imadi(e, R(cb), R(one), OMEGA_DATTN256_CHUNK, cb);
+ bra(e, L_chunk);
+ loop_end(e);
+ patch_bra(e, bra_done, here(e));
+
+ /* ---- epilogue: combine the warps, write the partial ---- */
+ int ep[8], ea[8], eb[8];
+ for (unsigned h = 0; h < 8; h++) { ep[h] = V(e); ea[h] = V(e); eb[h] = V(e); }
+ int pout = V64(e), ppart = V64(e), pcnt = V64(e), oscale = V(e);
+ if (e->err) return -1;
+ ldc64(e, pout, OMEGA_DATTN256_ARG_OUT); ldc64(e, ppart, OMEGA_DATTN256_ARG_PART); ldc64(e, pcnt, OMEGA_DATTN256_ARG_CNT); ldc32(e, oscale, OMEGA_DATTN256_ARG_OUT_SCALE);
+ /* per-warp maxes to shared: lane 0 of warp w writes m[h] at SM_M + w*32 + h*4 */
+ imadi(e, R(a0), R(warp), 32u, NOREG); imadi(e, R(a0), R(one), OMEGA_DATTN256_SM_M, a0);
+ isetp_ge_u32(e, lane, one);
+ { Region r = region_skip_if_p0(e); for (unsigned h = 0; h < H; h++) { imadi(e, R(t1), R(one), h * 4u, a0); sts32(e, t1, R(m[h])); } region_end(e, r); }
+ bar_sync(e);
+ /* lanes 0..5 of every warp: M[lane] = max over the 8 warps; lanes of warp 0 write it at SM_M + 256 + lane*4 */
+ movi(e, ccnt, H);
+ isetp_ge_u32(e, lane, ccnt);
+ {
+ Region r = region_skip_if_p0(e);
+ imadi(e, R(a1), R(lane), 4u, NOREG); imadi(e, R(a1), R(one), OMEGA_DATTN256_SM_M, a1);
+ for (unsigned w = 0; w < 8; w++) { imadi(e, R(t1), R(one), w * 32u, a1); lds32(e, R(ep[w]), t1, w == 0); }
+ for (unsigned w = 1; w < 8; w++) fmaxx(e, R(ep[0]), R(ep[0]), R(ep[w]));
+ imadi(e, R(t1), R(one), 256u, a1);
+ sts32(e, t1, R(ep[0]));
+ region_end(e, r);
+ }
+ bar_sync(e);
+ movi(e, t1, OMEGA_DATTN256_SM_M + 256u);
+ lds128(e, qa4, t1, 0, 1); lds128(e, qb4, t1, 16, 0);
+ for (unsigned h = 0; h < H; h++) { fsub(e, R(ea[h]), R(m[h]), h < 4 ? S(qa4, h) : S(qb4, h - 4)); mufu(e, BW_IR_MUFU_EX2, R(ea[h]), R(ea[h])); }
+ for (unsigned h = 0; h < H; h++) { for (unsigned q = 0; q < 4; q++) fmul(e, S(acc[h], q), S(acc[h], q), R(ea[h])); fmul(e, R(l[h]), R(l[h]), R(ea[h])); }
+ /* per-warp l to shared, then the partial's m and l by threads 0..5 (l summed over the even warps: the odd ones repeat them) */
+ imadi(e, R(a0), R(warp), 32u, NOREG); imadi(e, R(a0), R(one), OMEGA_DATTN256_SM_L, a0);
+ isetp_ge_u32(e, lane, one);
+ { Region r = region_skip_if_p0(e); for (unsigned h = 0; h < H; h++) { imadi(e, R(t1), R(one), h * 4u, a0); sts32(e, t1, R(l[h])); } region_end(e, r); }
+ bar_sync(e);
+ int pp = V64(e), pa64 = V64(e), pb64 = V64(e);
+ imadr(e, t2, cy, splits, cx);
+ imadi(e, R(t2), R(t2), PBYTES, NOREG);
+ imadw(e, pp, t2, 1u, ppart);
+ isetp_ge_u32(e, tid, ccnt); /* tid >= 6 skips */
+ {
+ Region r = region_skip_if_p0(e);
+ imadi(e, R(a1), R(tid), 4u, NOREG); imadi(e, R(a1), R(one), OMEGA_DATTN256_SM_L, a1);
+ for (unsigned w = 0; w < 4; w++) { imadi(e, R(t1), R(one), w * 64u, a1); lds32(e, R(ep[w]), t1, w == 0); }
+ for (unsigned w = 1; w < 4; w++) fadd(e, R(ep[0]), R(ep[0]), R(ep[w]));
+ imadi(e, R(t1), R(tid), 4u, NOREG); imadi(e, R(t1), R(one), OMEGA_DATTN256_SM_M + 256u, t1);
+ lds32(e, R(ep[1]), t1, 1);
+ imadw(e, pa64, tid, 4u, pp);
+ stg(e, BW_IR_STG_E, pa64, R(ep[1]), udesc); /* m[h] */
+ imadw(e, pb64, one, 4u * H, pa64);
+ stg(e, BW_IR_STG_E, pb64, R(ep[0]), udesc); /* l[h] */
+ region_end(e, r);
+ }
+ /* acc: 6 rounds of one head through the s[][] region as r[w][256]: warp w writes its dim half, thread tid sums the
+ * 4 warps that hold dim tid (warps (tid >> 7) + 2k); the store and load addresses computed once */
+ imadi(e, R(a0), R(warp), 1024u, NOREG); imadi(e, R(a0), R(lane), 16u, a0);
+ andi(e, R(t1), R(warp), 1u); imadi(e, R(a0), R(t1), 512u, a0); imadi(e, R(a0), R(one), OMEGA_DATTN256_SM_S, a0);
+ shr(e, t1, tid, 7);
+ if (MUT == 5) movrz(e, R(t1));
+ imadi(e, R(a1), R(t1), 1024u, NOREG); imadi(e, R(a1), R(tid), 4u, a1); imadi(e, R(a1), R(one), OMEGA_DATTN256_SM_S, a1);
+ for (unsigned q = 0; q < 4; q++) imadi(e, R(eb[q]), R(one), q * 4u, a0);
+ for (unsigned w = 0; w < 4; w++) imadi(e, R(ea[w]), R(one), w * 2048u, a1);
+ imadw(e, pa64, tid, 4u, pp);
+ for (unsigned rd = 0; rd < H; rd++) {
+ for (unsigned q = 0; q < 4; q++) sts32(e, eb[q], S(acc[rd], q));
+ bar_sync(e);
+ for (unsigned w = 0; w < 4; w++) lds32(e, R(ep[w]), ea[w], w == 0);
+ for (unsigned w = 1; w < 4; w++) fadd(e, R(ep[0]), R(ep[0]), R(ep[w]));
+ imadw(e, pb64, one, 8u * H + rd * 1024u, pa64);
+ stg(e, BW_IR_STG_E, pb64, R(ep[0]), udesc);
+ bar_sync(e);
+ }
+ /* publish, count, the last CTA combines */
+ membar(e);
+ bar_sync(e);
+ movi(e, t1, OMEGA_DATTN256_SM_FLAG);
+ isetp_ge_u32(e, tid, one);
+ {
+ Region r = region_skip_if_p0(e);
+ imadw(e, pb64, cy, 4u, pcnt);
+ atom_add(e, ep[0], pb64, one, udesc);
+ sts32(e, t1, R(ep[0]));
+ region_end(e, r);
+ }
+ bar_sync(e);
+ lds32(e, R(ep[0]), t1, 1);
+ isetp_ge_u32(e, ep[0], splitsm1);
+ const int bra_last = bra_if_p0_fwd(e);
+ exit_k(e);
+ patch_bra(e, bra_last, here(e));
+ /* combine: thread tid, outputs o = tid + 256 r (head r, dim tid), r = 0..5 */
+ int ho = V(e), oidx = V(e), ma = V64(e), la = V64(e), aa = V64(e), num = V(e), den = V(e), mx = V(e), s_i = V(e), rr = V(e);
+ if (e->err) return -1;
+ movrz(e, R(ho));
+ mov(e, R(oidx), R(tid));
+ movrz(e, R(rr));
+ movi(e, ccnt, H);
+ imadr(e, t2, cy, splits, NOREG);
+ imadi(e, R(t2), R(t2), PBYTES, NOREG); /* byte offset of partials[cy][0] */
+ const int L_r = here(e);
+ loop_begin(e);
+ isetp_ge_u32(e, rr, ccnt);
+ const int bra_rend = bra_if_p0_fwd(e);
+ imadi(e, R(t1), R(ho), 4u, t2); imadw(e, ma, t1, 1u, ppart);
+ imadw(e, la, one, 4u * H, ma);
+ imadi(e, R(t1), R(oidx), 4u, t2); imadw(e, aa, t1, 1u, ppart); imadw(e, aa, one, 8u * H, aa);
+ movrz(e, R(num)); movrz(e, R(den)); movi(e, mx, NEG_BIG); movrz(e, R(s_i));
+ const int L_s = here(e);
+ loop_begin(e);
+ isetp_ge_u32(e, s_i, splits);
+ const int bra_send = bra_if_p0_fwd(e);
+ ldg32(e, BW_IR_LDG_STRONG_SYS, ep[0], ma, udesc, 1);
+ ldg32(e, BW_IR_LDG_STRONG_SYS, ep[1], la, udesc, 0);
+ ldg32(e, BW_IR_LDG_STRONG_SYS, ep[2], aa, udesc, 0);
+ if (MUT != 4) {
+ fmaxx(e, R(ep[3]), R(mx), R(ep[0]));
+ fsub(e, R(ep[4]), R(mx), R(ep[3])); mufu(e, BW_IR_MUFU_EX2, R(ep[4]), R(ep[4]));
+ fsub(e, R(ep[5]), R(ep[0]), R(ep[3])); mufu(e, BW_IR_MUFU_EX2, R(ep[5]), R(ep[5]));
+ mov(e, R(mx), R(ep[3]));
+ fmul(e, R(num), R(num), R(ep[4])); fmul(e, R(den), R(den), R(ep[4]));
+ } else {
+ movi(e, ep[5], 0x3f800000u);
+ }
+ ffma(e, R(num), R(ep[5]), R(ep[2]), R(num));
+ ffma(e, R(den), R(ep[5]), R(ep[1]), R(den));
+ imadw(e, ma, one, PBYTES, ma);
+ imadw(e, la, one, PBYTES, la);
+ imadw(e, aa, one, PBYTES, aa);
+ imadi(e, R(s_i), R(one), 1u, s_i);
+ bra(e, L_s);
+ loop_end(e);
+ patch_bra(e, bra_send, here(e));
+ mufu(e, BW_IR_MUFU_RCP, R(den), R(den));
+ fmul(e, R(num), R(num), R(den));
+ fmul(e, R(num), R(num), R(oscale));
+ imadi(e, R(t1), R(cy), H * 256u, oidx);
+ imadw(e, pb64, t1, 4u, pout);
+ stg(e, BW_IR_STG_E, pb64, R(num), udesc);
+ imadi(e, R(ho), R(one), 1u, ho);
+ imadi(e, R(oidx), R(one), 256u, oidx);
+ imadi(e, R(rr), R(one), 1u, rr);
+ bra(e, L_r);
+ loop_end(e);
+ patch_bra(e, bra_rend, here(e));
+ /* thread 0 resets the counter for the next launch (every other CTA of this head has already added) */
+ isetp_ge_u32(e, tid, one);
+ { Region r = region_skip_if_p0(e); imadw(e, pb64, cy, 4u, pcnt); stg(e, BW_IR_STG_STRONG_SYS, pb64, R(zero), udesc); region_end(e, r); }
+ tail(e);
+ if (e->err) return -1;
+ return omega_bw_regalloc_solve(prog);
+}
+
+int omega_decode_attn256_prog_stats(const OmegaDecodeAttn256Spec *spec, uint32_t *insns, uint32_t *gprs) {
+ static BlackwellIRProgram prog;
+ if (omega_blackwell_codegen_decode_attn256_prog(spec, &prog) != 0) return -1;
+ if (insns) *insns = (uint32_t)prog.count;
+ if (gprs) *gprs = prog.regalloc.peak_gpr_usage;
+ return 0;
+}
diff --git a/src/omega_blackwell_codegen_attn256.h b/src/omega_blackwell_codegen_attn256.h
new file mode 100644
index 000000000 ..110ef815c
--- /dev/null
+++ b/src/omega_blackwell_codegen_attn256.h
@@ -0,0 +1,104 @@
+#ifndef OMEGA_BLACKWELL_CODEGEN_ATTN256_H
+#define OMEGA_BLACKWELL_CODEGEN_ATTN256_H
+/*
+ * omega_blackwell_codegen_attn256: decode attention for Qwen3.8-27B in ONE launch per layer (omega-mv#544,
+ * 2026-10-18). A derivative of omega_blackwell_codegen_attn.h (head_dim 128, 8 q per kv) for the 27B's full-attention
+ * layers: 24 query heads, 4 KV heads (6 q per kv), head_dim 256, per-head RMSNorm on q and k (the caller folds the
+ * model's zero-centred weights to 1 + w), rotary embedding from a host-built cos/sin table, the new token's K/V
+ * appended to the GPU-resident bf16 cache inside the kernel, softmax over the whole context, output scaled by
+ * `out_scale` ready for the gate (sigmoid(gate) * out happens outside) and o_proj.
+ *
+ * Partial RoPE by permutation (design decision 1 of #544): the kernel rotates the standard half pairs (i, i + 128) of
+ * its 256-wide head with table row [cos 128 | sin 128]; the host builds the table so only the first P pairs rotate
+ * (inv_freq_j = theta^(-2j / rotary_dim), rotary_dim = 2P) and the rest are identity (cos 1, sin 0). The engine
+ * permutes the q and k dims (and q_norm / k_norm) at load with omega_dattn256_perm (omega_gpu_decode_attn256_api.h)
+ * so the model's rotate-half within its first rotary_dim dims lands on those P pairs. Scores are invariant to a
+ * shared q/k permutation; V and the output are not permuted. The K cache holds permuted rows.
+ *
+ * Grid: (splits, kv_heads). CTA (cx, cy) handles KV head cy and the positions [cx*per_split, min(+per_split, pos+1));
+ * the host picks splits = ceil((pos+1)/per_split), so no CTA is empty. 8 warps = 256 threads per CTA.
+ *
+ * Per CTA:
+ * prologue one norm + rope block for all 8 warps (8 f32 per lane): warp h < 6 builds q'[h] = RoPE(table[pos],
+ * RMSNorm(q[cy*6+h], q_norm, eps)) * qk_scale, staged in shared memory as q'[h][256]; warp 6 builds
+ * k_new = RoPE(RMSNorm(k[cy], k_norm)) the same way (k_norm lives 1024 bytes after q_norm); warp 7 runs
+ * the block on v[cy] (result discarded) and reloads the raw v. In the CTA whose range holds `pos` (the
+ * last split) warps 6 and 7 write k_new and v_new as bf16 into the cache at [cy][pos], then MEMBAR +
+ * BAR.SYNC, so its own stream reads them back.
+ * chunks of 256 positions: score pass (thread = position: the 512-byte bf16 K row streamed in 32 quads with a
+ * `depth`-deep prefetch, 6 dot products against q' from shared memory, scores to shared s[t][8], 6 used);
+ * V pass (warp pair: warp w handles positions (w>>1) + 4i of the chunk and the dims 128*(w&1) .. +127;
+ * lane = 4 dims, LDG.64 per position; online softmax per warp: running max, alpha = EX2(m_old - m_new)
+ * applied only when the max moved (warp-uniform branch), p = EX2(s - m), acc += p * v, l += p. The two
+ * warps of a pair see the same positions, so their (m, l) are bit-identical).
+ * epilogue warps combine (m over all 8, l over the even warps, acc over the 4 warps that hold each dim half)
+ * through shared memory and write the CTA partial {m[6], l[6], acc[6][256]} to partials[cy][cx]; then
+ * one ATOMG.ADD on counters[cy]; the last CTA of the KV head combines the partials with the usual max
+ * rescale and writes out[(cy*6+h)*256+d] * out_scale, and resets the counter.
+ *
+ * Numbers (f32 on the chip, double in the host reference, tolerances in tests/gpu_decode_attn256_test.c):
+ * scores in log2 units: q' already carries (1/sqrt(256)) * log2(e), so p = EX2(s - m) = exp((q.k)/sqrt(d) - M).
+ * bf16 K/V are widened by a 16-bit shift; the new K/V are rounded to bf16 round-to-nearest-even before storing.
+ *
+ * Shared memory stays under the 16 KiB QMD cap (14896 bytes), registers under the chip allocator's 126.
+ * The host simulator (tests/bw_warp_sim_k.h) runs this kernel at 8 warps; a simulator pass is never a chip result.
+ */
+#include "omega_blackwell_codegen.h"
+#include <stdint.h>
+
+#define OMEGA_DATTN256_HEAD_DIM 256u
+#define OMEGA_DATTN256_Q_PER_KV 6u
+#define OMEGA_DATTN256_KV_HEADS 4u
+#define OMEGA_DATTN256_Q_HEADS 24u
+#define OMEGA_DATTN256_WARPS 8u
+#define OMEGA_DATTN256_CHUNK 256u /* positions per score pass = threads per CTA */
+#define OMEGA_DATTN256_ROW_BYTES 512u /* one bf16 K or V row */
+#define OMEGA_DATTN256_ROPE_ROW_BYTES 1024u /* cos[128] then sin[128], f32 */
+#define OMEGA_DATTN256_PARTIAL_WORDS 1548u /* m[6], l[6], acc[6][256] */
+#define OMEGA_DATTN256_MAX_DEPTH 4u
+/* bytes past the last row of a K or V plane the prefetch may touch (clamped reads of the last rows) */
+#define OMEGA_DATTN256_PLANE_SLACK (OMEGA_DATTN256_MAX_DEPTH * 4u * OMEGA_DATTN256_ROW_BYTES + 64u)
+#define OMEGA_DATTN256_QKV_WORDS (OMEGA_DATTN256_Q_HEADS * 256u + 2u * OMEGA_DATTN256_KV_HEADS * 256u) /* 8192 */
+#define OMEGA_DATTN256_OUT_WORDS (OMEGA_DATTN256_Q_HEADS * 256u) /* 6144 */
+
+/* constant bank: every address at 0x380 + 8n, then the scalars */
+#define OMEGA_DATTN256_ARG_QKV 0x380u /* f32 [24*256 q | 4*256 k | 4*256 v] (the gate is NOT part of it) */
+#define OMEGA_DATTN256_ARG_KC 0x388u /* bf16 K cache base: [kv_head][max_pos][256], kv_stride bytes per head */
+#define OMEGA_DATTN256_ARG_VC 0x390u /* bf16 V cache base, same layout */
+#define OMEGA_DATTN256_ARG_ROPE 0x398u /* f32 [max_pos][cos 128 | sin 128] */
+#define OMEGA_DATTN256_ARG_QN 0x3a0u /* f32 [256] q_norm weight (1 + w, permuted) */
+#define OMEGA_DATTN256_ARG_KN 0x3a8u /* f32 [256] k_norm weight (1 + w, permuted); MUST be ARG_QN + 1024 bytes: the kernel addresses it so */
+#define OMEGA_DATTN256_ARG_OUT 0x3b0u /* f32 [24][256] */
+#define OMEGA_DATTN256_ARG_PART 0x3b8u /* f32 [kv_heads][splits][1548] */
+#define OMEGA_DATTN256_ARG_CNT 0x3c0u /* u32 [kv_heads], zero before the launch */
+#define OMEGA_DATTN256_ARG_POS 0x3c8u /* u32 position of the new token; context = pos + 1 */
+#define OMEGA_DATTN256_ARG_PER_SPLIT 0x3ccu /* u32 positions per CTA (multiple of 256) */
+#define OMEGA_DATTN256_ARG_SPLITS 0x3d0u /* u32 = grid_x */
+#define OMEGA_DATTN256_ARG_KV_STRIDE 0x3d4u /* u32 bytes per KV head plane */
+#define OMEGA_DATTN256_ARG_EPS 0x3d8u /* f32 rms eps */
+#define OMEGA_DATTN256_ARG_OUT_SCALE 0x3dcu /* f32 multiplier on the output */
+#define OMEGA_DATTN256_ARG_QK_SCALE 0x3e0u /* f32 (1/sqrt(256)) * log2(e) */
+#define OMEGA_DATTN256_ARGS_WORDS 25u
+
+/* shared memory map (bytes) */
+#define OMEGA_DATTN256_SM_Q 0u /* q'[6][256] f32: 6144 (warps 6, 7 stage k and v at 6144.. 8191: inside SM_S, unused then) */
+#define OMEGA_DATTN256_SM_S 6144u /* s[256][8] f32 (6 used): 8192; reused as the reduce buffer r[8 warps][256] */
+#define OMEGA_DATTN256_SM_M 14336u /* m[8 warps][8] then the head maxes M[8]: 256 + 32 */
+#define OMEGA_DATTN256_SM_L 14624u /* l[8 warps][8]: 256 */
+#define OMEGA_DATTN256_SM_FLAG 14880u /* the atomic's old value: 16 */
+#define OMEGA_DATTN256_SHARED_BYTES 14896u
+
+typedef struct {
+ uint32_t depth; /* prefetch depth of the K and V streams, 1..4 */
+ int mutant; /* TEST ONLY. 0 none; 1 no RoPE on q and k; 2 V read one position late; 3 the new K/V are not
+ * written to the cache; 4 the cross-split combine ignores the max (differs only when splits > 1);
+ * 5 the odd warps' dim half is dropped from the partial (dims 128..255 wrong). */
+} OmegaDecodeAttn256Spec;
+
+/* Builds the IR program (register-allocated) into *prog. 0 ok, -1 refused (depth 0 or > 4, mutant outside 0..5,
+ * or the program outgrew BW_MAX_IR_INSNS / BW_MAX_VREGS). */
+int omega_blackwell_codegen_decode_attn256_prog(const OmegaDecodeAttn256Spec *spec, BlackwellIRProgram *prog);
+/* Instruction and peak-register counts of the program (host, no device). */
+int omega_decode_attn256_prog_stats(const OmegaDecodeAttn256Spec *spec, uint32_t *insns, uint32_t *gprs);
+
+#endif
diff --git a/src/omega_gpu_decode_attn256_api.c b/src/omega_gpu_decode_attn256_api.c
new file mode 100644
index 000000000 ..6a868d851
--- /dev/null
+++ b/src/omega_gpu_decode_attn256_api.c
@@ -0,0 +1,265 @@
+/*
+ * omega_gpu_decode_attn256_api.c: resident KV cache, RoPE table and launch for the head_dim 256 decode attention
+ * (omega-mv#544). A derivative of omega_gpu_decode_attn_api.c (see the header); the double-precision host reference
+ * lives in tests/gpu_decode_attn256_test.c so the library links without libm. Session use mirrors the 128 kernel:
+ * every buffer 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 call.
+ */
+#include "omega_gpu_decode_attn256_api.h"
+#include "omega_gpu_session.h"
+#include "omega_gpu_fmt.h"
+#include "omega_gpu_hostmath.h"
+#include <string.h>
+#include "omega_gpu_cmdlist.h"
+
+#define MARKER_TIMEOUT_MS 20000ull
+#define POISON_F32 (-999.0f)
+#define HD OMEGA_DATTN256_HEAD_DIM
+#define RB OMEGA_DATTN256_ROW_BYTES
+#define KVH OMEGA_DATTN256_KV_HEADS
+#define OUTW OMEGA_DATTN256_OUT_WORDS
+
+struct OmegaGpuDecodeAttn256Cache {
+ uint32_t layers, max_pos, max_splits, rotary_dim;
+ double theta;
+ uint64_t plane_bytes; /* one K or V plane of a layer: 4 * max_pos * 512 + slack */
+ OmegaGpuMem kv[OMEGA_GPU_DATTN256_MAX_LAYERS]; /* [K plane | V plane] per layer */
+ OmegaGpuMem rope, norms, part, cnt, qkv, out;
+};
+
+typedef struct {
+ bool valid;
+ OmegaDecodeAttn256Spec spec;
+ OmegaBlackwellKernel kernel;
+ OmegaGpuMem code;
+} Slot;
+
+static struct {
+ bool hooked;
+ Slot slot;
+ uint32_t depth, per_split;
+ int mutant;
+} g;
+static int g_rec; /* 1 while a record call runs (lock held): kernel_for must not evict */
+
+static void slot_clear_locked(void) { if (g.slot.valid) omega_gpu_session_free(&g.slot.code); memset(&g.slot, 0, sizeof g.slot); }
+static void on_session_close(void) { memset(&g.slot, 0, sizeof g.slot); }
+static OmegaGpuSession *dev_open_locked(void) {
+ if (!g.hooked) { (void)omega_gpu_session_on_close(on_session_close); g.hooked = true; }
+ return omega_gpu_session_open();
+}
+static uint32_t gpr_declared(uint32_t peak) { return omega_bw_gpr_declared(peak); }
+
+void omega_gpu_decode_attn256_set_depth(uint32_t depth) { omega_gpu_session_lock(); g.depth = depth; slot_clear_locked(); omega_gpu_session_unlock(); }
+void omega_gpu_decode_attn256_set_per_split(uint32_t per_split) { omega_gpu_session_lock(); g.per_split = per_split; omega_gpu_session_unlock(); }
+void omega_gpu_decode_attn256_test_set_mutant(int mutant) { omega_gpu_session_lock(); g.mutant = mutant; slot_clear_locked(); omega_gpu_session_unlock(); }
+
+/* ---- host math ---- */
+void omega_dattn256_rope_row(uint32_t pos, double theta, uint32_t rotary_dim, float *row256) {
+ const uint32_t P = rotary_dim / 2u;
+ for (unsigned i = 0; i < 128; i++) {
+ if (i < P) {
+ double inv = omega_hostmath_pow(theta, -(double)(2 * i) / (double)rotary_dim), ang = (double)pos * inv, s, c;
+ omega_hostmath_sincos(ang, &s, &c);
+ row256[i] = (float)c; row256[128 + i] = (float)s;
+ } else { row256[i] = 1.0f; row256[128 + i] = 0.0f; }
+ }
+}
+/* ---- cache ---- */
+int omega_gpu_decode_attn256_cache_alloc(uint32_t layers, uint32_t max_pos, double rope_theta, uint32_t rotary_dim, OmegaGpuDecodeAttn256Cache **out) {
+ if (!out) return OMEGA_GPU_DATTN_BAD_ARGS;
+ *out = NULL;
+ if (layers == 0 || layers > OMEGA_GPU_DATTN256_MAX_LAYERS || max_pos == 0 || max_pos > OMEGA_GPU_DATTN256_MAX_POS || max_pos % OMEGA_DATTN256_CHUNK ||
+ !(rope_theta > 0) || rotary_dim < 2 || rotary_dim > HD || rotary_dim % 2) return OMEGA_GPU_DATTN_BAD_ARGS;
+ OmegaGpuDecodeAttn256Cache *c = omega_gpu_host_calloc(1, sizeof *c);
+ if (!c) return OMEGA_GPU_DATTN_CHIP_FAIL;
+ c->layers = layers; c->max_pos = max_pos; c->theta = rope_theta; c->rotary_dim = rotary_dim;
+ c->max_splits = max_pos / OMEGA_DATTN256_CHUNK;
+ c->plane_bytes = (uint64_t)KVH * max_pos * RB + OMEGA_DATTN256_PLANE_SLACK;
+ int rc = OMEGA_GPU_DATTN_OK;
+ omega_gpu_session_lock();
+ if (!dev_open_locked()) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ for (uint32_t L = 0; L < layers && rc == OMEGA_GPU_DATTN_OK; L++) if (omega_gpu_session_alloc((size_t)(2 * c->plane_bytes), &c->kv[L]) != 0) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ if (rc == OMEGA_GPU_DATTN_OK && (omega_gpu_session_alloc((size_t)max_pos * OMEGA_DATTN256_ROPE_ROW_BYTES, &c->rope) != 0 ||
+ omega_gpu_session_alloc((size_t)layers * 2 * HD * 4, &c->norms) != 0 ||
+ omega_gpu_session_alloc((size_t)KVH * c->max_splits * OMEGA_DATTN256_PARTIAL_WORDS * 4, &c->part) != 0 ||
+ omega_gpu_session_alloc(64, &c->cnt) != 0 ||
+ omega_gpu_session_alloc((size_t)OMEGA_DATTN256_QKV_WORDS * 4, &c->qkv) != 0 ||
+ omega_gpu_session_alloc((size_t)OUTW * 4, &c->out) != 0)) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ if (rc == OMEGA_GPU_DATTN_OK) {
+ float *r = c->rope.cpu;
+ for (uint32_t p = 0; p < max_pos; p++) omega_dattn256_rope_row(p, rope_theta, rotary_dim, r + (size_t)p * 256);
+ memset(c->cnt.cpu, 0, 64);
+ memset(c->norms.cpu, 0, (size_t)layers * 2 * HD * 4);
+ for (uint32_t L = 0; L < layers; L++) memset(c->kv[L].cpu, 0, (size_t)(2 * c->plane_bytes));
+ if (omega_gpu_session_sync_to_gpu(&c->rope) != 0 || omega_gpu_session_sync_to_gpu(&c->cnt) != 0 || omega_gpu_session_sync_to_gpu(&c->norms) != 0) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ for (uint32_t L = 0; L < layers && rc == OMEGA_GPU_DATTN_OK; L++) if (omega_gpu_session_sync_to_gpu(&c->kv[L]) != 0) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ }
+ omega_gpu_session_unlock();
+ if (rc != OMEGA_GPU_DATTN_OK) { omega_gpu_decode_attn256_cache_free(c); return rc; }
+ *out = c;
+ return OMEGA_GPU_DATTN_OK;
+}
+void omega_gpu_decode_attn256_cache_free(OmegaGpuDecodeAttn256Cache *c) {
+ if (!c) return;
+ omega_gpu_session_lock();
+ for (uint32_t L = 0; L < c->layers; L++) if (c->kv[L].cpu) omega_gpu_session_free(&c->kv[L]);
+ OmegaGpuMem *ms[] = { &c->rope, &c->norms, &c->part, &c->cnt, &c->qkv, &c->out };
+ for (unsigned i = 0; i < 6; i++) if (ms[i]->cpu) omega_gpu_session_free(ms[i]);
+ omega_gpu_session_unlock();
+ omega_gpu_host_free(c);
+}
+int omega_gpu_decode_attn256_set_norms(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, const float *q_norm, const float *k_norm) {
+ if (!c || layer >= c->layers || !q_norm || !k_norm) return OMEGA_GPU_DATTN_BAD_ARGS;
+ omega_gpu_session_lock();
+ float *n = (float *)c->norms.cpu + (size_t)layer * 2 * HD;
+ memcpy(n, q_norm, HD * 4); memcpy(n + HD, k_norm, HD * 4);
+ int rc = omega_gpu_session_sync_to_gpu(&c->norms) == 0 ? OMEGA_GPU_DATTN_OK : OMEGA_GPU_DATTN_CHIP_FAIL;
+ omega_gpu_session_unlock();
+ return rc;
+}
+static uint16_t *row_ptr(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t kv_head, uint32_t pos, int plane) {
+ return (uint16_t *)((uint8_t *)c->kv[layer].cpu + (plane ? c->plane_bytes : 0) + ((size_t)kv_head * c->max_pos + pos) * RB);
+}
+int omega_gpu_decode_attn256_cache_write(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t kv_head, uint32_t pos, uint32_t count, const uint16_t *k, const uint16_t *v) {
+ if (!c || layer >= c->layers || kv_head >= KVH || pos >= c->max_pos || count == 0 || count > c->max_pos - pos || !k || !v) return OMEGA_GPU_DATTN_BAD_ARGS;
+ omega_gpu_session_lock();
+ memcpy(row_ptr(c, layer, kv_head, pos, 0), k, (size_t)count * RB); memcpy(row_ptr(c, layer, kv_head, pos, 1), v, (size_t)count * RB);
+ int rc = omega_gpu_session_sync_to_gpu(&c->kv[layer]) == 0 ? OMEGA_GPU_DATTN_OK : OMEGA_GPU_DATTN_CHIP_FAIL;
+ omega_gpu_session_unlock();
+ return rc;
+}
+int omega_gpu_decode_attn256_cache_read(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t kv_head, uint32_t pos, uint16_t *k, uint16_t *v) {
+ if (!c || layer >= c->layers || kv_head >= KVH || pos >= c->max_pos || !k || !v) return OMEGA_GPU_DATTN_BAD_ARGS;
+ omega_gpu_session_lock();
+ int rc = omega_gpu_session_sync_to_cpu(&c->kv[layer]) == 0 ? OMEGA_GPU_DATTN_OK : OMEGA_GPU_DATTN_CHIP_FAIL;
+ if (rc == OMEGA_GPU_DATTN_OK) { memcpy(k, row_ptr(c, layer, kv_head, pos, 0), RB); memcpy(v, row_ptr(c, layer, kv_head, pos, 1), RB); }
+ omega_gpu_session_unlock();
+ return rc;
+}
+
+/* ---- kernel ---- */
+static int kernel_for(const OmegaDecodeAttn256Spec *spec, Slot **out, bool *hit) {
+ Slot *s = &g.slot;
+ if (s->valid && memcmp(&s->spec, spec, sizeof *spec) == 0) { *out = s; *hit = true; return OMEGA_GPU_DATTN_OK; }
+ if (g_rec && s->valid) { omega_gpu_session_set_error("decode attn256 record: kernel cache miss would evict the resident kernel (warm up before recording)"); return OMEGA_GPU_DATTN_TOO_LARGE; }
+ slot_clear_locked();
+ BlackwellIRProgram *prog = omega_gpu_host_calloc(1, sizeof *prog);
+ if (!prog) { omega_gpu_session_set_error("decode attn256 codegen: host memory"); return OMEGA_GPU_DATTN_CODEGEN_FAIL; }
+ int cg = omega_blackwell_codegen_decode_attn256_prog(spec, prog);
+ 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("decode attn256 codegen refused the spec"); return OMEGA_GPU_DATTN_CODEGEN_FAIL; }
+ if ((uint64_t)OMEGA_DATTN256_CHUNK * gpr_declared(prog->regalloc.peak_gpr_usage) > 65536u) { omega_gpu_host_free(prog); omega_gpu_session_set_error("decode attn256: register file"); return OMEGA_GPU_DATTN_TOO_LARGE; }
+ 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);
+ omega_gpu_host_free(prog);
+ if (cg != 0 || !kernel.code || kernel.code_size != need) { omega_gpu_session_free(&code); omega_gpu_session_set_error("decode attn256 encode"); 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;
+ *out = s; *hit = false;
+ return OMEGA_GPU_DATTN_OK;
+}
+
+/* rec non-NULL (record path, caller holds the session lock): qkv / out are the device buffers dev_qkv / dev_out, the
+ * launch is appended to rec instead of submitted, nothing is staged, poisoned or read back. */
+static int dattn_core(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t pos, const float *qkv, float eps, float out_scale,
+ float *out, OmegaGpuDecodeAttn256Info *info, OmegaGpuCmdList *rec, uint64_t dev_qkv, uint64_t dev_out) {
+ uint64_t t0 = omega_gpu_session_now_ns();
+ if (info) memset(info, 0, sizeof *info);
+ if (!c || layer >= c->layers || pos >= c->max_pos || (rec ? (!dev_qkv || !dev_out) : (!qkv || !out))) return OMEGA_GPU_DATTN_BAD_ARGS;
+ const uint32_t per = g.per_split ? g.per_split : OMEGA_GPU_DATTN256_PER_SPLIT;
+ if (per % OMEGA_DATTN256_CHUNK) return OMEGA_GPU_DATTN_BAD_ARGS;
+ const uint32_t splits = (pos + per) / per; /* ceil((pos + 1) / per) */
+ if (splits > c->max_splits) return OMEGA_GPU_DATTN_TOO_LARGE;
+ OmegaDecodeAttn256Spec spec; memset(&spec, 0, sizeof spec);
+ spec.depth = g.depth ? g.depth : OMEGA_GPU_DATTN256_DEPTH; spec.mutant = g.mutant;
+
+ if (!rec) omega_gpu_session_lock();
+#define UNLOCK() do { if (!rec) omega_gpu_session_unlock(); } while (0)
+ int rc = OMEGA_GPU_DATTN_OK;
+ if (!dev_open_locked()) { UNLOCK(); return OMEGA_GPU_DATTN_CHIP_FAIL; }
+ Slot *ks = NULL; bool hit = false;
+ g_rec = rec != NULL;
+ rc = kernel_for(&spec, &ks, &hit);
+ g_rec = 0;
+ if (rc != OMEGA_GPU_DATTN_OK) { UNLOCK(); return rc; }
+ float *od = c->out.cpu;
+ if (!rec) {
+ memcpy(c->qkv.cpu, qkv, (size_t)OMEGA_DATTN256_QKV_WORDS * 4);
+ for (size_t i = 0; i < OUTW; i++) od[i] = POISON_F32;
+ memset(c->cnt.cpu, 0, 64);
+ if (omega_gpu_session_sync_to_gpu(&c->qkv) != 0 || omega_gpu_session_sync_to_gpu(&c->out) != 0 || omega_gpu_session_sync_to_gpu(&c->cnt) != 0) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ }
+
+ uint32_t args[OMEGA_DATTN256_ARGS_WORDS];
+ const uint64_t kc = c->kv[layer].va, vc = kc + c->plane_bytes, nm = c->norms.va + (uint64_t)layer * 2 * HD * 4;
+ const uint64_t qkv_va = rec ? dev_qkv : c->qkv.va, out_va = rec ? dev_out : c->out.va;
+ float fe = eps, fo = out_scale, fq = (float)(0.0625 * 1.4426950408889634 ); /* log2(e) / sqrt(256) */
+ uint32_t ue, uo, uq; memcpy(&ue, &fe, 4); memcpy(&uo, &fo, 4); memcpy(&uq, &fq, 4);
+#define A64(i, v) do { args[i] = (uint32_t)(v); args[(i) + 1] = (uint32_t)((v) >> 32); } while (0)
+ A64(0, qkv_va); A64(2, kc); A64(4, vc); A64(6, c->rope.va); A64(8, nm); A64(10, nm + HD * 4); A64(12, out_va); A64(14, c->part.va); A64(16, c->cnt.va);
+#undef A64
+ args[18] = pos; args[19] = per; args[20] = splits; args[21] = (uint32_t)(c->max_pos * RB); args[22] = ue; args[23] = uo; args[24] = uq;
+ if (info) {
+ info->layer = layer; info->pos = pos; info->splits = splits; info->per_split = per; info->depth = spec.depth;
+ info->grid_x = splits; info->grid_y = KVH; info->threads = OMEGA_DATTN256_CHUNK;
+ info->kv_bytes = 2ull * KVH * (pos + 1ull) * RB;
+ info->kernel_cache_hit = hit;
+ }
+ if (rc == OMEGA_GPU_DATTN_OK) {
+ OmegaGpuLaunch L = {
+ .code_va = ks->code.va, .gpr_count = gpr_declared(ks->kernel.gpr_count),
+ .threads_x = OMEGA_DATTN256_CHUNK, .threads_y = 1, .grid_x = splits, .grid_y = KVH,
+ .num_elements = (size_t)OUTW,
+ .args = args, .n_args = OMEGA_DATTN256_ARGS_WORDS, .timeout_ms = MARKER_TIMEOUT_MS,
+ .shared_bytes = OMEGA_DATTN256_SHARED_BYTES,
+ };
+ if (!omega_bw_gpr_declared_ok(L.gpr_count, ks->kernel.gpr_count)) { omega_gpu_session_set_error("declared registers below peak + 2: refusing to launch"); rc = OMEGA_GPU_DATTN_CHIP_FAIL; }
+ else if (rec) { if (omega_gpu_cmdlist_add(rec, &L) < 0) rc = OMEGA_GPU_DATTN_CHIP_FAIL; }
+ else if (omega_gpu_session_launch(&L, info ? &info->elapsed_ns : NULL, info ? &info->completion_marker : NULL) != 0) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ }
+ if (rc == OMEGA_GPU_DATTN_OK && !rec && (omega_gpu_session_sync_to_cpu(&c->out) != 0 || omega_gpu_session_sync_to_cpu(&c->cnt) != 0)) rc = OMEGA_GPU_DATTN_CHIP_FAIL;
+ if (rc == OMEGA_GPU_DATTN_OK && !rec) {
+ size_t unchanged = 0;
+ for (size_t i = 0; i < OUTW; i++) if (od[i] == POISON_F32) unchanged++;
+ const uint32_t *cn = c->cnt.cpu;
+ if (unchanged) { omega_gpu_session_set_error("decode attn256: output poison survived"); rc = OMEGA_GPU_DATTN_CHIP_FAIL; }
+ else if (cn[0] | cn[1] | cn[2] | cn[3]) { omega_gpu_session_set_error("decode attn256: a split counter did not return to zero"); rc = OMEGA_GPU_DATTN_CHIP_FAIL; }
+ else memcpy(out, od, (size_t)OUTW * 4);
+ }
+ UNLOCK();
+#undef UNLOCK
+ if (info) info->call_ns = omega_gpu_session_now_ns() - t0;
+ return rc;
+}
+
+int omega_gpu_decode_attn256_cache_view(const OmegaGpuDecodeAttn256Cache *c, uint32_t layer, OmegaGpuDecodeAttn256CacheView *v) {
+ if (!c || !v || layer >= c->layers) return OMEGA_GPU_DATTN_BAD_ARGS;
+ v->layers = c->layers; v->max_pos = c->max_pos; v->rotary_dim = c->rotary_dim; v->theta = c->theta;
+ v->k_va = c->kv[layer].va; v->v_va = c->kv[layer].va + c->plane_bytes;
+ v->rope_va = c->rope.va;
+ v->q_norm_va = c->norms.va + (uint64_t)layer * 2 * HD * 4; v->k_norm_va = v->q_norm_va + HD * 4;
+ v->part_va = c->part.va; v->cnt_va = c->cnt.va;
+ return OMEGA_GPU_DATTN_OK;
+}
+
+int omega_gpu_decode_attn256(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t pos, const float *qkv, float eps, float out_scale, float *out, OmegaGpuDecodeAttn256Info *info) {
+ return dattn_core(c, layer, pos, qkv, eps, out_scale, out, info, NULL, 0, 0);
+}
+
+int omega_gpu_decode_attn256_record(OmegaGpuCmdList *cl, OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t pos, uint64_t qkv_va,
+ float eps, float out_scale, uint64_t out_va) {
+ if (!cl) return OMEGA_GPU_DATTN_BAD_ARGS;
+ return dattn_core(c, layer, pos, NULL, eps, out_scale, NULL, NULL, cl, qkv_va, out_va);
+}
+
+int omega_gpu_decode_attn256_counters_check(OmegaGpuDecodeAttn256Cache *c) {
+ if (!c || !c->cnt.cpu) return OMEGA_GPU_DATTN_BAD_ARGS;
+ if (omega_gpu_session_sync_to_cpu(&c->cnt) != 0) return OMEGA_GPU_DATTN_CHIP_FAIL;
+ const uint32_t *cn = c->cnt.cpu;
+ if (cn[0] | cn[1] | cn[2] | cn[3]) { omega_gpu_session_set_error("decode attn256: a split counter did not return to zero"); return OMEGA_GPU_DATTN_CHIP_FAIL; }
+ return OMEGA_GPU_DATTN_OK;
+}
diff --git a/src/omega_gpu_decode_attn256_api.h b/src/omega_gpu_decode_attn256_api.h
new file mode 100644
index 000000000 ..6f7d4c796
--- /dev/null
+++ b/src/omega_gpu_decode_attn256_api.h
@@ -0,0 +1,119 @@
+#ifndef OMEGA_GPU_DECODE_ATTN256_API_H
+#define OMEGA_GPU_DECODE_ATTN256_API_H
+/*
+ * omega_gpu_decode_attn256_api: one-launch decode attention for Qwen3.8-27B (omega-mv#544, 2026-10-18): head_dim 256,
+ * 24 query heads over 4 KV heads, partial RoPE by permutation. A derivative of omega_gpu_decode_attn_api.h (the 30B's
+ * head_dim 128 kernel, untouched); the kernel is described in omega_blackwell_codegen_attn256.h. Return codes and the
+ * bf16 helpers are shared with that API (OMEGA_GPU_DATTN_*, omega_dattn_bf16_rne).
+ *
+ * int omega_gpu_decode_attn256_cache_alloc(uint32_t layers, uint32_t max_pos, double rope_theta, uint32_t rotary_dim,
+ * OmegaGpuDecodeAttn256Cache **out);
+ * GPU-resident bf16 KV cache for `layers` layers of 4 KV heads x `max_pos` positions x 256 (one allocation per
+ * layer, 2 * 4 * max_pos * 512 bytes + slack), the RoPE table (f32 [max_pos][cos 128 | sin 128], built in double:
+ * pair j < rotary_dim / 2 rotates with inv_freq theta^(-2j / rotary_dim), the rest is identity), the per-layer
+ * q_norm / k_norm weights, the cross-split partials and counters. rotary_dim: even, 2..256 (64 for Qwen3.8-27B,
+ * 256 = full RoPE). Opens the session. The Qwen3.8-27B cache at 131072 positions is 512 MiB per layer.
+ * void omega_gpu_decode_attn256_cache_free(OmegaGpuDecodeAttn256Cache *c);
+ * int omega_gpu_decode_attn256_set_norms(c, layer, q_norm, k_norm): 256 f32 each, ALREADY folded to 1 + w (the model's
+ * zero-centred RMSNorm) and permuted with omega_dattn256_perm_vec.
+ * int omega_gpu_decode_attn256(c, layer, pos, qkv, eps, out_scale, out, info);
+ * qkv: f32 [8192] = q 24 heads x 256 (permuted dims, gate NOT included), then k 4 x 256 (permuted), then v 4 x 256
+ * (NOT permuted); pos: the new token's position (< max_pos; positions 0..pos-1 already in the cache for that
+ * layer). Appends K/V at pos and writes out[24][256] * out_scale in the model's dim order (V and the output are
+ * never permuted). The gate (sigmoid of the second half of each head's q_proj rows) is applied by the caller.
+ * Returns OMEGA_GPU_DATTN_OK or an OMEGA_GPU_DATTN_* code; the chip failure text is in
+ * omega_gpu_decode_attn_last_error().
+ * Test helpers: cache_write moves `count` consecutive bf16 K and V rows (256 each; K rows in permuted order) of a layer
+ * and KV head into the cache in one sync; cache_read returns one row of each.
+ *
+ * The permutation (design decision 1 of #544; rotary_dim R = 2P, P pairs; slot i of the kernel's head holds the model's
+ * dim omega_dattn256_perm_slot(i, R)):
+ * i < P: model dim i (first half of the rotated dims)
+ * P <= i < 128: model dim R + (i - P) (unrotated dims, in order)
+ * 128 <= i < 128+P: model dim P + (i - 128) (second half of the rotated dims: the partner of slot i - 128)
+ * 128+P <= i: model dim i (the rest of the unrotated dims)
+ * so the kernel's rotate-half pairs (i, i + 128), i < P, are exactly the model's pairs (j, j + P) and the table's
+ * identity pairs i >= P leave the other dims alone. R = 256 gives the identity permutation. q, k and the two norm
+ * weights are permuted; the K cache holds permuted rows; V and the output are not permuted.
+ *
+ * Launch shape: grid (splits, 4), 256 threads, splits = ceil((pos + 1) / per_split), per_split a multiple of 256.
+ * Every buffer is GPU-uncached host-visible session memory (nvos.h:1117 rule), launched through
+ * omega_gpu_session_launch. The counters must be zero before a launch; the last CTA of each KV head resets its
+ * counter, and the API verifies the four words are zero after each call.
+ */
+#include "omega_blackwell_codegen_attn256.h"
+#include "omega_gpu_decode_attn_api.h"
+#include <stdint.h>
+#include <stddef.h>
+
+#define OMEGA_GPU_DATTN256_PER_SPLIT 256u
+#define OMEGA_GPU_DATTN256_MAX_LAYERS 64u
+#define OMEGA_GPU_DATTN256_MAX_POS 131072u
+#define OMEGA_GPU_DATTN256_DEPTH 4u
+
+typedef struct OmegaGpuDecodeAttn256Cache OmegaGpuDecodeAttn256Cache;
+
+typedef struct {
+ uint32_t layer, pos, splits, per_split, depth;
+ uint32_t grid_x, grid_y, threads;
+ uint64_t kv_bytes; /* K + V bytes the launch streams: 2 * 4 * (pos + 1) * 512 */
+ uint64_t elapsed_ns; /* marker-to-marker chip time */
+ uint64_t call_ns; /* whole call */
+ uint32_t completion_marker;
+ int kernel_cache_hit;
+} OmegaGpuDecodeAttn256Info;
+
+int omega_gpu_decode_attn256_cache_alloc(uint32_t layers, uint32_t max_pos, double rope_theta, uint32_t rotary_dim, OmegaGpuDecodeAttn256Cache **out);
+void omega_gpu_decode_attn256_cache_free(OmegaGpuDecodeAttn256Cache *c);
+int omega_gpu_decode_attn256_set_norms(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, const float *q_norm, const float *k_norm);
+int omega_gpu_decode_attn256(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t pos, const float *qkv, float eps,
+ float out_scale, float *out, OmegaGpuDecodeAttn256Info *info);
+/* Record path (decode graph; omega_gpu_cmdlist.h): the launch appended to cl instead of submitted. qkv_va: f32 [8192] on
+ * the device; out_va: f32 [24 * 256]. The caller holds omega_gpu_session_lock(). A kernel cache miss that would evict
+ * the resident kernel is refused (warm up with one non-record call first). */
+struct OmegaGpuCmdList;
+int omega_gpu_decode_attn256_record(struct OmegaGpuCmdList *cl, OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t pos, uint64_t qkv_va,
+ float eps, float out_scale, uint64_t out_va);
+/* Caller holds the lock, after the list ran: OK when the four split counters are zero, else CHIP_FAIL. */
+int omega_gpu_decode_attn256_counters_check(OmegaGpuDecodeAttn256Cache *c);
+int omega_gpu_decode_attn256_cache_write(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t kv_head, uint32_t pos, uint32_t count,
+ const uint16_t *k_bf16, const uint16_t *v_bf16); /* count rows from pos, one sync */
+int omega_gpu_decode_attn256_cache_read(OmegaGpuDecodeAttn256Cache *c, uint32_t layer, uint32_t kv_head, uint32_t pos,
+ uint16_t *k_bf16, uint16_t *v_bf16);
+/* Read-only view of a layer of the cache for the prefill attention: device addresses only. */
+typedef struct {
+ uint32_t layers, max_pos, rotary_dim;
+ double theta;
+ uint64_t k_va, v_va; /* K and V plane bases of `layer` (row (kv_head, pos) at + (kv_head * max_pos + pos) * 512) */
+ uint64_t rope_va; /* f32 [max_pos][cos 128 | sin 128] */
+ uint64_t q_norm_va, k_norm_va; /* f32 [256] each for `layer` */
+ uint64_t part_va, cnt_va; /* the cross-split partials and counters (prefill may reuse them) */
+} OmegaGpuDecodeAttn256CacheView;
+int omega_gpu_decode_attn256_cache_view(const OmegaGpuDecodeAttn256Cache *c, uint32_t layer, OmegaGpuDecodeAttn256CacheView *out);
+
+/* ---- measurement knobs (tests; each clears the kernel cache) ---- */
+void omega_gpu_decode_attn256_set_depth(uint32_t depth); /* 0 = default (OMEGA_GPU_DATTN256_DEPTH) */
+void omega_gpu_decode_attn256_set_per_split(uint32_t per_split); /* 0 = default; multiple of 256 */
+void omega_gpu_decode_attn256_test_set_mutant(int mutant); /* TEST ONLY: OmegaDecodeAttn256Spec.mutant */
+
+/* ---- host side ---- */
+/* RoPE table row for `pos`: cos[128] then sin[128], f32 from double; pairs j < rotary_dim/2 rotate with
+ * inv_freq[j] = theta^(-2j/rotary_dim), the rest are cos 1, sin 0 */
+void omega_dattn256_rope_row(uint32_t pos, double theta, uint32_t rotary_dim, float *row256);
+/* the model dim held by kernel slot i (see above); rotary_dim even, 2..256 */
+static inline uint32_t omega_dattn256_perm_slot(uint32_t i, uint32_t rotary_dim) {
+ const uint32_t P = rotary_dim / 2u;
+ if (i < 128u) return i < P ? i : rotary_dim + (i - P);
+ const uint32_t j = i - 128u;
+ return j < P ? P + j : i;
+}
+/* dst[i] = src[perm_slot(i)] for 256 f32 (q, k, norm weights); src and dst must not overlap */
+static inline void omega_dattn256_perm_vec(const float *src, float *dst, uint32_t rotary_dim) {
+ for (uint32_t i = 0; i < 256u; i++) dst[i] = src[omega_dattn256_perm_slot(i, rotary_dim)];
+}
+static inline void omega_dattn256_perm_vec_bf16(const uint16_t *src, uint16_t *dst, uint32_t rotary_dim) {
+ for (uint32_t i = 0; i < 256u; i++) dst[i] = src[omega_dattn256_perm_slot(i, rotary_dim)];
+}
+/* The double-precision reference of the whole layer step lives in tests/gpu_decode_attn256_test.c (libm). */
+
+#endif
diff --git a/tests/.crumb b/tests/.crumb
index 0d0790dd8 ..6b98163fd 100644
--- a/tests/.crumb
+++ b/tests/.crumb
@@ -296,14 +296,14 @@
}
],
"children_root": "sha256:ddc3618190458bc5073e3bee67ffccc68a2ee9f065f2cb0d86545386a29fddf8 ",
- "compiled_at": "2026-10-18T13:02:58Z",
+ "compiled_at": "2026-10-18T13:06:21Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:edf167b3607974785ec9cb7478d8d26d562cb5c83107322efa79954482d34c39 ",
+ "digest": "sha256:6947682ecc9b0f6e6704ae8d7ba4121075d6b219d6317b17acf7fe7b412f3892 ",
"evidence_files": 16,
"evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a ",
- "files": 1271,
- "generated_at_commit": "e7356996557da557d63de0f56558a335b5c25223 ",
- "source_tree": "sha256:d924aecc5ebf4daf3873b99f7b03db23db318b098329b12028f4673a3bc7b289 "
+ "files": 1272,
+ "generated_at_commit": "c3ab69f66d6b2a2bce7efe425d80b1306e1140ed ",
+ "source_tree": "sha256:f47111f6aad8c35e914abd28def6546c2c6ce9fe525c55538cd1b2d1f37f5670 "
},
"owner_lane": "",
"provenance": {
diff --git a/tests/gpu_decode_attn256_test.c b/tests/gpu_decode_attn256_test.c
new file mode 100644
index 000000000 ..c46162a38
--- /dev/null
+++ b/tests/gpu_decode_attn256_test.c
@@ -0,0 +1,466 @@
+/*
+ * gpu_decode_attn256_test: the one-launch decode attention for Qwen3.8-27B (omega-mv#544, omega_gpu_decode_attn256_api.h).
+ * --host-only host pieces: RoPE rows (partial: pairs >= rotary_dim/2 are identity), the permutation (bijection, and
+ * "full rotate-half on the permuted head with the partial table == the model's rotate-half within the
+ * first rotary_dim dims", double), reference sanity (context 1 returns v_new), codegen budget per depth
+ * and mutant, refusals. No device.
+ * --sim the kernel through tests/bw_warp_sim_k.h (no chip): contexts 1, 7, 256, 257, 301, 701 (1..3 splits,
+ * the cross-split combine, 2 chunks per CTA), rotary_dim 64 and 256, both fragment orders, every mutant
+ * caught at context 301.
+ * (default) the chip: parity against the double reference at contexts 1, 7, 256, 301 (sharp q), 1024, 4096, 8192,
+ * 32768 (and 131072 with --max-pos 131072), the appended K/V row read back and compared, second call
+ * identical, out_scale 2^64 path, timing medians with the host caches evicted, every mutant caught at
+ * context 301, JSON receipt with --out.
+ * The reference is the model's maths in the model's dim order (crates/aien-inference-abi/src/qwen38.rs `attention`:
+ * zero-centred RMSNorm x * rsqrt(mean + eps) * (1 + w), RoPE on the first rotary_dim dims with pairs (j, j + rotary_dim/2),
+ * scale 1/sqrt(256), causal softmax over the context). The test permutes q, k and the norm weights with
+ * omega_dattn256_perm_vec before handing them to the kernel, stores history K rows permuted, and un-permutes nothing on
+ * the way back (V and the output are in model order). The gate (sigmoid) is outside the kernel and outside this test.
+ * Tolerance: |out - ref| <= 3e-3 * max|v| + 1e-6 per element. Host and simulator passes are never chip results.
+ */
+#include "omega_gpu_decode_attn256_api.h"
+#include "omega_gpu_session.h"
+#include "omega_gpu_hostmath.h"
+#include "bw_warp_sim_k.h"
+#include <inttypes.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+static int g_checks, g_failed;
+#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; }
+static float frand(uint32_t *s, float lo, float hi) { return lo + (hi - lo) * ((float)(lcg(s) >> 8) / 16777216 .0f); }
+static double now_ms(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * 1e3 + t.tv_nsec / 1e6; }
+static int cmp_u64(const void *a, const void *b) { uint64_t x = *(const uint64_t *)a, y = *(const uint64_t *)b; return x < y ? -1 : x > y; }
+static const double THETA = 10000000 .0; /* Qwen3.8-27B rope_theta */
+static const float EPS = 1e-6f;
+#define HD 256u
+#define QH 24u
+#define KVH 4u
+#define QW OMEGA_DATTN256_QKV_WORDS /* 8192 */
+#define OW OMEGA_DATTN256_OUT_WORDS /* 6144 */
+#define QEND (QH * HD) /* 6144: k block starts here */
+#define KEND (QEND + KVH * HD) /* 7168: v block starts here */
+
+/* one layer's random state in MODEL order: qkv, history rows (bf16) for 4 KV heads, zero-centred norm weights w */
+typedef struct {
+ uint32_t max_pos, pos, rotary;
+ float qkv[QW], qn[HD], kn[HD];
+ uint16_t *kc, *vc; /* [4][max_pos][256] model order (history 0..pos-1 filled; the rest zero) */
+ float vmax;
+} Case;
+static void case_make(Case *c, uint32_t max_pos, uint32_t pos, uint32_t rotary, uint32_t seed, float qscale) {
+ uint32_t s = seed;
+ c->max_pos = max_pos; c->pos = pos; c->rotary = rotary;
+ for (size_t i = 0; i < QW; i++) c->qkv[i] = frand(&s, -1.0f, 1.0f) * (i < QEND ? qscale : 1.0f);
+ for (unsigned i = 0; i < HD; i++) { c->qn[i] = frand(&s, -0.2f, 0.2f); c->kn[i] = frand(&s, -0.2f, 0.2f); }
+ size_t words = (size_t)KVH * max_pos * HD;
+ c->kc = calloc(words, 2); c->vc = calloc(words, 2);
+ c->vmax = 1.0f;
+ for (unsigned g = 0; g < KVH; g++) for (uint32_t t = 0; t < pos; t++) for (unsigned i = 0; i < HD; i++) {
+ size_t o = ((size_t)g * max_pos + t) * HD + i;
+ c->kc[o] = omega_dattn_bf16_rne(frand(&s, -1.0f, 1.0f)); c->vc[o] = omega_dattn_bf16_rne(frand(&s, -1.0f, 1.0f));
+ }
+}
+static void case_free(Case *c) { free(c->kc); free(c->vc); }
+/* what the kernel sees: q and k heads permuted, v as is; norms 1 + w permuted; K history rows permuted */
+static void case_kernel_inputs(const Case *c, float *qkv_k, float *qn_k, float *kn_k) {
+ for (unsigned h = 0; h < QH + KVH; h++) omega_dattn256_perm_vec(c->qkv + h * HD, qkv_k + h * HD, c->rotary);
+ memcpy(qkv_k + KEND, c->qkv + KEND, (size_t)KVH * HD * 4);
+ float t[HD];
+ for (unsigned i = 0; i < HD; i++) t[i] = 1.0f + c->qn[i];
+ omega_dattn256_perm_vec(t, qn_k, c->rotary);
+ for (unsigned i = 0; i < HD; i++) t[i] = 1.0f + c->kn[i];
+ omega_dattn256_perm_vec(t, kn_k, c->rotary);
+}
+static uint16_t *case_kc_perm(const Case *c) {
+ size_t rows = (size_t)KVH * c->max_pos;
+ uint16_t *p = calloc(rows * HD, 2);
+ for (size_t r = 0; r < rows; r++) omega_dattn256_perm_vec_bf16(c->kc + r * HD, p + r * HD, c->rotary);
+ return p;
+}
+
+/* ---- double-precision oracle (test-owned: libm) in MODEL order ---- */
+static void norm_rope(double *x, const float *w, float eps, uint32_t rotary, uint32_t pos, double theta, int rope) {
+ double ss = 0; for (unsigned i = 0; i < HD; i++) ss += x[i] * x[i];
+ double r = 1.0 / sqrt(ss / (double)HD + (double)eps);
+ for (unsigned i = 0; i < HD; i++) x[i] = x[i] * r * (1.0 + (double)w[i]);
+ if (!rope) return;
+ const unsigned half = rotary / 2;
+ for (unsigned j = 0; j < half; j++) {
+ double inv = 1.0 / pow(theta, (double)(2 * j) / (double)rotary), ang = (double)pos * inv, cs = cos(ang), sn = sin(ang);
+ double x1 = x[j], x2 = x[j + half];
+ x[j] = x1 * cs - x2 * sn; x[j + half] = x2 * cs + x1 * sn;
+ }
+}
+/* Reference of the whole layer step. kc/vc: this layer's bf16 planes [4][max_pos][256] (model order) holding positions
+ * 0..pos-1; out: [24*256] doubles (already * out_scale); k_new/v_new: the bf16 rows (model order) the kernel must have
+ * appended at pos ([4][256] each). The reference rounds its k_new/v_new to bf16 and attends over the rounded values. */
+static void reference(const float *qkv, const uint16_t *kc, const uint16_t *vc, uint32_t max_pos, uint32_t pos, uint32_t rotary,
+ const float *q_w, const float *k_w, float eps, double theta, float out_scale, double *out, uint16_t *k_new, uint16_t *v_new) {
+ const double qscale = 1.0 / sqrt((double)HD);
+ for (unsigned gk = 0; gk < KVH; gk++) {
+ double k[HD];
+ for (unsigned i = 0; i < HD; i++) k[i] = qkv[QEND + gk * HD + i];
+ norm_rope(k, k_w, eps, rotary, pos, theta, 1);
+ for (unsigned i = 0; i < HD; i++) { k_new[gk * HD + i] = omega_dattn_bf16_rne((float)k[i]); v_new[gk * HD + i] = omega_dattn_bf16_rne(qkv[KEND + gk * HD + i]); }
+ }
+ double *p = calloc((size_t)pos + 1, sizeof(double));
+ for (unsigned h = 0; h < QH; h++) {
+ unsigned gk = h / (QH / KVH);
+ double q[HD];
+ for (unsigned i = 0; i < HD; i++) q[i] = qkv[h * HD + i];
+ norm_rope(q, q_w, eps, rotary, pos, theta, 1);
+ double mx = -1e300;
+ for (uint32_t t = 0; t <= pos; t++) {
+ const uint16_t *kr = t == pos ? k_new + gk * HD : kc + ((size_t)gk * max_pos + t) * HD;
+ double s = 0; for (unsigned i = 0; i < HD; i++) s += q[i] * (double)omega_dattn_bf16_f32(kr[i]);
+ s *= qscale; p[t] = s; if (s > mx) mx = s;
+ }
+ double l = 0; for (uint32_t t = 0; t <= pos; t++) { p[t] = exp(p[t] - mx); l += p[t]; }
+ double o[HD]; memset(o, 0, sizeof o);
+ for (uint32_t t = 0; t <= pos; t++) {
+ const uint16_t *vr = t == pos ? v_new + gk * HD : vc + ((size_t)gk * max_pos + t) * HD;
+ for (unsigned i = 0; i < HD; i++) o[i] += p[t] * (double)omega_dattn_bf16_f32(vr[i]);
+ }
+ for (unsigned i = 0; i < HD; i++) out[h * HD + i] = o[i] / l * (double)out_scale;
+ }
+ free(p);
+}
+
+/* compares out (f32 [6144]) against the reference; returns the number of elements outside the tolerance and the worst ratio */
+static size_t parity(const Case *c, const float *out, float out_scale, double *worst, uint16_t *k_new, uint16_t *v_new) {
+ double *ref = malloc(OW * sizeof(double));
+ reference(c->qkv, c->kc, c->vc, c->max_pos, c->pos, c->rotary, c->qn, c->kn, EPS, THETA, out_scale, ref, k_new, v_new);
+ double tol = 3e-3 * c->vmax * out_scale + 1e-6 * out_scale; size_t bad = 0; *worst = 0;
+ for (size_t i = 0; i < OW; i++) { double d = fabs((double)out[i] - ref[i]); if (d / tol > *worst) *worst = d / tol; if (d > tol) bad++; }
+ free(ref);
+ return bad;
+}
+/* appended rows (chip rows: K permuted, V model order) against the reference rows (model order): v exact, k within one
+ * bf16 ulp on at most 32 elements over the 4 heads */
+static int rows_ok(const uint16_t *k_chip, const uint16_t *v_chip, const uint16_t *k_ref, const uint16_t *v_ref, uint32_t rotary, char *why, size_t n) {
+ unsigned kflips = 0;
+ for (unsigned g = 0; g < KVH; g++) for (unsigned i = 0; i < HD; i++) {
+ unsigned ci = g * HD + i, ri = g * HD + omega_dattn256_perm_slot(i, rotary);
+ if (v_chip[ci] != v_ref[ci]) { snprintf(why, n, "v[%u] chip %04x ref %04x", ci, v_chip[ci], v_ref[ci]); return 0; }
+ if (k_chip[ci] != k_ref[ri]) { int d = (int)k_chip[ci] - (int)k_ref[ri]; if (d < -1 || d > 1) { snprintf(why, n, "k slot %u (model dim %u) chip %04x ref %04x", ci, ri, k_chip[ci], k_ref[ri]); return 0; } kflips++; }
+ }
+ if (kflips > 32) { snprintf(why, n, "%u one-ulp k flips", kflips); return 0; }
+ snprintf(why, n, "ok (%u one-ulp k flips)", kflips);
+ return 1;
+}
+
+/* ------------------------------------------------------------- host only */
+static void perm_checks(void) {
+ static const uint32_t rots[] = { 64, 256, 2, 128, 32 };
+ for (unsigned ri = 0; ri < sizeof rots / sizeof rots[0]; ri++) {
+ uint32_t R = rots[ri], P = R / 2; uint8_t seen[HD]; memset(seen, 0, sizeof seen); int bij = 1;
+ for (uint32_t i = 0; i < HD; i++) { uint32_t m = omega_dattn256_perm_slot(i, R); if (m >= HD || seen[m]) bij = 0; else seen[m] = 1; }
+ CHECK(bij, "perm rotary %u is a bijection", R);
+ int pairs = 1; for (uint32_t i = 0; i < P; i++) pairs &= omega_dattn256_perm_slot(i, R) == i && omega_dattn256_perm_slot(i + 128, R) == i + P;
+ CHECK(pairs, "perm rotary %u: slots (i, i+128), i < %u hold the model pairs (i, i+%u)", R, P, P);
+ if (R == 256) { int id = 1; for (uint32_t i = 0; i < HD; i++) id &= omega_dattn256_perm_slot(i, R) == i; CHECK(id, "perm rotary 256 is the identity"); }
+ /* the kernel's rotate-half on the permuted head with the partial table == the model's rope, in double */
+ uint32_t s = 99 + R; double maxd = 0;
+ for (unsigned trial = 0; trial < 50; trial++) {
+ uint32_t pos = trial < 3 ? trial : lcg(&s) % 131072u;
+ double x[HD], y_model[HD], xp[HD], yp[HD], y_back[HD]; float row[HD];
+ for (unsigned i = 0; i < HD; i++) x[i] = frand(&s, -2.0f, 2.0f);
+ memcpy(y_model, x, sizeof x);
+ { float w0[HD]; for (unsigned i = 0; i < HD; i++) w0[i] = 0.0f; /* rope only: norm with w = 0 then undo the scale */
+ double ss = 0; for (unsigned i = 0; i < HD; i++) ss += x[i] * x[i]; double r = 1.0 / sqrt(ss / HD + (double)EPS);
+ norm_rope(y_model, w0, EPS, R, pos, THETA, 1); for (unsigned i = 0; i < HD; i++) y_model[i] /= r; }
+ omega_dattn256_rope_row(pos, THETA, R, row);
+ for (unsigned i = 0; i < HD; i++) xp[i] = x[omega_dattn256_perm_slot(i, R)];
+ for (unsigned i = 0; i < 128; i++) { double cs = row[i], sn = row[128 + i]; yp[i] = xp[i] * cs - xp[i + 128] * sn; yp[i + 128] = xp[i + 128] * cs + xp[i] * sn; }
+ for (unsigned i = 0; i < HD; i++) y_back[omega_dattn256_perm_slot(i, R)] = yp[i];
+ for (unsigned i = 0; i < HD; i++) { double d = fabs(y_back[i] - y_model[i]); if (d > maxd) maxd = d; }
+ }
+ CHECK(maxd < 1e-5, "perm rotary %u: rotate-half on the permuted head == model rope (max abs diff %.3g; f32 table)", R, maxd);
+ printf("perm rotary %3u: bijection, pairs, rope-by-permutation max abs diff %.3g over 50 positions\n", R, maxd);
+ }
+}
+static void host_only(void) {
+ float row[HD]; omega_dattn256_rope_row(0, THETA, 64, row);
+ int ok = 1; for (unsigned i = 0; i < 128; i++) ok &= row[i] == 1.0f && row[128 + i] == 0.0f;
+ CHECK(ok, "rope row 0 is cos 1 sin 0");
+ omega_dattn256_rope_row(100, THETA, 64, row);
+ CHECK(fabs((double)row[0] - cos(100.0)) < 1e-6 && fabs((double)row[128] - sin(100.0)) < 1e-6, "rope row 100 pair 0 is cos/sin(100)");
+ CHECK(fabs((double)row[31] - cos(100.0 * pow(THETA, -62.0 / 64.0))) < 1e-6, "rope row 100 pair 31 uses theta^(-62/64)");
+ ok = 1; for (unsigned i = 32; i < 128; i++) ok &= row[i] == 1.0f && row[128 + i] == 0.0f;
+ CHECK(ok, "rope row 100: pairs 32..127 are identity for rotary_dim 64");
+ omega_dattn256_rope_row(100, THETA, 256, row);
+ CHECK(fabs((double)row[127] - cos(100.0 * pow(THETA, -254.0 / 256.0))) < 1e-6, "rope row 100 rotary 256 pair 127 uses theta^(-254/256)");
+ perm_checks();
+ /* reference sanity: context 1 returns v_new (rounded), whatever q and k */
+ { Case c; case_make(&c, 256, 0, 64, 11, 1.0f); double *ref = malloc(OW * sizeof(double)); uint16_t kn[KVH * HD], vn[KVH * HD];
+ reference(c.qkv, c.kc, c.vc, 256, 0, 64, c.qn, c.kn, EPS, THETA, 1.0f, ref, kn, vn);
+ int good = 1; for (unsigned h = 0; h < QH && good; h++) for (unsigned i = 0; i < HD; i++) if (ref[h * HD + i] != (double)omega_dattn_bf16_f32(vn[(h / 6) * HD + i])) { good = 0; break; }
+ CHECK(good, "reference: context 1 returns the rounded v_new of the head's KV group");
+ free(ref); case_free(&c); }
+ { Case c; case_make(&c, 256, 8, 64, 12, 1.0f);
+ double *ref = malloc(OW * sizeof(double)); uint16_t kn[KVH * HD], vn[KVH * HD];
+ reference(c.qkv, c.kc, c.vc, 256, 8, 64, c.qn, c.kn, EPS, THETA, 1.0f, ref, kn, vn);
+ double ss = 0; for (unsigned i = 0; i < HD; i++) { double v = omega_dattn_bf16_f32(kn[i]); ss += v * v; }
+ CHECK(ss / HD > 0.6 && ss / HD < 1.5, "reference: k_new has rms about 1 after RMSNorm (%.3f)", ss / HD);
+ double os = 0; for (unsigned i = 0; i < OW; i++) os += fabs(ref[i]);
+ CHECK(os / OW < 0.6, "reference: a 9-token softmax average of U(-1,1) rows is small (%.3f)", os / OW);
+ free(ref); case_free(&c); }
+ /* codegen budget */
+ for (uint32_t d = 1; d <= 4; d++) for (int m = 0; m <= 5; m++) {
+ OmegaDecodeAttn256Spec s = { d, m }; uint32_t n = 0, gp = 0;
+ int rc = omega_decode_attn256_prog_stats(&s, &n, &gp);
+ CHECK(rc == 0 && n <= 1024 && gp <= 126, "codegen depth %u mutant %d: rc %d insns %u gprs %u", d, m, rc, n, gp);
+ if (rc == 0 && m == 0) printf("codegen depth %u: %u instructions, %u registers (declared %u, 256 threads -> %u of 65536)\n", d, n, gp, omega_bw_gpr_declared(gp), 256 * omega_bw_gpr_declared(gp));
+ }
+ { OmegaDecodeAttn256Spec s = { 0, 0 }; CHECK(omega_decode_attn256_prog_stats(&s, NULL, NULL) != 0, "depth 0 refused");
+ s.depth = 5; CHECK(omega_decode_attn256_prog_stats(&s, NULL, NULL) != 0, "depth 5 refused");
+ s.depth = 1; s.mutant = 6; CHECK(omega_decode_attn256_prog_stats(&s, NULL, NULL) != 0, "mutant 6 refused"); }
+ CHECK(omega_gpu_decode_attn256_cache_alloc(0, 256, THETA, 64, NULL) == OMEGA_GPU_DATTN_BAD_ARGS, "NULL out refused");
+ { OmegaGpuDecodeAttn256Cache *c = (OmegaGpuDecodeAttn256Cache *)1;
+ CHECK(omega_gpu_decode_attn256_cache_alloc(1, 100, THETA, 64, &c) == OMEGA_GPU_DATTN_BAD_ARGS && c == NULL, "max_pos not a multiple of 256 refused before any device work");
+ c = (OmegaGpuDecodeAttn256Cache *)1;
+ CHECK(omega_gpu_decode_attn256_cache_alloc(1, 256, THETA, 63, &c) == OMEGA_GPU_DATTN_BAD_ARGS && c == NULL, "odd rotary_dim refused");
+ c = (OmegaGpuDecodeAttn256Cache *)1;
+ CHECK(omega_gpu_decode_attn256_cache_alloc(1, 256, THETA, 258, &c) == OMEGA_GPU_DATTN_BAD_ARGS && c == NULL, "rotary_dim > 256 refused");
+ c = (OmegaGpuDecodeAttn256Cache *)1;
+ CHECK(omega_gpu_decode_attn256_cache_alloc(1, 131072 + 256, THETA, 64, &c) == OMEGA_GPU_DATTN_BAD_ARGS && c == NULL, "max_pos > 131072 refused"); }
+ CHECK(OMEGA_DATTN256_SHARED_BYTES <= 16384u, "shared memory within the QMD cap (%u)", OMEGA_DATTN256_SHARED_BYTES);
+ CHECK(OMEGA_DATTN256_SM_FLAG + 16u == OMEGA_DATTN256_SHARED_BYTES && OMEGA_DATTN256_SM_S + 8192u <= OMEGA_DATTN256_SM_M && OMEGA_DATTN256_SM_M + 288u <= OMEGA_DATTN256_SM_L && OMEGA_DATTN256_SM_L + 256u <= OMEGA_DATTN256_SM_FLAG, "shared map does not overlap");
+}
+
+/* ------------------------------------------------------------- simulator */
+static uint64_t g_sim_issues;
+static int sim_point(uint32_t max_pos, uint32_t pos, uint32_t rotary, uint32_t depth, int mutant, uint32_t per_split, float qscale, uint32_t seed, char *msg, size_t n, double *worst, size_t *bad, char *rows, size_t rn) {
+ static BlackwellIRProgram prog;
+ OmegaDecodeAttn256Spec spec = { depth, mutant };
+ if (omega_blackwell_codegen_decode_attn256_prog(&spec, &prog) != 0) { snprintf(msg, n, "codegen refused"); return -1; }
+ Case c; case_make(&c, max_pos, pos, rotary, seed, qscale);
+ uint16_t *kcp = case_kc_perm(&c);
+ const uint32_t splits = (pos + per_split) / per_split;
+ size_t plane = (size_t)KVH * max_pos * OMEGA_DATTN256_ROW_BYTES + OMEGA_DATTN256_PLANE_SLACK, hist = (size_t)KVH * max_pos * OMEGA_DATTN256_ROW_BYTES;
+ uint8_t *kv = aligned_alloc(16, 2 * plane); memset(kv, 0, 2 * plane);
+ float *rope = aligned_alloc(16, (size_t)max_pos * OMEGA_DATTN256_ROPE_ROW_BYTES); for (uint32_t p = 0; p < max_pos; p++) omega_dattn256_rope_row(p, THETA, rotary, rope + (size_t)p * 256);
+ float *norms = aligned_alloc(16, 2048);
+ float *qkv = aligned_alloc(16, sizeof c.qkv);
+ case_kernel_inputs(&c, qkv, norms, norms + HD);
+ float *out = aligned_alloc(16, OW * 4), *copy = malloc(OW * 4);
+ float *part = aligned_alloc(16, (size_t)KVH * splits * OMEGA_DATTN256_PARTIAL_WORDS * 4);
+ uint32_t *cnt = aligned_alloc(16, 16);
+ int err = 0;
+ for (int order = 0; order < 2 && !err; order++) {
+ WsSim s; memset(&s, 0, sizeof s);
+ s.p = &prog; s.threads = 256; s.order = order;
+ static uint8_t smem[OMEGA_DATTN256_SHARED_BYTES]; s.smem = smem; s.smem_bytes = OMEGA_DATTN256_SHARED_BYTES;
+ memset(cnt, 0, 16); for (unsigned i = 0; i < OW; i++) out[i] = -999.0f;
+ memcpy(kv, kcp, hist); memcpy(kv + plane, c.vc, hist); /* fresh history (the kernel appends) */
+ uint64_t A[9] = { (uintptr_t)qkv, (uintptr_t)kv, (uintptr_t)(kv + plane), (uintptr_t)rope, (uintptr_t)norms, (uintptr_t)(norms + HD), (uintptr_t)out, (uintptr_t)part, (uintptr_t)cnt };
+ for (unsigned i = 0; i < 9; i++) { s.cbank[(0x380 + 8 * i) / 4] = (uint32_t)A[i]; s.cbank[(0x380 + 8 * i) / 4 + 1] = (uint32_t)(A[i] >> 32); }
+ float fe = EPS, fo = 1.0f, fq = (float)((1.0 / 16.0) * 1.4426950408889634 );
+ memcpy(&s.cbank[OMEGA_DATTN256_ARG_EPS / 4], &fe, 4); memcpy(&s.cbank[OMEGA_DATTN256_ARG_OUT_SCALE / 4], &fo, 4); memcpy(&s.cbank[OMEGA_DATTN256_ARG_QK_SCALE / 4], &fq, 4);
+ s.cbank[OMEGA_DATTN256_ARG_POS / 4] = pos; s.cbank[OMEGA_DATTN256_ARG_PER_SPLIT / 4] = per_split; s.cbank[OMEGA_DATTN256_ARG_SPLITS / 4] = splits; s.cbank[OMEGA_DATTN256_ARG_KV_STRIDE / 4] = max_pos * OMEGA_DATTN256_ROW_BYTES;
+ s.nranges = 7;
+ s.ranges[0].lo = (uintptr_t)qkv; s.ranges[0].hi = (uintptr_t)qkv + sizeof c.qkv;
+ s.ranges[1].lo = (uintptr_t)kv; s.ranges[1].hi = (uintptr_t)kv + 2 * plane;
+ s.ranges[2].lo = (uintptr_t)rope; s.ranges[2].hi = (uintptr_t)rope + (size_t)max_pos * OMEGA_DATTN256_ROPE_ROW_BYTES;
+ s.ranges[3].lo = (uintptr_t)norms; s.ranges[3].hi = (uintptr_t)norms + 2048;
+ s.ranges[4].lo = (uintptr_t)out; s.ranges[4].hi = (uintptr_t)out + OW * 4;
+ s.ranges[5].lo = (uintptr_t)part; s.ranges[5].hi = (uintptr_t)part + (size_t)KVH * splits * OMEGA_DATTN256_PARTIAL_WORDS * 4;
+ s.ranges[6].lo = (uintptr_t)cnt; s.ranges[6].hi = (uintptr_t)cnt + 16;
+ err = ws_run(&s, splits, KVH);
+ if (err) { snprintf(msg, n, "order %d: %s (pc %d)", order, s.msg, s.err_pc); break; }
+ g_sim_issues += s.warp_issues;
+ size_t unwritten = 0; for (unsigned i = 0; i < OW; i++) if (out[i] == -999.0f) unwritten++;
+ if (unwritten) { err = -1; snprintf(msg, n, "%zu output words never written", unwritten); break; }
+ if (cnt[0] | cnt[1] | cnt[2] | cnt[3]) { err = -1; snprintf(msg, n, "counters not reset: %u %u %u %u", cnt[0], cnt[1], cnt[2], cnt[3]); break; }
+ if (order == 0) memcpy(copy, out, OW * 4);
+ else if (memcmp(copy, out, OW * 4) != 0) { err = -1; snprintf(msg, n, "the fragment order changed the result"); }
+ }
+ if (!err) {
+ uint16_t kn[KVH * HD], vn[KVH * HD];
+ *bad = parity(&c, out, 1.0f, worst, kn, vn);
+ uint16_t kchip[KVH * HD], vchip[KVH * HD];
+ for (unsigned g = 0; g < KVH; g++) { memcpy(kchip + g * HD, kv + ((size_t)g * max_pos + pos) * OMEGA_DATTN256_ROW_BYTES, OMEGA_DATTN256_ROW_BYTES); memcpy(vchip + g * HD, kv + plane + ((size_t)g * max_pos + pos) * OMEGA_DATTN256_ROW_BYTES, OMEGA_DATTN256_ROW_BYTES); }
+ if (!rows_ok(kchip, vchip, kn, vn, rotary, rows, rn)) *bad += 1000;
+ snprintf(msg, n, "bad=%zu worst=%.3f rows: %s", *bad, *worst, rows);
+ }
+ free(kv); free(rope); free(norms); free(qkv); free(out); free(copy); free(part); free(cnt); free(kcp); case_free(&c);
+ return err;
+}
+static void sim_battery(void) {
+ char msg[300], rows[160]; double worst; size_t bad;
+ struct { uint32_t max_pos, pos, rotary, depth, per; float qscale; const char *name; } pts[] = {
+ { 256, 0, 64, 1, 256, 1.0f, "context 1" },
+ { 256, 6, 64, 2, 256, 1.0f, "context 7" },
+ { 256, 6, 64, 4, 256, 4.0f, "context 7, sharp q (x4)" },
+ { 256, 6, 256, 4, 256, 1.0f, "context 7, full rope (rotary 256)" },
+ { 256, 255, 64, 4, 256, 1.0f, "context 256 (full chunk, 1 split)" },
+ { 512, 256, 64, 4, 256, 1.0f, "context 257 (2 splits, last holds one position)" },
+ { 512, 300, 64, 3, 256, 1.0f, "context 301 (2 splits)" },
+ { 1024, 700, 64, 4, 256, 1.0f, "context 701 (3 splits)" },
+ { 1024, 700, 64, 2, 512, 1.0f, "context 701 (per_split 512: 2 chunks per CTA)" },
+ };
+ for (size_t i = 0; i < sizeof pts / sizeof pts[0]; i++) {
+ int err = sim_point(pts[i].max_pos, pts[i].pos, pts[i].rotary, pts[i].depth, 0, pts[i].per, pts[i].qscale, 100 + (uint32_t)i, msg, sizeof msg, &worst, &bad, rows, sizeof rows);
+ CHECK(err == 0 && bad == 0, "sim %s depth %u: %s", pts[i].name, pts[i].depth, msg);
+ printf("sim %-50s depth %u: %s %s\n", pts[i].name, pts[i].depth, err ? "ERROR" : bad ? "MISMATCH" : "ok", msg);
+ }
+ for (int m = 1; m <= 5; m++) {
+ int err = sim_point(512, 300, 64, 2, m, 256, 1.0f, 200, msg, sizeof msg, &worst, &bad, rows, sizeof rows);
+ int caught = err != 0 || bad > 0;
+ CHECK(caught, "sim mutant %d NOT caught (%s)", m, msg);
+ printf("sim mutant %d at context 301: %s (%s)\n", m, caught ? "caught" : "MISSED", msg);
+ }
+ printf("sim: %" PRIu64 " warp issues in total\n", g_sim_issues);
+}
+
+/* ------------------------------------------------------------- chip */
+static int g_evict = 1; static const char *g_only; static uint32_t g_maxp = 32768;
+static void evict_host_caches(void) {
+ static uint8_t *buf; const size_t sz = 512u << 20; static uint8_t pass;
+ if (!buf) buf = malloc(sz);
+ if (!buf) return;
+ memset(buf, ++pass, sz);
+ volatile uint64_t sum = 0; for (size_t i = 0; i < sz; i += 64) sum += buf[i];
+}
+static int fill_history(OmegaGpuDecodeAttn256Cache *cache, const Case *c, const uint16_t *kcp) {
+ if (c->pos == 0) return OMEGA_GPU_DATTN_OK;
+ for (unsigned g = 0; g < KVH; g++) {
+ int rc = omega_gpu_decode_attn256_cache_write(cache, 0, g, 0, c->pos, kcp + (size_t)g * c->max_pos * HD, c->vc + (size_t)g * c->max_pos * HD);
+ if (rc != OMEGA_GPU_DATTN_OK) return rc;
+ }
+ return OMEGA_GPU_DATTN_OK;
+}
+static int chip_run(const char *out_path, uint32_t reps) {
+ FILE *out = out_path ? fopen(out_path, "w") : NULL;
+ if (out_path && !out) { printf("cannot write %s\n", out_path); return 1; }
+ if (out) fprintf(out, "{\"receipt\":\"OMEGA_GPU_DECODE_ATTN256_V1\",\"reps\":%u,\"evict\":%d,\"max_pos\":%u,\"rotary_dim\":64,\"points\":[", reps, g_evict, g_maxp);
+ const uint32_t MAXP = g_maxp;
+ OmegaGpuDecodeAttn256Cache *cache = NULL;
+ double t0 = now_ms();
+ int rc = omega_gpu_decode_attn256_cache_alloc(1, MAXP, THETA, 64, &cache);
+ printf("cache alloc (1 layer, %u positions, %.0f MiB): rc=%s %.1f ms (%s)\n", MAXP, (double)MAXP * 2 * KVH * 512 / 1048576 .0, omega_gpu_decode_attn_rc_name(rc), now_ms() - t0, rc ? omega_gpu_decode_attn_last_error() : "");
+ CHECK(rc == OMEGA_GPU_DATTN_OK, "cache alloc");
+ if (rc != OMEGA_GPU_DATTN_OK) { if (out) fprintf(out, "],\"verdict\":\"OMEGA_GPU_DECODE_ATTN256_FAIL\"}\n"); return 1; }
+ struct { uint32_t pos; float qscale; const char *name; } pts[] = {
+ { 0, 1.0f, "context 1" }, { 6, 1.0f, "context 7" }, { 255, 1.0f, "context 256" }, { 300, 4.0f, "context 301 sharp q" },
+ { 1023, 1.0f, "context 1024" }, { 4095, 1.0f, "context 4096" }, { 8191, 1.0f, "context 8192" }, { 32767, 1.0f, "context 32768" },
+ { 131071, 1.0f, "context 131072" },
+ };
+ int first = 1;
+ for (size_t i = 0; i < sizeof pts / sizeof pts[0]; i++) {
+ if (pts[i].pos >= MAXP) continue;
+ if (g_only && !strstr(pts[i].name, g_only)) continue;
+ Case c; case_make(&c, MAXP, pts[i].pos, 64, 500 + (uint32_t)i, pts[i].qscale);
+ uint16_t *kcp = case_kc_perm(&c);
+ float *qkv_k = malloc(QW * 4), qn_k[HD], kn_k[HD];
+ case_kernel_inputs(&c, qkv_k, qn_k, kn_k);
+ CHECK(omega_gpu_decode_attn256_set_norms(cache, 0, qn_k, kn_k) == OMEGA_GPU_DATTN_OK, "set norms");
+ t0 = now_ms();
+ rc = fill_history(cache, &c, kcp);
+ double fill_ms = now_ms() - t0;
+ float *y = malloc(OW * 4), *y2 = malloc(OW * 4);
+ OmegaGpuDecodeAttn256Info info; memset(&info, 0, sizeof info);
+ if (rc == OMEGA_GPU_DATTN_OK) rc = omega_gpu_decode_attn256(cache, 0, c.pos, qkv_k, EPS, 1.0f, y, &info);
+ size_t bad = 0; double worst = 1e9; uint16_t kn[KVH * HD], vn[KVH * HD], kchip[KVH * HD], vchip[KVH * HD]; char rows[160] = "n/a";
+ if (rc == OMEGA_GPU_DATTN_OK) {
+ bad = parity(&c, y, 1.0f, &worst, kn, vn);
+ for (unsigned g = 0; g < KVH; g++) if (omega_gpu_decode_attn256_cache_read(cache, 0, g, c.pos, kchip + g * HD, vchip + g * HD) != OMEGA_GPU_DATTN_OK) bad += 1000;
+ if (!rows_ok(kchip, vchip, kn, vn, 64, rows, sizeof rows)) bad += 1000;
+ }
+ int ok = rc == OMEGA_GPU_DATTN_OK && bad == 0;
+ int same = 0; OmegaGpuDecodeAttn256Info i2; memset(&i2, 0, sizeof i2);
+ if (ok) { int r2 = omega_gpu_decode_attn256(cache, 0, c.pos, qkv_k, EPS, 1.0f, y2, &i2); same = r2 == OMEGA_GPU_DATTN_OK && memcmp(y, y2, OW * 4) == 0 && i2.kernel_cache_hit; }
+ CHECK(ok && same, "chip %s: rc=%s bad=%zu worst=%.3f rows=%s second-call-identical=%d (%s)", pts[i].name, omega_gpu_decode_attn_rc_name(rc), bad, worst, rows, same, omega_gpu_decode_attn_last_error());
+ if (ok) {
+ float *ys = malloc(OW * 4); int r3 = omega_gpu_decode_attn256(cache, 0, c.pos, qkv_k, EPS, 18446744073709551616 .0f, ys, NULL);
+ int good = r3 == OMEGA_GPU_DATTN_OK; double wr = 0;
+ for (unsigned k = 0; k < OW && good; k++) { double e = fabs((double)ys[k] / 18446744073709551616 .0 - (double)y[k]); double r = e / (fabs((double)y[k]) + 1e-6); if (r > wr) wr = r; }
+ CHECK(good && wr < 1e-5, "chip %s: out_scale 2^64 matches the unscaled output (worst rel %.2e)", pts[i].name, wr);
+ free(ys);
+ }
+ uint64_t *el = calloc(reps, sizeof *el), *cl = calloc(reps, sizeof *cl); uint32_t done = 0;
+ if (g_evict) evict_host_caches();
+ for (uint32_t r = 0; r < reps && ok; r++) { OmegaGpuDecodeAttn256Info ti; if (omega_gpu_decode_attn256(cache, 0, c.pos, qkv_k, EPS, 1.0f, y2, &ti) != OMEGA_GPU_DATTN_OK) break; el[r] = ti.elapsed_ns; cl[r] = ti.call_ns; done++; }
+ uint64_t med_el = 0, med_cl = 0; double gbs = 0;
+ if (done) { qsort(el, done, sizeof *el, cmp_u64); qsort(cl, done, sizeof *cl, cmp_u64); med_el = el[done / 2]; med_cl = cl[done / 2]; gbs = med_el ? (double)info.kv_bytes / (double)med_el : 0; }
+ printf("chip %-24s rc=%-9s bad=%zu worst=%.3f rows=%s grid=%ux%u per_split=%u depth=%u kv_bytes=%" PRIu64 " fill=%.1fms chip_med=%.1fus (%.1f GB/s) call_med=%.1fus reps=%u\n",
+ pts[i].name, omega_gpu_decode_attn_rc_name(rc), bad, worst, rows, info.grid_x, info.grid_y, info.per_split, info.depth, info.kv_bytes, fill_ms, med_el / 1e3, gbs, med_cl / 1e3, done);
+ if (out) fprintf(out, "%s{\"name\":\"%s\",\"pos\":%u,\"rc\":\"%s\",\"bad\":%zu,\"worst_of_tol\":%.3f,\"rows\":\"%s\",\"second_call_identical\":%d,\"grid_x\":%u,\"grid_y\":%u,\"per_split\":%u,\"depth\":%u,"
+ "\"kv_bytes\":%" PRIu64 ",\"fill_ms\":%.1f,\"chip_median_ns\":%" PRIu64 ",\"gb_per_s\":%.1f,\"call_median_ns\":%" PRIu64 ",\"reps\":%u}",
+ first ? "" : ",", pts[i].name, c.pos, omega_gpu_decode_attn_rc_name(rc), bad, worst, rows, same, info.grid_x, info.grid_y, info.per_split, info.depth, info.kv_bytes, fill_ms, med_el, gbs, med_cl, done);
+ first = 0;
+ free(el); free(cl);
+ if (ok && c.pos == 300) {
+ for (int m = 1; m <= 5; m++) {
+ omega_gpu_decode_attn256_test_set_mutant(m);
+ (void)fill_history(cache, &c, kcp); /* mutant 3 must not inherit the row the honest kernel wrote */
+ uint16_t zk[HD] = { 0 }, zv[HD] = { 0 };
+ for (unsigned g = 0; g < KVH; g++) (void)omega_gpu_decode_attn256_cache_write(cache, 0, g, c.pos, 1, zk, zv);
+ int r = omega_gpu_decode_attn256(cache, 0, c.pos, qkv_k, EPS, 1.0f, y2, NULL);
+ size_t mb = 0; double mw = 0; uint16_t k2[KVH * HD], v2[KVH * HD];
+ if (r == OMEGA_GPU_DATTN_OK) { mb = parity(&c, y2, 1.0f, &mw, k2, v2); }
+ int caught = r != OMEGA_GPU_DATTN_OK || mb > 0;
+ if (m == 4 && info.grid_x == 1) { printf("chip %-24s mutant 4: inert (1 split, the combine is not exercised)\n", pts[i].name); omega_gpu_decode_attn256_test_set_mutant(0); continue; }
+ CHECK(caught, "chip mutant %d NOT caught", m);
+ printf("chip %-24s mutant %d: %s (rc=%s bad=%zu worst=%.3f)\n", pts[i].name, m, caught ? "caught" : "MISSED", omega_gpu_decode_attn_rc_name(r), mb, mw);
+ if (out) fprintf(out, ",{\"name\":\"%s mutant %d\",\"caught\":%d,\"rc\":\"%s\",\"bad\":%zu,\"worst_of_tol\":%.3f}", pts[i].name, m, caught, omega_gpu_decode_attn_rc_name(r), mb, mw);
+ omega_gpu_decode_attn256_test_set_mutant(0);
+ }
+ }
+ free(y); free(y2); free(qkv_k); free(kcp); case_free(&c);
+ if (omega_gpu_session_is_blocked()) { printf("session latched: stopping\n"); break; }
+ }
+ omega_gpu_decode_attn256_cache_free(cache);
+ if (out) { fprintf(out, "],\"checks\":%d,\"failed\":%d,\"device_opens\":%u,\"verdict\":\"%s\"}\n", g_checks, g_failed, omega_gpu_session_open_count(), g_failed == 0 ? "OMEGA_GPU_DECODE_ATTN256_PASS" : "OMEGA_GPU_DECODE_ATTN256_FAIL"); fclose(out); }
+ return 0;
+}
+
+/* --q-heads Q --kv-heads K --head-dim D: any geometry other than 24 / 4 / 256 is REFUSED (receipt verdict "REFUSED", exit 3). */
+static int geometry_refusal(uint32_t qh, uint32_t kvh, uint32_t hd, const char *out_path) {
+ if (qh == QH && kvh == KVH && hd == HD) return 0;
+ printf("REFUSED: decode attention 256 at %u query / %u KV heads, head dim %u (built for %u / %u / %u)\n", qh, kvh, hd, QH, KVH, HD);
+ if (out_path) { FILE *f = fopen(out_path, "w"); if (f) { fprintf(f, "{\"test\":\"gpu_decode_attn256_test\",\"q_heads\":%u,\"kv_heads\":%u,\"head_dim\":%u,\"verdict\":\"REFUSED\"}\n", qh, kvh, hd); fclose(f); } }
+ return 3;
+}
+
+int main(int argc, char **argv) {
+ int host = 0, sim = 0; const char *out_path = NULL; uint32_t reps = 20, depth = 0, per = 0, spin = 2000; int sim_pos = -1; uint32_t sim_max = 256;
+ uint32_t q_heads = QH, kv_heads = KVH, head_dim = HD;
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--host-only") == 0) host = 1;
+ else if (strcmp(argv[i], "--sim") == 0) sim = 1;
+ else if (strcmp(argv[i], "--out") == 0 && i + 1 < argc) out_path = argv[++i];
+ else if (strcmp(argv[i], "--reps") == 0 && i + 1 < argc) reps = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--depth") == 0 && i + 1 < argc) depth = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--per-split") == 0 && i + 1 < argc) per = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--spin-us") == 0 && i + 1 < argc) spin = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--no-evict") == 0) g_evict = 0;
+ else if (strcmp(argv[i], "--sim-pos") == 0 && i + 1 < argc) sim_pos = atoi(argv[++i]);
+ else if (strcmp(argv[i], "--sim-max") == 0 && i + 1 < argc) sim_max = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--only") == 0 && i + 1 < argc) g_only = argv[++i];
+ else if (strcmp(argv[i], "--max-pos") == 0 && i + 1 < argc) g_maxp = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--q-heads") == 0 && i + 1 < argc) q_heads = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--kv-heads") == 0 && i + 1 < argc) kv_heads = (uint32_t)atoi(argv[++i]);
+ else if (strcmp(argv[i], "--head-dim") == 0 && i + 1 < argc) head_dim = (uint32_t)atoi(argv[++i]);
+ else { printf("unknown argument %s\n", argv[i]); return 2; }
+ }
+ { int g = geometry_refusal(q_heads, kv_heads, head_dim, out_path); if (g) return g; }
+ if (host) host_only();
+ if (sim && sim_pos >= 0 && sim_max <= (uint32_t)sim_pos) sim_max = (uint32_t)sim_pos + 1u;
+ if (sim && sim_pos >= 0) { char msg[300], rows[160]; double worst; size_t bad; int err = sim_point(sim_max, (uint32_t)sim_pos, 64, depth ? depth : 2, 0, per ? per : 256, 1.0f, 777, msg, sizeof msg, &worst, &bad, rows, sizeof rows); printf("sim pos %d: %s %s\n", sim_pos, err ? "ERROR" : bad ? "MISMATCH" : "ok", msg); return err || bad; }
+ if (sim) sim_battery();
+ if (!host && !sim) {
+ if (depth) omega_gpu_decode_attn256_set_depth(depth);
+ if (per) omega_gpu_decode_attn256_set_per_split(per);
+ (void)omega_gpu_session_set_spin_us(spin);
+ chip_run(out_path, reps ? reps : 1);
+ omega_gpu_session_close();
+ }
+ printf("gpu_decode_attn256_test: %d checks, %d failed: %s\n", g_checks, g_failed, g_failed ? "FAIL" : "PASS");
+ return g_failed ? 1 : 0;
+}
diff --git a/tools/.crumb b/tools/.crumb
index 8cf70bcac ..492c12d1a 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-18T13:06:21Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:566a123ba248da906e3c42430b73decd7c3ec030a4fd26c909d265aa9bf67db9 ",
+ "digest": "sha256:db3d0e54d63e2ca868e85392d6b71a612b2a49ff95948f9e1f13b1e7072f46e8 ",
"evidence_files": 0,
"evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ",
- "files": 284,
- "generated_at_commit": "88e24bdd57b27817d030d0ad95f62c3f3eacf426 ",
- "source_tree": "sha256:eee0218ae5c8d003fa0a585291551799e81e6c329a7f5db1295e771a75aee167 "
+ "files": 285,
+ "generated_at_commit": "c3ab69f66d6b2a2bce7efe425d80b1306e1140ed ",
+ "source_tree": "sha256:a2abf5ced00b4e60ea4b863a6e99f94fd406cec098075162227613c8751769ac "
},
"owner_lane": "",
"provenance": {
diff --git a/tools/run_gpu_decode_attn256_chip.sh b/tools/run_gpu_decode_attn256_chip.sh
new file mode 100755
index 000000000 ..7a0edf2ef
--- /dev/null
+++ b/tools/run_gpu_decode_attn256_chip.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# run_gpu_decode_attn256_chip.sh EVIDENCE_DIR [PHYSICS_DIR]
+# Qwen3.8-27B chip gate for omega_gpu_decode_attn256_api (omega-mv#544: one-launch decode attention, head_dim 256, 24 q / 4 kv
+# heads, partial RoPE by permutation, in-kernel KV append).
+# Caller holds the GB10 lock: flock /tmp/aien-gb10.lock tools/run_gpu_decode_attn256_chip.sh EVID
+# 0. host proofs first (never hardware results): --host-only (partial RoPE rows, the permutation, reference sanity, codegen
+# budgets, refusals) and --sim (warp-simulator parity on 9 contexts incl. rotary 256, multi-split and 2 chunks per CTA, mutants 1-5)
+# 1. baseline: the already-proven matmul API chip timing (chip and session path work before the new kernel is judged)
+# 2. main: parity against the double reference at contexts 1, 7, 256, 301 (sharp q), 1024, 4096, 8192, 32768; the appended
+# K/V rows read back; second call bit-identical; out_scale 2^64 path; mutants 1-5 at context 301; chip medians and
+# GB/s on the K+V bytes streamed, host caches evicted before each timing loop
+# 3. one variable per run, informational: --no-evict (host caches warm: the flattering number), --depth 1 (shallowest
+# prefetch), --per-split 1024 (4 chunks per CTA, a quarter of the CTAs), --max-pos 131072 (the 512 MiB per-layer
+# cache of the real model: allocation + parity at context 131072)
+# Verdict line last: "GPU_DECODE_ATTN256_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}"
+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=$PHYS physics_commit=$(git -C "$PHYS" rev-parse HEAD) physics_lock=$(cat physics.lock 2>/dev/null | head -1)"
+ uname -a; nvidia-smi --query-gpu=name,driver_version --format=csv,noheader 2>/dev/null; free -g | head -2
+} > "$EVID/device.txt"
+make PHYSICS_DIR="$PHYS" -j10 build/gpu_decode_attn256_test build/gpu_matmul_api_test > "$EVID/build.log" 2>&1 || { echo "GPU_DECODE_ATTN256_CHIP: FAIL build"; exit 1; }
+T=./build/gpu_decode_attn256_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
+./build/gpu_matmul_api_test --timing --out "$EVID/receipt-baseline-matmul.json" 2>&1 | tee "$EVID/baseline-matmul.log"
+echo "baseline exit ${PIPESTATUS[0]} (recorded)" | tee -a "$EVID/baseline-matmul.log"
+$T --reps 20 --out "$EVID/receipt-main.json" 2>&1 | tee "$EVID/main.log"; [ "${PIPESTATUS[0]}" = 0 ] || fail=1
+$T --reps 20 --no-evict --out "$EVID/receipt-noevict.json" 2>&1 | tee "$EVID/noevict.log"; echo "no-evict exit ${PIPESTATUS[0]} (informational)" | tee -a "$EVID/noevict.log"
+$T --reps 20 --depth 1 --out "$EVID/receipt-depth1.json" 2>&1 | tee "$EVID/depth1.log"; echo "depth 1 exit ${PIPESTATUS[0]} (informational)" | tee -a "$EVID/depth1.log"
+$T --reps 20 --per-split 1024 --out "$EVID/receipt-persplit1024.json" 2>&1 | tee "$EVID/persplit1024.log"; echo "per-split 1024 exit ${PIPESTATUS[0]} (informational)" | tee -a "$EVID/persplit1024.log"
+$T --reps 5 --max-pos 131072 --only "context 131072" --out "$EVID/receipt-maxpos131072.json" 2>&1 | tee "$EVID/maxpos131072.log"; echo "max-pos 131072 exit ${PIPESTATUS[0]} (informational)" | tee -a "$EVID/maxpos131072.log"
+
+echo "end $(date -u +%FT%TZ)" >> "$EVID/device.txt"
+(cd "$EVID" && sha256sum *.json *.log device.txt > SHA256SUMS)
+if [ $fail = 0 ]; then echo "GPU_DECODE_ATTN256_CHIP: PASS"; else echo "GPU_DECODE_ATTN256_CHIP: FAIL"; exit 1; fi