diff --git a/.github/ISSUE_TEMPLATE/add-a-library.md b/.github/ISSUE_TEMPLATE/add-a-library.md new file mode 100644 index 00000000..b17b7d5a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/add-a-library.md @@ -0,0 +1,20 @@ +--- +name: Add a library +about: A new kernel or a wider one (any-shape GEMM, scan, sort, FFT, random numbers ...). +title: "Library: " +labels: library +--- + +**What it computes**, and which CUDA library does this today. + +**Shapes and types** it must cover. + +**The host reference**: how the exact answer is computed on the CPU. + +**Done when** (the command anyone can run, and what it must print): + +**Checklist** +- [ ] host reference and test, seen failing first +- [ ] mutation test: a deliberately broken copy fails +- [ ] simulator run, where the simulator covers the instructions +- [ ] chip receipt under `evidence/`, with speed as a fraction of the measured ceiling diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..0086358d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/ISSUE_TEMPLATE/pain-point.md b/.github/ISSUE_TEMPLATE/pain-point.md new file mode 100644 index 00000000..f8ddb2e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pain-point.md @@ -0,0 +1,27 @@ +--- +name: Pain point +about: Something about CUDA or CUDA++ cost you time. Bring the receipt. +title: "Pain: " +labels: pain-point +--- + +**What you were trying to do** + +**The command you ran** (copy and paste) + +``` +``` + +**What it printed** (all of it) + +``` +``` + +**Output of `make doctor`** + +``` +``` + +**What should have happened instead** + +**Is this CUDA, CUDA++, or both?** If CUDA: a link to where others hit it helps it get a row in `docs/PAIN_POINTS.md`. diff --git a/.github/ISSUE_TEMPLATE/port-a-chip.md b/.github/ISSUE_TEMPLATE/port-a-chip.md new file mode 100644 index 00000000..815f57f6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/port-a-chip.md @@ -0,0 +1,28 @@ +--- +name: Port a chip +about: You want CUDA++ to run on your NVIDIA GPU. Open this first so nobody duplicates the work. +title: "Port: ()" +labels: port +--- + +**GPU** (name, and the PCI id `make doctor` prints, for example 0x2b85) + +**Kernel module version** (first line of `cat /proc/driver/nvidia/version`) + +**Output of `make doctor`** + +``` +``` + +**Output of `make test`** (last 20 lines are enough if it passes) + +``` +``` + +**Plan.** Follow `docs/runtime/PORTABILITY.md` section 5. Tick as you go, with a receipt path for each: + +- [ ] target row (PCI id, architecture, class numbers, launch descriptor version, memory model) +- [ ] encoder words checked on this chip +- [ ] launch descriptor and class numbers checked +- [ ] `make hello-gpu` PASS (receipt under `evidence/`) +- [ ] chip row added to `src/omega_gpu_chip.c` with the receipt path diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..16f98b76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# build outputs (make OUT_DIR, default build/) +build/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c5c3e7d1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,70 @@ +# Contributing to CUDA++ + +CUDA++ exists so that people can drop NVIDIA's closed software and still use the NVIDIA GPU they paid for. It gets there one receipt at a time, and anyone with a GPU can add one. This page says how. + +## The one rule + +Nothing counts until it runs and leaves a receipt. A receipt is the command you ran, the commit you ran it on, the machine, and what it printed, saved under `evidence/`. A pull request that says "should work" is welcome as a start; it is merged when its receipt is there. + +A failing test means the work is wrong. Find the cause; do not skip the test, loosen it or rerun it until it passes once. + +## What you need + +A Linux machine with an NVIDIA GPU, NVIDIA's open kernel module, `git`, `make` and a C compiler. No CUDA toolkit. Start here: + +``` +git clone https://github.com/aien-dev/CUDAplusplus +cd CUDAplusplus +make doctor # is this machine ready? every problem comes with the command that fixes it +make test # every host check, no GPU needed +make hello-gpu # the first kernel, on the GPU +``` + +If `make doctor` says your GPU is not qualified, that is not a dead end. It is the first contribution below. + +## Four ways to help, easiest first + +### 1. Report a pain point, with a receipt + +Something about CUDA or CUDA++ cost you time? Open an issue with the "Pain point" template. Paste the command you ran and its full output, and the output of `make doctor`. If it is a CUDA pain point CUDA++ does not answer yet, say what the better behaviour would be. `docs/PAIN_POINTS.md` is the list we work from; good reports get a row. + +### 2. Port a chip ("do it on your GPU") + +CUDA++ has run on one chip so far, the GB10 in the DGX Spark. Every other NVIDIA GPU needs a port, and the method is written down in `docs/HOW_WE_DID_IT.md`. What changes from chip to chip is listed in `docs/runtime/PORTABILITY.md` section 5. In order: + +1. Run `make doctor` and `make test` and keep both outputs. +2. Add a target row for your chip (PCI id, architecture, class numbers, launch descriptor version, memory model). Fields nobody has published are marked unknown until you measure them. +3. Check the encoder's instruction words on your chip: run `examples/hello_gpu` and the host tests' golden words against what your GPU does. Same family (for example another Blackwell part): mostly measuring. Different family: a new encoder. +4. When `make hello-gpu` prints PASS on your GPU, add your chip to the table in `src/omega_gpu_chip.c` with the path of your receipt. That row is what makes `make doctor` say READY for the next person with your GPU. + +Open the issue first with the "Port a chip" template, even before anything works, so two people do not port the same chip. + +### 3. Port a driver version + +CUDA++ talks to NVIDIA's open kernel module through its public headers (`third_party/nvidia-open-580.173.02/`). A different module version may change those calls, so `make doctor` refuses a version CUDA++ was not built for. To add one: copy that release's headers from NVIDIA's `open-gpu-kernel-modules` (MIT) into `third_party/nvidia-open-/`, point the Makefile at them, and run `make test` and `make hello-gpu`. Send the receipts. + +### 4. Add or widen a library + +CUDA++'s libraries (matrix multiply, attention, elementwise, mixture-of-experts routing) are shaped for the models AIEN runs. Any-shape GEMM, scans, sorts, FFT and random numbers are open (`ROADMAP.md`). A library change needs a host reference (the exact answer computed on the CPU), a simulator run where the simulator covers it, a mutation test (a deliberately broken copy must fail your test) and a chip receipt. Open an issue with the "Add a library" template first. + +## Reverse engineering, translation and ports are welcome + +CUDA++ is MIT. You may read, disassemble, reverse engineer and translate anything CUDA++ produces, including the machine code it writes, and run it or port it to any hardware, NVIDIA or not. We ask only that you keep the licence notice. This is on purpose: CUDA's licence forbids reverse engineering its output to target other hardware (`docs/PAIN_POINTS.md` section 2.8), and CUDA++ will never do that to anyone. + +Do not send us NVIDIA's code or binaries. CUDA++ stores no NVIDIA binary, cubin, PTX or firmware, and no listing printed by NVIDIA's tools (`docs/AUDIT.md`). If you used NVIDIA's compiler or disassembler on your own small kernels to learn an encoding, say so in the code comment, as the existing code does (`docs/HOW_WE_DID_IT.md`, step 2). + +## How a change gets in + +1. Work on a branch named for what it does. +2. Write the test first and watch it fail for the reason you expect. Then make it pass. Include a negative control: a case that must fail, and does. +3. Run `make test` (the whole host suite, not only your test). Every failure in that run goes in your description by name, including ones you did not cause. +4. Put receipts under `evidence//` with the commit they ran on. +5. Open the pull request. Say what it beats CUDA at, or where CUDA is still better. + +## Writing + +Plain English and short sentences. Say what a thing does, not how good it is. A number always comes with the command that produced it. Write the name as CUDA++, with the plus signs. + +## Licence + +By contributing you agree that your contribution is licensed under the MIT licence in `LICENSE`. diff --git a/Makefile b/Makefile index e861cb7a..932ee042 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ # # make libomega_gpu.a (= libcudapp.a): GPU toolchain + runtime + libraries + driver client # make test every host-only test (no GPU needed) -# make hello-gpu build examples/hello_gpu (runs on a GB10) +# make doctor is this machine ready? one line per check, each FAIL with its fix (no GPU opened) +# make hello-gpu run the doctor, then build examples/hello_gpu and run it (on a GB10) # # The driver client (nvrm/, m16/) and the NVIDIA open headers (third_party/) are in # this repository, so PHYSICS_DIR is "." here. Omega builds the same sources with @@ -272,7 +273,7 @@ HOST_TESTS = test-gpu-matmul-api test-gpu-elementwise test-gpu-reconv test-gpu-a test-gpu-engine-mutants test-gpu-engine-backend-compile test-gpu-engine-prod-build test-gpu-engine-sim \ test-gpu-engine-backend-mutants test-gpu-engine-gb10-compile test-gpu-serving-alloc test-gpu-engine-freestanding \ test-codegen-freestanding test-gpu-session-platform test-gpu-wait test-gpu-wait-mutants host-tests-m16 \ - test-runtime-api test-runtime-portability + test-runtime-api test-runtime-portability test-doctor test-hello-sim test: $(HOST_TESTS) @echo "CUDA++ HOST TESTS PASS ($(words $(HOST_TESTS)) targets)" diff --git a/README.md b/README.md index 10b9efbf..de5675e1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +

+ CUDA++: my own path from a program to an NVIDIA GPU. On the right, the 32 instructions of the first kernel CUDA++ ran, drawn bit by bit from src/omega_blackwell_encoder.c. +

+ # CUDA++ **CUDA++ is the GPU half of the Omega runtime, under the MIT licence so anyone can use it.** You write a GPU program, CUDA++ turns it into the GPU's own machine code and runs it on an NVIDIA GPU, with no NVIDIA user-space software anywhere: no CUDA toolkit, no `nvcc`, no PTX, no `libcuda`, no cuBLAS. @@ -6,49 +10,327 @@ It runs on the NVIDIA GB10 (the DGX Spark, compute capability sm_121) today. The CUDA++ keeps growing until every NVIDIA part on the Spark is replaced, and then does things CUDA does not: -- our own GPU driver replaces NVIDIA's kernel modules `nvidia.ko` and `nvidia-uvm.ko` (AIEN work item L332); -- our own disassembler replaces `nvdisasm`; +- my own GPU driver replaces NVIDIA's kernel modules `nvidia.ko` and `nvidia-uvm.ko` (AIEN work item L332); +- my own disassembler replaces `nvdisasm`; - only the GSP firmware stays NVIDIA's, for a physical reason: the GPU checks its signature and boots nothing else; - 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. -`ROADMAP.md` lists every NVIDIA piece on the Spark, what replaces it and how far that has got. - CUDA++ is not affiliated with or endorsed by NVIDIA; CUDA is NVIDIA's trademark. -## How it fits with Omega +**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) -Omega (github.com/aien-spark/omega, AGPL-3.0) is AIEN's language for all computing: the languages Omegese and OSC, their checker and the CPU backends. CUDA++ is the part of the Omega runtime that drives the GPU. Omega uses CUDA++ at a pinned commit (`cudapp.lock` in Omega), the same way it pins its other parts. 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. +## The stack -## What is in here +

CUDA and CUDA++ layer by layer. The compiler, maths libraries, runtime and driver library of CUDA are closed and are replaced by CUDA++ code. NVIDIA's open kernel module is still used for now; the signed GSP firmware stays.

-| Part | What it does | Where | +Between a CUDA program and the GPU sit four closed NVIDIA layers: the compiler, the maths libraries, the runtime and the driver library. CUDA++ replaces all four with its own code. Under them are NVIDIA's kernel module, whose source NVIDIA publishes, and the firmware inside the GPU. CUDA++ talks to the kernel module directly; AIEN's own driver for the GB10 is being built to replace it. + +## How I did it + +

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.

+ +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: + +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. +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. +3. **My own encoder, runtime and libraries** on top: 59 instruction kinds, a register allocator, launch descriptors, command lists, matrix multiply, attention. + +

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.

+ +No NVIDIA binary or listing is in this repository. The whole method, step by step with the files and receipts: [docs/HOW_I_DID_IT.md](docs/HOW_I_DID_IT.md). + +### What the machine code looks like + +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: + +

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.

+ +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: + +

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.

+ +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`. + +## The driver, part by part + +`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: + +

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.

+ +| Part | Where | What it does | | --- | --- | --- | -| 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` | -| 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*` | -| 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.*` | -| Driver client | Talks to NVIDIA's open kernel module through its ioctls; replaces `libcuda` | `nvrm/`, `m16/` | -| NVIDIA interface headers | The open kernel module's public interface definitions (MIT, unchanged) | `third_party/nvidia-open-580.173.02/` | -| Runtime API | The written, versioned API and its manifest check | `docs/runtime/API.md`, `src/omega_runtime_api.h` | +| 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. | +| 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()`). | +| 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. | +| 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. | +| 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. | +| 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. | +| 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. | +| 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. | + +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: + +- **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. +- **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). +- **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. +- **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. +- **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). + +Under the client: NVIDIA's open kernel module (`nvidia.ko`, `nvidia-uvm.ko`) and the GSP firmware inside the GPU. AIEN's own GB10 driver (L332) is being built to replace the two modules; 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). + +## One launch, start to finish + +

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.

+ +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. ## CUDA, piece by piece +

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

+ | CUDA piece | Its job | CUDA++ replacement | Status | | --- | --- | --- | --- | | 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 only | -| nvcc, NVVM, PTX, ptxas | Compile the kernel to machine code | Our own sm_121 encoder and register allocator | PASS: every kernel Omega runs is encoded by it | +| nvcc, NVVM, PTX, ptxas | Compile the kernel to machine code | My own sm_121 encoder and register allocator | PASS: every kernel Omega runs is encoded by it | | libcuda (driver API) | Talk to the kernel driver | `nvrm` client, ioctls straight to the open kernel module | PASS (`evidence/m16-blackwell-native-path-requalification-receipt.json`) | | 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 | -| cuBLAS | Matrix multiply | Matmul, tensor-core GEMM, FP8 and BF16 libraries | PARTIAL: shaped for the models we run; no any-shape GEMM yet | +| cuBLAS | Matrix multiply | Matmul, tensor-core GEMM, FP8 and BF16 libraries | PARTIAL: shaped for the models AIEN runs; no any-shape GEMM yet | | cuDNN, FlashAttention | Attention and network layers | Decode and prefill attention | PARTIAL: model-shaped | | CUB, Thrust | Reductions, scans, sorts | Frozen-order reductions (`evidence/E1-CLOSURE/`) | PARTIAL: no general scan or sort | | cuFFT, cuRAND | FFT, random numbers | none yet | MISSING | -| cuobjdump, nvdisasm | Read machine code back | none yet: some host tests call NVIDIA's `nvdisasm` as a cross-check when it is installed | MISSING | +| cuobjdump, nvdisasm | Read machine code back | My own sm_121 disassembler | BUILDING: on Omega branch `c6/disasm` (19eebe0e) it agrees with `nvdisasm` on 331 kernels; not in CUDA++ yet. Some host tests here still call `nvdisasm` as a cross-check when it is installed | | 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 | | CUDA samples, docs | Your first kernel | `examples/hello_gpu`, `docs/runtime/` | PARTIAL: one example | -| `nvidia.ko`, `nvidia-uvm.ko` | Kernel driver | AIEN's own GB10 driver (L332), being built | MISSING | +| `nvidia.ko`, `nvidia-uvm.ko` | Kernel driver | AIEN's own GB10 driver (L332), being built | BUILDING | | GSP firmware | Runs inside the GPU | stays NVIDIA's (signature-checked by the chip) | not replaceable | -PASS means a receipt exists on a named commit. Status words come from Omega's `docs/OMEGA.md`, section 2. +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". + +## Speed against the ceiling + +

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.

+ +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). + +## What is in here + +| Part | What it does | Where | +| --- | --- | --- | +| 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` | +| 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*` | +| 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.*` | +| Driver client | Talks to NVIDIA's open kernel module through its ioctls; replaces `libcuda` | `nvrm/`, `m16/` | +| NVIDIA interface headers | The open kernel module's public interface definitions (MIT, unchanged) | `third_party/nvidia-open-580.173.02/` | +| Runtime API | The written, versioned API and its manifest check | `docs/runtime/API.md`, `src/omega_runtime_api.h` | +| Figures | Every picture on this page, drawn from the repository's own data | `tools/figures/make_figures.py`, `docs/img/` | + +## CUDA's pain points, and how CUDA++ fixes them + +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`. + +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. + +### 1. Out of memory, and on the DGX Spark a frozen machine (26,390 GitHub issues say "CUDA out of memory") + +**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)) + +**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. + +**The command that shows it** (host test of the runtime on a simulated driver, run on the Spark): + +``` +$ make build/test_omega_gpu_platform_linux && ./build/test_omega_gpu_platform_linux +... + 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. + 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. +PASS D1_MEMORY_RESERVE_REFUSES_BEFORE_THE_DRIVER +test_omega_gpu_platform_linux (reference only, simulated driver): 9 passed, 0 failed +``` + +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`). + +### 2. The version and build matrix (11,034 GitHub issues mention "TORCH_CUDA_ARCH_LIST") + +**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)) + +**How CUDA++ fixes it.** There is no toolkit, framework build or extension build 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. A module of another version is refused, not guessed at. `make hello-gpu` runs the doctor first. + +**The command that shows it:** + +``` +$ make doctor +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.7 GiB shared by the CPU and the GPU, 61.3 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (one is installed at /usr/local/cuda/bin/nvcc; that is fine) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu +``` + +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): + +``` + FAIL NVIDIA kernel module: version 575.64.05 is loaded; CUDA++ speaks the 580.173.02 interface + Why: CUDA++ builds its driver calls from the 580.173.02 open-module headers + (third_party/nvidia-open-580.173.02). The layout of those calls can change between module versions, + and a wrong layout fails in strange ways, so CUDA++ refuses instead of guessing. + This is the only version CUDA++ asks you to match: no toolkit, no framework build, no extension build. + Do this: install the 580.173.02 open kernel module, or port the client to your version + (CONTRIBUTING.md, "Port a driver version": copy the new headers, rebuild, run make test and make hello-gpu). +``` + +Receipts: `evidence/dx/d2-doctor/make-doctor-spark.txt`, `evidence/dx/d2-doctor/fake-machines.txt`, `evidence/dx/d2-doctor/negative-control.txt`. **FIXED.** + +### 3. Errors reported late, at the wrong call (10,356 GitHub issues mention "CUDA_LAUNCH_BLOCKING") + +**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)) + +**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. + +**The command that shows it** (`--bug=past-end` hands the last launch one element too many, the classic off-by-one): + +``` +$ build/hello_gpu --sim --bug=past-end +FAULT at launch 8 of 8 of kernel vecadd (simulator): global load outside every buffer + launch: grid 1025 x 1 blocks of 128 threads, n = 131073, first element 917504 + instruction: 11 of 19, LDG.E (4-byte load) + thread: block 1024, thread 0 (element 1048576 of the whole job) + address: 0xeba6fbc6f040 (4 bytes), 0 bytes past the end of buffer a = [0xeba6fb86f040, 0xeba6fbc6f040) (4194304 bytes) + simulator: MEM at pc 11: global access outside the declared buffers + next: launch 8 was given n = 131073, and buffer a holds 131072 elements from this launch's first element. + Fix the launch or the buffer, run hello_gpu --sim until it passes, then run hello_gpu on the GPU. +``` + +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. + +### 4. Builds take hours and ship gigabytes (7,646 GitHub issues match nvcc "compile time") + +**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)) + +**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. + +**The command that shows it** (on the Spark, 20 cores, with other builds running: load average 31.31): + +``` +$ git clone -b dx/pain-points cudapp && cd cudapp +$ time make -j20 +exit 0, wall 2.034379307 s +$ ls -l build/libcudapp.a +1060126 build/libcudapp.a +$ nm -u build/libcudapp.a | grep -c -i cuda (CUDA symbols the library needs) +0 +``` + +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). + +### 5. A new chip: "no kernel image is available for execution on the device" (4,033 GitHub issues) + +**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)) + +**How CUDA++ fixes it.** CUDA++ writes each chip's machine code itself, so it knows exactly which chips it has run on: a table of qualified chips, each with its receipt. Any other NVIDIA GPU is refused by name and PCI id, with what is missing and the steps to port it. CUDA++ never loads code built for a different chip and keeps no cache across chips. + +**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): + +``` + FAIL GPU 000f:01:00.0: NVIDIA device 0x2b85 is not one CUDA++ has qualified. + Why: CUDA++ writes each chip's machine code itself and has run it only on the NVIDIA GB10 (sm_121), + so it refuses this GPU now instead of failing later with "no kernel image is available". + What is missing: a target row for this chip, a check that the encoder's instruction words are valid on it, + its launch descriptor and class numbers, and the hello-gpu qualification run with its receipt. + What to do: follow docs/runtime/PORTABILITY.md section 5 ("What a new GPU needs") and CONTRIBUTING.md ("Port a chip"), + or report it with the output of `make doctor` attached. +``` + +Receipt: `evidence/dx/d2-doctor/fake-machines.txt`. **FIXED: the refusal.** Not fixed: CUDA++ runs on one chip, CUDA on every NVIDIA GPU of the last decade. Porting more is open to everyone (`CONTRIBUTING.md`). + +### 6. Different answers from the same inputs (5,416 GitHub issues match nondeterministic cuda) + +**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)) + +**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 and no speed cost. Every hello-gpu run prints the hash of its output. + +**The command that shows it** (two runs): + +``` +$ build/hello_gpu --sim +output sha256 72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6 +$ build/hello_gpu --sim +output sha256 72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6 +``` + +Receipt: `evidence/dx/d3-faults/hello-sim-spark.txt`. **FIXED on the simulator.** Left: the same two-run check on the chip, for hello-gpu and a matrix-vector job (`docs/issues/D7-same-bits-chip.md`). + +### 7. The per-process CUDA tax (3,478 GitHub issues match "CUDA context" memory overhead) + +**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)) + +**How CUDA++ fixes it.** A CUDA++ process loads no CUDA library: AIEN's live 35B server 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`). + +**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`). + +### 8. Lock-in by licence (2,902 GitHub issues mention ZLUDA) + +**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)) + +**How CUDA++ fixes it.** MIT. Reverse engineering CUDA++'s output, translating it and porting it to any hardware are allowed and welcome (`CONTRIBUTING.md`). No NVIDIA binary is stored or run. + +**The command that shows it:** + +``` +$ head -1 LICENSE; git ls-files -z | xargs -0 file -b | grep -c -E "ELF|archive|PE32|Mach-O" +MIT License +0 +``` + +Receipt: `evidence/dx/pain-points/licence.txt`. **FIXED.** The GPU's signed firmware stays NVIDIA's: the chip checks its signature. + +### 9. Compiling at run time, and hangs while it compiles (517 GitHub issues match "JIT compilation" hang cuda) + +**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)) + +**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. + +**The command that shows it:** + +``` +$ build/hello_gpu --sim +kernel built in 22 us: 32 instructions, 12 registers, no compiler run, no cache +machine code sha256 6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1 +$ build/hello_gpu --sim +kernel built in 23 us: 32 instructions, 12 registers, no compiler run, no cache +machine code sha256 6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1 +``` + +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. + +### 10. Closed, model-shaped libraries + +**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)) + +**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. + +**NOT YET.** CUDA++'s matrix multiply and attention are shaped for the models AIEN runs. 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`). + +### 11. The incentive: compute sold from data centers + +**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. + +**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. + +**The command that shows it:** + +``` +$ build/hello_gpu --sim +work: 12582912 bytes moved (8388608 read, 4194304 written), 1048576 floating-point operations + at the GB10's measured 195.1 GB/s read ceiling this needs at least 64.5 us +``` + +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). + +Replacing a developer's CUDA libraries and NVIDIA's kernel module with CUDA++ is ledger item L401; its section here comes with it. ## Run your first kernel @@ -57,22 +339,28 @@ You need: a DGX Spark (GB10) running Linux with NVIDIA's open kernel module load From an empty folder: ```bash -git clone https://github.com/aien-dev/CUDAplusplus -cd CUDAplusplus +git clone https://github.com/aien-dev/CUDApp +cd CUDApp make hello-gpu ``` -`make hello-gpu` builds the library and `examples/hello_gpu`, then runs it. The program 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. `examples/hello_gpu/hello_gpu.c` explains each of its five steps. +`make hello-gpu` first runs `make doctor`, which checks the machine and names any problem with its fix, then builds the library and `examples/hello_gpu` and runs it. `build/hello_gpu --sim` runs the same kernel on the host simulator with no GPU. The program 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. `examples/hello_gpu/hello_gpu.c` explains each of its five steps. ## Build and test without a GPU ```bash make # build/libomega_gpu.a (also as build/libcudapp.a) make test # every host-only check: encoder goldens, simulators, refusals, mutation tests +python3 tools/figures/make_figures.py --check # the figures on this page match the code they are drawn from +make doctor # is this machine ready? one line per check, each problem with its fix; opens no device ``` `make test` opens no device. The chip gates (`./build/gpu_*_test --out receipt.json`) need a GB10; each test's comment in the `Makefile` says how it is run. +## How it fits with Omega + +[Omega](https://github.com/aien-dev/omega-mv) (AGPL-3.0) is AIEN's language for all computing: the languages Omegese and OSC, their checker and the CPU backends. CUDA++ is the part of the Omega runtime that drives the GPU. Omega uses CUDA++ at a pinned commit (`cudapp.lock` in Omega), the same way it pins its other parts. 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. + ## Names 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. diff --git a/ROADMAP.md b/ROADMAP.md index a89a70d4..a53b1ebc 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -15,16 +15,16 @@ Sources: Omega `docs/OMEGA.md` sections 2 to 5 (branch `docs/what-omega-is`, 202 | cuDNN, FlashAttention | Attention, network layers | decode and prefill attention | PARTIAL | model-shaped | | CUB, Thrust | Reductions, scans, sorts | frozen-order reductions | PARTIAL | `evidence/E1-CLOSURE/`; general scan and sort are bar C3 | | cuFFT, cuRAND | FFT, random numbers | none yet | MISSING | | -| `cuobjdump`, `nvdisasm` | Read machine code back | our own sm_121 disassembler | MISSING | bar C6: agree with `nvdisasm` on every library kernel, then replace every call to it | +| `cuobjdump`, `nvdisasm` | Read machine code back | my own sm_121 disassembler | BUILDING | bar C6: on Omega branch `c6/disasm` (19eebe0e, `evidence/C6-DISASM/` there) it agrees with `nvdisasm` on 331 kernels; not carried into CUDA++ yet, and some host tests here still call `nvdisasm` | | Nsight | Profiling | ceiling probes | PARTIAL | `evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/` (115.14 TFLOPS tensor-core peak, 195.1 GB/s reads), `evidence/OWN30B-LAUNCH-COST-20261014T0120Z/` | | CUDA samples and docs | First kernel, API reference | `examples/hello_gpu`, `docs/runtime/API.md` | PARTIAL | bar C2: hello-GPU from an empty folder on the GB10 + the zero-CUDA gate | | `nvidia.ko` | Kernel driver: GPU boot, memory, channels | AIEN's own GB10 driver (L332) | BUILDING | simulator gates PASS on `feat/own-gpu-driver` cd5eef7a (receipt `evidence/own-gpu-driver/rung1/gates-20261021T2158Z.txt` there); first chip window (window 0) prepared, not run | | `nvidia-uvm.ko` | Unified memory, page tables, faults | same driver: GPU page tables, allocator, channels (L193 cut D, L332) | BUILDING | host simulator, 225 checks PASS (aienos `feat/gb10-gpu-mmu-sim` bcc56506) | -| `nvidia-modeset.ko`, `nvidia-drm.ko` | Display | not needed for compute; dropped when our driver takes the GPU | MISSING | | +| `nvidia-modeset.ko`, `nvidia-drm.ko` | Display | not needed for compute; dropped when my driver takes the GPU | MISSING | | | `nvidia-smi`, NVML | Status, clocks, power | not started | MISSING | | -| GSP firmware (`gsp_*.bin`) | Runs inside the GPU | stays NVIDIA's: the chip checks its signature | not replaceable | our driver loads NVIDIA's signed file from the system's firmware folder; CUDA++ never ships it | +| GSP firmware (`gsp_*.bin`) | Runs inside the GPU | stays NVIDIA's: the chip checks its signature | not replaceable | my driver loads NVIDIA's signed file from the system's firmware folder; CUDA++ never ships it | -## 2. Bars before we say "replaces CUDA" +## 2. Bars before I say "replaces CUDA" From Omega `docs/OMEGA.md` section 3. Each needs a receipt on the exact commit; none is waived. @@ -33,7 +33,7 @@ From Omega `docs/OMEGA.md` section 3. Each needs a receipt on the exact commit; - **C3** any-shape GEMM in BF16 and FP8 (200+ shapes, 1 to 8192, each checked against a host reference, speed as a fraction of the measured tensor-core ceiling); reductions and prefix sums from 1 to 2^28 elements, bit-exact. - **C4** streams and events: two queues finish in under 0.75 of the sum of their solo times; an event wait orders two jobs, checked by data. - **C5** two processes share the GPU safely, and a kernel that never ends is timed out with the process still usable. -- **C6** our disassembler agrees with `nvdisasm` on every library kernel, and nothing calls `nvdisasm` any more. +- **C6** my disassembler agrees with `nvdisasm` on every library kernel, and nothing calls `nvdisasm` any more. ## 3. More than CUDA @@ -41,11 +41,32 @@ Things a CUDA stack does not do, because it does not own the whole path. Omega ` | Item | Why CUDA cannot | Status | | --- | --- | --- | -| One submission per generated word | CUDA launches go through the runtime and driver per kernel or per graph; we write the command list ourselves | PARTIAL: command lists exist (`src/omega_gpu_cmdlist.*`); extra launch in a list costs 24 to 31 us today with wait-for-idle (`evidence/OWN30B-LAUNCH-COST-20261014T0120Z/`) | +| One submission per generated word | CUDA launches go through the runtime and driver per kernel or per graph; I write the command list myself | PARTIAL: command lists exist (`src/omega_gpu_cmdlist.*`); extra launch in a list costs 24 to 31 us today with wait-for-idle (`evidence/OWN30B-LAUNCH-COST-20261014T0120Z/`) | | Resident whole-model kernel | needs control of scheduling and memory below the CUDA API | MISSING (AIEN L272) | | Zero-copy shared memory | the GB10's CPU and GPU share one memory; CUDA still stages through its own allocators | PARTIAL: weights shared between processes through the driver client (physics `feat/shared-mem` 82467f19, 1 GiB import in 171 ms; not yet in CUDA++ main) | -| Our own driver's launch path | CUDA's is fixed by NVIDIA | BUILDING (L332) | +| My own driver's launch path | CUDA's is fixed by NVIDIA | BUILDING (L332) | ## 4. Speed Speed is reported against the physical ceiling of this machine, not only against yesterday. The table and the ceilings are in Omega `docs/OMEGA.md` section 5; the head-to-head measurement against llama.cpp and vLLM on this Spark is bar P0 (AIEN L394, running). + +## 5. The developer bar: better to use than CUDA + +The research in `docs/PAIN_POINTS.md` ranks what developers hit with CUDA and its libraries, and why they stay. Each pain point becomes a row with a done-when anyone can run. The full table, with every row's mechanism and the counts behind its rank, is `docs/PAIN_POINTS.md` section 3; open rows have issue drafts in `docs/issues/`. + +| Row | Beats CUDA by | Status | +| --- | --- | --- | +| D1 | Memory you can see, and a refusal before the machine hangs | DONE on the host; chip run open | +| D2 | One command, one version: `make doctor`, then `make hello-gpu` | DONE | +| D3 | Faults named at the launch that caused them | DONE on the simulator; chip half open | +| D4 | The simulator first, from the same program: `hello_gpu --sim` | DONE | +| D5 | Builds in seconds, ships small | DONE (2.0 s, 1.06 MB) | +| D6 | A new chip works on day one or is refused with a sentence | DONE (the refusal) | +| D7 | Same inputs, same bits, at no cost | simulator DONE; chip open | +| D8 | No per-process CUDA tax | PLANNED (chip window) | +| D9 | No licence that stops you | DONE (`evidence/dx/pain-points/licence.txt`) | +| D10 | No compiling at run time | DONE for hello-gpu | +| D11 | Open libraries with an easy default path | PLANNED (L386, Omega bar C3) | +| D12 | Work per answer, against the machine's own ceiling | simulator DONE; chip open | +| D13 | Our own disassembler, in plain text | PLANNED (L386, Omega bar C6) | +| D14 | Recover from a fault without restarting | PLANNED (L386, Omega bar C5) | diff --git a/THIRD_PARTY.md b/THIRD_PARTY.md index d7f0a4c3..8b272407 100644 --- a/THIRD_PARTY.md +++ b/THIRD_PARTY.md @@ -22,7 +22,7 @@ Some comments in `src/` cite Mesa's open NVIDIA driver as the source of a hardwa opcodes and bit positions (`nak/sm70_encode.rs`), instruction latencies (`nak/sm120_instr_latencies.rs`), the QMD layout (`nak/qmd.rs`), reconvergence scopes (`nak_nir_lower_cf.c`), the compute dispatch and cache-invalidate sequence (`nvk_cmd_dispatch.c`), the shader-heap prefetch note (`nvk_device.c`), and -class method offsets (`clcec0.h`). The encoder, scheduler and command-list code in CUDA++ is our own; +class method offsets (`clcec0.h`). The encoder, scheduler and command-list code in CUDA++ is my own; the latency values used by `src/omega_gpu_elementwise_api.c` were taken from Mesa's tables. These Mesa files are MIT (checked 2026-10-21 at gitlab.freedesktop.org/mesa/mesa, branch main, first lines of each file): @@ -45,4 +45,4 @@ each file): by NVIDIA's kernel module from the system's own firmware folder; CUDA++ never ships it. - Some host tests print a listing through NVIDIA's `nvdisasm` when it happens to be installed, as a cross-check. No listing made by NVIDIA tools is stored in this repository (one such file was kept out - of the history at extraction, see `docs/AUDIT.md`). Our own disassembler is on the roadmap (C6). + of the history at extraction, see `docs/AUDIT.md`). My own disassembler is on the roadmap (C6). diff --git a/docs/AUDIT.md b/docs/AUDIT.md index f1463efa..fa67bf57 100644 --- a/docs/AUDIT.md +++ b/docs/AUDIT.md @@ -62,8 +62,8 @@ Kept out of the history (removed from every commit, listed in `tools/extract/ome - Every blob in both histories was checked for binary content (any zero byte): **0 binary files** after the exclusions above. - No firmware, no `libcuda`, no cubin, fatbin or PTX, no `.so`, `.o` or `.a`. -- No listing produced by NVIDIA tools (`nvdisasm`, `cuobjdump`) and nothing copied from NVIDIA's documentation. Some host tests call NVIDIA's `nvdisasm` at run time when it is installed, to cross-check our encoder; nothing it prints is stored. -- One CUDA C++ source remains in a receipt: `evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/fa_ops.cu`, our own probe kernel, used once with NVIDIA's compiler to measure the tensor-core ceiling we compare against. It is our code, not NVIDIA's. +- No listing produced by NVIDIA tools (`nvdisasm`, `cuobjdump`) and nothing copied from NVIDIA's documentation. Some host tests call NVIDIA's `nvdisasm` at run time when it is installed, to cross-check my encoder; nothing it prints is stored. +- One CUDA C++ source remains in a receipt: `evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/fa_ops.cu`, my own probe kernel, used once with NVIDIA's compiler to measure the tensor-core ceiling I compare against. It is my code, not NVIDIA's. ## 6. Limits of this audit diff --git a/docs/DRIVER.md b/docs/DRIVER.md new file mode 100644 index 00000000..83ceacca --- /dev/null +++ b/docs/DRIVER.md @@ -0,0 +1,80 @@ +# The driver client, call by call + +This is what replaces `libcuda`: `nvrm/nvrm.c` (about 900 lines) and the qualification programs in `m16/`. They talk to NVIDIA's open kernel module, version 580.173.02, through the ioctls its public headers define (`third_party/nvidia-open-580.173.02/`, MIT, unchanged). Line numbers below are for `nvrm/nvrm.c` on the commit that added this file. + +![The driver client's objects](img/driver-objects.svg) + +## The three device files + +| File | Opened by | Used for | +| --- | --- | --- | +| `/dev/nvidiactl` | `nvrm_open()` | The resource manager (RM): every object is created with `NV_ESC_RM_ALLOC`, configured with `NV_ESC_RM_CONTROL` and destroyed with `NV_ESC_RM_FREE`. | +| `/dev/nvidia` | `open_dev_fd()` (line 231), registered with `NV_ESC_REGISTER_FD` | CPU mappings of memory and of the usermode register page (`NV_ESC_RM_MAP_MEMORY`, then `mmap`). | +| `/dev/nvidia-uvm`, opened twice | `nvrm_open()` | The unified-memory driver, which owns the GPU page tables of the address space. | + +## 1. Open: `nvrm_open()` (line 293) + +In order: + +1. Reserve a slot of virtual addresses for this process, then open `/dev/nvidiactl` and `/dev/nvidia-uvm`. +2. `RM_ALLOC NV01_ROOT_CLIENT`: the root handle. Everything below hangs off it and is freed with it. +3. `UVM_INITIALIZE`, then `UVM_MM_INITIALIZE` on the second UVM file (a failure there is tolerated, as `libcuda` tolerates it). +4. `NV_ESC_CARD_INFO` lists the GPUs; take the first valid one and open its device file. +5. `RM_CONTROL NV0000_CTRL_CMD_GPU_GET_ID_INFO_V2` gives the device instance. +6. `RM_ALLOC NV01_DEVICE_0`, then `NV20_SUBDEVICE_0`, then `NV01_MEMORY_VIRTUAL` (the GPU address range). +7. `RM_CONTROL NV0080_CTRL_CMD_GPU_GET_CLASSLIST`, called twice (count, then list). The client looks for three classes and refuses to go on without them: `BLACKWELL_COMPUTE_B`, `BLACKWELL_CHANNEL_GPFIFO_A` and `HOPPER_USERMODE_A`. +8. `RM_ALLOC HOPPER_USERMODE_A` under the subdevice and map 64 KiB of it. The doorbell is the word at `NVC361_NOTIFY_CHANNEL_PENDING` inside that page. +9. `RM_CONTROL NV2080_CTRL_CMD_GR_GET_INFO` reads the SM version (sm_121 on the GB10). +10. `RM_ALLOC FERMI_VASPACE_A` with page faulting on and `IS_EXTERNALLY_OWNED`, so the unified-memory driver manages it. +11. `RM_CONTROL NV2080_CTRL_CMD_GPU_GET_GID_INFO` reads the GPU UUID, then `UVM_REGISTER_GPU` and `UVM_REGISTER_GPU_VASPACE` hand the GPU and the address space to UVM. + +## 2. Memory: `nvrm_alloc()` (line 546) and `nvrm_free()` (line 624) + +The GB10 has no separate video memory; the CPU and GPU share one LPDDR5X memory. Each buffer is: + +1. a range taken from the process's free list and reserved on the CPU side with `mmap(MAP_FIXED_NOREPLACE)`, so nothing else can land there; +2. `RM_ALLOC NV01_MEMORY_SYSTEM` (non-contiguous, PCI location, GPU-cacheable or not); +3. mapped for the CPU at exactly that address (`NV_ESC_RM_MAP_MEMORY` and `mmap`); +4. mapped for the GPU at the same address: `UVM_CREATE_EXTERNAL_RANGE`, `NV_ESC_RM_MAP_MEMORY_DMA`, `UVM_MAP_EXTERNAL_ALLOCATION` (line 498). + +So the CPU pointer and the GPU address of a buffer are the same number. Nothing is copied between a "host" and a "device" copy, because there is only one copy. + +`nvrm_alloc_gpu_uncached()` (line 554) makes the GPU skip its L2 cache for the buffer. Anything the CPU polls while the GPU writes it (completion markers, semaphores, the command ring) must be allocated this way; the platform contract refuses a host-polled buffer that is not (`src/omega_gpu_platform.h`). + +`nvrm_free()` undoes the four steps in reverse and returns the range to the free list. It refuses a stale or duplicate handle without calling the driver. If any step fails half way, the allocation is quarantined rather than reused, because the driver's state is then unknown. + +## 3. The channel: `nvrm_channel()` (line 695) + +1. `RM_ALLOC KEPLER_CHANNEL_GROUP_A` on the graphics/compute engine, then `FERMI_CONTEXT_SHARE_A` bound to the address space. +2. One GPU-uncached 64 KiB buffer holds the command ring (1,024 entries of 8 bytes) followed by its USERD control page; a 1 MiB buffer receives channel errors. +3. `RM_ALLOC BLACKWELL_CHANNEL_GPFIFO_A` with the ring, USERD and error buffer. +4. `RM_ALLOC BLACKWELL_COMPUTE_B` under the channel. This one allocation needs one free, physically contiguous 2 MiB block of host memory for the channel's context buffer. On a long-running host that block can be missing for a few hundred milliseconds, so `NV_ERR_NO_MEMORY` here, and only here, is retried: 50 times at 100 ms (`NVRM_CHANNEL_NO_MEMORY_RETRIES`, omega#523). Every other error is final at once. +5. `RM_CONTROL NVC36F_CTRL_CMD_GPFIFO_GET_WORK_SUBMIT_TOKEN`: the number the doorbell is rung with. +6. `UVM_REGISTER_CHANNEL` with 64 MiB of address space for the channel's context buffers, then `RM_CONTROL NVA06C_CTRL_CMD_GPFIFO_SCHEDULE` switches the channel on. + +## 4. Submitting work: `nvrm_enqueue()` (line 818) and `nvrm_ring()` (line 840) + +A ring entry is 8 bytes (`nvrm_gp_entry()`, line 810): the pushbuffer's GPU address in the low bits and its length in 32-bit words from bit 42. To submit: + +1. refuse if the ring would overrun entries that have not been seen to finish (Blackwell's USERD reports no read pointer, so the client counts: `put` and `retired`); +2. write the entry, `dsb sy`, write the new `GPPut` into USERD, `dsb sy`; +3. ring the doorbell: one 32-bit store of the work-submit token to the usermode page. + +There is no system call on this path. The pushbuffer itself is a list of method headers (`nvrm_mthd()` in `nvrm/nvrm.h`) and data words; what goes in it for a kernel launch is in `src/omega_gpu_cmdlist.c` and `src/omega_blackwell_submit.c`. + +## 5. Waiting: `m16/m16_gpu_wait.c` + +Completion is a word in GPU-uncached memory that the GPU writes with a semaphore release. The one wait primitive has two kinds (an exact value, or a counter that has reached a target, correct across wrap-around) and two bounds: a hard deadline that is never extended and a stall deadline that restarts only when a watched word changes. A memory barrier runs before every read. A wait that times out is reported as uncertain: the session then keeps every buffer and refuses all further GPU work in the process, because the GPU may still be running. + +## 6. Proof on the chip: `m16/` + +- `m16_requalify.c`: queue a semaphore release without ringing the doorbell and check the marker stays 0 for 100 ms; ring it and check the marker becomes `0x16c0ffee`; read `/proc/self/maps` to prove no `libcuda` was loaded. Receipt: `evidence/m16-blackwell-native-path-requalification-receipt.json`. +- `m16_concurrent.c`: two independent channels; ringing one never runs the other's work. +- `nvrm/lifecycle_gates.c`: `nvrm_free()` on the real chip (address reuse, stale and duplicate handles, CPU unmap) and the counter wait. +- `nvrm/submission_visibility_gates.c`: ring entries and rewritten command buffers published by the CPU are seen by the GPU on the second submission too (before the fix, the second submission stalled on the GB10). + +## 7. Above and below the client + +Above it, `src/omega_gpu_platform.h` is the contract the runtime is written against: typed handles instead of file descriptors, explicit rights and kinds for every buffer, polling named as polling, and no silent fallback. `src/omega_gpu_platform_linux.c` implements it on this client. AIEN's own GB10 driver (L332) implements the same contract without NVIDIA's kernel module. + +Below it, NVIDIA's open kernel module (`nvidia.ko`, `nvidia-uvm.ko`) does the rest: it boots the GPU's GSP firmware, builds page tables and schedules channels. The firmware stays NVIDIA's; the chip checks its signature. diff --git a/docs/HOW_I_DID_IT.md b/docs/HOW_I_DID_IT.md new file mode 100644 index 00000000..33fb6807 --- /dev/null +++ b/docs/HOW_I_DID_IT.md @@ -0,0 +1,65 @@ +# How I did it + +This is the whole method, including the reverse engineering, so anyone can check it, repeat it on another NVIDIA GPU, or do better. Every step below points at code or receipts in this repository. + +**Who:** me, Drake Stapleton, alone, directing AI coding agents as tools (Claude, Codex, Grok, Gemini; `docs/AUDIT.md` section 2). **Where:** one NVIDIA DGX Spark (GB10, sm_121, Linux, NVIDIA's open kernel module 580.173.02). **When:** the first native kernel ran on 2026-09-26; on 2026-10-21 a 35-billion-parameter model was serving on this code with zero CUDA libraries loaded. + +## The idea + +CUDA is several layers of NVIDIA software stacked on a GPU. Most of the layers are closed: the compiler (`nvcc`, `ptxas`), the driver library (`libcuda`) and the math libraries (cuBLAS, cuDNN). One layer is open: since 2022 NVIDIA publishes the source of its Linux kernel module (`open-gpu-kernel-modules`, MIT). The GPU itself runs whatever machine code it is handed. + +So I skipped every closed layer. CUDA++ talks to the open kernel module directly and hands the GPU machine code I write myself. Nothing NVIDIA ships above the kernel module is used at run time. + +``` + CUDA: your code -> nvcc/ptxas -> libcudart -> libcuda -> nvidia.ko -> GPU + CUDA++: your code -> my encoder -------> my runtime -----> nvidia.ko -> GPU +``` + +## Step 1. Talk to the kernel module without libcuda + +`libcuda` is a closed library, but everything it does to the hardware goes through ioctls on `/dev/nvidiactl`, `/dev/nvidia0` and `/dev/nvidia-uvm`, and the 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 (`nvrm/nvrm.c`, about 2,400 lines with `m16/`): + +1. open a resource-manager client, then the device and subdevice objects (classes `cl0000`, `cl0080`, `cl2080`); +2. create a GPU virtual address space and allocate memory, mapped for both CPU and GPU; +3. create a channel: a command ring (GPFIFO) and its control page (USERD), bound to the compute engine; +4. create the compute object (Blackwell's compute class); +5. write commands into the ring and ring the doorbell, a single store from user space; +6. wait for completion by polling a memory word the GPU writes. + +The headers say what each call takes. What they do not say I learned on the chip, and wrote down as rules with receipts. One example: a word the CPU polls while the GPU writes it must be mapped uncached for the GPU, or the CPU never sees it change. That stalled me once, on 2026-10-02, and the platform now refuses such a buffer (`docs/runtime/PORTABILITY.md`, `src/omega_gpu_platform.h`). The receipt that this path runs with no `libcuda` linked: `evidence/m16-blackwell-native-path-requalification-receipt.json`. + +## Step 2. Learn the machine code (the reverse engineering) + +NVIDIA does not publish the instruction encoding of its GPUs. Its public assembly language, PTX, is a virtual one; the real machine code (SASS) is undocumented. I worked it out from three sources and checked every result against the chip: + +1. **NVIDIA's own tools as an offline oracle.** I wrote small CUDA C++ probe kernels of my own, compiled them once with `nvcc 13.0.88 -arch=sm_121 -cubin`, and printed the machine code with `cuobjdump -sass`. Each instruction comes out as 16 bytes next to its mnemonic. Comparing kernels that differ in one detail (a register number, an immediate, a predicate, a modifier) shows which bits encode what. The source code says where this was done: `src/omega_blackwell_codegen.h`, `src/omega_blackwell_codegen.c`, `src/omega_blackwell_codegen_tc.c` and `src/omega_blackwell_codegen_qmma.h` cite the nvcc output they match. These tools are never run by CUDA++ itself; no NVIDIA listing or binary is stored in this repository (`docs/AUDIT.md` section 5). +2. **Mesa's open NVIDIA compiler.** Mesa's NAK compiler (MIT) encodes NVIDIA instructions for its Vulkan driver, so its source records many opcodes and bit positions (`nak/sm70_encode.rs`), instruction latencies (`nak/sm120_instr_latencies.rs`) and the launch descriptor layout (`nak/qmd.rs`). I cite it wherever I used a fact from it and copied no code (`THIRD_PARTY.md`). Where nvcc and NAK disagree for sm_121, I follow what nvcc emits and say so in a comment. +3. **The chip itself.** An encoding is only believed once the GPU runs it and gives the right answer. For arithmetic that is not exactly specified I ran probe kernels and fitted a model to the results: the tensor-core BF16 multiply-accumulate was characterised on 2,048 cases chosen to separate candidate models, until one model matched every output bit for bit (`tests/gpu_tc_probe_test.c`, `tests/bw_hmma_model.h`). The warp simulators the host tests run (`tests/bw_warp_sim*.h`) model the special-function unit the same way, flushing subnormals as the GB10 does. + +What came out of this: my own encoder and kernel builder (`src/omega_blackwell_encoder.c`, `src/omega_blackwell_codegen*.c`), 59 instruction kinds on virtual registers, a register allocator, and the launch descriptor (QMD) builder. Each instruction kind has golden words in the tests; when NVIDIA's `nvdisasm` happens to be installed, some host tests also feed my bytes to it and check it prints the instruction I meant (`tests/gpu_reconv_test.c`). Replacing that cross-check with my own disassembler is on the roadmap. + +The first kernel, vector add (`src/omega_blackwell_encoder.c`), is a fixed table of 32 instruction words checked bit for bit. The model's kernels are generated by the kernel builder. + +## Step 3. Launch work like the driver does + +A kernel launch on Blackwell is a short list of commands written into the channel ring: point at the code, hand over a launch descriptor (grid size, block size, registers, shared memory, constant buffer with the arguments), invalidate the right caches, fire. I took the order of those commands from Mesa's NVK Vulkan driver (`nvk_cmd_dispatch.c`, `nvk_cmd_buffer.c`) and the class method offsets from the open headers, built my own command lists (`src/omega_gpu_cmdlist.c`), and measured the result: about 24 to 31 microseconds per extra dependent launch (`evidence/OWN30B-LAUNCH-COST-20261014T0120Z/`). + +## Step 4. Build up, checking everything + +From there it is ordinary engineering with one rule: nothing counts until the chip agrees. Each piece has host tests (warp simulators, tensor-core models, refusal cases), mutation tests (a deliberately broken copy must fail), and a chip receipt on a named commit: + +- 2026-09-26: vector add qualified on the GB10; the first tensor-core matrix multiply code (M18). +- 2026-10-02: numerics closed on the chip (reductions, nine transcendental functions over all 2^32 inputs, 148 load and store kernels; `evidence/E1-CLOSURE/`). +- 2026-10-13: tensor-core peak measured at 115.14 TFLOPS and memory reads at 195.1 GB/s by my own probes (`evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/`). +- 2026-10-21: a 35B mixture-of-experts model served on this code, its words identical to an exact host reference, with zero CUDA libraries in the process. + +## What I did not do + +- I used no NVIDIA source code other than the open kernel module headers, and no NVIDIA binary. There is no `libcuda`, cubin, PTX or firmware in this repository or its history (`docs/AUDIT.md`). +- I did not take apart `libcuda`, `nvcc` or any other NVIDIA program. I ran NVIDIA's compiler and disassembler on my own small kernels and read what they printed. +- I did not touch the GPU's firmware. The GSP firmware is still NVIDIA's, loaded by NVIDIA's kernel module, and stays so: the chip checks its signature. +- I did not translate CUDA programs to run on other hardware. CUDA++ runs on NVIDIA GPUs, the ones people already paid for. + +## Do it on your GPU + +The same method works on any NVIDIA GPU the open kernel module supports. What changes per chip is listed in `docs/runtime/PORTABILITY.md`: the instruction encoding, the launch descriptor, the class numbers and the cache rules. Start with `examples/hello_gpu`, find the differences with the three sources above, and send the receipts. diff --git a/docs/PAIN_POINTS.md b/docs/PAIN_POINTS.md new file mode 100644 index 00000000..0208518a --- /dev/null +++ b/docs/PAIN_POINTS.md @@ -0,0 +1,429 @@ +# CUDA's pain points, and what CUDA++ does about them + +This is the research behind CUDA++'s developer bar (section 3). It asks two questions: what do people who use CUDA and its libraries actually run into, and why do they stay anyway? Then it turns the answers into rows anyone can check. + +Written 2026-10-22 for AIEN ledger item L400. Every outside claim has a numbered source at the end; every quote is copied word for word from the page and was checked against the saved page text by a script (section 5). Where CUDA is better today, section 4 says so. + +## 1. How this was done + +Sources: GitHub issues (PyTorch, vLLM, FlashAttention, FlashInfer, Triton, mamba, causal-conv1d, onnxruntime, bitsandbytes, ZLUDA, ROCm), NVIDIA's developer forums, the PyTorch forum, Hacker News, Reddit (r/LocalLLaMA, r/CUDA, r/MachineLearning, r/hardware), Stack Overflow, project blogs, NVIDIA's own documents and its filings. + +How often: each pain point has GitHub issue search counts (issues and pull requests whose text contains the phrase, all of GitHub, counted on 2026-10-22 between 00:18Z and 00:48Z). A count is a lower bound on how many people met the problem and wrote about it, not a count of people. Phrases overlap, so counts are not added up. The raw counts, the exact search URL of each and the time it ran are in `evidence/dx/pain-points/counts.json`; `tools/dx/recount.sh` runs them again. + +How badly: one of three levels. + +| Severity | Meaning | +| --- | --- | +| 3 | Work stops and the message points at the wrong place or the wrong cause, or the machine needs a power cycle. | +| 2 | Work stops with a clear cause, or it costs hours. | +| 1 | It costs time or money; work goes on. | + +Rank = reach (the largest single count for that pain point) times severity. This is a rough order, and it is written down so anyone can disagree with a number instead of with a feeling. + +Limits, said plainly: Reddit refused every automated read except its RSS feeds, so Reddit threads were read through RSS and carry no vote counts. Stack Overflow counts are small because most of these questions now live in GitHub issues and forums. Hacker News counts are story counts, not comment counts. + +## 2. The pain points, most people hurt first + +| Rank | Pain point | Reach (GitHub issues) | Severity | Score | CUDA++ row | +| --- | --- | --- | --- | --- | --- | +| 1 | Out of memory, and on the DGX Spark a frozen machine | 26,390 "CUDA out of memory" | 2 | 52,780 | D1 | +| 2 | The version and build matrix | 11,034 "TORCH_CUDA_ARCH_LIST" | 3 | 33,102 | D2 | +| 3 | Errors reported late, at the wrong call | 10,356 "CUDA_LAUNCH_BLOCKING" | 3 | 31,068 | D3, D4 | +| 4 | Builds take hours and ship gigabytes | 7,646 nvcc "compile time" | 2 | 15,292 | D5 | +| 5 | A new chip: "no kernel image is available" | 4,033 "no kernel image is available" | 3 | 12,099 | D6 | +| 6 | Different answers from the same inputs | 5,416 nondeterministic cuda | 2 | 10,832 | D7 | +| 7 | Memory and start-up cost of the CUDA context | 3,478 "CUDA context" memory overhead | 1 | 3,478 | D8 | +| 8 | Lock-in by licence | 2,902 ZLUDA | 1 | 2,902 | D9 | +| 9 | Compiling at run time, and hangs while it compiles | 517 "JIT compilation" hang cuda | 3 | 1,551 | D10 | +| 10 | Closed, model-shaped libraries | no single phrase | 2 | not scored | D11, D13 | +| 11 | The incentive: compute sold from data centers | not a bug report | 1 | not scored | D12 | + +The DGX Spark is not a separate row: its problems are rows 1, 2, 5 and 9 at their worst. 8,268 GitHub issues mention "DGX Spark". It gets its own part in section 2.12 because CUDA++ runs on it today. + +### 2.1 Out of memory, and on the Spark a frozen machine (rank 1) + +**What happens.** A job asks for more GPU memory than is free and stops with "CUDA out of memory". Usually the cause is real: the model does not fit. Two things make it worse than it has to be. PyTorch's caching allocator keeps freed memory for reuse, so the numbers people look at are wrong: "However, the unused memory managed by the allocator will still show as if used in nvidia-smi."[46] Fragmentation can make a job fail that would fit, and the fix is a tuning knob: "This can reduce fragmentation and may allow some borderline workloads to complete without running out of memory."[46] + +On the DGX Spark the CPU and GPU share one memory, and the failure is not an error message at all. A Spark owner wrote: "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."[2] On NVIDIA's forum: "I am experiencing a critical system-level freeze (hard-lock requiring power cycle) on the DGX Spark when running Gemma 4 at high memory utilization."[31] And: "The whole DGX Spark machine hangs completely—no mouse or keyboard response, nothing. no visual errors, no logs errors ."[32] + +**How often.** 26,390 GitHub issues contain "CUDA out of memory" and 12,124 contain "CUDA error: out of memory". Stack Overflow has 1,501 questions. The Spark freeze threads have 1,058 and 1,202 views[31][32]. + +**Why people stay.** Running out of memory happens on every GPU stack. Nobody leaves CUDA over it. + +**CUDA++'s answer (row D1).** CUDA++ has no caching allocator: every buffer is an explicit allocation you asked for, so what the process holds is what you allocated. What is missing is the part that matters on the Spark: refuse an allocation that would leave the machine without memory, with a sentence that says how much was asked, how much is free and what to do, before the kernel's out-of-memory killer or a hang. That is now built: the Linux platform refuses an allocation that would leave less than `CUDAPP_MEM_RESERVE_MIB` (default 4096) free, before the driver is called, and says so in one sentence. Status: DONE on the host (`evidence/dx/d1-memory/`); the chip run is open (`docs/issues/D1-memory.md`). + +### 2.2 The version and build matrix (rank 2) + +**What happens.** A CUDA program on Python sits on four version numbers that must agree: the kernel driver, the CUDA toolkit, the framework build (PyTorch's wheel is built for one CUDA version) and every extension built against both. A mismatch fails at import or later, often with a symbol name and no advice. Typical messages: "The detected CUDA version (12.0) mismatches the version that was used to compile PyTorch (11.7)" (the PyTorch forum thread with 10,462 views[40]), and "undefined symbol: _ZNK3c1010TensorImpl27throw_data_ptr_access_errorEv"[21]. Even finding the toolkit can fail: "However, CMake is unable to find the CUDA toolkit, even though it's installed and `nvcc` and `nvidia-smi` are working correctly."[94] The driver's "CUDA Version" is not the toolkit's version, which confuses people: "that value reflects the driver’s runtime capability , not the presence of the toolkit ."[35] + +Extensions ship one wheel per combination, so the wheel name itself is the matrix: FlashAttention prints "Precompiled wheel not found. Building from source..."[23] and a Reddit guide explains that two wheels match one setup and differ only in the C++ ABI flag, "cxx11abiFALSE" or "cxx11abiTRUE"[89]. Its maintainer said: "I don't know a right solution that works for all setups, happy to hear suggestions."[20] A vLLM user: "Please note here that we can't use precompiled vLLM because `vllm-project/vllm` has not moved to the required torch and CUDA versions yet."[15] And when it goes wrong quietly: "This causes a nightly to be silently installed, which fails at runtime due to an `undefined-symbol` error because `_C.abi3.so` fails at runtime."[15] + +Even the toolkit can change the answer. causal-conv1d records a "**numerical correctness bug** for sm_103 (B300): cubins built with CUDA 13.x nvcc for sm_103 produce wrong output"[5]. + +**How often.** 11,034 GitHub issues contain "TORCH_CUDA_ARCH_LIST" (the variable people set to build extensions for their GPU); 1,507 contain "CUDA driver version is insufficient"; 1,054 "not compatible with the current PyTorch installation"; 932 mention nvidia-smi's "CUDA Version" with a toolkit mismatch; 569 "detected CUDA version" mismatches. The Gaussian splatting install thread has 121 reactions[19], FlashAttention #246 has 84[20], vLLM #14452 has 44 reactions and 139 comments[15]. A forum post on the Spark: "getting a working CUDA toolkit (with nvcc ) turned into a trap maze."[35] + +**Why people stay.** The matrix is the price of the libraries, and the libraries are the reason to be there. A Reddit user on the Spark: "The funniest part is paying the NVIDIA tax specifically for CUDA compatibility and then not getting it."[88] Other stacks have the same matrix or a worse one (section 2.11). + +**CUDA++'s answer (row D2).** There is one version to match, and it is checked. CUDA++ uses no toolkit, no framework build and no extension build: the compiler, runtime and libraries are one repository at one commit, built by `make` with a C compiler. The only outside version is NVIDIA's kernel module, whose interface headers CUDA++ is built against (`third_party/nvidia-open-580.173.02/`). `make doctor` reads `/proc`, `/sys` and `/dev` (it opens no device) and prints one line per check; a wrong module version is refused with the reason and the fix, instead of failing later in a driver call. `make hello-gpu` runs the doctor first. Status: DONE (`evidence/dx/d2-doctor/`). + +### 2.3 Errors reported late, at the wrong call (rank 3) + +**What happens.** CUDA launches are asynchronous: "When you call a function that uses the GPU, the operations are enqueued to the particular device, but not necessarily executed until later."[46] So a bad memory access in one kernel is reported by some later, unrelated call: "an illegal memory access was encountered ... might be asynchronously reported at some other API call". vLLM's maintainers wrote: "In our experience the python stack traces for these types of exceptions are basically always incorrect and pretty worthless."[45] And: "Have you ever felt you are developing cuda kernels and your tests often run into illegal memory access (IMA for short) and you have no idea how to debug?"[45] + +After such a fault the whole context is gone. NVIDIA's forum moderator: "Pretty much all asynchronous errors (these are errors that occur as a result of device code execution) are sticky."[47] A developer in that thread: "My goal is to determine whether or not restart the executable, otherwise I will restart it for every cuda-related error, but it is a pity."[47] + +The tools for this are separate programs with their own gaps. compute-sanitizer "is hard to use in CI build farms that have a very strict network configuration"[48], and NVIDIA's own blog says the default mode misses bugs: "Compile-time instrumentation catches bugs that binary instrumentation misses, such as buffer overruns into neighboring allocated memory, while lowering runtime overhead in some cases by nearly an order of magnitude."[49] + +**How often.** 10,356 GitHub issues contain "CUDA_LAUNCH_BLOCKING" (the variable people set to make errors land at the right call); 7,833 contain "illegal memory access was encountered"; 6,812 "might be asynchronously reported"; 6,991 "compute-sanitizer"; 4,232 "device-side assert triggered"; 2,708 "cuda-gdb"; 1,883 "cudaErrorIllegalAddress". Stack Overflow: 166 questions on illegal memory access, 114 on CUDA_LAUNCH_BLOCKING. + +**Why people stay.** Every fast GPU stack runs work asynchronously, because waiting after each launch is slow. The debuggers exist, and people learn the environment variables. + +**CUDA++'s answer (rows D3 and D4).** Two parts. First, in CUDA++ a launch waits for its own completion by default (`omega_gpu_session_launch` is synchronous; command lists batch work on purpose), so an error comes back from the call that caused it, not a later one. Second, the same kernel program runs on CUDA++'s host warp simulator from the same program with one flag, and a bad access there is reported with the kernel, the launch, the instruction, the block and thread, the address and which buffer it missed and by how many bytes, plus the next command to run. What is not built: reading the GPU's own fault record (address and unit) from the driver after a fault on the chip, and recovering without ending the process (that is Omega bar C5, ledger L386). Status: DONE on the simulator (`evidence/dx/d3-faults/`); the chip half is open (`docs/issues/D3-chip-faults.md`). + +### 2.4 Builds take hours and ship gigabytes (rank 4) + +**What happens.** CUDA libraries are compiled once per GPU architecture and shipped together, so builds are slow and packages are huge. On FlashAttention: "For reference I just compiled it on a 2018 Dell laptop (Quadro P1000 GPU) and the build time was about 15 hours."[52] Another user: "Without both changes it defaulted to just using a single compilation job for me, taking forever (I gave up after an hour)."[52] On Reddit: "This cut my build time from 1+ hours to just under 15 minutes. Thank you!"[89] Building PyTorch for an older GPU: "It keeps crashing with the nvcc error out of memory, even after I've allocated over 0.75TB of vRAM on my SSD."[93] + +Sizes: "For example, recent manylinux2014 wheels for TensorFlow are 588 MB (wheels for 2.11.0 ), and for PyTorch those are 890 MB (wheels for 1.13.0 )."[53] PyPI's default limit is 100 MB per file[54], and projects wait in a queue for exceptions: "There are currently 34 other open limit request issues ahead of this one."[55] NVIDIA itself: "Docker images for ML and AI workloads are notoriously large, often exceeding 10 GB. Much of this comes from bundled GPU libraries for all possible architectures"[56]. On cuDNN, an NVIDIA employee: "We agree that the growth of the cuDNN DLL size is problematic, and we’re working on resolving this."[57] A user: "libcudnn.so.7 is over 200 MB in size!"[58] PyTorch had to drop older GPUs from its wheels: "Update: Option 2 is not a possible due to large binary size."[16] + +**How often.** 7,646 GitHub issues match nvcc "compile time"; 73 contain FlashAttention's "Precompiled wheel not found". + +**Why people stay.** Building once per architecture is what makes the code fast on each one; the cost lands on packagers and on whoever builds from source. + +**CUDA++'s answer (row D5).** CUDA++ builds from a clean checkout with `make` in a time and size printed by the build receipt, with no per-architecture copies, because kernels are generated for the chip the program runs on, in microseconds, when the program builds them (row D10). This is not a like-for-like comparison: CUDA++'s libraries cover far less than cuBLAS and cuDNN (section 4). Status: DONE: a fresh clone builds the library in 2.0 s wall on the Spark (20 cores, other builds running), giving a 1,060,126-byte `libcudapp.a` that needs no CUDA symbol (`evidence/dx/pain-points/d5-build-from-empty.txt`). + +### 2.5 A new chip: "no kernel image is available for execution on the device" (rank 5) + +**What happens.** A new GPU arrives and the libraries have no machine code for it yet. The error names no library, no kernel and no fix. It happened with the RTX 3090: "I am a skilled user of pytorch-gpu, recently I purchased an RTX 3090 server, but the bug with pytorch 1.7 and RT 3090 makes me mad."[11] With the RTX 5090: "NVIDIA GeForce RTX 5090 with CUDA capability sm_120 is not compatible with the current PyTorch installation."[14] With the 5070 Ti: "As a researcher, I purchased RTX 5070 Ti for deep learning workloads, but currently it cannot be used productively with DLC due to this gap."[13] "Users are forced to either build PyTorch from source or use experimental nightly builds with limited platform support."[12] Some patch it themselves: "PyTorch doesn’t support sm_120 or the RTX 5080 out of the box. So I patched it."[96] + +On the DGX Spark (sm_121) it happens across the stack. mamba-ssm ships wheels for older chips only ("pip install mamba-ssm # installs prebuilt wheel for sm_75-sm_90"[4]); causal-conv1d "does not ship prebuilt wheels for **sm_121** (GB10 / DGX Spark / Project DIGITS). Users must compile from source."[5] FlashInfer: "the mixed path still dies at routing time because a prebuilt, SM100-only `moe_utils` artifact takes precedence over the local JIT build."[6] FlashAttention: "FATAL: kernel built for sm80-sm100, but running on sm121"[9]. Triton's bundled assembler did not know the chip: "ptxas-blackwell fatal : Value ‘sm_121a’ is not defined for option ‘gpu-name’"[33], and "Setting TRITON_PTXAS_PATH doesn’t help - Triton ignores it in newer versions and uses its bundled ptxas which doesn’t support sm_121a."[34] NVIDIA's own model did not run on NVIDIA's own box: "Conclusion: Nemotron 3 Nano 30B currently cannot run on DGX Spark via SGLang due to Triton’s lack of sm_121a support."[34] + +The workarounds can be worse than the error. In Triton's sm_121 issue: "Those \"fixes\" produce a kernel that loads and then computes wrong numbers, which is so much worse than a clean \"no kernel image\" crash."[8] And a stale cache: "a warm `~/.triton/cache` populated on an `sm_120` box (or an earlier toolchain) gets reused on `sm_121` and silently miscompiles instead of rebuilding."[8] + +**How often.** 4,033 GitHub issues contain "no kernel image is available" (115 in PyTorch, 115 in vLLM, 20 in bitsandbytes, 18 in FlashInfer, 16 in FlashAttention); 600 contain "cudaErrorNoKernelImageForDevice"; 458 "sm_120 is not compatible"; 1,508 "ptxas fatal". 5,803 mention "sm_121" and 1,683 "sm_121a". PyTorch #31285 has 92 reactions and 78 comments[10]. + +**Why people stay.** The wait is weeks or months, and then it works. On the Spark forum: "It took several weeks of community effort here to get vllm working reasonably well, in both standalone and cluster configuration."[28] From the Spark Reddit thread: "Very frustrating compared to most every other GPU release that has zero day support from cuda/nvcc/pytorch/tensorflow."[88] + +**CUDA++'s answer (row D6).** CUDA++ writes each chip's machine code itself, so it knows exactly which chips it has run on: a table of qualified chips, each with its receipt. A chip in the table works. Any other NVIDIA GPU is refused by `make doctor`, by name and PCI id, with what is missing (a target row, an encoder check, the launch descriptor and class numbers, a qualification run) and what to do (the porting steps in `docs/runtime/PORTABILITY.md` section 5). Nothing loads code built for a different chip, and nothing is cached across chips. CUDA is better here today in one way: it runs on many chips; CUDA++ runs on one (section 4). Status: DONE for the refusal (`evidence/dx/d2-doctor/fake-machines.txt`). + +### 2.6 Different answers from the same inputs (rank 6) + +**What happens.** Fast GPU code often adds numbers in whatever order threads finish, and floating-point addition depends on order. PyTorch's documentation: "Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms."[50] cuBLAS's documentation: "In that case, the results are not guaranteed to be bit-wise reproducible because atomics are used for the computation."[51] Getting the same bits needs an environment variable with a cost: "set a debug environment variable CUBLAS_WORKSPACE_CONFIG to :16:8 (may limit overall performance) or :4096:8 (will increase library footprint in GPU memory by a"[51] + +**How often.** 5,416 GitHub issues match nondeterministic cuda; 1,117 contain "CUBLAS_WORKSPACE_CONFIG"; 526 "use_deterministic_algorithms". + +**Why people stay.** For training, small differences rarely matter, and speed does. + +**CUDA++'s answer (row D7).** CUDA++'s reductions use a fixed order (`evidence/E1-CLOSURE/`), so the same inputs give the same bits without a switch and without a cost to turn off. The row is done when two runs of the same job give the same output hash on the simulator and on the chip. Status: DONE on the simulator (`evidence/dx/d3-faults/hello-sim-spark.txt`, the same output hash twice); the chip half is open. + +### 2.7 Memory and start-up cost of the CUDA context (rank 7) + +**What happens.** Every process that uses CUDA loads the CUDA libraries and creates a context, which costs memory per process. On a Spark: "The CUDA tax, which is 4.6 GB approximately per each model on a DGX spark."[91] Kernels shipped as PTX are compiled when the context starts: "This JIT compilation can cause delay at application start-up time (or more accurately, CUDA context creation time)."[59] + +**How often.** 3,478 GitHub issues match "CUDA context" memory overhead. + +**Why people stay.** It is a fixed cost per process, small next to a large model on a large GPU. + +**CUDA++'s answer (row D8).** A CUDA++ process maps no CUDA library at all: on 2026-10-21 AIEN's live 35B server 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`). The row is done when the memory a CUDA++ process holds beyond its own buffers is measured and printed. Status: PLANNED (needs a chip window; section 3, D8). + +### 2.8 Lock-in by licence (rank 8) + +**What happens.** NVIDIA's CUDA licence forbids using CUDA's output on other hardware through translation: "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."[63] Tom's Hardware: "Nvidia has banned running CUDA-based software on other hardware platforms using translation layers in its licensing terms listed online since 2021, but the warning previously wasn't included in the documentation placed on a host system during the installation process."[64] It read the clause as aimed at ZLUDA: "The restriction appears to be designed to prevent initiatives like ZLUDA, which both Intel and AMD have recently participated, and, perhaps more critically, some Chinese GPU makers from utilizing CUDA code with translation layers."[64] + +ZLUDA itself ("ZLUDA is a drop-in replacement for CUDA on non-NVIDIA GPUs."[67]) lost its code once, though not to NVIDIA: "AMD's legal team appears to have clawed back control of much of the ZLUDA project's code base."[65] The developer: "The code was released with AMD's approval through an email. AMD's legal department now says it's not legally binding, hence the rollback."[66] On r/LocalLLaMA: "I hope someone is working on hardware agnostic solutions, we need more GPUs, not less."[95] A user at the time: "But since its amd shooting its own foot this project will likely not survive this setback."[68] + +**How often.** 2,902 GitHub issues mention ZLUDA; 89 Hacker News stories; the r/LocalLLaMA thread on the licence change is titled "CUDA Crackdown: NVIDIA's Licensing Update targets AMD and blocks ZLUDA". + +**Why people stay.** The clause targets other hardware. People who stay on NVIDIA hardware are not affected by it, and that is the point: it keeps the software where the hardware is. + +**CUDA++'s answer (row D9).** CUDA++ is MIT. Reverse engineering CUDA++'s output, translating it, and porting CUDA++ to any hardware, NVIDIA or not, are all allowed and welcome, and `CONTRIBUTING.md` says so. CUDA++ uses no NVIDIA licensed software at run time and stores no NVIDIA binary (`docs/AUDIT.md`). One thing stays NVIDIA's: the GPU's signed firmware, because the chip checks its signature. Status: DONE (receipt in section 3, D9). + +### 2.9 Compiling at run time, and hangs while it compiles (rank 9) + +**What happens.** Many libraries compile kernels the first time they are used: FlashInfer's default package "compiles/downloads kernels on first use"[60], Triton tunes and compiles at start ("Some users had expressed a desire to cache autotune results, both to speed up local iteration, and to avoid re-tuning when scaling up to large numbers of GPUs."[62]). This can hang: "Worker 0 completes compilation (172s) but workers 1-7 hang indefinitely."[61] On the Spark it took the GPU down: "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`."[2] Caches need care: "Insufficient cache size or a cache stored on a slow network share can cause long application start-up times"[59]. + +**How often.** 517 GitHub issues match "JIT compilation" hang cuda. Low count, high cost: the Spark report calls it "the finding that cost the most power cycles"[2]. + +**Why people stay.** Compiling for the exact shape is how these libraries get their speed. + +**CUDA++'s answer (row D10).** CUDA++'s kernel builder runs in the program's own process, takes microseconds, has no cache directory and no outside compiler to call, and produces the same bytes every time for the same kernel. The row is done when hello-gpu prints its kernel build time and the hash of the machine code, the same on every run. Status: DONE for hello-gpu: built in tens of microseconds (22 and 23 us in the receipt), the same machine-code hash on every run (`evidence/dx/d3-faults/hello-sim-spark.txt`). + +### 2.10 Closed, model-shaped libraries + +**What happens.** cuBLAS, cuDNN and the layers above them are closed. When they are slow or wrong for a shape, nobody outside NVIDIA can see why. Modular's Chris Lattner: "PTX is only partially documented, constantly shifting between hardware generations, and effectively a black box for developers."[76] And: "CUDA doesn’t provide performance portability across NVIDIA’s own hardware generations, and the sheer scale of its libraries is a double-edged sword."[76] On the Spark, FlashInfer's own audit found "**SM121 falls through to cutlass/cudnn only.**"[7] Users find the hardware's features unreachable: "Just be careful when buying a DGX Spark. You are not really getting a modern CUDA experience."[88] And the playbooks: "many of their official playbooks are broken and can’t be run as-is on the latest versions."[88] Closed code also hides behaviour: a Reddit thread found NVIDIA's FP8 path ran faster when a kernel's name contained "cutlass", and one reply put the risk plainly: "Even worse, if someone accidentally created a kernel with "cutlass" in the name, the driver would apply optimizations that are not safe."[92] + +**Why people stay.** The closed libraries are fast for the common shapes, and the easy path is the default: "With a design like Cuda where there is always a default easy path, and a complex but optional path."[77] tinygrad's pitch puts the flywheel plainly: "By being the dominant player, green team gets a whole ecosystem of developers to improve the developer experience for them."[78] + +**CUDA++'s answer (rows D11 and D13).** Every CUDA++ library is source in this repository, generated by the same kernel builder you can call, with host tests and a simulator. What is missing is breadth: CUDA++'s matrix multiply and attention are shaped for the models AIEN runs; any-shape GEMM, scans and sorts are Omega bar C3, and our own disassembler is bar C6 (ledger L386). Status: PLANNED (L386). + +### 2.11 Why people cannot leave + +Three reasons come up again and again. + +1. **The other stacks are worse today.** On ROCm: "If you want to know why everyone is going with Nvidia, there are a lot of them, but what they do at least well is they support they GPUs."[69] "I'm a long-time CUDA developer looking to explore ROCm and HIP development, but finding out which hardware even supports these tools is harder than it needs to be"[70]. In 2026, on a new AMD part: "We ran 93+ autonomous ML training experiments on a Strix Halo system (Radeon 8060S, gfx1151) using TheROCk nightly PyTorch and discovered 5 critical bf16 bugs, an undocumented 19x attention speedup, and several ecosystem gaps that prevent consumer AMD GPUs from being viable ML research platforms."[71] George Hotz: "AMD is structurally incapable of fixing these issues. They don't even have a 7900XTX in CI."[72] 17,774 GitHub issues contain ROCm "not supported". +2. **New work lands on CUDA first.** "On CUDA just runs of course with sliding window attention, ALiBi, and PagedAttention. ROCm fork? Nope."[74] "One of the biggest complaints we hear from the industry is \"we tried to port to X and we could never complete it\"."[79] And from a developer whose company tried: "i literally worked at a company where we dropped HIP support, and just went all in on nvidia."[95] +3. **The bar for an alternative is that it just works.** "you have to be able to pip install something and just have it work, reasonably fast, without crashing, and also it has to not interfere with 100 other weird poorly maintained ML library dependencies."[75] And people paid for the hardware: "To me it seems like you're paying more than twice the price mostly for CUDA compatibility."[44] + +So CUDA++ does not ask anyone to change hardware. It runs on the NVIDIA GPU people already own, and it has to beat CUDA on that GPU, row by row. + +### 2.12 The DGX Spark + +The Spark is a small machine sold as a way into NVIDIA's data-center stack. A Reddit user: "You design and validate them locally on the spark, running the exact same software, then push to the data center full of Nvidia GPU racks."[90] Its owners hit rows 1, 2, 5 and 9 at once. One report sums it up: "The published Docker images do not carry sm_121a kernels, a missing environment variable silently breaks the NVFP4 MoE, and a deep-context request with speculative decoding will hard hang the entire machine."[1] "Without it the NVFP4 MoE CUTLASS kernels are not built for GB10 and you get CUDA error: no kernel image is available for execution on the device ."[1] On NVIDIA's forum: "How many times have you tried to run something that doesn’t recognize SM121 and fails?"[28] "As of today, FP4 is not properly utilized in current VLLM builds on our hardware, so you lose a lot of performance picking NVFP4 quants compared to AWQ 4-bit on"[29] (that thread has 16,907 views). An owner of two Sparks: "It was not marketed like an experimental dev kit where buyers should expect to spend months switching backends, testing builds, setting flags, and relying on community or hardcore fan fixes just to make a core feature work properly."[97] Simon Willison: "I eventually managed to get a PyTorch 2.7 wheel for CUDA on ARM, but failed to do so for 2.8."[41] One honest counterpoint from PyTorch's maintainer: "Every PyTorch build with CUDA 12.8 and sm_120 support already supports sm_121 (DGXSpark) as these architectures are binary compatible."[38] The Spark's memory bandwidth is also a hard physical limit no software fixes: "the unified memory is LPDDR5x, offering up to 273 GB/s , shared across both CPU and GPU."[42] + +CUDA++ runs on the Spark today: AIEN serves a 35-billion-parameter model on it with no CUDA library loaded (README). + +### 2.13 The incentive, and less computation + +NVIDIA earns almost all its money from data centers. In its second quarter of fiscal 2027: "Data Center revenue of $89.0 billion, up 117% from a year ago"[85], out of "revenue for the second quarter ended July 26, 2026, of $96.2 billion"[85]: 92.5% of revenue. For fiscal 2025 the annual report gives data center revenue of $115,186 million out of $130,497 million[87], 88.3%. A company paid by the amount of compute it sells in data centers has no reason to make a small machine you own do the same work with less. + +People notice. "Nvidia uses VRAM amount for market segmentation. They can't make a 128GB consumer card without cannibalizing their enterprise sales."[82] "Sure, Nvidia gives for \"free\" their software stack.... as long as you use it on their products."[90] The counter-argument is real too: "There is no math that will make local models come out ahead in $/intelligence/token."[83] and "At $20/month for a cloud AI subscription, you’re looking at almost 30 years of service for the same money."[84] People still want local compute for reasons money does not cover: "The point of local models is privacy, offline use, and maybe no guard rails."[83] + +**CUDA++'s answer (row D12).** Measure the work, not the hardware. Every CUDA++ result prints the work it took: bytes moved, operations, and the time those need at this machine's own measured ceiling (195.1 GB/s reads and 115.14 TFLOPS tensor-core peak on the GB10, `evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/`). Less work per answer is the goal, so the number is always in front of the developer. Status: DONE on the simulator (`evidence/dx/d3-faults/hello-sim-spark.txt`); the measured GPU time next to it needs a chip run. + +## 3. The developer bar: D1 to D14 + +Each row has a done-when anyone can run. A row is DONE only with a receipt on a named commit. PLANNED rows name the ledger item that owns them. The aim is to beat CUDA, not to copy it. + +| Row | Beats CUDA by | Done when | Status | +| --- | --- | --- | --- | +| D1 | Memory you can see, and a refusal before the machine hangs | An allocation that would leave less than the reserve free on a unified-memory GPU is refused with a sentence naming the bytes asked, the bytes free and what to do; a host test drives it with a fake `/proc/meminfo`; the chip run shows the live budget | DONE on the host (`evidence/dx/d1-memory/`); chip run open | +| D2 | One command, one version | From an empty folder with only git, make and gcc: `make doctor` prints READY or names each problem with its fix; `make hello-gpu` runs the doctor first; a wrong kernel-module version is refused with a sentence; host test of 9 fake machines | DONE (`evidence/dx/d2-doctor/`) | +| D3 | Faults named at the cause | A bad access is reported at the launch that caused it with the kernel, launch number, instruction, block, thread, address, the buffer it missed and by how much, and the next command; `hello_gpu --sim --bug=past-end` shows it; a host test checks every field | DONE on the simulator (`evidence/dx/d3-faults/`); chip half open | +| D4 | The simulator first, from the same program | `hello_gpu --sim` runs the same kernel program on the host warp simulator and checks every answer bit for bit, with no GPU | DONE (`evidence/dx/d3-faults/`) | +| D5 | Builds in seconds, ships small | Fresh-checkout build time and library size printed by a receipt on the Spark | DONE (`evidence/dx/pain-points/d5-build-from-empty.txt`) | +| D6 | A new chip works on day one or is refused with a sentence | `make doctor` names any unqualified NVIDIA GPU with what is missing and the porting steps; never a bare "no kernel image"; host test with an unknown PCI id | DONE (`evidence/dx/d2-doctor/fake-machines.txt`) | +| D7 | Same inputs, same bits, at no cost | Two runs of the same job give the same output hash, on the simulator and on the chip | simulator half DONE; chip half open | +| D8 | No per-process CUDA tax | The memory a CUDA++ process holds beyond its own buffers is measured and printed | PLANNED (needs a chip window) | +| D9 | No licence that stops you | MIT; CONTRIBUTING.md welcomes reverse engineering of CUDA++'s output and ports to any hardware; no NVIDIA binary stored (AUDIT.md) | DONE (receipt `evidence/dx/pain-points/licence.txt`) | +| D10 | No compiling at run time | hello-gpu prints its kernel build time and the hash of its machine code, identical across runs; no cache directory | DONE for hello-gpu | +| D11 | Open libraries with an easy default path | Any-shape GEMM, reductions, scans, sorts in source with host references | PLANNED (L386, Omega bar C3) | +| D12 | Work per answer, against the machine's own ceiling | Every example prints bytes moved, operations and the floor time at the measured ceiling; with a chip window, the measured time next to it | simulator half DONE; chip half open | +| D13 | Our own disassembler, plain text a person can read | Disassembler agrees with nvdisasm on every library kernel; nothing calls nvdisasm | PLANNED (L386, Omega bar C6) | +| D14 | Recover from a fault without restarting | A kernel that faults or never ends is stopped and the same process keeps working | PLANNED (L386, Omega bar C5) | + +The swap story, replacing a developer's CUDA libraries and NVIDIA's kernel module with CUDA++'s, is ledger item L401. NVIDIA's kernel driver itself is being replaced by AIEN's own (L332, `ROADMAP.md`). + +## 4. Where CUDA is better today + +Said as plainly as the wins: + +- **Chips.** CUDA runs on every NVIDIA GPU of the last decade. CUDA++ runs on one, the GB10. Row D6 makes the refusal honest; it does not add chips. Porting is the community's job as much as ours (`CONTRIBUTING.md`). +- **Libraries.** cuBLAS, cuDNN, NCCL, cuFFT, cuRAND, CUTLASS and the whole ecosystem above them. CUDA++ has matrix multiply and attention shaped for the models AIEN runs, and no FFT, random numbers or multi-GPU (`ROADMAP.md`). +- **Languages and frameworks.** PyTorch, JAX, Triton and every framework speak CUDA. CUDA++ today is a C kernel builder; Omega's languages reaching the GPU is Omega bar C1 (L386). +- **Asynchronous work.** CUDA's streams overlap independent work. CUDA++'s launches are synchronous by default and its command lists are the way to batch; streams and events are Omega bar C4. +- **Tools.** Nsight, cuda-gdb and compute-sanitizer are mature. CUDA++ has a simulator and receipts, and no profiler GUI. +- **Speed across the board.** CUDA++ is measured against this machine's ceiling, and the head-to-head with llama.cpp and vLLM on the Spark is AIEN item L394. Until it lands, no speed claim against CUDA is made here. + +## 5. Checking this document + +The citation ledger (`evidence/dx/pain-points/ledger.json`) maps each [n] to its URL and holds the verbatim quotes. Each quote was accepted only if it appears in the saved text of the page. The script and the command: + +``` +python3 sources.py --ledger evidence/dx/pain-points/ledger.json verify docs/PAIN_POINTS.md --evidence +``` + +`sources.py` is the grounded-citations script used by AIEN's agents (MIT); a copy is in `tools/dx/sources.py`. + +## Sources + +[1] https://github.com/sudoingX/dgx-spark-laguna — sudoingX/dgx-spark-laguna README + > "The published Docker images do not carry sm_121a kernels, a missing environment variable silently breaks the NVFP4 MoE, and a deep-context request with speculative decoding will hard hang the entire machine." + > "Without it the NVFP4 MoE CUTLASS kernels are not built for GB10 and you get CUDA error: no kernel image is available for execution on the device ." +[2] https://github.com/sudoingX/dgx-spark-laguna/blob/main/FINDINGS.md — dgx-spark-laguna FINDINGS.md + > "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." + > "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`." + > "The published `vllm/vllm-openai:cu129-nightly` image resolves to `0.23.1rc1.dev`, not 0.25.1, and its kernels are not built for `sm_121a`." +[4] https://github.com/state-spaces/mamba/issues/1019 — No prebuilt wheels for sm_103 (B300) and sm_121 (GB10) + > "pip install mamba-ssm # installs prebuilt wheel for sm_75-sm_90" +[5] https://github.com/Dao-AILab/causal-conv1d/issues/119 — No prebuilt wheels for sm_121 (GB10 / DGX Spark) + > "`causal-conv1d` does not ship prebuilt wheels for **sm_121** (GB10 / DGX Spark / Project DIGITS). Users must compile from source." + > "Additionally, issue #105 documents a **numerical correctness bug** for sm_103 (B300): cubins built with CUDA 13.x nvcc for sm_103 produce wrong output (max_abs_diff ~0.4-0.6)." +[6] https://github.com/flashinfer-ai/flashinfer/issues/5238 — [Bug] SM121 (DGX Spark GB10): mixed mxfp8 x mxfp4 fused MoE dies in moe_sort routing with "no kernel image is available" + > "the mixed path still dies at routing time because a prebuilt, SM100-only `moe_utils` artifact takes precedence over the local JIT build." +[7] https://github.com/flashinfer-ai/flashinfer/issues/3170 — DGX Spark (SM121) Current Support Audit + > "**SM121 falls through to cutlass/cudnn only.**" +[8] https://github.com/triton-lang/triton/issues/10331 — Docs: bring-up recipe for Triton on NVIDIA Blackwell sm_121 (GB10 / DGX Spark / consumer Blackwell) + > "I was unable to find an authoritative doc page or pinned issue with the correct bring-up steps, and the workarounds that surface in search results actively make things worse" + > "Those "fixes" produce a kernel that loads and then computes wrong numbers, which is so much worse than a clean "no kernel image" crash." + > "a warm `~/.triton/cache` populated on an `sm_120` box (or an earlier toolchain) gets reused on `sm_121` and silently miscompiles instead of rebuilding." +[9] https://github.com/Dao-AILab/flash-attention/issues/1969 — Support for compute capability 12.1 (sm121) - NVIDIA GB10 GPU + > "Building from source fails with kernel mismatch: "FATAL: kernel built for sm80-sm100, but running on sm121"" + > "Minimum and Maximum cuda capability supported by this version of PyTorch is + (8.0) - (12.0)" +[10] https://github.com/pytorch/pytorch/issues/31285 — Cuda error: no kernel image is available for execution on the device + > "But starting from 1.3.1, we start to compile binaries only for arch 3.7 and up." +[11] https://github.com/pytorch/pytorch/issues/49161 — RuntimeError: CUDA error: no kernel image is available for execution on the driver, when use pytorch 1.7 on linux with R + > "I am a skilled user of pytorch-gpu, recently I purchased an RTX 3090 server, but the bug with pytorch 1.7 and RT 3090 makes me mad." +[12] https://github.com/pytorch/pytorch/issues/159207 — Add official support for CUDA sm_120 (RTX 5090 / Blackwell architecture) + > "Users are forced to either build PyTorch from source or use experimental nightly builds with limited platform support." +[13] https://github.com/pytorch/pytorch/issues/164342 — Official support for sm_120 (RTX 50-series / Blackwell) in stable PyTorch builds + > "As a researcher, I purchased RTX 5070 Ti for deep learning workloads, but currently it cannot be used productively with DLC due to this gap." +[14] https://github.com/vllm-project/vllm/issues/13306 — [Feature]: Support for RTX 5090 (CUDA 12.8) + > "NVIDIA GeForce RTX 5090 with CUDA capability sm_120 is not compatible with the current PyTorch installation." +[15] https://github.com/vllm-project/vllm/issues/14452 — [Doc]: Steps to run vLLM on your RTX5080 or 5090! + > "Please note here that we can't use precompiled vLLM because `vllm-project/vllm` has not moved to the required torch and CUDA versions yet." + > "This causes a nightly to be silently installed, which fails at runtime due to an `undefined-symbol` error because `_C.abi3.so` fails at runtime." +[16] https://github.com/pytorch/pytorch/issues/157517 — [release 2.8-2.9] Delete support for Maxwell, Pascal, and Volta architectures for CUDA 12.8 and 12.9 builds + > "Update: Option 2 is not a possible due to large binary size." +[19] https://github.com/graphdeco-inria/gaussian-splatting/issues/332 — Error installation of diff-gaussian-rasterization and found solution + > "I followed the README and the video at https://www.youtube.com/watch?v=UXtuigy_wYc but i fell in a slump for a few hours due to persistent errors in installing as suggested." +[20] https://github.com/Dao-AILab/flash-attention/issues/246 — No Module Named 'torch' + > "I don't know a right solution that works for all setups, happy to hear suggestions." +[21] https://github.com/Dao-AILab/flash-attention/issues/451 — Flash Attention 2.0 doesn't work: undefined symbol: _ZNK3c1010TensorImpl27throw_data_ptr_access_errorEv + > "undefined symbol: _ZNK3c1010TensorImpl27throw_data_ptr_access_errorEv" +[23] https://github.com/Dao-AILab/flash-attention/issues/1799 — Problems with the installation of flash_attn with pytorch 2.8.0+cu128 + > "Precompiled wheel not found. Building from source..." +[28] https://forums.developer.nvidia.com/t/what-a-missed-opportunity-for-nvidia/353585 — What a missed opportunity for nvidia + > "How many times have you tried to run something that doesn’t recognize SM121 and fails?" + > "It took several weeks of community effort here to get vllm working reasonably well, in both standalone and cluster configuration." +[29] https://forums.developer.nvidia.com/t/psa-state-of-fp4-nvfp4-support-for-dgx-spark-in-vllm/353069 — PSA: State of FP4/NVFP4 Support for DGX Spark in VLLM + > "As of today, FP4 is not properly utilized in current VLLM builds on our hardware, so you lose a lot of performance picking NVFP4 quants compared to AWQ 4-bit ones." +[31] https://forums.developer.nvidia.com/t/gemma-4-on-dgx-spark-gb10-system-freeze-at-80-utilization-sm-121-kernel-issues/366060 — Gemma 4 on DGX Spark (GB10): System Freeze at >80% Utilization & sm_121 Kernel Issues + > "I am experiencing a critical system-level freeze (hard-lock requiring power cycle) on the DGX Spark when running Gemma 4 at high memory utilization." + > "Official aarch64 images (e.g., vllm-openai:latest ) lacks sm_121 targets in their prebuilt binaries, defaulting to sm_120 , which causes decoding errors or crashes." +[32] https://forums.developer.nvidia.com/t/my-dgx-spark-hangs-is-this-normal/365930 — My DGX Spark Hangs ... is this normal? + > "The whole DGX Spark machine hangs completely—no mouse or keyboard response, nothing. no visual errors, no logs errors ." +[33] https://forums.developer.nvidia.com/t/running-llama-3-1-8b-fp4-get-triton-error-value-sm-121a-is-not-defined-for-option-gpu-name/348808 — Running Llama-3.1-8B-FP4 get triton error. Value 'sm_121a' is not defined for option 'gpu-name' + > "ptxas-blackwell fatal : Value ‘sm_121a’ is not defined for option ‘gpu-name’" +[34] https://forums.developer.nvidia.com/t/help-running-nemotron-3-nano-30b-a3b-fp8-on-dgx-spark-gb10/354771 — Help running Nemotron 3 Nano 30B-A3B-FP8 on DGX Spark (GB10) + > "Conclusion: Nemotron 3 Nano 30B currently cannot run on DGX Spark via SGLang due to Triton’s lack of sm_121a support." + > "Update 2: Setting TRITON_PTXAS_PATH doesn’t help - Triton ignores it in newer versions and uses its bundled ptxas which doesn’t support sm_121a." +[35] https://forums.developer.nvidia.com/t/dgx-spark-cuda-install-pitfalls-on-ubuntu-24-04-arm64-fixed/349881 — DGX Spark: CUDA Install Pitfalls on Ubuntu 24.04 (ARM64) – FIXED + > "getting a working CUDA toolkit (with nvcc ) turned into a trap maze." + > "that value reflects the driver’s runtime capability , not the presence of the toolkit ." +[38] https://discuss.pytorch.org/t/dgx-spark-gb10-cuda-13-0-python-3-12-sm-121/223744 — DGX Spark GB10 Cuda 13.0 Python 3.12 SM_121 + > "FATAL: kernel fmha_cutlassF_f16_aligned_64x128_rf_sm80 is for sm80-sm100, but was built for sm121" + > "i simply cannot believe GB10 is that slow in Spark …." + > "Every PyTorch build with CUDA 12.8 and sm_120 support already supports sm_121 (DGXSpark) as these architectures are binary compatible." +[40] https://discuss.pytorch.org/t/the-detected-cuda-version-12-0-mismatches-the-version-that-was-used-to-compile-pytorch-11-7/169586 — The detected CUDA version (12.0) mismatches the version that was used to compile PyTorch (11.7) + > "The PyTorch binaries do not support CUDA 12 yet and you would have to build from source using a locally installed CUDA 12.0 toolkit." +[41] https://simonwillison.net/2025/Oct/14/nvidia-dgx-spark — NVIDIA DGX Spark: great hardware, early days for the ecosystem + > "I eventually managed to get a PyTorch 2.7 wheel for CUDA on ARM, but failed to do so for 2.8." + > "I have not yet got my head around the difference between CUDA 12 and 13. 13 appears to be very new, and a lot of the existing tutorials and libraries appear to expect 12." +[42] https://lmsys.org/blog/2025-10-13-nvidia-dgx-spark — NVIDIA DGX Spark In-Depth Review: A New Standard for Local AI Inference + > "However, the only downside of this machine lies in memory bandwidth, the unified memory is LPDDR5x, offering up to 273 GB/s , shared across both CPU and GPU." +[44] https://news.ycombinator.com/item?id=45575127 — NVIDIA DGX Spark In-Depth Review (HN) + > "To me it seems like you're paying more than twice the price mostly for CUDA compatibility." +[45] https://vllm.ai/blog/2025-08-11-cuda-debugging — CUDA Core Dump: An Effective Tool to Debug Memory Access Issues and Beyond (vLLM blog) + > "In our experience the python stack traces for these types of exceptions are basically always incorrect and pretty worthless." + > "Many people launch CUDA kernels using the kernel<<<>>> syntax without adding error checking for the kernel launch status, for example, this code." + > "Have you ever felt you are developing cuda kernels and your tests often run into illegal memory access (IMA for short) and you have no idea how to debug? We definitely felt this pain again and again while working on vLLM, a high-performance inference engine for LLM models." +[46] https://docs.pytorch.org/docs/2.14/notes/cuda.html — CUDA semantics — PyTorch docs + > "When you call a function that uses the GPU, the operations are enqueued to the particular device, but not necessarily executed until later." + > "However, the unused memory managed by the allocator will still show as if used in nvidia-smi." + > "This can reduce fragmentation and may allow some borderline workloads to complete without running out of memory." +[47] https://forums.developer.nvidia.com/t/271625 — CUDA errors: determine "sticky-ness" (NVIDIA Developer Forums) + > "Pretty much all asynchronous errors (these are errors that occur as a result of device code execution) are sticky." + > "My goal is to determine whether or not restart the executable, otherwise I will restart it for every cuda-related error, but it is a pity." +[48] https://forums.developer.nvidia.com/t/225877 — Compute-sanitizer not quite a drop-in replacement of cuda-memcheck (NVIDIA Developer Forums) + > "This is hard to use in CI build farms that have a very strict network configuration." +[49] https://developer.nvidia.com/blog/better-bug-detection-how-compile-time-instrumentation-for-compute-sanitizer-enhances-memory-safety — Better Bug Detection: How Compile-Time Instrumentation for Compute Sanitizer Enhances Memory Safety (NVIDIA Technical Bl + > "Compile-time instrumentation catches bugs that binary instrumentation misses, such as buffer overruns into neighboring allocated memory, while lowering runtime overhead in some cases by nearly an order of magnitude." +[50] https://docs.pytorch.org/docs/2.14/notes/randomness.html — Reproducibility — PyTorch docs + > "Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms." +[51] https://docs.nvidia.com/cuda/cublas/index.html — cuBLAS documentation — Results reproducibility + > "set a debug environment variable CUBLAS_WORKSPACE_CONFIG to :16:8 (may limit overall performance) or :4096:8 (will increase library footprint in GPU memory by approximately 24MiB)." + > "In that case, the results are not guaranteed to be bit-wise reproducible because atomics are used for the computation." +[52] https://github.com/Dao-AILab/flash-attention/issues/1038 — Build flash-attn takes a lot of time · Issue #1038 · Dao-AILab/flash-attention + > "For reference I just compiled it on a 2018 Dell laptop (Quadro P1000 GPU) and the build time was about 15 hours." + > "Without both changes it defaulted to just using a single compilation job for me, taking forever (I gave up after an hour)." +[53] https://pypackaging-native.github.io/key-issues/gpus — Packaging projects with GPU code — pypackaging-native + > "GPU packages tend to result in very large wheels. This is mainly because compiled GPU libraries must support a number of architectures, leading to large binary sizes." + > "For example, recent manylinux2014 wheels for TensorFlow are 588 MB (wheels for 2.11.0 ), and for PyTorch those are 890 MB (wheels for 1.13.0 )." +[54] https://docs.pypi.org/project-management/storage-limits — Storage Limits — PyPI Docs + > "Limit for project 'sampleproject' is 100 MB." +[55] https://github.com/pypi/support/issues/10830 — File Limit Request: faiss-gpu - 250 MB · pypi/support #10830 + > "There are currently 34 other open limit request issues ahead of this one." +[56] https://developer.nvidia.com/blog/streamline-cuda-accelerated-python-install-and-packaging-workflows-with-wheel-variants — Streamline CUDA-Accelerated Python Install and Packaging Workflows with Wheel Variants (NVIDIA Technical Blog) + > "Docker images for ML and AI workloads are notoriously large, often exceeding 10 GB. Much of this comes from bundled GPU libraries for all possible architectures." +[57] https://forums.developer.nvidia.com/t/196340 — Cudnn dll for cuda 11 are too big for redistribution (NVIDIA Developer Forums) + > "We agree that the growth of the cuDNN DLL size is problematic, and we’re working on resolving this." +[58] https://forums.developer.nvidia.com/t/147271 — Any suggestions to reduce the size of libcudnn.so? (NVIDIA Developer Forums) + > "Do you have any suggestions to remove unused symbols to reduce this shared library size for deployment? libcudnn.so.7 is over 200 MB in size!" +[59] https://developer.nvidia.com/blog/cuda-pro-tip-understand-fat-binaries-jit-caching — CUDA Pro Tip: Understand Fat Binaries and JIT Caching (NVIDIA Technical Blog) + > "This JIT compilation can cause delay at application start-up time (or more accurately, CUDA context creation time)." + > "Insufficient cache size or a cache stored on a slow network share can cause long application start-up times" +[60] https://docs.flashinfer.ai/installation.html — Installation — FlashInfer documentation + > "flashinfer-python: Core package that compiles/downloads kernels on first use" +[61] https://github.com/vllm-project/vllm/issues/41865 — FlashInfer GDN JIT Compilation Causes Multi-Worker Deadlock · vLLM #41865 + > "Worker 0 completes compilation (172s) but workers 1-7 hang indefinitely." +[62] https://github.com/triton-lang/triton/commit/1f983791498aab4f8f3a922ac8128a59ee3a328b — Cache autotune timings to disk (#6261) · triton-lang/triton + > "Some users had expressed a desire to cache autotune results, both to speed up local iteration, and to avoid re-tuning when scaling up to large numbers of GPUs." +[63] https://docs.nvidia.com/cuda/eula/index.html — License Agreement for NVIDIA Software Development Kits — EULA + > "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." +[64] https://www.tomshardware.com/pc-components/gpus/nvidia-bans-using-translation-layers-for-cuda-software-to-run-on-other-chips-new-restriction-apparently-targets-zluda-and-some-chinese-gpu-makers — Nvidia bans using translation layers for CUDA software — Tom's Hardware + > "Nvidia has banned running CUDA-based software on other hardware platforms using translation layers in its licensing terms listed online since 2021, but the warning previously wasn't included in the documentation placed on a host system during the installation process." + > "The restriction appears to be designed to prevent initiatives like ZLUDA, which both Intel and AMD have recently participated, and, perhaps more critically, some Chinese GPU makers from utilizing CUDA code with translation layer" +[65] https://www.theregister.com/software/2024/08/09/amd-lawyers-claw-back-cuda-compatibility-layer-zluda/1009658 — AMD lawyers claw back CUDA compatibility layer ZLUDA — The Register + > "AMD's legal team appears to have clawed back control of much of the ZLUDA project's code base." +[66] https://www.tomshardware.com/pc-components/gpus/amd-asks-developer-to-take-down-open-source-zluda-dev-vows-to-rebuild-his-project — AMD asks developer to take down open source ZLUDA — Tom's Hardware + > "The code was released with AMD's approval through an email. AMD's legal department now says it's not legally binding, hence the rollback." +[67] https://github.com/vosen/ZLUDA — vosen/ZLUDA README (GitHub) + > "ZLUDA is a drop-in replacement for CUDA on non-NVIDIA GPUs." +[68] https://github.com/vosen/ZLUDA/discussions/261 — Code rollback · vosen/ZLUDA Discussion #261 + > "But since its amd shooting its own foot this project will likely not survive this setback." +[69] https://github.com/ROCm/legacy-rocm-build/issues/2308 — Support your GPUs for 8+ years, like Nvidia does, including gfx906 GPUs · ROCm #2308 + > "If you want to know why everyone is going with Nvidia, there are a lot of them, but what they do at least well is they support they GPUs." +[70] https://github.com/ROCm/legacy-rocm-build/issues/1714 — Which devices are even supported? (HIP/ROCm) · ROCm #1714 + > "I'm a long-time CUDA developer looking to explore ROCm and HIP development, but finding out which hardware even supports these tools is harder than it needs to be." +[71] https://github.com/ROCm/TheRock/issues/9198 — Strix Halo gfx1151: 93 ML experiments, 5 critical bf16 bugs · ROCm/TheRock #9198 + > "We ran 93+ autonomous ML training experiments on a Strix Halo system (Radeon 8060S, gfx1151) using TheROCk nightly PyTorch and discovered 5 critical bf16 bugs, an undocumented 19x attention speedup, and several ecosystem gaps that prevent consumer AMD GPUs from being viable ML research platforms." +[72] https://news.ycombinator.com/item?id=39888020 — Documentation for the AMD 7900XTX — Hacker News (comment by georgehotz) + > "AMD is structurally incapable of fixing these issues. They don't even have a 7900XTX in CI." +[74] https://news.ycombinator.com/item?id=39801234 — CUDA Is Still a Giant Moat for Nvidia — Hacker News + > "On CUDA just runs of course with sliding window attention, ALiBi, and PagedAttention. ROCm fork? Nope." + > "AMD needs to be funding a CUDA shim that allows people to port stuff directly to their cards." +[75] https://news.ycombinator.com/item?id=40970560 — Run CUDA, unmodified, on AMD GPUs — Hacker News (1330 points) + > "you have to be able to pip install something and just have it work, reasonably fast, without crashing, and also it has to not interfere with 100 other weird poorly maintained ML library dependencies." +[76] https://www.modular.com/blog/democratizing-ai-compute-part-4-cuda-is-the-incumbent-but-is-it-any-good — CUDA is the incumbent, but is it any good? (Democratizing AI Compute, Part 4) — Modular + > "PTX is only partially documented, constantly shifting between hardware generations, and effectively a black box for developers." + > "NIM also abstracts away underlying operations, increasing lock-in and limiting access to the low-level optimization and innovation key to CUDA's value proposition." + > "CUDA doesn’t provide performance portability across NVIDIA’s own hardware generations, and the sheer scale of its libraries is a double-edged sword." + > "For AI engineers who build on top of CUDA, it’s an essential tool, but one that comes with versioning headaches, opaque driver behavior, and deep platform dependence." +[77] https://news.ycombinator.com/item?id=48910260 — Alternative(s) to run CUDA on non-Nvidia hardware — Hacker News comment + > "With a design like Cuda where there is always a default easy path, and a complex but optional path." + > "That so many people have skill issues is the reason why Cuda trumps and will continue to trump Vulkan despite being vendor-locked." +[78] http://tinygrad.org/pitch.pdf — the tiny corp pitch deck (George Hotz, tinygrad.org) + > "By being the dominant player, green team gets a whole ecosystem of developers to improve the developer experience for them." +[79] https://news.ycombinator.com/item?id=48903715 — Alternative(s) to run CUDA on non-Nvidia hardware — Hacker News + > "One of the biggest complaints we hear from the industry is "we tried to port to X and we could never complete it"." +[82] https://news.ycombinator.com/item?id=45165571 — Intel Arc Pro B50 GPU Launched at $349 — Hacker News comment + > "Nvidia uses VRAM amount for market segmentation. They can't make a 128GB consumer card without cannibalizing their enterprise sales." +[83] https://news.ycombinator.com/item?id=49151324 — Qwen3.8-Max — Hacker News comment + > "There is no math that will make local models come out ahead in $/intelligence/token." + > "The point of local models is privacy, offline use, and maybe no guard rails." +[84] https://news.ycombinator.com/item?id=48089658 — Running local models on an M4 with 24GB memory — Hacker News comment + > "At $20/month for a cloud AI subscription, you’re looking at almost 30 years of service for the same money." +[85] https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-second-quarter-fiscal-2027 — NVIDIA Announces Financial Results for Second Quarter Fiscal 2027 + > "Data Center revenue of $89.0 billion, up 117% from a year ago" + > "NVIDIA (NASDAQ: NVDA) today reported revenue for the second quarter ended July 26, 2026, of $96.2 billion" +[87] https://www.sec.gov/Archives/edgar/data/1045810/000104581025000023/nvda-20250126.htm — NVIDIA Form 10-K for fiscal year ended Jan 26, 2025 (SEC) + > "Data Center revenue for fiscal year 2025 was up 142% from a year ago." + > "Revenue for fiscal year 2025 was $130.5 billion, up 114% from a year ago." +[88] https://www.reddit.com/r/LocalLLaMA/comments/1r569eb/psa_nvidia_dgx_spark_has_terrible_cuda_software — r/LocalLLaMA: PSA: NVIDIA DGX Spark has terrible CUDA & software compatibility + > "Just be careful when buying a DGX Spark. You are not really getting a modern CUDA experience." + > "The funniest part is paying the NVIDIA tax specifically for CUDA compatibility and then not getting it." + > "Very frustrating compared to most every other GPU release that has zero day support from cuda/nvcc/pytorch/tensorflow." + > "many of their official playbooks are broken and can’t be run as-is on the latest versions." + > "The sm121 fragmentation is the more interesting problem here." +[89] https://www.reddit.com/r/LocalLLaMA/comments/1no4ho1/some_things_i_learned_about_installing_flashattn — r/LocalLLaMA: Some things I learned about installing flash-attn + > "This cut my build time from 1+ hours to just under 15 minutes. Thank you!" + > "Usually the reason is a different torch. There's a whole issue on FA about people complaining." +[90] https://www.reddit.com/r/LocalLLaMA/comments/1oo6226/disappointed_by_dgx_spark — r/LocalLLaMA: Disappointed by dgx spark + > "You design and validate them locally on the spark, running the exact same software, then push to the data center full of Nvidia GPU racks." + > "Sure, Nvidia gives for "free" their software stack.... as long as you use it on their products." +[91] https://www.reddit.com/r/LocalLLaMA/comments/1sqera2/vllm_woes_in_spark — r/LocalLLaMA: VLLM woes in Spark + > "The CUDA tax, which is 4.6 GB approximately per each model on a DGX spark." +[92] https://www.reddit.com/r/LocalLLaMA/comments/1lx62hd/nvidia_being_nvidia_fp8_is_150_tflops_faster_when — r/LocalLLaMA: Nvidia being Nvidia: FP8 is 150 Tflops faster when kernel name contain "cutlass" + > "Even worse, if someone accidentally created a kernel with "cutlass" in the name, the driver would apply optimizations that are not safe." +[93] https://www.reddit.com/r/pytorch/comments/1l3uwk2/should_compiling_from_source_take_a_terabyte_of — r/pytorch: Should compiling from source take a terabyte of memory? + > "It keeps crashing with the nvcc error out of memory, even after I've allocated over 0.75TB of vRAM on my SSD." +[94] https://www.reddit.com/r/LocalLLaMA/comments/1k903ov/llamacpp_cuda_setup_running_into_issues_is_it — r/LocalLLaMA: Llama.cpp CUDA Setup - Running into Issues - Is it Worth the Effort? + > "However, CMake is unable to find the CUDA toolkit, even though it's installed and `nvcc` and `nvidia-smi` are working correctly." +[95] https://www.reddit.com/r/LocalLLaMA/comments/1b6gfjt/cuda_crackdown_nvidias_licensing_update_targets — r/LocalLLaMA: CUDA Crackdown: NVIDIA's Licensing Update targets AMD and blocks ZLUDA + > "i literally worked at a company where we dropped HIP support, and just went all in on nvidia." + > "I hope someone is working on hardware agnostic solutions, we need more GPUs, not less." +[96] https://www.reddit.com/r/CUDA/comments/1jhvtqm/patch_to_enable_pytorch_on_rtx_5080_cuda_128_sm — r/CUDA: Patch to enable PyTorch on RTX 5080 cuda 12.8 + sm_120 / Blackwell support + > "PyTorch doesn’t support sm_120 or the RTX 5080 out of the box. So I patched it." +[97] https://www.reddit.com/r/LocalLLaMA/comments/1scf1x8/dont_buy_the_dgx_spark_nvfp4_still_missing_after — r/LocalLLaMA: Don't buy the DGX Spark: NVFP4 Still Missing After 6 Months + > "It was not marketed like an experimental dev kit where buyers should expect to spend months switching backends, testing builds, setting flags, and relying on community or hardcore fan fixes just to make a core feature work properly." diff --git a/docs/img/ceilings.svg b/docs/img/ceilings.svg new file mode 100644 index 00000000..3169ab3b --- /dev/null +++ b/docs/img/ceilings.svg @@ -0,0 +1 @@ +The two ceilings I measured on the GB10Roofline: attainable speed against operations per byte, from the measured 115.14 TFLOPS tensor-core peak and 195.1 GB/s read bandwidth.SPEED AGAINST THE MACHINE'S CEILINGThe two ceilings I measured on the GB10Every speed claim is held against these: the tensor-core peak and the memory read rate my own probes reached.0.010.11101001000100001 G10 G100 G1 T10 T100 T1 Poperations per byte moved (log)operations per second (log)ridge: 590 ops/bytetensor-core peak 115.14 TFLOPSmemory reads 195.1 GB/svector add1 add per 12 bytes moved0.083 ops/byte: memory-bounddecode, BF16 matrix-vectormultiply + add per 2-byte weight1 ops/byte: memory-boundlarge BF16 GEMM (4096³)each byte reused many times1,365 ops/byte: compute-boundA generated word reads every activeweight once, so its speed is set bythe memory line, not the tensor cores.The two lines are measured: evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z (peak.log, bw.log). The dots are arithmetic, not measurements.One op is one add or one multiply; a fused multiply-add counts as two. diff --git a/docs/img/driver-objects.svg b/docs/img/driver-objects.svg new file mode 100644 index 00000000..cdf15244 --- /dev/null +++ b/docs/img/driver-objects.svg @@ -0,0 +1 @@ +The driver client: every object CUDA++ asks NVIDIA's kernel module forDevice files on the left, the resource-manager object tree in the middle, the unified-memory registrations on the right, all from nvrm/nvrm.c.THE DRIVER CLIENT, PART BY PARTWhat replaces libcuda: nvrm/nvrm.cAbout 900 lines of C that talk to NVIDIA's open kernel module through ioctls, written from its MIT headers. Each box isone object CUDA++ allocates (RM_ALLOC), with its class name, the header that defines it, and the function that creates it.DEVICE FILES/dev/nvidiactlresource manager: allocateobjects, controls, free/dev/nvidia0this GPU: CPU mappings ofmemory and the doorbell page/dev/nvidia-uvmunified memory: GPU pagetables of the address spaceRESOURCE-MANAGER OBJECTSRoot clientnvrm_open()NV01_ROOT_CLIENTthe handle that owns everything belowcl0000.hDeviceNV01_DEVICE_0the GPU; its class list names the Blackwell classescl0080.hSubdeviceNV20_SUBDEVICE_0SM version (sm_121) and GPU UUIDcl2080.hUsermode pageHOPPER_USERMODE_A64 KiB of GPU registers; holds the doorbellclc661.hVirtual memoryNV01_MEMORY_VIRTUALthe GPU address range CUDA++ may usecl0070.hAddress spaceFERMI_VASPACE_Apage faulting, handed to UVM to managecl90f1.hMemory, one per buffernvrm_alloc()NV01_MEMORY_SYSTEMGB10 has no VRAM: same address for CPU and GPUcl003e.hChannel groupnvrm_channel()KEPLER_CHANNEL_GROUP_Ascheduled on the graphics/compute enginecla06c.hContext shareFERMI_CONTEXT_SHARE_Abinds the channel to the address spacecl9067.hCommand ring (GPFIFO)BLACKWELL_CHANNEL_GPFIFO_A1,024 entries + USERD control page; submit tokenclc96f.hCompute objectBLACKWELL_COMPUTE_Bthe engine every kernel launch runs onclcec0.hUNIFIED MEMORY (UVM) CALLSUVM_INITIALIZEopen the UVM sessionUVM_REGISTER_GPUthis GPU, by UUIDUVM_REGISTER_GPU_VASPACEthe address spaceUVM_CREATE_EXTERNAL_RANGEper buffer: reserve the rangeUVM_MAP_EXTERNAL_ALLOCATIONper buffer: map it for the GPUUVM_REGISTER_CHANNEL64 MiB for the channel's contextBelow this line: NVIDIA's open kernel module (nvidia.ko, nvidia-uvm.ko) and the GSP firmware inside the GPU.AIEN's own GB10 driver (L332) is being built to replace the two modules; the signed firmware stays NVIDIA's. diff --git a/docs/img/hero.svg b/docs/img/hero.svg new file mode 100644 index 00000000..5bd186fc --- /dev/null +++ b/docs/img/hero.svg @@ -0,0 +1 @@ +CUDA++: my own path from a program to an NVIDIA GPUTitle, three measured facts, and the 32 instructions of the first kernel CUDA++ ran, drawn bit by bit from src/omega_blackwell_encoder.c.AIEN-DEV / CUDAPP · MIT · NVIDIA GB10 (SM_121)CUDA++My own path from a program to an NVIDIA GPU:machine code, runtime, libraries and driver client.No CUDA toolkit, no nvcc, no PTX, no libcuda.0CUDA libraries loaded in the live35B model server (2026-10-21)115.14TFLOPS tensor-core peak, measuredby my own probe kernel59instruction kinds my encoderwrites for sm_121THE FIRST KERNEL: VECTOR ADD32 instructions × 128 bits, every bit written by my encoderopcodepredicateregistersoperandmodifiersscheduling0000LDC0010S2R0020LDCU0030S2R0040LDCU0050IMAD0060ISETP.GE.U32.AND0070@P0 EXIT0080LDC.640090LDCU.6400a0LDC.6400b0LDC.6400c0IMAD.WIDE.U3200d0LDG.E00e0IMAD.WIDE.U3200f0LDG.E0100IMAD.WIDE.U320110IADD30120STG.E0130EXIT0140BRA0150NOP0160NOP0170NOP0180NOP0190NOP01a0NOP01b0NOP01c0NOP01d0NOP01e0NOP01f0NOP0326496127bit 0 to bit 127 of each instruction · lit = 1 · src/omega_blackwell_encoder.c diff --git a/docs/img/instruction.svg b/docs/img/instruction.svg new file mode 100644 index 00000000..86bf1057 --- /dev/null +++ b/docs/img/instruction.svg @@ -0,0 +1 @@ +One instruction, all 128 bits: IADD3 R9, PT, PT, R2, R5, RZThe add of vector add, decoded field by field, with its scheduling bits enlarged.ONE INSTRUCTION, ALL 128 BITSIADD3 R9, PT, PT, R2, R5, RZR9 = R2 + R5: the add in vector add, at offset 0x0110. Sixteen bytes, four 32-bit words.word 0 0x02097210word 1 0x00000005word 2 0x07ffe0ffword 3 0x010fca0003132636495961270x210 IADD3opcode + operand form@PTguard predicateR9destinationR2source AR5source BRZsource CPT, PTcarry predicates, modifierscontrolscheduling (enlarged below)bits 105 to 127: how the warp scheduler treats this instruction110501061107010801091110111111121113111411150116011701180119112001210122012301240125012601275 cyclesstall0yieldnonesets SBnoneread SBSB4waits on0reuse0unusedSB4 is the scoreboard both loads (LDG.E R2 and LDG.E R5) set: the add waits until both values have arrived from memory.Field positions: src/omega_blackwell_codegen.c ("Control words"), learned from nvcc output on my own probe kernels and Mesa NAK, believed only after the GB10 ran them. diff --git a/docs/img/launch-path.svg b/docs/img/launch-path.svg new file mode 100644 index 00000000..406fe9af --- /dev/null +++ b/docs/img/launch-path.svg @@ -0,0 +1 @@ +The life of one kernel launchFive CPU steps write into memory the CPU and GPU share, one store rings the doorbell, the GPU reads the ring, the pushbuffer and the launch descriptor, runs the grid and writes a completion marker the CPU polls.THE LAUNCH PATHThe life of one kernel launchOn the GB10 the CPU and the GPU share one memory, and CUDA++ maps every buffer at the same address on both. Nothing is copied.CPU (your process)SHARED MEMORYGPU1Build the kernelIR instructions, register allocation,16-byte machine words2Describe the launchQMD: grid, block, registers, sharedmemory, code address. Argumentsgo in constant bank 0.3Write the methodsINVALIDATE_SHADER_CACHES,WAIT_FOR_IDLE, SEND_PCAS_A (theQMD), then the completion tail4Queue one ring entry8 bytes: pushbuffer address + length;then advance USERD.GPPut5Ring the doorbellone 32-bit store of the channel'swork-submit tokenCode bufferwritten once, executed by the GPUQMD + constant bank 0384 B QMD · 224 driver words · argsPushbuffermethod headers + data wordsGPFIFO ring + USERD1,024 entries · GPPut (GPU-uncached)Usermode page (GPU registers)doorbell registerMarker page (GPU-uncached)0x44444444, then 0x464646466Host engine fetchesreads the new ring entry, thenthe pushbuffer's methods7Compute engine launchesinvalidates caches, reads the QMDand constant bank, starts thegrid on the SMs8The grid finishessemaphore release writes themarker, L2_FLUSH_DIRTY, thenthe second markerreads ring + pushbufferreads QMD, bank, codewakes the GPUwrites the markers9Wait, then retirepoll the marker with a hard deadlineand a stall deadline; results arealready in shared memoryBlue: the CPU writes. Amber: the GPU acts. Dashed: GPU registers mapped into the process, not memory.Measured on the GB10: 24 to 31 µs per extra dependent launch with wait-for-idle (evidence/OWN30B-LAUNCH-COST-20261014T0120Z). Command lists put many launches in one submission. diff --git a/docs/img/replacement-map.svg b/docs/img/replacement-map.svg new file mode 100644 index 00000000..fea499a0 --- /dev/null +++ b/docs/img/replacement-map.svg @@ -0,0 +1 @@ +Every NVIDIA piece on the Spark and what replaces itOne row per NVIDIA component with the CUDA++ replacement and its status (ROADMAP.md).THE REPLACEMENT MAPEvery NVIDIA piece on the Spark, and what replaces itPASS means a receipt on a named commit. The full table with every receipt is ROADMAP.md.NVIDIA PIECEITS JOBCUDA++STATUSnvcc · NVVM · PTX · ptxascompile kernelssm_121 encoder + register allocatorevery kernel Omega runsPASSlibcudauser-space drivernvrm + m16 driver clientm16 requalification receiptPASSlibcudartdevice, memory, launchsession, command lists, job engineone device, one processPARTIALcuBLASmatrix multiplymatmul, tensor-core GEMM, FP8, BF16model shapes; any-shape GEMM is C3PARTIALcuDNN · FlashAttentionattention, layersdecode and prefill attentionmodel-shapedPARTIALCUB · Thrustreductions, scans, sortsfrozen-order reductionsE1-CLOSURE; scans and sorts are C3PARTIALcuobjdump · nvdisasmread machine code backmy own sm_121 disassemblerOmega branch c6/disasm: 331 kernels agreeBUILDINGNsightmeasureceiling probes115.14 TFLOPS, 195.1 GB/sPARTIALcuFFT · cuRANDFFT, random numbersnone yetMISSINGnvidia.kokernel driverAIEN's own GB10 driver (L332)simulator gates passBUILDINGnvidia-uvm.kopage tables, faultssame driverhost simulator, 225 checksBUILDINGnvidia-smi · NVMLstatus, clocks, powernot startedMISSINGGSP firmwareruns inside the GPUstays NVIDIA's: signature-checkednever shipped by CUDA++STAYSPASS 2PARTIAL 5BUILDING 3MISSING 2STAYS 1 diff --git a/docs/img/reverse-engineering.svg b/docs/img/reverse-engineering.svg new file mode 100644 index 00000000..97f9c771 --- /dev/null +++ b/docs/img/reverse-engineering.svg @@ -0,0 +1 @@ +How I learned the GB10's machine codeThree sources and one rule: NVIDIA's compiler output on my own probe kernels, Mesa's open NAK compiler, and the chip itself. Nothing is believed until the GPU runs it and gives the right answer.THE REVERSE ENGINEERINGHow I learned the GB10's machine codeNVIDIA publishes no instruction encoding for its GPUs. I worked it out, and checked every answer on the chip.LEARN01My own probe kernela few lines of CUDA C++ Iwrote, e.g. one add02nvcc, once, offlinenvcc 13.0.88 -arch=sm_121-cubin. Never run byCUDA++ itself.03Read the bytes backcuobjdump -sass: 16 bytesnext to each mnemonic04Change one detaila register, an immediate, apredicate, a modifier; diffthe bits that movedPROVE05Field hypothesisbits 16..23 are thedestination register,and so on06My encoder writes itsrc/omega_blackwell_encoder.c, codegen*.c07The GB10 runs ita real launch on the chip,answers checked on the CPU08Golden wordskept in the tests; nvdisasmcross-check when installedright, bit for bit ↘wrong answer: back to the hypothesisMesa NAK (MIT), cited, no code copiedsm70_encode.rs opcodes and bit positions, sm120 latencies,qmd.rs launch descriptor layoutArithmetic the documents leave opentensor-core BF16: 2,048 chosen cases until one model matchedevery output bit (tests/gpu_tc_probe_test.c) diff --git a/docs/img/stack.svg b/docs/img/stack.svg new file mode 100644 index 00000000..6e851b22 --- /dev/null +++ b/docs/img/stack.svg @@ -0,0 +1 @@ +CUDA and CUDA++, layer by layerLeft: the NVIDIA CUDA stack. Right: CUDA++. The four closed layers above the kernel module are replaced by my own code; the open kernel module and the signed GPU firmware are still NVIDIA's.THE STACKWhat runs between your program and the GPUCUDACUDA++Your programCUDA C++ kernels and host codeYour programC calls to the kernel builder; Omega's languages next (bar C1)nvcc · NVVM · PTX · ptxascompiler, closedKernel builder · allocator · sm_121 encodersrc/omega_blackwell_codegen*.c, _encoder.c, _qmd.creplacedcuBLAS · cuDNN · CUBmaths libraries, closedMatmul · attention · MoE · reductionssrc/omega_gpu_*_api.creplacedlibcudartruntime API, closedSession · command lists · job enginesrc/omega_gpu_session.c, _cmdlist.c, _engine.creplacedlibcudadriver API, closedDriver client: nvrm + m16nvrm/nvrm.c, m16/: ioctls from the open headersreplaceduser space ↑ kernel ↓nvidia.ko · nvidia-uvm.koNVIDIA's open kernel modulenvidia.ko · nvidia-uvm.ko, for nowAIEN's own GB10 driver is being built (L332)nextGSP firmwareruns inside the GPU, signed by NVIDIAGSP firmwarestays NVIDIA's: the chip checks its signaturestaysNVIDIA GB10 GPUDGX Spark, sm_121NVIDIA GB10 GPUDGX Spark, sm_121closed, replaced by CUDA++mine, MITNVIDIA open source, replaced nextNVIDIA signed firmware, stays diff --git a/docs/img/timeline.svg b/docs/img/timeline.svg new file mode 100644 index 00000000..662faafe --- /dev/null +++ b/docs/img/timeline.svg @@ -0,0 +1 @@ +Under four weeks, one DGX SparkMilestones from the first native kernel to a 35B model served with no CUDA library loaded.UNDER FOUR WEEKS, ONE DGX SPARK2026-09-26First native kernelvector add qualified on theGB10; first tensor-core matmul2026-10-02Numerics closed on chipreductions, 9 functions overall 2^32 inputs, 148 ld/st kernels2026-10-13Ceilings measured115.14 TFLOPS tensor peak,195.1 GB/s reads, own probes2026-10-21A 35B model, no CUDAserved on this code with zeroCUDA libraries in the process diff --git a/docs/img/vecadd-scoreboards.svg b/docs/img/vecadd-scoreboards.svg new file mode 100644 index 00000000..c77b9f01 --- /dev/null +++ b/docs/img/vecadd-scoreboards.svg @@ -0,0 +1 @@ +Vector add, instruction by instruction, with its scoreboardsThe 21 real instructions of the first kernel. Lines on the left join an instruction that sets a scoreboard to the later instruction that waits on it; amber bars are fixed stall cycles.THE FIRST KERNEL, DECODEDHow vector add waits for its dataSlow instructions (constant loads, special registers, memory loads) set one of six scoreboards. A later instructionthat needs the result waits on it. Fast instructions stall a fixed number of cycles instead. My encoder writes these bits.OFFSETINSTRUCTIONSTALLSETSWAITS ONSB0SB1SB2SB3SB40000LDC R1, c[0x0][0x37c]10010S2R R9, SR_CTAID.X1SB00020LDCU UR4, c[0x0][0x360]1SB00030S2R R0, SR_TID.X1SB00040LDCU UR5, c[0x0][0x398]1SB10050IMAD R9, R9, UR4, R05SB00060ISETP.GE.U32.AND P0, PT, R9, UR5, PT13SB10070@P0 EXIT50080LDC.64 R2, c[0x0][0x380]1SB00090LDCU.64 UR4, c[0x0][0x358]7SB100a0LDC.64 R4, c[0x0][0x388]8SB200b0LDC.64 R6, c[0x0][0x390]1SB300c0IMAD.WIDE.U32 R2, R9, 0x4, R26SB000d0LDG.E R2, desc[UR4][R2.64]1SB4SB100e0IMAD.WIDE.U32 R4, R9, 0x4, R46SB200f0LDG.E R5, desc[UR4][R4.64]1SB40100IMAD.WIDE.U32 R6, R9, 0x4, R61SB30110IADD3 R9, PT, PT, R2, R5, RZ5SB40120STG.E desc[UR4][R6.64], R910130EXIT50140BRA (.L_x_0)Instruction words: src/omega_blackwell_encoder.c. Decoded by tools/figures/make_figures.py with the encoder's own field positions. diff --git a/docs/issues/D1-memory.md b/docs/issues/D1-memory.md new file mode 100644 index 00000000..b10c4b80 --- /dev/null +++ b/docs/issues/D1-memory.md @@ -0,0 +1,14 @@ +# D1: refuse an allocation before it hangs the machine + +Labels: pain-point, D1, good-first-issue + +**The pain.** On the DGX Spark the CPU and GPU share one memory, and the machine has no swap. A memory spike does not end in an error message: "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." (github.com/sudoingX/dgx-spark-laguna, FINDINGS.md). `docs/PAIN_POINTS.md` section 2.1. + +**What exists.** CUDA++ has no caching allocator: every buffer is an explicit allocation, so what a process holds is what it asked for. `make doctor` prints the shared memory and how much is free now. + +**What is left.** In the Linux platform's allocation path (`src/omega_gpu_platform_linux.c`, hosted), refuse an allocation that would leave less than a reserve free on a unified-memory GPU. The refusal is a sentence: bytes asked, bytes free, the reserve, and what to do (free buffers, lower the batch, or set the reserve). The reserve has a default and one setting to change it. + +**Done when.** +- A host test with a fake `/proc/meminfo` shows the refusal text and that a smaller allocation still succeeds (seen failing first). +- A negative control: with the check removed, the test fails. +- A chip run on the Spark prints the live budget at open. diff --git a/docs/issues/D11-libraries.md b/docs/issues/D11-libraries.md new file mode 100644 index 00000000..2353d5a7 --- /dev/null +++ b/docs/issues/D11-libraries.md @@ -0,0 +1,11 @@ +# D11: open libraries with an easy default path + +Labels: library, D11 + +**The pain.** Closed libraries nobody outside NVIDIA can read or fix; on new chips they fall back or fail ("SM121 falls through to cutlass/cudnn only.", FlashInfer #3170). `docs/PAIN_POINTS.md` section 2.10. + +**What exists.** Matrix multiply, matrix-vector, attention, elementwise and routing kernels in source, shaped for the models AIEN runs. + +**What is left.** Any-shape GEMM in BF16 and FP8, reductions, prefix sums and sorts, each with a host reference. This is Omega bar C3, owned by ledger L386; contributions go through it. + +**Done when.** Omega bar C3's receipts: 200+ GEMM shapes from 1 to 8192 against a host reference, speed as a fraction of the measured tensor-core ceiling; reductions and scans 1 to 2^28 elements bit-exact. diff --git a/docs/issues/D13-disassembler.md b/docs/issues/D13-disassembler.md new file mode 100644 index 00000000..5fff7dd4 --- /dev/null +++ b/docs/issues/D13-disassembler.md @@ -0,0 +1,9 @@ +# D13: our own disassembler, in plain text a person can read + +Labels: D13 + +**The pain.** PTX "is only partially documented, constantly shifting between hardware generations, and effectively a black box for developers." (Modular). CUDA++'s host tests still call NVIDIA's `nvdisasm` as a cross-check when it is installed. + +**What is left.** A disassembler built from CUDA++'s own encoder tables, printing each instruction with its control word (stall, barriers) in words, and a timing view like the motor's. Omega bar C6, ledger L386. + +**Done when.** It agrees with `nvdisasm` on every library kernel, and nothing in the tree calls `nvdisasm`. diff --git a/docs/issues/D14-recover.md b/docs/issues/D14-recover.md new file mode 100644 index 00000000..f6e72268 --- /dev/null +++ b/docs/issues/D14-recover.md @@ -0,0 +1,11 @@ +# D14: recover from a fault without restarting the process + +Labels: D14 + +**The pain.** "Pretty much all asynchronous errors (these are errors that occur as a result of device code execution) are sticky." (NVIDIA forums). After one fault the whole process has to restart. `docs/PAIN_POINTS.md` section 2.3. + +**What exists.** CUDA++ latches the process on an unconfirmed completion and parks buffers the GPU might still touch, instead of reusing them (`docs/runtime/API.md` section 3). Recovery is open (omega-mv#518). + +**What is left.** Stop a faulting or endless kernel and keep the same process usable. Omega bar C5, ledger L386. + +**Done when.** A kernel that never ends is timed out, and the same process then runs hello-gpu to PASS; chip receipt. diff --git a/docs/issues/D3-chip-faults.md b/docs/issues/D3-chip-faults.md new file mode 100644 index 00000000..902bf03d --- /dev/null +++ b/docs/issues/D3-chip-faults.md @@ -0,0 +1,11 @@ +# D3, chip half: read the GPU's own fault record after a fault + +Labels: pain-point, D3 + +**The pain.** CUDA reports a bad memory access at a later, unrelated call: "might be asynchronously reported at some other API call". vLLM's maintainers: "In our experience the python stack traces for these types of exceptions are basically always incorrect and pretty worthless." `docs/PAIN_POINTS.md` section 2.3. + +**What exists.** CUDA++ launches wait for their own completion by default, so an error comes back from the call that caused it. On the host simulator a bad access is named in full: kernel, launch, instruction, block, thread, address, the buffer it missed and by how much (`hello_gpu --sim --bug=past-end`). + +**What is left.** On the chip, a faulting kernel today shows up as a launch that does not complete (a timeout), and the process latches. Read the fault itself from the driver (the MMU fault's address, access type and engine, which the open kernel module records) and print it at the launch, with the kernel name and the next command (rerun the same launch under `--sim`). + +**Done when.** A deliberately bad kernel run on the GB10 inside a chip window prints the faulting address and the kernel name at the launch that caused it; receipt under `evidence/`. diff --git a/docs/issues/D7-same-bits-chip.md b/docs/issues/D7-same-bits-chip.md new file mode 100644 index 00000000..addbde72 --- /dev/null +++ b/docs/issues/D7-same-bits-chip.md @@ -0,0 +1,11 @@ +# D7, chip half: same inputs, same bits, on the GPU + +Labels: D7 + +**The pain.** "Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms." (PyTorch docs). Bitwise reproducibility in cuBLAS needs `CUBLAS_WORKSPACE_CONFIG` and costs speed or memory. `docs/PAIN_POINTS.md` section 2.6. + +**What exists.** CUDA++ reductions add in a fixed order (`evidence/E1-CLOSURE/`). On the simulator, two runs of hello-gpu print the same output hash. + +**What is left.** The same check on the chip, and the same check on a library kernel with a reduction (matrix-vector). + +**Done when.** Two runs on the GB10 of hello-gpu and of one matrix-vector job print the same output hash, with no setting turned on; receipt under `evidence/`. diff --git a/docs/issues/D8-process-tax.md b/docs/issues/D8-process-tax.md new file mode 100644 index 00000000..d5c2fc50 --- /dev/null +++ b/docs/issues/D8-process-tax.md @@ -0,0 +1,11 @@ +# D8: measure what a CUDA++ process costs beyond its own buffers + +Labels: D8 + +**The pain.** "The CUDA tax, which is 4.6 GB approximately per each model on a DGX spark." (r/LocalLLaMA). `docs/PAIN_POINTS.md` section 2.7. + +**What exists.** A CUDA++ process maps no CUDA library (Omega `evidence/WHAT-OMEGA-IS-20261021/live-serve-no-cuda.txt`). + +**What is left.** Measure it: resident memory of `hello_gpu` before open, after open and after its buffers are allocated, and the GPU memory the driver reports for the process, so the overhead beyond the program's own buffers is a number. + +**Done when.** `hello_gpu` prints its own overhead line, and a chip receipt records it. diff --git a/docs/issues/README.md b/docs/issues/README.md new file mode 100644 index 00000000..7124e8c7 --- /dev/null +++ b/docs/issues/README.md @@ -0,0 +1,3 @@ +# Issue drafts + +One file per open row of the developer bar (`docs/PAIN_POINTS.md` section 3). They are written to be filed as GitHub issues when the repository goes public (ledger L395 does that); until then they are the to-do list. Each says the pain, the row, what exists, what is left and the command that will show it is done. diff --git a/docs/runtime/portability_table.tsv b/docs/runtime/portability_table.tsv index d3a0fd04..be532401 100644 --- a/docs/runtime/portability_table.tsv +++ b/docs/runtime/portability_table.tsv @@ -103,3 +103,5 @@ src/omega_gpu_tern_api.c CHIP_SPECIFIC Launches the ternary GEMV with GPU-cached src/omega_gpu_tern_api.h CHIP_SPECIFIC Ternary GEMV API; includes omega_blackwell_codegen_tern.h. NO_HOSTED_INCLUDE src/omega_gpu_wait.c PORTABLE Bounded wait with a caller-supplied clock and hooks; no default clock in the freestanding build. Builds in make gpu-engine-freestanding. FREESTANDING_PROVEN src/omega_gpu_wait.h PORTABLE Bounded wait interface; includes only stdbool.h and stdint.h. NO_HOSTED_INCLUDE +src/omega_gpu_chip.c CHIP_SPECIFIC The qualified-chip table (GB10, PCI 10de:2e12, with its receipt) and the refusal text for any other NVIDIA GPU; scans /sys/bus/pci/devices with stdio and dirent. Developer bar D6. HOSTED_LIBC +src/omega_gpu_chip.h PORTABLE Types and declarations for the chip table and the PCI scan; no chip constant, no driver header. NO_HOSTED_INCLUDE diff --git a/evidence/dx/d1-memory/host-suite.txt b/evidence/dx/d1-memory/host-suite.txt new file mode 100644 index 00000000..c01f3dda --- /dev/null +++ b/evidence/dx/d1-memory/host-suite.txt @@ -0,0 +1,2 @@ +d1-memory a462199 make -k test rc=2; failing targets: test-gpu-attention test-gpu-engine-backend-mutants test-gpu-engine-mutants test-runtime-api test-runtime-portability-check test-runtime-portability-controls +# make -k test on this commit; main fc90713 fails the same 6 targets (~/handoffs/l400/suite-main.log), so this branch adds none diff --git a/evidence/dx/d1-memory/negative-control.txt b/evidence/dx/d1-memory/negative-control.txt new file mode 100644 index 00000000..e59a0aa8 --- /dev/null +++ b/evidence/dx/d1-memory/negative-control.txt @@ -0,0 +1,24 @@ +# commit a462199f106a0a0f095da486a038ccc1c3ad28f0 branch dx/d1-memory, run 2026-10-22T01:49:49Z on spark-b87b +# negative control: the reserve check removed from ref_dma_alloc; the D1 case must FAIL +$ grep -n MUTANT src/omega_gpu_platform_linux.c +235: rc = OMEGA_GPU_PLAT_OK; (void)mem_reserve_check; /* MUTANT: D1 check removed */ /* D1: before any slot or driver call; the sentence is in r->diag */ +$ make build/test_omega_gpu_platform_linux && ./build/test_omega_gpu_platform_linux +PASS LINUX_REF_CAPS_NO_MMIO_NO_IRQ +PASS HOSTED_DEFAULT_IS_LINUX_REFERENCE +PASS SAME_DRIVER_CALLS_AND_ORDER_AS_BEFORE +PASS REFERENCE_REFUSALS_CACHED_POLLED_RING_STALE +PASS OPEN_FAILURE_KEEPS_DRIVER_TEXT +PASS MARKER_NEVER_LATCHES_AND_PARKS +PASS L2_INVAL_PREFIX_ONCE_AFTER_CACHED_HOST_WRITE +PASS CMDLIST_NEAR_CAP_SUBMITS_WITH_L2_INVAL_PENDING + expect failed at line 272: p->dma_alloc(p->ctx, d, &big, &h, &cpu, &va, &bus) == OMEGA_GPU_PLAT_REFUSED_LIMIT + expect failed at line 273: fk.alloc_calls == allocs0 + expect failed at line 275: strstr(t, "dma_alloc: refused 2.0 MiB") != NULL + expect failed at line 276: strstr(t, "4.0 GiB of memory is free") != NULL + expect failed at line 277: strstr(t, "CUDAPP_MEM_RESERVE_MIB=4096") != NULL + expect failed at line 278: strstr(t, "freezes the machine") != NULL + expect failed at line 293: omega_gpu_session_alloc(2u << 20, &m) != 0 + expect failed at line 294: strstr(omega_gpu_session_last_error(), "dma_alloc: refused 2.0 MiB") != NULL +FAIL D1_MEMORY_RESERVE_REFUSES_BEFORE_THE_DRIVER +test_omega_gpu_platform_linux (reference only, simulated driver): 8 passed, 1 failed +exit 0 diff --git a/evidence/dx/d1-memory/platform-test-spark.txt b/evidence/dx/d1-memory/platform-test-spark.txt new file mode 100644 index 00000000..6a1d6707 --- /dev/null +++ b/evidence/dx/d1-memory/platform-test-spark.txt @@ -0,0 +1,19 @@ +# commit a462199f106a0a0f095da486a038ccc1c3ad28f0 branch dx/d1-memory, run 2026-10-22T01:49:45Z on spark-b87b +$ make build/test_omega_gpu_platform_linux && ./build/test_omega_gpu_platform_linux +PASS LINUX_REF_CAPS_NO_MMIO_NO_IRQ +PASS HOSTED_DEFAULT_IS_LINUX_REFERENCE +PASS SAME_DRIVER_CALLS_AND_ORDER_AS_BEFORE +PASS REFERENCE_REFUSALS_CACHED_POLLED_RING_STALE +PASS OPEN_FAILURE_KEEPS_DRIVER_TEXT +PASS MARKER_NEVER_LATCHES_AND_PARKS +PASS L2_INVAL_PREFIX_ONCE_AFTER_CACHED_HOST_WRITE +PASS CMDLIST_NEAR_CAP_SUBMITS_WITH_L2_INVAL_PENDING + 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. + 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. +PASS D1_MEMORY_RESERVE_REFUSES_BEFORE_THE_DRIVER +test_omega_gpu_platform_linux (reference only, simulated driver): 9 passed, 0 failed +exit 0 + +$ grep MemAvailable /proc/meminfo (this machine now) +MemTotal: 127598528 kB +MemAvailable: 64076016 kB diff --git a/evidence/dx/d2-doctor/fake-machines.txt b/evidence/dx/d2-doctor/fake-machines.txt new file mode 100644 index 00000000..84e936d0 --- /dev/null +++ b/evidence/dx/d2-doctor/fake-machines.txt @@ -0,0 +1,128 @@ +# commit 8f3a6a2d52c6a9a55cf37b7eccb2839321c835e5 branch dx/d2-doctor, run 2026-10-22T01:49:53Z on spark-b87b +$ CUDAPP_DOCTOR_SHOW=1 sh tests/doctor/run.sh build/cudapp-doctor +===== fake machine: gb10-ready (exit 0) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu +PASS gb10-ready +===== fake machine: no-module (exit 1) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + FAIL NVIDIA kernel module: not loaded (/tmp/cudapp-doctor-test.EF0eSB/nomod/proc/driver/nvidia/version does not exist) + CUDA++ uses no NVIDIA user-space software, but it talks to NVIDIA's kernel module. + Do this: sudo modprobe nvidia && sudo modprobe nvidia-uvm + If modprobe finds no module, install NVIDIA's open kernel module 580.173.02 (the open-gpu-kernel-modules release of that number), then run make doctor again. + FAIL device files: /dev/nvidiactl is missing + Do this: sudo modprobe nvidia (or run nvidia-modprobe once, which creates the device files) + FAIL device files: /dev/nvidia0 is missing + Do this: sudo modprobe nvidia (or run nvidia-modprobe once, which creates the device files) + FAIL device files: /dev/nvidia-uvm is missing + Do this: sudo modprobe nvidia-uvm (creates /dev/nvidia-uvm; CUDA++ maps GPU memory through it) + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 4 problems above. Fix the first FAIL line and run make doctor again. +PASS no-module +===== fake machine: module-version (exit 1) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + FAIL NVIDIA kernel module: version 575.64.05 is loaded; CUDA++ speaks the 580.173.02 interface + Why: CUDA++ builds its driver calls from the 580.173.02 open-module headers + (third_party/nvidia-open-580.173.02). The layout of those calls can change between module versions, + and a wrong layout fails in strange ways, so CUDA++ refuses instead of guessing. + This is the only version CUDA++ asks you to match: no toolkit, no framework build, no extension build. + Do this: install the 580.173.02 open kernel module, or port the client to your version + (CONTRIBUTING.md, "Port a driver version": copy the new headers, rebuild, run make test and make hello-gpu). + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 1 problem above. Fix the first FAIL line and run make doctor again. +PASS module-version +===== fake machine: closed-module (exit 0) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + warn NVIDIA kernel module: the closed module 580.173.02 is loaded; CUDA++ was qualified on the open module of that version + It uses the same calls and should work. If anything fails, switch to the open module and say so in your report. + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu +PASS closed-module +===== fake machine: unknown-chip (exit 1) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + FAIL GPU 000f:01:00.0: NVIDIA device 0x2b85 is not one CUDA++ has qualified. + Why: CUDA++ writes each chip's machine code itself and has run it only on the NVIDIA GB10 (sm_121), + so it refuses this GPU now instead of failing later with "no kernel image is available". + What is missing: a target row for this chip, a check that the encoder's instruction words are valid on it, + its launch descriptor and class numbers, and the hello-gpu qualification run with its receipt. + What to do: follow docs/runtime/PORTABILITY.md section 5 ("What a new GPU needs") and CONTRIBUTING.md ("Port a chip"), + or report it with the output of `make doctor` attached. + info memory: 121.6 GiB system memory, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 1 problem above. Fix the first FAIL line and run make doctor again. +PASS unknown-chip +===== fake machine: no-gpu (exit 1) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + FAIL GPU: no NVIDIA GPU found in /sys/bus/pci/devices + Do this: check the GPU is seated and powered (lspci | grep -i nvidia). + info memory: 121.6 GiB system memory, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 1 problem above. Fix the first FAIL line and run make doctor again. +PASS no-gpu +===== fake machine: no-uvm (exit 1) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + FAIL device files: /dev/nvidia-uvm is missing + Do this: sudo modprobe nvidia-uvm (creates /dev/nvidia-uvm; CUDA++ maps GPU memory through it) + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 1 problem above. Fix the first FAIL line and run make doctor again. +PASS no-uvm +===== fake machine: no-permission (exit 1) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + FAIL device files: /dev/nvidia0 exists but this user cannot open it for reading and writing + Do this: ask the machine's owner to add you to the group that owns it (ls -l on the file shows it), + or set the module option NVreg_DeviceFileMode=0666. + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +NOT READY: 1 problem above. Fix the first FAIL line and run make doctor again. +PASS no-permission +===== fake machine: memory-line (exit 0) +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (none installed) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu +PASS memory-line +doctor tests: 9 passed, 0 failed +exit 0 diff --git a/evidence/dx/d2-doctor/host-suite.txt b/evidence/dx/d2-doctor/host-suite.txt new file mode 100644 index 00000000..82604e0c --- /dev/null +++ b/evidence/dx/d2-doctor/host-suite.txt @@ -0,0 +1,2 @@ +d2-doctor 8f3a6a2 make -k test rc=2; failing targets: test-gpu-attention test-gpu-engine-backend-mutants test-gpu-engine-mutants test-runtime-api test-runtime-portability-check test-runtime-portability-controls +# make -k test on this commit; main fc90713 fails the same 6 targets (~/handoffs/l400/suite-main.log), so this branch adds none diff --git a/evidence/dx/d2-doctor/make-doctor-spark.txt b/evidence/dx/d2-doctor/make-doctor-spark.txt new file mode 100644 index 00000000..f7511dc8 --- /dev/null +++ b/evidence/dx/d2-doctor/make-doctor-spark.txt @@ -0,0 +1,12 @@ +# commit 8f3a6a2d52c6a9a55cf37b7eccb2839321c835e5 branch dx/d2-doctor, run 2026-10-22T01:49:42Z on spark-b87b +$ make doctor +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.7 GiB shared by the CPU and the GPU, 61.3 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (one is installed at /usr/local/cuda/bin/nvcc; that is fine) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu +exit 0 diff --git a/evidence/dx/d2-doctor/negative-control.txt b/evidence/dx/d2-doctor/negative-control.txt new file mode 100644 index 00000000..6dcd11fc --- /dev/null +++ b/evidence/dx/d2-doctor/negative-control.txt @@ -0,0 +1,14 @@ +# commit 8f3a6a2d52c6a9a55cf37b7eccb2839321c835e5 branch dx/d2-doctor, run 2026-10-22T01:49:42Z on spark-b87b +# negative control: the GB10 row changed to device 0x2e13 (src/omega_gpu_chip.c); the suite must FAIL +$ make test-doctor +FAIL gb10-ready +PASS no-module +PASS module-version +FAIL closed-module +PASS unknown-chip +PASS no-gpu +PASS no-uvm +PASS no-permission +FAIL memory-line +doctor tests: 6 passed, 3 failed +exit (of grep) 0 diff --git a/evidence/dx/d2-doctor/test-doctor.txt b/evidence/dx/d2-doctor/test-doctor.txt new file mode 100644 index 00000000..a87c5785 --- /dev/null +++ b/evidence/dx/d2-doctor/test-doctor.txt @@ -0,0 +1,13 @@ +# commit 8f3a6a2d52c6a9a55cf37b7eccb2839321c835e5 branch dx/d2-doctor, run 2026-10-22T01:49:42Z on spark-b87b +$ make test-doctor +PASS gb10-ready +PASS no-module +PASS module-version +PASS closed-module +PASS unknown-chip +PASS no-gpu +PASS no-uvm +PASS no-permission +PASS memory-line +doctor tests: 9 passed, 0 failed +exit 0 diff --git a/evidence/dx/d3-faults/fault-report-spark.txt b/evidence/dx/d3-faults/fault-report-spark.txt new file mode 100644 index 00000000..938875d7 --- /dev/null +++ b/evidence/dx/d3-faults/fault-report-spark.txt @@ -0,0 +1,14 @@ +# commit 213a19a91629951f224935052156c01fa174e8be branch dx/d3-faults, run 2026-10-22T01:49:43Z on spark-b87b +$ build/hello_gpu --sim --bug=past-end +hello_gpu: c = a + b over 1048576 floats on the host simulator (no GPU), built with Omega's own kernel builder +kernel built in 28 us: 32 instructions, 12 registers, no compiler run, no cache +machine code sha256 6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1 +FAULT at launch 8 of 8 of kernel vecadd (simulator): global load outside every buffer + launch: grid 1025 x 1 blocks of 128 threads, n = 131073, first element 917504 + instruction: 11 of 19, LDG.E (4-byte load) + thread: block 1024, thread 0 (element 1048576 of the whole job) + address: 0xeba6fbc6f040 (4 bytes), 0 bytes past the end of buffer a = [0xeba6fb86f040, 0xeba6fbc6f040) (4194304 bytes) + simulator: MEM at pc 11: global access outside the declared buffers + next: launch 8 was given n = 131073, and buffer a holds 131072 elements from this launch's first element. + Fix the launch or the buffer, run hello_gpu --sim until it passes, then run hello_gpu on the GPU. +exit 1 diff --git a/evidence/dx/d3-faults/hello-sim-spark.txt b/evidence/dx/d3-faults/hello-sim-spark.txt new file mode 100644 index 00000000..512a4ac9 --- /dev/null +++ b/evidence/dx/d3-faults/hello-sim-spark.txt @@ -0,0 +1,22 @@ +# commit 213a19a91629951f224935052156c01fa174e8be branch dx/d3-faults, run 2026-10-22T01:49:43Z on spark-b87b +$ build/hello_gpu --sim +hello_gpu: c = a + b over 1048576 floats on the host simulator (no GPU), built with Omega's own kernel builder +kernel built in 22 us: 32 instructions, 12 registers, no compiler run, no cache +machine code sha256 6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1 +checked 1048576 of 1048576 elements: 0 wrong, 0 never written +work: 12582912 bytes moved (8388608 read, 4194304 written), 1048576 floating-point operations + at the GB10's measured 195.1 GB/s read ceiling this needs at least 64.5 us +output sha256 72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6 +PASS +exit 0 + +$ build/hello_gpu --sim (again: the hashes must match) +hello_gpu: c = a + b over 1048576 floats on the host simulator (no GPU), built with Omega's own kernel builder +kernel built in 23 us: 32 instructions, 12 registers, no compiler run, no cache +machine code sha256 6248b8ed338019f75e20b13a8ef7e63b4e35764229e0669ffbe54464353e87d1 +checked 1048576 of 1048576 elements: 0 wrong, 0 never written +work: 12582912 bytes moved (8388608 read, 4194304 written), 1048576 floating-point operations + at the GB10's measured 195.1 GB/s read ceiling this needs at least 64.5 us +output sha256 72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6 +PASS +exit 0 diff --git a/evidence/dx/d3-faults/host-suite.txt b/evidence/dx/d3-faults/host-suite.txt new file mode 100644 index 00000000..a70ea964 --- /dev/null +++ b/evidence/dx/d3-faults/host-suite.txt @@ -0,0 +1,2 @@ +d3-faults 213a19a make -k test rc=2; failing targets: test-gpu-attention test-gpu-engine-backend-mutants test-gpu-engine-mutants test-runtime-api test-runtime-portability-check test-runtime-portability-controls +# make -k test on this commit; main fc90713 fails the same 6 targets (~/handoffs/l400/suite-main.log), so this branch adds none diff --git a/evidence/dx/d3-faults/negative-control.txt b/evidence/dx/d3-faults/negative-control.txt new file mode 100644 index 00000000..4c9da5e4 --- /dev/null +++ b/evidence/dx/d3-faults/negative-control.txt @@ -0,0 +1,12 @@ +# commit 213a19a91629951f224935052156c01fa174e8be branch dx/d3-faults, run 2026-10-22T01:49:43Z on spark-b87b +# negative control: buffer bounds switched off (s.nranges = 0); the fault tests must FAIL +PASS sim-pass (exit 0) +PASS sim-checks +PASS work-line +PASS hashes-printed +PASS same-bits-twice +FAIL fault-exit: exit 0, want 1 +FAIL fault-report +FAIL fault run went on past the faulting launch +FAIL fault-address-is-end-of-a (addr= range=) +hello --sim tests: 5 passed, 4 failed diff --git a/evidence/dx/d3-faults/test-hello-sim.txt b/evidence/dx/d3-faults/test-hello-sim.txt new file mode 100644 index 00000000..60a5c837 --- /dev/null +++ b/evidence/dx/d3-faults/test-hello-sim.txt @@ -0,0 +1,12 @@ +# commit 213a19a91629951f224935052156c01fa174e8be branch dx/d3-faults, run 2026-10-22T01:49:43Z on spark-b87b +$ make test-hello-sim +PASS sim-pass (exit 0) +PASS sim-checks +PASS work-line +PASS hashes-printed +PASS same-bits-twice +PASS fault-exit (exit 1) +PASS fault-report +PASS fault-address-is-end-of-a +hello --sim tests: 8 passed, 0 failed +exit 0 diff --git a/evidence/dx/pain-points/counts.json b/evidence/dx/pain-points/counts.json new file mode 100644 index 00000000..1f9f114a --- /dev/null +++ b/evidence/dx/pain-points/counts.json @@ -0,0 +1,487 @@ +[ + { + "query": "\"no kernel image is available\"", + "api": "search/issues?q=%22no+kernel+image+is+available%22&per_page=1", + "total": 4033, + "err": "", + "run_at": "2026-10-22T00:18:27Z" + }, + { + "query": "\"no kernel image is available\" repo:pytorch/pytorch", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3Apytorch%2Fpytorch&per_page=1", + "total": 115, + "err": "", + "run_at": "2026-10-22T00:18:30Z" + }, + { + "query": "\"no kernel image is available\" repo:vllm-project/vllm", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3Avllm-project%2Fvllm&per_page=1", + "total": 115, + "err": "", + "run_at": "2026-10-22T00:18:33Z" + }, + { + "query": "\"no kernel image is available\" repo:flashinfer-ai/flashinfer", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3Aflashinfer-ai%2Fflashinfer&per_page=1", + "total": 18, + "err": "", + "run_at": "2026-10-22T00:18:35Z" + }, + { + "query": "\"no kernel image is available\" repo:Dao-AILab/flash-attention", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3ADao-AILab%2Fflash-attention&per_page=1", + "total": 16, + "err": "", + "run_at": "2026-10-22T00:18:38Z" + }, + { + "query": "\"no kernel image is available\" repo:triton-lang/triton", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3Atriton-lang%2Ftriton&per_page=1", + "total": 4, + "err": "", + "run_at": "2026-10-22T00:18:41Z" + }, + { + "query": "\"no kernel image is available\" repo:bitsandbytes-foundation/bitsandbytes", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3Abitsandbytes-foundation%2Fbitsandbytes&per_page=1", + "total": 20, + "err": "", + "run_at": "2026-10-22T00:18:44Z" + }, + { + "query": "\"no kernel image is available\" repo:facebookresearch/xformers", + "api": "search/issues?q=%22no+kernel+image+is+available%22+repo%3Afacebookresearch%2Fxformers&per_page=1", + "total": 7, + "err": "", + "run_at": "2026-10-22T00:18:47Z" + }, + { + "query": "\"sm_121\"", + "api": "search/issues?q=%22sm_121%22&per_page=1", + "total": 5803, + "err": "", + "run_at": "2026-10-22T00:18:50Z" + }, + { + "query": "\"sm_120\"", + "api": "search/issues?q=%22sm_120%22&per_page=1", + "total": 14112, + "err": "", + "run_at": "2026-10-22T00:18:53Z" + }, + { + "query": "\"sm_121a\"", + "api": "search/issues?q=%22sm_121a%22&per_page=1", + "total": 1683, + "err": "", + "run_at": "2026-10-22T00:18:56Z" + }, + { + "query": "\"DGX Spark\"", + "api": "search/issues?q=%22DGX+Spark%22&per_page=1", + "total": 22302, + "err": "", + "run_at": "2026-10-22T00:18:59Z" + }, + { + "query": "\"GB10\"", + "api": "search/issues?q=%22GB10%22&per_page=1", + "total": 23834, + "err": "", + "run_at": "2026-10-22T00:19:02Z" + }, + { + "query": "\"detected CUDA version\" mismatches", + "api": "search/issues?q=%22detected+CUDA+version%22+mismatches&per_page=1", + "total": 569, + "err": "", + "run_at": "2026-10-22T00:19:05Z" + }, + { + "query": "\"CUDA driver version is insufficient\"", + "api": "search/issues?q=%22CUDA+driver+version+is+insufficient%22&per_page=1", + "total": 1507, + "err": "", + "run_at": "2026-10-22T00:19:08Z" + }, + { + "query": "\"undefined symbol\" repo:Dao-AILab/flash-attention", + "api": "search/issues?q=%22undefined+symbol%22+repo%3ADao-AILab%2Fflash-attention&per_page=1", + "total": 72, + "err": "", + "run_at": "2026-10-22T00:19:11Z" + }, + { + "query": "\"undefined symbol\" repo:vllm-project/vllm", + "api": "search/issues?q=%22undefined+symbol%22+repo%3Avllm-project%2Fvllm&per_page=1", + "total": 190, + "err": "", + "run_at": "2026-10-22T00:19:14Z" + }, + { + "query": "\"not compatible with the current PyTorch installation\"", + "api": "search/issues?q=%22not+compatible+with+the+current+PyTorch+installation%22&per_page=1", + "total": 1054, + "err": "", + "run_at": "2026-10-22T00:19:17Z" + }, + { + "query": "\"sm_120 is not compatible\"", + "api": "search/issues?q=%22sm_120+is+not+compatible%22&per_page=1", + "total": 458, + "err": "", + "run_at": "2026-10-22T00:19:20Z" + }, + { + "query": "\"DGX Spark\" is:issue", + "api": "search/issues?q=%22DGX+Spark%22+is%3Aissue&per_page=1", + "total": 8268, + "err": "", + "run_at": "2026-10-22T00:19:23Z" + }, + { + "query": "GitHub search/issues q=\"illegal memory access was encountered\"", + "total": 7833, + "run_at": "2026-10-22T00:22:30Z" + }, + { + "query": "GitHub search/issues q=\"CUDA_LAUNCH_BLOCKING\"", + "total": 10356, + "run_at": "2026-10-22T00:22:33Z" + }, + { + "query": "GitHub search/issues q=\"device-side assert triggered\"", + "total": 4232, + "run_at": "2026-10-22T00:22:36Z" + }, + { + "query": "GitHub search/issues q=\"CUBLAS_WORKSPACE_CONFIG\"", + "total": 1117, + "run_at": "2026-10-22T00:22:39Z" + }, + { + "query": "GitHub search/issues q=\"use_deterministic_algorithms\"", + "total": 526, + "run_at": "2026-10-22T00:22:43Z" + }, + { + "query": "GitHub search/issues q=nondeterministic cuda", + "total": 5416, + "run_at": "2026-10-22T00:22:46Z" + }, + { + "query": "GitHub search/issues q=\"CUDA out of memory\"", + "total": 26390, + "run_at": "2026-10-22T00:22:50Z" + }, + { + "query": "GitHub search/issues q=nvcc \"compile time\"", + "total": 7646, + "run_at": "2026-10-22T00:22:53Z" + }, + { + "query": "GitHub search/issues q=ROCm \"not supported\"", + "total": 17774, + "run_at": "2026-10-22T00:22:56Z" + }, + { + "query": "GitHub search/issues q=ZLUDA", + "total": 2902, + "run_at": "2026-10-22T00:23:00Z" + }, + { + "query": "GitHub search/issues q=\"might be asynchronously reported\"", + "total": 6812, + "run_at": "2026-10-22T00:23:03Z" + }, + { + "query": "GitHub search/issues q=\"cudaErrorIllegalAddress\"", + "total": 1883, + "run_at": "2026-10-22T00:23:06Z" + }, + { + "query": "StackOverflow search/advanced q=illegal memory access was encountered", + "total": 166, + "run_at": "2026-10-22T00:23:15Z" + }, + { + "query": "StackOverflow search/advanced q=CUDA_LAUNCH_BLOCKING", + "total": 114, + "run_at": "2026-10-22T00:23:15Z" + }, + { + "query": "StackOverflow search/advanced q=device-side assert triggered", + "total": 86, + "run_at": "2026-10-22T00:23:16Z" + }, + { + "query": "StackOverflow search/advanced q=CUBLAS_WORKSPACE_CONFIG", + "total": 4, + "run_at": "2026-10-22T00:23:17Z" + }, + { + "query": "StackOverflow search/advanced q=CUDA out of memory", + "total": 1501, + "run_at": "2026-10-22T00:23:18Z" + }, + { + "query": "StackOverflow search/advanced q=nvcc compile time", + "total": 189, + "run_at": "2026-10-22T00:23:18Z" + }, + { + "query": "StackOverflow search/advanced q=ROCm not supported", + "total": 32, + "run_at": "2026-10-22T00:23:19Z" + }, + { + "query": "StackOverflow search/advanced q=ZLUDA", + "total": 4, + "run_at": "2026-10-22T00:23:20Z" + }, + { + "query": "HN algolia tags=story query=CUDA moat", + "total": 125, + "run_at": "2026-10-22T00:23:21Z", + "top_stories": [ + { + "title": "AMD may get across the CUDA moat", + "points": 551, + "id": "37793635", + "created_at": "2023-10-06T17:35:36Z" + }, + { + "title": "CUDA Moat Still Alive", + "points": 221, + "id": "42489844", + "created_at": "2024-12-22T22:47:09Z" + }, + { + "title": "Jim Keller criticizes Nvidia's CUDA, x86", + "points": 197, + "id": "39480341", + "created_at": "2024-02-23T13:32:30Z" + } + ] + }, + { + "query": "HN algolia tags=story query=ZLUDA", + "total": 89, + "run_at": "2026-10-22T00:23:22Z", + "top_stories": [ + { + "title": "Open-source project ZLUDA lets CUDA apps run on AMD GPUs", + "points": 409, + "id": "39604745", + "created_at": "2024-03-05T15:36:27Z" + }, + { + "title": "Zluda: CUDA on Intel GPUs", + "points": 261, + "id": "26262038", + "created_at": "2021-02-25T12:12:43Z" + }, + { + "title": "Zluda: Run CUDA code on Intel GPUs, unmodified", + "points": 237, + "id": "36341211", + "created_at": "2023-06-15T14:42:49Z" + } + ] + }, + { + "query": "HN algolia tags=story query=ROCm", + "total": 28902, + "run_at": "2026-10-22T00:23:22Z", + "top_stories": [ + { + "title": "AMD funded a drop-in CUDA implementation built on ROCm: It's now open-source", + "points": 1045, + "id": "39344815", + "created_at": "2024-02-12T14:00:35Z" + }, + { + "title": "PyTorch 1.8, with AMD ROCm support", + "points": 313, + "id": "26353184", + "created_at": "2021-03-05T05:38:02Z" + }, + { + "title": "ROCm is AMD's priority, executive says", + "points": 293, + "id": "37663194", + "created_at": "2023-09-26T17:54:42Z" + } + ] + }, + { + "query": "HN algolia tags=story query=CUDA", + "total": 14967, + "run_at": "2026-10-22T00:23:23Z", + "top_stories": [ + { + "title": "Run CUDA, unmodified, on AMD GPUs", + "points": 1330, + "id": "40970560", + "created_at": "2024-07-15T19:05:07Z" + }, + { + "title": "Llm.c \u2013 LLM training in simple, pure C/CUDA", + "points": 1050, + "id": "39973467", + "created_at": "2024-04-08T20:38:49Z" + }, + { + "title": "AMD funded a drop-in CUDA implementation built on ROCm: It's now open-source", + "points": 1045, + "id": "39344815", + "created_at": "2024-02-12T14:00:35Z" + } + ] + }, + { + "query": "HN algolia tags=story query=nvidia lock-in", + "total": 17, + "run_at": "2026-10-22T00:23:23Z", + "top_stories": [ + { + "title": "Modular 25.4: One Container, AMD and Nvidia GPUs, No Lock-In", + "points": 7, + "id": "44311578", + "created_at": "2025-06-18T17:05:29Z" + }, + { + "title": "Nvidia's moat is not what it used to be", + "points": 6, + "id": "47740552", + "created_at": "2026-04-12T15:03:11Z" + }, + { + "title": "Show HN: LLMOne \u2013 Deploy LLMs from bare metal to production in hours", + "points": 5, + "id": "44345471", + "created_at": "2025-06-22T09:44:37Z" + } + ] + }, + { + "query": "HN algolia tags=story query=local LLM", + "total": 2989, + "run_at": "2026-10-22T00:23:23Z", + "top_stories": [ + { + "title": "Show HN: Clippy \u2013 90s UI for local LLMs", + "points": 1122, + "id": "43905942", + "created_at": "2025-05-06T15:02:22Z" + }, + { + "title": "Building a fully local LLM voice assistant to control my smart home", + "points": 699, + "id": "38985152", + "created_at": "2024-01-13T22:12:10Z" + }, + { + "title": "The local LLM ecosystem doesn\u2019t need Ollama", + "points": 648, + "id": "47788385", + "created_at": "2026-04-16T03:35:11Z" + } + ] + }, + { + "query": "HN algolia tags=story query=VRAM", + "total": 50907, + "run_at": "2026-10-22T00:23:24Z", + "top_stories": [ + { + "title": "1.5 TB of VRAM on Mac Studio \u2013 RDMA over Thunderbolt 5", + "points": 617, + "id": "46319657", + "created_at": "2025-12-18T22:23:09Z" + }, + { + "title": "Linux 7.3 improves performance when running out of vRAM", + "points": 547, + "id": "49342719", + "created_at": "2026-08-18T07:51:50Z" + }, + { + "title": "Use your Nvidia GPU's VRAM as swap space on Linux", + "points": 472, + "id": "48377404", + "created_at": "2026-06-02T22:55:33Z" + } + ] + }, + { + "query": "\"TORCH_CUDA_ARCH_LIST\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22TORCH_CUDA_ARCH_LIST%22", + "total": 11034, + "err": "", + "run_at": "2026-10-22T00:39:17Z" + }, + { + "query": "\"Precompiled wheel not found\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22Precompiled%20wheel%20not%20found%22", + "total": 73, + "err": "", + "run_at": "2026-10-22T00:39:24Z" + }, + { + "query": "\"ptxas fatal\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22ptxas%20fatal%22", + "total": 1508, + "err": "", + "run_at": "2026-10-22T00:39:32Z" + }, + { + "query": "\"cudaErrorNoKernelImageForDevice\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22cudaErrorNoKernelImageForDevice%22", + "total": 600, + "err": "", + "run_at": "2026-10-22T00:39:39Z" + }, + { + "query": "\"CUDA error: out of memory\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22CUDA%20error%3A%20out%20of%20memory%22", + "total": 12124, + "err": "", + "run_at": "2026-10-22T00:39:47Z" + }, + { + "query": "\"JIT compilation\" hang cuda", + "api": "https://api.github.com/search/issues?per_page=1&q=%22JIT%20compilation%22%20hang%20cuda", + "total": 517, + "err": "", + "run_at": "2026-10-22T00:39:54Z" + }, + { + "query": "\"CUDA context\" memory overhead", + "api": "https://api.github.com/search/issues?per_page=1&q=%22CUDA%20context%22%20memory%20overhead", + "total": 3478, + "err": "", + "run_at": "2026-10-22T00:40:01Z" + }, + { + "query": "\"nvidia-smi\" \"CUDA Version\" mismatch toolkit", + "api": "https://api.github.com/search/issues?per_page=1&q=%22nvidia-smi%22%20%22CUDA%20Version%22%20mismatch%20toolkit", + "total": 932, + "err": "", + "run_at": "2026-10-22T00:40:09Z" + }, + { + "query": "\"compute-sanitizer\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22compute-sanitizer%22", + "total": 6991, + "err": "", + "run_at": "2026-10-22T00:40:16Z" + }, + { + "query": "\"cuda-gdb\"", + "api": "https://api.github.com/search/issues?per_page=1&q=%22cuda-gdb%22", + "total": 2708, + "err": "", + "run_at": "2026-10-22T00:40:24Z" + } +] \ No newline at end of file diff --git a/evidence/dx/pain-points/d5-build-from-empty.txt b/evidence/dx/pain-points/d5-build-from-empty.txt new file mode 100644 index 00000000..3291577f --- /dev/null +++ b/evidence/dx/pain-points/d5-build-from-empty.txt @@ -0,0 +1,15 @@ +# D5: build CUDA++ from an empty folder 2026-10-22T01:50:38Z on spark-b87b, 20 cores +# load before: 31.31 27.10 23.18 gcc: 13.3.0 make: GNU Make 4.3 +$ git clone -b dx/pain-points cudapp && cd cudapp +commit 2e3804976498ae328e9d7a0538828e7074b789af +$ time make -j20 +exit 0, wall 2.034379307 s +# load after: 31.31 27.10 23.18 +$ ls -l build/libcudapp.a; size totals +1060126 build/libcudapp.a + 551938 46705 1642600 2241243 2232db (TOTALS) +$ git ls-files | wc -l; du -sh --exclude=.git --exclude=build . +431 +6.3M +$ nm -u build/libcudapp.a | grep -c -i cuda (CUDA symbols the library needs) +0 diff --git a/evidence/dx/pain-points/host-suite.txt b/evidence/dx/pain-points/host-suite.txt new file mode 100644 index 00000000..4715d551 --- /dev/null +++ b/evidence/dx/pain-points/host-suite.txt @@ -0,0 +1,6 @@ +dx/pain-points 2e38049 make -k test rc=2; failing targets: test-gpu-attention test-gpu-engine-backend-mutants test-gpu-engine-mutants test-runtime-api test-runtime-portability-check test-runtime-portability-controls +test_omega_gpu_platform_linux (reference only, simulated driver): 9 passed, 0 failed +doctor tests: 9 passed, 0 failed +hello --sim tests: 8 passed, 0 failed +done 2026-10-22T01:53:06Z +# main fc90713 fails the same 6 targets before any L400 change (~/handoffs/l400/suite-main.log) diff --git a/evidence/dx/pain-points/ledger.json b/evidence/dx/pain-points/ledger.json new file mode 100644 index 00000000..9d64814e --- /dev/null +++ b/evidence/dx/pain-points/ledger.json @@ -0,0 +1,1337 @@ +{ + "version": 1, + "sources": [ + { + "id": 1, + "url": "https://github.com/sudoingX/dgx-spark-laguna", + "title": "sudoingX/dgx-spark-laguna README", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The published Docker images do not carry sm_121a kernels, a missing environment variable silently breaks the NVFP4 MoE, and a deep-context request with speculative decoding will hard hang the entire machine.", + "added": "2026-10-21" + }, + { + "text": "Without it the NVFP4 MoE CUTLASS kernels are not built for GB10 and you get CUDA error: no kernel image is available for execution on the device .", + "added": "2026-10-21" + } + ] + }, + { + "id": 2, + "url": "https://github.com/sudoingX/dgx-spark-laguna/blob/main/FINDINGS.md", + "title": "dgx-spark-laguna FINDINGS.md", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "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.", + "added": "2026-10-21" + }, + { + "text": "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`.", + "added": "2026-10-21" + }, + { + "text": "The published `vllm/vllm-openai:cu129-nightly` image resolves to `0.23.1rc1.dev`, not 0.25.1, and its kernels are not built for `sm_121a`.", + "added": "2026-10-21" + } + ] + }, + { + "id": 3, + "url": "https://github.com/vllm-project/vllm/issues/43009", + "title": "[Bug]: Triton kernel JIT compilation during inference", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Curious if anyone else is experiencing this because for me it completely hangs vllm at:", + "added": "2026-10-21" + } + ] + }, + { + "id": 4, + "url": "https://github.com/state-spaces/mamba/issues/1019", + "title": "No prebuilt wheels for sm_103 (B300) and sm_121 (GB10)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "pip install mamba-ssm # installs prebuilt wheel for sm_75-sm_90", + "added": "2026-10-21" + } + ] + }, + { + "id": 5, + "url": "https://github.com/Dao-AILab/causal-conv1d/issues/119", + "title": "No prebuilt wheels for sm_121 (GB10 / DGX Spark)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "`causal-conv1d` does not ship prebuilt wheels for **sm_121** (GB10 / DGX Spark / Project DIGITS). Users must compile from source.", + "added": "2026-10-21" + }, + { + "text": "Additionally, issue #105 documents a **numerical correctness bug** for sm_103 (B300): cubins built with CUDA 13.x nvcc for sm_103 produce wrong output (max_abs_diff ~0.4-0.6).", + "added": "2026-10-21" + } + ] + }, + { + "id": 6, + "url": "https://github.com/flashinfer-ai/flashinfer/issues/5238", + "title": "[Bug] SM121 (DGX Spark GB10): mixed mxfp8 x mxfp4 fused MoE dies in moe_sort routing with \"no kernel image is available\"", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "the mixed path still dies at routing time because a prebuilt, SM100-only `moe_utils` artifact takes precedence over the local JIT build.", + "added": "2026-10-21" + } + ] + }, + { + "id": 7, + "url": "https://github.com/flashinfer-ai/flashinfer/issues/3170", + "title": "DGX Spark (SM121) Current Support Audit", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "**SM121 falls through to cutlass/cudnn only.**", + "added": "2026-10-21" + } + ] + }, + { + "id": 8, + "url": "https://github.com/triton-lang/triton/issues/10331", + "title": "Docs: bring-up recipe for Triton on NVIDIA Blackwell sm_121 (GB10 / DGX Spark / consumer Blackwell)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I was unable to find an authoritative doc page or pinned issue with the correct bring-up steps, and the workarounds that surface in search results actively make things worse", + "added": "2026-10-21" + }, + { + "text": "Those \"fixes\" produce a kernel that loads and then computes wrong numbers, which is so much worse than a clean \"no kernel image\" crash.", + "added": "2026-10-21" + }, + { + "text": "a warm `~/.triton/cache` populated on an `sm_120` box (or an earlier toolchain) gets reused on `sm_121` and silently miscompiles instead of rebuilding.", + "added": "2026-10-21" + } + ] + }, + { + "id": 9, + "url": "https://github.com/Dao-AILab/flash-attention/issues/1969", + "title": "Support for compute capability 12.1 (sm121) - NVIDIA GB10 GPU", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Building from source fails with kernel mismatch: \"FATAL: kernel built for sm80-sm100, but running on sm121\"", + "added": "2026-10-21" + }, + { + "text": "Minimum and Maximum cuda capability supported by this version of PyTorch is\n (8.0) - (12.0)", + "added": "2026-10-21" + } + ] + }, + { + "id": 10, + "url": "https://github.com/pytorch/pytorch/issues/31285", + "title": "Cuda error: no kernel image is available for execution on the device", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "But starting from 1.3.1, we start to compile binaries only for arch 3.7 and up.", + "added": "2026-10-21" + } + ] + }, + { + "id": 11, + "url": "https://github.com/pytorch/pytorch/issues/49161", + "title": "RuntimeError: CUDA error: no kernel image is available for execution on the driver, when use pytorch 1.7 on linux with R", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I am a skilled user of pytorch-gpu, recently I purchased an RTX 3090 server, but the bug with pytorch 1.7 and RT 3090 makes me mad.", + "added": "2026-10-21" + } + ] + }, + { + "id": 12, + "url": "https://github.com/pytorch/pytorch/issues/159207", + "title": "Add official support for CUDA sm_120 (RTX 5090 / Blackwell architecture)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Users are forced to either build PyTorch from source or use experimental nightly builds with limited platform support.", + "added": "2026-10-21" + } + ] + }, + { + "id": 13, + "url": "https://github.com/pytorch/pytorch/issues/164342", + "title": "Official support for sm_120 (RTX 50-series / Blackwell) in stable PyTorch builds", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "As a researcher, I purchased RTX 5070 Ti for deep learning workloads, but currently it cannot be used productively with DLC due to this gap.", + "added": "2026-10-21" + } + ] + }, + { + "id": 14, + "url": "https://github.com/vllm-project/vllm/issues/13306", + "title": "[Feature]: Support for RTX 5090 (CUDA 12.8)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "NVIDIA GeForce RTX 5090 with CUDA capability sm_120 is not compatible with the current PyTorch installation.", + "added": "2026-10-21" + } + ] + }, + { + "id": 15, + "url": "https://github.com/vllm-project/vllm/issues/14452", + "title": "[Doc]: Steps to run vLLM on your RTX5080 or 5090!", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Please note here that we can't use precompiled vLLM because `vllm-project/vllm` has not moved to the required torch and CUDA versions yet.", + "added": "2026-10-21" + }, + { + "text": "This causes a nightly to be silently installed, which fails at runtime due to an `undefined-symbol` error because `_C.abi3.so` fails at runtime.", + "added": "2026-10-21" + } + ] + }, + { + "id": 16, + "url": "https://github.com/pytorch/pytorch/issues/157517", + "title": "[release 2.8-2.9] Delete support for Maxwell, Pascal, and Volta architectures for CUDA 12.8 and 12.9 builds", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Update: Option 2 is not a possible due to large binary size.", + "added": "2026-10-21" + } + ] + }, + { + "id": 17, + "url": "https://github.com/pytorch/pytorch/issues/159779", + "title": "Enable CUDA 13.0 binaries", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Note: CUDA 12.9 first introduced sm_12x and sm_10x arch support, which will be compatible with sm_120 and sm_100 binaries respectively.", + "added": "2026-10-21" + } + ] + }, + { + "id": 18, + "url": "https://github.com/vllm-project/vllm/issues/1548", + "title": "The detected CUDA version (11.8) mismatches the version that was used to compile PyTorch (12.1).", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I have no idea about this issue, even though I pre-install pytorch=2.0.1+cu11.8, it still failed.", + "added": "2026-10-21" + } + ] + }, + { + "id": 19, + "url": "https://github.com/graphdeco-inria/gaussian-splatting/issues/332", + "title": "Error installation of diff-gaussian-rasterization and found solution", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I followed the README and the video at https://www.youtube.com/watch?v=UXtuigy_wYc but i fell in a slump for a few hours due to persistent errors in installing as suggested.", + "added": "2026-10-21" + } + ] + }, + { + "id": 20, + "url": "https://github.com/Dao-AILab/flash-attention/issues/246", + "title": "No Module Named 'torch'", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I don't know a right solution that works for all setups, happy to hear suggestions.", + "added": "2026-10-21" + } + ] + }, + { + "id": 21, + "url": "https://github.com/Dao-AILab/flash-attention/issues/451", + "title": "Flash Attention 2.0 doesn't work: undefined symbol: _ZNK3c1010TensorImpl27throw_data_ptr_access_errorEv", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "undefined symbol: _ZNK3c1010TensorImpl27throw_data_ptr_access_errorEv", + "added": "2026-10-21" + } + ] + }, + { + "id": 22, + "url": "https://github.com/Dao-AILab/flash-attention/issues/966", + "title": "ImportError: flash_attn_2_cuda...so: undefined symbol: _ZN3c104cuda9SetDeviceEi", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Like others (@rkuo2000) are mentioning, only some specific versions are working.", + "added": "2026-10-21" + } + ] + }, + { + "id": 23, + "url": "https://github.com/Dao-AILab/flash-attention/issues/1799", + "title": "Problems with the installation of flash_attn with pytorch 2.8.0+cu128", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Precompiled wheel not found. Building from source...", + "added": "2026-10-21" + } + ] + }, + { + "id": 24, + "url": "https://github.com/microsoft/onnxruntime/issues/27005", + "title": "[Feature Request] Support aarch64 for onnxruntime-gpu", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "only has wheels for the following platforms: `manylinux_2_27_x86_64`, `manylinux_2_28_x86_64`, `win_amd64`", + "added": "2026-10-21" + } + ] + }, + { + "id": 25, + "url": "https://github.com/microsoft/onnxruntime/issues/22903", + "title": "[Feature Request] Add official support for onnxruntime-gpu on ARM64/aarch64 platforms", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "No official pre-built wheels for onnxruntime-gpu on ARM64/aarch64", + "added": "2026-10-21" + } + ] + }, + { + "id": 26, + "url": "https://github.com/bitsandbytes-foundation/bitsandbytes/issues/1937", + "title": "[Windows] RTX 5070 Ti (Blackwell sm_120) - quantization support missing", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "custom builds require CUDA Toolkit 12.x which conflicts with CUDA 13.0+ driver requirements", + "added": "2026-10-21" + } + ] + }, + { + "id": 27, + "url": "https://github.com/NVIDIA/personaplex/issues/3", + "title": "PersonaPlex produces choppy/unusable audio on DGX Spark (GB10)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Audio output is extremely choppy and unusable for real-time conversation.", + "added": "2026-10-21" + } + ] + }, + { + "id": 28, + "url": "https://forums.developer.nvidia.com/t/what-a-missed-opportunity-for-nvidia/353585", + "title": "What a missed opportunity for nvidia", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "How many times have you tried to run something that doesn’t recognize SM121 and fails?", + "added": "2026-10-21" + }, + { + "text": "It took several weeks of community effort here to get vllm working reasonably well, in both standalone and cluster configuration.", + "added": "2026-10-21" + } + ] + }, + { + "id": 29, + "url": "https://forums.developer.nvidia.com/t/psa-state-of-fp4-nvfp4-support-for-dgx-spark-in-vllm/353069", + "title": "PSA: State of FP4/NVFP4 Support for DGX Spark in VLLM", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "As of today, FP4 is not properly utilized in current VLLM builds on our hardware, so you lose a lot of performance picking NVFP4 quants compared to AWQ 4-bit ones.", + "added": "2026-10-21" + } + ] + }, + { + "id": 30, + "url": "https://forums.developer.nvidia.com/t/fp4-on-dgx-spark-why-it-doesnt-scale-like-youd-expect/360142", + "title": "FP4 on DGX Spark — Why It Doesn't Scale Like You'd Expect", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The 5th gen tensor core instructions that make FP4 fast on B200 (SM100) don’t exist on the Spark.", + "added": "2026-10-21" + } + ] + }, + { + "id": 31, + "url": "https://forums.developer.nvidia.com/t/gemma-4-on-dgx-spark-gb10-system-freeze-at-80-utilization-sm-121-kernel-issues/366060", + "title": "Gemma 4 on DGX Spark (GB10): System Freeze at >80% Utilization & sm_121 Kernel Issues", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I am experiencing a critical system-level freeze (hard-lock requiring power cycle) on the DGX Spark when running Gemma 4 at high memory utilization.", + "added": "2026-10-21" + }, + { + "text": "Official aarch64 images (e.g., vllm-openai:latest ) lacks sm_121 targets in their prebuilt binaries, defaulting to sm_120 , which causes decoding errors or crashes.", + "added": "2026-10-21" + } + ] + }, + { + "id": 32, + "url": "https://forums.developer.nvidia.com/t/my-dgx-spark-hangs-is-this-normal/365930", + "title": "My DGX Spark Hangs ... is this normal?", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The whole DGX Spark machine hangs completely—no mouse or keyboard response, nothing. no visual errors, no logs errors .", + "added": "2026-10-21" + } + ] + }, + { + "id": 33, + "url": "https://forums.developer.nvidia.com/t/running-llama-3-1-8b-fp4-get-triton-error-value-sm-121a-is-not-defined-for-option-gpu-name/348808", + "title": "Running Llama-3.1-8B-FP4 get triton error. Value 'sm_121a' is not defined for option 'gpu-name'", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "ptxas-blackwell fatal : Value ‘sm_121a’ is not defined for option ‘gpu-name’", + "added": "2026-10-21" + } + ] + }, + { + "id": 34, + "url": "https://forums.developer.nvidia.com/t/help-running-nemotron-3-nano-30b-a3b-fp8-on-dgx-spark-gb10/354771", + "title": "Help running Nemotron 3 Nano 30B-A3B-FP8 on DGX Spark (GB10)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Conclusion: Nemotron 3 Nano 30B currently cannot run on DGX Spark via SGLang due to Triton’s lack of sm_121a support.", + "added": "2026-10-21" + }, + { + "text": "Update 2: Setting TRITON_PTXAS_PATH doesn’t help - Triton ignores it in newer versions and uses its bundled ptxas which doesn’t support sm_121a.", + "added": "2026-10-21" + } + ] + }, + { + "id": 35, + "url": "https://forums.developer.nvidia.com/t/dgx-spark-cuda-install-pitfalls-on-ubuntu-24-04-arm64-fixed/349881", + "title": "DGX Spark: CUDA Install Pitfalls on Ubuntu 24.04 (ARM64) – FIXED", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "getting a working CUDA toolkit (with nvcc ) turned into a trap maze.", + "added": "2026-10-21" + }, + { + "text": "that value reflects the driver’s runtime capability , not the presence of the toolkit .", + "added": "2026-10-21" + } + ] + }, + { + "id": 36, + "url": "https://forums.developer.nvidia.com/t/pytorch-2-4-and-below-10x-slowdown-on-nvidia-gb10-sm-121-due-to-missing-kernel-support/348907", + "title": "PyTorch 2.4 and below: 10x slowdown on NVIDIA GB10 (sm_121) due to missing kernel support", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Minimum and Maximum cuda capability supported by this version of PyTorch is (8.0) - (12.0)", + "added": "2026-10-21" + } + ] + }, + { + "id": 37, + "url": "https://forums.developer.nvidia.com/t/roadblock-dgx-spark-pytorch-2-8-and-ngc-25-09-missing-support-for-gb10-gpus-with-sm-121-for-flux-training/351552", + "title": "Roadblock: DGX Spark. PyTorch 2.8 and NGC 25.09 missing support for GB10 GPUs with sm_121 for FLUX training", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I am running into roadblocks with my newly purcchased DGX Spark.", + "added": "2026-10-21" + } + ] + }, + { + "id": 38, + "url": "https://discuss.pytorch.org/t/dgx-spark-gb10-cuda-13-0-python-3-12-sm-121/223744", + "title": "DGX Spark GB10 Cuda 13.0 Python 3.12 SM_121", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "FATAL: kernel fmha_cutlassF_f16_aligned_64x128_rf_sm80 is for sm80-sm100, but was built for sm121", + "added": "2026-10-21" + }, + { + "text": "i simply cannot believe GB10 is that slow in Spark ….", + "added": "2026-10-21" + }, + { + "text": "Every PyTorch build with CUDA 12.8 and sm_120 support already supports sm_121 (DGXSpark) as these architectures are binary compatible.", + "added": "2026-10-21" + } + ] + }, + { + "id": 39, + "url": "https://discuss.pytorch.org/t/nvidia-dgx-spark-support/223677", + "title": "NVIDIA DGX Spark support", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "ERROR: Could not find a version that satisfies the requirement torch (from versions: none)", + "added": "2026-10-21" + } + ] + }, + { + "id": 40, + "url": "https://discuss.pytorch.org/t/the-detected-cuda-version-12-0-mismatches-the-version-that-was-used-to-compile-pytorch-11-7/169586", + "title": "The detected CUDA version (12.0) mismatches the version that was used to compile PyTorch (11.7)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The PyTorch binaries do not support CUDA 12 yet and you would have to build from source using a locally installed CUDA 12.0 toolkit.", + "added": "2026-10-21" + } + ] + }, + { + "id": 41, + "url": "https://simonwillison.net/2025/Oct/14/nvidia-dgx-spark", + "title": "NVIDIA DGX Spark: great hardware, early days for the ecosystem", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I eventually managed to get a PyTorch 2.7 wheel for CUDA on ARM, but failed to do so for 2.8.", + "added": "2026-10-21" + }, + { + "text": "I have not yet got my head around the difference between CUDA 12 and 13. 13 appears to be very new, and a lot of the existing tutorials and libraries appear to expect 12.", + "added": "2026-10-21" + } + ] + }, + { + "id": 42, + "url": "https://lmsys.org/blog/2025-10-13-nvidia-dgx-spark", + "title": "NVIDIA DGX Spark In-Depth Review: A New Standard for Local AI Inference", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "However, the only downside of this machine lies in memory bandwidth, the unified memory is LPDDR5x, offering up to 273 GB/s , shared across both CPU and GPU.", + "added": "2026-10-21" + } + ] + }, + { + "id": 43, + "url": "https://news.ycombinator.com/item?id=45713835", + "title": "Nvidia DGX Spark: When benchmark numbers meet production reality (HN)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I haven't exactly bisected the issue but I'm pretty sure convolutions are broken on sm_121 after a certain size, getting 20x memory blowup from a convolution from a 2x batch size increase _only_ on the DGX Spark.", + "added": "2026-10-21" + } + ] + }, + { + "id": 44, + "url": "https://news.ycombinator.com/item?id=45575127", + "title": "NVIDIA DGX Spark In-Depth Review (HN)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "To me it seems like you're paying more than twice the price mostly for CUDA compatibility.", + "added": "2026-10-21" + } + ] + }, + { + "id": 45, + "url": "https://vllm.ai/blog/2025-08-11-cuda-debugging", + "title": "CUDA Core Dump: An Effective Tool to Debug Memory Access Issues and Beyond (vLLM blog)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "In our experience the python stack traces for these types of exceptions are basically always incorrect and pretty worthless.", + "added": "2026-10-21" + }, + { + "text": "Many people launch CUDA kernels using the kernel<<<>>> syntax without adding error checking for the kernel launch status, for example, this code.", + "added": "2026-10-21" + }, + { + "text": "Have you ever felt you are developing cuda kernels and your tests often run into illegal memory access (IMA for short) and you have no idea how to debug? We definitely felt this pain again and again while working on vLLM, a high-performance inference engine for LLM models.", + "added": "2026-10-21" + } + ] + }, + { + "id": 46, + "url": "https://docs.pytorch.org/docs/2.14/notes/cuda.html", + "title": "CUDA semantics — PyTorch docs", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "When you call a function that uses the GPU, the operations are enqueued to the particular device, but not necessarily executed until later.", + "added": "2026-10-21" + }, + { + "text": "However, the unused memory managed by the allocator will still show as if used in nvidia-smi.", + "added": "2026-10-21" + }, + { + "text": "This can reduce fragmentation and may allow some borderline workloads to complete without running out of memory.", + "added": "2026-10-21" + } + ] + }, + { + "id": 47, + "url": "https://forums.developer.nvidia.com/t/271625", + "title": "CUDA errors: determine \"sticky-ness\" (NVIDIA Developer Forums)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Pretty much all asynchronous errors (these are errors that occur as a result of device code execution) are sticky.", + "added": "2026-10-21" + }, + { + "text": "My goal is to determine whether or not restart the executable, otherwise I will restart it for every cuda-related error, but it is a pity.", + "added": "2026-10-21" + } + ] + }, + { + "id": 48, + "url": "https://forums.developer.nvidia.com/t/225877", + "title": "Compute-sanitizer not quite a drop-in replacement of cuda-memcheck (NVIDIA Developer Forums)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "This is hard to use in CI build farms that have a very strict network configuration.", + "added": "2026-10-21" + } + ] + }, + { + "id": 49, + "url": "https://developer.nvidia.com/blog/better-bug-detection-how-compile-time-instrumentation-for-compute-sanitizer-enhances-memory-safety", + "title": "Better Bug Detection: How Compile-Time Instrumentation for Compute Sanitizer Enhances Memory Safety (NVIDIA Technical Bl", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Compile-time instrumentation catches bugs that binary instrumentation misses, such as buffer overruns into neighboring allocated memory, while lowering runtime overhead in some cases by nearly an order of magnitude.", + "added": "2026-10-21" + } + ] + }, + { + "id": 50, + "url": "https://docs.pytorch.org/docs/2.14/notes/randomness.html", + "title": "Reproducibility — PyTorch docs", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Completely reproducible results are not guaranteed across PyTorch releases, individual commits, or different platforms.", + "added": "2026-10-21" + } + ] + }, + { + "id": 51, + "url": "https://docs.nvidia.com/cuda/cublas/index.html", + "title": "cuBLAS documentation — Results reproducibility", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "set a debug environment variable CUBLAS_WORKSPACE_CONFIG to :16:8 (may limit overall performance) or :4096:8 (will increase library footprint in GPU memory by approximately 24MiB).", + "added": "2026-10-21" + }, + { + "text": "In that case, the results are not guaranteed to be bit-wise reproducible because atomics are used for the computation.", + "added": "2026-10-21" + } + ] + }, + { + "id": 52, + "url": "https://github.com/Dao-AILab/flash-attention/issues/1038", + "title": "Build flash-attn takes a lot of time · Issue #1038 · Dao-AILab/flash-attention", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "For reference I just compiled it on a 2018 Dell laptop (Quadro P1000 GPU) and the build time was about 15 hours.", + "added": "2026-10-21" + }, + { + "text": "Without both changes it defaulted to just using a single compilation job for me, taking forever (I gave up after an hour).", + "added": "2026-10-21" + } + ] + }, + { + "id": 53, + "url": "https://pypackaging-native.github.io/key-issues/gpus", + "title": "Packaging projects with GPU code — pypackaging-native", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "GPU packages tend to result in very large wheels. This is mainly because compiled GPU libraries must support a number of architectures, leading to large binary sizes.", + "added": "2026-10-21" + }, + { + "text": "For example, recent manylinux2014 wheels for TensorFlow are 588 MB (wheels for 2.11.0 ), and for PyTorch those are 890 MB (wheels for 1.13.0 ).", + "added": "2026-10-21" + } + ] + }, + { + "id": 54, + "url": "https://docs.pypi.org/project-management/storage-limits", + "title": "Storage Limits — PyPI Docs", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Limit for project 'sampleproject' is 100 MB.", + "added": "2026-10-21" + } + ] + }, + { + "id": 55, + "url": "https://github.com/pypi/support/issues/10830", + "title": "File Limit Request: faiss-gpu - 250 MB · pypi/support #10830", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "There are currently 34 other open limit request issues ahead of this one.", + "added": "2026-10-21" + } + ] + }, + { + "id": 56, + "url": "https://developer.nvidia.com/blog/streamline-cuda-accelerated-python-install-and-packaging-workflows-with-wheel-variants", + "title": "Streamline CUDA-Accelerated Python Install and Packaging Workflows with Wheel Variants (NVIDIA Technical Blog)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Docker images for ML and AI workloads are notoriously large, often exceeding 10 GB. Much of this comes from bundled GPU libraries for all possible architectures.", + "added": "2026-10-21" + } + ] + }, + { + "id": 57, + "url": "https://forums.developer.nvidia.com/t/196340", + "title": "Cudnn dll for cuda 11 are too big for redistribution (NVIDIA Developer Forums)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "We agree that the growth of the cuDNN DLL size is problematic, and we’re working on resolving this.", + "added": "2026-10-21" + } + ] + }, + { + "id": 58, + "url": "https://forums.developer.nvidia.com/t/147271", + "title": "Any suggestions to reduce the size of libcudnn.so? (NVIDIA Developer Forums)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Do you have any suggestions to remove unused symbols to reduce this shared library size for deployment? libcudnn.so.7 is over 200 MB in size!", + "added": "2026-10-21" + } + ] + }, + { + "id": 59, + "url": "https://developer.nvidia.com/blog/cuda-pro-tip-understand-fat-binaries-jit-caching", + "title": "CUDA Pro Tip: Understand Fat Binaries and JIT Caching (NVIDIA Technical Blog)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "This JIT compilation can cause delay at application start-up time (or more accurately, CUDA context creation time).", + "added": "2026-10-21" + }, + { + "text": "Insufficient cache size or a cache stored on a slow network share can cause long application start-up times", + "added": "2026-10-21" + } + ] + }, + { + "id": 60, + "url": "https://docs.flashinfer.ai/installation.html", + "title": "Installation — FlashInfer documentation", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "flashinfer-python: Core package that compiles/downloads kernels on first use", + "added": "2026-10-21" + } + ] + }, + { + "id": 61, + "url": "https://github.com/vllm-project/vllm/issues/41865", + "title": "FlashInfer GDN JIT Compilation Causes Multi-Worker Deadlock · vLLM #41865", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Worker 0 completes compilation (172s) but workers 1-7 hang indefinitely.", + "added": "2026-10-21" + } + ] + }, + { + "id": 62, + "url": "https://github.com/triton-lang/triton/commit/1f983791498aab4f8f3a922ac8128a59ee3a328b", + "title": "Cache autotune timings to disk (#6261) · triton-lang/triton", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Some users had expressed a desire to cache autotune results, both to speed up local iteration, and to avoid re-tuning when scaling up to large numbers of GPUs.", + "added": "2026-10-21" + } + ] + }, + { + "id": 63, + "url": "https://docs.nvidia.com/cuda/eula/index.html", + "title": "License Agreement for NVIDIA Software Development Kits — EULA", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "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.", + "added": "2026-10-21" + } + ] + }, + { + "id": 64, + "url": "https://www.tomshardware.com/pc-components/gpus/nvidia-bans-using-translation-layers-for-cuda-software-to-run-on-other-chips-new-restriction-apparently-targets-zluda-and-some-chinese-gpu-makers", + "title": "Nvidia bans using translation layers for CUDA software — Tom's Hardware", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Nvidia has banned running CUDA-based software on other hardware platforms using translation layers in its licensing terms listed online since 2021, but the warning previously wasn't included in the documentation placed on a host system during the installation process.", + "added": "2026-10-21" + }, + { + "text": "The restriction appears to be designed to prevent initiatives like ZLUDA, which both Intel and AMD have recently participated, and, perhaps more critically, some Chinese GPU makers from utilizing CUDA code with translation layer", + "added": "2026-10-21" + } + ] + }, + { + "id": 65, + "url": "https://www.theregister.com/software/2024/08/09/amd-lawyers-claw-back-cuda-compatibility-layer-zluda/1009658", + "title": "AMD lawyers claw back CUDA compatibility layer ZLUDA — The Register", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "AMD's legal team appears to have clawed back control of much of the ZLUDA project's code base.", + "added": "2026-10-21" + } + ] + }, + { + "id": 66, + "url": "https://www.tomshardware.com/pc-components/gpus/amd-asks-developer-to-take-down-open-source-zluda-dev-vows-to-rebuild-his-project", + "title": "AMD asks developer to take down open source ZLUDA — Tom's Hardware", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The code was released with AMD's approval through an email. AMD's legal department now says it's not legally binding, hence the rollback.", + "added": "2026-10-21" + } + ] + }, + { + "id": 67, + "url": "https://github.com/vosen/ZLUDA", + "title": "vosen/ZLUDA README (GitHub)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "ZLUDA is a drop-in replacement for CUDA on non-NVIDIA GPUs.", + "added": "2026-10-21" + } + ] + }, + { + "id": 68, + "url": "https://github.com/vosen/ZLUDA/discussions/261", + "title": "Code rollback · vosen/ZLUDA Discussion #261", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "But since its amd shooting its own foot this project will likely not survive this setback.", + "added": "2026-10-21" + } + ] + }, + { + "id": 69, + "url": "https://github.com/ROCm/legacy-rocm-build/issues/2308", + "title": "Support your GPUs for 8+ years, like Nvidia does, including gfx906 GPUs · ROCm #2308", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "If you want to know why everyone is going with Nvidia, there are a lot of them, but what they do at least well is they support they GPUs.", + "added": "2026-10-21" + } + ] + }, + { + "id": 70, + "url": "https://github.com/ROCm/legacy-rocm-build/issues/1714", + "title": "Which devices are even supported? (HIP/ROCm) · ROCm #1714", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "I'm a long-time CUDA developer looking to explore ROCm and HIP development, but finding out which hardware even supports these tools is harder than it needs to be.", + "added": "2026-10-21" + } + ] + }, + { + "id": 71, + "url": "https://github.com/ROCm/TheRock/issues/9198", + "title": "Strix Halo gfx1151: 93 ML experiments, 5 critical bf16 bugs · ROCm/TheRock #9198", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "We ran 93+ autonomous ML training experiments on a Strix Halo system (Radeon 8060S, gfx1151) using TheROCk nightly PyTorch and discovered 5 critical bf16 bugs, an undocumented 19x attention speedup, and several ecosystem gaps that prevent consumer AMD GPUs from being viable ML research platforms.", + "added": "2026-10-21" + } + ] + }, + { + "id": 72, + "url": "https://news.ycombinator.com/item?id=39888020", + "title": "Documentation for the AMD 7900XTX — Hacker News (comment by georgehotz)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "AMD is structurally incapable of fixing these issues. They don't even have a 7900XTX in CI.", + "added": "2026-10-21" + } + ] + }, + { + "id": 73, + "url": "https://news.ycombinator.com/item?id=39592689", + "title": "Nvidia bans using translation layers — Hacker News", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "AMD only supports their (consumer) GPUs for ~4 years via ROCm in some instances.", + "added": "2026-10-21" + } + ] + }, + { + "id": 74, + "url": "https://news.ycombinator.com/item?id=39801234", + "title": "CUDA Is Still a Giant Moat for Nvidia — Hacker News", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "On CUDA just runs of course with sliding window attention, ALiBi, and PagedAttention. ROCm fork? Nope.", + "added": "2026-10-21" + }, + { + "text": "AMD needs to be funding a CUDA shim that allows people to port stuff directly to their cards.", + "added": "2026-10-21" + } + ] + }, + { + "id": 75, + "url": "https://news.ycombinator.com/item?id=40970560", + "title": "Run CUDA, unmodified, on AMD GPUs — Hacker News (1330 points)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "you have to be able to pip install something and just have it work, reasonably fast, without crashing, and also it has to not interfere with 100 other weird poorly maintained ML library dependencies.", + "added": "2026-10-21" + } + ] + }, + { + "id": 76, + "url": "https://www.modular.com/blog/democratizing-ai-compute-part-4-cuda-is-the-incumbent-but-is-it-any-good", + "title": "CUDA is the incumbent, but is it any good? (Democratizing AI Compute, Part 4) — Modular", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "PTX is only partially documented, constantly shifting between hardware generations, and effectively a black box for developers.", + "added": "2026-10-21" + }, + { + "text": "NIM also abstracts away underlying operations, increasing lock-in and limiting access to the low-level optimization and innovation key to CUDA's value proposition.", + "added": "2026-10-21" + }, + { + "text": "CUDA doesn’t provide performance portability across NVIDIA’s own hardware generations, and the sheer scale of its libraries is a double-edged sword.", + "added": "2026-10-21" + }, + { + "text": "For AI engineers who build on top of CUDA, it’s an essential tool, but one that comes with versioning headaches, opaque driver behavior, and deep platform dependence.", + "added": "2026-10-21" + } + ] + }, + { + "id": 77, + "url": "https://news.ycombinator.com/item?id=48910260", + "title": "Alternative(s) to run CUDA on non-Nvidia hardware — Hacker News comment", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "With a design like Cuda where there is always a default easy path, and a complex but optional path.", + "added": "2026-10-21" + }, + { + "text": "That so many people have skill issues is the reason why Cuda trumps and will continue to trump Vulkan despite being vendor-locked.", + "added": "2026-10-21" + } + ] + }, + { + "id": 78, + "url": "http://tinygrad.org/pitch.pdf", + "title": "the tiny corp pitch deck (George Hotz, tinygrad.org)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "By being the dominant player, green team gets a whole ecosystem of developers to improve the developer experience for them.", + "added": "2026-10-21" + } + ] + }, + { + "id": 79, + "url": "https://news.ycombinator.com/item?id=48903715", + "title": "Alternative(s) to run CUDA on non-Nvidia hardware — Hacker News", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "One of the biggest complaints we hear from the industry is \"we tried to port to X and we could never complete it\".", + "added": "2026-10-21" + } + ] + }, + { + "id": 80, + "url": "https://www.theregister.com/2024/12/17/nvidia_cuda_moat", + "title": "Nvidia's CUDA moat may not be as impenetrable as you think — The Register", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The reality is people want to write at higher levels of abstraction,", + "added": "2026-10-21" + }, + { + "text": "In the case of Flash Attention, the advent of ahead-of-time Triton kernel libraries for efficient memory utilization can be used to overcome this limitation in some scenarios.", + "added": "2026-10-21" + } + ] + }, + { + "id": 81, + "url": "https://github.com/triton-lang/triton", + "title": "triton-lang/triton README", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "NVIDIA GPUs (Compute Capability 8.0+)", + "added": "2026-10-21" + } + ] + }, + { + "id": 82, + "url": "https://news.ycombinator.com/item?id=45165571", + "title": "Intel Arc Pro B50 GPU Launched at $349 — Hacker News comment", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Nvidia uses VRAM amount for market segmentation. They can't make a 128GB consumer card without cannibalizing their enterprise sales.", + "added": "2026-10-21" + } + ] + }, + { + "id": 83, + "url": "https://news.ycombinator.com/item?id=49151324", + "title": "Qwen3.8-Max — Hacker News comment", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "There is no math that will make local models come out ahead in $/intelligence/token.", + "added": "2026-10-21" + }, + { + "text": "The point of local models is privacy, offline use, and maybe no guard rails.", + "added": "2026-10-21" + } + ] + }, + { + "id": 84, + "url": "https://news.ycombinator.com/item?id=48089658", + "title": "Running local models on an M4 with 24GB memory — Hacker News comment", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "At $20/month for a cloud AI subscription, you’re looking at almost 30 years of service for the same money.", + "added": "2026-10-21" + } + ] + }, + { + "id": 85, + "url": "https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-second-quarter-fiscal-2027", + "title": "NVIDIA Announces Financial Results for Second Quarter Fiscal 2027", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Data Center revenue of $89.0 billion, up 117% from a year ago", + "added": "2026-10-21" + }, + { + "text": "NVIDIA (NASDAQ: NVDA) today reported revenue for the second quarter ended July 26, 2026, of $96.2 billion", + "added": "2026-10-21" + } + ] + }, + { + "id": 86, + "url": "https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-fourth-quarter-and-fiscal-2025", + "title": "NVIDIA Announces Financial Results for Fourth Quarter and Fiscal 2025", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Record full-year revenue of $130.5 billion, up 114%", + "added": "2026-10-21" + }, + { + "text": "Full-year revenue rose 142% to a record $115.2 billion", + "added": "2026-10-21" + } + ] + }, + { + "id": 87, + "url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581025000023/nvda-20250126.htm", + "title": "NVIDIA Form 10-K for fiscal year ended Jan 26, 2025 (SEC)", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Data Center revenue for fiscal year 2025 was up 142% from a year ago.", + "added": "2026-10-21" + }, + { + "text": "Revenue for fiscal year 2025 was $130.5 billion, up 114% from a year ago.", + "added": "2026-10-21" + } + ] + }, + { + "id": 88, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1r569eb/psa_nvidia_dgx_spark_has_terrible_cuda_software", + "title": "r/LocalLLaMA: PSA: NVIDIA DGX Spark has terrible CUDA & software compatibility", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Just be careful when buying a DGX Spark. You are not really getting a modern CUDA experience.", + "added": "2026-10-21" + }, + { + "text": "The funniest part is paying the NVIDIA tax specifically for CUDA compatibility and then not getting it.", + "added": "2026-10-21" + }, + { + "text": "Very frustrating compared to most every other GPU release that has zero day support from cuda/nvcc/pytorch/tensorflow.", + "added": "2026-10-21" + }, + { + "text": "many of their official playbooks are broken and can’t be run as-is on the latest versions.", + "added": "2026-10-21" + }, + { + "text": "The sm121 fragmentation is the more interesting problem here.", + "added": "2026-10-21" + } + ] + }, + { + "id": 89, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1no4ho1/some_things_i_learned_about_installing_flashattn", + "title": "r/LocalLLaMA: Some things I learned about installing flash-attn", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "This cut my build time from 1+ hours to just under 15 minutes. Thank you!", + "added": "2026-10-21" + }, + { + "text": "Usually the reason is a different torch. There's a whole issue on FA about people complaining.", + "added": "2026-10-21" + } + ] + }, + { + "id": 90, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1oo6226/disappointed_by_dgx_spark", + "title": "r/LocalLLaMA: Disappointed by dgx spark", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "You design and validate them locally on the spark, running the exact same software, then push to the data center full of Nvidia GPU racks.", + "added": "2026-10-21" + }, + { + "text": "Sure, Nvidia gives for \"free\" their software stack.... as long as you use it on their products.", + "added": "2026-10-21" + } + ] + }, + { + "id": 91, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1sqera2/vllm_woes_in_spark", + "title": "r/LocalLLaMA: VLLM woes in Spark", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "The CUDA tax, which is 4.6 GB approximately per each model on a DGX spark.", + "added": "2026-10-21" + } + ] + }, + { + "id": 92, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1lx62hd/nvidia_being_nvidia_fp8_is_150_tflops_faster_when", + "title": "r/LocalLLaMA: Nvidia being Nvidia: FP8 is 150 Tflops faster when kernel name contain \"cutlass\"", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "Even worse, if someone accidentally created a kernel with \"cutlass\" in the name, the driver would apply optimizations that are not safe.", + "added": "2026-10-21" + } + ] + }, + { + "id": 93, + "url": "https://www.reddit.com/r/pytorch/comments/1l3uwk2/should_compiling_from_source_take_a_terabyte_of", + "title": "r/pytorch: Should compiling from source take a terabyte of memory?", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "It keeps crashing with the nvcc error out of memory, even after I've allocated over 0.75TB of vRAM on my SSD.", + "added": "2026-10-21" + } + ] + }, + { + "id": 94, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1k903ov/llamacpp_cuda_setup_running_into_issues_is_it", + "title": "r/LocalLLaMA: Llama.cpp CUDA Setup - Running into Issues - Is it Worth the Effort?", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "However, CMake is unable to find the CUDA toolkit, even though it's installed and `nvcc` and `nvidia-smi` are working correctly.", + "added": "2026-10-21" + } + ] + }, + { + "id": 95, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1b6gfjt/cuda_crackdown_nvidias_licensing_update_targets", + "title": "r/LocalLLaMA: CUDA Crackdown: NVIDIA's Licensing Update targets AMD and blocks ZLUDA", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "i literally worked at a company where we dropped HIP support, and just went all in on nvidia.", + "added": "2026-10-21" + }, + { + "text": "I hope someone is working on hardware agnostic solutions, we need more GPUs, not less.", + "added": "2026-10-21" + } + ] + }, + { + "id": 96, + "url": "https://www.reddit.com/r/CUDA/comments/1jhvtqm/patch_to_enable_pytorch_on_rtx_5080_cuda_128_sm", + "title": "r/CUDA: Patch to enable PyTorch on RTX 5080 cuda 12.8 + sm_120 / Blackwell support", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "PyTorch doesn’t support sm_120 or the RTX 5080 out of the box. So I patched it.", + "added": "2026-10-21" + } + ] + }, + { + "id": 97, + "url": "https://www.reddit.com/r/LocalLLaMA/comments/1scf1x8/dont_buy_the_dgx_spark_nvfp4_still_missing_after", + "title": "r/LocalLLaMA: Don't buy the DGX Spark: NVFP4 Still Missing After 6 Months", + "accessed": "2026-10-21", + "quotes": [ + { + "text": "It was not marketed like an experimental dev kit where buyers should expect to spend months switching backends, testing builds, setting flags, and relying on community or hardcore fan fixes just to make a core feature work properly.", + "added": "2026-10-21" + } + ] + } + ] +} diff --git a/evidence/dx/pain-points/licence.txt b/evidence/dx/pain-points/licence.txt new file mode 100644 index 00000000..a6eb8a8f --- /dev/null +++ b/evidence/dx/pain-points/licence.txt @@ -0,0 +1,22 @@ +# D9 receipt: no licence that stops you +# commit 2e3804976498ae328e9d7a0538828e7074b789af branch dx/pain-points, run 2026-10-22T01:53:06Z on spark-b87b +$ head -5 LICENSE +MIT License + +Copyright (c) 2026 Drake Stapleton + +Permission is hereby granted, free of charge, to any person obtaining a copy + +$ git ls-files | wc -l +431 +$ git ls-files -z | xargs -0 file -b | grep -c -E "ELF|archive|PE32|Mach-O" (binaries tracked) +0 +$ git log --name-only --format= | grep -c -i -E "\.(cubin|ptx|fatbin|so|a|o|bin)$|^build/" (cubin, PTX, fatbin, libraries, objects, firmware or build output in any commit of this branch) +0 +$ grep -c -i "reverse engineer" LICENSE (any clause about reverse engineering in our licence) +0 +$ grep -n -i "reverse engineer" CONTRIBUTING.md +50:## Reverse engineering, translation and ports are welcome +52:CUDA++ is MIT. You may read, disassemble, reverse engineer and translate anything CUDA++ produces, including the machine code it writes, and run it or port it to any hardware, NVIDIA or not. We ask only that you keep the licence notice. This is on purpose: CUDA's licence forbids reverse engineering its output to target other hardware (`docs/PAIN_POINTS.md` section 2.8), and CUDA++ will never do that to anyone. +$ SPDX licence tags in tracked .c/.h files + 223 SPDX-License-Identifier: MIT diff --git a/evidence/l424/README.md b/evidence/l424/README.md new file mode 100644 index 00000000..158c9668 --- /dev/null +++ b/evidence/l424/README.md @@ -0,0 +1,78 @@ +# L424 host receipt +recorded 2026-10-22T04:43Z + +## results +diff-check 0 +audit 0 +host 0 +zero-cuda 0 +figures 0 +doctor 0 + + +## zero-cuda.log +tools/zero-cuda-gate.sh --self-test +ZERO_CUDA FAIL /tmp/tmp.eDqrhs3TUO/probe.so needs: libcudart.so.13 +ZERO_CUDA FAIL /tmp/tmp.eDqrhs3TUO/probe.so imports: cudaMalloc +ZERO_CUDA SELF-TEST PASS (CUDA probe rejected, clean library accepted) +tools/zero-cuda-gate.sh build/hello_gpu build/gpu_matmul_api_test +ZERO_CUDA PASS build/hello_gpu needs=[libm.so.6 libc.so.6 ld-linux-aarch64.so.1] +ZERO_CUDA PASS build/gpu_matmul_api_test needs=[libc.so.6 ld-linux-aarch64.so.1] + + +## figures.log +figures current: 10 + + +## doctor.log +build/cudapp-doctor +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.7 GiB shared by the CPU and the GPU, 55.8 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (one is installed at /usr/local/cuda/bin/nvcc; that is fine) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu + + +## audit.log +blobs 1123 binaries 0 secret-hits 0 private-hits 485 (15 distinct) + + +## audit-selftest.log +SELFTEST PASS: planted 15 (one in a deleted file's history, one in a commit message), found 15 + + +## host-tail +BE_CLOSE_KEEPS_MARKER_POINTER KILLED close unmaps the first marker word (1 failing case(s), first: m_close_unmaps_every_sync_word) +BE_CLOSE_KEEPS_MARKER2_POINTER KILLED close unmaps the second marker word (1 failing case(s), first: m_close_unmaps_every_sync_word) +BE_CLOSE_KEEPS_SEM_POINTER KILLED close unmaps the semaphore word (1 failing case(s), first: m_close_unmaps_every_sync_word) +BE_CLOSE_NOT_CALLED KILLED close really closes the driver (36 failing case(s), first: m_success_driver_counts) +BE_CLOSE_ERROR_IGNORED KILLED a failed close is reported (CLEANUP) (2 failing case(s), first: m_cleanup_close_name_step_state) +WRAP_POISON_NOT_COMPLEMENT KILLED the poison word is the complement of the expected sum (7 failing case(s), first: m_vec_success_returns_zero) +WRAP_POISON_CONSTANT KILLED the poison word never collides with a legitimate sum (0xdeadbeef is one) (7 failing case(s), first: m_vec_success_returns_zero) +WRAP_ENGINE_FAILURE_IGNORED KILLED an engine failure (here a cleanup fault) fails the wrapper (1 failing case(s), first: m_vec_cleanup_fault_returns_nonzero) +WRAP_ORACLE_IGNORED KILLED the host oracle decides success, not the engine (1 failing case(s), first: m_vec_wrong_math_returns_nonzero) +WRAP_PARITY_FLAG_FORCED KILLED parity_verified follows the oracle (1 failing case(s), first: m_vec_wrong_math_parity_not_verified) +WRAP_MARKER_NOT_REPORTED KILLED the completion marker is reported (1 failing case(s), first: m_vec_success_completion_marker_and_semaphore) +WRAP_SEMAPHORE_NOT_REPORTED KILLED the semaphore value is reported (1 failing case(s), first: m_vec_success_completion_marker_and_semaphore) +WRAP_LAUNCH_TIME_NOT_REPORTED KILLED the launch time is reported (1 failing case(s), first: m_vec_success_timestamps) +WRAP_DONE_TIME_NOT_REPORTED KILLED the completion time is reported (1 failing case(s), first: m_vec_success_timestamps) +WRAP_ELAPSED_NOT_REPORTED KILLED the elapsed time is reported (1 failing case(s), first: m_vec_success_timestamps) +WRAP_SM_ARCH_NOT_REPORTED KILLED the architecture is reported (1 failing case(s), first: m_vec_success_shape_fields) +WRAP_ELEMENT_COUNT_NOT_REPORTED KILLED the element count is reported (1 failing case(s), first: m_vec_success_shape_fields) +WRAP_NULL_GUARD_DROPPED KILLED a NULL argument is refused before any use (harness exit 139 (crash or abort)) +WRAP_ZERO_COUNT_GUARD SURVIVED_REDUNDANT a zero element count is refused by the wrapper (redundant: the engine refuses element_count 0 as INVALID_ARGS (src/omega_gpu_engine.c job_valid) and the wrapper then returns -1, so the result is the same refusal) +WRAP_MARKER_TIMEOUT KILLED the first marker wait limit is 5000 ms (1 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_SEMAPHORE_TIMEOUT KILLED the semaphore wait limit is 5000 ms (1 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_MARKER2_TIMEOUT KILLED the second marker wait limit is 5000 ms (1 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_VISIBILITY_TIMEOUT SURVIVED_REDUNDANT the visibility limit is 5000 ms (redundant: the Blackwell barrier callback ignores its timeout argument (it is a CPU dsb sy that cannot wait), so no host observation depends on the value) +WRAP_FLAGS_ALL_PROTECTIONS KILLED the wrapper runs with every protection on (flags 0) (2 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_BACKEND_NOT_INSTALLED KILLED the wrapper installs the Blackwell backend itself (13 failing case(s), first: m_vec_success_returns_zero) +WRAP_PROGRAM_LENGTH KILLED the whole encoded program is handed to the engine (7 failing case(s), first: m_vec_success_returns_zero) +WRAP_MARKER_CHECK SURVIVED_REDUNDANT second check of the marker payload (redundant: the backend wait_word already refuses any first-marker value other than 0x44444444 (UNKNOWN_STATE), so the engine fails before this line is reached) +WRAP_SEMAPHORE_CHECK SURVIVED_REDUNDANT second check of the semaphore value (redundant: the backend wait_word already refuses any semaphore value other than DONE (6), so the engine fails before this line is reached) +mutants: 120 total, 107 killed, 13 survived as redundant, 0 survived as test gaps (receipt /tmp/mutrun.OaTUkO/out.json) +CUDA++ HOST TESTS PASS (33 targets) diff --git a/evidence/l424/audit-selftest.log b/evidence/l424/audit-selftest.log new file mode 100644 index 00000000..ad41c1cb --- /dev/null +++ b/evidence/l424/audit-selftest.log @@ -0,0 +1 @@ +SELFTEST PASS: planted 15 (one in a deleted file's history, one in a commit message), found 15 diff --git a/evidence/l424/audit.log b/evidence/l424/audit.log new file mode 100644 index 00000000..4fb037a4 --- /dev/null +++ b/evidence/l424/audit.log @@ -0,0 +1 @@ +blobs 1123 binaries 0 secret-hits 0 private-hits 485 (15 distinct) diff --git a/evidence/l424/doctor.log b/evidence/l424/doctor.log new file mode 100644 index 00000000..6234b6f0 --- /dev/null +++ b/evidence/l424/doctor.log @@ -0,0 +1,10 @@ +build/cudapp-doctor +cudapp doctor: is this machine ready for CUDA++? + info system: Linux 7.0.0-1019-nvidia aarch64 + ok NVIDIA kernel module: open module 580.173.02 (CUDA++ speaks 580.173.02) + ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user + ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified (receipt: evidence/m16-blackwell-native-path-requalification-receipt.json) + ok memory: 121.7 GiB shared by the CPU and the GPU, 55.8 GiB available now + info CUDA toolkit: not needed and not used by CUDA++ (one is installed at /usr/local/cuda/bin/nvcc; that is fine) + info compiler: this doctor was built by 13.3.0; CUDA++ needs only make and a C compiler +READY. Next: make hello-gpu diff --git a/evidence/l424/figures.log b/evidence/l424/figures.log new file mode 100644 index 00000000..f25c1f96 --- /dev/null +++ b/evidence/l424/figures.log @@ -0,0 +1 @@ +figures current: 10 diff --git a/evidence/l424/host-tail.txt b/evidence/l424/host-tail.txt new file mode 100644 index 00000000..bdb8e40d --- /dev/null +++ b/evidence/l424/host-tail.txt @@ -0,0 +1,30 @@ +BE_CLOSE_KEEPS_MARKER_POINTER KILLED close unmaps the first marker word (1 failing case(s), first: m_close_unmaps_every_sync_word) +BE_CLOSE_KEEPS_MARKER2_POINTER KILLED close unmaps the second marker word (1 failing case(s), first: m_close_unmaps_every_sync_word) +BE_CLOSE_KEEPS_SEM_POINTER KILLED close unmaps the semaphore word (1 failing case(s), first: m_close_unmaps_every_sync_word) +BE_CLOSE_NOT_CALLED KILLED close really closes the driver (36 failing case(s), first: m_success_driver_counts) +BE_CLOSE_ERROR_IGNORED KILLED a failed close is reported (CLEANUP) (2 failing case(s), first: m_cleanup_close_name_step_state) +WRAP_POISON_NOT_COMPLEMENT KILLED the poison word is the complement of the expected sum (7 failing case(s), first: m_vec_success_returns_zero) +WRAP_POISON_CONSTANT KILLED the poison word never collides with a legitimate sum (0xdeadbeef is one) (7 failing case(s), first: m_vec_success_returns_zero) +WRAP_ENGINE_FAILURE_IGNORED KILLED an engine failure (here a cleanup fault) fails the wrapper (1 failing case(s), first: m_vec_cleanup_fault_returns_nonzero) +WRAP_ORACLE_IGNORED KILLED the host oracle decides success, not the engine (1 failing case(s), first: m_vec_wrong_math_returns_nonzero) +WRAP_PARITY_FLAG_FORCED KILLED parity_verified follows the oracle (1 failing case(s), first: m_vec_wrong_math_parity_not_verified) +WRAP_MARKER_NOT_REPORTED KILLED the completion marker is reported (1 failing case(s), first: m_vec_success_completion_marker_and_semaphore) +WRAP_SEMAPHORE_NOT_REPORTED KILLED the semaphore value is reported (1 failing case(s), first: m_vec_success_completion_marker_and_semaphore) +WRAP_LAUNCH_TIME_NOT_REPORTED KILLED the launch time is reported (1 failing case(s), first: m_vec_success_timestamps) +WRAP_DONE_TIME_NOT_REPORTED KILLED the completion time is reported (1 failing case(s), first: m_vec_success_timestamps) +WRAP_ELAPSED_NOT_REPORTED KILLED the elapsed time is reported (1 failing case(s), first: m_vec_success_timestamps) +WRAP_SM_ARCH_NOT_REPORTED KILLED the architecture is reported (1 failing case(s), first: m_vec_success_shape_fields) +WRAP_ELEMENT_COUNT_NOT_REPORTED KILLED the element count is reported (1 failing case(s), first: m_vec_success_shape_fields) +WRAP_NULL_GUARD_DROPPED KILLED a NULL argument is refused before any use (harness exit 139 (crash or abort)) +WRAP_ZERO_COUNT_GUARD SURVIVED_REDUNDANT a zero element count is refused by the wrapper (redundant: the engine refuses element_count 0 as INVALID_ARGS (src/omega_gpu_engine.c job_valid) and the wrapper then returns -1, so the result is the same refusal) +WRAP_MARKER_TIMEOUT KILLED the first marker wait limit is 5000 ms (1 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_SEMAPHORE_TIMEOUT KILLED the semaphore wait limit is 5000 ms (1 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_MARKER2_TIMEOUT KILLED the second marker wait limit is 5000 ms (1 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_VISIBILITY_TIMEOUT SURVIVED_REDUNDANT the visibility limit is 5000 ms (redundant: the Blackwell barrier callback ignores its timeout argument (it is a CPU dsb sy that cannot wait), so no host observation depends on the value) +WRAP_FLAGS_ALL_PROTECTIONS KILLED the wrapper runs with every protection on (flags 0) (2 failing case(s), first: m_vec_success_timeouts_are_5000_each) +WRAP_BACKEND_NOT_INSTALLED KILLED the wrapper installs the Blackwell backend itself (13 failing case(s), first: m_vec_success_returns_zero) +WRAP_PROGRAM_LENGTH KILLED the whole encoded program is handed to the engine (7 failing case(s), first: m_vec_success_returns_zero) +WRAP_MARKER_CHECK SURVIVED_REDUNDANT second check of the marker payload (redundant: the backend wait_word already refuses any first-marker value other than 0x44444444 (UNKNOWN_STATE), so the engine fails before this line is reached) +WRAP_SEMAPHORE_CHECK SURVIVED_REDUNDANT second check of the semaphore value (redundant: the backend wait_word already refuses any semaphore value other than DONE (6), so the engine fails before this line is reached) +mutants: 120 total, 107 killed, 13 survived as redundant, 0 survived as test gaps (receipt /tmp/mutrun.OaTUkO/out.json) +CUDA++ HOST TESTS PASS (33 targets) diff --git a/evidence/l424/results b/evidence/l424/results new file mode 100644 index 00000000..e9c73a20 --- /dev/null +++ b/evidence/l424/results @@ -0,0 +1,6 @@ +diff-check 0 +audit 0 +host 0 +zero-cuda 0 +figures 0 +doctor 0 diff --git a/evidence/l424/zero-cuda.log b/evidence/l424/zero-cuda.log new file mode 100644 index 00000000..b547ac92 --- /dev/null +++ b/evidence/l424/zero-cuda.log @@ -0,0 +1,7 @@ +tools/zero-cuda-gate.sh --self-test +ZERO_CUDA FAIL /tmp/tmp.eDqrhs3TUO/probe.so needs: libcudart.so.13 +ZERO_CUDA FAIL /tmp/tmp.eDqrhs3TUO/probe.so imports: cudaMalloc +ZERO_CUDA SELF-TEST PASS (CUDA probe rejected, clean library accepted) +tools/zero-cuda-gate.sh build/hello_gpu build/gpu_matmul_api_test +ZERO_CUDA PASS build/hello_gpu needs=[libm.so.6 libc.so.6 ld-linux-aarch64.so.1] +ZERO_CUDA PASS build/gpu_matmul_api_test needs=[libc.so.6 ld-linux-aarch64.so.1] diff --git a/examples/hello_gpu/hello_gpu.c b/examples/hello_gpu/hello_gpu.c index d2677316..6eb3b605 100644 --- a/examples/hello_gpu/hello_gpu.c +++ b/examples/hello_gpu/hello_gpu.c @@ -15,21 +15,36 @@ * * Prints PASS or FAIL. Exit code: 0 PASS, 1 FAIL (wrong or missing results), 2 the GPU could not be used. * + * `hello_gpu --sim` runs the same kernel program on the host warp simulator instead (tests/bw_warp_sim.h): + * no GPU is opened. A bad memory access there stops at the launch that made it and is reported with the + * kernel, launch, instruction, block, thread, address and the buffer it missed (developer bar D3 and D4, + * docs/PAIN_POINTS.md). `--sim --bug=past-end` shows such a report: the last launch is given one element + * too many, a classic off-by-one. + * + * Both paths print the work the job takes (bytes moved, floating-point operations) and the least time + * those bytes need at this GB10's measured read ceiling (D12), the time the kernel took to build and the + * hash of its machine code (D10, no compiling at run time), and the hash of the output (D7: the same + * inputs give the same bits on every run). + * * Hardware: NVIDIA GB10 (DGX Spark, sm_121), Linux, the open NVIDIA kernel driver loaded. * Built by `make hello-gpu` (see README, "Run your first kernel"). */ #include "omega_blackwell_codegen.h" #include "omega_blackwell_qmd.h" #include "omega_gpu_session.h" +#include "sha256.h" +#include "../../tests/bw_warp_sim.h" /* the host warp simulator the host tests use; only --sim calls it */ #include #include #include +#include #define N_TOTAL (1u << 20) /* 1048576 floats per array */ #define THREADS 128u /* threads per block (CTA) */ #define MAX_CTAS 1024u /* blocks per launch the session is proven for (omega_gpu_elementwise_api.h) */ #define CHUNK (THREADS * MAX_CTAS) /* elements per launch: 131072, so N_TOTAL is 8 launches */ #define POISON 0xFFC0FFEEu /* a NaN pattern c starts out as: an element the GPU never wrote stays this */ +#define READ_CEILING_GBPS 195.1 /* GB10 global reads, measured: evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z/ */ /* ---- Step 1: the kernel, as IR instructions ------------------------------------------------------------- * Each instruction carries a "control word" that tells the chip how long to wait before the next one. @@ -106,13 +121,151 @@ static int build_vecadd(BlackwellIRProgram *prog) { return omega_bw_regalloc_solve(prog); /* picks the physical registers */ } -int main(void) { +/* ---- helpers shared by both paths ---------------------------------------------------------------------- */ +static double now_us(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (double)t.tv_sec * 1e6 + (double)t.tv_nsec / 1e3; } +static void print_sha(const char *what, const void *data, size_t len) { + uint8_t d[SHA256_DIGEST_SIZE]; + sha256_hash((const uint8_t *)data, len, d); + printf("%s sha256 ", what); + for (int i = 0; i < SHA256_DIGEST_SIZE; i++) printf("%02x", d[i]); + printf("\n"); +} +static void print_work(uint64_t read, uint64_t written, uint64_t fp_ops, double measured_us) { + double floor_us = (double)(read + written) / (READ_CEILING_GBPS * 1e3); + printf("work: %llu bytes moved (%llu read, %llu written), %llu floating-point operations\n", + (unsigned long long)(read + written), (unsigned long long)read, (unsigned long long)written, (unsigned long long)fp_ops); + printf(" at the GB10's measured %.1f GB/s read ceiling this needs at least %.1f us", READ_CEILING_GBPS, floor_us); + if (measured_us > 0) printf("; the GPU took %.1f us (%.0f%% of the ceiling)", measured_us, 100.0 * floor_us / measured_us); + printf("\n"); +} +static void inputs(float *fa, float *fb, uint32_t *wc) { + for (uint32_t i = 0; i < N_TOTAL; i++) { fa[i] = (float)i * 0.25f; fb[i] = 1.0f / (float)(1 + i % 7); wc[i] = POISON; } +} +/* Step 5, both paths: same IEEE single-precision add on both sides, so the bits must match. */ +static int check(const float *fa, const float *fb, const uint32_t *wc) { + uint32_t wrong = 0, unwritten = 0, first_bad = 0; + for (uint32_t i = 0; i < N_TOTAL; i++) { + float want = fa[i] + fb[i]; + if (wc[i] == POISON) unwritten++; + if (memcmp(&want, &wc[i], sizeof want) != 0) { if (!wrong++) first_bad = i; } + } + printf("checked %u of %u elements: %u wrong, %u never written\n", N_TOTAL, N_TOTAL, wrong, unwritten); + if (wrong) { float want = fa[first_bad] + fb[first_bad], got; memcpy(&got, &wc[first_bad], sizeof got); + printf("first mismatch: c[%u] = %g, expected %g\n", first_bad, got, want); } + return wrong ? 1 : 0; +} +static const char *op_text(BlackwellIROpcode op) { + switch (op) { + case BW_IR_LDG_E: return "LDG.E (4-byte load)"; + case BW_IR_STG_E: return "STG.E (4-byte store)"; + case BW_IR_IMAD_WIDE: return "IMAD.WIDE (64-bit address)"; + case BW_IR_IMAD: return "IMAD"; + case BW_IR_FADD: return "FADD"; + case BW_IR_S2R: return "S2R (read thread or block index)"; + case BW_IR_LDC: case BW_IR_LDC64: return "LDC (read a launch argument)"; + case BW_IR_ISETP_GE_U32: return "ISETP.GE.U32"; + case BW_IR_EXIT: return "EXIT"; + case BW_IR_BRA: return "BRA"; + default: return "instruction"; + } +} + +/* ---- --sim: the same program on the host warp simulator --------------------------------------------------- */ +static int run_sim(const BlackwellIRProgram *prog, int bug) { + const size_t bytes = (size_t)N_TOTAL * sizeof(float); + float *fa = aligned_alloc(64, bytes), *fb = aligned_alloc(64, bytes); + uint32_t *wc = aligned_alloc(64, bytes); + if (!fa || !fb || !wc) { printf("FAIL: host memory\n"); return 1; } + inputs(fa, fb, wc); + static WsSim s; + memset(&s, 0, sizeof s); + s.p = prog; s.threads = THREADS; + const char *names[3] = { "a", "b", "c" }; + const uintptr_t base_of[3] = { (uintptr_t)fa, (uintptr_t)fb, (uintptr_t)wc }; + for (int k = 0; k < 3; k++) { s.ranges[k].lo = base_of[k]; s.ranges[k].hi = base_of[k] + bytes; } + s.nranges = 3; /* every global access must land inside a, b or c */ + const uint32_t launches = (N_TOTAL + CHUNK - 1) / CHUNK; + uint32_t li = 0; + for (uint32_t base = 0; base < N_TOTAL; base += CHUNK) { + li++; + uint64_t off = (uint64_t)base * sizeof(float); + uint32_t n = N_TOTAL - base < CHUNK ? N_TOTAL - base : CHUNK; + if (bug && base + CHUNK >= N_TOTAL) n += 1; /* --bug=past-end: the last launch is told one element too many */ + uint64_t pa = base_of[0] + off, pb = base_of[1] + off, pc = base_of[2] + off; + memset(s.cbank, 0, sizeof s.cbank); + s.cbank[0x380 / 4] = (uint32_t)pa; s.cbank[0x384 / 4] = (uint32_t)(pa >> 32); + s.cbank[0x388 / 4] = (uint32_t)pb; s.cbank[0x38c / 4] = (uint32_t)(pb >> 32); + s.cbank[0x390 / 4] = (uint32_t)pc; s.cbank[0x394 / 4] = (uint32_t)(pc >> 32); + s.cbank[0x398 / 4] = n; + uint32_t grid = (n + THREADS - 1) / THREADS; + if (ws_run(&s, grid, 1) != 0) { + const BlackwellIRInsn *in = (s.err_pc >= 0 && (size_t)s.err_pc < prog->count) ? &prog->insns[s.err_pc] : NULL; + int store = in && in->op == BW_IR_STG_E; + if (s.err == WS_E_MEM) printf("FAULT at launch %u of %u of kernel vecadd (simulator): global %s outside every buffer\n", li, launches, store ? "store" : "load"); + else printf("FAULT at launch %u of %u of kernel vecadd (simulator): %s\n", li, launches, ws_err_name(s.err)); + printf(" launch: grid %u x 1 blocks of %u threads, n = %u, first element %u\n", grid, THREADS, n, base); + if (in) printf(" instruction: %d of %zu, %s\n", s.err_pc, prog->count, op_text(in->op)); + printf(" thread: block %u, thread %u (element %llu of the whole job)\n", s.err_cx, s.err_tid, + (unsigned long long)base + (unsigned long long)s.err_cx * THREADS + s.err_tid); + int near = 0; uint64_t dist = UINT64_MAX; int past = 1; + if (s.err == WS_E_MEM) { + for (int k = 0; k < 3; k++) { + uint64_t lo = s.ranges[k].lo, hi = s.ranges[k].hi, d; int pst; + if (s.err_addr >= hi) { d = s.err_addr - hi; pst = 1; } + else if (s.err_addr + s.err_bytes <= lo) { d = lo - (s.err_addr + s.err_bytes); pst = 0; } + else { d = 0; pst = 1; } /* starts inside, runs past the end */ + if (d < dist) { dist = d; near = k; past = pst; } + } + printf(" address: 0x%llx (%u bytes), %llu bytes %s buffer %s = [0x%llx, 0x%llx) (%zu bytes)\n", + (unsigned long long)s.err_addr, s.err_bytes, (unsigned long long)dist, past ? "past the end of" : "before the start of", + names[near], (unsigned long long)s.ranges[near].lo, (unsigned long long)s.ranges[near].hi, bytes); + } + printf(" simulator: %s\n", s.msg); + if (s.err == WS_E_MEM) + printf(" next: launch %u was given n = %u, and buffer %s holds %llu elements from this launch's first element.\n" + " Fix the launch or the buffer, run hello_gpu --sim until it passes, then run hello_gpu on the GPU.\n", + li, n, names[near], (unsigned long long)((s.ranges[near].hi - (s.ranges[near].lo + off)) / sizeof(float))); + else + printf(" next: the instruction above is where the program stopped; fix it and run hello_gpu --sim again.\n"); + free(fa); free(fb); free(wc); + return 1; + } + } + int rc = check(fa, fb, wc); + print_work(s.gld_bytes, s.gst_bytes, s.fp_ops, 0); + print_sha("output", wc, bytes); + printf("%s\n", rc ? "FAIL" : "PASS"); + free(fa); free(fb); free(wc); + return rc; +} + +int main(int argc, char **argv) { + int sim = 0, bug = 0; + for (int i = 1; i < argc; i++) { + if (!strcmp(argv[i], "--sim")) sim = 1; + else if (!strcmp(argv[i], "--bug=past-end")) bug = 1; + else { printf("usage: hello_gpu [--sim [--bug=past-end]]\n"); return 2; } + } + if (bug && !sim) { printf("--bug=past-end is only for --sim: on the GPU it would write past a buffer\n"); return 2; } int rc = 1; OmegaGpuMem code = { 0 }, a = { 0 }, b = { 0 }, c = { 0 }; static BlackwellIRProgram prog; - printf("hello_gpu: c = a + b over %u floats on the GPU, built with Omega's own kernel builder\n", N_TOTAL); + printf("hello_gpu: c = a + b over %u floats %s, built with Omega's own kernel builder\n", N_TOTAL, + sim ? "on the host simulator (no GPU)" : "on the GPU"); + double t0 = now_us(); if (build_vecadd(&prog) != 0) { printf("FAIL: the kernel did not build\n"); return 1; } + { /* the machine code, encoded once here so its hash and build time can be printed (D10) */ + size_t need = omega_bw_program_code_bytes(&prog); + void *words = calloc(1, need); + OmegaBlackwellKernel k; + if (!words || omega_blackwell_kernel_encode_into(&prog, words, need, &k) != 0) { printf("FAIL: the kernel did not encode\n"); free(words); return 1; } + double t1 = now_us(); + printf("kernel built in %.0f us: %zu instructions, %u registers, no compiler run, no cache\n", t1 - t0, k.insn_count, prog.regalloc.peak_gpr_usage); + print_sha("machine code", words, k.insn_count * 16u); + free(words); + } + if (sim) return run_sim(&prog, bug); /* ---- Step 2: open the GPU. One process owns one device channel; the lock serialises threads. */ omega_gpu_session_lock(); @@ -133,13 +286,14 @@ int main(void) { printf("kernel: %zu instructions, %u registers\n", kernel.insn_count, prog.regalloc.peak_gpr_usage); float *fa = a.cpu, *fb = b.cpu; uint32_t *wc = c.cpu; - for (uint32_t i = 0; i < N_TOTAL; i++) { fa[i] = (float)i * 0.25f; fb[i] = 1.0f / (float)(1 + i % 7); wc[i] = POISON; } + inputs(fa, fb, wc); if (omega_gpu_session_sync_to_gpu(&code) || omega_gpu_session_sync_to_gpu(&a) || omega_gpu_session_sync_to_gpu(&b) || omega_gpu_session_sync_to_gpu(&c)) { printf("FAIL: sync to GPU (stage: %s)\n", omega_gpu_session_last_error()); goto done; } /* ---- Step 4: launch. The argument words land in the kernel's constant bank: three addresses (low word, * high word) and n. Each launch is pointed at its own slice of the arrays. */ uint32_t declared = omega_bw_gpr_declared(prog.regalloc.peak_gpr_usage); + uint64_t gpu_ns = 0; for (uint32_t base = 0; base < N_TOTAL; base += CHUNK) { uint64_t off = (uint64_t)base * sizeof(float); uint32_t n = N_TOTAL - base < CHUNK ? N_TOTAL - base : CHUNK; @@ -148,21 +302,17 @@ int main(void) { OmegaGpuLaunch L = { .code_va = code.va, .gpr_count = declared < 64 ? 64 : declared, .threads_x = THREADS, .threads_y = 1, .grid_x = (n + THREADS - 1) / THREADS, .grid_y = 1, .num_elements = n, .args = args, .n_args = OMEGA_BW_CBANK_MATMUL_ARGS_WORDS, .timeout_ms = 10000 }; - if (omega_gpu_session_launch(&L, NULL, NULL) != 0) { printf("FAIL: launch at element %u (stage: %s)\n", base, omega_gpu_session_last_error()); goto done; } + uint64_t el = 0; + if (omega_gpu_session_launch(&L, &el, NULL) != 0) { printf("FAIL: launch at element %u (stage: %s)\n", base, omega_gpu_session_last_error()); goto done; } + gpu_ns += el; } if (omega_gpu_session_sync_to_cpu(&c) != 0) { printf("FAIL: sync to CPU (stage: %s)\n", omega_gpu_session_last_error()); goto done; } /* ---- Step 5: check every element. Same IEEE single-precision add on both sides, so the bits must match. */ - uint32_t wrong = 0, unwritten = 0, first_bad = 0; - for (uint32_t i = 0; i < N_TOTAL; i++) { - float want = fa[i] + fb[i]; - if (wc[i] == POISON) unwritten++; - if (memcmp(&want, &wc[i], sizeof want) != 0) { if (!wrong++) first_bad = i; } - } - printf("checked %u of %u elements: %u wrong, %u never written\n", N_TOTAL, N_TOTAL, wrong, unwritten); - if (wrong) { float want = fa[first_bad] + fb[first_bad], got; memcpy(&got, &wc[first_bad], sizeof got); - printf("first mismatch: c[%u] = %g, expected %g\n", first_bad, got, want); } - rc = wrong ? 1 : 0; + rc = check(fa, fb, (const uint32_t *)wc); + /* vecadd reads a[i] and b[i] and writes c[i]: 8 bytes in, 4 out and one add per element */ + print_work(8ull * N_TOTAL, 4ull * N_TOTAL, N_TOTAL, (double)gpu_ns / 1e3); + print_sha("output", wc, bytes); printf("%s\n", rc ? "FAIL" : "PASS"); done: diff --git a/mk/dx-doctor.mk b/mk/dx-doctor.mk new file mode 100644 index 00000000..3cb1a2dc --- /dev/null +++ b/mk/dx-doctor.mk @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: MIT +# Developer bar D2 and D6 (docs/PAIN_POINTS.md): `make doctor` says, in sentences, whether this +# machine can run CUDA++ and what to do if not. It reads files under /proc, /sys and /dev only: +# it opens no device and needs no GPU window. `make hello-gpu` runs it first. +DOCTOR = $(OUT_DIR)/cudapp-doctor +# The one version CUDA++ has to match: the NVIDIA open kernel module whose headers it is built +# against. Taken from the folder name, so there is exactly one place it is written. +CUDAPP_NVIDIA_OPEN_ABI := $(patsubst nvidia-open-%,%,$(notdir $(NVIDIA_OPEN))) + +.PHONY: doctor test-doctor +$(DOCTOR): tools/doctor/cudapp_doctor.c $(wildcard src/omega_gpu_chip.c src/omega_gpu_chip.h) | $(OUT_DIR) + $(CC) $(CFLAGS) -DCUDAPP_NVIDIA_OPEN_ABI='"$(CUDAPP_NVIDIA_OPEN_ABI)"' -o $@ tools/doctor/cudapp_doctor.c $(wildcard src/omega_gpu_chip.c) +doctor: $(DOCTOR) + $(DOCTOR) +test-doctor: $(DOCTOR) + sh tests/doctor/run.sh $(DOCTOR) diff --git a/mk/dx-sim.mk b/mk/dx-sim.mk new file mode 100644 index 00000000..ecce448e --- /dev/null +++ b/mk/dx-sim.mk @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT +# Developer bar D3, D4, D7, D10, D12 (docs/PAIN_POINTS.md): hello_gpu --sim runs the same kernel program +# on the host warp simulator; tests/dx/hello_sim_test.sh checks the answers, the fault report, the work +# line and that two runs give the same bits. Host only: --sim never opens a device. +.PHONY: test-hello-sim +test-hello-sim: $(OUT_DIR)/hello_gpu + sh tests/dx/hello_sim_test.sh $(OUT_DIR)/hello_gpu diff --git a/mk/runtime-r2.mk b/mk/runtime-r2.mk index cc828c11..9eb6fe04 100644 --- a/mk/runtime-r2.mk +++ b/mk/runtime-r2.mk @@ -10,5 +10,6 @@ $(HELLO_GPU): examples/hello_gpu/hello_gpu.c $(OUT_DIR)/libomega_gpu.a hello-gpu-build: $(HELLO_GPU) -hello-gpu: hello-gpu-build +hello-gpu: hello-gpu-build $(DOCTOR) + $(DOCTOR) ./$(HELLO_GPU) diff --git a/src/omega_gpu_chip.c b/src/omega_gpu_chip.c new file mode 100644 index 00000000..5a0244d1 --- /dev/null +++ b/src/omega_gpu_chip.c @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: MIT */ +/* omega_gpu_chip.c: the qualified-chip table and the refusal sentence (developer bar D6). + * See omega_gpu_chip.h. Hosted: reads sysfs with stdio and dirent. */ +#include "omega_gpu_chip.h" + +#include +#include +#include +#include + +/* One row per chip that has run hello_gpu and the gates on a named commit. Add a row only with a receipt. */ +static const OmegaGpuChipRow k_rows[] = { + { OMEGA_GPU_PCI_VENDOR_NVIDIA, 0x2e12u, "NVIDIA GB10", "sm_121", + "evidence/m16-blackwell-native-path-requalification-receipt.json" }, +}; + +const OmegaGpuChipRow *omega_gpu_chip_find(uint16_t vendor, uint16_t device) { + for (size_t i = 0; i < sizeof k_rows / sizeof k_rows[0]; i++) + if (k_rows[i].vendor == vendor && k_rows[i].device == device) return &k_rows[i]; + return NULL; +} + +static int read_hex(const char *path, unsigned long *out) { + FILE *f = fopen(path, "r"); + if (!f) return -1; + char line[64] = { 0 }; + int ok = fgets(line, sizeof line, f) != NULL; + fclose(f); + if (!ok) return -1; + char *end = NULL; + *out = strtoul(line, &end, 16); + return end == line ? -1 : 0; +} + +int omega_gpu_chip_scan(const char *root, OmegaGpuPciDev *out, int max) { + char dir[4096]; + snprintf(dir, sizeof dir, "%s/sys/bus/pci/devices", root ? root : ""); + DIR *d = opendir(dir); + if (!d) return -1; + int found = 0; + struct dirent *e; + while ((e = readdir(d)) != NULL) { + if (e->d_name[0] == '.') continue; + char p[4400]; + unsigned long vendor, device, cls; + snprintf(p, sizeof p, "%s/%s/vendor", dir, e->d_name); + if (read_hex(p, &vendor) != 0 || vendor != OMEGA_GPU_PCI_VENDOR_NVIDIA) continue; + snprintf(p, sizeof p, "%s/%s/class", dir, e->d_name); + if (read_hex(p, &cls) != 0 || (cls >> 16) != 0x03u) continue; /* display/3D only: skips the audio function */ + snprintf(p, sizeof p, "%s/%s/device", dir, e->d_name); + if (read_hex(p, &device) != 0) continue; + if (found < max && out) { + OmegaGpuPciDev *g = &out[found]; + memset(g, 0, sizeof *g); + snprintf(g->bdf, sizeof g->bdf, "%.63s", e->d_name); + g->vendor = (uint16_t)vendor; g->device = (uint16_t)device; g->class_code = (uint32_t)cls; + } + found++; + } + closedir(d); + return found; +} + +int omega_gpu_chip_refusal(const OmegaGpuPciDev *d, char *buf, size_t n) { + return snprintf(buf, n, + "GPU %s: NVIDIA device 0x%04x is not one CUDA++ has qualified.\n" + "Why: CUDA++ writes each chip's machine code itself and has run it only on the NVIDIA GB10 (sm_121),\n" + "so it refuses this GPU now instead of failing later with \"no kernel image is available\".\n" + "What is missing: a target row for this chip, a check that the encoder's instruction words are valid on it,\n" + "its launch descriptor and class numbers, and the hello-gpu qualification run with its receipt.\n" + "What to do: follow docs/runtime/PORTABILITY.md section 5 (\"What a new GPU needs\") and CONTRIBUTING.md (\"Port a chip\"),\n" + "or report it with the output of `make doctor` attached.", + d->bdf, d->device); +} diff --git a/src/omega_gpu_chip.h b/src/omega_gpu_chip.h new file mode 100644 index 00000000..2e2affdd --- /dev/null +++ b/src/omega_gpu_chip.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: MIT */ +/* omega_gpu_chip.h: which GPUs CUDA++ has machine code for, and what it says about the others. + * + * Developer bar D6 (docs/PAIN_POINTS.md): a GPU works on day one or is refused with a sentence + * that says what is missing and what to do. Never a bare "no kernel image is available". + * + * A chip is named by its PCI vendor and device id, read from /sys/bus/pci/devices. That needs no + * device open and no driver call. (The driver's SM-version field reads 0xa04 on the GB10, which does + * not tell sm_120 from sm_121: evidence/m16-blackwell-native-path-requalification-receipt.json.) + * A row is only added with a receipt: the chip ran examples/hello_gpu and its gates on a named commit. */ +#ifndef OMEGA_GPU_CHIP_H +#define OMEGA_GPU_CHIP_H + +#include +#include + +#define OMEGA_GPU_PCI_VENDOR_NVIDIA 0x10deu + +typedef struct { + uint16_t vendor, device; + const char *name; /* "NVIDIA GB10" */ + const char *sm; /* "sm_121" */ + const char *receipt; /* path of the receipt that qualified it, in this repository */ +} OmegaGpuChipRow; + +typedef struct { + char bdf[64]; /* PCI address, e.g. "000f:01:00.0" */ + uint16_t vendor, device; + uint32_t class_code; /* 0x03xxxx: display or 3D controller */ +} OmegaGpuPciDev; + +/* The qualified row for vendor:device, or NULL. */ +const OmegaGpuChipRow *omega_gpu_chip_find(uint16_t vendor, uint16_t device); + +/* Every NVIDIA display/3D-class PCI function under /sys/bus/pci/devices (root "" = the real + * system). Fills up to max entries; returns how many were found (may exceed max), or -1 when the + * folder cannot be read. */ +int omega_gpu_chip_scan(const char *root, OmegaGpuPciDev *out, int max); + +/* The refusal text for a GPU with no qualified row: what it is, why CUDA++ refuses it now rather + * than failing later, what is missing, and what to do. Returns the length written (snprintf rules). */ +int omega_gpu_chip_refusal(const OmegaGpuPciDev *d, char *buf, size_t n); + +#endif diff --git a/src/omega_gpu_platform_linux.c b/src/omega_gpu_platform_linux.c index 2c901662..8bfd2643 100644 --- a/src/omega_gpu_platform_linux.c +++ b/src/omega_gpu_platform_linux.c @@ -180,6 +180,40 @@ static int ref_device_close(void *ctx, OmegaGpuDeviceHandle dev) { static const char *ref_diag_text(void *ctx) { return ((LinuxRef *)ctx)->diag; } +/* Developer bar D1 (docs/PAIN_POINTS.md): on the GB10 every buffer this platform hands out is the machine's own memory, + * which the CPU and GPU share, and the machine has no swap by default. Running it out does not end in an error message: + * the whole box can freeze until a power cycle. So an allocation that would leave less than a reserve free is refused + * here, before a handle slot or the driver is touched, with a sentence. The reserve is CUDAPP_MEM_RESERVE_MIB (MiB, + * default 4096; 0 turns the check off). CUDAPP_MEMINFO names another meminfo file (tests). When the file cannot be read + * the check cannot know, and allows the allocation. */ +#define CUDAPP_MEM_RESERVE_DEFAULT_MIB 4096ull +static void human_bytes(char *out, size_t n, uint64_t b) { + if (b < (1ull << 30)) snprintf(out, n, "%.1f MiB", (double)b / (double)(1ull << 20)); + else snprintf(out, n, "%.1f GiB", (double)b / (double)(1ull << 30)); +} +static int mem_reserve_check(LinuxRef *r, uint64_t bytes) { + unsigned long long reserve_mib = CUDAPP_MEM_RESERVE_DEFAULT_MIB; + const char *e = getenv("CUDAPP_MEM_RESERVE_MIB"); + if (e && *e) { char *end = NULL; unsigned long long v = strtoull(e, &end, 10); if (end && end != e && *end == 0) reserve_mib = v; } + if (reserve_mib == 0) return OMEGA_GPU_PLAT_OK; + const char *path = getenv("CUDAPP_MEMINFO"); + FILE *f = fopen(path && *path ? path : "/proc/meminfo", "r"); + if (!f) return OMEGA_GPU_PLAT_OK; + unsigned long long avail_kb = 0; int have = 0; char line[256]; + while (!have && fgets(line, sizeof line, f)) have = sscanf(line, "MemAvailable: %llu kB", &avail_kb) == 1; + fclose(f); + if (!have) return OMEGA_GPU_PLAT_OK; + const uint64_t avail = (uint64_t)avail_kb * 1024ull, reserve = (uint64_t)reserve_mib << 20; + if (bytes <= avail && avail - bytes >= reserve) return OMEGA_GPU_PLAT_OK; + char want[32], free_[32], keep[32]; + human_bytes(want, sizeof want, bytes); human_bytes(free_, sizeof free_, avail); human_bytes(keep, sizeof keep, reserve); + snprintf(r->diag, sizeof r->diag, + "dma_alloc: refused %s: %s of memory is free and CUDA++ keeps %s free (CUDAPP_MEM_RESERVE_MIB=%llu), because the CPU and " + "GPU share it and running it out freezes the machine. Free buffers or use a smaller batch.", + want, free_, keep, reserve_mib); + return OMEGA_GPU_PLAT_REFUSED_LIMIT; +} + static int ref_dma_alloc(void *ctx, OmegaGpuDeviceHandle dev, const OmegaGpuBufferDesc *desc, OmegaGpuBufferHandle *out, OmegaCpuView *cpu, OmegaGpuVa *gpu, OmegaGpuBusAddr *bus) { LinuxRef *r = ctx; @@ -198,6 +232,8 @@ static int ref_dma_alloc(void *ctx, OmegaGpuDeviceHandle dev, const OmegaGpuBuff (desc->kind != OMEGA_GPU_HANDLE_BUF_DATA || (desc->rights & (OMEGA_GPU_RIGHT_CPU_READ | OMEGA_GPU_RIGHT_HOST_POLLED)))) rc = OMEGA_GPU_PLAT_REFUSED_CACHE_POLICY; if (rc != OMEGA_GPU_PLAT_OK) { rc = refuse(r, rc, "dma_alloc"); ref_unlock(r); return rc; } + rc = mem_reserve_check(r, desc->bytes); /* D1: before any slot or driver call; the sentence is in r->diag */ + if (rc != OMEGA_GPU_PLAT_OK) { ref_unlock(r); return rc; } uint32_t idx = 0, gen = 0; rc = omega_gpu_handles_open(&r->t, desc->kind, desc->bytes, LINUX_REF_BUFFERS, g_caps.max_total_bytes, &idx, &gen); if (rc != OMEGA_GPU_PLAT_OK) { rc = refuse(r, rc, "dma_alloc"); ref_unlock(r); return rc; } diff --git a/src/omega_gpu_session.c b/src/omega_gpu_session.c index 4df1c0d8..fc712310 100644 --- a/src/omega_gpu_session.c +++ b/src/omega_gpu_session.c @@ -131,6 +131,20 @@ void omega_gpu_session_set_error(const char *stage) { omega_gpu_fmt(g_err, sizeo /* A platform refusal: the driver text when the device refused (the Linux reference writes ": ", * the stage names the session ever reported), else the stage and the refusal name. */ +/* The platform refused and wrote a full sentence for this stage (the Linux reference's memory reserve, developer bar D1, + * starts "dma_alloc: refused "): pass it on as it is. Any other refusal keeps the short form below. */ +static void fail_plat(const char *stage, int rc); +static void fail_plat_said(const char *stage, int rc) { + const OmegaGpuPlatform *p = LOAD(g_p); + const char *diag = p ? p->diag_text(p->ctx) : ""; + static const char said[] = "dma_alloc: refused "; + if (rc == OMEGA_GPU_PLAT_REFUSED_LIMIT && diag && stage && memcmp(stage, "dma_alloc", 10) == 0 && + strlen(diag) >= sizeof said - 1 && memcmp(diag, said, sizeof said - 1) == 0) { + omega_gpu_fmt(g_err, sizeof g_err, "%s", diag); + return; + } + fail_plat(stage, rc); +} static void fail_plat(const char *stage, int rc) { const OmegaGpuPlatform *p = LOAD(g_p); const char *diag = p ? p->diag_text(p->ctx) : ""; @@ -230,9 +244,10 @@ static int mem_alloc(uint32_t kind, uint32_t rights, size_t bytes, OmegaGpuMem * OmegaCpuView cpu; OmegaGpuVa va; OmegaGpuBusAddr bus; /* the bus address never leaves this function */ int rc = p->dma_alloc(p->ctx, g_s.dev, &d, &out->handle, &cpu, &va, &bus); if (rc != OMEGA_GPU_PLAT_OK || !cpu.ptr || cpu.len < want) { + const int platform_refused = rc != OMEGA_GPU_PLAT_OK; /* only then is the platform's text about this call */ if (rc == OMEGA_GPU_PLAT_OK) { (void)p->dma_free(p->ctx, out->handle); rc = OMEGA_GPU_PLAT_REFUSED_LIMIT; } BUMP(g_stats.alloc_failures, 1u); - fail_plat("dma_alloc", rc); + if (platform_refused) fail_plat_said("dma_alloc", rc); else fail_plat("dma_alloc", rc); memset(out, 0, sizeof *out); return -1; } diff --git a/tests/bw_warp_sim.h b/tests/bw_warp_sim.h index 7f05f4fa..d337475b 100644 --- a/tests/bw_warp_sim.h +++ b/tests/bw_warp_sim.h @@ -93,11 +93,19 @@ typedef struct { uint64_t splits; /* branches that split a fragment */ uint64_t bar_split_arrivals; /* BAR.SYNC reached by a fragment that is not the whole live warp */ int max_frags, peak_bars; + /* developer bar D3 (docs/PAIN_POINTS.md): who faulted, and where. Set with err. */ + uint32_t cur_tid, cur_cx, cur_cy; /* the lane being executed */ + uint32_t err_tid, err_cx, err_cy; /* block (cx, cy) and thread of the first error */ + uint64_t err_addr; unsigned err_bytes; /* WS_E_MEM: the address and access size that missed */ + /* developer bar D12: the work done, counted per lane (accumulates across ws_run calls) */ + uint64_t gld_bytes, gst_bytes; /* global bytes loaded and stored */ + uint64_t fp_ops; /* FADD, FSUB, FMUL count 1; FFMA counts 2 */ } WsSim; static void ws_fail(WsSim *s, int err, int pc, const char *what) { if (s->err) return; s->err = err; s->err_pc = pc; + s->err_tid = s->cur_tid; s->err_cx = s->cur_cx; s->err_cy = s->cur_cy; snprintf(s->msg, sizeof s->msg, "%s at pc %d: %s", ws_err_name(err), pc, what ? what : ""); } @@ -118,6 +126,7 @@ static uint32_t ws_lut3(uint32_t lut, uint32_t a, uint32_t b, uint32_t c) { static int ws_mem_ok(WsSim *s, uint64_t a, unsigned bytes, int pc) { if (s->nranges == 0) return 1; for (int i = 0; i < s->nranges; i++) if (a >= s->ranges[i].lo && a + bytes <= s->ranges[i].hi) return 1; + if (!s->err) { s->err_addr = a; s->err_bytes = bytes; } ws_fail(s, WS_E_MEM, pc, "global access outside the declared buffers"); return 0; } static uint32_t *ws_smem(WsSim *s, uint32_t a, int pc) { @@ -129,6 +138,7 @@ static int ws_popc(uint32_t m) { return __builtin_popcount(m); } /* One lane, one non-control instruction. */ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, uint32_t tid, uint32_t cx, uint32_t cy) { const BlackwellIRProgram *p = s->p; + s->cur_tid = tid; s->cur_cx = cx; s->cur_cy = cy; uint32_t a = ws_rds(l, in->src1_vreg, in->src1_subreg, p), b = ws_rds(l, in->src2_vreg, in->src2_subreg, p), c = ws_rds(l, in->src3_vreg, in->src3_subreg, p); switch (in->op) { case BW_IR_NOP: break; @@ -148,17 +158,17 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_LOP3_XOR: ws_wrs(l, in->dst_vreg, in->dst_subreg, a ^ b, p); break; case BW_IR_LOP3_LUT: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_lut3(in->imm & 0xff, a, b, c), p); break; case BW_IR_ISETP_GE_U32: l->p0 = a >= b; break; - case BW_IR_LDG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } - case BW_IR_LDG_E_U16: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 2, pc)) return; uint16_t x; memcpy(&x, (const void *)(uintptr_t)ad, 2); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); break; } - case BW_IR_STG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; memcpy((void *)(uintptr_t)ad, &b, 4); break; } - case BW_IR_LDG_E_64: case BW_IR_LDG_E_128: { unsigned n = in->op == BW_IR_LDG_E_64 ? 8u : 16u; uint64_t ad = ws_rd64(l, in->src1_vreg, p) + (uint64_t)(int64_t)(int32_t)in->imm; if (!ws_mem_ok(s, ad, n, pc)) return; if (ad & (n - 1)) { ws_fail(s, WS_E_MEM, pc, "wide global load not naturally aligned"); return; } uint32_t x[4]; memcpy(x, (const void *)(uintptr_t)ad, n); for (unsigned i = 0; i < n / 4; i++) ws_wrs(l, in->dst_vreg, i, x[i], p); break; } + case BW_IR_LDG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; uint32_t x; memcpy(&x, (const void *)(uintptr_t)ad, 4); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); s->gld_bytes += 4; break; } + case BW_IR_LDG_E_U16: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 2, pc)) return; uint16_t x; memcpy(&x, (const void *)(uintptr_t)ad, 2); ws_wrs(l, in->dst_vreg, in->dst_subreg, x, p); s->gld_bytes += 2; break; } + case BW_IR_STG_E: { uint64_t ad = ws_rd64(l, in->src1_vreg, p); if (!ws_mem_ok(s, ad, 4, pc)) return; memcpy((void *)(uintptr_t)ad, &b, 4); s->gst_bytes += 4; break; } + case BW_IR_LDG_E_64: case BW_IR_LDG_E_128: { unsigned n = in->op == BW_IR_LDG_E_64 ? 8u : 16u; uint64_t ad = ws_rd64(l, in->src1_vreg, p) + (uint64_t)(int64_t)(int32_t)in->imm; if (!ws_mem_ok(s, ad, n, pc)) return; if (ad & (n - 1)) { ws_fail(s, WS_E_MEM, pc, "wide global load not naturally aligned"); return; } uint32_t x[4]; memcpy(x, (const void *)(uintptr_t)ad, n); s->gld_bytes += n; for (unsigned i = 0; i < n / 4; i++) ws_wrs(l, in->dst_vreg, i, x[i], p); break; } case BW_IR_LDS128: { uint32_t ad = a + in->imm; if (ad & 15u) { ws_fail(s, WS_E_SMEM, pc, "LDS.128 address not 16-byte aligned"); return; } for (unsigned i = 0; i < 4; i++) { uint32_t *m = ws_smem(s, ad + 4u * i, pc); if (!m) return; ws_wrs(l, in->dst_vreg, i, *m, p); } break; } case BW_IR_LDS32: { uint32_t *m = ws_smem(s, a, pc); if (!m) return; ws_wrs(l, in->dst_vreg, in->dst_subreg, *m, p); break; } case BW_IR_STS32: { uint32_t *m = ws_smem(s, a, pc); if (!m) return; *m = b; break; } - case BW_IR_FADD: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) + ws_u2f(b)), p); break; - case BW_IR_FSUB: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) - ws_u2f(b)), p); break; - case BW_IR_FMUL: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) * ws_u2f(b)), p); break; - case BW_IR_FFMA: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaf(ws_u2f(a), ws_u2f(b), ws_u2f(c))), p); break; + case BW_IR_FADD: s->fp_ops++; ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) + ws_u2f(b)), p); break; + case BW_IR_FSUB: s->fp_ops++; ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) - ws_u2f(b)), p); break; + case BW_IR_FMUL: s->fp_ops++; ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(ws_u2f(a) * ws_u2f(b)), p); break; + case BW_IR_FFMA: s->fp_ops += 2; ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaf(ws_u2f(a), ws_u2f(b), ws_u2f(c))), p); break; case BW_IR_FMNMX_MAX: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fmaxf(ws_u2f(a), ws_u2f(b))), p); break; case BW_IR_FMNMX_MIN: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(fminf(ws_u2f(a), ws_u2f(b))), p); break; case BW_IR_MUFU_EX2: ws_wrs(l, in->dst_vreg, in->dst_subreg, ws_f2u(exp2f(ws_u2f(a))), p); break; diff --git a/tests/doctor/run.sh b/tests/doctor/run.sh new file mode 100644 index 00000000..04b91c6e --- /dev/null +++ b/tests/doctor/run.sh @@ -0,0 +1,117 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Host test for `cudapp-doctor` (CUDA++ developer bar D2 and D6, docs/PAIN_POINTS.md). +# usage: tests/doctor/run.sh build/cudapp-doctor (CUDAPP_DOCTOR_SHOW=1 also prints what each fake machine is told) +# No GPU and no device file is opened: every case is a fake machine built under a temporary +# folder and handed to the doctor through CUDAPP_DOCTOR_ROOT. Each case states the exit code +# and the sentences a person must see. A case that passes with the wrong text is a failure. +set -u +DOC=${1:?usage: run.sh path/to/cudapp-doctor} +T=$(mktemp -d "${TMPDIR:-/tmp}/cudapp-doctor-test.XXXXXX") +trap 'rm -rf "$T"' EXIT +pass=0; fail=0 + +# make_machine DIR [module-version-line|none] [pci-device-id|none] [dev nodes...] +make_machine() { + d=$1; ver=$2; pci=$3; shift 3 + mkdir -p "$d/proc/driver/nvidia" "$d/sys/bus/pci/devices" "$d/dev" + if [ "$ver" != none ]; then + printf 'NVRM version: %s\nGCC version: gcc version 13.3.0\n' "$ver" > "$d/proc/driver/nvidia/version" + else + rmdir "$d/proc/driver/nvidia" + fi + if [ "$pci" != none ]; then + g="$d/sys/bus/pci/devices/000f:01:00.0"; mkdir -p "$g" + echo 0x10de > "$g/vendor"; echo "$pci" > "$g/device"; echo 0x030000 > "$g/class" + fi + # an unrelated non-NVIDIA device the doctor must ignore + o="$d/sys/bus/pci/devices/0000:00:00.0"; mkdir -p "$o"; echo 0x8086 > "$o/vendor"; echo 0x1234 > "$o/device"; echo 0x060000 > "$o/class" + printf 'MemTotal: 127535484 kB\nMemFree: 1000000 kB\nMemAvailable: 42000000 kB\n' > "$d/proc/meminfo" + for n in "$@"; do : > "$d/dev/$n"; chmod 666 "$d/dev/$n"; done +} +OPEN='NVIDIA UNIX Open Kernel Module for aarch64 580.173.02 Release Build (test) Tue Jun 23 08:34:19 UTC 2026' +NODES='nvidiactl nvidia0 nvidia-uvm' + +# check NAME WANT_EXIT ROOT then one grep -F pattern per argument (all must appear) +check() { + name=$1; want=$2; root=$3; shift 3 + out=$(CUDAPP_DOCTOR_ROOT="$root" "$DOC" 2>&1); got=$? + [ -n "${CUDAPP_DOCTOR_SHOW:-}" ] && { echo "===== fake machine: $name (exit $got)"; printf "%s\n" "$out"; } + ok=1 + [ "$got" -eq "$want" ] || { echo " exit $got, want $want"; ok=0; } + for pat in "$@"; do + printf '%s\n' "$out" | grep -qF -- "$pat" || { echo " missing: $pat"; ok=0; } + done + # D6: never the bare CUDA message, in any case + printf '%s\n' "$out" | grep -qi 'no kernel image' && ! printf '%s\n' "$out" | grep -qF 'instead of failing later' && { echo " bare 'no kernel image' text"; ok=0; } + if [ $ok -eq 1 ]; then pass=$((pass+1)); echo "PASS $name"; else fail=$((fail+1)); echo "FAIL $name"; printf '%s\n' "$out" | sed 's/^/ | /'; fi +} + +# 1. a ready GB10 +make_machine "$T/gb10" "$OPEN" 0x2e12 $NODES +check gb10-ready 0 "$T/gb10" \ + 'ok NVIDIA kernel module: open module 580.173.02' \ + 'ok GPU 000f:01:00.0: NVIDIA GB10 (sm_121), qualified' \ + 'evidence/m16-blackwell-native-path-requalification-receipt.json' \ + 'ok device files: /dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm' \ + 'CUDA toolkit: not needed' \ + 'READY. Next: make hello-gpu' + +# 2. no NVIDIA kernel module loaded +make_machine "$T/nomod" none 0x2e12 +check no-module 1 "$T/nomod" \ + 'FAIL NVIDIA kernel module: not loaded' \ + 'sudo modprobe nvidia' \ + 'NOT READY' + +# 3. a different module version: our ioctl structures come from the 580.173.02 headers +make_machine "$T/oldmod" 'NVIDIA UNIX Open Kernel Module for aarch64 575.64.05 Release Build (test)' 0x2e12 $NODES +check module-version 1 "$T/oldmod" \ + 'FAIL NVIDIA kernel module: version 575.64.05 is loaded; CUDA++ speaks the 580.173.02 interface' \ + 'refuses instead of guessing' \ + 'NOT READY' + +# 4. the proprietary (closed) module at the right version: allowed, with a warning +make_machine "$T/closed" 'NVIDIA UNIX aarch64 Kernel Module 580.173.02 Release Build (test)' 0x2e12 $NODES +check closed-module 0 "$T/closed" \ + 'warn NVIDIA kernel module: the closed module 580.173.02' \ + 'READY. Next: make hello-gpu' + +# 5. D6: a GPU CUDA++ has no machine code for. Refused with what is missing and what to do. +make_machine "$T/newchip" "$OPEN" 0x2b85 $NODES +check unknown-chip 1 "$T/newchip" \ + 'FAIL GPU 000f:01:00.0: NVIDIA device 0x2b85 is not one CUDA++ has qualified' \ + 'instead of failing later with "no kernel image is available"' \ + 'What is missing:' \ + 'docs/runtime/PORTABILITY.md section 5' \ + 'NOT READY' + +# 6. no NVIDIA GPU at all +make_machine "$T/nogpu" "$OPEN" none $NODES +check no-gpu 1 "$T/nogpu" \ + 'FAIL GPU: no NVIDIA GPU found in /sys/bus/pci/devices' \ + 'NOT READY' + +# 7. the unified-memory device file is missing +make_machine "$T/nouvm" "$OPEN" 0x2e12 nvidiactl nvidia0 +check no-uvm 1 "$T/nouvm" \ + 'FAIL device files: /dev/nvidia-uvm is missing' \ + 'sudo modprobe nvidia-uvm' \ + 'NOT READY' + +# 8. a device file this user may not open +make_machine "$T/perm" "$OPEN" 0x2e12 $NODES +chmod 600 "$T/perm/dev/nvidia0"; chmod 000 "$T/perm/dev/nvidia0" +if [ -r "$T/perm/dev/nvidia0" ]; then + echo "SKIP perm (running as root: every file is readable)" +else + check no-permission 1 "$T/perm" \ + 'FAIL device files: /dev/nvidia0 exists but this user cannot open it for reading and writing' \ + 'NOT READY' +fi + +# 9. the memory line on a unified-memory chip +check memory-line 0 "$T/gb10" 'ok memory: 121.6 GiB shared by the CPU and the GPU, 40.1 GiB available now' + +echo "doctor tests: $pass passed, $fail failed" +[ "$fail" -eq 0 ] diff --git a/tests/dx/hello_sim_test.sh b/tests/dx/hello_sim_test.sh new file mode 100644 index 00000000..43029b85 --- /dev/null +++ b/tests/dx/hello_sim_test.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Host test for developer bar rows D3, D4, D7, D10 and D12 (docs/PAIN_POINTS.md), on hello_gpu --sim. +# usage: tests/dx/hello_sim_test.sh build/hello_gpu +# No GPU: --sim runs the same kernel program on the host warp simulator (tests/bw_warp_sim.h). +# D4 --sim checks all 1048576 answers bit for bit and passes +# D3 --sim --bug=past-end (the host passes n+1 on the last launch, a classic off-by-one) fails +# AT that launch and names the kernel, launch, instruction, block, thread, address, the buffer +# and how far past its end, and the next command +# D7 two runs print the same output hash +# D10 two runs print the same machine-code hash, and the build time is printed +# D12 the work line gives the exact bytes moved and the floor time at the measured ceiling +set -u +H=${1:?usage: hello_sim_test.sh path/to/hello_gpu} +pass=0; fail=0 +want() { # name, text, pattern... + n=$1; t=$2; shift 2; ok=1 + for p in "$@"; do printf '%s\n' "$t" | grep -qF -- "$p" || { echo " missing: $p"; ok=0; }; done + if [ $ok -eq 1 ]; then pass=$((pass+1)); echo "PASS $n"; else fail=$((fail+1)); echo "FAIL $n"; printf '%s\n' "$t" | sed 's/^/ | /'; fi +} +exitis() { # name, got, want + if [ "$2" -eq "$3" ]; then pass=$((pass+1)); echo "PASS $1 (exit $2)"; else fail=$((fail+1)); echo "FAIL $1: exit $2, want $3"; fi +} + +out1=$("$H" --sim 2>&1); rc1=$? +exitis sim-pass "$rc1" 0 +want sim-checks "$out1" \ + 'on the host simulator (no GPU)' \ + 'checked 1048576 of 1048576 elements: 0 wrong, 0 never written' \ + 'PASS' +want work-line "$out1" \ + 'work: 12582912 bytes moved (8388608 read, 4194304 written), 1048576 floating-point operations' \ + 'at the GB10'"'"'s measured 195.1 GB/s read ceiling this needs at least 64.5 us' +want hashes-printed "$out1" 'output sha256 ' 'machine code sha256 ' 'kernel built in ' +out2=$("$H" --sim 2>&1) +h1=$(printf '%s\n' "$out1" | grep -E 'output sha256|machine code sha256'); h2=$(printf '%s\n' "$out2" | grep -E 'output sha256|machine code sha256') +if [ -n "$h1" ] && [ "$h1" = "$h2" ]; then pass=$((pass+1)); echo "PASS same-bits-twice"; else fail=$((fail+1)); echo "FAIL same-bits-twice"; echo " run1: $h1"; echo " run2: $h2"; fi +printf '%s\n' "$out1" | grep -q FAULT && { fail=$((fail+1)); echo "FAIL clean run printed FAULT"; } + +bad=$("$H" --sim --bug=past-end 2>&1); rcb=$? +exitis fault-exit "$rcb" 1 +want fault-report "$bad" \ + 'FAULT at launch 8 of 8 of kernel vecadd (simulator): global load outside every buffer' \ + 'instruction: ' 'LDG.E (4-byte load)' \ + 'thread: block 1024, thread 0 (element 1048576 of the whole job)' \ + 'address: 0x' '0 bytes past the end of buffer a = [' \ + 'next: ' +printf '%s\n' "$bad" | grep -q 'checked 1048576' && { fail=$((fail+1)); echo "FAIL fault run went on past the faulting launch"; } +# The address line must name the real end of a: parse "a = [lo, hi)" and the faulting address. +lo_hi=$(printf '%s\n' "$bad" | sed -n 's/.*buffer a = \[\(0x[0-9a-f]*\), \(0x[0-9a-f]*\)).*/\1 \2/p') +addr=$(printf '%s\n' "$bad" | sed -n 's/^ *address: \(0x[0-9a-f]*\).*/\1/p') +set -- $lo_hi +if [ -n "$addr" ] && [ $# -eq 2 ] && [ $(( addr )) -eq $(( $2 )) ] && [ $(( $2 - $1 )) -eq 4194304 ]; then pass=$((pass+1)); echo "PASS fault-address-is-end-of-a" +else fail=$((fail+1)); echo "FAIL fault-address-is-end-of-a (addr=$addr range=$lo_hi)"; fi + +echo "hello --sim tests: $pass passed, $fail failed" +[ "$fail" -eq 0 ] diff --git a/tests/test_omega_gpu_platform_linux.c b/tests/test_omega_gpu_platform_linux.c index 6917d15d..5ee405c2 100644 --- a/tests/test_omega_gpu_platform_linux.c +++ b/tests/test_omega_gpu_platform_linux.c @@ -241,6 +241,63 @@ static void c_cmdlist_near_cap_with_l2_inval_pending(void) { omega_gpu_session_unlock(); } +/* Developer bar D1 (docs/PAIN_POINTS.md): on the GB10 every CUDA++ buffer is the machine's own memory, and running + * it out freezes the whole box. The reference refuses an allocation that would leave less than the reserve free, + * before the driver is called, with a sentence that names the bytes asked, the bytes free and the setting. + * CUDAPP_MEMINFO points the platform at a fake /proc/meminfo; CUDAPP_MEM_RESERVE_MIB sets the reserve (0 = off). */ +static void write_meminfo(const char *path, unsigned long long avail_kb) { + FILE *f = fopen(path, "w"); + if (!f) { case_ok = 0; return; } + fprintf(f, "MemTotal: 127535484 kB\nMemFree: 100000 kB\nMemAvailable: %llu kB\n", avail_kb); + fclose(f); +} +static void c_memory_reserve(void) { + fake_reset(); + fk.alloc_max = 8u << 20; /* the fake driver may hand out up to 8 MiB, so only our check can refuse */ + char path[] = "/tmp/cudapp-meminfo-XXXXXX"; + int fd = mkstemp(path); if (fd >= 0) close(fd); + write_meminfo(path, 4097ull * 1024ull); /* 4097 MiB free: 1 MiB above the default 4096 MiB reserve */ + setenv("CUDAPP_MEMINFO", path, 1); + unsetenv("CUDAPP_MEM_RESERVE_MIB"); + OmegaGpuPlatformCaps caps; + const OmegaGpuPlatform *p = omega_gpu_platform_linux(&caps); + OmegaGpuDeviceHandle d; + EXPECT(p->device_open(p->ctx, 0, &d) == OMEGA_GPU_PLAT_OK); + OmegaGpuBufferDesc small = {.kind = OMEGA_GPU_HANDLE_BUF_DATA, .rights = OMEGA_GPU_RIGHT_CPU_READ | OMEGA_GPU_RIGHT_GPU_WRITE, + .gpu_cache = OMEGA_GPU_CACHE_GPU_UNCACHED, .bytes = 4096}; + OmegaGpuBufferDesc big = small; big.bytes = 2u << 20; + OmegaGpuBufferHandle h; OmegaCpuView cpu; OmegaGpuVa va; OmegaGpuBusAddr bus; + EXPECT(p->dma_alloc(p->ctx, d, &small, &h, &cpu, &va, &bus) == OMEGA_GPU_PLAT_OK); /* leaves more than the reserve */ + const int allocs0 = fk.alloc_calls; + EXPECT(p->dma_alloc(p->ctx, d, &big, &h, &cpu, &va, &bus) == OMEGA_GPU_PLAT_REFUSED_LIMIT); + EXPECT(fk.alloc_calls == allocs0); /* refused before the driver */ + const char *t = p->diag_text(p->ctx); + EXPECT(strstr(t, "dma_alloc: refused 2.0 MiB") != NULL); + EXPECT(strstr(t, "4.0 GiB of memory is free") != NULL); + EXPECT(strstr(t, "CUDAPP_MEM_RESERVE_MIB=4096") != NULL); + EXPECT(strstr(t, "freezes the machine") != NULL); + printf(" refusal: %s\n", t); + setenv("CUDAPP_MEM_RESERVE_MIB", "0", 1); /* the reserve can be turned off */ + EXPECT(p->dma_alloc(p->ctx, d, &big, &h, &cpu, &va, &bus) == OMEGA_GPU_PLAT_OK); + setenv("CUDAPP_MEM_RESERVE_MIB", "1", 1); /* and set: 1 MiB reserve, 2 MiB fits in 4097 MiB */ + EXPECT(p->dma_alloc(p->ctx, d, &big, &h, &cpu, &va, &bus) == OMEGA_GPU_PLAT_OK); + unsetenv("CUDAPP_MEM_RESERVE_MIB"); + setenv("CUDAPP_MEMINFO", "/nonexistent/meminfo", 1); /* cannot read memory: the check cannot know, so it allows */ + EXPECT(p->dma_alloc(p->ctx, d, &big, &h, &cpu, &va, &bus) == OMEGA_GPU_PLAT_OK); + EXPECT(p->device_close(p->ctx, d) == OMEGA_GPU_PLAT_OK); + /* through the session, the same sentence reaches omega_gpu_session_last_error() */ + setenv("CUDAPP_MEMINFO", path, 1); + omega_gpu_session_lock(); + EXPECT(omega_gpu_session_open() != NULL); + OmegaGpuMem m; + EXPECT(omega_gpu_session_alloc(2u << 20, &m) != 0); + EXPECT(strstr(omega_gpu_session_last_error(), "dma_alloc: refused 2.0 MiB") != NULL); + printf(" session: %s\n", omega_gpu_session_last_error()); + EXPECT(omega_gpu_session_alloc(4096, &m) == 0); + omega_gpu_session_unlock(); + unlink(path); +} + typedef struct { const char *id; void (*fn)(void); } Case; static const Case CASES[] = { {"LINUX_REF_CAPS_NO_MMIO_NO_IRQ", c_caps}, @@ -251,6 +308,7 @@ static const Case CASES[] = { {"MARKER_NEVER_LATCHES_AND_PARKS", c_marker_never_latches}, {"L2_INVAL_PREFIX_ONCE_AFTER_CACHED_HOST_WRITE", c_l2_inval_prefix_once}, {"CMDLIST_NEAR_CAP_SUBMITS_WITH_L2_INVAL_PENDING", c_cmdlist_near_cap_with_l2_inval_pending}, + {"D1_MEMORY_RESERVE_REFUSES_BEFORE_THE_DRIVER", c_memory_reserve}, }; int main(void) { diff --git a/tools/doctor/cudapp_doctor.c b/tools/doctor/cudapp_doctor.c new file mode 100644 index 00000000..5c9c1894 --- /dev/null +++ b/tools/doctor/cudapp_doctor.c @@ -0,0 +1,202 @@ +/* SPDX-License-Identifier: MIT */ +/* cudapp-doctor: is this machine ready for CUDA++, and if not, what exactly to do. + * + * Developer bar D2 and D6 (docs/PAIN_POINTS.md). CUDA's install needs a driver, a toolkit, a + * framework build and an extension build whose versions all agree, and a mismatch shows up later + * as an undefined symbol or "no kernel image". CUDA++ has one thing to match: the NVIDIA kernel + * module its driver client speaks to. This program checks that and everything else a first run + * needs, and prints one line per check. Every failing line says what is wrong, why it matters and + * the command to run next. + * + * It reads files only (/proc, /sys, /dev): no device is opened and no GPU window is needed. + * CUDAPP_DOCTOR_ROOT= makes it read /proc, /sys and /dev instead (tests). + * Exit 0: READY. Exit 1: at least one FAIL line. */ +#include "omega_gpu_chip.h" + +#include +#include +#include +#include +#include + +#ifndef CUDAPP_NVIDIA_OPEN_ABI +#error "build with make doctor: CUDAPP_NVIDIA_OPEN_ABI comes from the third_party/nvidia-open- folder" +#endif + +static const char *g_root = ""; +static int g_fail, g_warn; + +static void path(char *out, size_t n, const char *p) { snprintf(out, n, "%s%s", g_root, p); } + +static void line(const char *tag, const char *what, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +#include +static void line(const char *tag, const char *what, const char *fmt, ...) { + printf(" %-5s %s: ", tag, what); + va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); + printf("\n"); + if (!strcmp(tag, "FAIL")) g_fail++; + if (!strcmp(tag, "warn")) g_warn++; +} +static void more(const char *text) { /* indented follow-on lines, one per \n */ + const char *s = text; + while (*s) { + const char *e = strchr(s, '\n'); + size_t len = e ? (size_t)(e - s) : strlen(s); + printf(" %.*s\n", (int)len, s); + if (!e) break; + s = e + 1; + } +} + +/* ---- the kernel module: present, open or closed, and the one version CUDA++ must match ---- */ +static void check_module(void) { + char p[4200], buf[1024] = { 0 }; + path(p, sizeof p, "/proc/driver/nvidia/version"); + FILE *f = fopen(p, "r"); + if (!f || !fgets(buf, sizeof buf, f)) { + if (f) fclose(f); + line("FAIL", "NVIDIA kernel module", "not loaded (%s/proc/driver/nvidia/version does not exist)", g_root); + more("CUDA++ uses no NVIDIA user-space software, but it talks to NVIDIA's kernel module.\n" + "Do this: sudo modprobe nvidia && sudo modprobe nvidia-uvm\n" + "If modprobe finds no module, install NVIDIA's open kernel module " CUDAPP_NVIDIA_OPEN_ABI + " (the open-gpu-kernel-modules release of that number), then run make doctor again."); + return; + } + fclose(f); + int open_module = strstr(buf, "Open Kernel Module") != NULL; + /* the version is the first word that looks like N.N or N.N.N after "Module" */ + char ver[64] = { 0 }; + const char *m = strstr(buf, "Module"); + for (const char *s = m ? m : buf; *s; s++) { + if (*s >= '0' && *s <= '9') { + size_t k = 0; + while ((s[k] >= '0' && s[k] <= '9') || s[k] == '.') k++; + if (k > 2 && memchr(s, '.', k) && k < sizeof ver) { memcpy(ver, s, k); break; } + s += k ? k - 1 : 0; + } + } + if (!ver[0]) { + line("FAIL", "NVIDIA kernel module", "loaded, but its version could not be read from: %.120s", buf); + more("Do this: report it with the output of `cat /proc/driver/nvidia/version` attached."); + return; + } + if (strcmp(ver, CUDAPP_NVIDIA_OPEN_ABI) != 0) { + line("FAIL", "NVIDIA kernel module", "version %s is loaded; CUDA++ speaks the " CUDAPP_NVIDIA_OPEN_ABI " interface", ver); + more("Why: CUDA++ builds its driver calls from the " CUDAPP_NVIDIA_OPEN_ABI " open-module headers\n" + "(third_party/nvidia-open-" CUDAPP_NVIDIA_OPEN_ABI "). The layout of those calls can change between module versions,\n" + "and a wrong layout fails in strange ways, so CUDA++ refuses instead of guessing.\n" + "This is the only version CUDA++ asks you to match: no toolkit, no framework build, no extension build.\n" + "Do this: install the " CUDAPP_NVIDIA_OPEN_ABI " open kernel module, or port the client to your version\n" + "(CONTRIBUTING.md, \"Port a driver version\": copy the new headers, rebuild, run make test and make hello-gpu)."); + return; + } + if (!open_module) { + line("warn", "NVIDIA kernel module", "the closed module %s is loaded; CUDA++ was qualified on the open module of that version", ver); + more("It uses the same calls and should work. If anything fails, switch to the open module and say so in your report."); + return; + } + line("ok", "NVIDIA kernel module", "open module %s (CUDA++ speaks " CUDAPP_NVIDIA_OPEN_ABI ")", ver); +} + +/* ---- device files ---- */ +static void check_nodes(void) { + static const char *const nodes[] = { "/dev/nvidiactl", "/dev/nvidia0", "/dev/nvidia-uvm" }; + int bad = 0; + for (size_t i = 0; i < sizeof nodes / sizeof nodes[0]; i++) { + char p[4200]; + path(p, sizeof p, nodes[i]); + if (access(p, F_OK) != 0) { + line("FAIL", "device files", "%s is missing", nodes[i]); + if (!strcmp(nodes[i], "/dev/nvidia-uvm")) + more("Do this: sudo modprobe nvidia-uvm (creates /dev/nvidia-uvm; CUDA++ maps GPU memory through it)"); + else + more("Do this: sudo modprobe nvidia (or run nvidia-modprobe once, which creates the device files)"); + bad++; + } else if (access(p, R_OK | W_OK) != 0) { + line("FAIL", "device files", "%s exists but this user cannot open it for reading and writing", nodes[i]); + more("Do this: ask the machine's owner to add you to the group that owns it (ls -l on the file shows it),\n" + "or set the module option NVreg_DeviceFileMode=0666."); + bad++; + } + } + if (!bad) line("ok", "device files", "/dev/nvidiactl /dev/nvidia0 /dev/nvidia-uvm can be opened by this user"); +} + +/* ---- the GPU itself: qualified, or refused with what is missing (D6) ---- */ +static void check_gpu(int *unified) { + OmegaGpuPciDev devs[16]; + int n = omega_gpu_chip_scan(g_root, devs, 16); + if (n < 0) { line("FAIL", "GPU", "cannot read %s/sys/bus/pci/devices", g_root); more("Do this: run make doctor on the machine itself, not in a container without /sys."); return; } + if (n == 0) { + line("FAIL", "GPU", "no NVIDIA GPU found in /sys/bus/pci/devices"); + more("Do this: check the GPU is seated and powered (lspci | grep -i nvidia)."); + return; + } + if (n > 16) n = 16; + for (int i = 0; i < n; i++) { + const OmegaGpuChipRow *r = omega_gpu_chip_find(devs[i].vendor, devs[i].device); + char what[96]; + snprintf(what, sizeof what, "GPU %.63s", devs[i].bdf); + if (r) { + line("ok", what, "%s (%s), qualified (receipt: %s)", r->name, r->sm, r->receipt); + if (r->device == 0x2e12u) *unified = 1; /* GB10: one memory for CPU and GPU */ + } else { + char text[2048]; + omega_gpu_chip_refusal(&devs[i], text, sizeof text); + const char *nl = strchr(text, '\n'); + const char *first = text + 4 + strlen(devs[i].bdf) + 2; /* after "GPU : " (a PCI address has colons in it) */ + line("FAIL", what, "%.*s", (int)(nl - first), first); + more(nl + 1); + } + } +} + +/* ---- memory: on a unified-memory chip the GPU's memory is the machine's memory ---- */ +static void check_memory(int unified) { + char p[4200], l[256]; + path(p, sizeof p, "/proc/meminfo"); + FILE *f = fopen(p, "r"); + if (!f) { line("info", "memory", "cannot read /proc/meminfo"); return; } + unsigned long long total = 0, avail = 0; + while (fgets(l, sizeof l, f)) { + sscanf(l, "MemTotal: %llu kB", &total); + sscanf(l, "MemAvailable: %llu kB", &avail); + } + fclose(f); + double gt = (double)total / 1048576.0, ga = (double)avail / 1048576.0; + if (unified) line("ok", "memory", "%.1f GiB shared by the CPU and the GPU, %.1f GiB available now", gt, ga); + else line("info", "memory", "%.1f GiB system memory, %.1f GiB available now", gt, ga); +} + +/* ---- the CUDA toolkit: not needed. Say so, so nobody installs it for us. ---- */ +static void note_toolkit(void) { + const char *paths[] = { "/usr/local/cuda/bin/nvcc", "/usr/bin/nvcc" }; + for (size_t i = 0; i < 2; i++) { + char p[4200]; + path(p, sizeof p, paths[i]); + if (access(p, X_OK) == 0) { line("info", "CUDA toolkit", "not needed and not used by CUDA++ (one is installed at %s; that is fine)", paths[i]); return; } + } + line("info", "CUDA toolkit", "not needed and not used by CUDA++ (none installed)"); +} + +int main(int argc, char **argv) { + (void)argc; (void)argv; + const char *r = getenv("CUDAPP_DOCTOR_ROOT"); + if (r) g_root = r; + struct utsname u; + printf("cudapp doctor: is this machine ready for CUDA++?\n"); + if (uname(&u) == 0) line("info", "system", "%s %s %s", u.sysname, u.release, u.machine); + check_module(); + check_nodes(); + int unified = 0; + check_gpu(&unified); + check_memory(unified); + note_toolkit(); + line("info", "compiler", "this doctor was built by " __VERSION__ "; CUDA++ needs only make and a C compiler"); + if (g_fail) { + printf("NOT READY: %d problem%s above. Fix the first FAIL line and run make doctor again.\n", g_fail, g_fail == 1 ? "" : "s"); + return 1; + } + printf("READY. Next: make hello-gpu\n"); + return 0; +} diff --git a/tools/dx/recount.sh b/tools/dx/recount.sh new file mode 100755 index 00000000..f18a3921 --- /dev/null +++ b/tools/dx/recount.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# Re-run the GitHub issue search counts behind docs/PAIN_POINTS.md and print then and now. +# usage: tools/dx/recount.sh [evidence/dx/pain-points/counts.json] +# Uses GitHub's public search API (unauthenticated: about 10 searches a minute, so it waits 7 s between +# them). Entries that were not GitHub searches (Stack Overflow, Hacker News) are listed, not rerun. +F=${1:-evidence/dx/pain-points/counts.json} +python3 - "$F" <<'PY' +import json, sys, time, urllib.request, urllib.parse +for r in json.load(open(sys.argv[1])): + api = r.get('api') or '' + if 'api.github.com' not in api and not api.startswith('search/issues'): + if r['query'].startswith('GitHub search/issues q='): + q = r['query'].split('q=', 1)[1] + api = 'https://api.github.com/search/issues?per_page=1&q=' + urllib.parse.quote(q) + else: + print(f"{r.get('total')!s:>8} (not rerun) {r['query']}"); continue + if api.startswith('search/'): api = 'https://api.github.com/' + api + try: + with urllib.request.urlopen(urllib.request.Request(api, headers={'Accept': 'application/vnd.github+json'}), timeout=30) as h: + now = json.load(h).get('total_count') + except Exception as e: + now = f'error {e}' + print(f"{r.get('total')!s:>8} -> {now!s:<8} {r['query']} (then: {r.get('run_at')})") + time.sleep(7) +PY diff --git a/tools/dx/sources.py b/tools/dx/sources.py new file mode 100644 index 00000000..9b864ef7 --- /dev/null +++ b/tools/dx/sources.py @@ -0,0 +1,683 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +# Copied from the Hermes Agent grounded-citations skill (MIT) to check docs/PAIN_POINTS.md: see section 5 there. +"""Citation ledger for grounded answers and documents. + +Owns the ``url -> [n]`` mapping used by the ``grounded-citations`` skill. +Ids are assigned at retrieval time and never change, so a draft's ``[3]`` +always resolves to the same page. The model only ever emits integers the +ledger handed it, which is what makes the citations verifiable. + +Subcommands +----------- + reset start a clean ledger + add URL [URL ...] register source(s), print their ids + ingest FILE|- register every url found in JSON tool output + quote ID --text T --from FILE|- attach verbatim supporting evidence to a source + list show the ledger + render render a Sources block + verify DRAFT check a draft's citations against the ledger + +Fact-checking is evidence-backed citation: ``quote`` only accepts text that +literally appears in the fetched page text you point it at, ``verify +--evidence`` requires every cited source to carry at least one such quote, and +``render --style evidence`` prints the quotes under each source so the reader +can check the chain themselves. Claims from model knowledge are declared with +an ``[unverified]`` marker rather than silently blended in. + +Ledger path resolution (first wins): + --ledger PATH + $HERMES_CITATION_LEDGER + $HERMES_HOME/cache/citations/ledger.json +""" + +from __future__ import annotations + +import argparse +import json +import os +import re +import sys +import time +from pathlib import Path +from typing import Any, Iterable + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +try: + from _hermes_home import get_hermes_home +except ImportError: # standalone copy in CUDA++ (tools/dx): default ledger under ~/.hermes, or pass --ledger + def get_hermes_home(): + return Path(os.environ.get("HERMES_HOME", Path.home() / ".hermes")) + +SCHEMA_VERSION = 1 + +# A citation marker in prose: [12]. Markdown links ([text](url)) and +# reference-style labels are excluded by requiring digits only and no +# following "(" or ":". +_CITE_RE = re.compile(r"\[(\d{1,4})\](?![(:])") +_SOURCES_HEADER_RE = re.compile(r"^\s*(?:#{1,6}\s*)?(?:\*\*)?sources:?(?:\*\*)?\s*$", re.IGNORECASE) +_SOURCE_LINE_RE = re.compile(r"^\s*\[(\d{1,4})\]\s*[-–:]?\s*(\S+)") +_URL_IN_TEXT_RE = re.compile(r"https?://[^\s\"'<>)\]}]+") +_FENCE_RE = re.compile(r"^\s*(?:```|~~~)") +# Explicit declaration that a claim comes from model knowledge, not a source. +_UNVERIFIED_RE = re.compile(r"\[unverified\]", re.IGNORECASE) + + +# --------------------------------------------------------------------------- +# Ledger I/O +# --------------------------------------------------------------------------- + + +def resolve_ledger_path(explicit: str | None = None) -> Path: + if explicit: + return Path(explicit).expanduser() + env = os.environ.get("HERMES_CITATION_LEDGER", "").strip() + if env: + return Path(env).expanduser() + return get_hermes_home() / "cache" / "citations" / "ledger.json" + + +def normalize_url(url: str) -> str: + """Canonicalize a URL for ledger identity. + + Strips the fragment and a trailing slash so ``/page``, ``/page/`` and + ``/page#section`` are one source. Query strings are significant and are + kept — they usually select different content. + """ + u = (url or "").strip() + if "#" in u: + u = u.split("#", 1)[0] + stripped = u.rstrip("/") + return stripped or u + + +def load_ledger(path: Path) -> dict[str, Any]: + if not path.exists(): + return {"version": SCHEMA_VERSION, "sources": []} + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (json.JSONDecodeError, OSError) as exc: + raise SystemExit(f"error: ledger at {path} is unreadable ({exc}); run `reset` to start over") + if not isinstance(data, dict) or not isinstance(data.get("sources"), list): + raise SystemExit(f"error: ledger at {path} has an unexpected shape; run `reset`") + return data + + +def save_ledger(path: Path, data: dict[str, Any]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + tmp = path.with_suffix(path.suffix + f".tmp{os.getpid()}") + tmp.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + os.replace(tmp, path) + + +class _LedgerLock: + """Best-effort cross-process lock (O_EXCL lockfile, stdlib only). + + Parallel subagents can share one ledger via --ledger; without a lock two + concurrent ``add`` calls can assign the same id. Falls through after the + timeout rather than blocking a task forever — a stale lock must never + wedge the ledger. + """ + + def __init__(self, path: Path, timeout: float = 5.0) -> None: + self.lock_path = path.with_suffix(path.suffix + ".lock") + self.timeout = timeout + self.fd: int | None = None + + def __enter__(self) -> _LedgerLock: + self.lock_path.parent.mkdir(parents=True, exist_ok=True) + deadline = time.monotonic() + self.timeout + while True: + try: + self.fd = os.open(str(self.lock_path), os.O_CREAT | os.O_EXCL | os.O_WRONLY) + return self + except FileExistsError: + if time.monotonic() >= deadline: + # Assume a stale lock from a crashed run. + try: + self.lock_path.unlink() + except OSError: + return self + continue + time.sleep(0.05) + + def __exit__(self, *_exc: object) -> None: + if self.fd is not None: + try: + os.close(self.fd) + except OSError: + pass + try: + self.lock_path.unlink() + except OSError: + pass + + +# --------------------------------------------------------------------------- +# Core operations +# --------------------------------------------------------------------------- + + +def _by_url(sources: list[dict[str, Any]]) -> dict[str, dict[str, Any]]: + return {s["url"]: s for s in sources} + + +def add_sources( + path: Path, + urls: Iterable[str], + title: str | None = None, + accessed: str | None = None, +) -> list[dict[str, Any]]: + """Register urls, returning their ledger entries (existing or new).""" + urls = [u for u in (str(u).strip() for u in urls) if u] + if not urls: + return [] + with _LedgerLock(path): + data = load_ledger(path) + sources = data["sources"] + index = _by_url(sources) + out: list[dict[str, Any]] = [] + changed = False + for raw in urls: + key = normalize_url(raw) + existing = index.get(key) + if existing is not None: + if title and not existing.get("title"): + existing["title"] = title + changed = True + out.append(existing) + continue + entry = { + "id": len(sources) + 1, + "url": key, + "title": (title or "").strip(), + "accessed": accessed or time.strftime("%Y-%m-%d"), + } + sources.append(entry) + index[key] = entry + out.append(entry) + changed = True + if changed: + save_ledger(path, data) + return out + + +def urls_from_json(payload: Any) -> list[tuple[str, str]]: + """Walk arbitrary JSON tool output collecting (url, title) pairs. + + Handles web_search (``data.web[]``), web_extract (``results[]``) and any + other nesting, in document order, deduped. + """ + found: list[tuple[str, str]] = [] + seen: set[str] = set() + + def walk(node: Any) -> None: + if isinstance(node, dict): + url = node.get("url") or node.get("link") or node.get("source_url") + if isinstance(url, str) and url.startswith(("http://", "https://")): + key = normalize_url(url) + if key not in seen: + seen.add(key) + raw_title = node.get("title") or node.get("name") or "" + found.append((url, raw_title if isinstance(raw_title, str) else "")) + for value in node.values(): + walk(value) + elif isinstance(node, list): + for item in node: + walk(item) + + walk(payload) + return found + + +# --------------------------------------------------------------------------- +# Evidence quotes (fact-checking) +# --------------------------------------------------------------------------- + + +def _normalize_ws(text: str) -> str: + """Collapse all whitespace runs to single spaces for verbatim matching.""" + return " ".join((text or "").split()) + + +# Markdown artifacts that retrieval tools inject into otherwise-identical prose. +# ``web_extract`` returns markdown, so the most citation-worthy sentences are +# exactly the ones carrying inline links and emphasis around terms: +# "including _[ERAP1](https://…/erap1/)_, _[IL1A](…)_, have also been…" +# reads identically to the page a human sees. Matching has to see through that +# markup, or the skill pushes the agent toward weaker evidence fragments. +_MD_LINK_RE = re.compile(r"\[([^\]]*)\]\((?:[^()\s]|\([^()]*\))*\)") +_MD_NOISE_RE = re.compile(r"[*_`~]|\\(?=[^\w\s])") + + +def _match_key(text: str) -> str: + """Canonicalize text for verbatim comparison. + + Whitespace-, case-, and markdown-insensitive: inline links collapse to + their label, emphasis/code markers and backslash escapes are dropped. The + stored quote keeps whatever the caller passed, so the rendered evidence + block shows clean prose rather than extractor artifacts. + """ + collapsed = _MD_LINK_RE.sub(r"\1", text or "") + return _normalize_ws(_MD_NOISE_RE.sub("", collapsed)).casefold() + + +def quote_in_evidence(quote: str, evidence: str) -> bool: + """True when ``quote`` appears verbatim in the fetched ``evidence`` text, + ignoring whitespace, case, and markdown markup on either side.""" + q = _match_key(quote) + return bool(q) and q in _match_key(evidence) + + +def attach_quote(path: Path, source_id: int, quote: str, evidence: str) -> dict[str, Any]: + """Attach a verbatim quote to a ledger entry after checking it against + the evidence text. Raises SystemExit on unknown id or non-verbatim text — + a quote the page does not contain is exactly the fabrication this guards + against.""" + quote = (quote or "").strip() + if len(_normalize_ws(quote).split()) < 3: + raise SystemExit("error: quote too short — use at least 3 words of verbatim text") + if not quote_in_evidence(quote, evidence): + raise SystemExit( + "error: quote not found verbatim in the evidence text — " + "copy the exact wording from the fetched page, do not paraphrase" + ) + with _LedgerLock(path): + data = load_ledger(path) + entry = next((s for s in data["sources"] if s["id"] == source_id), None) + if entry is None: + raise SystemExit(f"error: no source [{source_id}] in the ledger") + quotes = entry.setdefault("quotes", []) + norm = _match_key(quote) + if not any(_match_key(q.get("text", "")) == norm for q in quotes): + quotes.append({"text": quote, "added": time.strftime("%Y-%m-%d")}) + save_ledger(path, data) + return entry + + +def render_sources( + sources: list[dict[str, Any]], + style: str = "markdown", + only: set[int] | None = None, +) -> str: + picked = [s for s in sources if only is None or s["id"] in only] + picked.sort(key=lambda s: s["id"]) + if not picked: + return "" + lines: list[str] = [] + if style == "bibtex": + for s in picked: + key = f"source{s['id']}" + title = s.get("title") or s["url"] + lines.append( + "@misc{{{},\n title = {{{}}},\n howpublished = {{\\url{{{}}}}},\n note = {{Accessed {}}}\n}}".format(key, title, s["url"], s.get("accessed", "")) + ) + return "\n".join(lines) + if style == "footnotes": + for s in picked: + title = s.get("title") + suffix = f" — {title}" if title else "" + lines.append(f"[^{s['id']}]: {s['url']}{suffix}") + return "\n".join(lines) + header = "Sources:" if style == "plain" else "## Sources" + lines.append(header) + if style != "plain": + lines.append("") + for s in picked: + title = s.get("title") + suffix = f" — {title}" if title else "" + lines.append(f"[{s['id']}] {s['url']}{suffix}") + if style == "evidence": + for q in s.get("quotes", []): + lines.append(f' > "{q.get("text", "")}"') + return "\n".join(lines) + + +# --------------------------------------------------------------------------- +# Verification +# --------------------------------------------------------------------------- + + +def _split_draft(text: str) -> tuple[str, dict[int, str]]: + """Split a draft into (prose, sources_block_map). + + The sources block is everything after the last ``Sources`` header; its + ``[n] url`` lines are parsed out so they aren't counted as prose citations. + Fenced code blocks are dropped from prose. + """ + lines = text.splitlines() + header_idx = -1 + for i, line in enumerate(lines): + if _SOURCES_HEADER_RE.match(line): + header_idx = i + listed: dict[int, str] = {} + if header_idx >= 0: + for line in lines[header_idx + 1:]: + m = _SOURCE_LINE_RE.match(line) + if m: + url_match = _URL_IN_TEXT_RE.search(line) + listed[int(m.group(1))] = url_match.group(0) if url_match else m.group(2) + body_lines = lines[:header_idx] + else: + body_lines = lines + prose: list[str] = [] + in_fence = False + for line in body_lines: + if _FENCE_RE.match(line): + in_fence = not in_fence + continue + if not in_fence: + prose.append(line) + return "\n".join(prose), listed + + +def _strip_sources_block(text: str) -> str: + """Return the draft with its trailing Sources block removed. + + Everything from the last Sources header onward goes; a draft with no such + header is returned unchanged. This is what makes ``render --replace-in`` + idempotent instead of stacking duplicate blocks. + """ + lines = text.splitlines() + header_idx = -1 + for i, line in enumerate(lines): + if _SOURCES_HEADER_RE.match(line): + header_idx = i + if header_idx < 0: + return text + return "\n".join(lines[:header_idx]) + + +def _sentences(prose: str) -> list[str]: + """Rough sentence split over prose lines, skipping headings and tables.""" + out: list[str] = [] + for line in prose.splitlines(): + stripped = line.strip() + if not stripped or stripped.startswith("#") or stripped.startswith("|"): + continue + if stripped.startswith(">"): + stripped = stripped.lstrip("> ").strip() + for part in re.split(r"(?<=[.!?])\s+", stripped): + part = part.strip() + if len(part.split()) >= 4: + out.append(part) + return out + + +def verify_draft( + draft_path: Path, + sources: list[dict[str, Any]], + strict: bool = False, + min_coverage: float | None = None, + require_evidence: bool = False, +) -> tuple[int, list[str], list[str]]: + """Return (exit_code, errors, warnings).""" + text = draft_path.read_text(encoding="utf-8") + prose, listed = _split_draft(text) + by_id = {s["id"]: s for s in sources} + + errors: list[str] = [] + warnings: list[str] = [] + + cited = [int(m) for m in _CITE_RE.findall(prose)] + cited_set = set(cited) + + unknown = sorted(i for i in cited_set if i not in by_id) + if unknown: + errors.append( + "citations not in the ledger (hallucinated or renumbered): " + + ", ".join(f"[{i}]" for i in unknown) + ) + + if cited_set and not listed: + errors.append("draft cites sources but has no `Sources:` block — run `render --cited-in`") + + missing_from_block = sorted(cited_set - set(listed)) if listed else [] + if missing_from_block: + errors.append( + "cited but absent from the Sources block: " + + ", ".join(f"[{i}]" for i in missing_from_block) + ) + + for sid, url in sorted(listed.items()): + entry = by_id.get(sid) + if entry is None: + errors.append(f"Sources block lists [{sid}], which is not in the ledger") + continue + if normalize_url(url) != entry["url"]: + errors.append( + f"Sources block URL for [{sid}] does not match the ledger " + f"(block: {url} / ledger: {entry['url']}) — re-run `render`" + ) + + extra_in_block = sorted(set(listed) - cited_set) + if extra_in_block: + warnings.append( + "listed in Sources but never cited inline: " + + ", ".join(f"[{i}]" for i in extra_in_block) + ) + + registered_uncited = sorted(set(by_id) - cited_set) + if registered_uncited: + warnings.append( + "registered in the ledger but not cited in this draft: " + + ", ".join(f"[{i}]" for i in registered_uncited) + ) + + sentences = _sentences(prose) + cited_sentences = [s for s in sentences if _CITE_RE.search(s)] + unverified_sentences = [s for s in sentences if _UNVERIFIED_RE.search(s)] + covered = [s for s in sentences if _CITE_RE.search(s) or _UNVERIFIED_RE.search(s)] + coverage = (len(covered) / len(sentences)) if sentences else 0.0 + if min_coverage is not None and sentences and coverage < min_coverage: + errors.append( + f"citation coverage {coverage:.0%} is below the required {min_coverage:.0%} " + f"({len(covered)}/{len(sentences)} sentences cited or marked [unverified])" + ) + + if require_evidence: + unevidenced = sorted( + i for i in cited_set if i in by_id and not by_id[i].get("quotes") + ) + if unevidenced: + errors.append( + "cited sources carry no verbatim evidence quote (run `quote` with the " + "fetched page text): " + ", ".join(f"[{i}]" for i in unevidenced) + ) + + over_cited = [s for s in sentences if len(_CITE_RE.findall(s)) > 3] + if over_cited: + warnings.append(f"{len(over_cited)} sentence(s) carry more than 3 citations") + + code = 1 if errors else (1 if (strict and warnings) else 0) + quoted = sum(1 for s in sources if s.get("quotes")) + stats = ( + f"{len(sentences)} prose sentence(s), {len(covered)} with declared provenance " + f"({coverage:.0%}) — {len(cited_sentences)} cited, " + f"{len(unverified_sentences)} marked [unverified] (a sentence may be both); " + f"{len(cited_set)} distinct source(s) cited, " + f"{len(by_id)} in ledger ({quoted} with evidence quotes)" + ) + warnings.insert(0, f"stats: {stats}") + return code, errors, warnings + + +# --------------------------------------------------------------------------- +# CLI +# --------------------------------------------------------------------------- + + +def _parse_only(spec: str | None) -> set[int] | None: + if not spec: + return None + out: set[int] = set() + for chunk in spec.replace(" ", "").split(","): + if not chunk: + continue + if "-" in chunk: + lo, _, hi = chunk.partition("-") + out.update(range(int(lo), int(hi) + 1)) + else: + out.add(int(chunk)) + return out + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser( + prog="sources.py", description="Citation ledger for grounded answers and documents." + ) + parser.add_argument("--ledger", help="ledger file path (overrides env / default)") + sub = parser.add_subparsers(dest="cmd", required=True) + + sub.add_parser("reset", help="start a clean ledger") + + p_add = sub.add_parser("add", help="register source url(s), print their ids") + p_add.add_argument("urls", nargs="+") + p_add.add_argument("--title", help="title for the source (single-url calls)") + p_add.add_argument("--accessed", help="access date (default: today)") + p_add.add_argument("--json", action="store_true", help="emit JSON instead of ids") + + p_ing = sub.add_parser("ingest", help="register every url in JSON tool output") + p_ing.add_argument("file", help="JSON file, or - for stdin") + + p_q = sub.add_parser("quote", help="attach verbatim supporting evidence to a source") + p_q.add_argument("id", type=int, help="ledger id of the source the quote supports") + p_q.add_argument("--text", required=True, help="the exact quote, copied from the page") + p_q.add_argument( + "--from", + dest="evidence", + required=True, + help="file with the fetched page text (or - for stdin) the quote must appear in", + ) + + p_list = sub.add_parser("list", help="show the ledger") + p_list.add_argument("--json", action="store_true") + + p_render = sub.add_parser("render", help="render a Sources block") + p_render.add_argument( + "--style", default="markdown", choices=["markdown", "plain", "footnotes", "bibtex", "evidence"] + ) + p_render.add_argument("--only", help="ids to include, e.g. 1,3,5-7") + p_render.add_argument("--cited-in", help="include only ids cited in this draft file") + p_render.add_argument( + "--replace-in", + help="rewrite this draft's Sources block in place (implies --cited-in on it)", + ) + + p_ver = sub.add_parser("verify", help="check a draft's citations against the ledger") + p_ver.add_argument("draft") + p_ver.add_argument("--strict", action="store_true", help="treat warnings as failures") + p_ver.add_argument("--min-coverage", type=float, help="required cited-sentence share, e.g. 0.5") + p_ver.add_argument( + "--evidence", + action="store_true", + help="require every cited source to carry at least one verbatim quote", + ) + + args = parser.parse_args(argv) + path = resolve_ledger_path(args.ledger) + + if args.cmd == "reset": + with _LedgerLock(path): + save_ledger(path, {"version": SCHEMA_VERSION, "sources": []}) + print(f"ledger reset: {path}") + return 0 + + if args.cmd == "add": + title = args.title if len(args.urls) == 1 else None + entries = add_sources(path, args.urls, title=title, accessed=args.accessed) + if args.json: + print(json.dumps(entries, indent=2, ensure_ascii=False)) + else: + for e in entries: + print(f"[{e['id']}] {e['url']}") + return 0 + + if args.cmd == "ingest": + raw = sys.stdin.read() if args.file == "-" else Path(args.file).read_text(encoding="utf-8") + try: + payload = json.loads(raw) + except json.JSONDecodeError as exc: + print(f"error: input is not valid JSON ({exc})", file=sys.stderr) + return 2 + pairs = urls_from_json(payload) + if not pairs: + print("no urls found in input", file=sys.stderr) + return 1 + for url, title in pairs: + entry = add_sources(path, [url], title=title or None)[0] + print(f"[{entry['id']}] {entry['url']}") + return 0 + + if args.cmd == "quote": + raw = ( + sys.stdin.read() + if args.evidence == "-" + else Path(args.evidence).read_text(encoding="utf-8") + ) + entry = attach_quote(path, args.id, args.text, raw) + print(f"[{entry['id']}] evidence attached ({len(entry.get('quotes', []))} quote(s))") + return 0 + + data = load_ledger(path) + sources = sorted(data["sources"], key=lambda s: s["id"]) + + if args.cmd == "list": + if args.json: + print(json.dumps(sources, indent=2, ensure_ascii=False)) + elif not sources: + print(f"ledger is empty: {path}") + else: + for s in sources: + title = f" {s['title']}" if s.get("title") else "" + nq = len(s.get("quotes", [])) + mark = f" ({nq} quote{'s' if nq != 1 else ''})" if nq else "" + print(f"[{s['id']}] {s['url']}{title}{mark}") + return 0 + + if args.cmd == "render": + only = _parse_only(args.only) + draft_for_ids = args.replace_in or args.cited_in + if draft_for_ids: + draft = Path(draft_for_ids).read_text(encoding="utf-8") + prose, _ = _split_draft(draft) + cited = {int(m) for m in _CITE_RE.findall(prose)} + only = cited if only is None else (only & cited) + block = render_sources(sources, style=args.style, only=only) + if not block: + print("no sources to render", file=sys.stderr) + return 1 + if args.replace_in: + target = Path(args.replace_in) + body = _strip_sources_block(target.read_text(encoding="utf-8")) + target.write_text(body.rstrip("\n") + "\n\n" + block + "\n", encoding="utf-8") + print(f"Sources block rewritten in {target}") + return 0 + print(block) + return 0 + + if args.cmd == "verify": + draft_path = Path(args.draft) + if not draft_path.is_file(): + print(f"error: no such draft: {draft_path}", file=sys.stderr) + return 2 + code, errors, warnings = verify_draft( + draft_path, + sources, + strict=args.strict, + min_coverage=args.min_coverage, + require_evidence=args.evidence, + ) + for w in warnings: + prefix = "info" if w.startswith("stats: ") else "warn" + print(f"{prefix}: {w}") + for e in errors: + print(f"FAIL: {e}", file=sys.stderr) + print("citations OK" if code == 0 else "verification failed") + return code + + return 2 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/figures/make_figures.py b/tools/figures/make_figures.py new file mode 100644 index 00000000..32cf7a53 --- /dev/null +++ b/tools/figures/make_figures.py @@ -0,0 +1,834 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Draw the README figures (docs/img/*.svg) from this repository's own data. + +Run from the repository root: python3 tools/figures/make_figures.py +Check they are current: python3 tools/figures/make_figures.py --check + +Nothing here is drawn by an image generator. The machine-code figures read the +instruction words straight out of src/omega_blackwell_encoder.c and decode them +with the field positions my encoder uses (src/omega_blackwell_codegen.c, +"Control words"). The numbers on the other figures are the receipts named on +each figure. Colours are the aienos.com "Turing look" tokens. +""" +import os +import re +import sys +from html import escape + +ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) +OUT = os.path.join(ROOT, "docs", "img") + +# ---- Turing look tokens (aienos.com public/assets/turing-look.css) ---------------- +BG, CARD, CARD2 = "#08090c", "#0e1219", "#131822" +LINE, LINE2 = "#1c2536", "#2a3648" +INK, INK2, INK3 = "#f1f5f9", "#94a3b8", "#64748b" +BLUE, BLUE_SOFT, GREEN = "#2d7ff9", "#7db4ff", "#00e599" +AMBER, VIOLET, ROSE, CYAN = "#f59e0b", "#a78bfa", "#fb7185", "#22d3ee" + +SANS = "Inter, ui-sans-serif, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif" +MONO = "ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace" + + +# ---- tiny SVG writer --------------------------------------------------------------- +class Svg: + def __init__(self, w, h, title, desc): + self.w, self.h = w, h + self.parts = [] + self.title, self.desc = title, desc + + def add(self, s): + self.parts.append(s) + + def rect(self, x, y, w, h, fill="none", stroke="none", rx=0.0, sw=1.0, op=1.0, dash=None, extra=""): + d = f' stroke-dasharray="{dash}"' if dash else "" + o = f' opacity="{op}"' if op != 1 else "" + self.add(f'') + + def text(self, x, y, s, size=16.0, fill=INK, weight=400, anchor="start", mono=False, op=1.0, ls=None, italic=False, strike=False): + fam = MONO if mono else SANS + size = max(size, 12.5) # README width scales figures to about 0.73: keep the smallest text readable + o = f' opacity="{op}"' if op != 1 else "" + l = f' letter-spacing="{ls}"' if ls is not None else "" + it = ' font-style="italic"' if italic else "" + it += ' text-decoration="line-through"' if strike else "" + self.add(f'{escape(s)}') + + def lines(self, x, y, rows, size=15.0, fill=INK2, gap=None, **kw): + gap = gap or size * 1.4 + for i, r in enumerate(rows): + self.text(x, y + i * gap, r, size=size, fill=fill, **kw) + + def line(self, x1, y1, x2, y2, stroke=LINE2, sw=1.5, dash=None, arrow=False, op=1.0): + d = f' stroke-dasharray="{dash}"' if dash else "" + a = ' marker-end="url(#arrow)"' if arrow else "" + o = f' opacity="{op}"' if op != 1 else "" + self.add(f'') + + def path(self, d, stroke=LINE2, sw=1.5, fill="none", arrow=False, dash=None, op=1.0): + a = ' marker-end="url(#arrow)"' if arrow else "" + ds = f' stroke-dasharray="{dash}"' if dash else "" + o = f' opacity="{op}"' if op != 1 else "" + self.add(f'') + + def circle(self, x, y, r, fill=INK, stroke="none", sw=1.0): + self.add(f'') + + def pill(self, x, y, label, color, size=13.0, h=24.0, filled=False, w=None): + w = w or (len(label) * size * 0.62 + 22) + if filled: + self.rect(x, y, w, h, fill=color, rx=h / 2, op=0.16) + self.rect(x, y, w, h, stroke=color, rx=h / 2, sw=1, op=0.7) + else: + self.rect(x, y, w, h, stroke=color, rx=h / 2, sw=1.2) + self.text(x + w / 2, y + h / 2 + size * 0.36, label, size=size, fill=color, weight=600, anchor="middle", + mono=True) + return w + + def kicker(self, x, y, s, color=BLUE_SOFT): + self.text(x, y, s.upper(), size=14, fill=color, weight=600, mono=True, ls=1.5) + + def frame(self): + self.rect(0.5, 0.5, self.w - 1, self.h - 1, fill=BG, stroke=LINE, rx=22) + self.rect(0.5, 0.5, self.w - 1, self.h - 1, fill="url(#glow)", rx=22) + + def svg(self): + head = (f'' + f'{escape(self.title)}{escape(self.desc)}' + '' + '' + f'' + f'' + f'' + '' + f'' + f'' + '' + '') + return head + "".join(self.parts) + "\n" + + +def card(s, x, y, w, h, accent=None, fill=CARD, rx=16.0, sw=1.0, dash=None): + s.rect(x, y, w, h, fill=fill, stroke=accent or LINE2, rx=rx, sw=sw, dash=dash) + + +# ---- the first kernel's words, read from the encoder source ------------------------ +def vecadd_words(): + src = open(os.path.join(ROOT, "src", "omega_blackwell_encoder.c")).read() + rows = re.findall(r'/\* ([0-9a-f]{4}) \*/ \{ \{ (0x[0-9a-f]+), (0x[0-9a-f]+), (0x[0-9a-f]+), (0x[0-9a-f]+) \}, ' + r'"([^"]+)" \}', src) + if len(rows) != 32: + sys.exit(f"expected 32 vecadd instructions in src/omega_blackwell_encoder.c, found {len(rows)}") + out = [] + for addr, w0, w1, w2, w3, mn in rows: + w = [int(v, 16) for v in (w0, w1, w2, w3)] + bits = w[0] | (w[1] << 32) | (w[2] << 64) | (w[3] << 96) + out.append({"addr": addr, "w": w, "bits": bits, "mn": mn, **decode_control(w[3])}) + return out + + +def decode_control(w3): + # src/omega_blackwell_codegen.c, "Control words": stall = bits 9..12 of w[3], yield = 13, + # write barrier = 14..16, read barrier = 17..19, wait mask = 20..25; 7 in a barrier field means none. + return {"stall": (w3 >> 9) & 0xF, "yield": (w3 >> 13) & 1, "wbar": (w3 >> 14) & 7, + "rbar": (w3 >> 17) & 7, "wait": [i for i in range(6) if (w3 >> (20 + i)) & 1], + "reuse": (w3 >> 26) & 0xF} + + +# Bit fields as drawn (bit 0 = lowest bit of word 0). +FIELDS = [ # (lo, hi, name, colour) + (0, 11, "opcode and operand form", BLUE), + (12, 15, "guard predicate", VIOLET), + (16, 31, "destination and first source register", GREEN), + (32, 63, "second source: register, immediate or constant address", CYAN), + (64, 104, "third source, predicate operands, modifiers", INK2), + (105, 127, "scheduling: stall, yield, scoreboards, reuse", AMBER), +] + + +def field_colour(b): + for lo, hi, _, c in FIELDS: + if lo <= b <= hi: + return c + return INK2 + + +def short_mn(mn): + pred = "" + if mn.startswith("@"): + pred, mn = mn.split(" ", 1) + pred += " " + return pred + mn.split(" ")[0] + + +# ---- figure 1: hero ------------------------------------------------------------------ +def fig_hero(words): + s = Svg(1280, 680, "CUDA++: my own path from a program to an NVIDIA GPU", + "Title, three measured facts, and the 32 instructions of the first kernel CUDA++ ran, drawn bit by bit " + "from src/omega_blackwell_encoder.c.") + s.frame() + s.rect(0.5, 0.5, s.w - 1, s.h - 1, fill="url(#glow2)", rx=22) + s.kicker(64, 92, "aien-dev / CUDApp · MIT · NVIDIA GB10 (sm_121)") + s.text(58, 196, "CUDA++", size=104, weight=800, ls=-3) + s.lines(64, 250, ["My own path from a program to an NVIDIA GPU:", + "machine code, runtime, libraries and driver client.", + "No CUDA toolkit, no nvcc, no PTX, no libcuda."], size=22, fill=INK2, gap=32) + facts = [("0", GREEN, "CUDA libraries loaded in the live", "35B model server (2026-10-21)"), + ("115.14", GREEN, "TFLOPS tensor-core peak, measured", "by my own probe kernel"), + ("59", GREEN, "instruction kinds my encoder", "writes for sm_121")] + for i, (num, col, l1, l2) in enumerate(facts): + y = 372 + i * 80 + card(s, 64, y, 500, 66, fill=CARD) + s.rect(64, y, 4, 66, fill=col, rx=2) + s.text(88, y + 44, num, size=34, weight=800, fill=col, ls=-1) + s.lines(232, y + 28, [l1, l2], size=16, fill=INK2, gap=21) + + x0, y0, cw, rh = 620, 168, 3.4, 13.5 + s.kicker(x0, 92, "the first kernel: vector add", INK2) + s.text(x0, 116, "32 instructions × 128 bits, every bit written by my encoder", size=15, fill=INK3) + for i, (lo, hi, name, col) in enumerate(FIELDS): + label = {BLUE: "opcode", VIOLET: "predicate", GREEN: "registers", CYAN: "operand", + INK2: "modifiers", AMBER: "scheduling"}[col] + lx = x0 + i * 100 + s.rect(lx, 133, 10, 10, fill=col, rx=2) + s.text(lx + 15, 142, label, size=13, fill=INK2) + for r, ins in enumerate(words): + y = y0 + r * rh + nop = ins["mn"] == "NOP" + for lo, hi, _, col in FIELDS: + s.rect(x0 + lo * cw, y, (hi - lo + 1) * cw - 0.8, rh - 3, fill=col, op=0.07 if not nop else 0.04) + for b in range(128): + if (ins["bits"] >> b) & 1: + s.rect(x0 + b * cw, y, cw - 0.8, rh - 3, fill=field_colour(b), op=0.95 if not nop else 0.35) + s.text(x0 + 128 * cw + 14, y + rh - 4.5, ins["addr"], size=11.5, fill=INK3, mono=True) + s.text(x0 + 128 * cw + 52, y + rh - 4.5, short_mn(ins["mn"]), size=11.5, fill=INK2 if not nop else INK3, + mono=True, op=1 if not nop else 0.6) + for b in (0, 32, 64, 96, 127): + s.line(x0 + b * cw + cw / 2, y0 + 32 * rh - 1, x0 + b * cw + cw / 2, y0 + 32 * rh + 4, stroke=INK3, sw=1) + s.text(x0 + b * cw + cw / 2, y0 + 32 * rh + 17, str(b), size=11, fill=INK3, anchor="middle", mono=True) + s.text(x0, y0 + 32 * rh + 40, "bit 0 to bit 127 of each instruction · lit = 1 · src/omega_blackwell_encoder.c", + size=13, fill=INK2, mono=True) + return s + + +# ---- figure 2: the two stacks ---------------------------------------------------------- +def fig_stack(): + s = Svg(1200, 930, "CUDA and CUDA++, layer by layer", + "Left: the NVIDIA CUDA stack. Right: CUDA++. The four closed layers above the kernel module are " + "replaced by my own code; the open kernel module and the signed GPU firmware are still NVIDIA's.") + s.frame() + s.kicker(48, 60, "the stack") + s.text(48, 100, "What runs between your program and the GPU", size=30, weight=800, ls=-0.5) + lx, rx, cw, mid = 48, 664, 488, 600 + s.text(lx, 150, "CUDA", size=22, weight=700, fill=INK2) + s.text(rx, 150, "CUDA++", size=22, weight=700, fill=GREEN) + rows = [ + ("program", ("Your program", "CUDA C++ kernels and host code"), + ("Your program", "C calls to the kernel builder; Omega's languages next (bar C1)")), + ("closed", ("nvcc · NVVM · PTX · ptxas", "compiler, closed"), + ("Kernel builder · allocator · sm_121 encoder", "src/omega_blackwell_codegen*.c, _encoder.c, _qmd.c")), + ("closed", ("cuBLAS · cuDNN · CUB", "maths libraries, closed"), + ("Matmul · attention · MoE · reductions", "src/omega_gpu_*_api.c")), + ("closed", ("libcudart", "runtime API, closed"), + ("Session · command lists · job engine", "src/omega_gpu_session.c, _cmdlist.c, _engine.c")), + ("closed", ("libcuda", "driver API, closed"), + ("Driver client: nvrm + m16", "nvrm/nvrm.c, m16/: ioctls from the open headers")), + ("open", ("nvidia.ko · nvidia-uvm.ko", "NVIDIA's open kernel module"), + ("nvidia.ko · nvidia-uvm.ko, for now", "AIEN's own GB10 driver is being built (L332)")), + ("fw", ("GSP firmware", "runs inside the GPU, signed by NVIDIA"), + ("GSP firmware", "stays NVIDIA's: the chip checks its signature")), + ("hw", ("NVIDIA GB10 GPU", "DGX Spark, sm_121"), ("NVIDIA GB10 GPU", "DGX Spark, sm_121")), + ] + marks = {"closed": ("replaced", GREEN), "open": ("next", VIOLET), "fw": ("stays", AMBER)} + y, rh, gap = 172, 72, 14 + for i, (kind, left, right) in enumerate(rows): + if i == 5: + y += 30 + s.line(36, y - 22, s.w - 36, y - 22, stroke=INK3, sw=1, dash="6 6") + w = 196 + s.rect(mid - w / 2, y - 33, w, 22, fill=BG) + s.text(mid, y - 17, "user space ↑ kernel ↓", size=13, fill=INK2, anchor="middle", mono=True) + # left + if kind == "closed": + card(s, lx, y, cw, rh, accent=LINE2, fill=CARD) + s.text(lx + 22, y + 32, left[0], size=19, weight=650, fill=INK3, strike=True) + s.text(lx + 22, y + 56, left[1], size=14, fill=INK3) + else: + acc = {"program": LINE2, "open": BLUE, "fw": AMBER, "hw": LINE2}[kind] + card(s, lx, y, cw, rh, accent=acc, fill=CARD) + s.text(lx + 22, y + 32, left[0], size=19, weight=650) + s.text(lx + 22, y + 56, left[1], size=14, fill=INK2) + # right + acc = {"program": LINE2, "closed": GREEN, "open": BLUE, "fw": AMBER, "hw": LINE2}[kind] + fill = "#0b1a17" if kind == "closed" else CARD + card(s, rx, y, cw, rh, accent=acc, fill=fill, sw=1.4 if kind == "closed" else 1) + s.text(rx + 22, y + 32, right[0], size=19, weight=650, fill=INK) + s.text(rx + 22, y + 56, right[1], size=14 if kind != "closed" else 13.5, fill=INK2, + mono=(kind in ("closed",))) + if kind in marks: + lab, col = marks[kind] + w = len(lab) * 8.6 + 18 + s.line(lx + cw + 4, y + rh / 2, mid - w / 2, y + rh / 2, stroke=col, sw=1.6, op=0.8) + s.line(mid + w / 2, y + rh / 2, rx - 10, y + rh / 2, stroke=col, sw=1.6, arrow=True, op=0.8) + s.rect(mid - w / 2, y + rh / 2 - 12, w, 24, fill=BG, rx=12) + s.pill(mid - w / 2, y + rh / 2 - 12, lab, col, size=13, w=w, filled=True) + y += rh + gap + ly = y + 16 + for lab, col, x in (("closed, replaced by CUDA++", INK3, 48), ("mine, MIT", GREEN, 300), + ("NVIDIA open source, replaced next", BLUE, 440), ("NVIDIA signed firmware, stays", AMBER, 740)): + s.rect(x, ly - 11, 14, 14, stroke=col, fill="#0b1a17" if col == GREEN else CARD, rx=3, sw=1.5) + s.text(x + 22, ly + 1, lab, size=14, fill=INK2) + return s + + +# ---- figure 3: one instruction, every bit --------------------------------------------- +def fig_instruction(words): + ins = next(w for w in words if w["mn"].startswith("IADD3")) + s = Svg(1200, 800, "One instruction, all 128 bits: IADD3 R9, PT, PT, R2, R5, RZ", + "The add of vector add, decoded field by field, with its scheduling bits enlarged.") + s.frame() + s.kicker(48, 60, "one instruction, all 128 bits") + s.text(48, 102, "IADD3 R9, PT, PT, R2, R5, RZ", size=32, weight=800, mono=True, ls=-0.5) + s.text(48, 134, f"R9 = R2 + R5: the add in vector add, at offset 0x{ins['addr']}. " + "Sixteen bytes, four 32-bit words.", size=17, fill=INK2) + x0, y0, cw, ch, wg = 56, 196, 8.2, 38, 10 + + def bx(b): + return x0 + b * cw + (b // 32) * wg + + for k in range(4): + s.text(bx(32 * k), y0 - 12, f"word {k} 0x{ins['w'][k]:08x}", size=14, fill=INK2, mono=True) + for b in range(128): + on = (ins["bits"] >> b) & 1 + col = field_colour(b) + s.rect(bx(b), y0, cw - 1.2, ch, fill=col, op=0.95 if on else 0.12, rx=1.5) + for b in (0, 31, 32, 63, 64, 95, 96, 127): + s.text(bx(b) + cw / 2, y0 + ch + 16, str(b), size=11.5, fill=INK3, anchor="middle", mono=True) + + def bracket(lo, hi, row, title, value, col): + x1, x2 = bx(lo) + 1.5, bx(hi) + cw - 2.7 + yb = y0 + ch + 30 + row * 60 + s.path(f"M{x1:.1f} {yb - 6} L{x1:.1f} {yb} L{x2:.1f} {yb} L{x2:.1f} {yb - 6}", stroke=col, sw=1.6) + s.line((x1 + x2) / 2, yb, (x1 + x2) / 2, yb + 8, stroke=col, sw=1.6) + s.text(x1, yb + 26, value, size=16, weight=700, fill=col, mono=True) + s.text(x1, yb + 45, title, size=13, fill=INK2) + + rd, ra = (ins["w"][0] >> 16) & 0xFF, (ins["w"][0] >> 24) & 0xFF + rb, rc = ins["w"][1] & 0xFF, ins["w"][2] & 0xFF + g = (ins["w"][0] >> 12) & 7 + reg = lambda r: "RZ" if r == 255 else f"R{r}" + bracket(0, 11, 0, "opcode + operand form", f"0x{ins['w'][0] & 0xfff:03x} IADD3", BLUE) + bracket(12, 15, 1, "guard predicate", "@PT" if g == 7 else f"@P{g}", VIOLET) + bracket(16, 23, 2, "destination", reg(rd), GREEN) + bracket(24, 31, 0, "source A", reg(ra), GREEN) + bracket(32, 39, 1, "source B", reg(rb), CYAN) + bracket(64, 71, 0, "source C", reg(rc), INK2) + bracket(72, 104, 1, "carry predicates, modifiers", "PT, PT", INK2) + bracket(105, 127, 0, "scheduling (enlarged below)", "control", AMBER) + + # enlarged control bits + zy, zx, zw = 530, 70, 44 + card(s, 40, zy - 40, 1120, 240, fill=CARD) + s.text(60, zy - 12, "bits 105 to 127: how the warp scheduler treats this instruction", size=16, weight=700, + fill=AMBER) + for i, b in enumerate(range(105, 128)): + on = (ins["bits"] >> b) & 1 + s.rect(zx + i * zw, zy + 8, zw - 4, 40, fill=AMBER, op=0.9 if on else 0.12, rx=4) + s.text(zx + i * zw + (zw - 4) / 2, zy + 35, str(on), size=17, weight=700, fill=BG if on else INK2, + anchor="middle", mono=True) + s.text(zx + i * zw + (zw - 4) / 2, zy + 64, str(b), size=11, fill=INK3, anchor="middle", mono=True) + c = ins + sub = [(105, 108, "stall", f"{c['stall']} cycles"), (109, 109, "yield", str(c["yield"])), + (110, 112, "sets SB", "none" if c["wbar"] == 7 else f"SB{c['wbar']}"), + (113, 115, "read SB", "none" if c["rbar"] == 7 else f"SB{c['rbar']}"), + (116, 121, "waits on", ", ".join(f"SB{i}" for i in c["wait"]) or "none"), + (122, 125, "reuse", str(c["reuse"])), (126, 127, "unused", "0")] + for lo, hi, name, val in sub: + x1 = zx + (lo - 105) * zw + x2 = zx + (hi - 105) * zw + zw - 4 + yb = zy + 76 + s.path(f"M{x1} {yb} L{x1} {yb + 6} L{x2} {yb + 6} L{x2} {yb}", stroke=AMBER, sw=1.4) + s.text(x1, yb + 30, val, size=15, weight=700, fill=INK, mono=True) + s.text(x1, yb + 49, name, size=13, fill=INK2) + s.text(60, zy + 180, "SB4 is the scoreboard both loads (LDG.E R2 and LDG.E R5) set: the add waits until both " + "values have arrived from memory.", size=14, fill=INK2) + s.text(48, s.h - 24, "Field positions: src/omega_blackwell_codegen.c (\"Control words\"), learned from nvcc output " + "on my own probe kernels and Mesa NAK, believed only after the GB10 ran them.", + size=13, fill=INK3) + return s + + +# ---- figure 4: scoreboards in vector add ------------------------------------------------- +def fig_listing(words): + body = words[:21] + rh, top = 30, 196 + s = Svg(1200, top + len(body) * rh + 90, "Vector add, instruction by instruction, with its scoreboards", + "The 21 real instructions of the first kernel. Lines on the left join an instruction that sets a " + "scoreboard to the later instruction that waits on it; amber bars are fixed stall cycles.") + s.frame() + s.kicker(48, 60, "the first kernel, decoded") + s.text(48, 100, "How vector add waits for its data", size=30, weight=800, ls=-0.5) + s.lines(48, 132, ["Slow instructions (constant loads, special registers, memory loads) set one of six scoreboards. " + "A later instruction", + "that needs the result waits on it. Fast instructions stall a fixed number of cycles instead. " + "My encoder writes these bits."], size=15, fill=INK2, gap=21) + sbcol = [CYAN, VIOLET, GREEN, ROSE, AMBER, BLUE] + lane = lambda k: 228 - k * 34 + hy = top - 14 + for lab, x in (("offset", 270), ("instruction", 336), ("stall", 760), ("sets", 940), ("waits on", 1040)): + s.text(x, hy, lab.upper(), size=12, fill=INK3, mono=True, ls=1) + for k in range(5): + s.text(lane(k), hy, f"SB{k}", size=12, fill=sbcol[k], anchor="middle", mono=True, weight=700) + ry = lambda r: top + r * rh + rh / 2 + for r, ins in enumerate(body): + if r % 2 == 0: + s.rect(250, top + r * rh, 920, rh, fill=CARD, rx=6) + y = ry(r) + 5 + s.text(270, y, ins["addr"], size=14, fill=INK3, mono=True) + s.text(336, y, ins["mn"], size=14.5, fill=INK, mono=True) + if ins["stall"]: + s.rect(760, ry(r) - 6, ins["stall"] * 11, 12, fill=AMBER, rx=3, op=0.85) + s.text(760 + ins["stall"] * 11 + 8, y, str(ins["stall"]), size=12, fill=INK3, mono=True) + if ins["wbar"] != 7: + s.pill(940, ry(r) - 11, f"SB{ins['wbar']}", sbcol[ins["wbar"]], size=12, h=22, filled=True, w=52) + for j, k in enumerate(ins["wait"]): + s.pill(1040 + j * 60, ry(r) - 11, f"SB{k}", sbcol[k], size=12, h=22, w=52) + # lanes: every wait joins the setters of that scoreboard since its previous wait + pending = {k: [] for k in range(6)} + for r, ins in enumerate(body): + for k in ins["wait"]: + setters = pending[k] + if setters: + x = lane(k) + s.line(x, ry(setters[0]), x, ry(r), stroke=BG, sw=7) + s.line(x, ry(setters[0]), x, ry(r), stroke=sbcol[k], sw=2.4) + for sr in setters: + s.line(x, ry(sr), 246, ry(sr), stroke=BG, sw=6) + s.line(x, ry(sr), 246, ry(sr), stroke=sbcol[k], sw=1.4, op=0.7, dash="3 4") + s.circle(x, ry(sr), 5, fill=sbcol[k], stroke=BG, sw=2) + s.line(x, ry(r), 252, ry(r), stroke=BG, sw=6) + s.line(x, ry(r), 252, ry(r), stroke=sbcol[k], sw=1.8, arrow=True) + pending[k] = [] + if ins["wbar"] != 7: + pending[ins["wbar"]].append(r) + s.text(48, s.h - 30, "Instruction words: src/omega_blackwell_encoder.c. Decoded by tools/figures/make_figures.py with the " + "encoder's own field positions.", size=13, fill=INK3) + return s + + +# ---- figure 5: how the machine code was learned --------------------------------------------- +def fig_reverse(): + s = Svg(1200, 760, "How I learned the GB10's machine code", + "Three sources and one rule: NVIDIA's compiler output on my own probe kernels, Mesa's open NAK " + "compiler, and the chip itself. Nothing is believed until the GPU runs it and gives the right answer.") + s.frame() + s.kicker(48, 60, "the reverse engineering") + s.text(48, 100, "How I learned the GB10's machine code", size=30, weight=800, ls=-0.5) + s.text(48, 132, "NVIDIA publishes no instruction encoding for its GPUs. I worked it out, and checked every " + "answer on the chip.", size=16, fill=INK2) + + def box(x, y, w, h, n, title, sub, col): + card(s, x, y, w, h, accent=col, fill=CARD) + s.text(x + 18, y + 30, n, size=13, fill=col, mono=True, weight=700) + s.text(x + 18, y + 56, title, size=17, weight=700) + s.lines(x + 18, y + 80, sub, size=13.5, fill=INK2, gap=19) + + s.text(48, 180, "LEARN", size=13, fill=INK3, mono=True, ls=2, weight=700) + W, H, y1 = 258, 150, 194 + xs = [48, 334, 620, 906] + box(xs[0], y1, W, H, "01", "My own probe kernel", ["a few lines of CUDA C++ I", "wrote, e.g. one add"], BLUE_SOFT) + box(xs[1], y1, W, H, "02", "nvcc, once, offline", ["nvcc 13.0.88 -arch=sm_121", "-cubin. Never run by", "CUDA++ itself."], INK2) + box(xs[2], y1, W, H, "03", "Read the bytes back", ["cuobjdump -sass: 16 bytes", "next to each mnemonic"], INK2) + box(xs[3], y1, W, H, "04", "Change one detail", ["a register, an immediate, a", "predicate, a modifier; diff", "the bits that moved"], BLUE_SOFT) + for a, b in zip(xs, xs[1:]): + s.line(a + W + 4, y1 + H / 2, b - 6, y1 + H / 2, stroke=INK2, sw=1.6, arrow=True) + + s.text(48, 404, "PROVE", size=13, fill=INK3, mono=True, ls=2, weight=700) + y2 = 418 + box(48, y2, 258, 150, "05", "Field hypothesis", ["bits 16..23 are the", "destination register,", "and so on"], GREEN) + box(334, y2, 258, 150, "06", "My encoder writes it", ["src/omega_blackwell_", "encoder.c, codegen*.c"], GREEN) + box(620, y2, 258, 150, "07", "The GB10 runs it", ["a real launch on the chip,", "answers checked on the CPU"], GREEN) + box(906, y2, 258, 150, "08", "Golden words", ["kept in the tests; nvdisasm", "cross-check when installed"], GREEN) + s.path(f"M{xs[3] + W / 2} {y1 + H + 4} C {xs[3] + W / 2} 392, 177 380, 177 {y2 - 8}", stroke=INK2, sw=1.6, + arrow=True) + s.line(306 + 4, y2 + 75, 334 - 6, y2 + 75, stroke=INK2, sw=1.6, arrow=True) + s.line(592 + 4, y2 + 75, 620 - 6, y2 + 75, stroke=INK2, sw=1.6, arrow=True) + s.line(878 + 4, y2 + 75, 906 - 6, y2 + 75, stroke=GREEN, sw=2, arrow=True) + s.text(892, y2 - 10, "right, bit for bit ↘", size=12.5, fill=GREEN, anchor="middle", mono=True) + s.path(f"M749 {y2 + H + 4} C 749 {y2 + H + 52}, 177 {y2 + H + 52}, 177 {y2 + H + 8}", stroke=ROSE, sw=1.6, + arrow=True, dash="5 5") + s.text(463, y2 + H + 56, "wrong answer: back to the hypothesis", size=13, fill=ROSE, anchor="middle", mono=True) + + yb = 652 + card(s, 48, yb, 540, 84, accent=VIOLET, fill=CARD) + s.text(66, yb + 30, "Mesa NAK (MIT), cited, no code copied", size=15, weight=700, fill=VIOLET) + s.lines(66, yb + 54, ["sm70_encode.rs opcodes and bit positions, sm120 latencies,", "qmd.rs launch descriptor layout"], + size=13, fill=INK2, gap=18) + card(s, 612, yb, 552, 84, accent=AMBER, fill=CARD) + s.text(630, yb + 30, "Arithmetic the documents leave open", size=15, weight=700, fill=AMBER) + s.lines(630, yb + 54, ["tensor-core BF16: 2,048 chosen cases until one model matched", "every output bit (tests/gpu_tc_probe_test.c)"], + size=13, fill=INK2, gap=18) + return s + + +# ---- figure 6: the driver client's objects ------------------------------------------------ +def fig_driver(): + s = Svg(1200, 1160, "The driver client: every object CUDA++ asks NVIDIA's kernel module for", + "Device files on the left, the resource-manager object tree in the middle, the unified-memory " + "registrations on the right, all from nvrm/nvrm.c.") + s.frame() + s.kicker(48, 60, "the driver client, part by part") + s.text(48, 100, "What replaces libcuda: nvrm/nvrm.c", size=30, weight=800, ls=-0.5) + s.lines(48, 132, ["About 900 lines of C that talk to NVIDIA's open kernel module through ioctls, written from its " + "MIT headers. Each box is", + "one object CUDA++ allocates (RM_ALLOC), with its class name, the header that defines it, and the " + "function that creates it."], size=15, fill=INK2, gap=21) + + # device files + s.text(48, 196, "DEVICE FILES", size=12, fill=INK3, mono=True, ls=1.5, weight=700) + devs = [("/dev/nvidiactl", ["resource manager: allocate", "objects, controls, free"], BLUE), + ("/dev/nvidia0", ["this GPU: CPU mappings of", "memory and the doorbell page"], BLUE), + ("/dev/nvidia-uvm", ["unified memory: GPU page", "tables of the address space"], VIOLET)] + for i, (name, sub, col) in enumerate(devs): + y = 210 + i * 118 + card(s, 48, y, 236, 100, accent=col) + s.text(66, y + 32, name, size=16, weight=700, mono=True, fill=col) + s.lines(66, y + 58, sub, size=13, fill=INK2, gap=18) + + # object tree + s.text(316, 196, "RESOURCE-MANAGER OBJECTS", size=12, fill=INK3, mono=True, ls=1.5, weight=700) + nodes = [ # depth, title, class, header, note, colour, creator + (0, "Root client", "NV01_ROOT_CLIENT", "cl0000.h", "the handle that owns everything below", BLUE, "nvrm_open"), + (1, "Device", "NV01_DEVICE_0", "cl0080.h", "the GPU; its class list names the Blackwell classes", BLUE, ""), + (2, "Subdevice", "NV20_SUBDEVICE_0", "cl2080.h", "SM version (sm_121) and GPU UUID", BLUE, ""), + (3, "Usermode page", "HOPPER_USERMODE_A", "clc661.h", "64 KiB of GPU registers; holds the doorbell", AMBER, ""), + (2, "Virtual memory", "NV01_MEMORY_VIRTUAL", "cl0070.h", "the GPU address range CUDA++ may use", BLUE, ""), + (2, "Address space", "FERMI_VASPACE_A", "cl90f1.h", "page faulting, handed to UVM to manage", VIOLET, ""), + (2, "Memory, one per buffer", "NV01_MEMORY_SYSTEM", "cl003e.h", "GB10 has no VRAM: same address for CPU and GPU", GREEN, "nvrm_alloc"), + (2, "Channel group", "KEPLER_CHANNEL_GROUP_A", "cla06c.h", "scheduled on the graphics/compute engine", BLUE, "nvrm_channel"), + (3, "Context share", "FERMI_CONTEXT_SHARE_A", "cl9067.h", "binds the channel to the address space", BLUE, ""), + (3, "Command ring (GPFIFO)", "BLACKWELL_CHANNEL_GPFIFO_A", "clc96f.h", "1,024 entries + USERD control page; submit token", GREEN, ""), + (4, "Compute object", "BLACKWELL_COMPUTE_B", "clcec0.h", "the engine every kernel launch runs on", GREEN, ""), + ] + tx, nw, nh, ng, ind = 316, 560, 64, 12, 30 + pos = [] + for i, (d, title, cls, hdr, note, col, fn) in enumerate(nodes): + x, y = tx + d * ind, 210 + i * (nh + ng) + w = nw - d * ind + card(s, x, y, w, nh, accent=col if col != BLUE else LINE2) + s.rect(x, y + 10, 3, nh - 20, fill=col, rx=1.5) + s.text(x + 16, y + 25, title, size=15.5, weight=700) + if fn: + s.text(x + 22 + len(title) * 8.4, y + 25, fn + "()", size=12, fill=INK3, mono=True) + s.text(x + w - 14, y + 25, cls, size=12, fill=col, mono=True, anchor="end") + s.text(x + 16, y + 48, note, size=13, fill=INK2) + s.text(x + w - 14, y + 48, hdr, size=11.5, fill=INK3, mono=True, anchor="end") + pos.append((d, x, y)) + # connectors: each node joins its parent (the closest earlier node one level up) + for i, (d, x, y) in enumerate(pos): + if d == 0: + continue + p = next(j for j in range(i - 1, -1, -1) if pos[j][0] == d - 1) + px = pos[p][1] + 14 + s.path(f"M{px} {pos[p][2] + nh} L{px} {y + nh / 2} L{x} {y + nh / 2}", stroke=LINE2, sw=1.4) + # device files feed the objects: control node to the root, GPU node to the usermode mapping + s.path(f"M284 260 C 300 260, 300 242, {tx - 4} 242", stroke=BLUE, sw=1.3, dash="3 4", arrow=True) + s.path(f"M284 378 C 300 378, 300 {pos[3][2] + 32}, {pos[3][1] - 4} {pos[3][2] + 32}", stroke=AMBER, sw=1.3, + dash="3 4", arrow=True) + + # UVM registrations + ux = 912 + s.text(ux, 196, "UNIFIED MEMORY (UVM) CALLS", size=12, fill=INK3, mono=True, ls=1.5, weight=700) + uvm = [("UVM_INITIALIZE", "open the UVM session", 210), + ("UVM_REGISTER_GPU", "this GPU, by UUID", 286), + ("UVM_REGISTER_GPU_VASPACE", "the address space", 590), + ("UVM_CREATE_EXTERNAL_RANGE", "per buffer: reserve the range", 666), + ("UVM_MAP_EXTERNAL_ALLOCATION", "per buffer: map it for the GPU", 742), + ("UVM_REGISTER_CHANNEL", "64 MiB for the channel's context", 894)] + for name, sub, y in uvm: + card(s, ux, y, 250, 64, accent=VIOLET) + s.text(ux + 14, y + 26, name, size=11.8, weight=700, fill=VIOLET, mono=True) + s.text(ux + 14, y + 48, sub, size=13, fill=INK2) + # dotted links from UVM calls to the objects they bind + links = [(286, 2), (590, 5), (666, 6), (742, 6), (894, 9)] + for uy, ni in links: + d, x, y = pos[ni] + s.line(ux - 4, uy + 32, tx + nw + 6, y + nh / 2, stroke=VIOLET, sw=1.5, dash="4 4", op=0.95) + + by = 210 + len(nodes) * (nh + ng) + 8 + card(s, 48, by, 1104, 70, accent=INK3, fill=CARD2, dash="6 5") + s.text(68, by + 30, "Below this line: NVIDIA's open kernel module (nvidia.ko, nvidia-uvm.ko) and the GSP " + "firmware inside the GPU.", size=15, fill=INK) + s.text(68, by + 53, "AIEN's own GB10 driver (L332) is being built to replace the two modules; the signed firmware " + "stays NVIDIA's.", size=14, fill=INK2) + return s + + +# ---- figure 7: life of one launch ------------------------------------------------------------ +def fig_launch(): + s = Svg(1200, 1010, "The life of one kernel launch", + "Five CPU steps write into memory the CPU and GPU share, one store rings the doorbell, the GPU reads " + "the ring, the pushbuffer and the launch descriptor, runs the grid and writes a completion marker the " + "CPU polls.") + s.frame() + s.kicker(48, 60, "the launch path") + s.text(48, 100, "The life of one kernel launch", size=30, weight=800, ls=-0.5) + s.text(48, 132, "On the GB10 the CPU and the GPU share one memory, and CUDA++ maps every buffer at the same " + "address on both. Nothing is copied.", size=15.5, fill=INK2) + cx, mx, gx = 48, 440, 820 + cw, mw, gw = 350, 300, 332 + s.text(cx, 186, "CPU (your process)", size=13, fill=BLUE_SOFT, mono=True, weight=700, ls=1) + s.text(mx, 186, "SHARED MEMORY", size=13, fill=GREEN, mono=True, weight=700, ls=1) + s.text(gx, 186, "GPU", size=13, fill=AMBER, mono=True, weight=700, ls=1) + s.rect(mx - 14, 168, mw + 28, 740, fill=GREEN, rx=18, op=0.035) + + def step(x, y, w, n, title, sub, col, h=104): + card(s, x, y, w, h, accent=col) + s.circle(x + 26, y + 28, 14, fill=col) + s.text(x + 26, y + 33, str(n), size=14, weight=800, fill=BG, anchor="middle") + s.text(x + 50, y + 33, title, size=16, weight=700) + s.lines(x + 18, y + 60, sub, size=13, fill=INK2, gap=18) + + def buf(y, title, sub, col=GREEN, h=68, dash=None): + card(s, mx, y, mw, h, accent=col, dash=dash) + s.text(mx + 16, y + 27, title, size=15, weight=700, fill=col) + s.text(mx + 16, y + 50, sub, size=12.5, fill=INK2, mono=True) + + rows = [206, 326, 446, 566, 686] + step(cx, rows[0], cw, 1, "Build the kernel", ["IR instructions, register allocation,", "16-byte machine words"], BLUE_SOFT) + step(cx, rows[1], cw, 2, "Describe the launch", ["QMD: grid, block, registers, shared", "memory, code address. Arguments", "go in constant bank 0."], BLUE_SOFT, h=110) + step(cx, rows[2], cw, 3, "Write the methods", ["INVALIDATE_SHADER_CACHES,", "WAIT_FOR_IDLE, SEND_PCAS_A (the", "QMD), then the completion tail"], BLUE_SOFT, h=110) + step(cx, rows[3], cw, 4, "Queue one ring entry", ["8 bytes: pushbuffer address + length;", "then advance USERD.GPPut"], BLUE_SOFT) + step(cx, rows[4], cw, 5, "Ring the doorbell", ["one 32-bit store of the channel's", "work-submit token"], AMBER) + + buf(rows[0] + 18, "Code buffer", "written once, executed by the GPU") + buf(rows[1] + 18, "QMD + constant bank 0", "384 B QMD · 224 driver words · args") + buf(rows[2] + 18, "Pushbuffer", "method headers + data words") + buf(rows[3] + 18, "GPFIFO ring + USERD", "1,024 entries · GPPut (GPU-uncached)") + buf(rows[4] + 18, "Usermode page (GPU registers)", "doorbell register", col=AMBER, dash="5 4") + buf(826, "Marker page (GPU-uncached)", "0x44444444, then 0x46464646") + + for r in range(5): + s.line(cx + cw + 4, rows[r] + 52, mx - 6, rows[r] + 52, stroke=BLUE_SOFT if r < 4 else AMBER, sw=1.6, + arrow=True) + + gsteps = [(286, 6, "Host engine fetches", ["reads the new ring entry, then", "the pushbuffer's methods"]), + (446, 7, "Compute engine launches", ["invalidates caches, reads the QMD", "and constant bank, starts the", "grid on the SMs"]), + (606, 8, "The grid finishes", ["semaphore release writes the", "marker, L2_FLUSH_DIRTY, then", "the second marker"])] + for y, n, t, sub in gsteps: + step(gx, y, gw, n, t, sub, AMBER, h=118) + # GPU reads: two buses on the right of the memory column, one per GPU step + bx6, bx7 = mx + mw + 18, mx + mw + 40 + for r in (2, 3): + s.line(mx + mw, rows[r] + 52, bx6, rows[r] + 52, stroke=INK2, sw=1.3) + s.line(bx6, rows[3] + 52, bx6, 345, stroke=INK2, sw=1.3) + s.line(bx6, 345, gx - 6, 345, stroke=INK2, sw=1.3, arrow=True) + for r in (0, 1): + s.line(mx + mw, rows[r] + 52, bx7, rows[r] + 52, stroke=INK2, sw=1.3) + s.line(bx7, rows[0] + 52, bx7, 505, stroke=INK2, sw=1.3) + s.line(bx7, 505, gx - 6, 505, stroke=INK2, sw=1.3, arrow=True) + for r in (2, 3): + s.circle(bx6, rows[r] + 52, 3.5, fill=INK2) + for r in (0, 1): + s.circle(bx7, rows[r] + 52, 3.5, fill=INK2) + s.text(gx + 4, 278, "reads ring + pushbuffer", size=11.5, fill=INK3, mono=True) + s.text(gx + 4, 438, "reads QMD, bank, code", size=11.5, fill=INK3, mono=True) + # the doorbell wakes the host engine + dy = rows[4] + 52 + s.path(f"M{mx + mw + 4} {dy} L802 {dy} L802 395 L{gx - 6} 395", stroke=BG, sw=7) + s.path(f"M{mx + mw + 4} {dy} L802 {dy} L802 395 L{gx - 6} 395", stroke=AMBER, sw=1.8, arrow=True) + s.add(f'wakes the GPU') + s.path(f"M{gx + gw / 2} {606 + 118 + 4} L{gx + gw / 2} 860 L{mx + mw + 6} 860", stroke=AMBER, sw=1.8, + arrow=True) + s.text(gx + gw / 2 - 8, 848, "writes the markers", size=12, fill=AMBER, mono=True, anchor="end") + step(cx, 806, cw, 9, "Wait, then retire", ["poll the marker with a hard deadline", "and a stall deadline; results are", "already in shared memory"], BLUE_SOFT, h=110) + s.line(mx - 4, 860, cx + cw + 6, 860, stroke=BLUE_SOFT, sw=1.6, arrow=True) + s.text(48, 958, "Blue: the CPU writes. Amber: the GPU acts. Dashed: GPU registers mapped into the process, " + "not memory.", size=13, fill=INK2) + s.text(48, 980, "Measured on the GB10: 24 to 31 µs per extra dependent launch with wait-for-idle " + "(evidence/OWN30B-LAUNCH-COST-20261014T0120Z). Command lists put many launches in one submission.", + size=13, fill=INK3) + return s + + +# ---- figure 8: replacement map ------------------------------------------------------------- +STATUS_COL = {"PASS": GREEN, "PARTIAL": BLUE_SOFT, "BUILDING": VIOLET, "MISSING": INK2, "STAYS": AMBER} + + +def fig_status(): + rows = [ # piece, job, replacement, status, note + ("nvcc · NVVM · PTX · ptxas", "compile kernels", "sm_121 encoder + register allocator", "PASS", "every kernel Omega runs"), + ("libcuda", "user-space driver", "nvrm + m16 driver client", "PASS", "m16 requalification receipt"), + ("libcudart", "device, memory, launch", "session, command lists, job engine", "PARTIAL", "one device, one process"), + ("cuBLAS", "matrix multiply", "matmul, tensor-core GEMM, FP8, BF16", "PARTIAL", "model shapes; any-shape GEMM is C3"), + ("cuDNN · FlashAttention", "attention, layers", "decode and prefill attention", "PARTIAL", "model-shaped"), + ("CUB · Thrust", "reductions, scans, sorts", "frozen-order reductions", "PARTIAL", "E1-CLOSURE; scans and sorts are C3"), + ("cuobjdump · nvdisasm", "read machine code back", "my own sm_121 disassembler", "BUILDING", "Omega branch c6/disasm: 331 kernels agree"), + ("Nsight", "measure", "ceiling probes", "PARTIAL", "115.14 TFLOPS, 195.1 GB/s"), + ("cuFFT · cuRAND", "FFT, random numbers", "none yet", "MISSING", ""), + ("nvidia.ko", "kernel driver", "AIEN's own GB10 driver (L332)", "BUILDING", "simulator gates pass"), + ("nvidia-uvm.ko", "page tables, faults", "same driver", "BUILDING", "host simulator, 225 checks"), + ("nvidia-smi · NVML", "status, clocks, power", "not started", "MISSING", ""), + ("GSP firmware", "runs inside the GPU", "stays NVIDIA's: signature-checked", "STAYS", "never shipped by CUDA++"), + ] + rh, top = 52, 200 + s = Svg(1200, top + len(rows) * rh + 80, "Every NVIDIA piece on the Spark and what replaces it", + "One row per NVIDIA component with the CUDA++ replacement and its status (ROADMAP.md).") + s.frame() + s.kicker(48, 60, "the replacement map") + s.text(48, 100, "Every NVIDIA piece on the Spark, and what replaces it", size=30, weight=800, ls=-0.5) + s.text(48, 132, "PASS means a receipt on a named commit. The full table with every receipt is ROADMAP.md.", + size=15.5, fill=INK2) + hx = [48, 330, 560, 900, 1040] + for lab, x in zip(("NVIDIA piece", "its job", "CUDA++", "status", ""), hx): + s.text(x, top - 16, lab.upper(), size=12.5, fill=INK2, mono=True, ls=1, weight=700) + for i, (p, job, rep, st, note) in enumerate(rows): + y = top + i * rh + if i % 2 == 0: + s.rect(36, y, 1128, rh, fill=CARD, rx=8) + s.text(48, y + 22, p, size=15, weight=700, mono=True, fill=INK if st != "STAYS" else AMBER) + s.text(330, y + 22, job, size=14, fill=INK2) + s.text(560, y + 22, rep, size=14.5, fill=INK) + if note: + s.text(560, y + 41, note, size=12.5, fill=INK2, op=0.85) + col = STATUS_COL[st] + s.pill(900, y + 12, st, col, size=12, h=24, filled=True, w=108) + tot = {k: sum(1 for r in rows if r[3] == k) for k in STATUS_COL} + x = 48 + yb = top + len(rows) * rh + 40 + for k, col in STATUS_COL.items(): + s.rect(x, yb - 12, 14, 14, fill=col, rx=3, op=0.85) + lab = f"{k} {tot[k]}" + s.text(x + 22, yb, lab, size=14, fill=INK2, mono=True) + x += 40 + len(lab) * 9 + return s + + +# ---- figure 9: ceilings ------------------------------------------------------------------------- +def fig_ceiling(): + import math + peak, bw = 115.14e12, 195.1e9 # evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z + s = Svg(1200, 660, "The two ceilings I measured on the GB10", + "Roofline: attainable speed against operations per byte, from the measured 115.14 TFLOPS tensor-core " + "peak and 195.1 GB/s read bandwidth.") + s.frame() + s.kicker(48, 60, "speed against the machine's ceiling") + s.text(48, 100, "The two ceilings I measured on the GB10", size=30, weight=800, ls=-0.5) + s.text(48, 132, "Every speed claim is held against these: the tensor-core peak and the memory read rate my " + "own probes reached.", size=15.5, fill=INK2) + px, py, pw, ph = 130, 170, 700, 380 + xmin, xmax, ymin, ymax = -2, 4, 9, 15 # log10 FLOP/byte, log10 FLOP/s + X = lambda v: px + (math.log10(v) - xmin) / (xmax - xmin) * pw + Y = lambda v: py + ph - (math.log10(v) - ymin) / (ymax - ymin) * ph + s.rect(px, py, pw, ph, fill=CARD, rx=10) + for e in range(xmin, xmax + 1): + s.line(X(10 ** e), py, X(10 ** e), py + ph, stroke=LINE, sw=1) + s.text(X(10 ** e), py + ph + 22, f"{10 ** e:g}", size=12.5, fill=INK3, anchor="middle", mono=True) + for e in range(ymin, ymax + 1): + s.line(px, Y(10 ** e), px + pw, Y(10 ** e), stroke=LINE, sw=1) + lab = {9: "1 G", 10: "10 G", 11: "100 G", 12: "1 T", 13: "10 T", 14: "100 T", 15: "1 P"}[e] + s.text(px - 12, Y(10 ** e) + 4, lab, size=12.5, fill=INK3, anchor="end", mono=True) + s.text(px + pw / 2, py + ph + 48, "operations per byte moved (log)", size=13.5, fill=INK2, anchor="middle") + s.add(f'operations per second (log)') + ridge = peak / bw + pts = [(10 ** xmin, bw * 10 ** xmin), (ridge, peak), (10 ** xmax, peak)] + d = " ".join(("M" if i == 0 else "L") + f"{X(a):.1f} {Y(b):.1f}" for i, (a, b) in enumerate(pts)) + s.path(d, stroke=GREEN, sw=3) + s.line(X(ridge), Y(peak), X(ridge), py + ph, stroke=GREEN, sw=1, dash="4 5", op=0.6) + s.text(X(ridge) + 8, py + ph - 10, f"ridge: {ridge:.0f} ops/byte", size=12.5, fill=GREEN, mono=True) + s.text(X(ridge) - 14, Y(peak) + 5, "tensor-core peak 115.14 TFLOPS", size=14, fill=GREEN, mono=True, weight=700, + anchor="end") + ang = math.degrees(math.atan((ph / (ymax - ymin)) / (pw / (xmax - xmin)))) + s.add(f'memory reads 195.1 GB/s') + marks = [(1 / 12, "vector add", "1 add per 12 bytes moved", CYAN), + (1.0, "decode, BF16 matrix-vector", "multiply + add per 2-byte weight", AMBER), + (4096 / 3, "large BF16 GEMM (4096³)", "each byte reused many times", ROSE)] + for v, lab, sub, col in marks: + yv = min(bw * v, peak) + s.circle(X(v), Y(yv), 6, fill=col, stroke=BG, sw=2) + # legend panel + lx = 880 + for i, (v, lab, sub, col) in enumerate(marks): + y = 196 + i * 92 + s.circle(lx + 8, y - 5, 6, fill=col) + s.text(lx + 24, y, lab, size=15, weight=700, fill=col) + s.text(lx + 24, y + 21, sub, size=13, fill=INK2) + bound = "memory-bound" if v < ridge else "compute-bound" + num = f"{v:,.0f}" if v >= 10 else (f"{v:.0f}" if v == 1 else f"{v:.3f}") + s.text(lx + 24, y + 40, f"{num} ops/byte: {bound}", size=12.5, fill=INK2, mono=True) + s.lines(lx, 488, ["A generated word reads every active", "weight once, so its speed is set by", "the memory line, not the tensor cores."], + size=13.5, fill=INK2, gap=19) + s.text(48, s.h - 40, "The two lines are measured: evidence/OWN30B-T3-TC-PEAK-BW-5faa0f70-20261013T2236Z " + "(peak.log, bw.log). The dots are arithmetic, not measurements.", size=13, fill=INK2) + s.text(48, s.h - 20, "One op is one add or one multiply; a fused multiply-add counts as two.", size=13, fill=INK3) + return s + + +# ---- figure 10: timeline ------------------------------------------------------------------------ +def fig_timeline(): + ev = [("2026-09-26", "First native kernel", ["vector add qualified on the", "GB10; first tensor-core matmul"]), + ("2026-10-02", "Numerics closed on chip", ["reductions, 9 functions over", "all 2^32 inputs, 148 ld/st kernels"]), + ("2026-10-13", "Ceilings measured", ["115.14 TFLOPS tensor peak,", "195.1 GB/s reads, own probes"]), + ("2026-10-21", "A 35B model, no CUDA", ["served on this code with zero", "CUDA libraries in the process"])] + s = Svg(1200, 270, "Under four weeks, one DGX Spark", + "Milestones from the first native kernel to a 35B model served with no CUDA library loaded.") + s.frame() + s.kicker(48, 56, "under four weeks, one DGX Spark") + y = 120 + s.path(f"M80 {y} L950 {y}", stroke=GREEN, sw=2.5, op=0.6) + for i, (d, t, sub) in enumerate(ev): + x = 80 + i * 290 + s.circle(x, y, 9, fill=BG, stroke=GREEN, sw=3) + anchor = "start" + s.text(x, y - 22, d, size=13.5, fill=GREEN, mono=True, anchor=anchor, weight=700) + s.text(x, y + 40, t, size=17, weight=700, anchor=anchor) + for j, l in enumerate(sub): + s.text(x, y + 64 + j * 20, l, size=14, fill=INK2, anchor=anchor) + return s + + +FIGS = { + "hero.svg": lambda w: fig_hero(w), + "stack.svg": lambda w: fig_stack(), + "instruction.svg": lambda w: fig_instruction(w), + "vecadd-scoreboards.svg": lambda w: fig_listing(w), + "reverse-engineering.svg": lambda w: fig_reverse(), + "driver-objects.svg": lambda w: fig_driver(), + "launch-path.svg": lambda w: fig_launch(), + "replacement-map.svg": lambda w: fig_status(), + "ceilings.svg": lambda w: fig_ceiling(), + "timeline.svg": lambda w: fig_timeline(), +} + + +def main(): + check = "--check" in sys.argv + words = vecadd_words() + os.makedirs(OUT, exist_ok=True) + stale = [] + for name, fn in FIGS.items(): + data = fn(words).svg() + path = os.path.join(OUT, name) + if check: + if not os.path.exists(path) or open(path).read() != data: + stale.append(name) + else: + with open(path, "w") as f: + f.write(data) + print(f"wrote docs/img/{name} ({len(data)} bytes)") + if check: + if stale: + sys.exit("stale figures (run python3 tools/figures/make_figures.py): " + ", ".join(stale)) + print(f"figures current: {len(FIGS)}") + + +if __name__ == "__main__": + main()