interplane.Get Omega
Read in your language

gpu-head-to-head

aien-dev/gpu-head-to-head

Brought by drakestapleton

branch main Branches Tags History

gpu-head-to-head / coldstart / PROTOCOL.md

201 lines · 13507 bytes Raw Blame History Source

PROTOCOL: cold start to first verified result, CUDApp vs NVIDIA user-space compile paths (GB10)

Predeclared before any measured GPU run. This file, the harness in coldstart/ and amendment A7 of the repo's PROTOCOL.md are committed and pushed before the GPU window opens. Any later change is a separate, dated commit listed in section 11, and results name the protocol commit they ran under.

This is a chip-level microbenchmark. The repo's PROTOCOL.md section 1 still holds: none of these numbers enters the main results table (results/RESULTS.md). They live in results/coldstart/ only.

1. Question

On one DGX Spark (GB10, sm_121), how long does a fresh process take from exec to its first verified GPU result when the kernel reaches the GPU through CUDApp's own path (its kernel builder and encoder, then its own ioctl/mmap calls on /dev/nvidiactl and /dev/nvidia0, no NVIDIA user-space library), compared with the NVIDIA user-space paths that compile a kernel at run time (NVRTC, or the PTX compiler library) and then load and launch it through libcuda?

2. Arms

ArmBinaryKernel description in the processBuild step (timed as build)GPU path
CUDAPPcs_cudappCUDApp examples/hello_gpu/hello_gpu.c build_vecadd (IR program)build_vecadd + omega_blackwell_kernel_encode_into: 512 B of machine codeCUDApp libomega_gpu.a session API (own nvrm ioctls)
PTXCcs_ptxccoldstart/vecadd.ptx, read into memory during prepstatic nvPTXCompiler (--gpu-name=sm_121): 5600 B cubinCUDA driver API, libcuda
NVRTCcs_nvrtcthe CUDA C++ string in cs_cuda.cnvrtcCompileProgram (--gpu-architecture=sm_121): 5600 B cubinCUDA driver API, libcuda

PTXC is the like-for-like arm against CUDAPP: both start from a device-level description and stop at loadable machine code. vecadd.ptx is NVRTC's own compute_121 PTX for the NVRTC source (build.sh checks that it is still byte-identical to what NVRTC emits), and PTXC's cubin is byte-identical to NVRTC's (sha256 691edc87423da8a86c5403d332bb980aa20f8808c84a0ffbf79481081c7dd6e8, 5600 B, observed with --build-only --emit-code after the section 3 build). So PTXC and NVRTC load and run the same code; they differ in the build step and in what the process links.

3. Pins and build

4. Job, phases, metrics

The job is hello_gpu's job at the pin: c = a + b over 1,048,576 floats, a[i] = i * 0.25, b[i] = 1 / (1 + i % 7), c poisoned with 0xFFC0FFEE, eight launches of 1024 blocks x 128 threads, then every element compared bit for bit with the CPU's own a[i] + b[i]. A process is correct only with wrong == 0 and unwritten == 0 (exit 0).

Phases, each closed by a CLOCK_MONOTONIC stamp inside the process:

PhaseCUDAPPPTXC / NVRTC
prephost inputshost inputs (PTXC: also reads vecadd.ptx)
buildkernel description to machine code in host memoryPTX or C++ to cubin in host memory
openomega_gpu_session_opencuInit, cuDeviceGet, cuDevicePrimaryCtxRetain, cuCtxSetCurrent
loadcode buffer allocated, words copied, synced to GPUcuModuleLoadData, cuModuleGetFunction
datathree buffers allocated, inputs and poison copied in and syncedcuMemAlloc x3, cuMemcpyHtoD x3
runeight launches, each waits for its completion markereight cuLaunchKernel, cuCtxSynchronize
checkoutput synced to CPU, bit-exact checkcuMemcpyDtoH, bit-exact check
closebuffers freed, session closedcuMemFree x3, cuModuleUnload, cuDevicePrimaryCtxRelease

The driver (run.py) stamps t0 just before Popen and t1 when the child has exited and its pipes are drained, on the same clock.

