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/aien-architecture-mv/blob/main/docs/milestone-14-spec.md # aien-architecture-mv Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-architecture-mv / docs / milestone-14-spec.md` 271 lines · 17513 bytes Raw Blame History Rendered 1 # Specification: Milestone 14 — Omega Realization Synthesis (`OMEGA_REALIZATION_SYNTHESIS`) 2 3 ```text 4 Document ID: SPEC-OMEGA-M14 5 Milestone: Milestone 14 (OMEGA_REALIZATION_SYNTHESIS) 6 Classification: Sovereign Machine Canonical Specification 7 Target Substrate: Automated $G_S \times G_M \to G_R$ Synthesis Targeting Declared Hardware Capabilities 8 Status: COMPLETE / RATIFIED (aien-spark/aien-architecture#25, aien-spark/omega#19) 9 Lineage: SILICON -> ATLAS (M1) -> PHYSICS (M2/M3) -> OMEGA (M4-M14) -> AIEN 10 ``` 11 12 --- 13 14 ## 1. Executive Summary & Foundational Doctrine 15 16 Milestone 13 established the formal machine hardware graph substrate (`OMEGA_MACHINE_GRAPH`), providing content-addressed, Physics-certified structural models of physical execution pipelines, functional compute units, register files, and cache/memory hierarchies. 17 Milestone 14 establishes automated machine-aware realization synthesis (`OMEGA_REALIZATION_SYNTHESIS`): 18 19 > **LOWERING IS NOT HARDCODED COMPILATION; REALIZATION IS SYNTHESIS: $G_S \times G_M \to G_R$. THE SOVEREIGN SYSTEM DISCOVERS THE OPTIMAL INSTRUCTION SCHEDULE AND REGISTER ASSIGNMENT UPON PHYSICAL HARDWARE WITHOUT COMPROMISING MATHEMATICAL PURITY.** 20 21 In the sovereign hierarchy: 22 - **Semantic Graph ($G_S$)** (Milestone 4 `OMEGA_SEMANTICS`, Milestone 8 `OMEGA_PROGRAM_CORE`): Defines pure mathematical meaning, abstract typed ASTs, and invariant envelopes without committing that meaning to any physical machine representation. 23 - **Machine Hardware Graph ($G_M$)** (Milestone 13 `OMEGA_MACHINE_GRAPH`): Formally describes physical execution pipelines, issue widths, unit latencies, register files, and memory hierarchies as reported and authorized by Physics. 24 - **Realization Graph ($G_R$)** (Milestone 5 `OMEGA_AARCH64`, Milestone 14 `OMEGA_REALIZATION_SYNTHESIS`): Synthesized through the formal mapping $G_S \times G_M \to G_R$, generating verified native machine code optimized for target hardware capabilities. 25 26 A conventional compiler relies on hardcoded lowering templates, fixed calling conventions, and hand-tuned heuristics that obscure hardware realities and introduce foreign runtime abstractions. Omega realization synthesis treats the machine hardware graph $G_M$ as a concrete constraint manifold. The synthesis engine searches over instruction selection, instruction scheduling, and register allocation to discover native machine code realizations that maximize throughput, fold issue slots, and eliminate pipeline bubbles while strictly preserving semantic equivalence. 27 28 Every synthesized realization is immutably bound through a cryptographic triple identity: 29 $$\text{REALIZATION\_ID} = \text{SHA-256}(\text{OMG0} \mid \text{KIND\_REALIZATION} \mid \text{profile} \mid \text{entry\_offset} \mid \text{code\_len} \mid \text{SEMANTIC\_ID} \mid \text{MACHINE\_ID} \mid \text{code\_bytes})$$ 30 31 --- 32 33 ## 2. Core Doctrine & Invariants 34 35 As mandated by canonical roadmap doctrine (`DOCTRINE-ROADMAP`), the realization synthesis engine satisfies six foundational invariants: 36 37 1. **Realization is Synthesis, Not Hardcoded Compilation**: Lowering searches over machine scheduling, instruction selection, and register assignment to match $G_M$. The system does not emit static instruction boilerplate; it formulates lowering as an optimization problem constrained by the target machine graph's pipeline dimensions and functional unit counts. 38 2. **Triple Identity Binding**: $REALIZATION_ID$ deterministically incorporates $SEMANTIC_ID$ ($G_S$), $MACHINE_ID$ ($G_M$), and machine code bytes. A realization is valid only when paired with both the semantic intent it implements and the physical machine profile for which it was generated. Modifying semantic intent, machine topology, or machine code changes the cryptographic identity. 39 3. **Machine-Aware Scheduling & Optimization**: Synthesizes instruction schedules optimized for target machine issue width (4-wide on DGX Spark Grace V2 vs 2-wide on QEMU virt), functional unit concurrency, and execution latencies. The scheduler reorders independent operations and eliminates write-after-read (WAR) or write-after-write (WAW) hazards to maximize multi-issue slot occupancy. 40 4. **Strict Semantic Preservation**: Native execution of the synthesized realization produces identical outputs to semantic evaluation across all test domains. Parity is absolute: for every input in the domain envelope, executing native machine code emits the exact bitwise value computed by interpreting the semantic AST. 41 5. **Zero Foreign Toolchain**: 0 LLVM, 0 GNU as, 0 GCC inline asm, 0 JIT, 0 Python. All native machine instructions are generated via direct AArch64 machine byte encoders (`aarch64_encoder.c`) without invoking external compilers, assemblers, linkers, or foreign runtimes. 42 6. **Mandatory M7 Verification**: Every synthesized realization passes Milestone 7 (`OMEGA_VERIFY`) $V_0$ structural, $V_1$ differential, and $V_2$ property verification before admission. No realization is stored or deployed without passing the full verification ladder. 43 44 --- 45 46 ## 3. Synthesis Engine Architecture & Machine Scheduling 47 48 ### 3.1 Synthesis Pipeline 49 50 ```text 51 +-------------------------------------------------------------------------------+ 52 | OMEGA_REALIZATION_SYNTHESIS PIPELINE | 53 +-------------------------------------------------------------------------------+ 54 | 1. Task Ingress : Semantic Graph (G_S) x Machine Hardware Graph (G_M) | 55 | 2. Instruction Search : Select candidate machine instructions for AST nodes | 56 | 3. Schedule Search : Machine-aware scheduling over target issue slots | 57 | - Unit latency avoidance (RAW stall elimination) | 58 | - Structural hazard resolution (ALU/MUL/LSU bounds) | 59 | - Multi-issue packing (issue_width: 4 vs 2) | 60 | 4. Register Allocation : GPR assignment maximizing operand independence | 61 | 5. Direct Byte Emit : Sovereign AArch64 machine code generation | 62 | 6. Triple Identity : SHA-256(OMG0 | G_S | G_M | code_bytes) -> REAL_ID | 63 | 7. Verification Ladder : M7 V0 Structural -> V1 Differential -> V2 Property | 64 | 8. Receipt & Admission : Emit qualification receipt and admit Realization | 65 +-------------------------------------------------------------------------------+ 66 ``` 67 68 ### 3.2 Machine Scheduling & Instruction Selection 69 70 The realization synthesis engine searches the lowering space using target pipeline metrics from $G_M$: 71 72 - **Functional Unit Modeling**: The engine references `units` in $G_M$ (`UNIT_ALU`, `UNIT_MULTIPLIER`, `UNIT_LOAD_STORE`, `UNIT_BRANCH`, `UNIT_VECTOR`) to schedule operations only on available hardware ports without exceeding cycle throughput limits. 73 - **Latency-Aware Interleaving**: For multi-cycle operations (e.g., multiplication with 3-cycle latency), the scheduler interleaves independent operations (such as subsequent immediate loads or address calculations) into the latency bubble, preventing pipeline stalls. 74 - **Dual-Issue and Quad-Issue Packing**: 75 - On **NVIDIA DGX Spark Grace V2** (ARM Neoverse V2, 4-wide dispatch, 4x ALU, 2x Branch, 2x Multiplier, out-of-order execution), synthesis generates schedules that pre-load independent operands into separate registers (e.g., `X1`, `X2`), enabling multiple instructions to be dispatched in the same cycle without anti-dependencies. 76 - On **QEMU Virt AArch64 Baseline** (generic AArch64, 2-wide dispatch, 2x ALU, 1x Multiplier, in-order execution), synthesis prioritizes minimal register pressure, sequential dependency resolution, and compact footprint. 77 78 ### 3.3 Target Specialization Comparison 79 80 Consider the affine arithmetic transformation $f(x) = 3x - 2$: 81 82 - **DGX Spark Grace V2 (4-Wide Dispatch)**: 83 ```text 84 Cycle 0, Slot 0: MOVZ X1, 3, LSL 0 ; Port 0 (ALU 0) - Pre-load multiplier 85 Cycle 0, Slot 1: MOVZ X2, 2, LSL 0 ; Port 1 (ALU 1) - Pre-load subtrahend (disjoint reg) 86 Cycle 1, Slot 0: MUL X0, X0, X1 ; Port 2 (Multiplier 0) - Compute 3 * x 87 Cycle 4, Slot 0: SUB X0, X0, X2 ; Port 0 (ALU 0) - Immediate subtract using pre-loaded X2 88 Cycle 4, Slot 1: RET ; Port 1 (Branch 0) - Return 89 ``` 90 Operand pre-loading eliminates register hazards and leverages multi-issue capability across distinct execution units. 91 92 - **QEMU Virt Generic (2-Wide Dispatch)**: 93 ```text 94 Cycle 0, Slot 0: MOVZ X1, 3, LSL 0 ; ALU 0 - Load multiplier 95 Cycle 1, Slot 0: MUL X0, X0, X1 ; Multiplier - Compute 3 * x 96 Cycle 5, Slot 0: MOVZ X1, 2, LSL 0 ; ALU 0 - Reuse temporary X1 (low register pressure) 97 Cycle 6, Slot 0: SUB X0, X0, X1 ; ALU 0 - Subtract 98 Cycle 7, Slot 0: RET ; Branch - Return 99 ``` 100 Sequential schedule minimizing register allocation footprint to match constrained in-order execution pipelines. 101 102 ### 3.4 Verification Ladder Integration 103 104 Before any synthesized realization is accepted, it must pass all three tiers of the Milestone 7 (`OMEGA_VERIFY`) verification engine: 105 106 1. **$V_0$ Structural Verification**: Confirms alignment, valid instruction boundaries, non-zero code length within safe buffer bounds, safe entry offset, and mandatory legal termination (`RET`). 107 2. **$V_1$ Differential Verification**: Executes the realization in a memory-isolated execution page across boundary test vectors and compares observed results against high-level semantic evaluation: 108 $$\forall x \in \text{TestDomain}, \quad \text{Exec}(G_R, x) == \text{Eval}(G_S, x)$$ 109 3. **$V_2$ Property Verification**: Enforces calling convention invariants (AAPCS64), ensuring callee-saved registers (`X19`-`X28`) are preserved, stack balance is strictly maintained, and execution terminates deterministically without traps. 110 111 --- 112 113 ## 4. Data Model & C API Declarations 114 115 ```c 116 #ifndef OMEGA_REALIZE_SYNTH_H 117 #define OMEGA_REALIZE_SYNTH_H 118 119 #include "omega_types.h" 120 #include "omega_program.h" 121 #include "omega_machine.h" 122 #include "omega_realize.h" 123 #include "omega_verify.h" 124 #include 125 #include 126 #include 127 128 #define OMEGA_REALIZE_MAX_SCHEDULE_SLOTS 128 129 130 /* Individual scheduled instruction slot */ 131 typedef struct { 132 uint32_t cycle; 133 ComputeUnitType unit_type; 134 uint32_t instruction_word; 135 uint8_t dest_reg; 136 uint8_t src_reg1; 137 uint8_t src_reg2; 138 uint8_t latency_cycles; 139 } RealizationScheduleSlot; 140 141 /* Complete machine-aware instruction schedule */ 142 typedef struct { 143 uint32_t total_cycles; 144 uint32_t slot_count; 145 uint32_t issue_width; 146 RealizationScheduleSlot slots[OMEGA_REALIZE_MAX_SCHEDULE_SLOTS]; 147 } RealizationSchedule; 148 149 /* Synthesis task parameters binding semantic intent and target machine */ 150 typedef struct { 151 const OmegaProgram *program; 152 const OmegaMachineGraph *machine; 153 bool optimize_latency; 154 uint32_t max_unroll_factor; 155 } RealizationSynthesisTask; 156 157 /* Complete synthesis output object with verification receipt */ 158 typedef struct { 159 bool solved; 160 RealizationObject realization; 161 SemanticId realization_id; 162 uint32_t estimated_cycles; 163 uint32_t code_bytes_len; 164 RealizationSchedule schedule; 165 VerifyReport verify_report; 166 } RealizationSynthesisResult; 167 168 typedef RealizationSynthesisResult OmegaRealizationSynthesisResult; 169 170 /* Task Initialization */ 171 void omega_realize_task_init(RealizationSynthesisTask *task, 172 const OmegaProgram *prog, 173 const OmegaMachineGraph *mg); 174 175 /* Cryptographic Triple Binding: 176 * REALIZATION_ID = SHA-256(OMG0 | KIND_REALIZATION | profile | entry_offset | code_len | 177 * SEMANTIC_ID | MACHINE_ID | code_bytes) 178 */ 179 int omega_realize_compute_triple_id(const SemanticId *semantic_id, 180 const SemanticId *machine_id, 181 const RealizationObject *real, 182 SemanticId *out_id); 183 184 /* Machine-Aware Schedule Construction & Validation */ 185 int omega_realize_build_schedule(const OmegaProgram *prog, 186 const OmegaMachineGraph *mg, 187 RealizationSchedule *schedule); 188 189 int omega_realize_validate_schedule(const RealizationSchedule *schedule, 190 const OmegaMachineGraph *mg, 191 char *err_msg, 192 size_t err_msg_len); 193 194 /* Core Realization Synthesis Entrypoint (G_S x G_M -> G_R) */ 195 int omega_synthesize_realization(const RealizationSynthesisTask *task, 196 RealizationSynthesisResult *result); 197 198 /* Target Specialization Entrypoints */ 199 int omega_synthesize_for_dgx_spark(const OmegaProgram *prog, 200 RealizationSynthesisResult *result); 201 202 int omega_synthesize_for_qemu_virt(const OmegaProgram *prog, 203 RealizationSynthesisResult *result); 204 205 #endif /* OMEGA_REALIZE_SYNTH_H */ 206 ``` 207 208 --- 209 210 ## 5. The 10 Qualification Gates 211 212 Milestone 14 qualification requires 100% pass across 10 canonical gates: 213 214 1. `OMEGA_REAL_SYNTH_INIT_PASS`: Synthesis task initializes cleanly with valid semantic program ($G_S$), target machine hardware graph ($G_M$), and optimization parameters. 215 2. `OMEGA_REAL_SYNTH_TRIPLE_ID_PASS`: Cryptographic triple binding deterministic SHA-256 identity incorporates $SEMANTIC_ID$, $MACHINE_ID$, and raw machine code bytes. 216 3. `OMEGA_REAL_SYNTH_SCHEDULE_OPT_PASS`: Machine-aware schedule search generates valid instruction schedules avoiding structural hazards and matching pipeline constraints. 217 4. `OMEGA_REAL_SYNTH_DGX_SPARK_PASS`: Realization specialized for 4-wide DGX Spark Grace Neoverse V2 pipeline synthesizes multi-issue instruction layout. 218 5. `OMEGA_REAL_SYNTH_QEMU_VIRT_PASS`: Realization specialized for 2-wide QEMU virt baseline synthesizes compact sequential schedule. 219 6. `OMEGA_REAL_SYNTH_SEMANTIC_PARITY_PASS`: Native execution of synthesized realization achieves exact bit-for-bit output equivalence with semantic evaluation across all test vectors. 220 7. `OMEGA_REAL_SYNTH_V0_STRUCTURAL_PASS`: Synthesized realization passes Milestone 7 (`OMEGA_VERIFY`) $V_0$ structural verification (valid entry point, aligned code bounds, legal instruction boundaries). 221 8. `OMEGA_REAL_SYNTH_V1_DIFFERENTIAL_PASS`: Synthesized realization passes Milestone 7 (`OMEGA_VERIFY`) $V_1$ differential verification against reference semantic evaluation across boundary inputs. 222 9. `OMEGA_REAL_SYNTH_V2_PROPERTY_PASS`: Synthesized realization passes Milestone 7 (`OMEGA_VERIFY`) $V_2$ property verification (register preservation, stack neutrality, deterministic termination). 223 10. `OMEGA_REAL_SYNTH_RECEIPT_PASS`: Master qualification test harness executes all assertions and produces an immutable cryptographic receipt recording machine identity, semantic identity, and realization gates. 224 225 --- 226 227 ## 6. Provenance & Qualification Evidence 228 229 Milestone 14 is qualified and ratified. All 10 canonical qualification gates passed with 100% compliance and zero regression across cumulative milestones M4 through M14 (101/101 cumulative gates). 230 231 - **Implementation Commit**: ``c0c8102ecc7f36cb86ab8686e5f1ee08eb59762d`` (`aien-spark/omega#19`) 232 - **Qualification Receipt Commit**: ``03fbcb9`` (`aien-spark/omega`) 233 - **Qualification Receipt File**: [`evidence/omega_realization_synthesis_qualification_receipt.json`](https://github.com/aien-dev/omega-mv/blob/main/evidence/omega_realization_synthesis_qualification_receipt.json) 234 235 ```json 236 { 237 "milestone": "MILESTONE 14 — OMEGA_REALIZATION_SYNTHESIS", 238 "status": "QUALIFIED / PASS", 239 "contract_id": "CONTRACT-OMEGA-REALIZATION-SYNTHESIS-M14", 240 "source_parent_commit": "`db066d9b4dbce19069bc92025aa0fae7401d413e`", 241 "qualified_implementation_commit": "`c0c8102ecc7f36cb86ab8686e5f1ee08eb59762d`", 242 "receipt_commit": "`7c07acae88ebeb32e62608bb30bc659a61297943`", 243 "gates": { 244 "OMEGA_REAL_SYNTH_INIT_PASS": "PASS", 245 "OMEGA_REAL_SYNTH_TRIPLE_ID_PASS": "PASS", 246 "OMEGA_REAL_SYNTH_SCHEDULE_OPT_PASS": "PASS", 247 "OMEGA_REAL_SYNTH_DGX_SPARK_PASS": "PASS", 248 "OMEGA_REAL_SYNTH_QEMU_VIRT_PASS": "PASS", 249 "OMEGA_REAL_SYNTH_SEMANTIC_PARITY_PASS": "PASS", 250 "OMEGA_REAL_SYNTH_V0_STRUCTURAL_PASS": "PASS", 251 "OMEGA_REAL_SYNTH_V1_DIFFERENTIAL_PASS": "PASS", 252 "OMEGA_REAL_SYNTH_V2_PROPERTY_PASS": "PASS", 253 "OMEGA_REAL_SYNTH_RECEIPT_PASS": "PASS" 254 }, 255 "cumulative_qualification": { 256 "cumulative_gates": 101, 257 "cumulative_passed": 101, 258 "zero_regression": true 259 } 260 } 261 ``` 262 263 --- 264 265 ## 7. Future Horizons & Accelerator Coupling 266 267 Milestone 14 completes the core CPU realization synthesis pipeline ($G_S \times G_M \to G_R$). This synthesis engine forms the direct foundation for downstream accelerator milestones: 268 - **Milestone 15 (`PHYSICS_ACCELERATOR_LINK`)**: Bounded coherent memory interfaces and SMMUv3 DMA translation, extending $G_M$ to model CPU-accelerator interconnects. 269 - **Milestone 16 (`BLACKWELL_NATIVE_PATH_KNOWN`)**: Empirical microarchitectural characterization of Blackwell streaming multiprocessors, command queues, and MMIO doorbells, providing the machine graph for sovereign GPU hardware. 270 - **Milestone 17 (`OMEGA_BLACKWELL_VECTOR`)**: Extending $G_S \times G_M \to G_R$ synthesis to target native Blackwell SIMD/vector execution units. 271 - **Milestone 18 (`OMEGA_BLACKWELL_MATMUL`)**: Synthesizing tensor matrix multiply kernels directly into tensor core pipelines under mathematical invariant preservation.