CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / om / resident / README.md
| 1 | # Resident small-model kernel |
| 2 | |
| 3 | IMPLEMENTED in seeded Omega at compiler source `omega-mv@e5b32567`. |
| 4 | Chip: EXERCISED on the GB10 on 2026-11-12, on a shared chip (values only), receipt |
| 5 | `evidence/chip-gates-shared-20261112/`: `gpu_resident_chip --chip` passes both witnesses in both |
| 6 | modes after the `S2R` scheduling fix described there. It is not QUALIFIED: the exclusive window of |
| 7 | the runbook below is still NOT_RUN. The ROADMAP row is PARTIAL. |
| 8 | This branch stacks on the generic replay in CodegenA commit `22ebf8f`. |
| 9 | No replay implementation is forked or changed here. |
| 10 | |
| 11 | `resident.om` emits one descriptor interpreter through the canonical eight-u64 IR |
| 12 | records and `omega_gpu_om_ir_replay`. `check.om` exports the Omega admission entry. |
| 13 | `src/omega_gpu_resident.c` widens descriptor words and calls those entries. It has |
| 14 | no operation selection, scheduling, layer arithmetic or barrier decisions. |
| 15 | The internal builder is not an addition to the public runtime API. |
| 16 | |
| 17 | ## Contract |
| 18 | |
| 19 | A descriptor is eight little-endian u32 words: |
| 20 | `op, input_a_offset, input_b_offset, output_offset, rows, cols, 0, 0`. |
| 21 | Offsets count f32 elements in one arena. Operations are GEMV (1, row-major), |
| 22 | ADD (2), MUL (3), SUM (4, one output row), COPY (5). Elementwise operations and |
| 23 | COPY require cols=1. Dimensions are bounded by 32; the table has at most 64 |
| 24 | entries and the arena at most 65536 elements. Outputs cannot overlap their own |
| 25 | inputs. Later descriptors may consume earlier outputs. Admission rejects invalid |
| 26 | opcodes, bounds, reserved words, dimensions, overlap and unsupported launch grids. |
| 27 | The table and pointers must not change after admission until completion. |
| 28 | |
| 29 | The launch has one or two CTAs, each with 32 threads. Thread zero of each CTA |
| 30 | works; other threads exit. CTA c owns rows c, c+ctas, ... . The device loops over |
| 31 | the descriptor table; no host return occurs between layers. The included model |
| 32 | has GEMV -> ADD -> MUL -> SUM -> COPY, with dependencies at every boundary. |
| 33 | |
| 34 | The grid barrier uses an arrival counter and monotonically increasing generation |
| 35 | word, initially both zero. Every CTA fences its data stores, then atomically adds |
| 36 | one to the counter. The last arrival atomically resets the counter, fences, and |
| 37 | atomically exchanges the new generation. Others poll with STRONG.SYS loads. |
| 38 | There is a fence on exit. Arena traffic uses STRONG.SYS loads/stores too. |
| 39 | The initial count/generation must be reset for every model invocation. |
| 40 | All CTAs must fit simultaneously; this bounded grid is not a general oversubscribed |
| 41 | cooperative launch. Hardware occupancy and memory-order behavior still require |
| 42 | the chip tier. Never run a dropped-barrier control on the chip. |
| 43 | |
| 44 | The fixed vreg plan uses pairs 0..7 and scalars 8..30. Initialization and terminal |
| 45 | self-reads hold all values across every generated loop and branch arm, without |
| 46 | assuming that the straight-line register allocator understands a CFG. |
| 47 | |
| 48 | ## Host acceptance |
| 49 | |
| 50 | Run with the pinned `OMEGA_OMC` and `OMEGA_BRIDGE` from the repository: |
| 51 | |
| 52 | ```sh |
| 53 | taskset -c 10-14 nice -n 10 make -j3 test-gpu-resident |
| 54 | ``` |
| 55 | |
| 56 | The plain C evaluator is independent of the generator. f32 order is fixed: |
| 57 | GEMV multiplies, rounds, then accumulates left-to-right with a separate FADD; |
| 58 | SUM accumulates left-to-right. The compiler uses `-ffp-contract=off`. |
| 59 | The exact-f32 witness includes a cancellation that distinguishes an FMA from |
| 60 | separate multiply/add. WolframLanguageEvaluator query: |
| 61 | `{Expand[(1+2^-23)(1-2^-23)-1], N[1+2^-23,25], N[1-2^-23,25]}` |
| 62 | returned `{-1/70368744177664, 1.00000011920928955078125, |
| 63 | 0.99999988079071044921875}`. The rounding check |
| 64 | `Round[(1+2^-23)(1-2^-23),2^-24]-1` returned `0` through |
| 65 | WolframLanguageEvaluator: separately rounded f32 multiplication is 1, so adding |
| 66 | -1 is zero; an FMA retains the nonzero product residual. |
| 67 | |
| 68 | `bw_warp_sim_k.h` previously completed each CTA before starting the next. It now |
| 69 | has a default-off instruction quantum and the existing integer atomic-exchange |
| 70 | operation. Existing `ws_run` callers keep quantum=0 and retain their scheduling. |
| 71 | `tests/gpu_resident_grid.h` interleaves one-warp CTAs in both CTA orders and |
| 72 | several instruction quanta; it executes the emitted polling loops, not a host |
| 73 | replacement barrier. This SC/coherent memory model cannot qualify GPU caches, |
| 74 | fences, progress or occupancy. It also has no instruction latency: a |
| 75 | variable-latency producer read without its wait passes the simulator. `gpu_resident_test` |
| 76 | therefore runs the static hazard checker (`src/omega_bw_hazard.c`) on the encoded kernels |
| 77 | (1 and 5 layers, 1 and 2 CTAs) before the simulator, and the mutant |
| 78 | `fixed-latency-thread-id` must fail there. The dropped-barrier control uses an intentionally |
| 79 | unfair long quantum so the reduction observes unfinished producer rows. |
| 80 | Corrupted descriptors must be refused before replay. Source mutations must |
| 81 | compile successfully, then fail the oracle. Missing tools are NOT_RUN. |
| 82 | |
| 83 | ## Authorized chip runbook (exclusive window: NOT_RUN) |
| 84 | |
| 85 | Only after the operator opens a current exclusive window, runs the platform's |
| 86 | normal admission/doctor checks, and authorizes this exact candidate: |
| 87 | |
| 88 | ```sh |
| 89 | taskset -c 10-14 nice -n 10 make -j3 build/gpu_resident_chip |
| 90 | SPARK_WINDOW="$AUTHORIZED_WINDOW_ID" build/gpu_resident_chip --chip |
| 91 | ``` |
| 92 | |
| 93 | The executable refuses missing `--chip` or an empty window label before any |
| 94 | device call. The label is a guard, not authorization. Capture the command, rc, |
| 95 | stdout/stderr, source/compiler hashes, machine and window in a new evidence |
| 96 | directory. A timeout is uncertain completion: preserve the runtime latch and |
| 97 | parked buffers; do not retry, free through another path, reset the GPU or unload |
| 98 | modules. Escalate to the operator. |
| 99 | |
| 100 | Both paths use PCAS command lists with WFI ordering and the same model, arena, |
| 101 | CTA geometry and f32 comparison. The resident path records one launch; the |
| 102 | per-layer baseline records five. Require exact output, the expected generation |
| 103 | words, matching semaphore counts and observed launch counts on both ordinary and |
| 104 | cancellation fixtures. Record raw elapsed_ns independently; do not claim a speedup |
| 105 | from launch count alone. The historical receipt |
| 106 | `evidence/OWN30B-LAUNCH-COST-20261014T0120Z/` measured 24–31 us per extra launch. |
| 107 | That is context, not a current resident-kernel measurement. |