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/CUDApp/blob/main/README.md # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. 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 `CUDApp / README.md` 528 lines · 59812 bytes Raw Blame History Rendered 1

2 CUDA++ for the NVIDIA DGX Spark (GB10, sm_121): my own path from a program to the GPU. On the right, the 32 instructions of the first kernel CUDA++ ran, drawn bit by bit from src/omega_blackwell_encoder.c. 3

4 5 # CUDA++ for the NVIDIA DGX Spark 6 7 [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.`23578452`.svg)](https://doi.org/10.5281/zenodo.`23578452`) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.`23614483`.svg)](https://doi.org/10.5281/zenodo.`23614483`) 8 9 **CUDA++ for the NVIDIA DGX Spark (GB10, sm_121). It is the GPU half of the Omega runtime. First-party CUDA++ material in this revision is licensed under Apache-2.0 WITH LLVM-exception.** You write a GPU program, CUDA++ turns it into the GB10's own machine code and runs it on the Spark's GPU with no CUDA user-space software at build or run time: no CUDA toolkit, no `nvcc`, no PTX, no `libcuda`, no cuBLAS. NVIDIA's compiler and disassembler were used offline as references while the encoding was worked out ([how I did it](#how-i-did-it)). NVIDIA's open kernel module (580.173.02) and the GPU's signed GSP firmware are still in the path. It's a research-stage toolchain and runtime, not a drop-in replacement for all of CUDA. 10 11 > **Who this is for, and what hardware** 12 > 13 > | | | 14 > |---|---| 15 > | **Supported** | The NVIDIA DGX Spark. Its GB10 Grace Blackwell chip (GPU compute capability sm_121, PCI id `10de:2e12`) remains the only device with execution receipts. | 16 > | **Other GB10 systems** | Not run. CUDA++ recognises the GPU by its PCI id, not by the system maker, so another GB10 system with the same kernel module is the same target to the code. Nobody has run CUDA++ on one. | 17 > | **Ampere preparation** | RTX 3090 (GA102) and RTX 3060 Ti (GA104), sm_86: target-specific encoder/cubin, discrete-memory and x86 host preparation are in this tree. Both devices are **NOT_RUN**, not supported/qualified hardware yet. See the [port audit](docs/PORT-AMPERE.md) and [device test plan](tests/ampere/README.md). | 18 > | **You need** | Linux on the Spark's ARM CPU (aarch64). NVIDIA's open kernel module, version 580.173.02: `make doctor` and `make hello-gpu` refuse another version, and `/dev/nvidiactl`, `/dev/nvidia0` and `/dev/nvidia-uvm` must exist. NVIDIA's signed GSP firmware, which that module loads into the GPU. `git`, `make` and a C compiler. No CUDA toolkit. | 19 > | **Not supported** | Other NVIDIA GPUs are not qualified. The prepared sm_86 path above has no device receipt. A target row for RTX 5070 (sm_120) exists on Omega's `rig/gb20x` branch and has not run on that chip ([portability](docs/runtime/PORTABILITY.md)). Other vendors remain PLANNED. The multi-backend split is [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). Unmodified CUDA applications are not supported: CUDA++ does not compile CUDA C++ or PTX. | 20 21 > **Licensing status:** This revision uses Apache-2.0 WITH LLVM-exception for first-party material. For the historical MIT version, use [``232332422bfdc31c8918085b50f13c1e18ab702e``](https://github.com/aien-dev/CUDApp/tree/`232332422bfdc31c8918085b50f13c1e18ab702e`). The old MIT grant and third-party notices are preserved. See [the transition and provenance audit](docs/LICENSING_TRANSITION.md). 22 23 It runs on the NVIDIA GB10 (the DGX Spark, compute capability sm_121) today. On 2026-10-21 the model Aien serves on the Spark, Qwen3.6-35B-A3B (a mixture-of-experts model with about 3B parameters active per token), was served by the C GPU stack this repository was extracted from (the live build used the Omega repository's copy of these sources). The live server had only the C library, the maths library, `libgcc_s` and the loader mapped, and zero CUDA libraries (receipt in Omega: `evidence/WHAT-OMEGA-IS-`20261021`/live-serve-no-cuda.txt`). That stack is mostly C. Two pieces of it now run as code written in the Omega language: the sm_121 instruction encoder (`om/encoder/bw_enc_sm121.om`) and the cubin packer (`om/cubin/cubin_elf.om`), compiled by the pinned Omega compiler and linked through an omega-bridge binding. Their C bodies are out of the default build and kept only as differential oracles; the .om encoder is byte-identical to the C one on every kernel the test suite builds ([evidence](evidence/CUDAPP-OM-ENCODER/README.md), migration table in CUDApp#79). The rest (kernel builders, register allocation, runtime) is still C. Omega programs compiled to the GPU by the Omega compiler itself is Omega bar C1. As of 2026-10-29 it is EXERCISED on the GB10 but in draft PRs only, not merged: kernels written in Omegese ran on the chip with 645 checks and 0 failed ([omega-mv#885](https://github.com/aien-dev/omega-mv/pull/885)), with their lowering also written in seeded `.om`, and the 35B decode gate swapped for its Omegese version gave the golden tokens on a test server ([omega-mv#886](https://github.com/aien-dev/omega-mv/pull/886)). Both pull requests were still open drafts on 2026-10-29. They use omega-mv's own copy of the sm_121 encoder, not a pinned CUDA++. 24 25 CUDA++ keeps growing to cover the jobs of NVIDIA's user-space software on the Spark, and then do things CUDA does not: 26 27 - my own GB10 kernel driver replaces NVIDIA's open kernel modules `nvidia.ko` and `nvidia-uvm.ko`. It is being built in three repositories, and none of them has run on the GB10 yet: aien-dev/aien-gpu (Omega units inside a Linux module; host and QEMU tests pass), aien-dev/omega-gpu-driver (seeded Omega over `vfio-pci`; step W0 exercised in QEMU only) and aienux#441 (ledger L332: the C reference driver and the GB10 simulator that aien-gpu's boot steps are checked against). Until one passes on the chip, CUDA++ runs on `nvidia.ko` 580.173.02. GB10 facts measured on the way (chip id, boot sequence) still go upstream to the Linux drivers Nova and nouveau as findings; 28 - my own disassembler replaces `nvdisasm`; 29 - the GSP firmware stays NVIDIA's too, for a physical reason: the GPU checks its signature and boots nothing else; 30 - beyond CUDA: owning the whole path from program to chip, so one submission per generated word, whole-model kernels that stay resident on the GPU, and zero-copy use of the memory the CPU and GPU share. 31 32 CUDA++ is not affiliated with or endorsed by NVIDIA; CUDA is NVIDIA's trademark. 33 34 **New to CUDA++?** Start with the [first-run and independent verification guide](docs/START_HERE.md). It separates host-only tests from real GB10 execution, documents the current support boundary, and explains how to interpret receipts. See [contributing](CONTRIBUTING.md), [security reporting](SECURITY.md), and [the readiness roadmap](ROADMAP.md) before relying on it in a deployment. 35 36 **On this page:** [the stack](#the-stack) · [how I did it](#how-i-did-it) · [the machine code](#what-the-machine-code-looks-like) · [the driver, part by part](#the-driver-part-by-part) · [one launch, start to finish](#one-launch-start-to-finish) · [CUDA, piece by piece](#cuda-piece-by-piece) · [speed](#speed-against-the-ceiling) · [run your first kernel](#run-your-first-kernel) 37 38 ## TileLab driver checks and replay 39 40 `make test-tilelab-host TILELAB_OMC=/path/to/pinned/omc` runs the driver's 41 host-only refusals and oracle checks, then the bounded Omega conductor in 42 `tests/tilelab_host_fault.om`. The compiler must match `tools/c5/omc.pin`. 43 The separately compiled `gpu_tilelab_host_fault` replaces every GEMM and 44 configuration entry with nondelegating CPU fault injection; it does not call 45 GPU or session entry points. Its receipts say `execution: synthetic-host`. 46 These results are host control-flow evidence, never chip qualification. 47 48 The conductor checks the full shape-list capacity, escaped JSON identifiers, 49 failed warmup and timed calls, runtime-failed mutants, successfully executed 50 wrong-result mutants, correct-result negative controls, and buffered receipt 51 failure on `/dev/full`. A runtime error cannot count as a caught mutant. 52 Receipt write or close failure returns nonzero before a final PASS. 53 Arm names must be valid UTF-8. JSON preserves multibyte identifiers exactly, 54 escapes quotes, backslashes and control characters, and refuses malformed 55 UTF-8 before any execution or receipt creation. 56 57 Build the current replay with `make tilelab-replay TILELAB_OMC=/path/to/pinned/omc`. 58 Its interface is: 59 60 ```text 61 build/tilelab_replay DRIVER OUTPUT_PREFIX "M,N,K;..." ROUNDS [NAME:RT,CT,WM,WN,BAND ...] 62 ``` 63 64 It invokes the driver directly, without a shell, and groups at most fifteen 65 explicit configurations per invocation because the default arm occupies the 66 remaining slot. Outputs are `OUTPUT_PREFIX.0.json`, `.1.json`, and so on. 67 Every child must succeed; nonzero child exits, failed execution, and signals 68 stop replay without printing replay PASS. The host conductor checks failure 69 propagation and a configuration list spanning three invocations. 70 71 Using the real device driver still requires the operator's current GPU-window 72 authorization. Neither building replay nor passing host tests grants it. 73 The scripts and receipts under `evidence/TILELAB-`20261028`/` are immutable 74 historical records, not current executable gates. In particular, the archived 75 sweep scripts can mask child failures and an over-capacity group. Use this 76 current replay for new runs; do not rewrite the historical scripts or receipts. 77 78 ## The stack 79 80

