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 / adr / 0043-gpu-stack-portable-top-thin-backend.md
| 1 | # ADR 0043: The GPU stack splits into a portable Omega top and a thin per-target backend behind one 30-call ABI |
| 2 | |
| 3 | **Status:** Accepted (Drake, 2026-10-30). Proposed 2026-10-27. |
| 4 | Design only. No code moves under this ADR until the gate in Decision 0 is met. Recorded by lane |
| 5 | SplitDesign. |
| 6 | **Related:** ARCH-0042 (ACCEPTED 2026-10-30, #342: Omega owns computation, CUDApp owns GPU execution, Omega |
| 7 | Bridge owns compatibility; Decision 2 superseded in part, see Decision 1), ARCH-0024 (Omega is the |
| 8 | destination language), ARCH-0018 |
| 9 | (substrate-neutral realization). The companion file-level design is `docs/ARCHITECTURE.md` in |
| 10 | aien-dev/CUDApp (draft PR linked from this PR). **Merge order:** after ARCH-0042 (#342), whose |
| 11 | Decision 2 this ADR amends; if #342 changes first, this ADR is re-checked against its merged text. |
| 12 | **Inputs, all at pinned heads:** CUDApp main `780a0af1`; omega-mv main `e5b32567`; omega-mv |
| 13 | `omegese/gpu-front` `d1ac019e` and `omegese/gpu` `a99d711c`; the binding plan |
| 14 | `~/handoffs/GpuStack/PLAN.md` (phases P2–P4); the outside review Drake adopted |
| 15 | (`~/handoffs/ExternalReview/2026-10-27-review.md`); research notes |
| 16 | `~/handoffs/SplitDesign/filemap.md` and `c1path.md`. |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Context |
| 21 | |
| 22 | CUDApp (CUDA++) runs LLM kernels on one chip, the GB10 (sm_121), through NVIDIA's open kernel module. |
| 23 | The outside review counted about 26k lines of C in CUDApp and about 35k lines of GPU C in omega-mv, and |
| 24 | answered "portable to AMD, Intel or Apple" with NO. PLAN.md orders the work: cut scope, prove the |
| 25 | numbers, generalize (P2), second backend (P3), integrate (P4). This ADR is the P2–P4 design. |
| 26 | |
| 27 | What the code is today (CUDApp `780a0af1`, file and line evidence in `filemap.md`): |
| 28 | |
| 29 | 1. **Two backend tables already exist over the same driver client.** `OmegaGpuPlatform` |
| 30 | (`src/omega_gpu_platform.h`, ABI 1.2, 22 function pointers, typed index+generation handles, |
| 31 | separate CPU / GPU-VA / bus-address types) sits under the session and command list. |
| 32 | `OmegaGpuBackend` (`src/omega_gpu_engine.h`, 15 ops, VECTOR_1D only) sits under the job engine. |
| 33 | Neither covers kernel compilation or command encoding. |
| 34 | 2. **The seam is in the wrong place.** `queue_submit` takes raw NVIDIA method words, so the QMD and |
| 35 | pushbuffer encoding happens above it, in the "portable" files: `omega_gpu_cmdlist.c` (:199, :219, |
| 36 | :226, :261) and `omega_gpu_session.c` (includes QMD/submit headers :18-19). |
| 37 | 3. **Kernel definitions are C generators against a post-scheduling Blackwell IR.** |
| 38 | `BlackwellIRInsn` carries sm_121 control words and scoreboards. Fifteen `omega_blackwell_codegen_*` |
| 39 | generators plus inline emitters inside `omega_gpu_attention_api.c` and |
| 40 | `omega_gpu_elementwise_api.c` define every LLM kernel. Seventeen API files include backend headers. |
| 41 | 4. **Two files bypass the platform** and call `nvrm/` and `m16/` directly: |
| 42 | `omega_blackwell_engine.c` and `omega_blackwell_submit.c`. |
| 43 | 5. **One submission per token already exists for one model.** `decode_graph` records a whole |
| 44 | Qwen3-30B-A3B token (436 launches over 48 layers) into one command list. That is 1 submit, |
| 45 | 1 doorbell, 2 marker waits and 1 retire. The CPU still writes about 1 KB of constants and 1 KB of |
| 46 | QMD per launch ([INFERENCE] about 872 KiB per token into uncached memory). |
| 47 | 6. **Weights are copied, not shared.** `omega_gpu_fp8_api.c:269-275` does `memcpy` then |
| 48 | sync-to-GPU, although the GB10's memory is physically one LPDDR5X pool. |
| 49 | 7. **The Omega-language path to the GPU (bar C1) is separate and NVIDIA-shaped.** On |
| 50 | `omegese/gpu-front` the path is `tools/omegese/omegese.c` → `src/compiler/osc_ir.{h,c}` (IR v6, 37 |
| 51 | ops, 7 GPU-only) → `src/checker2/c2_check.c` (12 GPU rules) → `src/omega_osc_gpu.c` → the existing |
| 52 | BlackwellIR encoder → `src/omega_osc_launch.c`. C1 is "BUILDING, chip FAIL" (2026-10-22: vadd |
| 53 | 896 wrong words with trap status 0, the GEMM launch hung, attention not run, cause undocumented). |
| 54 | IR v6 bakes in a warp of 32, down-only shuffles, a 48 KiB shared cap, a 16-deep nesting cap tied to |
| 55 | BSSY barrier registers, and transcendental semantics defined by MUFU. All of these stages except |
| 56 | the IR text are C. |
| 57 | 8. **Omega can already drive a device without C.** omc on omega-mv main `e5b32567` has `devctl`, |
| 58 | `devcall` (RM_ALLOC / RM_CONTROL), `uvmctl` (an allowlist of 11 UVM requests from the 580.173.02 |
| 59 | ABI, including MAP_EXTERNAL_ALLOCATION and CREATE_EXTERNAL_RANGE), `mapnew`, `maphold`, `mapbind`, |
| 60 | `mapget` and `mapset` (aligned 32/64-bit device-word access bracketed by DSB SY); |
| 61 | `seed/host/MAPPING.md`. omc emits static AArch64 Linux ELF only. It has no way to call a C shared |
| 62 | library, and its `devctl` allowlist covers only NVRM requests and FIONREAD. |
| 63 | 9. **Non-NVIDIA reach today is SPIR-V and CPU only.** `irspirv.om` (merged; OpenCL SPIR-V on PoCL |
| 64 | CPU), `vkspirv.om` (draft omega-mv #876: Vulkan GLCompute SPIR-V, lavapipe green in CI, MoltenVK on |
| 65 | an M2 PASS, interim C launcher `vk-host.c`). No AMD, Intel, Apple-native or Qualcomm emitter exists. |
| 66 | |
| 67 | PLAN.md's language rule binds the design: C imported from omega-mv moves unchanged; **new host-runtime |
| 68 | code is `.om`** (streams and events, multi-process sharing, the watchdog, the API implementation, the |
| 69 | scheduler, memory management); device kernels stay on the current encoder until C1 lands; any new C |
| 70 | needs a missing-feature reason with an extension proposal filed, behind a `migration-pending` build |
| 71 | switch. |
| 72 | |
| 73 | ## Decision |
| 74 | |
| 75 | ### 0. Gate: no code for P2–P4 before the proof |
| 76 | |
| 77 | Code under this ADR starts only when P0 has published a same-box head-to-head and P1's bars C2–C5 are |
| 78 | QUALIFIED on the GB10. Until then only design documents, extension proposals and host-only experiments |
| 79 | that touch no shared file are allowed. This restates PLAN.md; it is not new policy. |
| 80 | |
| 81 | ### 1. The split |
| 82 | |
| 83 | | Layer | Owns | Language | Lives in | |
| 84 | |---|---|---|---| |
| 85 | | **Portable top** | kernel definitions (Omegese), model graphs and scheduling (decode graph, batching), serving, the memory planner (weights, KV pool, scratch, serving reservation), streams/events, multi-process sharing, watchdog policy, the versioned public API | `.om` for all new code; the imported C top stays as migration | CUDApp | |
| 86 | | **Backend ABI** | the 30 calls in Decision 2 and the code-object formats in Decision 3 | defined once in `.om`; fixed field layout so receipts and the CPU reference backend can check it. The imported C stack is **not** retrofitted to it (that would be new C); it keeps `OmegaGpuPlatform` 1.2 until it is retired | CUDApp `backend/abi.om` (new) | |
| 87 | | **Thin backend, one per target** | driver client, command encoding (QMD/pushbuffer, AQL packets, Vulkan or Metal command buffers), code-object writer, per-target lowering and machine-code encoder, tuned kernels | `.om` for every new backend; the GB10 C backend is migration | new backends in CUDApp `backend/<target>/`; the existing GB10 C files stay where they are in `src/`, `nvrm/`, `m16/` and are classified, not moved | |
| 88 | | **Kernel IR, checker, front end** | Omegese, the kernel IR, checker2 | `.om` destination (omc's IR mode); the C front end on `omegese/gpu-front` is migration | omega-mv (ARCH-0042 Decision 1) | |
| 89 | | **Integrations** | ggml, vLLM, ONNX Runtime attachments | per-host language at the edge, calling compiled Omega through omega-bridge bindings | connected repos under omega-bridge (ARCH-0042 Decision 3) | |
| 90 | |
| 91 | Ownership seam with ARCH-0042, **settled by Main's ruling of 2026-10-27** (recorded in |
| 92 | `~/handoffs/GpuStack/PLAN.md`, Rules → "Where code lives"): the existing C lowering in omega-mv (the |
| 93 | Omegese → IR → sm_121 path, checker2, host words) stays in omega-mv and is fixed there by lane C1Lang; |
| 94 | CUDApp consumes it at a pinned sha. Everything else in the GPU stack (driver client, kernels, runtime, |
| 95 | receipts) lands in CUDApp, as does any new `.om` code generator, including the `.om` successor of the |
| 96 | sm_121 lowering (`backend/gb10/`). The omega-mv copies of GPU runtime code are not deleted until the |
| 97 | cutover is proven; removal is a separate PR. Existing code is not moved or split between repos |
| 98 | (ARCH-0042 Decision 7). |
| 99 | |
| 100 | **Supersedes, in part, ARCH-0042 Decision 2.** Where Decision 2 assigns "GPU code generators … the |
| 101 | register allocator and scheduling bits" to CUDApp, that clause does not cover the existing C sm_121 |
| 102 | lowering of the Omegese → IR → checker2 path, which stays in omega-mv under the ruling above. The rest of |
| 103 | Decision 2 stands. |
| 104 | |
| 105 | **In-process rule.** The top and a backend are linked into one program by omc (both `.om`), so a call |
| 106 | across the ABI is an ordinary Omega call. A `.om` top cannot call a C backend in-process today (fact 8). |
| 107 | Consequence: the imported C top and C GB10 backend keep running together as the migration path, and |
| 108 | the new `.om` top is built against a `.om` GB10 backend that uses the device words omc already has. |
| 109 | No `.om`-to-C shim is written to bridge them. |
| 110 | |
| 111 | ### 2. The backend ABI: 30 calls |
| 112 | |
| 113 | `OmegaBackend` ABI 2.0 is the successor of both `OmegaGpuPlatform` 1.2 and `OmegaGpuBackend` in the |
| 114 | `.om` stack; the two C tables stay frozen under the imported C stack until it is retired. It keeps the 1.2 |
| 115 | conventions that worked: typed handles (index + generation, 1024-slot table), separate CPU-view / |
| 116 | GPU-VA / bus-address types, rights bits, the GPU-uncached rule for host-polled words, and |
| 117 | `negotiate`/`check` before use. Host services (time, sleep, locks, host allocation) leave the backend: |
| 118 | the top gets them from Omega host words. All calls return a status code (`OK`, `REFUSED`, `NOMEM`, |
| 119 | `TIMEOUT`, `FAULT`, `LOST`, `UNSUPPORTED`); outputs go through out-parameters. |
| 120 | |
| 121 | | # | Call | Contract | GB10 today (CUDApp `780a0af1`) | |
| 122 | |---|---|---|---| |
| 123 | | 1 | `ob_negotiate(abi_major, abi_minor, out table)` | refuse on major mismatch | `omega_gpu_platform_negotiate` (platform.c) | |
| 124 | | 2 | `ob_device_count(out n)` | enumerate devices of this backend | `omega_gpu_chip.c` /sys PCI table | |
| 125 | | 3 | `ob_device_open(index, out dev)` | open driver, create VA space and channel | `nvrm_open` + `m16_native_create_channel` (platform_linux.c `device_open`) | |
| 126 | | 4 | `ob_device_close(dev)` | release everything owned by the device | `m16_native_close` | |
| 127 | | 5 | `ob_device_caps(dev, out caps)` | target id, subgroup width, shared bytes, max grid, accepted code formats, unified-memory class, queue count, timestamp period | scattered constants (code_alloc.h, codegen limits); new struct | |
| 128 | | 6 | `ob_device_status(dev, out fault)` | fault/lost state and driver fault code | not exposed; nvrm event/Xid path [INFERENCE] | |
| 129 | | 7 | `ob_diag_text(dev, buf, n)` | bounded diagnostic text | `ref_diag_text` | |
| 130 | | 8 | `ob_mem_alloc(dev, bytes, flags, out buf)` | flags: DEVICE_LOCAL, HOST_VISIBLE, HOST_COHERENT, GPU_UNCACHED, CODE, READ_MOSTLY; returns handle + CPU view + GPU VA | `dma_alloc` → `nvrm_alloc_gpu_uncached` / `nvrm_alloc` | |
| 131 | | 9 | `ob_mem_import_host(dev, cpu_ptr, bytes, flags, out buf)` | zero-copy: map existing page-aligned host memory (an mmapped weight file) for the GPU without copying; `UNSUPPORTED` if the target cannot | none; fp8_api.c:269-275 copies | |
| 132 | | 10 | `ob_mem_free(buf)` | | `dma_free` → `nvrm_free` | |
| 133 | | 11 | `ob_mem_flush(buf, off, n)` | CPU writes visible to GPU | `sync_cpu_to_gpu` (dsb sy + L2 invalidate, omega#457) | |
| 134 | | 12 | `ob_mem_invalidate(buf, off, n)` | GPU writes visible to CPU | `sync_gpu_to_cpu` | |
| 135 | | 13 | `ob_mem_advise(buf, off, n, advice)` | prefetch, residency, read-mostly; advisory, never changes results | none (AIEN_OMEGA_DGRAPH_PREFETCH env only) | |
| 136 | | 14 | `ob_mem_info(dev, out stats)` | used, free, reserved, driver allocations since seal | serving reserve/seal stats (serving.c) | |
| 137 | | 15 | `ob_code_load(dev, code_object, out code)` | load one code object (Decision 3); validates format and resource metadata, refuses unknown | `session_alloc_code` + code copy; `omega_cubin.c` for cubins | |
| 138 | | 16 | `ob_code_info(code, out info)` | registers, shared bytes, argument layout, max threads | QMD fields in `omega_blackwell_qmd.c` | |
| 139 | | 17 | `ob_code_free(code)` | | `session_free` | |
| 140 | | 18 | `ob_queue_open(dev, flags, out q)` | flags: priority, shared-process | `queue_open` (one queue today) | |
| 141 | | 19 | `ob_queue_close(q)` | | `queue_close` | |
| 142 | | 20 | `ob_dispatch(q, code, dispatch)` | append one launch: grid[3], block[3], dynamic shared bytes, argument bytes, buffer bindings. **The backend encodes it**: QMD + constant bank on GB10, an AQL packet + kernarg on AMD, `vkCmdDispatch` on Vulkan, a compute encoder on Metal | `omega_gpu_session_launch` (session.c:445) and `emit_inline_qmd` (cmdlist.c:226) with its PCAS method words (cmdlist.c:308-309), moved below the seam | |
| 143 | | 21 | `ob_submit(q, out seq)` | ring the doorbell once for everything appended since the last submit | `queue_submit` → `m16_native_submit_methods` (1 GPFIFO entry + doorbell) | |
| 144 | | 22 | `ob_graph_begin(q)` | start recording dispatches into a replayable graph | `omega_gpu_cmdlist` record mode | |
| 145 | | 23 | `ob_graph_end(q, out graph)` | close the recording; the backend may pre-encode everything | cmdlist finalize | |
| 146 | | 24 | `ob_graph_launch(q, graph, patches, out seq)` | replay a graph with a small patch list (token position, KV length, buffer offsets) and one doorbell | `omega_gpu_cmdlist_submit`'s `queue_submit` call (cmdlist.c:325), which `decode_graph` replays through; per-token patching is new | |
| 147 | | 25 | `ob_graph_free(graph)` | | cmdlist free | |
| 148 | | 26 | `ob_fence_wait(q, seq, timeout_ns, out status)` | wait for completion; `TIMEOUT` and `FAULT` are results, not hangs | `poll_word` → `m16_native_wait_marker` | |
| 149 | | 27 | `ob_event_record(q, out ev)` | a point in a queue other queues or processes can wait on (C4 streams) | none (cmdlist stamps only) | |
| 150 | | 28 | `ob_queue_wait_event(q, ev)` | GPU-side wait, no CPU round trip | none | |
| 151 | | 29 | `ob_queue_reset(q)` | cancel outstanding work and restore a usable queue after a fault or a watchdog decision (C5) | `queue_retire` + session park; recovery is new | |
| 152 | | 30 | `ob_clock_ns(dev, out host_ns, out gpu_ticks)` | correlate host and GPU clocks for timing receipts | `time_now_ns` (host only) | |
| 153 | |
| 154 | Rules on the ABI: |
| 155 | |
| 156 | - **Raw method words never cross it.** That is the defect it fixes. `submit_prefix_words`, PCAS and |
| 157 | INLINE modes, and the 5-word L2 invalidate prefix become GB10 backend internals. |
| 158 | - **Bypasses are retired.** `omega_blackwell_engine.c` and `omega_blackwell_submit.c` stop being |
| 159 | called by the top; they stay in place as GB10-internal code (or are deleted at a cutover that |
| 160 | replaces them). The `m16/` and `nvrm/` gate programs remain backend tests. Within CUDApp the split is |
| 161 | logical (headers, build groups, CODEOWNERS), not a file move. |
| 162 | - **Versioning.** The public runtime API is ABI 0.1 today. Moving the STABLE |
| 163 | `omega_gpu_session_launch` / `OmegaGpuLaunch` from raw code + QMD shape to a code object is a MAJOR |
| 164 | bump (API.md §2). The decode-path APIs absent from the manifest today (fp8, fp8gemm, bf16_gemv, |
| 165 | decode_attn, router, tern, tcgemm, prefill*, moe, decode_graph) enter the manifest as EXPERIMENTAL |
| 166 | before any of them moves (CUDApp#124). API.md §2 counts an added EXPERIMENTAL entry as a MINOR |
| 167 | change, so the first such entry bumps the API to 0.2 (MINOR) when it enters the manifest; no |
| 168 | exception to API.md §2 is made. |
| 169 | - **A CPU reference backend** (AArch64, `.om`) implements the same 30 calls with code-object format |
| 170 | `AARCH64`. It runs every top-level test on a GitHub `ubuntu-24.04-arm` runner without a GPU and is |
| 171 | the negative-control target: a mutant kernel must fail there before any chip run is requested. |
| 172 | |
| 173 | ### 3. One kernel source: Omegese → kernel IR → checker2 → per-target lowering |
| 174 | |
| 175 | Kernels are written once in Omegese. Bar C1's path becomes the only kernel source once C1 is QUALIFIED |
| 176 | on the GB10; the C generators stay as the tuned GB10 path and as the oracle for each kernel until its |
| 177 | Omegese version matches it on chip with identical golden tokens. |
| 178 | |
| 179 | **IR v7 (proposal to omega-mv; v6 stays frozen for C1).** Make the NVIDIA-shaped facts per-target |
| 180 | parameters reported by `ob_device_caps`, not semantics: |
| 181 | |
| 182 | - subgroup width as a parameter (32 on NVIDIA and Apple, 64 on CDNA, 32 or 64 on RDNA, implementation |
| 183 | defined on Vulkan), with shuffles defined over the parameter and both directions; |
| 184 | - shared-memory budget as a parameter, refused by checker2 when a kernel exceeds the device's value; |
| 185 | - the nesting cap as a checker2 parameter, not a property of BSSY; |
| 186 | - transcendental ops defined by a stated accuracy class (correctly rounded / ≤ N ulp / fast), each |
| 187 | target proving its class against the host reference; |
| 188 | - new: explicit address spaces (global, shared, constant), atomics, f16/bf16/fp8 types, and one tiled |
| 189 | matrix-multiply-accumulate op with per-target lowering (HMMA/QMMA on sm_121, MFMA on CDNA, WMMA on |
| 190 | RDNA 3/3.5, simdgroup matrix on Apple, cooperative-matrix or scalar on Vulkan). |
| 191 | |
| 192 | The checker2 race and divergence rules are already target-generic and carry over unchanged. The |
| 193 | front end's destination is omc's own IR mode (OMEGESE §11, `.om`); the C front end |
| 194 | `tools/omegese/omegese.c` is migration. |
| 195 | |
| 196 | **Per-target lowerings and code objects:** |
| 197 | |
| 198 | | Target | Code object | Lowering path | Oracles (verification only, never in the build path) | |
| 199 | |---|---|---|---| |
| 200 | | GB10 sm_121 | `SM121_RAW` (code + launch metadata, today's form) | existing `omega_osc_gpu.c` → BlackwellIR → regalloc → encoder; `.om` port after C1 | NAK sources (MIT) + chip tests; `nvdisasm` as a read-only checker (C6) | |
| 201 | | AMD CDNA3 (gfx942) / RDNA3.5 (gfx1151) | `AMDGPU_HSACO` (ELF code object with HSA metadata notes) | **direct `.om` encoder** from AMD's published ISA reference guides, plus a `.om` HSACO writer | `llvm-mc --disassemble`, `llvm-readelf --notes`, reference kernels from `llc -mtriple=amdgcn-amd-amdhsa`, chip tests | |
| 202 | | Vulkan 1.3 compute | `SPIRV_VK` | `vkspirv.om` (draft #876) re-based on IR v7 | `spirv-val`, lavapipe, chip tests | |
| 203 | | Apple M-series | `MSL_SOURCE` | `.om` emits Metal Shading Language text; Metal's runtime compiler builds it at load | the same kernel through MoltenVK + SPIR-V; host reference | |
| 204 | | Qualcomm Adreno | `SPIRV_VK` via Mesa turnip | the Vulkan path | as Vulkan | |
| 205 | | CPU reference | `AARCH64` | omc's native path | host reference, Wolfram for constants | |
| 206 | |
| 207 | Why the direct AMD encoder and not LLVM IR → `llc` in the build: an outside compiler in the build path |
| 208 | is a dependency that must be recorded with its replacement (harness rule), and AMD publishes the ISA, so |
| 209 | a direct encoder needs no reverse engineering. LLVM stays where `nvdisasm` sits for NVIDIA: an oracle |
| 210 | that checks my words. If the direct encoder blocks P3 for longer than a stated budget, `llc` may be |
| 211 | used as a disclosed, pinned, migration-pending build dependency by a later decision, not by default. |
| 212 | |
| 213 | Apple honestly: AIR and the AGX ISA are undocumented, so the Apple backend emits MSL text and relies on |
| 214 | Apple's compiler. That is a platform dependency of the same kind as NVIDIA's kernel module, recorded |
| 215 | with its version. No AGX reverse engineering. |
| 216 | |
| 217 | ### 4. Unified memory is the edge |
| 218 | |
| 219 | Three mechanisms, each a measurement target before any claim: |
| 220 | |
| 221 | 1. **Zero-copy weights.** The weight file is mmapped once; `ob_mem_import_host` maps those pages for |
| 222 | the GPU. Weights appear once in physical memory and processes that share the file share the pages |
| 223 | (this feeds C5 multi-process sharing). |
| 224 | 2. **One submission per token.** The decode token is a recorded graph replayed with a patch list |
| 225 | (`ob_graph_launch`), removing the per-launch QMD/constant rewrite (about 872 KiB per token |
| 226 | [INFERENCE]). |
| 227 | 3. **A resident whole-model kernel** (experiment, not a commitment): a persistent kernel reads a |
| 228 | device-side work word per token from host-coherent memory. It is gated on watchdog and preemption |
| 229 | behaviour per target and is dropped on any target where it cannot be cancelled by `ob_queue_reset`. |
| 230 | |
| 231 | | Machine | Memory | Zero-copy import | One submission per token | Resident kernel | |
| 232 | |---|---|---|---|---| |
| 233 | | GB10 | 128 GB LPDDR5X shared, CPU–GPU coherent link | UVM external range on mmapped pages (`uvmctl` CREATE_EXTERNAL_RANGE / MAP_EXTERNAL_ALLOCATION are already allowlisted in omc); first task is a host probe of which path the 580.173.02 module accepts for file-backed pages [INFERENCE] | exists for Qwen3-30B-A3B via PCAS; add patching | host-polled word in GPU-uncached memory (existing rule); watchdog TBD | |
| 234 | | Apple M-series (M2 reachable) | unified LPDDR | `newBufferWithBytesNoCopy` on page-aligned mmap, shared storage mode | one command buffer per token; indirect command buffers for replay | not planned: the GPU watchdog kills long kernels [INFERENCE] | |
| 235 | | AMD Strix Halo (gfx1151 APU) | unified LPDDR5X | KFD SVM (`AMDKFD_IOC_SVM` set-attributes) or userptr allocation | N AQL packets written to the user-mode queue, one doorbell write | candidate; AQL queues allow long-running kernels [INFERENCE] | |
| 236 | | AMD MI300A (gfx942 APU) | unified HBM3 | KFD SVM with XNACK (`AMDKFD_IOC_SET_XNACK_MODE`) | as Strix Halo | candidate | |
| 237 | | AMD MI300X (gfx942 discrete) | separate HBM; **not unified** | copy path only; tests the backend and kernels, not the unified-memory edge | as Strix Halo | candidate | |
| 238 | | Qualcomm Snapdragon (Adreno) | unified LPDDR5X | `VK_EXT_external_memory_host` on turnip | reused Vulkan command buffers, one `vkQueueSubmit` | not planned | |
| 239 | |
| 240 | KFD facts checked 2026-10-27 on kernel.org master: `include/uapi/linux/kfd_ioctl.h` defines |
| 241 | `KFD_IOCTL_MAJOR_VERSION 1`, `MINOR 23`, `AMDKFD_IOC_SVM`, `AMDKFD_IOC_SET_XNACK_MODE`, |
| 242 | `AMDKFD_IOC_CREATE_QUEUE`, `AMDKFD_IOC_ALLOC_MEMORY_OF_GPU`, `AMDKFD_IOC_MAP_MEMORY_TO_GPU`, |
| 243 | `AMDKFD_IOC_CREATE_EVENT`, `AMDKFD_IOC_WAIT_EVENTS`, `AMDKFD_IOC_ACQUIRE_VM`. |
| 244 | |
| 245 | The pitch "the fastest inference stack for unified-memory machines, across vendors" stays out of every |
| 246 | README until a paired A/B receipt backs it on at least two vendors. |
| 247 | |
| 248 | ### 5. Second backend: AMD first, Vulkan as the broad fallback |
| 249 | |
| 250 | **The AMD backend is `.om` end to end:** `/dev/kfd` + a DRM render node for the driver client, AQL |
| 251 | packets written by the backend, the direct gfx encoder of Decision 3, an HSACO writer. It does not link |
| 252 | ROCr or HIP. ROCr/HSA (`hsa_amd_svm_*`, AQL) is the reference for behaviour and a test oracle. |
| 253 | |
| 254 | Required Omega extension (proposal to file before P3 code): widen omc's `devctl` allowlist, today |
| 255 | NVRM-only, with the exact KFD ioctl requests and payload sizes from `kfd_ioctl.h` 1.23, the same way |
| 256 | `uvmctl` lists UVM requests from the pinned 580.173.02 ABI. |
| 257 | |
| 258 | **Vulkan** needs the Vulkan loader, a C shared library. omc cannot call shared libraries (fact 8), so a |
| 259 | `.om` Vulkan backend needs a second extension proposal: checked calls into ELF/Mach-O shared libraries. |
| 260 | Until it lands, `vk-host.c` (draft #876) stays the disclosed interim C launcher behind |
| 261 | `migration-pending`. Metal has the same prerequisite. Direct DRM ioctls (amdgpu, v3d, msm) avoid the |
| 262 | loader on Linux and are the `.om`-native route where a vendor documents its uAPI. |
| 263 | |
| 264 | **Licences, checked 2026-10-27 from upstream files** (I use public interfaces and documentation; no |
| 265 | code is copied): |
| 266 | |
| 267 | | Component | Licence | Source checked | |
| 268 | |---|---|---| |
| 269 | | Linux amdgpu driver | `MODULE_LICENSE("GPL and additional rights")` | `drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c` | |
| 270 | | KFD uAPI header | MIT-style permission notice, AMD 2014 | `include/uapi/linux/kfd_ioctl.h` | |
| 271 | | ROCR-Runtime (HSA runtime) | University of Illinois/NCSA | ROCm/ROCR-Runtime `LICENSE.txt`; repo marked deprecated, moved to ROCm/rocm-systems `projects/rocr-runtime` | |
| 272 | | ROCT thunk (libhsakmt) | MIT | ROCm/ROCT-Thunk-Interface `LICENSE.md` | |
| 273 | | HIP runtime (CLR) | MIT | GitHub licence field, ROCm/clr | |
| 274 | | LLVM (AMDGPU backend; oracle only) | Apache-2.0 WITH LLVM-exception | llvm/llvm-project `llvm/LICENSE.TXT` | |
| 275 | | SPIR-V headers | MIT-style Khronos | KhronosGroup/SPIRV-Headers `LICENSE` | |
| 276 | | Vulkan headers | Apache-2.0 or MIT per file | KhronosGroup/Vulkan-Headers `LICENSE.md` | |
| 277 | | MoltenVK | Apache-2.0 | GitHub licence field | |
| 278 | | AMD ISA reference guides | AMD document terms, not yet read | **open: the IP-lawyer review Drake requires covers this** | |
| 279 | |
| 280 | **Hardware I can reach (probed read-only 2026-10-27T01:44Z):** |
| 281 | |
| 282 | | Machine | GPU | Use | Status | |
| 283 | |---|---|---|---| |
| 284 | | DGX Spark | GB10 (sm_121) | GB10 backend, the head-to-head | reachable; GPU per lock rules | |
| 285 | | macbook | Apple M2, 10 GPU cores, Metal 4 (Darwin 25.6.0) | Metal backend; MoltenVK | reachable over SSH | |
| 286 | | hub | Raspberry Pi 5, V3D, `/dev/dri/renderD128` | Vulkan on real hardware via Mesa v3dv | reachable; no Vulkan ICD installed | |
| 287 | | iMac | AMD Polaris 10 (1002:67df rev c5, gfx803) | AMD driver-client bring-up only (pre-CDNA ISA; ROCm support for gfx803 ended [INFERENCE]) | offline at probe (SSH timeout, ping 100% loss); boots the aienux firmware-hosted UEFI app, which keeps the name Allen (its Omega port is draft aienux#495), not a host OS with an AMD driver | |
| 288 | | GitHub `ubuntu-24.04-arm` | lavapipe, CPU | Vulkan and CPU-reference CI | available | |
| 289 | | Rented MI300X | gfx942, 192 GB HBM3, discrete | AMD backend qualification | not rented; Drake's gate | |
| 290 | |
| 291 | No Strix Halo, MI300A or Snapdragon machine is reachable. Their rows in Decision 4 stay PROPOSED. |
| 292 | |
| 293 | **MI300X cost.** PLAN.md budgets MODELED $18.51 through the renting lane. Public third-party listings |
| 294 | on 2026-10-26 (not re-verified, not a quote) ranged $2.39–$4.42 per GPU-hour. WolframLanguageEvaluator: |
| 295 | `{18.51/4.42, 18.51/2.39}` → `{4.19, 7.74}` hours. AMD Developer Cloud offers one |
| 296 | MI300X with $100 credit for 30 days through the AMD AI Developer Program form, at AMD's discretion; a |
| 297 | powered-off VM is still billed (FreeCompute survey 2026-10-26). Every hour of a rental is planned in |
| 298 | advance: host-side encoder and HSACO work is finished on lavapipe/CPU and the iMac first. |
| 299 | |
| 300 | ### 6. Integration: plug into the ecosystem (P4) |
| 301 | |
| 302 | Per ARCH-0042 Decision 3 these are omega-bridge attachments in connected repos, each pinning CUDApp and |
| 303 | omega-bridge by sha. Each calls compiled Omega through omega-bridge native bindings (BRIDGE-1: C, C++, |
| 304 | Python, Rust, Zig and Go callers on Linux AArch64). Effort is in lane-weeks, [INFERENCE]. |
| 305 | |
| 306 | | Target | Interface (checked 2026-10-27) | Maps to | Effort | |
| 307 | |---|---|---|---| |
| 308 | | **ggml / llama.cpp** (aien-dev/ggml-omega, draft #1, CPU backend today) | `ggml-backend-impl.h` at the pinned llama.cpp `7aca0d2e`, `GGML_BACKEND_API_VERSION 3`: `ggml_backend_reg_i` (`get_device_count`, `get_device`, `get_proc_address`), `ggml_backend_device_i` (`get_memory`, `get_props`, `init_backend`, `get_buffer_type`, `buffer_from_host_ptr`, `supports_op`, `offload_op`, `event_new`), `ggml_backend_i` (`set_tensor_async`, `graph_compute`, `graph_plan_*`, `event_record`, `event_wait`), buffer and buffer-type tables; loaded with `GGML_BACKEND_PATH` | `buffer_from_host_ptr` → `ob_mem_import_host` (zero-copy GGUF); `graph_compute` → one `ob_graph_launch` per token; `supports_op` from IR v7 coverage | 2–3 weeks to a GPU backend passing `test-backend-ops` for the ops it claims; first and cheapest, gives like-for-like llama-bench | |
| 309 | | **vLLM** | out-of-tree platform plugin: entry-point group `vllm.platform_plugins` returning the qualified name of a `vllm.platforms` `Platform` subclass (checked in `vllm/plugins/__init__.py` and `vllm/platforms/__init__.py` on main); `vllm.general_plugins` for custom ops | worker, attention backend, paged KV on the memory planner | 6–10 weeks; the hard part is that vLLM's tensors are PyTorch tensors, so it needs a PyTorch device for Omega memory or a host-tensor bridge. Starts after ggml | |
| 310 | | **ONNX Runtime** | plugin execution-provider library (`RegisterExecutionProviderLibrary`; the library exports `CreateEpFactories` / `ReleaseEpFactory`; `OrtEpFactory` `GetSupportedDevices` / `CreateEp`; `OrtEp` `GetCapability` / `Compile`; `onnxruntime_ep_c_api.h` on main, `ORT_API_VERSION 32`) | `GetCapability` claims the subgraphs IR v7 covers; `Compile` lowers them to a graph | 3–5 weeks; out of tree, no ORT fork | |
| 311 | |
| 312 | ### 7. Human review |
| 313 | |
| 314 | - CUDApp gets a proposed `CODEOWNERS` (inactive until reviewers exist) and `REVIEWING.md` (draft PR). |
| 315 | Core paths: the backend ABI header, every `backend/*/` encoder and driver client, the code-object |
| 316 | writers, the runtime API manifest, and `THIRD_PARTY.md`. checker2 and the IR lowering live in |
| 317 | omega-mv (Decision 1), so CUDApp's CODEOWNERS cannot cover them; they are reviewed on omega-mv PRs. |
| 318 | - Merge rule: everything keeps PLAN.md's agent rule (CI green, gates re-run from a fresh clone on the |
| 319 | exact head, receipts posted, a non-author approval, `--match-head-commit`, no self-merge). **Once |
| 320 | human reviewers exist, a PR touching a core path also needs one approving human review.** |
| 321 | Enforcement is a GitHub ruleset change, which is Drake's decision. |
| 322 | - Drake requires one IP-lawyer review and at least two experienced GPU or compiler engineers. He |
| 323 | chooses the people. Invitation drafts are prepared for him, unsent, in |
| 324 | `~/handoffs/SplitDesign/INVITATIONS.md`; no one is contacted by agents. |
| 325 | |
| 326 | ## Consequences |
| 327 | |
| 328 | - In the `.om` stack two backend tables become one, and raw method words and the two bypasses have no |
| 329 | place in it. The C stack is frozen, not reworked, and is retired kernel by kernel once the `.om` |
| 330 | stack matches it on chip with identical golden tokens. |
| 331 | - The GB10 C backend stays as migration; new backends and the new top are `.om`. Three Omega extension |
| 332 | proposals are prerequisites: (E1) the KFD `devctl` allowlist; (E2) checked shared-library calls |
| 333 | (Vulkan loader, Metal) and Mach-O output for macOS; (E3) IR v7, filed as aien-dev/omega-mv#883. |
| 334 | - Encoding provenance becomes a backend gate. CUDApp `docs/HOW_I_DID_IT.md:35-39` says "Where nvcc and |
| 335 | NAK disagree for sm_121, I follow what nvcc emits"; PLAN.md requires encodings re-derived from NAK |
| 336 | plus chip tests, never from nvcc. The GB10 backend's encoder carries an inventory of every field with |
| 337 | its NAK citation or chip test before it is declared the backend. Nothing derived from omega-mv #864 |
| 338 | enters any backend while it is on HOLD. |
| 339 | - Nothing here is implementation or qualification evidence. Every row above is PROPOSED. |
| 340 | |
| 341 | ## Source |
| 342 | |
| 343 | - PLAN.md phases P2–P4 and Rules; the 2026-10-27 outside review. |
| 344 | - `~/handoffs/SplitDesign/filemap.md` (CUDApp `780a0af1`, file:line evidence). |
| 345 | - `~/handoffs/SplitDesign/c1path.md` (omega-mv `omegese/gpu-front` `d1ac019e`, C1 verbatim, IR v6). |
| 346 | - omega-mv main `e5b32567`: `seed/host/MAPPING.md`, `docs/one_layer/OMEGESE.md` §10–11. |