interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

GitHub aien-dev/omega-mv#275 (code only)

closed derived 0f4eff1207016e0b #275

Imported from GitHub aien-dev/omega-mv#275 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 02978cfd2087fed38cab1ca6edc5aa38a62424c8 · Head 6fab49839e73571d643ab78addcd5a32a5e419d0

Apply it

git checkout -b patch-0f4eff1207016e0b 02978cfd2087fed38cab1ca6edc5aa38a62424c8
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/0f4eff1207016e0b.patch | git am

Raw patch (mbox) · 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
275
6fab49839e73571d643ab78addcd5a32a5e419d0
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":275,"url":"https://github.com/aien-dev/omega-mv/pull/275","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:05Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 2603dca3e..719434c79 100644
--- a/.crumb
+++ b/.crumb
@@ -51,8 +51,8 @@
           "purpose": "Directory calibration. Purpose not yet described by a human."
         },
         {
-          "digest": "e156df1e52268bb3346ded9bf7afcb426960e643a8889e1d76865a83a3a5a642",
-          "last_commit": "55d05d6",
+          "digest": "1c478a7e59b6a030f35f00356f51098708307326e8bd7127d99573e98666b395",
+          "last_commit": "d12d012",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
@@ -87,33 +87,33 @@
           "purpose": "Directory spec. Purpose not yet described by a human."
         },
         {
-          "digest": "fab4c6952b54567c65c8bd843e46bcd238c688940ed1d1830af2b584b057781b",
-          "last_commit": "55d05d6",
+          "digest": "be4a15a5245076828c97b151dd4ed1cc891c7dc5f22aee9ffdd0d93fb430e720",
+          "last_commit": "d12d012",
           "name": "src",
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
-          "digest": "9eb57c43d48ae70bce44757cbf075c38a03a090e0da529260d88e197e602c767",
-          "last_commit": "55d05d6",
+          "digest": "58368f55fc201ea01917bd941190d00de8e40f4e5b161525d48d03eac877084e",
+          "last_commit": "d12d012",
           "name": "tests",
           "purpose": "Directory tests. Purpose not yet described by a human."
         },
         {
-          "digest": "9e08561d488a03e636cb8622b6667636230ac21cce1711e0ff6a45cf7f5c5761",
-          "last_commit": "00f54b6",
+          "digest": "1a6281ce3f92b5e68d0709eab039f9852df5e7132493e2e12f90f7ff495560d1",
+          "last_commit": "d12d012",
           "name": "tools",
           "purpose": "Directory tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:59067587092f050563a42fe041880c24f8c92e7c0c09bc01e5885b712222826b",
-      "compiled_at": "2026-10-04T19:57:19Z",
+      "children_root": "sha256:3dfdebd3b8a90fadcdc4cdf89c37d7939bfe585c8c3146736b41614ed8d4db47",
+      "compiled_at": "2026-10-04T19:57:41Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:55e53e69b40dc3fd8b30b97f8a493fda44b457f717f3048e3a37eb9c163589c4",
+      "digest": "sha256:ef305ccd639ab0ae01d1bd7d341ec115dc0e3abf98e84293a73fb0482b17d5fa",
       "evidence_files": 1289,
       "evidence_root": "sha256:748eb7ce0bd377815585505582eb76663350e35af3d876a488897ceea120ba3f",
       "files": 3049,
-      "generated_at_commit": "55d05d6a53e55dddc06f5eb689bee10c8830f52d",
-      "source_tree": "sha256:a1f0fb11e0348083ced716d80bdce7f58050b2f26cb1c146206fb4244f1af0ed"
+      "generated_at_commit": "d12d012a763f44ebb367431497eaf727256b25a8",
+      "source_tree": "sha256:89fe46eed931e5dda00562ec210c6f07446d0bdd5444742f372a3d16f17730a4"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/Makefile b/Makefile
index 3106d0830..a79189330 100644
--- a/Makefile
+++ b/Makefile
@@ -2173,6 +2173,7 @@ $(GPU_ATTN_TEST): tests/gpu_attention_test.c src/omega_gpu_attention_api.h $(OUT
 test-gpu-attention: $(GPU_ATTN_TEST)
 	./$(GPU_ATTN_TEST) --host-only
 	./$(GPU_ATTN_TEST) --sim
+	./$(GPU_ATTN_TEST) --sweep --sim --out $(OUT_DIR)/gpu_attention_sweep_sim.json
 
 # FB-1 cut 4b: fresh-process device-open probe (flake investigation, tools/probe_gpu_open.sh)
 $(OUT_DIR)/gpu_session_probe: tests/gpu_session_probe.c src/omega_gpu_session.h $(OUT_DIR)/libomega_gpu.a
diff --git a/docs/.crumb b/docs/.crumb
index a5012d5ce..3ce0ed302 100644
--- a/docs/.crumb
+++ b/docs/.crumb
@@ -81,8 +81,8 @@
           "purpose": "Directory docs/estimation. Purpose not yet described by a human."
         },
         {
-          "digest": "4272674cbb644368ae8fef74a5775144b11dbd3aac3eb25f073bd898f0268329",
-          "last_commit": "bceec7b",
+          "digest": "9d273061333f2d4c54d4450cf2ed8f5aad36e301fe2ba299399d388c47f86f8a",
+          "last_commit": "d12d012",
           "name": "numeric",
           "purpose": "Directory docs/numeric. Purpose not yet described by a human."
         },
@@ -117,15 +117,15 @@
           "purpose": "Directory docs/turing. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:c86da32ec6d7b7bc1f8db4bdf024fadf35ae5d588cbadf733db2292beb32691f",
-      "compiled_at": "2026-10-04T19:57:19Z",
+      "children_root": "sha256:202ed4db636f4f835d49c1b95ba93276d042d33cab14e49d40266d0905e7d125",
+      "compiled_at": "2026-10-04T19:57:41Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:e156df1e52268bb3346ded9bf7afcb426960e643a8889e1d76865a83a3a5a642",
+      "digest": "sha256:1c478a7e59b6a030f35f00356f51098708307326e8bd7127d99573e98666b395",
       "evidence_files": 26,
       "evidence_root": "sha256:f58236184eadc5f8c8f95499127a9f43c2f4dc702ddca267853d8c3dee0690f1",
       "files": 100,
-      "generated_at_commit": "55d05d6a53e55dddc06f5eb689bee10c8830f52d",
-      "source_tree": "sha256:a6ae94eae6a9333187ad07cf8161cb7261242e9ad567e32d80602224c4556887"
+      "generated_at_commit": "d12d012a763f44ebb367431497eaf727256b25a8",
+      "source_tree": "sha256:905f8c986ea594eb1dc8d8ed2ab228ff5f06078a5c3eb04b5a2f1b9d3e67c0ab"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/docs/numeric/.crumb b/docs/numeric/.crumb
index 211f49913..0061435f9 100644
--- a/docs/numeric/.crumb
+++ b/docs/numeric/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-04T19:07:57Z",
+      "compiled_at": "2026-10-04T19:18:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:4272674cbb644368ae8fef74a5775144b11dbd3aac3eb25f073bd898f0268329",
+      "digest": "sha256:9d273061333f2d4c54d4450cf2ed8f5aad36e301fe2ba299399d388c47f86f8a",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 10,
-      "generated_at_commit": "3a3144d4a2cbc4fd55a60da85fe94bd7ed5a9a39",
-      "source_tree": "sha256:804ae75ce73ff6bc90b9a9a820a86ec37274225b1528c09617df150ad4d5ec6c"
+      "generated_at_commit": "a274e0a2c8d39f3a9cb57cb9681a500b7d9f2252",
+      "source_tree": "sha256:afc08234f882c5d3af02da93f4e4443870ff429bc8c89c4a36647bbb5adaa66a"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/docs/numeric/FB1_CUT5_ATTENTION.md b/docs/numeric/FB1_CUT5_ATTENTION.md
index 1bd32ea20..87ea07774 100644
--- a/docs/numeric/FB1_CUT5_ATTENTION.md
+++ b/docs/numeric/FB1_CUT5_ATTENTION.md
@@ -88,6 +88,33 @@ mutant's. Names come from `omega_gpu_attention_mutant_name` (table checked again
 Negative control: the comparison must reject the oracle with kv heads swapped. Repeat run
 on a cache hit must be bit-identical.
 
+## Staging dedupe per launch (OM-2)
+
+The paged path stages the referenced blocks' layer slice into a GPU-uncached staging buffer.
+Within one batched launch the staged slot is now keyed by the physical block id: a block that
+several sequences reference (a shared prompt prefix) is copied once and every row of the
+renumbered block table points at the same slot. `OmegaGpuAttnInfo` reports the effect:
+`kv_blocks_logical` (table entries walked), `kv_blocks_unique` (slices actually copied),
+`kv_bytes_staged` (bytes copied) and `kv_bytes_naive` (what per-reference staging would have
+copied); `kv_source` is `OMEGA_GPU_ATTN_KV_STAGED` (0) in this cut, there is no resident KV
+(see "Limits"). `omega_gpu_attention_test_set_dedupe(false)` restores per-reference staging
+as a negative control; the test proves the legacy counters equal the naive numbers and that the
+deduped output is bit-identical to the legacy output. Simulator evidence, 4 sequences sharing
+10 scattered prefix blocks with private tails {1,2,3,3}: 8q/2kv (one launch) 19 unique of 49
+logical, 155648 of 401408 bytes; 32q/8kv (two launches, dedupe is per launch) 29 of 49,
+950272 of 1605632 bytes.
+
+## Head and kv-head scaling sweep (`gpu_attention_test --sweep --out <json>`)
+
+q heads {1,2,4,8,16,24,32,64} x every divisor as kv heads x context {256, 2048}, bs 16,
+scattered block ids with a shared prefix across 4 sequences. Non power-of-two ratios (the 24-head
+rows) must be refused with `BAD_ARGS` and are recorded as `unsupported_by_kernel_envelope`.
+Supported points: oracle parity on the first call, then N timed calls (20 on chip, 1 under
+`--sim`), recording median/p90 call and kernel milliseconds, launches, CTAs, threads per CTA,
+q/out widths and the staging counters above. Schema `OMEGA_GPU_ATTENTION_SWEEP_V1`; the file
+says `host_simulator` and that hardware counters are unavailable (no invented counters). The
+sweep asserts no timing thresholds; the 3 ms gate stays in `--timing`.
+
 ## Host IR simulator (`gpu_attention_test --sim`)
 
 Executes the allocated IR program (physical registers, so the register allocator's loop
@@ -103,8 +130,11 @@ of that CTA instruction by instruction.
 
 - head_dim 64 only (TinyLlama, Llama-3.2-1B). Larger heads need a bigger shared-memory
   declaration in the QMD (word 36) and a second thread-per-token tiling.
-- Staging copy of q, the referenced KV blocks and the tables per call; the device is opened
-  per call (cut 1b's resident handle API is the path to remove both).
+- Staging copy of q, the referenced KV blocks (once per physical block per launch, OM-2) and
+  the tables per call. No resident KV: the pool lives in an anonymous CPU mmap whose
+  "device address" is the CPU virtual address, not a GPU VA this channel can address, and
+  GPU-cached system memory is not coherent with CPU mappings (nvos.h), so a resident copy
+  needs an Omega-owned GPU-uncached mirror plus exact block generations from the pool.
 - Serialising instruction schedule (every instruction waits on everything pending), as in
   cut 4: correctness first, throughput later.
 - Context <= 4096 on the contiguous gqa path.
diff --git a/src/.crumb b/src/.crumb
index ab1ce0cd5..7610e4927 100644
--- a/src/.crumb
+++ b/src/.crumb
@@ -170,14 +170,14 @@
         }
       ],
       "children_root": "sha256:607467f8ea6e425bf33f7a0df65a411055a569e302b8127ab84822a0b4559109",
-      "compiled_at": "2026-10-04T19:57:19Z",
+      "compiled_at": "2026-10-04T19:57:41Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:fab4c6952b54567c65c8bd843e46bcd238c688940ed1d1830af2b584b057781b",
+      "digest": "sha256:be4a15a5245076828c97b151dd4ed1cc891c7dc5f22aee9ffdd0d93fb430e720",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 403,
-      "generated_at_commit": "55d05d6a53e55dddc06f5eb689bee10c8830f52d",
-      "source_tree": "sha256:bf53ea9b7e9ea01435d1b4889e9fae8f7dadddbbe66137845af1c377c0e6b667"
+      "generated_at_commit": "d12d012a763f44ebb367431497eaf727256b25a8",
+      "source_tree": "sha256:be5556c8348e8b02f96d241a4e0b4ade91f9cc94793b60f45c526218554ef8e2"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/src/omega_gpu_attention_api.c b/src/omega_gpu_attention_api.c
index d680009ea..aa83eab9e 100644
--- a/src/omega_gpu_attention_api.c
+++ b/src/omega_gpu_attention_api.c
@@ -422,6 +422,7 @@ static int build_kernel(const KSpec *k, OmegaBlackwellKernel *kernel, BlackwellI
 /* One kernel per KSpec; the device copy is uploaded once and stays resident for
  * the process (cut 4b). The IR program is kept for the host simulator. */
 static int g_mutant;
+static bool g_dedupe = true; /* shared-prefix staging dedupe; false = legacy per-sequence staging (test hook) */
 typedef struct { int used; KSpec k; OmegaBlackwellKernel kernel; BlackwellIRProgram *prog; NvrmMem code; } Slot;
 static OmegaGpuAttnSim g_sim;
 static Slot g_cache[8];
@@ -431,6 +432,7 @@ static bool g_hooked;
 #define UNLOCK() omega_gpu_session_unlock()
 
 void omega_gpu_attention_test_set_simulator(OmegaGpuAttnSim sim) { LOCK(); g_sim = sim; UNLOCK(); }
+void omega_gpu_attention_test_set_dedupe(bool on) { LOCK(); g_dedupe = on; UNLOCK(); }
 
 static void cache_clear_locked(void) {
     for (size_t i = 0; i < sizeof g_cache / sizeof g_cache[0]; i++)
@@ -568,8 +570,10 @@ static int run_launch(const Slot *ks, const Launch *L, OmegaGpuAttnInfo *info) {
     return unwritten ? OMEGA_GPU_ATTN_UNWRITTEN : OMEGA_GPU_ATTN_OK;
 }
 
-/* Caller holds the lock. */
+/* Caller holds the lock. Accounts the launch's q / table / output traffic (the KV
+ * staging bytes are accounted where the slices are copied). */
 static int launch(const Slot *ks, const Launch *L, OmegaGpuAttnInfo *info) {
+    if (info) { info->q_bytes += L->q_bytes; info->tab_bytes += L->tab_bytes; info->out_bytes += L->out_bytes; info->kv_source = OMEGA_GPU_ATTN_KV_STAGED; }
     if (g_sim) return g_sim(ks->prog, L, info);
     return run_launch(ks, L, info);
 }
@@ -633,6 +637,7 @@ int omega_gpu_gqa_attention_f32(const float *q, const float *k_cache, const floa
     if (!pool) { UNLOCK(); return OMEGA_GPU_ATTN_CHIP_FAIL; }
     memcpy(pool, k_cache, plane);
     memcpy(pool + plane, v_cache, plane);
+    if (info) { info->kv_bytes_staged += 2 * plane; info->kv_bytes_naive += 2 * plane; info->kv_blocks_logical += 1; info->kv_blocks_unique += 1; } /* one contiguous pseudo-block */
     uint32_t tab[2] = { 0, seq_len }; /* table row {0}, then the context length at byte 4 */
     Launch L = {
         .q = q, .q_bytes = n_out * 4, .pool = pool, .pool_bytes = 2 * plane, .tab = tab, .tab_bytes = sizeof tab,
@@ -681,27 +686,67 @@ static int paged_core(const float *q, const uint8_t *pool, const OmegaGpuKvLayou
     if (seqs_per_launch == 0) seqs_per_launch = 1;
     uint32_t maxb = 1;
     for (uint32_t s = 0; s < num_seqs; s++) if (n_blocks[s] > maxb) maxb = n_blocks[s];
+    /* Dedupe map: physical block id -> staged slot of the current launch (-1 = not staged yet),
+     * plus the list of ids touched by the launch (in slot order) so the reset is O(unique). */
+    int32_t *slot_of = NULL; uint32_t *touched = NULL;
+    if (g_dedupe) {
+        size_t nb = ly->num_blocks ? ly->num_blocks : 1;
+        slot_of = malloc(nb * sizeof *slot_of);
+        touched = malloc(nb * sizeof *touched);
+        if (!slot_of || !touched) { free(slot_of); free(touched); free(eff); UNLOCK(); return OMEGA_GPU_ATTN_CHIP_FAIL; }
+        memset(slot_of, 0xff, nb * sizeof *slot_of); /* every entry -1 */
+    }
     for (uint32_t s0 = 0; s0 < num_seqs && rc == OMEGA_GPU_ATTN_OK; s0 += seqs_per_launch) {
         uint32_t ns = num_seqs - s0 < seqs_per_launch ? num_seqs - s0 : seqs_per_launch;
-        /* stage the referenced blocks' layer slice, renumbered in table order */
+        /* logical references: every sequence's blocks up to its (truncated) context */
         uint32_t total = 0;
         for (uint32_t s = 0; s < ns; s++) total += eff[s0 + s] ? (eff[s0 + s] + ly->block_size - 1) / ly->block_size : 0;
-        uint64_t staged_bytes = (uint64_t)(total ? total : 1) * ly->layer_stride_bytes;
-        if (staged_bytes > 0xffffffffull) { rc = OMEGA_GPU_ATTN_TOO_LARGE; break; }
-        void *host_tmp = NULL;
-        uint8_t *staged = stage_target((size_t)staged_bytes, &host_tmp);
         uint32_t *tab = calloc((size_t)ns * maxb + ns, sizeof *tab);
-        if (!staged || !tab) { free(host_tmp); free(tab); rc = OMEGA_GPU_ATTN_CHIP_FAIL; break; }
+        if (!tab) { rc = OMEGA_GPU_ATTN_CHIP_FAIL; break; }
+        /* pass 1: assign staged slots. Dedupe keys on the PHYSICAL block id (not the table
+         * position): a CoW prefix block shared by several branches gets one slot. Each
+         * sequence's compact table keeps its own block order and truncated context. */
         uint32_t g = 0;
         for (uint32_t s = 0; s < ns; s++) {
             uint32_t need = eff[s0 + s] ? (eff[s0 + s] + ly->block_size - 1) / ly->block_size : 0;
-            for (uint32_t b = 0; b < need; b++, g++) {
-                const uint8_t *src = pool + (size_t)tables[s0 + s][b] * ly->block_stride_bytes + (size_t)layer_idx * ly->layer_stride_bytes;
-                memcpy(staged + (size_t)g * ly->layer_stride_bytes, src, (size_t)ly->layer_stride_bytes);
-                tab[(size_t)s * maxb + b] = g;
+            for (uint32_t b = 0; b < need; b++) {
+                uint32_t id = tables[s0 + s][b];
+                if (g_dedupe) {
+                    if (slot_of[id] < 0) { slot_of[id] = (int32_t)g; touched[g] = id; g++; }
+                    tab[(size_t)s * maxb + b] = (uint32_t)slot_of[id];
+                } else {
+                    tab[(size_t)s * maxb + b] = g++; /* legacy: one slot per reference */
+                }
             }
             tab[(size_t)ns * maxb + s] = eff[s0 + s];
         }
+        uint64_t staged_bytes = (uint64_t)(g ? g : 1) * ly->layer_stride_bytes;
+        if (staged_bytes > 0xffffffffull) { free(tab); rc = OMEGA_GPU_ATTN_TOO_LARGE; break; }
+        void *host_tmp = NULL;
+        uint8_t *staged = stage_target((size_t)staged_bytes, &host_tmp);
+        if (!staged) { free(tab); rc = OMEGA_GPU_ATTN_CHIP_FAIL; break; }
+        /* pass 2: copy each staged slot's (physical block, layer) slice exactly once */
+        if (g_dedupe) {
+            for (uint32_t u = 0; u < g; u++) {
+                const uint8_t *src = pool + (size_t)touched[u] * ly->block_stride_bytes + (size_t)layer_idx * ly->layer_stride_bytes;
+                memcpy(staged + (size_t)u * ly->layer_stride_bytes, src, (size_t)ly->layer_stride_bytes);
+                slot_of[touched[u]] = -1; /* reset for the next launch */
+            }
+        } else {
+            uint32_t w = 0;
+            for (uint32_t s = 0; s < ns; s++) {
+                uint32_t need = eff[s0 + s] ? (eff[s0 + s] + ly->block_size - 1) / ly->block_size : 0;
+                for (uint32_t b = 0; b < need; b++, w++) {
+                    const uint8_t *src = pool + (size_t)tables[s0 + s][b] * ly->block_stride_bytes + (size_t)layer_idx * ly->layer_stride_bytes;
+                    memcpy(staged + (size_t)w * ly->layer_stride_bytes, src, (size_t)ly->layer_stride_bytes);
+                }
+            }
+        }
+        if (info) {
+            info->kv_blocks_logical += total; info->kv_blocks_unique += g;
+            info->kv_bytes_staged += (uint64_t)g * ly->layer_stride_bytes;
+            info->kv_bytes_naive += (uint64_t)total * ly->layer_stride_bytes;
+        }
         Launch L = {
             .q = q + (size_t)s0 * row, .q_bytes = (size_t)ns * row * 4, .pool = staged, .pool_bytes = (size_t)staged_bytes,
             .tab = tab, .tab_bytes = ((size_t)ns * maxb + ns) * 4, .out = out + (size_t)s0 * row, .out_bytes = (size_t)ns * row * 4,
@@ -713,7 +758,7 @@ static int paged_core(const float *q, const uint8_t *pool, const OmegaGpuKvLayou
         free(host_tmp); free(tab);
     }
     UNLOCK();
-    free(eff);
+    free(eff); free(slot_of); free(touched);
     if (info) info->call_ns = now_ns() - t0;
     return rc;
 }
diff --git a/src/omega_gpu_attention_api.h b/src/omega_gpu_attention_api.h
index d498eef98..01ad01179 100644
--- a/src/omega_gpu_attention_api.h
+++ b/src/omega_gpu_attention_api.h
@@ -45,7 +45,10 @@
  * Staging: the host copies q, the referenced KV blocks' layer slice, the (compacted,
  * renumbered) block tables and the context lengths into GPU-uncached staging buffers
  * for each launch and copies the result back. The kernel itself walks the block
- * table; a resident pool handle is a later cut.
+ * table; a resident pool handle is a later cut. Since the attention hardening cut
+ * (2026-10-04) a launch stages each physical block's layer slice once however many
+ * sequences of the batch reference it (shared CoW prefixes), and OmegaGpuAttnInfo
+ * reports the bytes staged against the per-sequence (naive) figure.
  *
  * Cut 4b (2026-10-04): the device, channel and launch scratch are the process-wide
  * session shared with the matmul and elementwise APIs (omega_gpu_session.h): one
@@ -100,7 +103,16 @@ typedef struct {
     uint32_t ctas_last_launch, threads_per_cta;
     char target_chip[64];
     uint32_t sm_architecture;
+    /* Appended (attention hardening cut, 2026-10-04): transfer accounting for the call.
+     * Existing field order above is ABI; sovereign-core mirrors this struct field for field. */
+    uint64_t kv_bytes_staged;   /* KV layer-slice bytes actually copied into staging (sum over launches) */
+    uint64_t kv_bytes_naive;    /* what per-sequence staging would have copied (every sequence its own blocks) */
+    uint32_t kv_blocks_logical; /* block references summed over sequences, truncated to each context */
+    uint32_t kv_blocks_unique;  /* distinct (physical block, layer) slices staged, summed over launches */
+    uint64_t q_bytes, tab_bytes, out_bytes; /* q, block-table/context and result traffic (sum over launches) */
+    uint32_t kv_source;         /* OMEGA_GPU_ATTN_KV_STAGED; a resident pool is a later cut */
 } OmegaGpuAttnInfo;
+#define OMEGA_GPU_ATTN_KV_STAGED 0u
 
 /* Contiguous f32 KV (TensorBackend::gqa_attention). q and out: [num_q_heads][head_dim]. */
 int omega_gpu_gqa_attention_f32(const float *q, const float *k_cache, const float *v_cache,
@@ -173,6 +185,14 @@ struct BlackwellIRProgramTag;
 typedef int (*OmegaGpuAttnSim)(const void *prog /* const BlackwellIRProgram * */, const OmegaGpuAttnLaunch *L, OmegaGpuAttnInfo *info);
 void omega_gpu_attention_test_set_simulator(OmegaGpuAttnSim sim);
 
+/* Shared-prefix staging dedupe (attention hardening cut, 2026-10-04): within one launch
+ * every (physical block, layer) slice referenced by the batch is staged once, keyed by the
+ * physical block id, and every sequence's compact table points at that one staged slot.
+ * On by default. `false` selects the legacy per-sequence staging (every sequence copies
+ * its own blocks), kept as the reference fallback and as the negative control of the
+ * staging-byte tests. Test hook; never cleared in production. */
+void omega_gpu_attention_test_set_dedupe(bool on);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/tests/.crumb b/tests/.crumb
index 0843844a9..ab6260b53 100644
--- a/tests/.crumb
+++ b/tests/.crumb
@@ -284,14 +284,14 @@
         }
       ],
       "children_root": "sha256:0a4e348cf355e1fa5924f9c76a460d1d49bc285687b134365ef0fb9dab4f0855",
-      "compiled_at": "2026-10-04T19:57:19Z",
+      "compiled_at": "2026-10-04T19:57:41Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:9eb57c43d48ae70bce44757cbf075c38a03a090e0da529260d88e197e602c767",
+      "digest": "sha256:58368f55fc201ea01917bd941190d00de8e40f4e5b161525d48d03eac877084e",
       "evidence_files": 11,
       "evidence_root": "sha256:d5c1bceb4d57ef0eb42797c58801b5926509711614c3e38bb7105b6efa3942f2",
       "files": 790,
-      "generated_at_commit": "55d05d6a53e55dddc06f5eb689bee10c8830f52d",
-      "source_tree": "sha256:c3ad53ad3ba707657f944d28dcf4aa052510d627d52b5318e31172e7f13cc243"
+      "generated_at_commit": "d12d012a763f44ebb367431497eaf727256b25a8",
+      "source_tree": "sha256:0b472eb701f9a089b91ad665fe93d050ae46cdca92672a0ed7d2a6a65c3d5bae"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tests/gpu_attention_test.c b/tests/gpu_attention_test.c
index 03a64a470..af714069b 100644
--- a/tests/gpu_attention_test.c
+++ b/tests/gpu_attention_test.c
@@ -4,6 +4,9 @@
  *                                             mutant), register budget, nvdisasm listing check
  *   ./gpu_attention_test --timing [--out r.json] cut 4b gate: 1 query x 32 heads x 2048 ctx, 100 calls
  *                                             through the persistent session, median under 3 ms
+ *   ./gpu_attention_test --sweep [--out s.json]  head-scaling sweep: paged bf16 at head_dim 64 over q heads
+ *                                             1..64 x every kv-head divisor x ctx 256/2048, parity + timings
+ *                                             (receipt OMEGA_GPU_ATTENTION_SWEEP_V1; --sim marks host timings)
  *   ./gpu_attention_test --out receipt.json   chip gate: every shape against the host oracle, the
  *                                             mutants (deliberately wrong kernels, all of
  *                                             1 .. OMEGA_GPU_ATTN_MUTANT_COUNT-1) which the same
@@ -217,7 +220,12 @@ static void host_only(void) {
 
 /* ------------------------------------------------------------- chip gate */
 typedef struct { const char *name; size_t n; int rc; size_t bad; double worst; int pass; uint64_t chip_ns, call_ns; uint32_t calls, unwritten;
-                 int mutants_run, mutants_caught; char mutant_note[400]; } Case;
+                 int mutants_run, mutants_caught; char mutant_note[400];
+                 uint64_t kv_staged, kv_naive; uint32_t blk_logical, blk_unique; } Case;
+static void case_info(Case *c, const OmegaGpuAttnInfo *i) {
+    c->chip_ns = i->elapsed_ns; c->call_ns = i->call_ns; c->calls = i->chip_calls; c->unwritten = i->unwritten_words;
+    c->kv_staged = i->kv_bytes_staged; c->kv_naive = i->kv_bytes_naive; c->blk_logical = i->kv_blocks_logical; c->blk_unique = i->kv_blocks_unique;
+}
 static Case g_cases[32]; static int g_ncases;
 static int g_mutant_caught[OMEGA_GPU_ATTN_MUTANT_COUNT], g_mutant_run[OMEGA_GPU_ATTN_MUTANT_COUNT];
 
@@ -225,12 +233,13 @@ static void record(Case c, FILE *out) {
     g_cases[g_ncases++] = c;
     CHECK(c.pass, "%s rc=%s violations=%zu worst=%g", c.name, omega_gpu_attention_rc_name(c.rc), c.bad, c.worst);
     CHECK(c.mutants_caught == c.mutants_run, "%s mutants caught %d of %d (%s)", c.name, c.mutants_caught, c.mutants_run, c.mutant_note);
-    printf("%s %s n=%zu rc=%s violations=%zu worst_scaled_err=%g chip_ns=%" PRIu64 " call_ns=%" PRIu64 " calls=%u unwritten=%u | mutants %d/%d %s\n",
+    printf("%s %s n=%zu rc=%s violations=%zu worst_scaled_err=%g chip_ns=%" PRIu64 " call_ns=%" PRIu64 " calls=%u unwritten=%u kv_staged=%" PRIu64 "/%" PRIu64 " blocks=%u/%u | mutants %d/%d %s\n",
            c.pass && c.mutants_caught == c.mutants_run ? "PASS" : "FAIL", c.name, c.n, omega_gpu_attention_rc_name(c.rc), c.bad, c.worst, c.chip_ns, c.call_ns, c.calls, c.unwritten,
-           c.mutants_caught, c.mutants_run, c.mutant_note);
-    if (out) fprintf(out, "%s{\"case\":\"%s\",\"n\":%zu,\"rc\":\"%s\",\"violations\":%zu,\"worst_scaled_err\":%g,\"pass\":%s,\"chip_elapsed_ns\":%" PRIu64 ",\"call_ns\":%" PRIu64 ",\"chip_calls\":%u,\"unwritten_words\":%u,\"mutants_run\":%d,\"mutants_caught\":%d,\"mutant_note\":\"%s\"}",
+           c.kv_staged, c.kv_naive, c.blk_unique, c.blk_logical, c.mutants_caught, c.mutants_run, c.mutant_note);
+    if (out) fprintf(out, "%s{\"case\":\"%s\",\"n\":%zu,\"rc\":\"%s\",\"violations\":%zu,\"worst_scaled_err\":%g,\"pass\":%s,\"chip_elapsed_ns\":%" PRIu64 ",\"call_ns\":%" PRIu64 ",\"chip_calls\":%u,\"unwritten_words\":%u,"
+                     "\"kv_bytes_staged\":%" PRIu64 ",\"kv_bytes_naive\":%" PRIu64 ",\"kv_blocks_unique\":%u,\"kv_blocks_logical\":%u,\"mutants_run\":%d,\"mutants_caught\":%d,\"mutant_note\":\"%s\"}",
                      g_ncases > 1 ? "," : "", c.name, c.n, omega_gpu_attention_rc_name(c.rc), c.bad, c.worst, c.pass ? "true" : "false", c.chip_ns, c.call_ns, c.calls, c.unwritten,
-                     c.mutants_run, c.mutants_caught, c.mutant_note);
+                     c.kv_staged, c.kv_naive, c.blk_unique, c.blk_logical, c.mutants_run, c.mutants_caught, c.mutant_note);
 }
 
 static const char *mutant_name(int m) { return omega_gpu_attention_mutant_name((OmegaGpuAttnMutant)m); }
@@ -285,7 +294,7 @@ static int chip(const char *out_path) {
         GqaCtx gc = { q, kc, vc, seq, nqh, nkv };
         c.rc = run_gqa(&gc, got, &info);
         c.bad = compare(got, want, n, 2e-4, 2e-5, &c.worst);
-        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; c.chip_ns = info.elapsed_ns; c.call_ns = info.call_ns; c.calls = info.chip_calls; c.unwritten = info.unwritten_words;
+        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; case_info(&c, &info);
         if (ci == 3) {
             OmegaGpuAttnInfo i2; int rc2 = run_gqa(&gc, again, &i2);
             CHECK(rc2 == OMEGA_GPU_ATTN_OK && i2.kernel_cache_hit && memcmp(got, again, n * 4) == 0, "%s repeat run (cache hit) is bit-identical", name);
@@ -314,7 +323,7 @@ static int chip(const char *out_path) {
         OmegaGpuAttnInfo info; GqaCtx gc = { q, kc, vc, seq, nqh, nkv };
         c.rc = run_gqa(&gc, got, &info);
         c.bad = compare(got, want, n, 1e-3, 1e-4, &c.worst);
-        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; c.chip_ns = info.elapsed_ns; c.call_ns = info.call_ns; c.calls = info.chip_calls; c.unwritten = info.unwritten_words;
+        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; case_info(&c, &info);
         static const int ms[2] = { OMEGA_GPU_ATTN_MUTANT_NO_MAX, 0 };
         run_mutants(&c, ms, run_gqa, &gc, got, want, n, 1e-3, 1e-4);
         record(c, out); free(q); free(kc); free(vc); free(got); free(want);
@@ -332,7 +341,7 @@ static int chip(const char *out_path) {
         OmegaGpuAttnInfo info; GqaCtx gc = { q, kc, vc, seq, nqh, nkv };
         c.rc = run_gqa(&gc, got, &info);
         c.bad = compare(got, want, n, 2e-4, 2e-5, &c.worst);
-        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; c.chip_ns = info.elapsed_ns; c.call_ns = info.call_ns; c.calls = info.chip_calls; c.unwritten = info.unwritten_words;
+        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; case_info(&c, &info);
         static const int ms_q[2] = { OMEGA_GPU_ATTN_MUTANT_Q_ROW, 0 };
         static const int ms_o[3] = { OMEGA_GPU_ATTN_MUTANT_OUT_ROW, OMEGA_GPU_ATTN_MUTANT_KV_HEAD, 0 };
         run_mutants(&c, ms_q, run_gqa, &gc, got, want, n, 2e-4, 2e-5);
@@ -364,7 +373,7 @@ static int chip(const char *out_path) {
         OmegaGpuAttnInfo info; PagedCtx pc = { q, pool, &ly, ids, nblk, ctx, layer, nqh, nkv };
         c.rc = run_paged(&pc, got, &info);
         c.bad = compare(got, want, n, 2e-4, 2e-5, &c.worst);
-        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; c.chip_ns = info.elapsed_ns; c.call_ns = info.call_ns; c.calls = info.chip_calls; c.unwritten = info.unwritten_words;
+        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; case_info(&c, &info);
         if (ci == 3) {
             /* NO_MAX cannot overflow on unit-scale scores (softmax is shift invariant); it is caught by the large-score gqa case */
             static const int ms3[6] = { OMEGA_GPU_ATTN_MUTANT_KV_HEAD, OMEGA_GPU_ATTN_MUTANT_SLOT, OMEGA_GPU_ATTN_MUTANT_NO_RESCALE, OMEGA_GPU_ATTN_MUTANT_Q_ROW, OMEGA_GPU_ATTN_MUTANT_OUT_ROW, 0 };
@@ -402,13 +411,65 @@ static int chip(const char *out_path) {
         OmegaGpuAttnInfo info; BatchCtx bc = { q, pool, &ly, tables, ctxs2, maxb, nseq, layer, nqh, nkv };
         c.rc = run_batch(&bc, got, &info);
         c.bad = compare(got, want, n, 2e-4, 2e-5, &c.worst);
-        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; c.chip_ns = info.elapsed_ns; c.call_ns = info.call_ns; c.calls = info.chip_calls; c.unwritten = info.unwritten_words;
+        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; case_info(&c, &info);
         int zeros = 1; for (size_t i = 0; i < (size_t)nqh * hd; i++) if (got[(size_t)nqh * hd + i] != 0.0f) zeros = 0;
         CHECK(zeros, "batch: the empty sequence is all zeros");
         static const int ms[5] = { OMEGA_GPU_ATTN_MUTANT_KV_HEAD, OMEGA_GPU_ATTN_MUTANT_SLOT, OMEGA_GPU_ATTN_MUTANT_Q_ROW, OMEGA_GPU_ATTN_MUTANT_OUT_ROW, 0 };
         run_mutants(&c, ms, run_batch, &bc, got, want, n, 2e-4, 2e-5);
+        /* all 7 referenced blocks are distinct here, so dedupe stages exactly the naive figure */
+        CHECK(c.blk_logical == 7 && c.blk_unique == 7 && c.kv_staged == c.kv_naive && c.kv_staged == 7ull * ly.layer_stride_bytes, "batch: 7 distinct blocks staged once each (%u/%u, %" PRIu64 " bytes)", c.blk_unique, c.blk_logical, c.kv_staged);
         record(c, out); free(pool); free(tables); free(q); free(got); free(want);
     }
+    /* 5. branch-heavy batch (attention hardening cut): four sequences share the same 10 physical
+     * prefix blocks (160 tokens, scattered ids) and own private tails of 1..3 blocks ending in a
+     * partial 64-token chunk. The shared prefix must be staged once per launch, keyed by the
+     * physical block id. Two head shapes: 8q/2kv puts all four sequences in one launch
+     * (unique = 10 + 9 tails), 32q/8kv splits them two per launch (unique = 2*10 + 9).
+     * Negative control: the legacy per-sequence staging (test hook) copies the prefix four
+     * times and the byte-reduction check must flag it. */
+    for (int sh = 0; sh < 2; sh++) {
+        uint32_t nqh = sh ? 32 : 8, nkv = sh ? 8 : 2, bs = 16, layers = 2, layer = 1, nseq = 4, prefix_blocks = 10, pool_blocks = 64;
+        uint32_t expect_unique = sh ? 2 * prefix_blocks + 9 : prefix_blocks + 9;
+        uint32_t maxb = prefix_blocks + 3;
+        OmegaGpuKvLayout ly = layout_for(pool_blocks, bs, layers, nkv, hd);
+        uint8_t *pool = malloc(ly.pool_bytes); uint16_t *pw = (uint16_t *)pool;
+        for (size_t i = 0; i < ly.pool_bytes / 2; i++) pw[i] = f2bf(frand(&seed, -1.0f, 1.0f));
+        int32_t *tables = malloc((size_t)nseq * maxb * 4);
+        for (size_t i = 0; i < (size_t)nseq * maxb; i++) tables[i] = -1;
+        const uint32_t tails[4] = { 1, 2, 3, 3 };                 /* private blocks per sequence: 9 in all */
+        const int32_t ctxs5[4] = { 165, 180, 193, 207 };          /* 160 + 5, 20, 33, 47: every last chunk partial */
+        for (uint32_t s = 0; s < nseq; s++) {
+            for (uint32_t b = 0; b < prefix_blocks; b++) tables[s * maxb + b] = (int32_t)((b * 5 + 7) % pool_blocks); /* same scattered physical prefix */
+            for (uint32_t b = 0; b < tails[s]; b++) tables[s * maxb + prefix_blocks + b] = (int32_t)(50 + s * 3 + b);   /* private, distinct */
+        }
+        size_t n = (size_t)nseq * nqh * hd;
+        float *q = malloc(n * 4), *got = malloc(n * 4), *want = malloc(n * 4), *legacy = malloc(n * 4);
+        for (size_t i = 0; i < n; i++) q[i] = frand(&seed, -1.0f, 1.0f);
+        oracle_batch(q, pool, &ly, tables, ctxs5, maxb, nseq, layer, nqh, nkv, hd, want);
+        char name[96]; snprintf(name, sizeof name, "paged_bf16_shared_prefix_4seq_%uq%ukv_10pre", nqh, nkv);
+        Case c = { .name = strdup(name), .n = n };
+        OmegaGpuAttnInfo info; BatchCtx bc = { q, pool, &ly, tables, ctxs5, maxb, nseq, layer, nqh, nkv };
+        c.rc = run_batch(&bc, got, &info);
+        c.bad = compare(got, want, n, 2e-4, 2e-5, &c.worst);
+        c.pass = c.rc == OMEGA_GPU_ATTN_OK && c.bad == 0; case_info(&c, &info);
+        uint32_t logical = 4 * prefix_blocks + 9;
+        CHECK(c.blk_logical == logical && c.blk_unique == expect_unique, "%s: %u logical references, %u unique staged (expected %u/%u)", name, c.blk_logical, c.blk_unique, logical, expect_unique);
+        CHECK(c.kv_naive == (uint64_t)logical * ly.layer_stride_bytes && c.kv_staged == (uint64_t)expect_unique * ly.layer_stride_bytes && c.kv_staged < c.kv_naive,
+              "%s: staged %" PRIu64 " < naive %" PRIu64 " bytes (saved %" PRIu64 ")", name, c.kv_staged, c.kv_naive, c.kv_naive - c.kv_staged);
+        CHECK(info.kv_source == OMEGA_GPU_ATTN_KV_STAGED && info.q_bytes == n * 4 && info.out_bytes == n * 4 && info.tab_bytes > 0, "%s: q/out/table traffic accounted (q=%" PRIu64 " out=%" PRIu64 " tab=%" PRIu64 ")", name, info.q_bytes, info.out_bytes, info.tab_bytes);
+        /* negative control: legacy per-sequence staging duplicates the shared prefix; same answer, more bytes */
+        omega_gpu_attention_test_set_dedupe(false);
+        OmegaGpuAttnInfo li; int lrc = run_batch(&bc, legacy, &li);
+        omega_gpu_attention_test_set_dedupe(true);
+        double lw; size_t lbad = compare(legacy, want, n, 2e-4, 2e-5, &lw);
+        CHECK(lrc == OMEGA_GPU_ATTN_OK && lbad == 0, "%s legacy staging: parity (rc=%s bad=%zu)", name, omega_gpu_attention_rc_name(lrc), lbad);
+        CHECK(li.kv_blocks_unique == logical && li.kv_bytes_staged == li.kv_bytes_naive && li.kv_bytes_staged > c.kv_staged,
+              "%s negative control: duplicated prefix staging is flagged (legacy staged %" PRIu64 " == naive %" PRIu64 ", dedupe %" PRIu64 ")", name, li.kv_bytes_staged, li.kv_bytes_naive, c.kv_staged);
+        CHECK(memcmp(got, legacy, n * 4) == 0, "%s: dedupe and legacy staging are bit-identical", name);
+        static const int ms5[3] = { OMEGA_GPU_ATTN_MUTANT_KV_HEAD, OMEGA_GPU_ATTN_MUTANT_SLOT, 0 };
+        run_mutants(&c, ms5, run_batch, &bc, got, want, n, 2e-4, 2e-5);
+        record(c, out); free(pool); free(tables); free(q); free(got); free(want); free(legacy);
+    }
     /* every mutant the API knows (1 .. COUNT-1) ran at least once and was caught every time;
      * a mutant added to the enum without a battery entry fails here */
     for (int m = 1; m < OMEGA_GPU_ATTN_MUTANT_COUNT; m++) {
@@ -585,17 +646,114 @@ static int timing(const char *out_path) {
     return 0;
 }
 
+/* ------------------------------------------------ head-scaling sweep (attention hardening cut)
+ * `--sweep [--out sweep.json]`: the production paged bf16 path at head_dim 64 over query-head
+ * counts 1, 2, 4, 8, 16, 24, 32, 64 and every divisor as the kv-head count, at context 256
+ * (latency) and 2048 (bandwidth), block size 16, scattered block ids. Points whose GQA ratio
+ * is not a power of two are mathematically legal (the generic contract allows them) but
+ * outside the current kernel envelope (codegen selects the kv head with a shift): they are
+ * called anyway, must be refused with BAD_ARGS, and are recorded as
+ * "unsupported_by_kernel_envelope" (no chip time). Every supported point is checked against
+ * the host oracle on its first call, then warmed and timed over N calls (median / p90 of the
+ * whole call and of the chip kernel time). Gates: parity, no unwritten word, one device open,
+ * every call OK; the timings are evidence, not a threshold. Only quantities the stack measures
+ * are recorded; SM occupancy, bandwidth utilisation and cache hit rates are not observable
+ * through this path and are reported as unavailable. Under --sim the timings are host-simulator
+ * timings and the receipt says so. */
+static int sweep(const char *out_path) {
+    FILE *out = out_path ? fopen(out_path, "w") : NULL;
+    if (out_path && !out) { printf("cannot open %s\n", out_path); return 2; }
+    const int N = g_sim_mode ? 1 : 20;
+    const uint32_t hd = 64, bs = 16, layers = 1, layer = 0;
+    static const uint32_t qheads[8] = { 1, 2, 4, 8, 16, 24, 32, 64 };
+    static const uint32_t ctxs[2] = { 256, 2048 };
+    uint32_t seed = 0xfb1c05eeu;
+    if (out) fprintf(out, "{\"schema\":\"OMEGA_GPU_ATTENTION_SWEEP_V1\",\"path\":\"paged_bf16\",\"head_dim\":%u,\"block_size\":%u,\"timed_calls\":%d,\"host_simulator\":%s,"
+                     "\"tolerances\":{\"rel\":2e-4,\"abs\":2e-5},\"hardware_counters\":\"unavailable (SM occupancy, bandwidth utilisation, cache hit rates are not observable through this path)\",\"points\":[",
+                     hd, bs, N, g_sim_mode ? "true" : "false");
+    int npoints = 0, supported = 0, unsupported = 0;
+    double *samples = malloc((size_t)N * sizeof *samples), *ksamples = malloc((size_t)N * sizeof *ksamples);
+    for (int qi = 0; qi < 8; qi++) for (uint32_t nkv = 1; nkv <= qheads[qi]; nkv++) {
+        uint32_t nqh = qheads[qi];
+        if (nqh % nkv) continue;
+        uint32_t ratio = nqh / nkv; int pow2 = (ratio & (ratio - 1)) == 0;
+        for (int ci = 0; ci < 2; ci++) {
+            uint32_t ctx = ctxs[ci], nblk = (ctx + bs - 1) / bs, pool_blocks = nblk + 5;
+            OmegaGpuKvLayout ly = layout_for(pool_blocks, bs, layers, nkv, hd);
+            uint8_t *pool = malloc(ly.pool_bytes); uint16_t *pw = (uint16_t *)pool;
+            for (size_t i = 0; i < ly.pool_bytes / 2; i++) pw[i] = f2bf(frand(&seed, -1.0f, 1.0f));
+            uint32_t *ids = malloc(nblk * 4);
+            for (uint32_t b = 0; b < nblk; b++) ids[b] = (b * 7 + 3) % pool_blocks;
+            size_t n = (size_t)nqh * hd;
+            float *q = malloc(n * 4), *got = malloc(n * 4), *want = malloc(n * 4);
+            for (size_t i = 0; i < n; i++) q[i] = frand(&seed, -1.0f, 1.0f);
+            OmegaGpuAttnInfo info; memset(&info, 0, sizeof info);
+            int rc = omega_gpu_paged_attention_bf16(q, pool, &ly, ids, nblk, ctx, layer, nqh, nkv, hd, got, &info);
+            const char *klass; int pass; size_t bad = 0; double worst = 0; int ok_calls = 0; uint32_t unwritten = 0, cache_hits = 0; double med = 0, p90 = 0, kmed = 0, kp90 = 0;
+            if (!pow2) {
+                klass = "unsupported_by_kernel_envelope";
+                pass = rc == OMEGA_GPU_ATTN_BAD_ARGS; unsupported++;
+                CHECK(pass, "sweep %uq/%ukv ctx %u: ratio %u (not a power of two) refused with BAD_ARGS (got %s)", nqh, nkv, ctx, ratio, omega_gpu_attention_rc_name(rc));
+            } else {
+                klass = "supported"; supported++;
+                oracle_paged(q, pool, &ly, ids, nblk, ctx, layer, nqh, nkv, hd, want);
+                bad = compare(got, want, n, 2e-4, 2e-5, &worst);
+                unwritten = info.unwritten_words;
+                uint64_t kv_staged = info.kv_bytes_staged, kv_naive = info.kv_bytes_naive, qb = info.q_bytes, tb = info.tab_bytes, ob = info.out_bytes;
+                uint32_t launches = info.chip_calls, ctas = info.ctas_last_launch, blk_l = info.kv_blocks_logical, blk_u = info.kv_blocks_unique, kv_src = info.kv_source;
+                for (int i = 0; i < N; i++) {
+                    OmegaGpuAttnInfo ti;
+                    int trc = omega_gpu_paged_attention_bf16(q, pool, &ly, ids, nblk, ctx, layer, nqh, nkv, hd, got, &ti);
+                    samples[i] = ti.call_ns / 1e6; ksamples[i] = ti.elapsed_ns / 1e6;
+                    double w; size_t b2 = compare(got, want, n, 2e-4, 2e-5, &w);
+                    if (w > worst) worst = w;
+                    bad += b2; unwritten += ti.unwritten_words; cache_hits += ti.kernel_cache_hit;
+                    if (trc == OMEGA_GPU_ATTN_OK && b2 == 0) ok_calls++;
+                }
+                qsort(samples, (size_t)N, sizeof samples[0], cmp_d); qsort(ksamples, (size_t)N, sizeof ksamples[0], cmp_d);
+                med = samples[N / 2]; p90 = samples[N * 9 / 10]; kmed = ksamples[N / 2]; kp90 = ksamples[N * 9 / 10];
+                pass = rc == OMEGA_GPU_ATTN_OK && bad == 0 && ok_calls == N && unwritten == 0 && cache_hits == (uint32_t)N;
+                CHECK(pass, "sweep %uq/%ukv ctx %u: rc=%s violations=%zu ok_calls=%d/%d unwritten=%u cache_hits=%u", nqh, nkv, ctx, omega_gpu_attention_rc_name(rc), bad, ok_calls, N, unwritten, cache_hits);
+                printf("%s sweep %2uq/%2ukv ratio %2u ctx %4u: launches=%u ctas=%u call_ms med=%.3f p90=%.3f kernel_ms med=%.3f p90=%.3f kv_staged=%" PRIu64 " (naive %" PRIu64 ") blocks=%u/%u q=%" PRIu64 " tab=%" PRIu64 " out=%" PRIu64 " worst=%g\n",
+                       pass ? "PASS" : "FAIL", nqh, nkv, ratio, ctx, launches, ctas, med, p90, kmed, kp90, kv_staged, kv_naive, blk_u, blk_l, qb, tb, ob, worst);
+                if (out) fprintf(out, "%s{\"q_heads\":%u,\"kv_heads\":%u,\"gqa_ratio\":%u,\"head_dim\":%u,\"context\":%u,\"q_width\":%zu,\"out_width\":%zu,\"class\":\"%s\",\"rc\":\"%s\",\"pass\":%s,"
+                                 "\"violations\":%zu,\"worst_scaled_err\":%g,\"unwritten_words\":%u,\"launches_per_call\":%u,\"ctas_last_launch\":%u,\"threads_per_cta\":%u,"
+                                 "\"call_ms_median\":%.4f,\"call_ms_p90\":%.4f,\"kernel_ms_median\":%.4f,\"kernel_ms_p90\":%.4f,\"kernel_cache_hits\":%u,\"first_call_cache_hit\":%s,"
+                                 "\"kv_bytes_staged\":%" PRIu64 ",\"kv_bytes_naive\":%" PRIu64 ",\"kv_blocks_logical\":%u,\"kv_blocks_unique\":%u,\"q_bytes\":%" PRIu64 ",\"tab_bytes\":%" PRIu64 ",\"out_bytes\":%" PRIu64 ",\"kv_source\":\"%s\"}",
+                                 npoints ? "," : "", nqh, nkv, ratio, hd, ctx, n, n, klass, omega_gpu_attention_rc_name(rc), pass ? "true" : "false", bad, worst, unwritten, launches, ctas, info.threads_per_cta,
+                                 med, p90, kmed, kp90, cache_hits, info.kernel_cache_hit ? "true" : "false", kv_staged, kv_naive, blk_l, blk_u, qb, tb, ob, kv_src == OMEGA_GPU_ATTN_KV_STAGED ? "staged" : "resident");
+                npoints++;
+            }
+            if (!pow2) {
+                printf("%s sweep %2uq/%2ukv ratio %2u ctx %4u: %s (rc=%s)\n", pass ? "PASS" : "FAIL", nqh, nkv, ratio, ctx, klass, omega_gpu_attention_rc_name(rc));
+                if (out) fprintf(out, "%s{\"q_heads\":%u,\"kv_heads\":%u,\"gqa_ratio\":%u,\"head_dim\":%u,\"context\":%u,\"q_width\":%zu,\"out_width\":%zu,\"class\":\"%s\",\"rc\":\"%s\",\"pass\":%s}",
+                                 npoints ? "," : "", nqh, nkv, ratio, hd, ctx, n, n, klass, omega_gpu_attention_rc_name(rc), pass ? "true" : "false");
+                npoints++;
+            }
+            free(pool); free(ids); free(q); free(got); free(want);
+        }
+    }
+    free(samples); free(ksamples);
+    uint32_t opens = omega_gpu_session_open_count();
+    CHECK(opens == (g_sim_mode ? 0u : 1u), "sweep: device opened %s (opens=%u)", g_sim_mode ? "never (simulator)" : "once", opens);
+    printf("sweep: %d points (%d supported, %d unsupported by the kernel envelope), device_opens=%u\n", npoints, supported, unsupported, opens);
+    if (out) { fprintf(out, "],\"points_total\":%d,\"points_supported\":%d,\"points_unsupported\":%d,\"device_opens\":%u,\"checks\":%d,\"failed\":%d,\"verdict\":\"%s\"}\n", npoints, supported, unsupported, opens, g_checks, g_failed, g_failed == 0 ? "OMEGA_GPU_ATTENTION_SWEEP_PASS" : "OMEGA_GPU_ATTENTION_SWEEP_FAIL"); fclose(out); }
+    return 0;
+}
+
 int main(int argc, char **argv) {
-    const char *out_path = NULL; int host = 0, sim = 0, timing_mode = 0;
+    const char *out_path = NULL; int host = 0, sim = 0, timing_mode = 0, sweep_mode = 0;
     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], "--timing") == 0) timing_mode = 1;
+        else if (strcmp(argv[i], "--sweep") == 0) sweep_mode = 1;
         else if (strcmp(argv[i], "--out") == 0 && i + 1 < argc) out_path = argv[++i];
     }
     if (sim) { g_sim_mode = 1; omega_gpu_attention_test_set_simulator(sim_launch); }
     if (host) host_only();
     else if (timing_mode) { if (timing(out_path) != 0) return 2; }
+    else if (sweep_mode) { if (sweep(out_path) != 0) return 2; }
     else if (chip(out_path) != 0) return 2;
     printf("%s: %d checks, %d failed\n", g_failed ? "FAIL" : "PASS", g_checks, g_failed);
     return g_failed ? 1 : 0;
diff --git a/tools/.crumb b/tools/.crumb
index 49b41d808..2b8e1d430 100644
--- a/tools/.crumb
+++ b/tools/.crumb
@@ -56,14 +56,14 @@
         }
       ],
       "children_root": "sha256:0920c282c31e3be9b4745fab718ceb60dbfe2ea90dda2108986f60fc2ac53e23",
-      "compiled_at": "2026-10-04T19:07:57Z",
+      "compiled_at": "2026-10-04T19:18:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:9e08561d488a03e636cb8622b6667636230ac21cce1711e0ff6a45cf7f5c5761",
+      "digest": "sha256:1a6281ce3f92b5e68d0709eab039f9852df5e7132493e2e12f90f7ff495560d1",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 120,
-      "generated_at_commit": "3a3144d4a2cbc4fd55a60da85fe94bd7ed5a9a39",
-      "source_tree": "sha256:172b5a4666f700959782e204a6278eaf02307c5fe94fcf6f9441ae5bd8918412"
+      "generated_at_commit": "a274e0a2c8d39f3a9cb57cb9681a500b7d9f2252",
+      "source_tree": "sha256:cbcfb5f36ecaa585d40d30eed94d7992c3fdf9b069b1dc25a2d720970d184762"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/tools/run_gpu_attention_chip.sh b/tools/run_gpu_attention_chip.sh
index ac2ba9bd0..734b6a0b8 100755
--- a/tools/run_gpu_attention_chip.sh
+++ b/tools/run_gpu_attention_chip.sh
@@ -7,6 +7,8 @@
 # negative control and a cache-hit repeat. Sealed receipt folder
 # OUT_ROOT/FB1-CUT5-<sha>/ (default ~/workspace/evidence-out):
 #   receipt.json  machine-readable verdict per case      run.log    test output
+#   sweep.json    head-scaling sweep (q/kv heads x ctx)  sweep.log  its output
+#   timing.json   cut 4b timing gate (median < 3 ms)      timing.log its output
 #   device.txt    kernel, driver, omega and physics shas  build.log  compiler output
 #   sim.log       the same battery through the host IR simulator, run first
 #   copies of the three source files the verdict depends on, SHA256SUMS over all
@@ -35,8 +37,15 @@ if [ "$sim_rc" -ne 0 ]; then
 fi
 ./build/gpu_attention_test --out "$OUT/receipt.json" > "$OUT/run.log" 2>&1
 rc=$?
+# head-scaling sweep (attention hardening cut) and the cut 4b timing gate, same session rules
+./build/gpu_attention_test --sweep --out "$OUT/sweep.json" > "$OUT/sweep.log" 2>&1
+sweep_rc=$?
+./build/gpu_attention_test --timing --out "$OUT/timing.json" > "$OUT/timing.log" 2>&1
+timing_rc=$?
+[ "$rc" -eq 0 ] && rc=$sweep_rc
+[ "$rc" -eq 0 ] && rc=$timing_rc
 cp src/omega_gpu_attention_api.c src/omega_gpu_attention_api.h tests/gpu_attention_test.c "$OUT/"
 (cd "$OUT" && sha256sum -- * > SHA256SUMS)
-tail -1 "$OUT/run.log"
-echo "FB1-CUT5 chip gate rc=$rc receipt=$OUT/receipt.json"
+tail -1 "$OUT/run.log"; tail -1 "$OUT/sweep.log"; tail -1 "$OUT/timing.log"
+echo "FB1-CUT5 chip gate rc=$rc (sweep rc=$sweep_rc timing rc=$timing_rc) receipt=$OUT/receipt.json sweep=$OUT/sweep.json"
 exit $rc