IDMetricDefinition (ns, reported in us)Role
H1buildbuild phaseheadline
H2readybuild + open + loaddescriptive: CUDA 13 defaults to lazy module loading (CUDA_MODULE_LOADING unset), so part of the NVIDIA arms' load work can move into run
H3firstResultexec + prep + build + open + load + data + run + checkheadline: spawn to verified result
H4proct1 - t0headline: spawn to process exit, close and teardown included
Eexect_main - t0: spawn, exec, dynamic linking, constructorsdescriptive
Wwarm buildper process, median of 10 further builds in a --build-only processdescriptive

5. Schedule (coldstart/run.py)

  1. Pre-checks (section 6), then the control processes of section 6, one per arm per control.
  2. 2 warmup rounds (each arm once per round, order CUDAPP, PTXC, NVRTC), not analysed.
  3. 30 measured rounds. Round r runs the arms in permutation r mod 6 of the 6 orders, so every order runs 5 times. 1 s sleep before every measured spawn. Measured processes run with --warm 0, so no per-process warm build sits inside their proc time.
  4. Warm phase W: 10 rounds under the same permutation rule and gap, each process --build-only (no GPU opened) with its 10 warm builds.
  5. Cap: 15 minutes from driver start. When it is reached the driver stops, writes what it has and the session verdict is INCOMPLETE_CAP.

Output: results/coldstart/<UTC run id>/{raw.jsonl,session.json,rows.wl}, plus the control artefacts code.<ARM>.bin and maps.<ARM>.txt. Every spawned process gets CUDA_CACHE_DISABLE=1.

Pinning: the driver runs on core 12 (Cortex-A725). Every arm process runs on one core, the first of 9, 8, 7 (Cortex-X925, A2) that hosts no nvidia-modeset kthread at driver start (field 39 of /proc/<pid>/stat); the core and the kthread cpus go into session.json.

6. Pre-checks, controls, validity

The driver refuses to start, before any process runs, when any of these fails:

Controls, all before the first measured process. Any failure makes the session verdict CONTROLS_FAILED and no measured process runs:

Validity of rows and arms (in coldstart/analysis.wl): a measured row is valid when its process was correct and load1 < 6 at its spawn. An arm is valid with at least 28 of its 30 measured rows valid.

Session validity: a session is VOID when its verdict is not MEASURED (CONTROLS_FAILED, INCOMPLETE_CAP, a refused pre-check), when the spark-window lease ran out before close (spark-window verdict NO VERDICT), or when the window's holder lost the chip lock during the run (for example a chip-watchdog kill posted on the BOARD). A void session is never retried inside the same window. It is re-run in a new window, and both sessions are published.

7. Statistics and verdicts

Computed by coldstart/analysis.wl (csAnalyse, with h2hStats of results/wolfram/analysis.wl) in the Wolfram MCP kernel on the run's rows.wl; query and output are kept beside the rows. Per arm and metric: n, median, Q1, Q3, IQR (Wolfram Median, Quantile with its default definition, InterquartileRange), p99 as a descriptive figure, in microseconds over valid rows. W is reported as the statistics of the 10 per-process medians.

For each headline (H1, H3, H4) and each comparison CUDAPP vs PTXC, CUDAPP vs NVRTC:

No significance tests. Median ratios (other over CUDAPP) are descriptive. The same calls are printed for H2, E and W, labelled descriptive. Results are published whichever way they come out, including every case where CUDApp is higher.

8. Caveats and disclosures

9. Publication

results/coldstart/<run>/: raw.jsonl (every process, controls and warmups included), session.json (pins, build.txt, controls, kthread cpus, quiet output, GPU apps before and after), rows.wl, code.*.bin, maps.*.txt, the Wolfram query and output, and RESULTS.md with window id and times, pins, controls, valid row counts, per arm median and IQR per metric, verdicts and void status. Evidence label: MEASURED on this Spark in that window. Chip-only; never copied into results/RESULTS.md.

10. Tooling

cs_cuda.c, cs_cudapp.c, build.sh and run.py are C, shell and Python measurement tooling, not product code: the NVIDIA arms must call NVIDIA's C APIs, and cs_cudapp.c wraps CUDApp's own C example. The Omega successor of the CUDApp arm is the native .om hello tracked in aien-dev/CUDApp#79.

11. Amendments

None yet.