From 8c97adaa08e6d52443a6b7766275b95f94991838 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 4 Oct 2026 14:45:21 -0500 Subject: [PATCH 1/3] omega-gpu: pin omega.lock to OM-2 cd80bf4, mirror staging counters in OmegaGpuAttnInfo SC-3 of Drake's attention hardening cut (stacks on SC-2). - omega.lock -> cd80bf457affad4ecec4e18b65223ebc10fb10f9 (omega attn/om2-staging-dedupe-sweep head; re-pin to the merge commit once omega #273/#274 land on main). - ffi.rs: OmegaGpuAttnInfo appended field for field after sm_architecture (kv_bytes_staged, kv_bytes_naive, kv_blocks_logical, kv_blocks_unique, q_bytes, tab_bytes, out_bytes, kv_source) + OMEGA_GPU_ATTN_KV_STAGED; zeroed() updated; const asserts pin size 176 and the field offsets, checked against the C header with _Static_assert at cd80bf4. - OmegaGb10Backend sums kv_bytes_staged / kv_bytes_naive over chip attention calls (accessors kv_bytes_staged(), kv_bytes_naive()). Verification: native build with AIEN_OMEGA_DIR= AIEN_PHYSICS_DIR= --release OK (lock == HEAD check passed); AIEN_FORCE_CPU_STUB=1 build OK; fmt + clippy (-D warnings) clean; stub tests: aien-omega-gpu, inference-abi lib 88, attention_wiring 12, omega_backend_parity 1 (+4 ignored chip tests) all PASS. Chip parity gate queued on the heavy lane (result in the PR). Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .crumb | 8 ++-- .../aien-inference-abi/src/omega_backend.rs | 20 ++++++++++ crates/aien-omega-gpu/src/ffi.rs | 39 ++++++++++++++++++- omega.lock | 2 +- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/.crumb b/.crumb index 165214e2..771ff8e8 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:dfcfd805db0c30c667bc5682364bd3acb3383d494967dcae39f2420739723d7d", - "compiled_at": "2026-10-04T19:58:07Z", + "compiled_at": "2026-10-04T19:58:08Z", "compiler": "crumb-compile/1", - "digest": "sha256:6f3b97496eebddeed0d73eaabee351bf0770e4d9d2a707dce3db2a8bbd6325ba", + "digest": "sha256:e836638ababce01124ad287bbe020ab9166c5a966c5685b0048e196a304f334c", "evidence_files": 20, "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170", "files": 677, - "generated_at_commit": "df957c87d65a9cd3d6fa64b31b71fa9c6ac7f59e", - "source_tree": "sha256:74c872ab7ce0dbab4709476e1b5641085a32bf2bf641bc4bf213b4092b2c7ac5" + "generated_at_commit": "9938ce893d480e81d73a687ecb5c8c0b2e617807", + "source_tree": "sha256:96c383ca2eb7e21f6762a4f2eb8372ce6c6af757c916cb7eac4cf79f4202ebda" } }, "history": [], diff --git a/crates/aien-inference-abi/src/omega_backend.rs b/crates/aien-inference-abi/src/omega_backend.rs index 98a9a12a..a71d5035 100644 --- a/crates/aien-inference-abi/src/omega_backend.rs +++ b/crates/aien-inference-abi/src/omega_backend.rs @@ -71,6 +71,9 @@ pub struct OmegaGb10Backend { chip_errors: AtomicU64, chip_calls: AtomicU64, chip_ns: AtomicU64, + /// OM-2 staging counters summed over every chip attention call. + kv_bytes_staged: AtomicU64, + kv_bytes_naive: AtomicU64, last_error: Mutex, } @@ -115,6 +118,8 @@ impl OmegaGb10Backend { chip_errors: AtomicU64::new(0), chip_calls: AtomicU64::new(0), chip_ns: AtomicU64::new(0), + kv_bytes_staged: AtomicU64::new(0), + kv_bytes_naive: AtomicU64::new(0), last_error: Mutex::new(String::new()), } } @@ -137,6 +142,17 @@ impl OmegaGb10Backend { self.chip_ns.load(Ordering::Relaxed) } + /// KV bytes omega copied into its staging buffer over every chip attention call (OM-2: + /// one copy per physical block per launch) and what per-reference staging would have + /// copied. Equal when no block is shared inside a launch. + pub fn kv_bytes_staged(&self) -> u64 { + self.kv_bytes_staged.load(Ordering::Relaxed) + } + + pub fn kv_bytes_naive(&self) -> u64 { + self.kv_bytes_naive.load(Ordering::Relaxed) + } + pub fn last_error(&self) -> String { self.last_error .lock() @@ -350,6 +366,10 @@ impl OmegaGb10Backend { Ok(info) => { self.chip_calls.fetch_add(1, Ordering::Relaxed); self.chip_ns.fetch_add(info.elapsed_ns, Ordering::Relaxed); + self.kv_bytes_staged + .fetch_add(info.kv_bytes_staged, Ordering::Relaxed); + self.kv_bytes_naive + .fetch_add(info.kv_bytes_naive, Ordering::Relaxed); true } Err(e) => self.fail(format!("{what}: {e}")), diff --git a/crates/aien-omega-gpu/src/ffi.rs b/crates/aien-omega-gpu/src/ffi.rs index 77ae458b..78054724 100644 --- a/crates/aien-omega-gpu/src/ffi.rs +++ b/crates/aien-omega-gpu/src/ffi.rs @@ -1,5 +1,6 @@ //! Raw declarations, written by hand from omega `src/omega_gpu_matmul_api.h` -//! at the commit pinned in `omega.lock` (3d4648c; headers unchanged since 6b940fa). Nothing generated. +//! at the commit pinned in `omega.lock` (cd80bf4; matmul header unchanged since 6b940fa, attention header +//! extended by OM-2 cd80bf4: staging counters appended to `OmegaGpuAttnInfo`). Nothing generated. //! Includes the resident-weights handles added by omega FB-1 cut 1b. use std::os::raw::{c_char, c_int}; @@ -211,13 +212,15 @@ extern "C" { pub fn omega_gpu_elementwise_rc_name(rc: c_int) -> *const c_char; } -// ---- omega `src/omega_gpu_attention_api.h` (FB-1 cut 5 + 4b, pinned 3d4648c) ---- +// ---- omega `src/omega_gpu_attention_api.h` (FB-1 cut 5 + 4b + OM-1/OM-2, pinned cd80bf4) ---- pub const OMEGA_GPU_ATTN_OK: c_int = 0; pub const OMEGA_GPU_ATTN_BAD_ARGS: c_int = -1; pub const OMEGA_GPU_ATTN_TOO_LARGE: c_int = -2; pub const OMEGA_GPU_ATTN_CODEGEN_FAIL: c_int = -3; pub const OMEGA_GPU_ATTN_CHIP_FAIL: c_int = -4; pub const OMEGA_GPU_ATTN_UNWRITTEN: c_int = -5; +/// `OmegaGpuAttnInfo::kv_source`: KV reached the kernel through the per-call staging copy. +pub const OMEGA_GPU_ATTN_KV_STAGED: u32 = 0; /// Mirrors `OmegaGpuAttnInfo` field for field, same order (note `call_ns` is third). #[repr(C)] @@ -235,6 +238,20 @@ pub struct OmegaGpuAttnInfo { pub threads_per_cta: u32, pub target_chip: [c_char; 64], pub sm_architecture: u32, + // OM-2 (omega cd80bf4): appended after sm_architecture, ABI order preserved. + /// Bytes of KV copied into the staging buffer by this call (one copy per physical block per launch). + pub kv_bytes_staged: u64, + /// Bytes per-reference staging would have copied (every block-table entry once). + pub kv_bytes_naive: u64, + /// Block-table entries walked. + pub kv_blocks_logical: u32, + /// Distinct physical blocks actually copied. + pub kv_blocks_unique: u32, + pub q_bytes: u64, + pub tab_bytes: u64, + pub out_bytes: u64, + /// `OMEGA_GPU_ATTN_KV_STAGED` (0): the only source in this cut; there is no resident KV. + pub kv_source: u32, } impl OmegaGpuAttnInfo { @@ -252,10 +269,28 @@ impl OmegaGpuAttnInfo { threads_per_cta: 0, target_chip: [0; 64], sm_architecture: 0, + kv_bytes_staged: 0, + kv_bytes_naive: 0, + kv_blocks_logical: 0, + kv_blocks_unique: 0, + q_bytes: 0, + tab_bytes: 0, + out_bytes: 0, + kv_source: 0, } } } +// Field-for-field mirror guard against omega `src/omega_gpu_attention_api.h` at cd80bf4: the C +// struct is 176 bytes and these are its offsets (checked with _Static_assert against the header on +// 2026-10-04). A header change that moves a field fails this build instead of misreading a counter. +const _: () = assert!(std::mem::size_of::() == 176); +const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, sm_architecture) == 116); +const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, kv_bytes_staged) == 120); +const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, kv_blocks_logical) == 136); +const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, q_bytes) == 144); +const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, kv_source) == 168); + /// Mirrors `OmegaGpuKvLayout` (itself a mirror of aien-kv-cache `KvLayoutDesc`), /// field for field, strides in bytes. #[repr(C)] diff --git a/omega.lock b/omega.lock index 1d632393..bb39677f 100644 --- a/omega.lock +++ b/omega.lock @@ -1 +1 @@ -3d4648c7ee767e18066d1a82b9f0cffb6bac9255 +cd80bf457affad4ecec4e18b65223ebc10fb10f9 From 8c60f97ed5d702df3bd1966a8d0691e0b9c113c9 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 4 Oct 2026 14:59:30 -0500 Subject: [PATCH 2/3] omega-gpu: re-pin omega.lock to rebased OM-2 head f777036 cd80bf4 (the sha the GB10 gates ran at) rebased onto omega main 55d05d6 is f777036; attention sources identical, only crumb files and the base moved. Native build with AIEN_OMEGA_DIR at f777036 OK, stub build OK, clippy clean. Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .crumb | 8 ++++---- crates/aien-omega-gpu/src/ffi.rs | 12 ++++++------ omega.lock | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.crumb b/.crumb index 771ff8e8..607b53b2 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:dfcfd805db0c30c667bc5682364bd3acb3383d494967dcae39f2420739723d7d", - "compiled_at": "2026-10-04T19:58:08Z", + "compiled_at": "2026-10-04T19:59:30Z", "compiler": "crumb-compile/1", - "digest": "sha256:e836638ababce01124ad287bbe020ab9166c5a966c5685b0048e196a304f334c", + "digest": "sha256:d817a2171eb490882bc53cd0da668535145c80958d7f7b1e2e574b33900f5233", "evidence_files": 20, "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170", "files": 677, - "generated_at_commit": "9938ce893d480e81d73a687ecb5c8c0b2e617807", - "source_tree": "sha256:96c383ca2eb7e21f6762a4f2eb8372ce6c6af757c916cb7eac4cf79f4202ebda" + "generated_at_commit": "1d7379f361ea4b8dbc85d0e78278d121b129855c", + "source_tree": "sha256:1b48a6bf633a6051032a5ef5cd437903506b5a4bc4f59f66a7207e289150710b" } }, "history": [], diff --git a/crates/aien-omega-gpu/src/ffi.rs b/crates/aien-omega-gpu/src/ffi.rs index 78054724..83a08dcb 100644 --- a/crates/aien-omega-gpu/src/ffi.rs +++ b/crates/aien-omega-gpu/src/ffi.rs @@ -1,6 +1,6 @@ //! Raw declarations, written by hand from omega `src/omega_gpu_matmul_api.h` -//! at the commit pinned in `omega.lock` (cd80bf4; matmul header unchanged since 6b940fa, attention header -//! extended by OM-2 cd80bf4: staging counters appended to `OmegaGpuAttnInfo`). Nothing generated. +//! at the commit pinned in `omega.lock` (f777036; matmul header unchanged since 6b940fa, attention header +//! extended by OM-2 f777036: staging counters appended to `OmegaGpuAttnInfo`). Nothing generated. //! Includes the resident-weights handles added by omega FB-1 cut 1b. use std::os::raw::{c_char, c_int}; @@ -212,7 +212,7 @@ extern "C" { pub fn omega_gpu_elementwise_rc_name(rc: c_int) -> *const c_char; } -// ---- omega `src/omega_gpu_attention_api.h` (FB-1 cut 5 + 4b + OM-1/OM-2, pinned cd80bf4) ---- +// ---- omega `src/omega_gpu_attention_api.h` (FB-1 cut 5 + 4b + OM-1/OM-2, pinned f777036) ---- pub const OMEGA_GPU_ATTN_OK: c_int = 0; pub const OMEGA_GPU_ATTN_BAD_ARGS: c_int = -1; pub const OMEGA_GPU_ATTN_TOO_LARGE: c_int = -2; @@ -238,7 +238,7 @@ pub struct OmegaGpuAttnInfo { pub threads_per_cta: u32, pub target_chip: [c_char; 64], pub sm_architecture: u32, - // OM-2 (omega cd80bf4): appended after sm_architecture, ABI order preserved. + // OM-2 (omega f777036): appended after sm_architecture, ABI order preserved. /// Bytes of KV copied into the staging buffer by this call (one copy per physical block per launch). pub kv_bytes_staged: u64, /// Bytes per-reference staging would have copied (every block-table entry once). @@ -281,9 +281,9 @@ impl OmegaGpuAttnInfo { } } -// Field-for-field mirror guard against omega `src/omega_gpu_attention_api.h` at cd80bf4: the C +// Field-for-field mirror guard against omega `src/omega_gpu_attention_api.h` at f777036: the C // struct is 176 bytes and these are its offsets (checked with _Static_assert against the header on -// 2026-10-04). A header change that moves a field fails this build instead of misreading a counter. +// 2026-10-04; f777036 is cd80bf4 rebased onto omega main 55d05d6, same attention sources). A header change that moves a field fails this build instead of misreading a counter. const _: () = assert!(std::mem::size_of::() == 176); const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, sm_architecture) == 116); const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, kv_bytes_staged) == 120); diff --git a/omega.lock b/omega.lock index bb39677f..b773cb21 100644 --- a/omega.lock +++ b/omega.lock @@ -1 +1 @@ -cd80bf457affad4ecec4e18b65223ebc10fb10f9 +f777036885f08dc3b01ed6d73988a0b758588990 From 389d71f48e26817d3193e3d503a30d7e2515fa76 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 4 Oct 2026 15:38:05 -0500 Subject: [PATCH 3/3] omega-gpu: re-pin omega.lock to merged OM-2 e5593ae Co-authored-by: Drake Stapleton Co-Authored-By: Claude Fable 5.1 --- .crumb | 8 ++++---- crates/aien-omega-gpu/src/ffi.rs | 12 ++++++------ omega.lock | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.crumb b/.crumb index 607b53b2..0c24acf6 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:dfcfd805db0c30c667bc5682364bd3acb3383d494967dcae39f2420739723d7d", - "compiled_at": "2026-10-04T19:59:30Z", + "compiled_at": "2026-10-04T20:38:05Z", "compiler": "crumb-compile/1", - "digest": "sha256:d817a2171eb490882bc53cd0da668535145c80958d7f7b1e2e574b33900f5233", + "digest": "sha256:6d499cbb26f7041353de10fd948cdbfa3013d648c58da39dc6395cc409b898a9", "evidence_files": 20, "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170", "files": 677, - "generated_at_commit": "1d7379f361ea4b8dbc85d0e78278d121b129855c", - "source_tree": "sha256:1b48a6bf633a6051032a5ef5cd437903506b5a4bc4f59f66a7207e289150710b" + "generated_at_commit": "8c60f97ed5d702df3bd1966a8d0691e0b9c113c9", + "source_tree": "sha256:6edde9bdd6a59719ac31631c16a3520139a9b6cc61ac8f9e122a16b26a9610c0" } }, "history": [], diff --git a/crates/aien-omega-gpu/src/ffi.rs b/crates/aien-omega-gpu/src/ffi.rs index 83a08dcb..7fcb0f86 100644 --- a/crates/aien-omega-gpu/src/ffi.rs +++ b/crates/aien-omega-gpu/src/ffi.rs @@ -1,6 +1,6 @@ //! Raw declarations, written by hand from omega `src/omega_gpu_matmul_api.h` -//! at the commit pinned in `omega.lock` (f777036; matmul header unchanged since 6b940fa, attention header -//! extended by OM-2 f777036: staging counters appended to `OmegaGpuAttnInfo`). Nothing generated. +//! at the commit pinned in `omega.lock` (e5593ae; matmul header unchanged since 6b940fa, attention header +//! extended by OM-2 e5593ae: staging counters appended to `OmegaGpuAttnInfo`). Nothing generated. //! Includes the resident-weights handles added by omega FB-1 cut 1b. use std::os::raw::{c_char, c_int}; @@ -212,7 +212,7 @@ extern "C" { pub fn omega_gpu_elementwise_rc_name(rc: c_int) -> *const c_char; } -// ---- omega `src/omega_gpu_attention_api.h` (FB-1 cut 5 + 4b + OM-1/OM-2, pinned f777036) ---- +// ---- omega `src/omega_gpu_attention_api.h` (FB-1 cut 5 + 4b + OM-1/OM-2, pinned e5593ae) ---- pub const OMEGA_GPU_ATTN_OK: c_int = 0; pub const OMEGA_GPU_ATTN_BAD_ARGS: c_int = -1; pub const OMEGA_GPU_ATTN_TOO_LARGE: c_int = -2; @@ -238,7 +238,7 @@ pub struct OmegaGpuAttnInfo { pub threads_per_cta: u32, pub target_chip: [c_char; 64], pub sm_architecture: u32, - // OM-2 (omega f777036): appended after sm_architecture, ABI order preserved. + // OM-2 (omega e5593ae): appended after sm_architecture, ABI order preserved. /// Bytes of KV copied into the staging buffer by this call (one copy per physical block per launch). pub kv_bytes_staged: u64, /// Bytes per-reference staging would have copied (every block-table entry once). @@ -281,9 +281,9 @@ impl OmegaGpuAttnInfo { } } -// Field-for-field mirror guard against omega `src/omega_gpu_attention_api.h` at f777036: the C +// Field-for-field mirror guard against omega `src/omega_gpu_attention_api.h` at e5593ae: the C // struct is 176 bytes and these are its offsets (checked with _Static_assert against the header on -// 2026-10-04; f777036 is cd80bf4 rebased onto omega main 55d05d6, same attention sources). A header change that moves a field fails this build instead of misreading a counter. +// 2026-10-04; e5593ae is the squash-merge of OM-2 (f777036 was cd80bf4 rebased onto omega main 55d05d6, same attention sources)). A header change that moves a field fails this build instead of misreading a counter. const _: () = assert!(std::mem::size_of::() == 176); const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, sm_architecture) == 116); const _: () = assert!(std::mem::offset_of!(OmegaGpuAttnInfo, kv_bytes_staged) == 120); diff --git a/omega.lock b/omega.lock index b773cb21..2293ec4a 100644 --- a/omega.lock +++ b/omega.lock @@ -1 +1 @@ -f777036885f08dc3b01ed6d73988a0b758588990 +e5593ae488fcb9038557a4317a07faa7625649a3