cuda-crack
I broke CUDA: GB10 sm_121 machine code without the CUDA toolkit - method, encoder tables, receipts
Brought by drakestapleton
cuda-crack / receipts / cudapp / evidence / CUDAPP-OM-ENCODER / README.md
| 1 | # CUDAPP-OM-ENCODER: the sm_121 encoder and the cubin packer in seeded Omega |
| 2 | |
| 3 | Status: IMPLEMENTED and EXERCISED on a Linux AArch64 host and on the GB10 (DGX Spark, sm_121) beside the |
| 4 | live model server. Draft, not merged. |
| 5 | |
| 6 | ## What changed |
| 7 | |
| 8 | | Piece | `.om` unit (default hosted build) | C body, now out of the default build | |
| 9 | |---|---|---| |
| 10 | | Instruction encoder + program NOP padding (`encode_single_insn`, `omega_bw_encode_program`) | `om/encoder/bw_enc_sm121.om` (515 lines) | `bw_c_encode_insn` in `src/omega_blackwell_codegen.c` (568 lines), built only for `OMEGA_GPU_NO_POSIX` and `CUDAPP_ENCODER=c\|diff` | |
| 11 | | Cubin ELF writer (`omega_cubin_pack`) | `om/cubin/cubin_elf.om` (523 lines) | `c_cubin_pack` and helpers in `src/omega_cubin.c` (337 lines), built only for `OMEGA_GPU_NO_POSIX`, `CUDAPP_MIGRATION_PENDING_C_CUBIN` and `CUDAPP_MIGRATION_PENDING_CUBIN_DIFF` | |
| 12 | |
| 13 | Both units are compiled by the pinned Omega compiler and linked through the omega-bridge native ABI v1 |
| 14 | binding that `om/units.sh` generates (`src/omega_om_units.c`, `src/omega_native.h`, |
| 15 | `src/omega_om_units.ident`; generated, checked byte for byte by `make test-om-units`). |
| 16 | |
| 17 | - omc: aien-dev/omega-mv `e5b32567a7aff3ce594e3254a622a846a6cd190b`, `seed/out/omc` sha256 |
| 18 | `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. |
| 19 | - omega-bridge: `431fff0a` (`om/omega-bridge.lock`), `src/native.om` sha256 |
| 20 | `c77a5922f91d53d4a0bbd4e7b1c4703f7098263abc843be2918db1ece7496782`. |
| 21 | - Constants: every literal in both units is the decimal form of the C hex word, converted with |
| 22 | Wolfram (`wolfram-constants.txt`, `../CUDAPP-OM-CUBIN/wolfram-constants.txt`). |
| 23 | - `cubin_elf.om` is a translation of `src/omega_cubin.c` only; nothing from omega-mv #864 (`cubin.om`, |
| 24 | on HOLD) was read (docs/ARCHITECTURE.md §6). |
| 25 | |
| 26 | Why the freestanding build keeps C: the bridge binding needs pthread and mmap, which the freestanding |
| 27 | allowlist refuses. Successor: a freestanding omega-bridge binding with a caller-supplied stack. |
| 28 | |
| 29 | ## Host evidence (Linux AArch64) |
| 30 | |
| 31 | | Command | Observed | |
| 32 | |---|---| |
| 33 | | `make test-om-encoder` (in `make test`) | `PASS: hosted golden-word fixtures through the .om encoder`; `encoder diff: .om and C byte-identical on 68 golden instructions and 14 fixture programs`; red check: a build that flips one bit after encoding aborts | |
| 34 | | `make test-om-encoder-corpus` | `encoder corpus: 243 distinct kernels identical .om vs C; diff build 559 program encodes and 32 single-instruction encodes, all SAME` (`host/corpus.log`, `host/corpus-diff.log`; `host/corpus-k-om.sha256` and `host/corpus-k-c.sha256` are equal, 243 lines) | |
| 35 | | `make test-om-encoder-mutants` | 3 of 3 mutant units red (dst shift 16→17, HMMA bf16 flag 262144→0, NOP control word +1): `golden words FAIL, dump vs C DIFFERS` | |
| 36 | | `make test-om-cubin` (in `make test`) | artifact tests through the .om packer (47 and 48 checks, 0 failed); `cubin diff: .om and C packers identical (code, bytes, message) on 869 calls`; red check aborts | |
| 37 | | `make test-om-cubin-mutants` | 3 of 3 mutant units red | |
| 38 | | `make test-om-units` | `PASS src/{omega_om_units.c,omega_native.h,omega_om_units.ident} regenerate byte for byte` | |
| 39 | | `make test-codegen-freestanding` | PASS; `codegen dumps byte-identical: 14 fixtures, 24448 code bytes` (hosted side .om, freestanding side C) | |
| 40 | |
| 41 | `test-om-units` and both mutant targets need the omc and omega-bridge checkouts (`OMEGA_MV=`, |
| 42 | `OMEGA_BRIDGE_DIR=`); without them they print NOT_RUN and exit 3. CI job `om-units` runs them on the |
| 43 | arm64 runner with pinned clones. |
| 44 | |
| 45 | Corpus note: at main `c30c0be6` the corpus target `sm121dis-corpus-bins` cannot build |
| 46 | `build/gpu_scan_test` (its files exist only on PR #112, branch `c3/gemm-scan` `8822da4e`). The corpus run |
| 47 | overlaid those files from `8822da4e` (blobs: `mk/c3.mk` 3d440dbd, `src/omega_numeric.c` 271f0027, |
| 48 | `src/omega_numeric.h` b3548189, `src/omega_numeric_reduce.c` 3dffadfe, `src/omega_numeric_reduce.h` |
| 49 | ac9cf9c9, plus that branch's `tests/gpu_{gemm,scan}_test.c`) and removed them afterwards. None of those |
| 50 | files are in this change. |
| 51 | |
| 52 | ## GB10 evidence (`chip-20261027T080240Z/`) |
| 53 | |
| 54 | Tree: `010abb1549c48a4be6d63da47101d393f76cb2dd` (+ documentation edits only). One hold of |
| 55 | `/tmp/aien-gb10.lock`, 45 s of GPU work, beside the live model server (compute apps before and after: |
| 56 | only the server; health ok both times, `health.txt`). The same programs ran from `build/` (the .om |
| 57 | encoder; `nm` shows `omega_blackwell_codegen.o` calls `omega_bw_enc_sm121`) and from `build-enc-c/` |
| 58 | (`CUDAPP_ENCODER=c`, `bw_c_encode_insn`): |
| 59 | |
| 60 | | Program | .om encoder | C encoder | |
| 61 | |---|---|---| |
| 62 | | `cudapp-doctor` | rc 0 | rc 0 | |
| 63 | | `hello_gpu` | PASS, 1048576 of 1048576 elements, 0 wrong | same | |
| 64 | | `hello_gpu_control --bug=short` (negative control) | rc 1, FAIL, 1 wrong 1 never written | same | |
| 65 | | `gpu_elementwise_test` | PASS 35 checks | same | |
| 66 | | `gpu_reconv_test` | PASS 235 checks | same | |
| 67 | | `gpu_decode_attn_test` | PASS 29 checks | same | |
| 68 | | `gpu_bf16_gemv_test` | PASS 12 checks | same | |
| 69 | | `gpu_router_test` | PASS 17 checks | same | |
| 70 | | `gpu_matmul_api_test` | PASS 97 checks | same | |
| 71 | |
| 72 | The 70 kernels the chip runs dumped (`OMEGA_KERNEL_DUMP_DIR`) hash identically between the two |
| 73 | builds (`kernels-om.sha256` = `kernels-c.sha256`). The timings in the logs are not an A/B measurement. |
| 74 | The cubin packer is host packaging; no chip program above loads a cubin. |
| 75 | |
| 76 | ## Not run / limits |
| 77 | |
| 78 | - Freestanding builds still use the C encoder and C packer (see above). |
| 79 | - Out of scope, still C: register allocation and the kernel builders, the QMMA byte patch, TC marks, |
| 80 | the inline emitters in `omega_gpu_attention_api.c` and `omega_gpu_elementwise_api.c`. |
| 81 | - The .om path refuses with MEM before validation on allocation failure and refuses images above |
| 82 | 128 MiB (omc arrays stop at 16777216 elements, error 23); the C path allocates them. |
| 83 | - Not QUALIFIED for serving: the live model server was not rebuilt or restarted. |