aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / docs / milestone-13-spec.md
| 1 | # Specification: Milestone 13 — Omega Machine Graph (`OMEGA_MACHINE_GRAPH`) |
| 2 | |
| 3 | ```text |
| 4 | Document ID: SPEC-OMEGA-M13 |
| 5 | Milestone: Milestone 13 (OMEGA_MACHINE_GRAPH) |
| 6 | Classification: Sovereign Machine Canonical Specification |
| 7 | Target Substrate: Formal Machine Hardware Graph ($G_M$) Describing Execution Pipelines and Memory Hierarchies |
| 8 | Status: COMPLETE / RATIFIED (aien-spark/aien-architecture#24, aien-spark/omega#18) |
| 9 | Lineage: SILICON -> ATLAS (M1) -> PHYSICS (M2/M3) -> OMEGA (M4-M13) -> AIEN |
| 10 | ``` |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## 1. Executive Summary & Foundational Doctrine |
| 15 | |
| 16 | Milestone 12 established adaptive realization selection across varying input regimes and cache dynamics (`OMEGA_LIVING_MATVEC`). |
| 17 | Milestone 13 establishes the formal machine hardware graph substrate (`OMEGA_MACHINE_GRAPH`): |
| 18 | |
| 19 | > **PHYSICS GOVERNS THE MACHINE; OMEGA MODELS ITS CAPACITIES. THE MACHINE GRAPH $G_M$ EXPOSES PHYSICAL REALITY AS AN AUTHORITATIVE, IMMUTABLE REASONING SURFACE WITHOUT DEFILING PURE SEMANTICS.** |
| 20 | |
| 21 | In sovereign architecture: |
| 22 | - **Semantic Graph ($G_S$)** (Milestone 4, `OMEGA_SEMANTICS`): Defines pure mathematical and computational meaning without committing that meaning to a physical machine representation. |
| 23 | - **Machine Hardware Graph ($G_M$)** (Milestone 13, `OMEGA_MACHINE_GRAPH`): Formally describes the physical execution pipelines, functional compute units, register files, and cache/memory hierarchy topologies as reported by Physics. |
| 24 | - **Realization Graph ($G_R$)** (Milestone 14, `OMEGA_REALIZATION_SYNTHESIS`): Synthesized through the formal mapping $G_S \times G_M \to G_R$, matching semantic execution structures to physical hardware capabilities and cost curves. |
| 25 | |
| 26 | The machine graph $G_M$ is not an operating system device tree, an emulated virtual machine, or an informal configuration file. It is a strictly typed, topologically validated, content-addressed mathematical graph that models hardware constraints as first-class reasoning surfaces. |
| 27 | |
| 28 | --- |
| 29 | |
| 30 | ## 2. Core Doctrine & Invariants |
| 31 | |
| 32 | As mandated by canonical roadmap doctrine (`DOCTRINE-ROADMAP`), the machine graph substrate satisfies five foundational invariants: |
| 33 | |
| 34 | 1. **Physics Authority Ingress**: $G_M$ is derived from verified physical machine descriptors provided by Physics (Milestone 2 `PHYSICS_BOOT`, Milestone 3 `PHYSICS_EFFECTS` authority). Omega never guesses hardware capabilities, queries unauthorized control registers, or runs heuristics. Every machine graph carries a cryptographic seal binding it to a Physics execution receipt. |
| 35 | 2. **Canonical Hardware Identity (`MACHINE_ID`)**: Every distinct machine topology possesses a deterministic SHA-256 state digest computed over a canonical wire encoding (`OMG0` format with `KIND_MACHINE = 0x07`). Identical physical configurations yield bit-identical `MACHINE_ID`s across independent runs. |
| 36 | 3. **Structural Completeness**: $G_M$ explicitly models all hardware resources necessary for execution scheduling and latency evaluation: |
| 37 | - Execution pipelines: issue width, maximum in-flight window, dispatch order (in-order vs. out-of-order). |
| 38 | - Functional compute units: dedicated modeling of ALU, BRANCH, MULTIPLIER, DIVIDER, LOAD_STORE, VECTOR, and ACCELERATOR_PORT units with unit count, issue latency, and throughput per cycle. |
| 39 | - Register files: General Purpose Registers (GPR count and bit-width) and Vector registers (count and bit-width). |
| 40 | - Memory hierarchy: Multi-tier caches (L1I, L1D, L2, L3) with capacity, line size, associativity, and cycle access latency, alongside physical DRAM base address and size. |
| 41 | 4. **Topology Differential**: Distinct hardware targets produce distinct `MACHINE_ID`s. Heterogeneous microarchitectures (e.g., NVIDIA DGX Spark Neoverse V2 vs QEMU generic AArch64) produce provably distinct cryptographic identities, preventing cross-target realization contamination. |
| 42 | 5. **Realization Foundation**: $G_M$ supplies empirical cycle latency and resource cost models utilized by Milestone 14 realization synthesis (`OMEGA_REALIZATION_SYNTHESIS`, $G_S \times G_M \to G_R$). Realization synthesis leverages $G_M$ to schedule instructions, optimize issue-slot occupancy, and avoid pipeline stalls. |
| 43 | |
| 44 | --- |
| 45 | |
| 46 | ## 3. Machine Hardware Graph Topology & Ingress |
| 47 | |
| 48 | ### 3.1 Architectural Structure |
| 49 | |
| 50 | ```text |
| 51 | +-------------------------------------------------------------------------------+ |
| 52 | | PHYSICS AUTHORITY HARDWARE INGRESS | |
| 53 | | PhysicsDescriptor (Magic: 0x4D414348 'MACH', Profile, Seals, Physical Caps) | |
| 54 | +-------------------------------------------------------------------------------+ |
| 55 | │ |
| 56 | ▼ omega_machine_ingest_physics_descriptor() |
| 57 | +-------------------------------------------------------------------------------+ |
| 58 | | OMEGA MACHINE GRAPH (G_M) ARCHITECTURE | |
| 59 | +-------------------------------------------------------------------------------+ |
| 60 | | 1. Identity & Profile : Name, Target Profile, Deterministic MACHINE_ID | |
| 61 | | 2. Execution Pipeline : Issue Width, Out-of-Order Window, Unit Capacities | |
| 62 | | - ALU Units (Count, Latency, Throughput) | |
| 63 | | - Multiplier Units (Count, Latency, Throughput) | |
| 64 | | - Vector / SIMD (Count, Latency, Throughput) | |
| 65 | | - Branch / Jump (Count, Latency, Throughput) | |
| 66 | | - Load / Store Ports (Count, Latency, Throughput) | |
| 67 | | 3. Register File : GPRs (31 x 64-bit), Vector Regs (32 x 128/256-bit) | |
| 68 | | 4. Memory Hierarchy : L1I Cache -> L1D Cache -> L2 Cache -> L3 Cache | |
| 69 | | (Monotonic hierarchy, line sizes, latencies) | |
| 70 | | 5. Coherent Memory : DRAM Base Address, Total Capacity (Bytes) | |
| 71 | | 6. Authority Seal : Physics Authority Seal (32-byte cryptographic seal) | |
| 72 | +-------------------------------------------------------------------------------+ |
| 73 | │ |
| 74 | ▼ omega_machine_compute_id() |
| 75 | +-------------------------------------------------------------------------------+ |
| 76 | | CANONICAL HARDWARE IDENTITY: SHA-256 (OMG0 SERIALIZATION) | |
| 77 | +-------------------------------------------------------------------------------+ |
| 78 | ``` |
| 79 | |
| 80 | ### 3.2 Canonical Target Profiles |
| 81 | |
| 82 | Milestone 13 establishes two reference hardware topologies: |
| 83 | |
| 84 | 1. **NVIDIA DGX Spark Grace Profile (`NVIDIA_DGX_SPARK_GRACE_V2`)**: |
| 85 | - Microarchitecture: ARM Neoverse V2 core. |
| 86 | - Pipeline: 4-wide dispatch, 256 instructions max in-flight, out-of-order execution. |
| 87 | - Functional Units: 4x ALU (1-cycle latency), 2x Branch (1-cycle latency), 2x Multiplier (3-cycle latency), 1x Divider (12-cycle latency), 2x Load/Store (3-cycle latency), 4x Vector/SIMD (2-cycle latency). |
| 88 | - Register Files: 31x 64-bit GPRs (X0-X30), 32x 128-bit Vector registers (V0-V31). |
| 89 | - Cache Hierarchy: 64KB 4-way L1I (3-cycle latency), 64KB 8-way L1D (4-cycle latency), 1MB 8-way L2 (10-cycle latency), 114MB 16-way L3 (35-cycle latency). |
| 90 | - Coherent DRAM: 128 GB LPDDR5X at physical base `0x80000000`. |
| 91 | |
| 92 | 2. **QEMU Virt AArch64 Baseline Profile (`QEMU_VIRT_AARCH64_GENERIC`)**: |
| 93 | - Microarchitecture: Generic AArch64 emulation core. |
| 94 | - Pipeline: 2-wide dispatch, 64 instructions max in-flight, in-order execution. |
| 95 | - Functional Units: 2x ALU (1-cycle latency), 1x Branch (1-cycle latency), 1x Multiplier (4-cycle latency), 1x Load/Store (4-cycle latency), 2x Vector/SIMD (3-cycle latency). |
| 96 | - Register Files: 31x 64-bit GPRs, 32x 128-bit Vector registers. |
| 97 | - Cache Hierarchy: 32KB 2-way L1I (2-cycle latency), 32KB 4-way L1D (3-cycle latency), 512KB 8-way L2 (12-cycle latency). |
| 98 | - Coherent DRAM: 1 GB at physical base `0x40000000`. |
| 99 | |
| 100 | ### 3.3 Topological Consistency & Cycle Prevention |
| 101 | |
| 102 | The machine graph engine enforces topological invariant checks via `omega_machine_validate_topology()`: |
| 103 | - **Cache Monotonicity**: Cache levels must strictly increase monotonically ($L_1 \le L_2 \le L_3$). Inverted cache hierarchies or duplicate unified levels are rejected. |
| 104 | - **Cache Line Power-of-Two**: Every cache line size must be a non-zero power of two (typically 64 bytes). |
| 105 | - **Acyclic Memory DAG**: Memory hierarchy references must form a strict tree/DAG terminating in coherent DRAM without cycles. |
| 106 | - **Architectural Register Integrity**: For AArch64 profiles, GPR count must equal exactly 31 registers with 64-bit width. |
| 107 | - **Non-Zero Pipeline Capacities**: Pipeline issue width and functional unit counts must be strictly positive. |
| 108 | |
| 109 | ### 3.4 Latency & Execution Cost Modeling |
| 110 | |
| 111 | $G_M$ provides an analytical cost function `omega_machine_estimate_latency()` that accepts a compiled machine code realization (`RealizationObject`) and models cycle execution latency: |
| 112 | - Decodes machine instructions into operation classes (ALU, MUL, LOAD/STORE, BRANCH, VECTOR). |
| 113 | - Maps each instruction to the corresponding functional unit latency declared in $G_M$. |
| 114 | - Models pipeline issue folding: $\text{Folded Cycles} = \lceil \text{Instruction Count} / \text{Issue Width} \rceil$. |
| 115 | - Total cycle latency accounts for structural hazards and unit latencies, providing the empirical cost metric required for Milestone 14 realization synthesis. |
| 116 | |
| 117 | --- |
| 118 | |
| 119 | ## 4. Data Model & C API Declarations |
| 120 | |
| 121 | ```c |
| 122 | #ifndef OMEGA_MACHINE_H |
| 123 | #define OMEGA_MACHINE_H |
| 124 | |
| 125 | #include "omega_types.h" |
| 126 | #include "omega_realize.h" |
| 127 | #include <stdbool.h> |
| 128 | #include <stddef.h> |
| 129 | |
| 130 | #define OMEGA_MACHINE_MAX_UNITS 8 |
| 131 | #define OMEGA_MACHINE_MAX_CACHES 8 |
| 132 | |
| 133 | typedef enum { |
| 134 | UNIT_ALU = 0, |
| 135 | UNIT_BRANCH = 1, |
| 136 | UNIT_MULTIPLIER = 2, |
| 137 | UNIT_DIVIDER = 3, |
| 138 | UNIT_LOAD_STORE = 4, |
| 139 | UNIT_VECTOR = 5, |
| 140 | UNIT_ACCELERATOR_PORT = 6 |
| 141 | } ComputeUnitType; |
| 142 | |
| 143 | typedef struct { |
| 144 | ComputeUnitType type; |
| 145 | uint32_t count; |
| 146 | uint32_t latency_cycles; |
| 147 | uint32_t throughput_per_cycle; |
| 148 | } MachineComputeUnit; |
| 149 | |
| 150 | typedef struct { |
| 151 | uint32_t issue_width; |
| 152 | uint32_t max_in_flight; |
| 153 | bool out_of_order; |
| 154 | size_t unit_count; |
| 155 | MachineComputeUnit units[OMEGA_MACHINE_MAX_UNITS]; |
| 156 | } MachinePipeline; |
| 157 | |
| 158 | typedef struct { |
| 159 | uint32_t gpr_count; /* 31 for AArch64 X0-X30 */ |
| 160 | uint32_t gpr_width_bits; /* 64-bit */ |
| 161 | uint32_t vector_count; /* 32 for V0-V31 */ |
| 162 | uint32_t vector_width_bits; /* 128-bit for NEON / 256+ for SVE */ |
| 163 | } MachineRegisterFile; |
| 164 | |
| 165 | typedef struct { |
| 166 | uint32_t level; /* 1 = L1, 2 = L2, 3 = L3 */ |
| 167 | bool is_instruction; |
| 168 | uint64_t size_bytes; |
| 169 | uint32_t line_size_bytes; |
| 170 | uint32_t associativity; |
| 171 | uint32_t latency_cycles; |
| 172 | } MachineCacheLevel; |
| 173 | |
| 174 | typedef struct { |
| 175 | SemanticId machine_id; |
| 176 | char name[64]; |
| 177 | uint8_t target_profile; |
| 178 | MachinePipeline pipeline; |
| 179 | MachineRegisterFile registers; |
| 180 | size_t cache_count; |
| 181 | MachineCacheLevel caches[OMEGA_MACHINE_MAX_CACHES]; |
| 182 | uint64_t dram_base; |
| 183 | uint64_t dram_size; |
| 184 | bool is_physics_authorized; |
| 185 | uint8_t physics_receipt_seal[32]; |
| 186 | } OmegaMachineGraph; |
| 187 | |
| 188 | /* Raw physical machine descriptor packet ingested from Physics */ |
| 189 | typedef struct { |
| 190 | uint32_t magic; /* 0x4D414348 = 'MACH' */ |
| 191 | uint16_t version; |
| 192 | uint16_t target_profile; |
| 193 | char cpu_name[32]; |
| 194 | uint32_t issue_width; |
| 195 | uint32_t gpr_count; |
| 196 | uint32_t vec_count; |
| 197 | uint64_t l1d_size; |
| 198 | uint64_t l2_size; |
| 199 | uint64_t l3_size; |
| 200 | uint64_t dram_base; |
| 201 | uint64_t dram_size; |
| 202 | uint8_t physics_seal[32]; |
| 203 | } MachineDescriptor; |
| 204 | |
| 205 | typedef MachineDescriptor PhysicsDescriptor; |
| 206 | |
| 207 | /* Machine Graph Initialization & Canonical Identity */ |
| 208 | void omega_machine_init(OmegaMachineGraph *mg, const char *name, uint8_t target_profile); |
| 209 | int omega_machine_compute_id(OmegaMachineGraph *mg); |
| 210 | |
| 211 | /* Target Topology Builders */ |
| 212 | int omega_machine_build_dgx_spark(OmegaMachineGraph *mg); |
| 213 | int omega_machine_build_qemu_virt(OmegaMachineGraph *mg); |
| 214 | |
| 215 | /* Physics Ingress & Validation */ |
| 216 | int omega_machine_ingest_physics_descriptor(OmegaMachineGraph *mg, const MachineDescriptor *desc); |
| 217 | int omega_machine_validate_topology(const OmegaMachineGraph *mg, char *err_msg, size_t err_msg_len); |
| 218 | |
| 219 | /* Cost & Latency Evaluation */ |
| 220 | uint32_t omega_machine_estimate_latency(const OmegaMachineGraph *mg, const RealizationObject *real); |
| 221 | |
| 222 | #endif /* OMEGA_MACHINE_H */ |
| 223 | ``` |
| 224 | |
| 225 | --- |
| 226 | |
| 227 | ## 5. The 10 Qualification Gates |
| 228 | |
| 229 | Milestone 13 qualification requires 100% pass across 10 canonical gates: |
| 230 | |
| 231 | 1. `OMEGA_MACHINE_INIT_PASS`: Machine graph initializes cleanly with valid target name, designated execution profile, and zero-initialized memory structures. |
| 232 | 2. `OMEGA_MACHINE_PIPELINE_PASS`: Multi-unit execution pipeline is fully modeled, specifying issue width, in-flight window, dispatch order, and unit-specific cycle latencies. |
| 233 | 3. `OMEGA_MACHINE_REGISTER_FILE_PASS`: Register file capacities and widths are validated (31 64-bit GPRs, 32 128-bit Vector registers for AArch64 targets). |
| 234 | 4. `OMEGA_MACHINE_MEMORY_HIERARCHY_PASS`: Multi-tier cache hierarchy (L1I, L1D, L2, L3) is accurately constructed with explicit capacities, line sizes, associativity, and access latencies. |
| 235 | 5. `OMEGA_MACHINE_PHYSICS_INGRESS_PASS`: Physical descriptor packet is ingested from Physics, verifying descriptor magic (`0x4D414348`), parameter bounds, and cryptographic authority seal. |
| 236 | 6. `OMEGA_MACHINE_CANONICAL_ID_PASS`: Deterministic bit-for-bit `MACHINE_ID` generation via SHA-256 over canonical `OMG0` wire-format serialization. |
| 237 | 7. `OMEGA_MACHINE_TOPOLOGY_DIFFERENCE_PASS`: Distinct hardware microarchitectures (NVIDIA DGX Spark Neoverse V2 vs. QEMU virt AArch64) generate distinct, collision-free `MACHINE_ID`s. |
| 238 | 8. `OMEGA_MACHINE_CYCLE_PREVENTION_PASS`: Topological validator rejects cyclic memory dependencies, inverted cache hierarchies, non-power-of-two line sizes, and invalid issue widths. |
| 239 | 9. `OMEGA_MACHINE_COST_EVALUATION_PASS`: Execution latency estimator accurately models realization execution cycles, correctly accounting for opcode latencies and pipeline issue folding. |
| 240 | 10. `OMEGA_MACHINE_RECEIPT_PASS`: Master qualification runner executes all test assertions and generates an immutable cryptographic receipt recording machine identity, topology hash, and gate results. |
| 241 | |
| 242 | --- |
| 243 | |
| 244 | ## 6. Provenance & Qualification Evidence |
| 245 | |
| 246 | Upon execution of the Milestone 13 test harness (`tests/run_m13_gates.sh`), the system emits a signed qualification receipt into `evidence/omega_machine_qualification_receipt.json`. |
| 247 | |
| 248 | ```json |
| 249 | { |
| 250 | "milestone": "OMEGA_MACHINE_GRAPH", |
| 251 | "document_id": "SPEC-OMEGA-M13", |
| 252 | "status": "QUALIFIED", |
| 253 | "machine_id_dgx_spark": "e4a2...<64-hex>", |
| 254 | "machine_id_qemu_virt": "c8f1...<64-hex>", |
| 255 | "topology_difference_verified": true, |
| 256 | "physics_authority_seal_verified": true, |
| 257 | "gates": { |
| 258 | "OMEGA_MACHINE_INIT_PASS": "PASS", |
| 259 | "OMEGA_MACHINE_PIPELINE_PASS": "PASS", |
| 260 | "OMEGA_MACHINE_REGISTER_FILE_PASS": "PASS", |
| 261 | "OMEGA_MACHINE_MEMORY_HIERARCHY_PASS": "PASS", |
| 262 | "OMEGA_MACHINE_PHYSICS_INGRESS_PASS": "PASS", |
| 263 | "OMEGA_MACHINE_CANONICAL_ID_PASS": "PASS", |
| 264 | "OMEGA_MACHINE_TOPOLOGY_DIFFERENCE_PASS": "PASS", |
| 265 | "OMEGA_MACHINE_CYCLE_PREVENTION_PASS": "PASS", |
| 266 | "OMEGA_MACHINE_COST_EVALUATION_PASS": "PASS", |
| 267 | "OMEGA_MACHINE_RECEIPT_PASS": "PASS" |
| 268 | } |
| 269 | } |
| 270 | ``` |