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

branch main Branches Tags History

aien-sovereign-core-mv / docs / AIEN_INFERENCE_ABI_SPEC.md

244 lines · 10431 bytes Raw Blame History Source

AIEN Inference ABI & Native Runtime Architecture Specification

1. Research Thesis

Modern inference engines expend substantial compute and memory overhead mitigating runtime friction introduced by Python, dynamic tracing guards, and interpreter-level scheduling.

This research branch evaluates the thesis:

How much of modern LLM inference latency, memory pressure, and energy consumption belongs to forward tensor mathematics, and how much is an artifact of the software orchestration stack?

By systematically replacing each layer of the inference engine with native compiled Rust and Omega kernels, I measure the empirical delta across each removal.


2. Silicon Execution Architecture

AIEN serves as the native compiled inference runtime. High-performance tensor execution is decoupled into silicon backends conforming to the AIEN Inference ABI:

                         AIEN / ENOS
                             │
                     aien-inference-abi
                             │
             ┌───────────────┴────────────────┐
             │                                │
             ▼                                ▼
       Blackwell Native                  Native CPU
       GB10 fast path                     fallback
             │                                │
             └───────────────┬────────────────┘
                             │
                     AIEN Scheduler
                             │
                       aien-kv-cache
                             │
                         Model State
SubsystemFast Path (Blackwell)Fallback Path (Native CPU)Test Oracle
SchedulerAIEN Native Continuous Batching SchedulerAIEN Native Continuous Batching SchedulerDeterministic Step Scheduler
KV ManagementAIEN Physical Unified CoW PoolIn-process Paged PoolVirtual Page Table
Execution EngineGB10 sm_121 Omega native kernels (OmegaGb10Backend, no CUDA)Rayon Multi-Core NEON/AVXReferenceCpuBackend (FP32 Oracle)
Inference BackendBlackwellInferenceBackendNativeCpuInferenceBackendMockInferenceBackend
Memory SubstrateDGX Spark 128 GB Unified Coherent MemoryStandard Host DRAMHeap Slices

Monitored Telemetry per Stage

  1. TTFT (Time To First Token): Prefill latency in milliseconds.
  2. ITL (Inter-Token Latency): Decode step time in milliseconds (p50, p95, p99).
  3. Throughput: Sustained output tokens per second under concurrency sweeps (C = 1, 4, 16, 64).
  4. Memory Footprint: Host RSS (MB), GPU Allocated VRAM (MB), GPU Reserved VRAM (MB).
  5. KV Efficiency: Physical block fragmentation percentage, prefix reuse hit rate.
  6. Host Resource Draw: CPU Utilization (%), GPU Tensor Core Utilization (%), NVLink-C2C bus saturation (GB/s).
  7. Thermodynamic Efficiency: Measured Joules / token via power sampling.

3. Core Architecture: AIEN Inference ABI

The inference interface belongs to AIEN. Silicon backends conform to this trait:

use async_trait::async_trait;
use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct ModelConfig {
    pub model_id: String,
    pub max_sequence_length: usize,
    pub block_size: usize,
    pub num_layers: usize,
    pub num_heads: usize,
    pub head_dim: usize,
}

#[derive(Debug, Clone)]
pub struct SequenceRequest {
    pub request_id: u64,
    pub prompt_tokens: Vec<u32>,
    pub sampling_params: SamplingParams,
}

#[derive(Debug, Clone)]
pub struct SamplingParams {
    pub temperature: f32,
    pub top_p: f32,
    pub max_tokens: usize,
    pub stop_token_ids: Vec<u32>,
}

#[derive(Debug, Clone)]
pub struct ScheduledBatch {
    pub prefill_requests: Vec<SequenceRequest>,
    pub decode_requests: Vec<u64>,
    pub block_tables: HashMap<u64, Vec<usize>>,
}

#[derive(Debug, Clone)]
pub enum DecodeOutput {
    Token { token_id: u32, logprob: Option<f32> },
    Finished { reason: FinishReason },
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FinishReason {
    StopToken,
    LengthLimit,
    Aborted,
}

#[async_trait]
pub trait AienInferenceBackend: Send + Sync {
    async fn load_model(&mut self, config: &ModelConfig) -> Result<(), String>;
    async fn execute_step(
        &mut self,
        batch: &ScheduledBatch,
    ) -> Result<Vec<DecodeOutput>, String>;
}

4. Native Scheduling & Paged KV-Cache Management

KV Block Table Specification

Blocks are fixed-token chunks (e.g. 16 or 32 tokens) allocated from a pre-mapped pool in unified host/device memory.

pub struct KvBlock {
    pub block_id: usize,
    pub ref_count: usize,
    pub is_shared: bool,
}

pub struct BlockTable {
    pub blocks: Vec<usize>,
}

pub struct AienKvManager {
    total_blocks: usize,
    free_blocks: Vec<usize>,
    allocated_tables: HashMap<u64, BlockTable>,
}

impl AienKvManager {
    pub fn allocate_prompt_blocks(&mut self, token_count: usize) -> Result<BlockTable, String>;
    pub fn fork_sequence(&mut self, parent_req_id: u64, child_req_id: u64) -> Result<(), String>;
    pub fn free_sequence(&mut self, req_id: u64);
}

Prefix Sharing & Zero-Copy Subagent Branching

When a subagent forks from a parent agent:

