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/omega-mv/blob/main/docs/runtime/PORTABILITY.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / docs / runtime / PORTABILITY.md` 159 lines ยท 17649 bytes Raw Blame History Rendered 1 # Omega portability: what is tied to the chip, what is not 2 3 Slice R3 of the runtime roadmap (omega-mv#596, tracking #593). Written for a developer who has never seen this 4 repository and wants to know how much of Omega they would have to change to run it on another GPU, another operating 5 system, or no operating system. Every claim names the file it comes from. Where a source is missing the claim is marked 6 UNVERIFIED. Nothing here was run on a GPU; this slice is read-only analysis plus a host-side check. 7 8 Companion documents, not repeated here: `docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md` (which driver call each part makes 9 today and which cut removes it) and `docs/numeric/OMEGA_GPU_ENGINE.md` (the engine contract). 10 11 ## 1. Two separate questions 12 13 Porting Omega means answering two questions that are easy to mix up: 14 15 1. **Chip.** Does this file know something about the GB10 (Grace Blackwell, compute capability sm_121)? Machine-code 16 words, launch-descriptor fields, class numbers, cache behaviour. 17 2. **Operating system and driver.** Does this file need Linux, the NVIDIA open driver, or a C library? 18 19 The table `docs/runtime/portability_table.tsv` answers both, one row per `src/omega_gpu_*`, `src/omega_blackwell_*` and 20 `src/omega_bw_*` file (132 rows): 21 22 | Column | Values | Meaning | 23 |---|---|---| 24 | `class` | `CHIP_SPECIFIC`, `PORTABLE` | `CHIP_SPECIFIC`: the file carries knowledge of the GB10 or of the driver interface that exposes it, so a different GPU or driver means reviewing or replacing it. `PORTABLE`: it carries neither. | 25 | `reason` | text | Why, with the evidence (an include list, a constant, a make target). | 26 | `os_binding` | `FREESTANDING_PROVEN`, `NO_HOSTED_INCLUDE`, `HOSTED_LIBC`, `LINUX_DRIVER` | `FREESTANDING_PROVEN`: a `.c` file in `GPU_FS_SRCS` (`mk/omega-gpu-engine.mk`), built by `make gpu-engine-freestanding` with no hosted headers. `NO_HOSTED_INCLUDE`: no hosted header by include scan only (a header, or a `.c` outside that build). `HOSTED_LIBC`: includes stdio, stdlib, time, errno, math or pthread. `LINUX_DRIVER`: includes `nvrm.h`, `m16_native.h` or `omega_gpu_platform_linux.h`. | 27 28 Totals over the source tree based on omega-mv main `62d1d0d6` (the 102 rows reviewed on `a8ffd2b9` plus 21 rows for the 29 files that landed on main after it), plus 5 rows added when the trains joined this table with later work 30 (`src/omega_bw_hazard.{c,h}`, omega-mv#554, landed by train r1 #971; `src/omega_gpu_fp8_slots.{c,h}` and 31 `src/omega_gpu_fp8_internal.h`, #961, in train r2), plus 4 rows for the trainer's bf16 GEMM 32 (`src/omega_blackwell_codegen_tgemm.{c,h}` and `src/omega_gpu_tgemm_api.{c,h}`, landed by train r5 #996 without rows, 33 omega-mv#596): 122 files are `CHIP_SPECIFIC` and 10 are `PORTABLE`. By `os_binding`: 13 `FREESTANDING_PROVEN`, 99 34 `NO_HOSTED_INCLUDE`, 17 `HOSTED_LIBC`, 3 `LINUX_DRIVER`. The small `PORTABLE` 35 count is the honest result: almost everything in `src/omega_gpu_*` launches a Blackwell kernel. Command to recount: 36 section 7. 37 38 `make test-runtime-portability` (host only, no compiler, no GPU) checks the table against the tree: every file has a row, 39 every row names a real file, a `PORTABLE` row's file includes no Linux or NVRM header and no Blackwell header, and the 40 `os_binding` column agrees with the includes and with the freestanding file list. It proves rows and includes agree. It 41 does not prove a reason is right; the reasons are human claims and each cites what to check. The include scan reads 42 direct `#include` lines only, and skips lines inside `#ifndef OMEGA_GPU_NO_POSIX` (the hosted-only branch) and 43 `#ifdef OMEGA_ATTN_DEBUG` (a debug trace). 44 45 ## 2. What is tied to the chip 46 47 | Piece | Where | What is chip-specific about it | 48 |---|---|---| 49 | Machine-code encoder | `src/omega_blackwell_encoder.c`, `.h` | Packs instructions into 16-byte words (`OMEGA_BW_INSTRUCTION_BYTES`). A different instruction set needs a new encoder. | 50 | Kernel generators | `src/omega_blackwell_codegen*.c`, `src/omega_bw_*.h` | Every kernel (vector add, matmul, FP8 GEMV, attention, router, tensor-core GEMM, ternary GEMV) is generated as sm_121 instructions with scheduling rules proven on the chip (`src/omega_bw_em.h`). Some ops are patched in after encoding because the shared encoder lacks them (`src/omega_blackwell_codegen_qmma.h`, values from an nvcc sm_121 oracle). | 51 | Launch descriptor (QMD) | `src/omega_blackwell_qmd.h`, `.c` | A 96-word, 384-byte structure the GPU reads to start a kernel (`OMEGA_BW_QMD_BYTES`). Each field has an evidence tier: documented in NVIDIA's `clcdc0qmd.h`, observed on silicon, or reverse engineered. | 52 | Class numbers and setup words | `src/omega_gpu_session.c` (`SETUP_WORDS`), `src/omega_gpu_cmdlist.c`, `src/omega_blackwell_engine.c`, `src/omega_blackwell_submit.c` and seven more files | The pushbuffer words that select compute class `0xcec0` (Blackwell compute B) and set up the engine. The same 18-word block is copied into 11 files under `src/` (`grep -l 0x0000cec0 src/*.c src/runtime/*.c`). Method numbers such as `WAIT_FOR_IDLE 0x0110` and `SEND_PCAS_A 0x02b4` are in `src/omega_gpu_cmdlist.c`. The channel and user-mode classes (`clc96f.h`, `clc661.h`) are used by `physics/nvrm/nvrm.c`, outside this repository. | 53 | Cache rules | `src/omega_gpu_platform.c` (check at the cache-policy refusal), `src/omega_gpu_mem_cached.h`, `src/omega_gpu_cmdlist.h`, `src/omega_gpu_prefill.h` | Anything the CPU polls for a GPU write must be GPU-uncached, because GPU-cacheable system memory "will not be coherent with direct CPU mappings" (nvidia-open 580.173.02 `nvos.h`, quoted in `src/omega_gpu_platform.h`). Read-only weights may be GPU-cached only if the CPU wrote them once and never reads them. A command list ends with an L2 flush and a second marker on an uncached page. A chip with coherent memory could relax these rules. | 54 | Code buffer tail | `src/omega_gpu_code_alloc.h` | Code buffers stay mapped for 2 KB after the last instruction (`OMEGA_GPU_CODE_PREFETCH_TAIL`) because the instruction cache prefetches past it. The rule comes from Mesa NVK; that it was the cause of the GB10 fault in omega#323 is INFERRED until the chip confirms, per the header. | 55 | Target facts | `src/omega_bw_target.h` on branch `rig/gb20x` | Compute class, QMD version, shared-memory configuration, SM count and cache sizes in one table row per chip. Only the GB10 row is chip-proven. | 56 57 **A finding that corrects a simple reading of the architecture.** The session (`src/omega_gpu_session.c`), the command 58 list, and the matmul and attention APIs are free of the operating system: the first, the matmul and the attention API are 59 in the freestanding build. They are not free of the chip. They embed `SETUP_WORDS`, method numbers, QMD use and sm_121 60 stall counts. The platform contract hides the *driver*; it does not hide the *GPU*. The table marks those files 61 `CHIP_SPECIFIC` with `os_binding` `FREESTANDING_PROVEN` for that reason. 62 63 ## 3. What is portable 64 65 | Piece | Where | Why it is portable | 66 |---|---|---| 67 | Platform validation implementation | `src/omega_gpu_platform.c` | Reusable capability negotiation and handle-table checks, included in `make gpu-engine-freestanding`. This does not make the header contract chip-neutral: `omega_gpu_platform.h` specifies NVIDIA cache policy and GPFIFO queue semantics and is classified separately as `CHIP_SPECIFIC`. | 68 | Engine state machine | `src/omega_gpu_engine.c`, `.h` | Open, validate, submit, verify, close, with a named failing step. Talks to a backend through a function table (`OmegaGpuBackend`). No chip knowledge. | 69 | Bounded wait | `src/omega_gpu_wait.c` | Clock and hooks come from the caller; the freestanding build has no default clock. | 70 | Text and host math | `src/omega_gpu_fmt.c`, `src/omega_gpu_hostmath.c` | A bounded formatter and libm-free log, exp, pow. | 71 | Scan host reference | `src/omega_gpu_scan_ref.c` | The frozen reduction and prefix-sum order depends only on n and the element index (`docs/numeric/E1_REDUCTION_CONTRACT.md`); plain C additions on the CPU. Its header `omega_gpu_scan.h` is `CHIP_SPECIFIC` and pulls in `omega_blackwell_codegen.h`, so reuse elsewhere needs the reference declarations split out. | 72 73 Plain C signatures are not evidence of a chip-neutral contract. The matmul header exposes Blackwell tile macros (16/8/16), the MoE header defines tile-major packing and column alignment, and the session header exposes QMD fields/defaults and the two-marker/L2-flush launch protocol. All three are `CHIP_SPECIFIC`. The platform header also requires review for another chip because its queue contract names GPFIFO and its host-polled rights require the NVIDIA GPU-uncached visibility rule. The serving header describes the GB10 reservation/cache contract; `omega_gpu_serving.c` calls those matmul/attention reservation APIs rather than implementing generic allocation accounting. Both serving files are therefore `CHIP_SPECIFIC`, even though the implementation builds without hosted headers. 74 75 A hardware name in an example or historical comment alone is not a machine dependency. The classifications above are based on exposed layout, tile, visibility, queue or backend-call semantics. The remaining portable engine/math/formatter/wait helpers do not prove that their consumer or a complete backend supports another GPU. 76 77 What the freestanding build proves, and what it does not, is in `docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md` section 1 and 78 section 4: the listed files link with only `memcpy`, `memmove`, `memset`, `memcmp`, `strlen` and `strcmp` undefined, and 79 nothing there opens a device. The table adds the other direction: which files are outside that build and why. 80 81 Open regression at `62d1d0d6`: `make gpu-engine-freestanding` compiles every listed file with `-ffreestanding` but the 82 closure link fails with `freestanding GPU link still needs: abort mmap mprotect munmap pthread_key_create pthread_once 83 pthread_setspecific`. All seven come from `src/omega_om_units.c`, the omega-bridge binding that replaced `src/sha256.c` 84 in `GPU_FS_SRCS` at the OM-2 cutover (``450bbefd``, #747): it runs Omega code on its own `mmap`ed stack with a 85 `pthread` key and calls `abort`. The encoder, codegen, matmul, realize and attention objects need `sha256_*` from it. 86 Until the binding has a freestanding form (a caller-supplied stack, no `abort`; repair in progress on branch 87 `w3/gpu-fs-freestanding-units`, not merged), `FREESTANDING_PROVEN` means "in `GPU_FS_SRCS` and compiled freestanding per 88 file", not "the closure links". 89 90 ## 4. Three ways to reach the GPU 91 92 | | Linux open driver | WSL2 under Windows (`/dev/dxg`) | Native Aienux | 93 |---|---|---|---| 94 | Status | Runs on the DGX Spark (GB10). The only backend with chip evidence. | Host-tested only. Nothing has touched a real `/dev/dxg` or an RTX 5070 (`docs/rig/dxg-backend.md` on `rig/gb20x`, section 5, status line). | Not built. The boot image that looks for the GPU has not been booted on hardware (aienos `docs/GB10_NATIVE_STATUS.md`). NOT_RUN. | 95 | How it talks | `/dev/nvidiactl`, `/dev/nvidia0`, `/dev/nvidia-uvm` through `physics/nvrm` and `physics/m16`. Omega rings the GPU itself through a channel it owns. | D3DKMT ioctls on `/dev/dxg` (Microsoft's `dxgkrnl`), which forwards to the Windows NVIDIA driver. No doorbell ioctl exists; each submit is an ioctl (`docs/WINDOWS-GPU-PATH.md` section 1, aien-rig branch `app/v0`). | Aienux drives PCI, SMMU, firmware load, queues and doorbells itself. | 96 | Platform contract | `src/omega_gpu_platform_linux.c` implements it (reference only, hosted only). The vector executor `src/omega_blackwell_submit.c` and engine backend `src/omega_blackwell_engine.c` still call `m16_native_*` directly. | **Does not use it.** The branch defines its own interface, `OmegaSubmitOps` in `src/omega_gpu_submit_iface.h`, with an nvrm and a dxg implementation. No `OmegaGpuBackend` sits on it yet (`dxg-backend.md` section 5). | Designed around it: the contract's native owners per driver responsibility are listed in the boundary doc section 2. No native implementation exists (boundary doc section 6, "C, remaining"). | 97 | Biggest open question | none for the GB10 | NVIDIA's private driver data blobs and whether the Windows driver accepts Omega's own Blackwell method stream at all (`dxg-backend.md` section 4: "the largest open question"). `docs/WINDOWS-GPU-PATH.md` section 3 found no public project doing raw NVIDIA submission over `/dev/dxg`. | Everything the Linux driver does today: GSP firmware, memory, page tables, queues, interrupts, reset (boundary doc section 2, all rows NOT_RUN). | 98 | Chip code reused | all | The same encoder and QMD; the target table lists the RTX 5070 as sm_120, "THEORETICAL: built from public sources only, never run on the chip" (`src/omega_bw_target.h` on `rig/gb20x`). | The encoder and QMD builder are plain C with no Linux dependency (aienos `docs/GB10_NATIVE_DEPENDENCY_MAP.md`, plain-English summary, item 1); the freestanding build checks that for the files in `GPU_FS_SRCS`. | 99 100 Two caveats a reader should keep: 101 102 - The aienos dependency map is pinned to an older Omega commit (``2ae8677c``, its "Pins" table). Where it disagrees with the 103 boundary doc, which tracks `omega_gpu_session.c` moving onto the platform contract, the boundary doc is newer. 104 - The `rig/gb20x` interface and the platform contract describe the same job (open a device, allocate, queue, submit, 105 wait) with different shapes. The branch's own text does not mention the platform contract 106 (`grep -i platform docs/rig/dxg-backend.md` finds nothing). Whether the two should be merged is a design question for 107 the lane that owns that branch (ledger L024); this note does not decide it and did not edit the branch. 108 109 ## 5. What a new GPU needs 110 111 For a GPU in the same family (another Blackwell part such as the RTX 5070, sm_120), the work is mostly *measuring*. For a 112 different family it is *rewriting*. In order: 113 114 1. **Identify the chip.** Add a target row: PCI ids, architecture and implementation ids, SM version as the driver 115 reports it, compute and channel and user-mode class numbers, QMD version and shared-memory fields, SM count, L2 size, 116 memory model (unified like GB10 or discrete VRAM), host barrier. The shape of this row is `OmegaBwTarget` in 117 `src/omega_bw_target.h` on `rig/gb20x`; each field there carries an evidence grade, and fields nobody has published are 118 `UNKNOWN` until measured on the card. 119 2. **Machine code.** Same family: check whether `src/omega_blackwell_encoder.c` output is valid on the new chip. For 120 sm_120 versus sm_121 the branch records "no sm_120 vs sm_121 encoding split is public" (`omega_bw_target.c`, field 121 `isa`, evidence INFERRED). Different family: a new encoder, new generators for every `omega_blackwell_codegen_*.c` kernel 122 you need, and new emitter helpers (the whole `CHIP_SPECIFIC` block of the table). 123 3. **Launch descriptor.** Confirm or replace the QMD builder (`src/omega_blackwell_qmd.c`) and the constant-bank layout. 124 4. **Class numbers and setup words.** Replace the `0xcec0` setup block. It lives in 11 files; today a change means 11 125 edits (`grep -l 0x0000cec0 src/*.c src/runtime/*.c`). Folding the copies into one is a cleanup this slice records but 126 does not make. 127 5. **Cache and coherence rules.** Decide for the new memory model which buffers may be GPU-cached, which must be 128 uncached, and what flush ends a command list. The contract refuses a cached host-polled buffer 129 (`OMEGA_GPU_PLAT_REFUSED_CACHE_POLICY`); a chip with coherent memory would change that rule in one place 130 (`src/omega_gpu_platform.c`) and in the cache notes of `mem_cached`, `cmdlist`, `prefill`. 131 6. **Code buffer tail.** Check whether the new chip also prefetches past the last instruction (`src/omega_gpu_code_alloc.h`). 132 7. **A platform implementation.** Provide the services in `OMEGA_GPU_SVC_REQUIRED_V1` (time, wait, lock, MMIO, DMA, sync, 133 completion) and `OMEGA_GPU_SVC_REQUIRED_SESSION` (device, queue, clock, host memory), at ABI 1.2, and pass 134 `omega_gpu_platform_check_for`. `tests/test_omega_gpu_platform.c` reaches every refusal; use it as the starting test. 135 The Linux reference (`src/omega_gpu_platform_linux.c`) is the worked example. 136 8. **A backend.** Either the vector backend (`OmegaGpuBackend`, example `src/omega_blackwell_engine.c`) or the session path. 137 9. **Qualification on the chip.** The M17 and M18 gates (`src/omega_blackwell_gates.c`) and the poison-word vector add are 138 the first correctness check; nothing is claimed for a chip until they pass there. 139 10. **Update the table.** `make test-runtime-portability` refuses a new `omega_gpu_*`, `omega_blackwell_*` or `omega_bw_*` 140 file that has no row. 141 142 ## 6. Limits of this note 143 144 - It reads source. No GPU, WSL2 machine or native boot was used; every "works" in the table of section 4 is a claim of the 145 source it cites, and the WSL2 and native columns have no chip evidence at all. 146 - `class` is a judgement per file. The mechanical parts (includes, the freestanding list) are checked; whether a reason is 147 right is not. 148 - The dxg and native documents live on other branches and repositories and can change. They were read from 149 `origin/rig/gb20x` (``12e17891``), aien-rig `origin/app/v0`, and aienos `origin/main` on 2026-10-19. 150 151 ## 7. Reproduce 152 153 ``` 154 make test-runtime-portability # the check plus the negative controls; host only 155 awk -F'\t' '!/^#/ && $1!="file" {n[$2]++} END {for (c in n) print c, n[c]}' docs/runtime/portability_table.tsv 156 ``` 157 158 Evidence of the controls and of the freestanding build on `a8ffd2b9` is in `evidence/RUNTIME-R3-PORT/`; the rerun on 159 `62d1d0d6` is in `evidence/RUNTIME-R3-PORT-`62d1d0d6`/`.