Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/patches/b3141c397cf63c92 # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/omega-mv#411 (code only) closed derived `b3141c397cf63c92` #411 Imported from GitHub aien-dev/omega-mv#411 (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 `e1fd259d24e3892556a396d34ccb0551729330cd` · Head `f7463079ce2aba39d04a6c1e1d4e745a5b20c7e9` ### Apply it ``` git checkout -b patch-b3141c397cf63c92 e1fd259d24e3892556a396d34ccb0551729330cd curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/b3141c397cf63c92.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 411 f7463079ce2aba39d04a6c1e1d4e745a5b20c7e9 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":411,"url":"https://github.com/aien-dev/omega-mv/pull/411","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:47Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 09069ea06..6a863531d 100644 --- a/.crumb +++ b/.crumb @@ -87,14 +87,14 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "75fec26567f55d0e562142b1af20bd99720dc6234c6d240f7666b7bac492e839", - "last_commit": "1339759c", + "digest": "c33506c2d8631760724d58bb289fd919708ba36544f9f2e9cb965b98135655ce", + "last_commit": "09eed552", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "2c25a63590c9d5759d12eacabb3cd37adbac87e8ee6ac4e074b4970e3419d144", - "last_commit": "1339759c", + "digest": "c8932aae0268325ccc74e09284de055134b022abdfaa080227f5be40c0a638e7", + "last_commit": "09eed552", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -105,15 +105,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:5915c54b2603c860c268df3245eb1c216bead640c9d3e7b76d01c5f0c8662773", - "compiled_at": "2026-10-12T08:02:05Z", + "children_root": "sha256:e08d6114f714cb983afbd6163802e3755302dc35def33c5a4a9af4959aa30c94", + "compiled_at": "2026-10-12T08:17:13Z", "compiler": "crumb-compile/1", - "digest": "sha256:fc7b5b2170d9e44c319668e8f12649172b33995f03a1ad6ac782b8921dd859b5", + "digest": "sha256:4b4c03d378eee5119797d16061cf58e9a5d62ea7446b1861077ae242c659b831", "evidence_files": 7245, "evidence_root": "sha256:035beef5cdb99afaefd1743640f5e7eeaaed13c4a5ec6c8b4b6a4cb0c528407a", "files": 9734, - "generated_at_commit": "51b0b4a3514266219dd50ea32ea66e5b2f5a144d", - "source_tree": "sha256:9bd7de37a9a347d44cb043349f47eab2f001a54245a1c6a74b3cee1f3d8fb51d" + "generated_at_commit": "09eed5528137abc1103768858538db18815654ab", + "source_tree": "sha256:6f903c535c14d9ce6bfad05e181e87819a35923c891380ddc7ffe8c98692d9a4" }, "owner_lane": "", "provenance": { diff --git a/src/.crumb b/src/.crumb index 74b02bf66..98860b109 100644 --- a/src/.crumb +++ b/src/.crumb @@ -176,14 +176,14 @@ } ], "children_root": "sha256:2f64d32b2351272f4de10e1143efdb74dbc3cae56b1f0a3039ca9edcfebf6e8c", - "compiled_at": "2026-10-12T07:29:56Z", + "compiled_at": "2026-10-12T08:17:13Z", "compiler": "crumb-compile/1", - "digest": "sha256:75fec26567f55d0e562142b1af20bd99720dc6234c6d240f7666b7bac492e839", + "digest": "sha256:c33506c2d8631760724d58bb289fd919708ba36544f9f2e9cb965b98135655ce", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 451, - "generated_at_commit": "ec1d3398f0dcc91e6eb66c21107299f042682cff", - "source_tree": "sha256:ba11b6b3e0bb56ab2ea66d441a265da89eab4e3c19ec165194398a3418c79929" + "generated_at_commit": "09eed5528137abc1103768858538db18815654ab", + "source_tree": "sha256:7147cd5fbc544c2eec82bad9702336692840f284b328b67c08025a8c528b0326" }, "owner_lane": "", "provenance": { diff --git a/src/omega_gpu_attention_api.c b/src/omega_gpu_attention_api.c index 728ceceff..3edadbae5 100644 --- a/src/omega_gpu_attention_api.c +++ b/src/omega_gpu_attention_api.c @@ -559,6 +559,7 @@ typedef struct { int used; KSpec k; OmegaBlackwellKernel kernel; BlackwellIRProg static OmegaGpuAttnSim g_sim; static Slot g_cache[8]; static OmegaGpuScratch g_q, g_pool, g_tab, g_out; /* staging, grown to the high-water mark, reused per call */ +static NvrmMem g_resident; /* the resident KV pool (omega_gpu_attention_pool_alloc); cpu NULL = none */ static bool g_hooked; #define LOCK() omega_gpu_session_lock() #define UNLOCK() omega_gpu_session_unlock() @@ -566,6 +567,47 @@ static bool g_hooked; 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(); } +/* ---- resident KV pool (see the header) ---- */ + +static int dev_open_locked(void); + +/* The kernel computes block_id * block_stride + slot * token_stride + head offset in 32 bits before + * widening onto the 64-bit layer base: one layer slice (both planes, every token and head of the + * block) past the block's start must stay inside 32 bits. */ +static bool resident_fits(const OmegaGpuKvLayout *ly, uint32_t block_id) { + return ly->block_stride_bytes <= 0xffffffffull && + (uint64_t)block_id * ly->block_stride_bytes + ly->layer_stride_bytes <= 0xffffffffull; +} +bool omega_gpu_attention_test_resident_fits(const OmegaGpuKvLayout *layout, uint32_t block_id) { + return layout && resident_fits(layout, block_id); +} + +int omega_gpu_attention_pool_alloc(size_t bytes, void **cpu) { + if (!cpu || bytes == 0) return OMEGA_GPU_ATTN_BAD_ARGS; + *cpu = NULL; + LOCK(); + if (g_resident.cpu) { omega_gpu_session_set_error("attention pool: already allocated"); UNLOCK(); return OMEGA_GPU_ATTN_BAD_ARGS; } + if (g_sim) { + g_resident.cpu = calloc(1, bytes); + if (!g_resident.cpu) { UNLOCK(); return OMEGA_GPU_ATTN_CHIP_FAIL; } + g_resident.va = (uintptr_t)g_resident.cpu; g_resident.size = bytes; + } else { + int rc = dev_open_locked(); + if (rc != OMEGA_GPU_ATTN_OK) { UNLOCK(); return rc; } + if (omega_gpu_session_alloc(bytes, &g_resident) != 0) { memset(&g_resident, 0, sizeof g_resident); UNLOCK(); return OMEGA_GPU_ATTN_CHIP_FAIL; } + } + *cpu = g_resident.cpu; + UNLOCK(); + return OMEGA_GPU_ATTN_OK; +} + +void omega_gpu_attention_pool_free(void) { + LOCK(); + if (g_resident.cpu) { if (g_sim) free(g_resident.cpu); else omega_gpu_session_free(&g_resident); } + memset(&g_resident, 0, sizeof g_resident); + UNLOCK(); +} + static void cache_clear_locked(void) { for (size_t i = 0; i < sizeof g_cache / sizeof g_cache[0]; i++) if (g_cache[i].used) { free(g_cache[i].kernel.code); free(g_cache[i].prog); omega_gpu_session_free(&g_cache[i].code); memset(&g_cache[i], 0, sizeof g_cache[i]); } @@ -580,6 +622,7 @@ void omega_gpu_attention_cache_clear(void) { /* Called by the session (lock held, device still open) right before it closes. */ static void on_session_close(void) { cache_clear_locked(); + memset(&g_resident, 0, sizeof g_resident); /* the session's memory goes with it; the caller's mapping is dead */ omega_gpu_session_scratch_free(&g_q); omega_gpu_session_scratch_free(&g_pool); omega_gpu_session_scratch_free(&g_tab); omega_gpu_session_scratch_free(&g_out); } @@ -673,10 +716,11 @@ static int run_launch(const Slot *ks, const Launch *L, OmegaGpuAttnInfo *info) { int sr = omega_gpu_session_scratch(&g_q, L->q_bytes); if (!sr) sr = omega_gpu_session_scratch(&g_tab, L->tab_bytes); if (!sr) sr = omega_gpu_session_scratch(&g_out, L->out_bytes); - if (!sr && L->pool != g_pool.mem.cpu) sr = omega_gpu_session_scratch(&g_pool, L->pool_bytes); + if (!sr && !L->pool_va && L->pool != g_pool.mem.cpu) sr = omega_gpu_session_scratch(&g_pool, L->pool_bytes); if (sr) return sr == OMEGA_GPU_SESSION_SCRATCH_RESERVED ? OMEGA_GPU_ATTN_TOO_LARGE : OMEGA_GPU_ATTN_CHIP_FAIL; memcpy(g_q.mem.cpu, L->q, L->q_bytes); - if (L->pool != g_pool.mem.cpu) memcpy(g_pool.mem.cpu, L->pool, L->pool_bytes); + if (!L->pool_va && L->pool != g_pool.mem.cpu) memcpy(g_pool.mem.cpu, L->pool, L->pool_bytes); + const uint64_t pool_va = L->pool_va ? L->pool_va : g_pool.mem.va; /* resident: the caller's KV, read in place */ memcpy(g_tab.mem.cpu, L->tab, L->tab_bytes); size_t out_words = L->out_bytes / 4; uint32_t *out_dev = (uint32_t *)g_out.mem.cpu; @@ -685,7 +729,7 @@ static int run_launch(const Slot *ks, const Launch *L, OmegaGpuAttnInfo *info) { uint32_t args[ARG_WORDS]; args[0] = (uint32_t)g_q.mem.va; args[1] = (uint32_t)(g_q.mem.va >> 32); - args[2] = (uint32_t)g_pool.mem.va; args[3] = (uint32_t)(g_pool.mem.va >> 32); + args[2] = (uint32_t)pool_va; args[3] = (uint32_t)(pool_va >> 32); args[4] = (uint32_t)g_out.mem.va; args[5] = (uint32_t)(g_out.mem.va >> 32); args[6] = (uint32_t)g_tab.mem.va; args[7] = (uint32_t)(g_tab.mem.va >> 32); memcpy(&args[8], L->params, sizeof L->params); @@ -714,7 +758,10 @@ static int run_launch(const Slot *ks, const Launch *L, OmegaGpuAttnInfo *info) { /* 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 (info) { + info->q_bytes += L->q_bytes; info->tab_bytes += L->tab_bytes; info->out_bytes += L->out_bytes; + info->kv_source = L->pool_va ? OMEGA_GPU_ATTN_KV_RESIDENT : OMEGA_GPU_ATTN_KV_STAGED; + } if (g_sim) return g_sim(ks->prog, L, info); return run_launch(ks, L, info); } @@ -954,10 +1001,17 @@ 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]; + /* Resident pool (2026-10-12): the caller's pool IS omega's allocation. Read it in place when the + * layout fits the allocation and every referenced block passes the 32-bit fit rule; else stage. */ + bool resident = g_resident.cpu && (const void *)pool == g_resident.cpu && ly->pool_bytes <= g_resident.size; + for (uint32_t s = 0; resident && s < num_seqs; s++) { + uint32_t need = eff[s] ? (eff[s] + ly->block_size - 1) / ly->block_size : 0; + for (uint32_t b = 0; b < need; b++) if (!resident_fits(ly, tables[s][b])) { resident = false; break; } + } /* 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) { + if (g_dedupe && !resident) { size_t nb = ly->num_blocks ? ly->num_blocks : 1; slot_of = malloc(nb * sizeof *slot_of); touched = malloc(nb * sizeof *touched); @@ -971,6 +1025,28 @@ static int paged_core(const float *q, const uint8_t *pool, const OmegaGpuKvLayou for (uint32_t s = 0; s < ns; s++) total += eff[s0 + s] ? (eff[s0 + s] + ly->block_size - 1) / ly->block_size : 0; uint32_t *tab = calloc((size_t)ns * maxb + ns, sizeof *tab); if (!tab) { rc = OMEGA_GPU_ATTN_CHIP_FAIL; break; } + if (resident) { + /* the table carries the physical ids; the kernel's block stride is the pool's; the layer + * base is the chip address of this layer's slice of block 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++) tab[(size_t)s * maxb + b] = tables[s0 + s][b]; + tab[(size_t)ns * maxb + s] = eff[s0 + s]; + } + if (info) { info->kv_blocks_logical += total; 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 = (const uint8_t *)pool + (size_t)layer_idx * ly->layer_stride_bytes, .pool_bytes = 0, + .tab = tab, .tab_bytes = ((size_t)ns * maxb + ns) * 4, .out = out + (size_t)s0 * row, .out_bytes = (size_t)ns * row * 4, + .grid_x = num_q_heads, .grid_y = ns, + .params = { maxb, f2u(score_scale(HD)), (uint32_t)ly->block_stride_bytes, (uint32_t)ly->token_stride_bytes, + (uint32_t)ly->kv_plane_stride_bytes, (uint32_t)ly->head_stride_bytes, num_q_heads, ns * maxb * 4 }, + .pool_va = g_resident.va + (uint64_t)layer_idx * ly->layer_stride_bytes, + }; + rc = launch(ks, &L, info); + free(tab); + continue; + } /* 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. */ diff --git a/src/omega_gpu_attention_api.h b/src/omega_gpu_attention_api.h index 78e943dee..c6c863f4b 100644 --- a/src/omega_gpu_attention_api.h +++ b/src/omega_gpu_attention_api.h @@ -48,7 +48,9 @@ * 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. Since the attention hardening cut + * table. Resident pool (2026-10-12): a paged call whose pool pointer is the allocation + * omega_gpu_attention_pool_alloc returned reads the KV in place instead (no staging; see + * that declaration for the one rule). 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. @@ -114,9 +116,10 @@ typedef struct { 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 */ + uint32_t kv_source; /* OMEGA_GPU_ATTN_KV_STAGED (slices copied per call) or OMEGA_GPU_ATTN_KV_RESIDENT (read in place) */ } OmegaGpuAttnInfo; #define OMEGA_GPU_ATTN_KV_STAGED 0u +#define OMEGA_GPU_ATTN_KV_RESIDENT 1u /* 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, @@ -152,6 +155,20 @@ int omega_gpu_paged_attention_batch_bf16(const float *q, const void *pool, const uint32_t num_q_heads, uint32_t num_kv_heads, uint32_t head_dim, float *out, OmegaGpuAttnInfo *info); +/* Resident KV pool (2026-10-12). One GPU-uncached, host-visible allocation of `bytes` that the caller + * writes its paged bf16 KV into directly (sovereign-core's pool buffer). A paged call whose `pool` + * pointer is this allocation reads the KV in place: nothing is staged, the block table carries the + * physical block ids and the kernel's block stride is the layout's block stride. The kernel forms + * block_id * block_stride + the in-block offsets in 32 bits, so a call takes the resident path only + * when block_stride_bytes and, for every block it references, block_id * block_stride_bytes + + * layer_stride_bytes fit in 32 bits, and the layout's pool_bytes fit the allocation; otherwise that + * call stages exactly as before. OmegaGpuAttnInfo.kv_source says which path ran. One pool per + * process: a second alloc is refused (BAD_ARGS) until omega_gpu_attention_pool_free. The alloc opens + * the session (CHIP_FAIL carries the driver text in omega_gpu_attention_last_error()); under the host + * simulator it is plain host memory. The caller must not free the pool while a call is in flight. */ +int omega_gpu_attention_pool_alloc(size_t bytes, void **cpu); +void omega_gpu_attention_pool_free(void); + const char *omega_gpu_attention_rc_name(int rc); void omega_gpu_attention_cache_clear(void); @@ -228,6 +245,7 @@ typedef struct { void *out; size_t out_bytes; uint32_t grid_x, grid_y; uint32_t params[8]; + uint64_t pool_va; /* resident pool: chip address of the layer base (`pool` is its host mapping, pool_bytes 0); 0 = stage `pool` */ } OmegaGpuAttnLaunch; /* Host simulator hook (tests): when set, every launch runs the allocated IR program @@ -245,6 +263,10 @@ void omega_gpu_attention_test_set_simulator(OmegaGpuAttnSim sim); * staging-byte tests. Test hook; never cleared in production. */ void omega_gpu_attention_test_set_dedupe(bool on); +/* The resident pool's per-block fit rule (see omega_gpu_attention_pool_alloc), exposed so the + * 4 GiB edge can be checked without allocating a 4 GiB pool. Test hook. */ +bool omega_gpu_attention_test_resident_fits(const OmegaGpuKvLayout *layout, uint32_t block_id); + #ifdef __cplusplus } #endif diff --git a/tests/.crumb b/tests/.crumb index e43b895a1..fdbb08971 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -290,14 +290,14 @@ } ], "children_root": "sha256:9597c068d5bf4eb27f1d91842813a2b10269c2ccae421dceefb4308030ec0fc2", - "compiled_at": "2026-10-12T07:29:56Z", + "compiled_at": "2026-10-12T08:17:13Z", "compiler": "crumb-compile/1", - "digest": "sha256:2c25a63590c9d5759d12eacabb3cd37adbac87e8ee6ac4e074b4970e3419d144", + "digest": "sha256:c8932aae0268325ccc74e09284de055134b022abdfaa080227f5be40c0a638e7", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", "files": 1024, - "generated_at_commit": "ec1d3398f0dcc91e6eb66c21107299f042682cff", - "source_tree": "sha256:9822bd317bc6b22b70cab66ea273cad2c5768c8561b39b4b9913a4e6be8ace51" + "generated_at_commit": "09eed5528137abc1103768858538db18815654ab", + "source_tree": "sha256:f1e943d7d11af91e696903447bae33deb6b0d1d747bbe25ed20422aad9a4988b" }, "owner_lane": "", "provenance": { diff --git a/tests/gpu_attention_test.c b/tests/gpu_attention_test.c index 3d78faac4..6da274598 100644 --- a/tests/gpu_attention_test.c +++ b/tests/gpu_attention_test.c @@ -441,6 +441,14 @@ static int chip(const char *out_path) { CHECK(rc3 == OMEGA_GPU_ATTN_OK && differ > n / 2, "mha: Q_ROW and OUT_ROW outputs are distinct wrong answers (%zu of %zu differ)", differ, n); record(c, out); free(q); free(kc); free(vc); free(got); free(want); free(got_q); } + /* resident fit rule at the 32-bit edge (Qwen3-8B geometry: 36 layers, 8 kv heads x 128, block 16), no allocation */ + { + OmegaGpuKvLayout big = layout_for(4096, 16, 36, 8, 128); + uint32_t id_ok = (uint32_t)((0xffffffffull - big.layer_stride_bytes) / big.block_stride_bytes); + CHECK(omega_gpu_attention_test_resident_fits(&big, id_ok) && !omega_gpu_attention_test_resident_fits(&big, id_ok + 1), + "resident fit rule at the 4 GiB edge: block %u fits, %u does not (block stride %llu)", id_ok, id_ok + 1, + (unsigned long long)big.block_stride_bytes); + } /* 3. paged bf16 KV, block size 16, 2 layers (layer 1 under test), scattered block ids */ for (int sh = 0; sh < 2; sh++) for (int ci = 0; ci < 9; ci++) { uint32_t nqh = shapes[sh].nqh, nkv = shapes[sh].nkv, ctx = ctxs[ci], bs = 16, layers = 2, layer = 1; @@ -459,6 +467,27 @@ 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); + /* Resident pool (2026-10-12): the same bytes in omega's own allocation, read in place. Same kernel, + * same data, only the addressing differs: bit-identical to the staged result just computed (which is + * the negative control: a plain host pool reports STAGED), nothing staged, info says RESIDENT. */ + if (c.rc == OMEGA_GPU_ATTN_OK) { + void *rp = NULL; + int arc = omega_gpu_attention_pool_alloc(ly.pool_bytes, &rp); + CHECK(arc == OMEGA_GPU_ATTN_OK && rp, "%s: resident pool alloc rc=%d (%s)", name, arc, omega_gpu_attention_last_error()); + if (arc == OMEGA_GPU_ATTN_OK) { + memcpy(rp, pool, ly.pool_bytes); + float *got_r = malloc(n * 4); OmegaGpuAttnInfo ri; + PagedCtx rpc = { q, rp, &ly, ids, nblk, ctx, layer, nqh, nkv }; + int rrc = run_paged(&rpc, got_r, &ri); + int same = memcmp(got_r, got, n * 4) == 0; + CHECK(rrc == OMEGA_GPU_ATTN_OK && ri.kv_source == OMEGA_GPU_ATTN_KV_RESIDENT && ri.kv_bytes_staged == 0 && + info.kv_source == OMEGA_GPU_ATTN_KV_STAGED && same, + "%s: resident pool rc=%d source=%u staged=%llu (control source=%u) bit-identical=%d", name, rrc, ri.kv_source, + (unsigned long long)ri.kv_bytes_staged, info.kv_source, same); + free(got_r); + } + omega_gpu_attention_pool_free(); + } 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 */ ```