Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/gpu-head-to-head/blob/main/coldstart/PROTOCOL.md # gpu-head-to-head aien-dev/gpu-head-to-head Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `gpu-head-to-head / coldstart / PROTOCOL.md` 201 lines ยท 13507 bytes Raw Blame History Rendered 1 # PROTOCOL: cold start to first verified result, CUDApp vs NVIDIA user-space compile paths (GB10) 2 3 Predeclared before any measured GPU run. This file, the harness in `coldstart/` and amendment A7 of the 4 repo's [PROTOCOL.md](../PROTOCOL.md) are committed and pushed before the GPU window opens. Any later change 5 is a separate, dated commit listed in section 11, and results name the protocol commit they ran under. 6 7 This is a chip-level microbenchmark. The repo's PROTOCOL.md section 1 still holds: none of these numbers 8 enters the main results table (`results/RESULTS.md`). They live in `results/coldstart/` only. 9 10 ## 1. Question 11 12 On one DGX Spark (GB10, sm_121), how long does a fresh process take from `exec` to its first verified 13 GPU result when the kernel reaches the GPU through CUDApp's own path (its kernel builder and encoder, 14 then its own `ioctl`/`mmap` calls on `/dev/nvidiactl` and `/dev/nvidia0`, no NVIDIA user-space library), 15 compared with the NVIDIA user-space paths that compile a kernel at run time (NVRTC, or the PTX compiler 16 library) and then load and launch it through `libcuda`? 17 18 ## 2. Arms 19 20 | Arm | Binary | Kernel description in the process | Build step (timed as `build`) | GPU path | 21 |-----|--------|-----------------------------------|-------------------------------|----------| 22 | CUDAPP | `cs_cudapp` | CUDApp `examples/hello_gpu/hello_gpu.c` `build_vecadd` (IR program) | `build_vecadd` + `omega_blackwell_kernel_encode_into`: 512 B of machine code | CUDApp `libomega_gpu.a` session API (own nvrm ioctls) | 23 | PTXC | `cs_ptxc` | `coldstart/vecadd.ptx`, read into memory during prep | static `nvPTXCompiler` (`--gpu-name=sm_121`): 5600 B cubin | CUDA driver API, `libcuda` | 24 | NVRTC | `cs_nvrtc` | the CUDA C++ string in `cs_cuda.c` | `nvrtcCompileProgram` (`--gpu-architecture=sm_121`): 5600 B cubin | CUDA driver API, `libcuda` | 25 26 PTXC is the like-for-like arm against CUDAPP: both start from a device-level description and stop at 27 loadable machine code. `vecadd.ptx` is NVRTC's own `compute_121` PTX for the NVRTC source (build.sh checks 28 that it is still byte-identical to what NVRTC emits), and PTXC's cubin is byte-identical to NVRTC's 29 (sha256 ``691edc87423da8a86c5403d332bb980aa20f8808c84a0ffbf79481081c7dd6e8``, 5600 B, observed with 30 `--build-only --emit-code` after the section 3 build). So PTXC and NVRTC load and run the same code; 31 they differ in the build step and in what the process links. 32 33 ## 3. Pins and build 34 35 - CUDApp ``cc0908bdc0a0377f2166e9328dcf1d985457e27f`` (cloned by `coldstart/build.sh` into `OUTDIR/cudapp`, 36 checked clean and at the pin; library and `hello_gpu` built with CUDApp's own Makefile and flags). 37 - gcc 13.3.0. NVIDIA arms: `-std=gnu11 -Wall -Wextra -Werror -O2`. 38 - CUDA 13.0 (`/usr/local/cuda-13.0`, `version.json` cuda 13.0.3): NVRTC `libnvrtc.so.13.0.88` 39 (`nvrtcVersion` 13.0), PTX compiler `libnvptxcompiler_static.a` (`nvPTXCompilerGetVersion` 13.0). 40 - Driver 580.173.02 (`/proc/driver/nvidia/version`, `libcuda.so.580.173.02`), `cuDriverGetVersion` 13000. 41 - Build: `taskset -c 10-14 nice -n 19 ionice -c3 coldstart/build.sh /tmp/csb/out` printed `build: OK 42 /tmp/csb/out` on 2026-10-29 (binaries written 22:08:17Z). `build.txt` sha256: 43 44 | File | sha256 | 45 |------|--------| 46 | `cs_cudapp` | ``ba4496b361a6f53ec65ccec1b8c999509e392bce7f439d2e4d1e86aa4d7d31cd`` | 47 | `cs_nvrtc` | ``878bc185cd7a28f52d33253f217efd4a1773cdd1c5bf92669ed0168195e8f14e`` | 48 | `cs_ptxc` | ``27ae182fe36dda55813ba96f89b7f416505010c2bb3d40805fc263d17c3a28e4`` | 49 | `cudapp/build/hello_gpu` | ``af5e9f6640445cb4d02a857c63ca568f4da48d6c15212dab98631ad9ea6ce3aa`` | 50 | `cudapp/build/libomega_gpu.a` | ``3c626939a7f599d929d30bc8c9f9f37e08a6bc02bdcd9755c98504bda9e06724`` | 51 | `coldstart/vecadd.ptx` | ``9abb51a8a751ec3e2483ba7a57effbe6a387f282f5ffa1bf4a485048e66669a2`` | 52 53 The three arm shas equal those of the earlier build from 16:53Z, although the header comments of both 54 C files changed in between: comments do not reach object code, and nothing is built with `-g`. 55 - Emitted code: CUDAPP `--emit-code` sha256 ``9e28bd9c46f80584d77238a752e99cecddbc8d622ffbe320885ed2f499e1f075`` 56 (512 B), equal to the "machine code sha256" that `hello_gpu --sim` prints at the pin; PTXC and NVRTC as 57 in section 2. 58 59 ## 4. Job, phases, metrics 60 61 The job is `hello_gpu`'s job at the pin: `c = a + b` over 1,048,576 floats, `a[i] = i * 0.25`, 62 `b[i] = 1 / (1 + i % 7)`, `c` poisoned with `0xFFC0FFEE`, eight launches of 1024 blocks x 128 threads, 63 then every element compared bit for bit with the CPU's own `a[i] + b[i]`. A process is correct only with 64 `wrong == 0` and `unwritten == 0` (exit 0). 65 66 Phases, each closed by a `CLOCK_MONOTONIC` stamp inside the process: 67 68 | Phase | CUDAPP | PTXC / NVRTC | 69 |-------|--------|--------------| 70 | prep | host inputs | host inputs (PTXC: also reads `vecadd.ptx`) | 71 | build | kernel description to machine code in host memory | PTX or C++ to cubin in host memory | 72 | open | `omega_gpu_session_open` | `cuInit`, `cuDeviceGet`, `cuDevicePrimaryCtxRetain`, `cuCtxSetCurrent` | 73 | load | code buffer allocated, words copied, synced to GPU | `cuModuleLoadData`, `cuModuleGetFunction` | 74 | data | three buffers allocated, inputs and poison copied in and synced | `cuMemAlloc` x3, `cuMemcpyHtoD` x3 | 75 | run | eight launches, each waits for its completion marker | eight `cuLaunchKernel`, `cuCtxSynchronize` | 76 | check | output synced to CPU, bit-exact check | `cuMemcpyDtoH`, bit-exact check | 77 | close | buffers freed, session closed | `cuMemFree` x3, `cuModuleUnload`, `cuDevicePrimaryCtxRelease` | 78 79 The driver (`run.py`) stamps `t0` just before `Popen` and `t1` when the child has exited and its pipes 80 are drained, on the same clock. 81 82 | ID | Metric | Definition (ns, reported in us) | Role | 83 |----|--------|---------------------------------|------| 84 | H1 | build | build phase | headline | 85 | H2 | ready | build + open + load | descriptive: CUDA 13 defaults to lazy module loading (`CUDA_MODULE_LOADING` unset), so part of the NVIDIA arms' load work can move into run | 86 | H3 | firstResult | exec + prep + build + open + load + data + run + check | headline: spawn to verified result | 87 | H4 | proc | `t1 - t0` | headline: spawn to process exit, close and teardown included | 88 | E | exec | `t_main - t0`: spawn, `exec`, dynamic linking, constructors | descriptive | 89 | W | warm build | per process, median of 10 further builds in a `--build-only` process | descriptive | 90 91 ## 5. Schedule (`coldstart/run.py`) 92 93 1. Pre-checks (section 6), then the control processes of section 6, one per arm per control. 94 2. 2 warmup rounds (each arm once per round, order CUDAPP, PTXC, NVRTC), not analysed. 95 3. 30 measured rounds. Round `r` runs the arms in permutation `r mod 6` of the 6 orders, so every order 96 runs 5 times. 1 s sleep before every measured spawn. Measured processes run with `--warm 0`, so no 97 per-process warm build sits inside their proc time. 98 4. Warm phase W: 10 rounds under the same permutation rule and gap, each process `--build-only` 99 (no GPU opened) with its 10 warm builds. 100 5. Cap: 15 minutes from driver start. When it is reached the driver stops, writes what it has and the 101 session verdict is `INCOMPLETE_CAP`. 102 103 Output: `results/coldstart//{raw.jsonl,session.json,rows.wl}`, plus the control artefacts 104 `code..bin` and `maps..txt`. Every spawned process gets `CUDA_CACHE_DISABLE=1`. 105 106 Pinning: the driver runs on core 12 (Cortex-A725). Every arm process runs on one core, the first of 107 9, 8, 7 (Cortex-X925, A2) that hosts no nvidia-modeset kthread at driver start (field 39 of 108 `/proc//stat`); the core and the kthread cpus go into `session.json`. 109 110 ## 6. Pre-checks, controls, validity 111 112 The driver refuses to start, before any process runs, when any of these fails: 113 114 - not inside a spark-window that holds the chip lock (`SPARK_WINDOW` set and `AIEN_GB10_LOCK_HELD=1`); 115 - an arm binary or `vecadd.ptx` does not match its sha256 in `build.txt`; 116 - every candidate arm core hosts an nvidia-modeset kthread; 117 - `bench/quiet.py --window 60 --max-load 6` fails (a foreign process above 20% of one CPU over 60 s, or 118 `load1 >= 6`; the omp harness is recorded, not gated, as in A2); 119 - `nvidia-smi --query-compute-apps` lists any compute process. 120 121 Controls, all before the first measured process. Any failure makes the session verdict 122 `CONTROLS_FAILED` and no measured process runs: 123 124 - code: each arm `--build-only --emit-code`; CUDAPP's code sha256 must be ``9e28bd9c`...` (section 3); 125 PTXC's cubin must be byte-identical to NVRTC's. 126 - skip-run (negative control): each arm `--skip-run` must exit 1 with `unwritten == wrong == `1048576``. 127 - maps: each arm runs the full job and copies `/proc/self/maps`. CUDAPP's map must hold no 128 `libcuda`, `libcudart`, `libnvrtc`, `libnvptx` or `libnvidia` mapping and at least one `/dev/nvidia` 129 mapping; each NVIDIA arm's map must hold `libcuda` (the positive control of the library check). 130 - output: the maps runs must all be correct and give the same output FNV-1a hash across the three arms. 131 132 Validity of rows and arms (in `coldstart/analysis.wl`): a measured row is valid when its process was 133 correct and `load1 < 6` at its spawn. An arm is valid with at least 28 of its 30 measured rows valid. 134 135 Session validity: a session is VOID when its verdict is not `MEASURED` (`CONTROLS_FAILED`, 136 `INCOMPLETE_CAP`, a refused pre-check), when the spark-window lease ran out before close (spark-window 137 verdict NO VERDICT), or when the window's holder lost the chip lock during the run (for example a 138 chip-watchdog kill posted on the BOARD). A void session is never retried inside the same window. It is 139 re-run in a new window, and both sessions are published. 140 141 ## 7. Statistics and verdicts 142 143 Computed by `coldstart/analysis.wl` (`csAnalyse`, with `h2hStats` of `results/wolfram/analysis.wl`) in the 144 Wolfram MCP kernel on the run's `rows.wl`; query and output are kept beside the rows. Per arm and metric: 145 n, median, Q1, Q3, IQR (Wolfram `Median`, `Quantile` with its default definition, `InterquartileRange`), 146 p99 as a descriptive figure, in microseconds over valid rows. W is reported as the statistics of the 147 10 per-process medians. 148 149 For each headline (H1, H3, H4) and each comparison CUDAPP vs PTXC, CUDAPP vs NVRTC: 150 151 - `CUDAPP_LOWER`: CUDAPP Q3 < other arm Q1; 152 - `CUDAPP_HIGHER`: other arm Q3 < CUDAPP Q1; 153 - `OVERLAPPING`: otherwise; 154 - `NO_VERDICT`: either arm is invalid (section 6), or the session is void. 155 156 No significance tests. Median ratios (other over CUDAPP) are descriptive. The same calls are printed for 157 H2, E and W, labelled descriptive. Results are published whichever way they come out, including every 158 case where CUDApp is higher. 159 160 ## 8. Caveats and disclosures 161 162 - Different builds: `ptxas` (inside NVRTC and nvPTXCompiler) runs an optimizing assembler and register 163 allocator over a general kernel description; CUDApp's builder lowers one fixed IR program for this one 164 kernel to 32 instructions (512 B). H1 compares those two build steps as each stack does them, not two 165 compilers of equal scope. 166 - Process spawn (`fork`/`exec` from Python, page-in) is in exec, firstResult and proc for every arm. The 167 binaries differ in size (`cs_ptxc` links the static PTX compiler, 38,394,840 B; `cs_cudapp` 168 1,405,168 B; `cs_nvrtc` 72,496 B plus the shared `libnvrtc` and `libcuda`), and that difference is part 169 of what E measures. 170 - PTXC and NVRTC load and run an identical cubin, so differences between them after build come from the 171 process (linked libraries), not from the code. 172 - The data and check phases are each stack's own transfers: CUDApp syncs host-mapped buffers, the 173 NVIDIA arms copy with `cuMemcpyHtoD`/`cuMemcpyDtoH`. firstResult includes them for all arms. 174 - One session, one machine, one date. The study measures GB10 under the stated load only. 175 - Pre-protocol pilot (before this file existed; the numbers came with the lane assignment, no raw rows 176 are filed): NVRTC fresh compile 290,679 / 138,026 / 137,686 us in three pilot runs, warm NVRTC builds 177 about 10.8 to 11.9 ms; CUDApp `hello_gpu --sim` kernel build 145 / 62 / 74 us (host, niced core; see 178 CUDApp branch `docs/hello-sim-receipt-date` `aa7b8771`, README section 9). They shaped the schedule 179 and are not results. 180 - Host build-only dry run (`run.py --dry-run`, 2026-10-29 21:57:16Z to 21:57:31Z, gap 0.02 s, no GPU 181 opened, scratch `/tmp/csb/dry`): EXERCISED, not results. Wolfram `csAnalyse[csRows, csWarm]` on its 182 `rows.wl` gave build medians CUDAPP 72.6085 us, PTXC 5919.412 us, NVRTC 139870.6725 us and warm-build 183 medians 5.184 / 3156.583 / 16345.90225 us. Its firstResult and proc stop at build (no GPU phases). 184 185 ## 9. Publication 186 187 `results/coldstart//`: `raw.jsonl` (every process, controls and warmups included), `session.json` 188 (pins, build.txt, controls, kthread cpus, quiet output, GPU apps before and after), `rows.wl`, 189 `code.*.bin`, `maps.*.txt`, the Wolfram query and output, and `RESULTS.md` with window id and times, 190 pins, controls, valid row counts, per arm median and IQR per metric, verdicts and void status. Evidence 191 label: MEASURED on this Spark in that window. Chip-only; never copied into `results/RESULTS.md`. 192 193 ## 10. Tooling 194 195 `cs_cuda.c`, `cs_cudapp.c`, `build.sh` and `run.py` are C, shell and Python measurement tooling, not 196 product code: the NVIDIA arms must call NVIDIA's C APIs, and `cs_cudapp.c` wraps CUDApp's own C example. 197 The Omega successor of the CUDApp arm is the native `.om` hello tracked in aien-dev/CUDApp#79. 198 199 ## 11. Amendments 200 201 None yet.