  1. The parent's BlockTable entries have their ref_count incremented.
  2. is_shared is marked true.
  3. The child agent inherits the exact block indices without copying KV memory.
  4. During decode, if a child writes to a shared block, copy-on-write allocates a new private block.

5. Empirical Benchmark Telemetry & Live Pressure Verification

[!NOTE] Control Plane Scope Clarification: The throughput and latency figures in Sections 5.1 through 5.4 measure native control plane execution: block-table indexing, sequence queue transitions, reference-counting mutations, and batch assembly. Block indices represent coordinate pointers in pre-allocated unified memory. Physical tensor manipulation across the Blackwell GPU substrate begins in Stages 2 through 4.

Execution Substrate: NVIDIA DGX Spark (NVIDIA Grace Blackwell GB10, aarch64, 121 GB Unified LPDDR5X Memory, Linux 7.0.0-1019-nvidia).

5.1 Paged KV Cache Block-Table Allocator Throughput (Control Plane)

Benchmark binary: bench_inference_stack (it measured the Modular MAX engine and was removed from the tree on 2026-10-15; the results below are kept only as a record)

MetricResultSub-unit Latency
Allocation Throughput134,338,182.94 blocks/sec119.10 ns/sequence (7.44 ns/block)
Deallocation Throughput238,709,061.40 blocks/sec67.03 ns/sequence (4.19 ns/block)
Memory Management StatusZero-allocation pooling verifiedDeterministic constant time O(1)

5.2 Subagent Zero-Copy Sequence Fork vs Naive Memory Copy

Parent sequence context: 4,096 tokens (256 KV blocks).

Subagents ForkedZero-Copy Fork TimeNaive Copy Est.Speedup RatioProjected Tensor Memory Saved
11.58 µs1.92 ms1,212.1x0.38 GB
100.46 µs19.20 ms4,152.2x3.75 GB
500.47 µs96.00 ms4,067.8x18.75 GB
1000.39 µs192.00 ms4,977.2x37.50 GB
5000.45 µs960.00 ms4,236.1x187.50 GB

5.3 Copy-on-Write (CoW) Mutation Latency

5.4 Continuous Batching Scheduler Step Overhead

Active SequencesBatch Build Time (µs)Scheduler Overhead Ratio (in 10ms step)
11.01 µs0.0101%
92.02 µs0.0202%
405.20 µs0.0520%
969.66 µs0.0966%
19217.68 µs0.1768%

5.5 Live Microservice Call Stress & Memory Pressure

Benchmark harness: target/release/stress_aien_live executing against live production endpoints on spark.

Cortex-rs Vector Memory Call Stress (Port 18080, /api/cortex/search)

ConcurrencyTotal CallsThroughput (req/s)p50 Latency (ms)p95 Latency (ms)p99 Latency (ms)Success Rate
102001,637.21 req/s6.03 ms7.10 ms11.35 ms100.0%
252001,867.17 req/s10.97 ms29.68 ms41.53 ms100.0%
502001,960.52 req/s11.82 ms57.90 ms78.56 ms100.0%
1002002,103.73 req/s23.02 ms68.83 ms88.18 ms100.0%

Cortex Transformer Encoder Batch & Density Stress (Port 18081, /embed)

Batch SizeTotal TextsDuration (ms)Throughput (texts/sec)Per-Text Latency (ms)
120100.21 ms199.59 texts/s5.01 ms
480451.71 ms177.11 texts/s5.65 ms
8160851.81 ms187.84 texts/s5.32 ms
163201547.26 ms206.82 texts/s4.84 ms
326403165.60 ms202.17 texts/s4.95 ms

MAX LLM Streaming & Latency Pressure (Port 18082, unsloth/Llama-3.2-1B-Instruct)

Concurrent StreamsTTFT p50 (ms)ITL p50 (ms)ITL p95 (ms)Aggregate Tok/sE2E Latency p50 (ms)
1130.59 ms90.62 ms97.77 ms11.58 tok/s2,763.97 ms
45,652.78 ms86.60 ms103.46 ms11.61 tok/s8,299.38 ms
811,198.92 ms87.25 ms101.76 ms11.59 tok/s13,795.19 ms
1622,234.08 ms84.76 ms100.95 ms11.66 tok/s24,854.70 ms

Resident Set Size (RSS) Memory Stability Under Pressure

ServiceBaseline RSSPeak Concurrency RSSPost-Stress DeltaMemory Stability
cortex-rs15.97 MB18.57 MB+2.60 MBConfirmed leak-free
cortex-encoder-rs780.02 MB780.39 MB+0.36 MBConfirmed leak-free
max inference engine9,011.61 MB9,013.99 MB+2.38 MBConfirmed leak-free
aegis daemon4.80 MB4.80 MB+0.00 MBZero drift