omega-kernel-smoke
Minimal Omega GPU kernel smoke verification harness
Brought by drakestapleton
omega-kernel-smoke / README.md
| 1 | # omega-kernel-template |
| 2 | |
| 3 | Write a small kernel in [Omega](https://github.com/aien-dev/omega-mv), push, and get a receipt: |
| 4 | the same `kernel.om` compiled by the pinned Omega compiler, run **natively on AArch64** and as |
| 5 | **SPIR-V on PoCL's CPU OpenCL device**, and checked case by case against a Python reference. |
| 6 | It runs on GitHub's free `ubuntu-24.04-arm` runners. No GPU, no CUDA toolkit, no local install. |
| 7 | |
| 8 | ## Quickstart |
| 9 | |
| 10 | 1. Click **Use this template** → **Create a new repository** |
| 11 | (or: `gh repo create my-kernel --template aien-dev/omega-kernel-template --public --clone`). |
| 12 | 2. Edit `kernel.om`, and give each `fn` its expected answer in `reference.py` |
| 13 | (optional: pin your own inputs in `cases.tsv`). |
| 14 | 3. Commit and push. |
| 15 | 4. Open the run under **Actions**: the summary says PASS or FAIL per case, and the |
| 16 | `omega-kernel-receipt` artifact holds `receipt.json`, `kernel.spv`, the AArch64 disassembly and `SHA256SUMS`. |
| 17 | |
| 18 | ## What one run does |
| 19 | |
| 20 | | step | tool | where it runs | |
| 21 | |---|---|---| |
| 22 | | `kernel.om` → OSC IR | `omc`, the Omega compiler, fetched from aien-dev/omega-mv at a pinned commit and sha256 | runner CPU | |
| 23 | | IR → SPIR-V 1.0 OpenCL kernel | `irspirv.om`, the Omega SPIR-V translator, compiled by that same `omc` | runner CPU | |
| 24 | | validate | `spirv-val --target-env opencl2.1`; the translator must also be byte-for-byte deterministic | runner CPU | |
| 25 | | run SPIR-V | PoCL 7.2 CPU device (one work-item per case) | runner CPU | |
| 26 | | run native | `omc` compiles each case to an AArch64 Linux program | runner CPU | |
| 27 | | expected values | `reference.py` in CPython | runner CPU | |
| 28 | |
| 29 | A case passes when the AArch64 result equals `reference.py` **and** the SPIR-V result equals the |
| 30 | AArch64 result bit for bit (a trap must be the same trap on both). The check runs your `cases.tsv` |
| 31 | lines plus edge values and 32 seeded random inputs per `fn`, so the same commit always checks the |
| 32 | same cases. A wrong kernel fails: the branch |
| 33 | [`demo/wrong-kernel`](https://github.com/aien-dev/omega-kernel-template/tree/demo/wrong-kernel) |
| 34 | uses the textbook `(a + b) / 2`, which overflows `uint`, and its run is red. |
| 35 | |
| 36 | ## Honest scope |
| 37 | |
| 38 | - This is **CPU evidence**. SPIR-V runs on PoCL's CPU device, not on a GPU. Nothing here runs on a |
| 39 | GPU, emits sm_121 SASS, or uses the CUDA++ runtime; the receipt lists those as `not_run`. |
| 40 | - Kernels are scalar functions: integer types (`uchar ushort uint ulong byte short int long`) and |
| 41 | `bool`, at most 6 parameters, returning one of those or `void`, with `while … bound N` loops, |
| 42 | `if`/`else` and `trap N`. IR mode refuses `struct`, `global`, `text`, floats and host words |
| 43 | (error 9 or 3). The names `main` and `ir_dump` are reserved by the check. |
| 44 | - Each case is a separate kernel launch with one work-item; this is a correctness check, not a |
| 45 | speed test. |
| 46 | |
| 47 | ## Files you edit |
| 48 | |
| 49 | - `kernel.om`: your Omega functions. The demo has `avg` (overflow-free average), `gcd` and `clamp` |
| 50 | (which traps 3 on an empty range). |
| 51 | - `reference.py`: one Python function per `fn`, returning the exact answer, or `raise Trap(n)` where |
| 52 | the kernel runs `trap n`. Results must fit the return type; signed values are plain negative ints. |
| 53 | - `cases.tsv`: optional fixed inputs, one per line: `fn arg1 arg2 …` (decimal, `true`/`false`). |
| 54 | |
| 55 | ## Run it on your own AArch64 Linux machine |
| 56 | |
| 57 | Ubuntu 24.04 on arm64, from a clean checkout: |
| 58 | |
| 59 | ```sh |
| 60 | sudo apt-get install -y --no-install-recommends clang-18 libllvm18 libllvmspirvlib18.1 \ |
| 61 | ocl-icd-libopencl1 ocl-icd-opencl-dev spirv-tools curl |
| 62 | sh tools/fetch.sh |
| 63 | sh tools/check.sh |
| 64 | ``` |
| 65 | |
| 66 | `check.sh` exits 0 for PASS, 1 for FAIL and 3 for NOT_RUN (wrong platform or missing tool), and |
| 67 | writes `build/summary.md` and `build/receipt/`. On x86-64 it reports NOT_RUN: the native half |
| 68 | needs AArch64. |
| 69 | |
| 70 | ## Pins and receipts |
| 71 | |
| 72 | `toolchain.lock` pins the omega-mv commit, the sha256 of `omc`, `irspirv.om`, `opencl-host.c` and |
| 73 | `parity.py`, and the sha256 of the PoCL release asset. `tools/fetch.sh` refuses any file whose |
| 74 | hash differs. The PoCL asset is built from source on the same runner image by |
| 75 | `.github/workflows/toolchain.yml` and self-tested with the demo kernel before it is published. |
| 76 | `receipt.json` (schema `omega-kernel-receipt/1`) records the verdict, run URL, commit, pins, hashes |
| 77 | of the built translator, host, `kernel.ir` and `kernel.spv`, the Ubuntu package versions, the |
| 78 | OpenCL device PoCL reported, and every differing case. |
| 79 | |
| 80 | ## What is interim |
| 81 | |
| 82 | The kernel compiler and the SPIR-V translator are Omega. The glue around them is not yet: |
| 83 | |
| 84 | - `tools/fetch.sh` (POSIX sh + curl): successor is an Omega fetch-and-verify unit once seeded Omega |
| 85 | has an HTTPS word. |
| 86 | - `tools/check.sh` (POSIX sh): successor is an Omega conductor in the style of omega-mv |
| 87 | `seed/qualification/om2/gate.om`. |
| 88 | - `tools/cases.py` (Python) plans cases and writes the receipt; same Omega conductor successor. |
| 89 | `reference.py` stays Python on purpose: an oracle independent of `omc`. |
| 90 | - `opencl-host.c` and `parity.py` come from omega-mv `seed/spirv/`, where their status is tracked. |
| 91 | |
| 92 | ## Human-Directed Agentic Engineering |
| 93 | |
| 94 | Current and future development follows Human-Directed Agentic Engineering (HDAE): |
| 95 | humans define goals, architecture, constraints, acceptance criteria, and stopping |
| 96 | points; agents implement, execute checks, diagnose failures, and revise within |
| 97 | those boundaries. Human review retains responsibility for claims, acceptance, |
| 98 | and release decisions. This describes the development method, not kernel runtime |
| 99 | behavior or a retrospective claim about earlier receipts. |
| 100 | |
| 101 | For the documented method and a systems-software case study, see Gregory M. |
| 102 | Kurtzer (2026), [*Ginux: Building an Independent Kernel That Runs Linux Userspace |
| 103 | through Human-Directed Agentic Engineering*](https://doi.org/10.5281/zenodo.23682548). |
| 104 | |
| 105 | ## License |
| 106 | |
| 107 | Apache-2.0; see `LICENSE` and `NOTICE`. |