interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

GitHub aien-dev/aien-sovereign-core-mv#202 (code only)

closed derived 7591893d20ed5902 #202

Imported from GitHub aien-dev/aien-sovereign-core-mv#202 (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 37939f52dfb9a1fa320ffec9b90ff362ff0091e7 · Head 389d71f48e26817d3193e3d503a30d7e2515fa76

Apply it

git checkout -b patch-7591893d20ed5902 37939f52dfb9a1fa320ffec9b90ff362ff0091e7
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/7591893d20ed5902.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/aien-sovereign-core-mv
202
389d71f48e26817d3193e3d503a30d7e2515fa76
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":202,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/202","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:17Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 165214e2..0c24acf6 100644
--- a/.crumb
+++ b/.crumb
@@ -77,14 +77,14 @@
         }
       ],
       "children_root": "sha256:dfcfd805db0c30c667bc5682364bd3acb3383d494967dcae39f2420739723d7d",
-      "compiled_at": "2026-10-04T19:58:07Z",
+      "compiled_at": "2026-10-04T20:38:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:6f3b97496eebddeed0d73eaabee351bf0770e4d9d2a707dce3db2a8bbd6325ba",
+      "digest": "sha256:6d499cbb26f7041353de10fd948cdbfa3013d648c58da39dc6395cc409b898a9",
       "evidence_files": 20,
       "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170",
       "files": 677,
-      "generated_at_commit": "df957c87d65a9cd3d6fa64b31b71fa9c6ac7f59e",
-      "source_tree": "sha256:74c872ab7ce0dbab4709476e1b5641085a32bf2bf641bc4bf213b4092b2c7ac5"
+      "generated_at_commit": "8c60f97ed5d702df3bd1966a8d0691e0b9c113c9",
+      "source_tree": "sha256:6edde9bdd6a59719ac31631c16a3520139a9b6cc61ac8f9e122a16b26a9610c0"
     }
   },
   "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<String>,
 }
 
@@ -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..7fcb0f86 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` (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};
 
@@ -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 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;
 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 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).
+    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 e5593ae: the C
+// struct is 176 bytes and these are its offsets (checked with _Static_assert against the header on
+// 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::<OmegaGpuAttnInfo>() == 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..2293ec4a 100644
--- a/omega.lock
+++ b/omega.lock
@@ -1 +1 @@
-3d4648c7ee767e18066d1a82b9f0cffb6bac9255
+e5593ae488fcb9038557a4317a07faa7625649a3