CUDA and CUDA++ layer by layer. The compiler, maths libraries, runtime and driver library of CUDA are closed and CUDA++ has its own code for their jobs. NVIDIA's open kernel module is still in the path and my own GB10 driver is being built to replace it; the signed GSP firmware stays.

81 82 Between a CUDA program and the GPU sit four closed NVIDIA layers: the compiler, the maths libraries, the runtime and the driver library. CUDA++ does their jobs with its own code, at research stage. Under them are NVIDIA's kernel module, whose source NVIDIA publishes, and the firmware inside the GPU. CUDA++ talks to the kernel module directly today. My own GB10 driver replaces that module; it has not run on the GB10 yet. The firmware stays NVIDIA's. 83 84 ## How I did it 85 86

Timeline: 2026-09-26 first native kernel; 2026-10-02 numerics closed on chip; 2026-10-13 ceilings measured; 2026-10-21 a 35B model served with no CUDA library.

87 88 I built it alone on one DGX Spark in under four weeks, directing AI coding agents. NVIDIA publishes the source of its Linux kernel module, but not its compiler, its driver library or the GPU's machine code. So I skipped every closed layer: 89 90 1. **No libcuda.** I wrote my own client for the open kernel module's ioctls, from its MIT headers: client, device, address space, memory, command ring, compute object, doorbell, completion. [The driver, part by part](#the-driver-part-by-part) shows every piece. 91 2. **No nvcc, no PTX.** The GPU's machine code is undocumented, so I reverse engineered it: compiled small probe kernels of my own once with NVIDIA's compiler, read the machine code back with NVIDIA's disassembler, compared kernels that differ in one detail to find which bits mean what, cross-checked against Mesa's open NVIDIA compiler, and believed nothing until the chip ran it and gave the right answer. Arithmetic the documents do not pin down (the tensor cores) was measured on the chip until a model matched every output bit. 92 3. **My own encoder, runtime and libraries** on top: 59 instruction kinds, a register allocator, launch descriptors, command lists, matrix multiply, attention. 93 94 I'm not the only one mapping this instruction set in the open, and I credit the others: Mesa's NAK compiler has an SM120 encoder tested against `nvdisasm`; [cubit](https://github.com/kacper-daftcode/cubit) is an MIT assembler and disassembler for SM120 and SM121a; [blackwell-isa](https://github.com/kacper-daftcode/blackwell-isa) publishes an sm121a encoding table; [nvidia-sass-document](https://github.com/cicuvc/nvidia-sass-document) documents SASS encodings; tinygrad's NV backend talks to the same open kernel module interface. Cross-checking CUDA++ against them is PROPOSED. 95 96

The method in eight steps. Learn: my own probe kernel, nvcc once offline, read the bytes back, change one detail. Prove: field hypothesis, my encoder writes it, the GB10 runs it, golden words in the tests. A wrong answer goes back to the hypothesis.

97 98 No NVIDIA binary or NVIDIA-tool listing is stored in the current tree. The former `nvdisasm` test pin of CUDA++'s own trace-emitter words was removed in #93; its history is recorded in `PROVENANCE.md` section 6. The whole method, step by step with the files and receipts: [docs/HOW_I_DID_IT.md](docs/HOW_I_DID_IT.md). 99 100 ### What the machine code looks like 101 102 Every GB10 instruction is 16 bytes. The low bits say what to do and to which registers; the top 23 bits tell the warp scheduler how long to wait before the next instruction and which earlier results to wait for. Here is the add from the first kernel, every bit accounted for: 103 104

IADD3 R9, PT, PT, R2, R5, RZ decoded: opcode 0x210, guard predicate PT, destination R9, sources R2, R5 and RZ, and the scheduling bits: stall 5 cycles, waits on scoreboard SB4.

105 106 Those scheduling bits are what a compiler normally hides. Slow instructions (memory loads, constant loads, special registers) set one of six scoreboards; a later instruction that needs the result waits on it. Here is the whole first kernel with its waits drawn in: 107 108

The 21 real instructions of vector add, with lines joining each instruction that sets a scoreboard to the later instruction that waits on it, and amber bars for fixed stall cycles.

109 110 Getting one of these bits wrong does not fail loudly: the GPU reads a register before the load has landed and returns a wrong number. That is why every encoding has golden words in the tests and a chip run behind it. The figures on this page are drawn from the repository's own data by `tools/figures/make_figures.py`; the two above decode the words in `src/omega_blackwell_encoder.c`. 111 112 ## The driver, part by part 113 114 `libcuda` is closed, but everything it does to the hardware goes through ioctls on three device files, and NVIDIA's open kernel module defines every one of those calls in its public headers. I copied 67 of those headers unchanged (`third_party/nvidia-open-580.173.02/`, MIT) and wrote my own client against them. This is the whole of it: 115 116

The driver client: the three device files, the tree of resource-manager objects it allocates from the root client down to the Blackwell compute object, and the unified-memory calls that bind the address space, each buffer and the channel.

117 118 | Part | Where | What it does | 119 | --- | --- | --- | 120 | Open | `nvrm_open()` in `nvrm/nvrm.c` | Opens `/dev/nvidiactl` and `/dev/nvidia-uvm`, finds the GPU (`NV_ESC_CARD_INFO`), allocates the root client, device and subdevice, reads the class list to pick the Blackwell classes, reads the SM version and GPU UUID, maps the 64 KiB usermode page that holds the doorbell, and creates an address space that the unified-memory driver manages. | 121 | Memory | `nvrm_alloc()`, `nvrm_free()` | One system-memory object per buffer. The GB10 has no separate video memory, so each buffer is mapped at the **same address** for the CPU and the GPU: a pointer means the same thing on both sides and nothing is copied. Anything the CPU polls is allocated GPU-uncached (`nvrm_alloc_gpu_uncached()`). | 122 | Channel | `nvrm_channel()` | Channel group, context share, a command ring of 1,024 entries with its USERD control page, and the Blackwell compute object. Asks for the channel's work-submit token, registers the channel with the unified-memory driver and switches scheduling on. | 123 | Submit | `nvrm_enqueue()`, `nvrm_ring()` | Writes one 8-byte ring entry (pushbuffer address and length), advances `GPPut` with a full memory barrier, then rings the doorbell: a single 32-bit store of the token. No system call is made to launch work. | 124 | Wait | `m16/m16_gpu_wait.c` | The one completion wait: polls a word the GPU writes, with a hard deadline that is never extended and a stall deadline that restarts only on progress. | 125 | Qualification | `m16/m16_requalify.c`, `m16/m16_concurrent.c` | Proofs on the chip. Requalify queues work **without** ringing the doorbell and checks nothing happens for 100 ms, rings it, checks the marker turns to `0x16c0ffee`, and reads `/proc/self/maps` to prove `libcuda` was never loaded. Concurrent runs two channels and checks neither can fire the other. | 126 | Platform contract | `src/omega_gpu_platform.h` | What the runtime may ask of the machine: typed handles instead of file descriptors, explicit rights on every buffer, no silent fallback. The Linux client above is one implementation; AIEN's own driver plugs in at the same seam. | 127 | Session, command lists, engine | `src/omega_gpu_session.c`, `src/omega_gpu_cmdlist.c`, `src/omega_gpu_engine.c` | One device per process, kept open; many launches recorded into one submission; a job runner that returns success or exactly one named failure, and refuses all further GPU work if it cannot tell whether the GPU finished. | 128 129 RM/UVM parameter blocks are filled and decoded by the seeded Omega codecs in 130 `native/nvrm/struct.om`, using the measured 580.173.02 header layouts. 131 `CUDAPP_MIGRATION_PENDING_C_NVRM_STRUCT=1` selects the old C parameter fills for 132 the migration oracle; its default is **0**, the Omega path. Raw ioctl calls 133 remain in C. The shared UVM bodies retain the older fixed-size exports while 134 the struct entry uses exact-size views. See [host evidence and the chip runbook](evidence/NVRM-STRUCT-OM/README.md): 135 byte/layout differential and mutants are host evidence, not live-RM qualification. 136 137 What the headers do not say, I learned on the chip and wrote down as rules, each with a receipt or an issue behind it: 138 139 - **A word the CPU polls must be GPU-uncached.** Otherwise the GPU keeps the new value in its L2 cache and the CPU never sees it change. This stalled the work once, on 2026-10-02; the platform now refuses such a buffer. 140 - **New code needs a shader-cache invalidate before it runs.** The GPU's instruction cache does not see CPU writes; after a code address was reused, the chip ran the old instructions. Every launch that uploads code now starts with `INVALIDATE_SHADER_CACHES` (receipt FB1-CUT1B-`4345406` in Omega). 141 - **Dependent launches need a wait-for-idle between them.** Without one, two grids on one channel may overlap. The order of the launch commands follows Mesa's NVK driver. 142 - **Blackwell's control page reports no read pointer.** The client counts completed ring entries itself and never overruns entries that have not been seen to finish. 143 - **Creating the compute object needs one free, physically contiguous 2 MiB block** for its context buffer. On a busy host it is briefly missing, so that one allocation is retried, bounded (omega#523). 144 145 Under the client: NVIDIA's open kernel module (`nvidia.ko`, `nvidia-uvm.ko`) and the GSP firmware inside the GPU. My own GB10 driver replaces the kernel module (aien-dev/aien-gpu, aien-dev/omega-gpu-driver and aienux#441, L332; none has run on the GB10 yet). The client speaks NVIDIA's ioctl interface, so moving it onto my driver is part of the replacement; that move is PROPOSED and not started. The firmware stays NVIDIA's because the chip checks its signature. Every object and call in order, with line references: [docs/DRIVER.md](docs/DRIVER.md). 146 147 ## One launch, start to finish 148 149

The life of one kernel launch: the CPU builds the kernel, writes the launch descriptor, the methods and one ring entry into shared memory, and rings the doorbell; the GPU fetches, launches the grid and writes completion markers that the CPU polls.

150 151 The CPU does five things, all of them plain memory writes except the last, which is a single store to a GPU register. The GPU then does the rest on its own: it fetches the ring entry, reads the commands, reads the launch descriptor (the QMD: grid size, block size, registers, shared memory, code address), runs the grid, and writes two completion markers with a cache flush between them. Results are already in memory the CPU can read. Recording many launches into one submission (`src/omega_gpu_cmdlist.c`) is how a whole generated word goes to the GPU at once. 152 153 ## CUDA, piece by piece 154 155

Every NVIDIA piece on the Spark with its CUDA++ replacement and status.

156 157 | CUDA piece | Its job | CUDA++ replacement | Status | 158 | --- | --- | --- | --- | 159 | CUDA C++ language | How you write a kernel | The kernel builder (C calls). Omega's languages reaching the GPU is Omega bar C1, built on this toolchain | PARTIAL: C calls here; Omegese kernels EXERCISED on the GB10 in omega-mv draft #885/#886 (not merged) | 160 | nvcc, NVVM, PTX, ptxas | Compile the kernel to machine code | My own sm_121 encoder and register allocator | PASS: every GPU kernel this stack runs is encoded by it | 161 | libcuda (driver API) | Talk to the kernel driver | `nvrm` client, ioctls straight to the open kernel module | PARTIAL: implemented; M16 historical summary is unauditable here (see below) | 162 | libcudart (runtime API) | Device, memory, launch, streams | Session, command lists, job engine | PARTIAL: one device, one process; no streams or events yet; a timeout ends GPU use for the process | 163 | cuBLAS | Matrix multiply | Matmul, tensor-core GEMM, FP8 and BF16 libraries, and the general `omega_gpu_gemm_ex` (any M, N, K, op N/T, leading dimensions, alpha/beta, strided batches, f32/bf16/f16/e4m3/e5m2 inputs, fp8 scales) | PARTIAL: the fast kernels are shaped for the models AIEN runs. `gemm_ex` takes any shape (902 chip checks on the merged kernels, `evidence/GEMM-GENERAL-`00c9cf9`/`; the earlier 901 checks of `evidence/GEMM-GENERAL-`fba0384`/` predate the main merge) but runs from host memory with the k sum on the host, so it is not a serving path; f32 is bf16x3, not IEEE fp32; no fp8 output (`docs/runtime/API.md` 9.8) | 164 | cuDNN, FlashAttention | Attention and network layers | Decode and prefill attention | PARTIAL: the fused fast paths are model-shaped; since runtime API 0.6.0 a general fallback (`omega_gpu_attention_general`, EXPERIMENTAL) takes head_dim 1..256, any MHA/GQA/MQA ratio, causal or not, sliding windows and any length, chip-exercised on GB10 (`evidence/ATTN-GENERAL-`20261027`-`4d51f91f`/`). It is a scalar f32 kernel without tensor cores, and has no ALiBi, softcap or dropout | 165 | CUB, Thrust | Reductions, scans, sorts | Frozen-order reductions (`evidence/E1-CLOSURE/`) | PARTIAL: no general scan or sort | 166 | cuFFT, cuRAND | FFT, random numbers | xoshiro256** and Philox4x32-10 random numbers with cuRAND's uniform, uniform_double, uniform2_double and normal distributions; complex, real (R2C/C2R) and 2-D/3-D FFTs and cufftPlanMany layouts for any length 2 to 4096; kernels and pass plans built by the seeded Omega unit `om/mathlibs/mathlibs_ir.om` | PARTIAL: one GB10 run of xoshiro256** and the complex FFT, 4 to 2048 points (`evidence/MATHLIBS-RNG-FFT-2026-10-27/`). 2026-11-06: Philox (cuRAND stream), R2C/C2R 8 to 4096 points and 2-D/3-D transforms pass host and simulator checks only, chip NOT_RUN (`evidence/MATHLIBS-PHILOX-RFFT-ND-2026-11-06/`). 2026-11-06: Philox distributions, non-power-of-two lengths (mixed radix, Bluestein) and cufftPlanMany layouts pass host and simulator checks only, chip NOT_RUN (`evidence/MATHLIBS-GAPS-2026-11-06/`); no `curand_normal_double` yet | 167 | cuobjdump, nvdisasm | Read machine code back | My own sm_121 disassembler | BUILDING: the decoder is the seeded Omega unit `om/disasm/sm121_dis.om`; on 2026-11-05 it agreed with `nvdisasm` on all 3,191 kernels the library builds (host only; nothing run on the chip). The regular host tests use it; `nvdisasm` runs only in named oracle targets | 168 | Nsight | Measure | Ceiling probes: 115.14 TFLOPS tensor-core peak, 195.1 GB/s reads (`evidence/OWN30B-T3-TC-PEAK-BW-`5faa0f70`-20261013T2236Z/`) | PARTIAL: probes, no single tool | 169 | CUDA samples, docs | Your first kernel | `examples/hello_gpu`, `docs/runtime/` | PARTIAL: one example | 170 | `nvidia.ko`, `nvidia-uvm.ko` | Kernel driver | My own GB10 driver: aien-dev/aien-gpu, aien-dev/omega-gpu-driver, aienux#441 (L332) | BUILDING: host, QEMU and simulator results only; nothing has run on the GB10, and the `nvrm` client still speaks NVIDIA's ioctls. Receipts per track in `ROADMAP.md` | 171 | GSP firmware | Runs inside the GPU | stays NVIDIA's (signature-checked by the chip) | not replaceable | 172 173 PASS means a receipt exists on a named commit. Status words come from Omega's `docs/OMEGA.md`, section 2. `ROADMAP.md` lists every NVIDIA piece on the Spark with its receipt, and the bars CUDA++ must pass before it says "replaces CUDA". 174 175 The default mathlibs host path is also seeded Omega: `om/mathlibs/host.om` 176 owns RNG admission and seed arithmetic, FFT admission and launch walking, 177 mixed-radix/Bluestein planning, layout/overlap checks, and poison counting. 178 The six typed entry units are registered in `om/units.sh`; their generated C 179 bindings are checked in. The C file retains session, allocation, clock, table 180 copying and callback effects. The old host computations compile only with the 181 default-OFF `CUDAPP_MIGRATION_PENDING_C_MATHLIBS_HOST` oracle flag. 182 183 Run the focused host differential, red and missing-unit controls, oracle gcov, 184 and eight seeded-source mutants without exposing GPU devices: 185 186 ```sh 187 export OMEGA_OMC=$HOME/work/cudastack/omega-mv/seed/out/omc 188 export OMEGA_BRIDGE=$HOME/work/cudastack/omega-bridge 189 bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make test-mathlibs-host-om 190 bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 test-gpu-mathlibs 191 ``` 192 193 The host migration evidence and separate, unrun chip procedure are in 194 `evidence/mathlibs-host-`20261106`/README.md`. These checks do not qualify GPU 195 execution, change the public API, or replace the historical chip receipts. 196 197 The imported `evidence/m16-blackwell-native-path-requalification-receipt.json` 198 is an **unauditable historical summary**, not qualification of this checkout. 199 It names implementation commit ``a2c0d7fbc03f7ce91fcb6389312a0ee8630322cd``, 200 but its `evidence/m16-requalification` raw logs and superseded receipt are absent 201 from this repository. Its historical PASS and durability fields are preserved 202 unchanged, not endorsed as current evidence. No immutable durable source for those 203 missing logs has been established. Current native qualification is **NOT_RUN**; 204 it needs retained raw logs from a new authorized GPU run, not a host-only check. 205 206 ## Speed against the ceiling 207 208

Roofline of the GB10 from my own probes: 115.14 TFLOPS tensor-core peak and 195.1 GB/s memory reads, meeting at 590 operations per byte.

209 210 Every speed number is held against what this machine can physically do, measured by my own probe kernels. Generating a word of text reads each active weight once and does about one operation per byte, far left of the ridge, so its speed is set by memory, not by the tensor cores. The head-to-head measurement against llama.cpp and vLLM on this Spark is Omega bar P0 (AIEN L394) and has not been published. Until it is, this repository claims no speed comparison with CUDA, llama.cpp, vLLM or TensorRT. Its predeclared protocol is in [aien-dev/gpu-head-to-head](https://github.com/aien-dev/gpu-head-to-head), which pins this repository by commit; the raw logs and results will be published there. Chip-only times (GPU time per token) and end-to-end times (through the HTTP server, prompt included) are different measurements and are always labelled separately; figures other projects publish are theirs, not re-measured here. 211 212 ## What is in here 213 214 | Part | What it does | Where | 215 | --- | --- | --- | 216 | GPU toolchain | Writes sm_121 machine code (SASS) directly: a kernel builder with 59 instruction kinds, a register allocator, the instruction encoder, launch descriptors (QMD) | `src/omega_blackwell_codegen*.c`, `src/omega_blackwell_encoder.c`, `src/omega_blackwell_qmd.c` | 217 | GPU runtime | Opens the device, allocates memory, uploads code, launches kernels, records command lists, runs jobs. The job of CUDA's runtime and driver API | `src/omega_gpu_session.*`, `omega_gpu_cmdlist.*`, `omega_gpu_engine.*`, `omega_gpu_platform*` | 218 | Libraries | Matrix multiply and matrix-vector (BF16, FP8, 4-bit, ternary), attention for decode and prefill, elementwise, mixture-of-experts routing. The job of cuBLAS and cuDNN | `src/omega_gpu_*_api.*` | 219 | Driver client | Talks to NVIDIA's open kernel module through its ioctls; replaces `libcuda` | `nvrm/`, `m16/` | 220 | NVIDIA interface headers | The open kernel module's public interface definitions (MIT, unchanged) | `third_party/nvidia-open-580.173.02/` | 221 | Runtime API | The written, versioned API and its manifest check | `docs/runtime/API.md`, `src/omega_runtime_api.h` | 222 | Figures | Every picture on this page, drawn from the repository's own data | `tools/figures/make_figures.py`, `docs/img/` | 223 224 ## CUDA's pain points, and how CUDA++ fixes them 225 226 I read what developers write about CUDA and its libraries on GitHub, Reddit, NVIDIA's forums, the PyTorch forum, Hacker News and Stack Overflow, and ranked the problems by how many people they hurt (GitHub issue counts times how badly they hurt). The full research, with 97 sources and every quote checked word for word against its page, is `docs/PAIN_POINTS.md`. How CUDA++ itself was built, reverse engineering included, is `docs/HOW_I_DID_IT.md`. 227 228 Each row below gives the pain in a developer's own words, how CUDA++ fixes it, and the command that shows it, with the output it printed on my DGX Spark and the receipt it came from. A row says FIXED only when that command and receipt are on this branch. Where CUDA is still better, `docs/PAIN_POINTS.md` section 4 says so. 229 230 ### 1. Out of memory, and on the DGX Spark a frozen machine (26,390 GitHub issues say "CUDA out of memory") 231 232 **The pain.** "The Spark ships with zero swap. On unified memory a spike goes straight to a global OOM that hard hangs the whole box. No ssh, no ping, needs a power cycle." ([dgx-spark-laguna FINDINGS.md](https://github.com/sudoingX/dgx-spark-laguna/blob/main/FINDINGS.md)) 233 234 **How CUDA++ fixes it.** On the GB10 the CPU and GPU share one memory, and every CUDA++ buffer is part of it. CUDA++ has no caching allocator, so what a process holds is what it asked for. Before any allocation reaches the driver, CUDA++ checks how much memory the machine has free. If the buffer would leave less than a reserve (4 GiB by default, `CUDAPP_MEM_RESERVE_MIB` to change it, 0 to turn it off), the allocation is refused with a sentence instead of freezing the box. 235 236 **The command that shows it** (host test of the runtime on a simulated driver, run on the Spark): 237 238 ``` 239 $ make build/test_omega_gpu_platform_linux && ./build/test_omega_gpu_platform_linux 240 ... 241 refusal: dma_alloc: refused 2.0 MiB: 4.0 GiB of memory is free and CUDA++ keeps 4.0 GiB free (CUDAPP_MEM_RESERVE_MIB=4096), because the CPU and GPU share it and running it out freezes the machine. Free buffers or use a smaller batch. 242 session: dma_alloc: refused 2.0 MiB: 4.0 GiB of memory is free and CUDA++ keeps 4.0 GiB free (CUDAPP_MEM_RESERVE_MIB=4096), because the CPU and GPU share it and running it out freezes the machine. Free buffers or use a smaller batch. 243 PASS D1_MEMORY_RESERVE_REFUSES_BEFORE_THE_DRIVER 244 test_omega_gpu_platform_linux (reference only, simulated driver): 9 passed, 0 failed 245 ``` 246 247 Receipts: `evidence/dx/d1-memory/platform-test-spark.txt`, and `evidence/dx/d1-memory/negative-control.txt` (with the check removed, the test fails). **FIXED in the runtime, shown on the host.** Left: the same refusal on the chip itself, inside a GPU window (`docs/issues/D1-memory.md`). 248 249 ### 2. The version and build matrix (11,034 GitHub issues mention "TORCH_CUDA_ARCH_LIST") 250 251 **The pain.** "I don't know a right solution that works for all setups, happy to hear suggestions." (FlashAttention's maintainer, [flash-attention #246](https://github.com/Dao-AILab/flash-attention/issues/246)) 252 253 **How CUDA++ fixes it.** There is no toolkit version to match: compiler, runtime and libraries are one repository at one commit, built with `make` and a C compiler. The one outside version is NVIDIA's kernel module, whose public headers CUDA++ is built against. `make doctor` checks it and everything else a first run needs. It reads `/proc`, `/sys` and `/dev` only and opens no device. Every problem gets a line saying what is wrong, why and the command that fixes it. **The doctor wrapper** refuses a module of another version; `make hello-gpu` runs that wrapper first. Programs that link the library directly get the library's own GPU admission at device open (runtime API 0.14.0): an unknown or unqualified PCI id is refused with a sentence before any `/dev/nvidia` node opens. The driver-version check is still in the doctor only. The diagnostic is not a sandbox or current-commit qualification; callers must perform the compatibility preflight themselves and have an authorized GPU window. 254 255 **The command that shows it:** 256 257 The following excerpts are historical doctor output; current output explicitly 258 labels the M16 receipt as a historical summary with raw evidence unavailable. 259 260 ``` 261 $ make doctor 262 cudapp doctor: is this machine ready for CUDA++? 263 info system: Linux 7.0.0-1019-nvidia aarch64 264 ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) 265 ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user 266 ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) 267 ok memory: 121.7 GiB shared by the CPU and the GPU, 61.3 GiB available now 268 info CUDA toolkit: not needed and not used by CUDA++ (one is installed at /usr/local/cuda/bin/nvcc; that is fine) 269 info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler 270 READY. Next: make hello-gpu 271 ``` 272 273 On a machine with the wrong module (one of the nine fake machines `CUDAPP_DOCTOR_SHOW=1 sh tests/doctor/run.sh build/cudapp-doctor` builds): 274 275 ``` 276 FAIL NVIDIA kernel module: version 575.64.05 is loaded; CUDA++ speaks the 580.173.02 interface 277 Why: CUDA++ builds its driver calls from the 580.173.02 open-module headers 278 (third_party/nvidia-open-580.173.02). The layout of those calls can change between module versions, 279 and a wrong layout fails in strange ways, so CUDA++ refuses instead of guessing. 280 This is the only version CUDA++ asks you to match: no toolkit, no framework build, no extension build. 281 Do this: install the 580.173.02 open kernel module, or port the client to your version 282 (CONTRIBUTING.md, "Port a driver version": copy the new headers, rebuild, run make test and make hello-gpu). 283 ``` 284 285 Receipts: `evidence/dx/d2-doctor/make-doctor-spark.txt`, `evidence/dx/d2-doctor/fake-machines.txt`, `evidence/dx/d2-doctor/negative-control.txt`. **FIXED.** 286 287 ### 3. Errors reported late, at the wrong call (10,356 GitHub issues mention "CUDA_LAUNCH_BLOCKING") 288 289 **The pain.** "In our experience the python stack traces for these types of exceptions are basically always incorrect and pretty worthless." (vLLM's maintainers, [vLLM blog](https://vllm.ai/blog/2025-08-11-cuda-debugging)) 290 291 **How CUDA++ fixes it.** A CUDA++ launch waits for its own completion by default, so an error comes back from the call that caused it. And the same kernel program runs on CUDA++'s host warp simulator with one flag, where every global access is checked against the buffers the launch was given. A bad access stops the run at that launch and names the kernel, the launch, the instruction, the block and thread, the address, the buffer it missed and by how much, and what to do next. 292 293 **The command that shows it** (`--bug=past-end` hands the last launch one element too many, the classic off-by-one): 294 295 ``` 296 $ build/hello_gpu --sim --bug=past-end 297 FAULT at launch 8 of 8 of kernel vecadd (simulator): global load outside every buffer 298 launch: grid 1025 x 1 blocks of 128 threads, n = 131073, first element 917504 299 instruction: 11 of 19, LDG.E (4-byte load) 300 thread: block 1024, thread 0 (element `1048576` of the whole job) 301 address: 0xeba6fbc6f040 (4 bytes), 0 bytes past the end of buffer a = [0xeba6fb86f040, 0xeba6fbc6f040) (`4194304` bytes) 302 simulator: MEM at pc 11: global access outside the declared buffers 303 next: launch 8 was given n = 131073, and buffer a holds 131072 elements from this launch's first element. 304 Fix the launch or the buffer, run hello_gpu --sim until it passes, then run hello_gpu on the GPU. 305 ``` 306 307 Receipts: `evidence/dx/d3-faults/fault-report-spark.txt`, `evidence/dx/d3-faults/test-hello-sim.txt`, `evidence/dx/d3-faults/negative-control.txt` (with bounds checking off, the fault checks fail). **FIXED on the simulator.** Left: on the chip a faulting kernel still shows up as a launch that never completes, and the process then refuses further GPU work. Reading the GPU's own fault record (`docs/issues/D3-chip-faults.md`) and recovering without a restart (Omega bar C5, ledger L386) are open. 308 309 ### 4. Builds take hours and ship gigabytes (7,646 GitHub issues match nvcc "compile time") 310 311 **The pain.** "For reference I just compiled it on a 2018 Dell laptop (Quadro P1000 GPU) and the build time was about 15 hours." ([flash-attention #1038](https://github.com/Dao-AILab/flash-attention/issues/1038)) 312 313 **How CUDA++ fixes it.** No per-architecture copies and no template-heavy device compiler: CUDA++ generates each kernel's machine code when the program builds it (row 9), so the library is plain C. 314 315 **The command that shows it** (on the Spark, 20 cores, with other builds running: load average 31.31): 316 317 ``` 318 $ git clone -b dx/pain-points cudapp && cd cudapp 319 $ time make -j20 320 exit 0, wall 2.`034379307` s 321 $ ls -l build/libcudapp.a 322 `1060126` build/libcudapp.a 323 $ nm -u build/libcudapp.a | grep -c -i cuda (CUDA symbols the library needs) 324 0 325 ``` 326 327 Receipt: `evidence/dx/pain-points/d5-build-from-empty.txt`. **FIXED for what CUDA++ contains.** This is not like for like: CUDA++'s libraries cover far less than cuBLAS and cuDNN (`docs/PAIN_POINTS.md` section 4). 328 329 ### 5. A new chip: "no kernel image is available for execution on the device" (4,033 GitHub issues) 330 331 **The pain.** "Very frustrating compared to most every other GPU release that has zero day support from cuda/nvcc/pytorch/tensorflow." ([r/LocalLLaMA, on the DGX Spark](https://www.reddit.com/r/LocalLLaMA/comments/1r569eb/psa_nvidia_dgx_spark_has_terrible_cuda_software)) 332 333 **How CUDA++ fixes it.** CUDA++ writes sm_121 machine code and has a supported-target table. `make doctor` refuses other NVIDIA GPUs by name and PCI id, with what is missing and the steps to port them. `make hello-gpu` runs the doctor first. Since runtime API 0.14.0 the library refuses them too: before it opens any `/dev/nvidia` node, `om/admission/chip_admit.om` decides from `/sys/bus/pci/devices` whether the GPU is a CUDA++ target, and any other is refused with one sentence naming its address and PCI id (host-tested with simulated driver and fake PCI trees, `make test-chip-admission`; the chip run is NOT_RUN). A table row is not proof that the current checkout passed its gates; the M16 evidence limitation above applies. 334 335 **The command that shows it** (`CUDAPP_DOCTOR_SHOW=1 sh tests/doctor/run.sh build/cudapp-doctor`, the fake machine with a GPU CUDA++ has not qualified): 336 337 ``` 338 FAIL GPU 000f:01:00.0: NVIDIA device 0x2b85 is not one CUDA++ has qualified. 339 Why: CUDA++ writes each chip's machine code itself and has run it only on the NVIDIA GB10 (sm_121), 340 so it refuses this GPU now instead of failing later with "no kernel image is available". 341 What is missing: a target row for this chip, a check that the encoder's instruction words are valid on it, 342 its launch descriptor and class numbers, and the hello-gpu qualification run with its receipt. 343 What to do: follow docs/runtime/PORTABILITY.md section 5 ("What a new GPU needs") and CONTRIBUTING.md ("Port a chip"), 344 or report it with the output of `make doctor` attached. 345 ``` 346 347 Receipt: `evidence/dx/d2-doctor/fake-machines.txt`. **FIXED in the doctor wrapper only: the refusal.** Direct library admission is not enforced. Not fixed: CUDA++ targets one chip; porting more is open to everyone (`CONTRIBUTING.md`). 348 349 ### 6. Different answers from the same inputs (5,416 GitHub issues match nondeterministic cuda) 350 351 **The pain.** "Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms." ([PyTorch docs](https://docs.pytorch.org/docs/2.14/notes/randomness.html)) 352 353 **How CUDA++ fixes it.** CUDA++ adds in a fixed order (no atomics in its reductions, `evidence/E1-CLOSURE/`), so the same inputs give the same bits with no setting to turn on. Every hello-gpu run prints the hash of its output, and so do the chip paths of the bf16 matrix-vector, rmsnorm and decode-attention tests. 354 355 **The command that shows it** (10 separate processes on the GB10, nothing set, the caller holds the GPU lock; output from the receipt): 356 357 ``` 358 $ flock -w 900 /tmp/aien-gb10.lock tools/run_d7_same_bits_chip.sh gemv 10 /tmp/d7 359 ... (one line per run, then:) 360 SAME gemv_f32_151936x2048 `ed3805976ef5eb04a893ed9d3b9ad1cc8afa17e60a36b7d4dd9dd98e698f9e4b` in 10 of 10 runs 361 d7 same-bits: PASS (1 labels x 10 runs) 362 ``` 363 364 Receipt: `evidence/d7-same-bits-chip/2026-10-27/SUMMARY.md` (chip) and `evidence/dx/d3-faults/hello-sim-spark.txt` (simulator). **FIXED on the GB10 for four jobs, 10 separate processes each, driver 580.173.02:** hello-gpu (vector add; the chip hash equals the simulator's), the bf16 matrix-vector 151936 x 2048 (warp-shuffle reduction), rmsnorm at three shapes (reduction across the block) and decode attention at eight context lengths up to 32768 (softmax reductions, combine across up to 128 splits). The checker goes red on a chip run with one element unwritten and on a one-bit hash change (`negative-control/`). Not shown: the other kernels (scan and sum-reduce build on main since #112 but are NOT_RUN in this check), other GPUs, other inputs (`docs/issues/D7-same-bits-chip.md`). 365 366 ### 7. The per-process CUDA tax (3,478 GitHub issues match "CUDA context" memory overhead) 367 368 **The pain.** "The CUDA tax, which is 4.6 GB approximately per each model on a DGX spark." ([r/LocalLLaMA](https://www.reddit.com/r/LocalLLaMA/comments/1sqera2/vllm_woes_in_spark)) 369 370 **How CUDA++ fixes it.** A CUDA++ process loads no CUDA library: Aien's live Qwen3.6-35B-A3B server (mixture-of-experts, about 3B parameters active per token) on 2026-10-21 had only the C library, the maths library, `libgcc_s` and the loader mapped (Omega `evidence/WHAT-OMEGA-IS-`20261021`/live-serve-no-cuda.txt`). 371 372 **NOT YET MEASURED.** The memory a CUDA++ process holds beyond its own buffers still needs a number from a chip run (`docs/issues/D8-process-tax.md`). 373 374 ### 8. Lock-in by licence (2,902 GitHub issues mention ZLUDA) 375 376 **The pain.** CUDA's licence: "You may not reverse engineer, decompile or disassemble any portion of the output generated using SDK elements for the purpose of translating such output artifacts to target a non-NVIDIA platform." ([CUDA EULA](https://docs.nvidia.com/cuda/eula/index.html)) And a developer: "I hope someone is working on hardware agnostic solutions, we need more GPUs, not less." ([r/LocalLLaMA](https://www.reddit.com/r/LocalLLaMA/comments/1b6gfjt/cuda_crackdown_nvidias_licensing_update_targets)) 377 378 **How CUDA++ addresses it.** This candidate uses Apache-2.0 WITH LLVM-exception for first-party material and preserves the earlier MIT grant for its pinned historical snapshot. Reverse engineering CUDA++ output, translating it and porting it to any hardware are allowed under the applicable license (`CONTRIBUTING.md`). Third-party notices remain in force. 379 380 **The command that shows it:** 381 382 ``` 383 $ grep -e "Version 2.0, January 2004" -e "LLVM Exceptions" LICENSE 384 Version 2.0, January 2004 385 ---- LLVM Exceptions to the Apache 2.0 License ---- 386 ``` 387 388 The earlier MIT-era output is retained as a dated receipt at `evidence/dx/pain-points/licence.txt`; it describes the historical tree, not this candidate. The GPU's signed firmware stays NVIDIA's: the chip checks its signature. 389 390 ### 9. Compiling at run time, and hangs while it compiles (517 GitHub issues match "JIT compilation" hang cuda) 391 392 **The pain.** "A deep prefill forces a live JIT for a huge novel shape mid-inference, and that compile or kernel deadlocks the GPU on `sm_121a`." ([dgx-spark-laguna FINDINGS.md](https://github.com/sudoingX/dgx-spark-laguna/blob/main/FINDINGS.md)) 393 394 **How CUDA++ fixes it.** The kernel builder runs inside the program, calls no outside compiler, keeps no cache directory, and gives the same bytes every time. 395 396 **The command that shows it:** 397 398 ``` 399 $ build/hello_gpu --sim 400 kernel built in 22 us: 32 instructions, 12 registers, no compiler run, no cache 401 machine code sha256 `6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1` 402 $ build/hello_gpu --sim 403 kernel built in 23 us: 32 instructions, 12 registers, no compiler run, no cache 404 machine code sha256 `6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1` 405 ``` 406 407 Receipt: `evidence/dx/d3-faults/hello-sim-spark.txt`. **FIXED for the kernels CUDA++ builds.** The model's larger kernels are built the same way; their build times are not yet printed. 408 409 ### 10. Closed, model-shaped libraries 410 411 **The pain.** "Even worse, if someone accidentally created a kernel with "cutlass" in the name, the driver would apply optimizations that are not safe." ([r/LocalLLaMA](https://www.reddit.com/r/LocalLLaMA/comments/1lx62hd/nvidia_being_nvidia_fp8_is_150_tflops_faster_when)) 412 413 **How CUDA++ fixes it.** Every CUDA++ library is source in this repository, built by the same kernel builder you can call, with host references and a simulator. 414 415 **NOT YET.** CUDA++'s fast matrix multiply kernels are shaped for the models AIEN runs. The general GEMM `omega_gpu_gemm_ex` takes any shape, but it works from host memory and sums k on the host (`docs/runtime/API.md` section 9.8): correct on the GB10, not a serving path. Attention has a general fallback since runtime API 0.6.0 (head_dim 1..256, any GQA ratio, causal and non-causal, sliding window, any length), but it is a scalar f32 kernel; its fast fused paths are still model-shaped. A device-resident any-shape GEMM, scans and sorts (Omega bar C3) and my own disassembler (bar C6) are ledger L386 (`docs/issues/D11-libraries.md`, `docs/issues/D13-disassembler.md`). 416 417 ### 11. The incentive: compute sold from data centers 418 419 **The pain.** NVIDIA's data-center segment was 92.5% of its revenue last quarter: "Data Center revenue of $89.0 billion" out of $96.2 billion ([NVIDIA, Q2 fiscal 2027](https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-second-quarter-fiscal-2027)). A company paid for compute sold has no reason to make the machine you own do the same work with less. 420 421 **How CUDA++ answers it.** Measure the work, not the hardware. Every hello-gpu run prints the bytes it moved, the operations it did, and the least time those bytes need at this machine's own measured ceiling, so less work per answer is a number in front of the developer. 422 423 **The command that shows it:** 424 425 ``` 426 $ build/hello_gpu --sim 427 work: `12582912` bytes moved (`8388608` read, `4194304` written), `1048576` floating-point operations 428 at the GB10's measured 195.1 GB/s read ceiling this needs at least 64.5 us 429 ``` 430 431 Receipt: `evidence/dx/d3-faults/hello-sim-spark.txt`; the ceiling, `evidence/OWN30B-T3-TC-PEAK-BW-`5faa0f70`-20261013T2236Z/`. **FIXED on the simulator.** Left: the measured GPU time printed next to the floor, from a chip run (the code prints it; it has not run on the chip yet). 432 433 The developer replacement workflow is ledger item L401. Its kernel-module replacement scope is pending a separate kernel decision; the supported path here retains NVIDIA's open kernel module. 434 435 ## Run your first kernel 436 437 You need: a DGX Spark (GB10) running Linux with NVIDIA's open kernel module loaded (version 580.173.02 was used here; `/dev/nvidia0` and `/dev/nvidia-uvm` must exist and be readable and writable by your user), plus `git`, `make`, `gcc` and `bash`; the zero-CUDA gate also uses `readelf` and `nm` from binutils, which comes with `gcc`. Nothing from the CUDA toolkit is needed or used, no environment variable needs to be set, and nothing is fetched besides this repository. 438 439 From an empty folder: 440 441 ```bash 442 git clone https://github.com/aien-dev/CUDApp 443 cd CUDApp 444 make hello-gpu 445 make hello-gpu-control 446 make zero-cuda-gate 447 ``` 448 449 `make hello-gpu` builds the library and `examples/hello_gpu`, runs `make doctor` (which checks the machine and names any problem with its fix), then runs the program. It builds a vector-add kernel, adds two arrays of one million numbers on the GPU and checks every answer on the CPU. It prints `PASS` and exits 0 when all answers are right, exits 1 when any is wrong, and exits 2 when it cannot use the GPU. `build/hello_gpu --sim` runs the same kernel on the host simulator with no GPU. `examples/hello_gpu/hello_gpu.c` explains each of its five steps. It is C on purpose: a foreign caller of the runtime's C API (`src/omega_gpu_session.h`, `docs/runtime/API.md`), not first-party implementation, and its first line says `ORACLE/foreign-caller example`. The C API has no Omega binding. The Omega-language counterpart is the native vector launch of `docs/speculation/NATIVE-KERNEL.md` (`native/blackwell/launch.om` over `native/nvrm/context.om`, no C runtime), which adds uint32 arrays rather than floats; replacing this program with `.om` is tracked in #79. 450 451 `make hello-gpu-control` checks the check: it builds a second copy, `build/hello_gpu_control`, with a migration-pending switch turned on (`CUDAPP_MIGRATION_PENDING_HELLO_CONTROL=1`; it is off in `build/hello_gpu`, and its `.om` successor is #79), runs it with `--bug=short`, which gives the last launch one element too few (nothing is written outside a buffer), and passes only when the program catches that one missing answer, prints `FAIL` and exits 1. `make zero-cuda-gate` reads the built programs' ELF dynamic section and imports and fails on any CUDA library or CUDA symbol; it first runs its own negative control, a stub `libcudart` that must fail. It is a check on the binaries, not proof that NVIDIA's kernel modules or firmware are gone. 452 453 On a shared machine, hold the GPU lock your operator uses around these commands (on the AIEN Spark: `flock -w 900 /tmp/aien-gb10.lock make hello-gpu`). A run of exactly these commands by a brand-new Linux user with an empty environment is recorded in `evidence/C2-CLEAN-USER/`. 454 455 ## Run your first kernel without a GPU 456 457 You need: Linux with `git`, `make`, `gcc` and `bash`, plus `readelf` and `nm` from binutils for the zero-CUDA gate (this block has been run on aarch64 only). No GPU, no NVIDIA driver, no CUDA toolkit and no environment variable. From an empty folder: 458 459 ```bash 460 git clone https://github.com/aien-dev/CUDApp 461 cd CUDApp 462 make hello-gpu-build 463 build/hello_gpu --sim 464 make zero-cuda-gate 465 ``` 466 467 `make hello-gpu-build` builds the library and `build/hello_gpu` and runs nothing; `make hello-gpu` would also open the GPU, so do not use it here. `build/hello_gpu --sim` builds the same vector-add kernel and runs it on the host warp simulator; it prints the runtime API version of the library and of the program, checks every answer and prints `PASS`. It never opens a `/dev/nvidia` node. When it is later run on a GPU without `--sim`, the library first checks that the GPU is one CUDA++ targets and refuses any other with one sentence before it opens anything (`docs/runtime/API.md` section 1). `tools/runtime/clean-room-sim.sh ` runs exactly this block from a fresh clone in an empty folder with an empty environment, traces it, and fails if any `/dev/nvidia` node or CUDA file was opened; its run is in `evidence/C2-CLEAN-ROOM-SIM-`20261105`/`. 468 469 ## Build and test without a GPU 470 471 ```bash 472 make # build/libomega_gpu.a (also as build/libcudapp.a) 473 make test # portable host suite: x86-64 and AArch64, no NVIDIA tools, no sibling checkout 474 python3 tools/figures/make_figures.py --check # the figures on this page match the code they are drawn from 475 make doctor # is this machine ready? one line per check, each problem with its fix; opens no device 476 ``` 477 478 `make test` opens no device. It is the portable suite: the same command is the 479 x86-64 host gate and the AArch64 host gate. On the x86-64 VM in 480 `evidence/HOST-X86-`20261030``, that command exits 2 at the default 481 `CUDAPP_MEM_RESERVE_MIB` of 4096 and passes only with 482 `CUDAPP_MEM_RESERVE_MIB=0`. The default is unchanged. Production ordering on AArch64 483 stays `dsb sy` (`nvrm/cpu_barrier.h`). On x86-64 the Blackwell device open 484 returns `ENOTSUP` and names AArch64; the fake-driver simulator is a separate 485 compile. `docs/OMEGA_HOST_TESTS.md` lists the portable commands and the 486 target-only ones. 487 488 The chip gates (`./build/gpu_*_test --out receipt.json`) and `make hello-gpu` 489 need a GB10. `make test-omega-slices` needs `OMEGA_OSC_COMPILER_DIR` pointing 490 at the pinned OSC compiler checkout. None of those are inside `make test`. 491 Each chip test's comment in the `Makefile` says how it is run. 492 493 `make test-gemm-selectors` is the focused host-only CLI regression for PFGEMM, 494 QGEMM and FP8GEMM. Each validates `--shape` before host/simulator/chip work or 495 receipt creation; unknown, empty and case-mismatched selectors exit 2 with INVALID, 496 never PASS. PFGEMM/QGEMM accept `gateup`, `down`, `qkv`, `o`; omission runs all. 497 FP8GEMM also accepts `d768` and `all` (the four standard shapes, not `d768`). 498 No selected mode/cases/checks yields NOT_RUN rather than a zero-case PASS. 499 Invalid FP8GEMM input leaves an existing `--out` file untouched. These refusal 500 tests and doctor tests do not qualify GPU execution. Their before/after output 501 is retained in `evidence/security-host-`20261026`/`; the full host suite and GPU 502 gates were NOT_RUN for this repair. 503 504 ## How it fits with Omega and Omega Bridge 505 506 Ownership rule ([ARCH-0042](https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/adr/0042-omega-cudapp-bridge-ownership.md), Accepted 2026-10-30): Omega owns computation, CUDA++ owns GPU execution, Omega Bridge owns compatibility. 507 508 - **CUDA++ (this repository)** owns GPU execution: the sm_121 encoder and GPU code generators, the cubin writer and artifact exporter, artifact admission, the disassembler, the driver client (`nvrm/`), submission, sessions and the GPU runtime. 509 - **[Omega](https://github.com/aien-dev/omega-mv)** owns Aien's seeded `.om` language, its compiler and the compiler pin, semantics, and the declared contract of what a kernel computes. The existing Omegese → IR → sm_121 lowering, its checker and host words stay in omega-mv. omega-mv#885 (draft) adds a seeded `.om` port of that lowering. It stops at BlackwellIR, so register allocation and sm_121 encoding are still the C builder. CUDA++ is the GPU execution component Omega consumes. 510 - **[Omega Bridge](https://github.com/aien-dev/omega-bridge)** owns compatibility: C and Python emitted from a checked Omega subset, native bindings for foreign callers, framework attachments and GPU artifact negotiation (`gpu_adapter.om`). Bridge runs no kernels itself: its GPU adapter only accepts or refuses an attachment request and opens no device. Execution goes through this repository. Framework attachments, in open pull requests that have not merged, exercised op by op on one GB10: llama.cpp/GGML through the opt-in `OmegaGB10` device of [aien-dev/ggml-omega#2](https://github.com/aien-dev/ggml-omega/pull/2) (ready for review, not a draft; MUL_MAT through `omega_gpu_gemm_ex`, RMS_NORM, swiglu; every other op stays on ggml's CPU backend; test-backend-ops against the CPU backend: 871, 7 and 12 cases OK, 0 FAIL, with the k-dropping mutant caught, rerun on 2026-10-31 against #139 at `117d8d71` in `evidence/GGML-OMEGA-OPS-`117d8d7`/`; that pull request also records bounded BF16 and Q8 runs of one model that matched CPU greedy tokens over 16 generated tokens, which is not whole-model qualification), and PyTorch through the `torch.library` ops `cudapp::mm` and `cudapp::swiglu` of draft [aien-dev/omega-bridge#30](https://github.com/aien-dev/omega-bridge/pull/30) (CPU tensors staged per call, checked against torch CPU). Both depend on `omega_gpu_gemm_ex`, which [#139](https://github.com/aien-dev/CUDApp/pull/139) adds. 511 512 The currently shipped CUDApp implementation still contains first-party C; the planned, test-gated replacement with native `.om` is tracked in [#79](https://github.com/aien-dev/CUDApp/issues/79). The code was split out of Omega on 2026-10-21 with its full history; `docs/AUDIT.md` records how, and what was checked before it was published. 513 514 Not yet true: Omega does not consume CUDA++ at a pin today. Omega main has no `cudapp.lock`; it still builds its own diverged copy of the GPU code ([#106](https://github.com/aien-dev/CUDApp/issues/106)) and takes the driver client from physics-mv ([#107](https://github.com/aien-dev/CUDApp/issues/107)). The disassembler is in Omega ([#10](https://github.com/aien-dev/CUDApp/issues/10)). The cubin writer lives here (`src/omega_cubin.c`, and `om/cubin/cubin_elf.om` on the hosted build). A second writer, omega-mv `seed/sm80/cubin.om`, is not on omega-mv main: it is the closed, unmerged branch of [omega-mv#864](https://github.com/aien-dev/omega-mv/pull/864). Ownership, the differences, and what was not run are in [docs/CUBIN_WRITERS.md](docs/CUBIN_WRITERS.md) ([#108](https://github.com/aien-dev/CUDApp/issues/108)). The `.om` work here takes its compiler through Omega Bridge's bootstrap rather than an Omega pin ([omega-mv#870](https://github.com/aien-dev/omega-mv/issues/870)). 515 516 ## Names 517 518 The C names still carry the `omega_` prefix they had inside Omega, so Omega's work in progress carries over unchanged (`tools/extract/carry.sh`). `docs/NAMING.md` has the plan for the `cudapp` names. 519 520 ## Human-Directed Agentic Engineering 521 522 Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, architecture, constraints, acceptance criteria, and stopping points; agents implement, execute checks, diagnose failures, and revise within those boundaries. Human review retains responsibility for claims, acceptance, and release decisions. 523 524 For the documented method and a systems-software case study, see Gregory M. Kurtzer, [*Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed Agentic Engineering* (2026)](https://doi.org/10.5281/zenodo.`23682548`). This describes development, not GPU runtime autonomy or hardware qualification. 525 526 ## Licence 527 528 First-party material at this revision is Apache-2.0 WITH LLVM-exception ([LICENSE](LICENSE)); third-party terms and notices are in [THIRD_PARTY.md](THIRD_PARTY.md). The earlier MIT grant is documented in [the licensing transition](docs/LICENSING_TRANSITION.md) and the [license at the pinned historical MIT commit](https://github.com/aien-dev/CUDApp/blob/`232332422bfdc31c8918085b50f13c1e18ab702e`/LICENSE).