interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / docs / runtime / API.md

1112 lines · 92155 bytes Raw Blame History Rendered
1# Omega Runtime API v0
2
3Omega Runtime API version: 0.18.0
4
5Status: first written version, 2026-10-19 (slice R1, omega-mv#594, tracking #593). Source of truth is the C headers in
6`src/`. This file describes them; `docs/runtime/omega_runtime_api.manifest` lists them; `make test-runtime-api` checks the
7list against the headers (a host check, no GPU). Review state: reviewed by Opus 5.5 against the headers and the code on 2026-10-22 (L386); its findings are fixed
8in this version. The check proves the list and every quoted C signature match the headers; prose is checked by review.
9
10The version number lives in one header, `src/omega_runtime_api.h` (`OMEGA_RUNTIME_API_VERSION_MAJOR`, `_MINOR`, `_PATCH`).
11
12## 1. What this is
13
14Omega is a GPU compute runtime that does not use CUDA. This file is the written contract for the part a program calls
15directly: find and open the GPU, get memory, copy data in and out, run a kernel, run many kernels in one submission, run a
16packaged job, and read errors. GB10 is the historical device target. The Linux reference now also has
17an experimental sm_86 direct-driver path for GA102/GA104; both Ampere devices remain NOT_RUN.
18
19Compatibility preflight has two parts. `make doctor` checks the kernel-module version, the PCI target and the rest of
20the machine, and `make hello-gpu` runs it first. Since 0.14.0 the library also admits the GPU itself at device open:
21before `nvrm_open` opens any `/dev/nvidia` node it reads `/sys/bus/pci/devices`, and `om/admission/chip_admit.om`
22decides whether the GPU is one CUDA++ targets (GB10 `0x2e12` as sm_121; the prepared, NOT_RUN Ampere ids `0x2204`,
23`0x2486`, `0x2489` as sm_86). An unknown or unqualified PCI id is refused with one sentence naming the address and id,
24and no node is opened. `CUDAPP_GPU_BDF` (for example `000f:01:00.0`) picks one GPU when several are present; without
25it every NVIDIA display GPU must be a target. The driver's card list is checked again against the same decision before
26the device node opens, and the sm the driver's classes select must equal the admitted one. The driver-version check
27stays in the doctor only. Callers must not bypass the preflight or the operator's GPU authorization procedure.
28The M16 receipt imported here is a historical summary whose referenced raw logs
29are absent; it is not current-commit qualification (see README evidence limitation).
30
31How to read an entry:
32
33| Tier | Meaning |
34| --- | --- |
35| **STABLE** | Used by other code in the project, covered by chip results, and kept compatible under the rule in section 2. Has its own `####` section below. |
36| **EXPERIMENTAL** | Works and is listed, but may change in any minor version, because the design is still moving or only one use of it exists. Listed in tables with the reason. |
37| **INTERNAL** | Exists in a header for the project's own libraries or tests. Not part of the API; not in the manifest; may change or disappear any time. Every such name in a manifest header is listed, with a reason, in `docs/runtime/omega_runtime_api.internal` (section 10), so nobody builds on it by accident. |
38
39Every C signature in this file is copied from the header it names. `tools/runtime_api_check.sh` re-checks every quoted
40signature against the headers on every run.
41
42## 2. Version and compatibility rule
43
44The version is MAJOR.MINOR.PATCH (semantic versioning), currently **0.18.0**. It is a property of the list of entries and
45their behaviour, not of the library build. Changes so far:
46- 0.18.0: adds experimental seeded row softmax/layernorm/rmsnorm, ReLU/GELU/SiLU and implicit conv2d, a shared DNN storage-format contract, and native f16 inputs to any-shape attention. Native scalar f16 conversion is implemented in the seeded sm_121 encoder. Shape admission and kernel arithmetic are Omega; C execution entries are memory/session shells. Hardware qualification is NOT_RUN.
47- 0.17.0: adds experimental seeded-Omega arbitrary-shape f32/bf16 attention, `omega_gpu_attn_any`, with a CPU-only code-generation entry. Geometry, GQA and causal tails are decided in `om/attn-any/`; hardware qualification is NOT_RUN. Existing tuned model-shape entries are unchanged.
48- 0.16.0: adds experimental complete-access-set command-list recording and whole-program planning/submission. The seeded planner compares all outstanding dispatches, drains RAW/WAR/WAW hazards (including overlapping VA aliases), retains admission and completion ordering, and refuses programs that cannot fit one submission. Legacy recording/submission remains conservative.
49- 0.15.0: adds the EXPERIMENTAL random-number and FFT entries of section 9.10 (`src/omega_gpu_mathlibs_api.h`,
50 a new manifest header). The header already held the xoshiro256** generator and the complex FFT outside the manifest; it
51 now also has `omega_gpu_philox_generate` (Philox4x32-10, cuRAND's stream), `omega_gpu_fft_r2c`, `omega_gpu_fft_c2r`,
52 `omega_gpu_fft_c2c_nd` (2-D and 3-D) and `omega_gpu_fft_plan_walk`, and all of them enter the manifest together.
53 `omega_gpu_mathlibs_test_set_mutant` goes on the INTERNAL list. The same lane adds `omega_gpu_philox_generate_dist`
54 (cuRAND's uniform, uniform_double, uniform2_double and normal on Philox, any offset), `omega_gpu_fft_many` and
55 `omega_gpu_fft_many_walk` (cufftPlanMany layouts, any length 2..4096 by mixed radix 2/3/4/5/7 or Bluestein) with
56 `OmegaGpuFftMany`, `OmegaGpuFftManyLaunch` and their constants; `omega_gpu_fft_c2c`, `_r2c`, `_c2r` and `_c2c_nd`
57 now accept any length 2..4096 where they refused lengths that are not powers of two, and the callback of
58 `omega_gpu_fft_plan_walk` runs after the session lock is released. No existing entry changes otherwise.
59- 0.14.0: adds experimental `omega_runtime_api_version` in `omega_runtime_api.h`, which returns the
60 `OMEGA_RUNTIME_API_VERSION` the linked library was built at (section 9.9), and library admission at device open
61 (section 1): `nvrm_open`, under every session open, now refuses an unknown or unqualified PCI id, or a GPU the driver
62 reports with an sm other than the admitted one, with a sentence and without opening a `/dev/nvidia` node. A machine
63 that opened before still opens unless its GPU is not a CUDA++ target. Changed behaviour of existing entries while MAJOR
64 is 0, so MINOR.
65- 0.13.0: adds experimental `omega_gpu_prefill_attn256_scoped` in `omega_gpu_attention_mirror.h`. Mode 0 preserves ordinary attention; mode 1 copies the complete original 27B K/V into one GPU-private reusable buffer before attention; mode 2 uses the provisional Omega-selected 1024-row threshold. Omega checks geometry, bounds, allocation capacity and completed PREP/copy/ATTEND ordering. Other modes and unsupported mirrored shapes are refused. `copy_ns` reports copy chip time separately from the unchanged attention info layout; total call time includes allocation and copying. Existing host/device/recorded entries and defaults are unchanged. See `om/attention-mirror/README.md` for qualification status.
66- 0.12.0: adds experimental `omega_gpu_pf_qgemm_reading_option` with `(rows, index)`. The checked Omega policy returns the scoped rt, warps, wait and group values at indices 0..3, or UINT32_MAX for invalid input. This proposed adaptive profile uses 64 rows for requests at most 64 rows and 128 above that threshold. Callers obtain the checked height and use `omega_gpu_pf_qgemm_workspace_fits` to check existing row, padded-row and tile capacities before switching profiles. The query returns 1 only when all capacities cover the request; otherwise callers allocate a compatible workspace.
67- 0.11.0: adds experimental `omega_gpu_pf_qgemm_scoped` per-call options and the checked `omega_gpu_pf_qgemm_scoped_bm` tile-height query. Explicit calls neither read nor modify process-global tuning knobs. Tile storage must use the queried height; actual projection dimensions are validated on every call.
68- 0.10.0: adds the experimental `omega_gpu_pf_qgemm_set_group` selector. Existing entry signatures and the default execution order are unchanged.
69- 0.9.0 (AmperePort, CUDApp#170): grows STABLE `OmegaGpuLaunch` with `target_sm` (a MAJOR-class change
70 taken as MINOR under the major-version-zero rule); adds EXPERIMENTAL
71 `omega_gpu_session_target_sm`. Zero-initialized legacy launches still mean sm_121, not auto-detect.
72 An explicit sm_86 launch must match the opened device and use sm_86 code and argument layout.
73 Adds discrete VRAM allocation/BAR-mapped visibility and a VRAM-based D1 reserve;
74 no Ampere hardware qualification is claimed. See `docs/PORT-AMPERE.md`.
75- 0.8.0 (CUDApp#139): adds the EXPERIMENTAL general matrix multiply of section 9.8 (`src/omega_gpu_gemm_ex.h`:
76 `omega_gpu_gemm_ex`, `omega_gpu_gemm_ex_fp8_block_rows`, `OmegaGemmExArgs`, `OmegaGemmExInfo` and their constants),
77 and two of its test hooks to the INTERNAL list. **Layout change:** `OmegaGpuFp8GemmInfo` (EXPERIMENTAL, section 9.7)
78 grows from 80 to 88 bytes with the new field `general` at offset 80 (1 when the call took the general fallback for a
79 shape the tuned kernel refuses); a caller built against the 0.7.0 layout must be rebuilt. `OmegaGpuFp8Info` gains the
80 same field at offset 156, inside existing padding, so it stays 160 bytes. `omega_gpu_fp8_general_rows` goes on the
81 INTERNAL list. The struct is EXPERIMENTAL, so the size change is MINOR under the rule below.
82- 0.7.0 (omega #588, carried with the b5ab3fe sync): adds EXPERIMENTAL `omega_gpu_decode_graph_abort_token`, which
83 releases the session lock and leaves the token without submitting what was recorded. A failed `begin_token` now
84 releases the lock itself, and `omega_gpu_decode_graph_token` answers every begin failure (not only BAD_ARGS) without
85 holding the lock (`tests/test_omega_gpu_decode_graph_abort.c`, 5 mutants in `make test-gpu-decode-graph`).
86- 0.6.0 (AttnGeneral): adds EXPERIMENTAL `omega_gpu_attention_general`, `OmegaGpuAttnGeneralDesc`,
87 `OMEGA_GPU_ATTN_GENERAL_MAX_HEAD_DIM` (256), `OMEGA_GPU_ATTN_GENERAL_MAX_Q_HEADS` (1024) and `OMEGA_GPU_ATTN_WINDOW_NONE`:
88 one attention kernel for every head_dim 1..256, any query-head count with any kv-head count dividing it (MHA, GQA,
89 MQA), causal, non-causal and sliding-window masks, strided f32 or bf16 KV, any kv_len. The existing attention entries
90 keep their tuned kernels for the shapes they took and now run the general kernel for the shapes they refused
91 (head_dim other than 64 / 128, non-power-of-two GQA, more than 64 query heads, contexts past 4096); the paged
92 entries do the same without the context split. Five test hooks and the general mutant ids go on the INTERNAL list.
93- 0.5.0: adds EXPERIMENTAL `omega_gpu_cmdlist_submit_pair`, `omega_gpu_cmdlist_wait_for`,
94 `OmegaGpuCmdListOpts.first_barrier_none`, `omega_gpu_session_extra_queue` (streams, C4) and `omega_gpu_session_recover`,
95 `omega_gpu_session_recoveries` (recovery after a latch, C5), carried from omega-mv e5b32567 by CUDApp#121; two
96 module-to-session hooks go on the INTERNAL list (section 10). Also adds EXPERIMENTAL `omega_gpu_fp8_grouped_ctas_rule`
97 and `omega_gpu_fp8_grouped_ctas_auto` (section 9.7) and INTERNAL `OMEGA_GPU_SM_COUNT`.
98- 0.4.0: `OMEGA_GPU_HANDLE_SLOTS` 1024 -> 4096 and `OMEGA_GPU_CMDLIST_MAX_LAUNCHES` 2048 -> 4096 (STABLE constants), and
99 so `OmegaGpuHandleTable` (EXPERIMENTAL) grows to 69648 bytes: the values the live server (omega-mv 6de999da, carried by
100 CUDApp#120) was built with. A MAJOR-class change, taken as MINOR under the major-version-zero rule below. Also adds the
101 carried decode-path calls of section 9.7 (FP8 knobs and quantiser, record-into-command-list forms, router row batching)
102 as EXPERIMENTAL, and six more names to the INTERNAL list.
103- 0.3.0: adds the EXPERIMENTAL decode-path entries of section 9.7 and their result codes; no STABLE entry changed.
104- 0.2.0: adds `OMEGA_RUNTIME_API_VERSION_PATCH`, lists `OMEGA_RUNTIME_API_VERSION` in the manifest and the INTERNAL list
105 (section 10); no entry changed.
106
107**A PATCH bump (0.5.0 to 0.5.1) is for:**
108- a fix that changes no manifest entry: a STABLE function that did not do what this file says now does (the fix makes it
109 match), or a correction to this file's prose.
110
111**A MINOR bump (0.5 to 0.6) is allowed to:**
112- add a function, a constant, an enum value at the end of an existing enum, or a new struct;
113- add an EXPERIMENTAL entry, change or remove an EXPERIMENTAL entry, or move an entry from EXPERIMENTAL to STABLE;
114- add a new failure name for the same call to report (callers must treat an unknown failure code or stage text as a failure).
115
116**From 1.0 on it needs a MAJOR bump (1.x to 2.0) to:**
117- remove or rename a STABLE function, struct, field or constant;
118- change a STABLE function's argument or return types, a STABLE struct's size, field order or field offsets, or the value
119 of a STABLE constant or enum value;
120- change documented behaviour of a STABLE entry: what the lock covers, what a latch does, which buffers get parked, what
121 a return value means;
122- move a STABLE entry down to EXPERIMENTAL or INTERNAL;
123- raise the platform contract's major number (section 9.2).
124
125**Major version zero** (semantic versioning 2.0.0, item 4: "anything MAY change at any time"): while MAJOR is 0, a change
126from the MAJOR list above needs a MINOR bump (0.5 to 0.6) plus its line in the change list above and in the manifest;
127MAJOR is reserved for the first break after 1.0. It still never goes unbumped: a STABLE change with no bump fails the
128check. STABLE in 0.x means "written down and checked", not "frozen". The first 1.0 will be cut only when section 8 (what
129v0 does not have) has been looked at again.
130
131How it is enforced (all host checks, no GPU; CI job `runtime-api`, `.github/workflows/runtime-api.yml`):
132- `make test-runtime-api` (`tools/runtime_api_check.sh`): a header change that moves any listed entry fails until the
133 manifest line is edited on purpose (`tools/runtime_api_check.sh --bless` refreshes the numbers; the diff is reviewed). A
134 function, macro or enumerator added to a manifest header fails until it is listed in the manifest or in the INTERNAL list
135 with a reason. The version macros, the manifest's `abi` line and consts, and the `Omega Runtime API version:` line in this
136 file must agree.
137- `make test-runtime-api-semver` (`tools/runtime_api_semver.sh`, base `origin/main` by default; CI uses the pull request's
138 base): compares the manifest with the base's entry by entry and fails when the change needs a bigger bump than it has,
139 or when the version goes down. Constants count as STABLE unless their manifest line carries `# EXPERIMENTAL`. While the
140 base's MAJOR is 0, a MAJOR-class change passes with a MINOR bump (the rule above); once the base is 1.x it needs MAJOR.
141- What stays a review duty: a change of documented behaviour with no entry change (the script cannot see prose), and the
142 limits listed in section 11.
143
144The platform contract has its own number (`OMEGA_GPU_PLATFORM_ABI_MAJOR` 1, `OMEGA_GPU_PLATFORM_ABI_MINOR` 2, set in
145`src/omega_gpu_platform.h`). A platform minor bump needs at least a runtime MINOR bump; a platform major bump needs a runtime MAJOR bump.
146
147## 3. How the pieces fit (plain English)
148
149**Device and platform.** Omega talks to the GPU through a small "platform" layer: a table of services (a clock, a lock,
150device-visible memory, a submission queue, a way to poll for completion). Today one platform exists, the Linux reference
151(`src/omega_gpu_platform_linux.c`), which uses NVIDIA's open kernel driver. The contract is written so a second backend
152(WSL2 on Windows, or AIENOS with no Linux driver) can fill the same table. A program normally never touches the platform:
153the first call that needs the GPU installs the Linux reference by itself. There is **one device, one channel per process**.
154There is no call to ask the device its name, SM count or memory size yet (section 8).
155
156**Memory.** You ask the session for a buffer and get an `OmegaGpuMem`: a handle, a CPU pointer, a GPU address and a size.
157Every ordinary buffer is GPU-uncached, because the CPU writes inputs the chip reads and polls markers the chip writes.
158You make CPU writes visible to the GPU with `omega_gpu_session_sync_to_gpu` and GPU writes visible to the CPU with
159`omega_gpu_session_sync_to_cpu`. Code (the machine code of a kernel) lives in a separate kind of buffer
160(`omega_gpu_session_alloc_code`): the CPU writes it once, the GPU only executes it. Handles carry a generation number, so a
161handle from a closed device or an already freed buffer is refused instead of silently reused. A buffer you mean to reuse and
162grow, such as staging space, can be an `OmegaGpuScratch`. For read-only weights there is a GPU-cached allocation
163(`omega_gpu_session_alloc_cached`, EXPERIMENTAL). There is no async copy and no unified memory in v0.
164
165**Launch.** One kernel launch is an `OmegaGpuLaunch`: where the code is, how many registers, the block and grid size, the
166argument words, shared memory, and a timeout. `omega_gpu_session_launch` submits it and waits for the chip to finish (it
167is synchronous). The wait is by polling a completion word, never by an interrupt.
168For sm_86, set `OmegaGpuLaunch.target_sm = 86` and use the target-aware encoder in
169`omega_ampere_codegen.h`. `target_sm = 0` preserves legacy sm_121 behavior; it is
170not permission to run Blackwell code on Ampere. A target mismatch refuses before
171submission. Existing Blackwell library kernels and command-list packets are not
172silently retargeted; unsupported Ampere packets are refused.
173
174**Command lists.** `omega_gpu_cmdlist_*` records many launches and submits them as one unit with one completion wait. By
175default each launch is preceded by a barrier so dependent launches cannot overlap; a launch can be marked independent.
176EXPERIMENTAL: streams, events and dependency-ordered execution are being built on top of it (omega-mv#580), so its options
177and statistics will grow.
178
179**Module load.** There is no module or fat-binary loader in v0, and no PTX or JIT: the program brings the machine code.
180Loading a kernel is `omega_gpu_session_alloc_code` (section 5) plus a CPU copy of the code into `code.cpu`; the launch then
181names `code.va`. The project's own kernels come from its encoder (`src/omega_blackwell_*`, INTERNAL), and
182`examples/hello_gpu` shows the whole path. A loader that reads a packaged module is section 8 work.
183
184**Streams and events.** EXPERIMENTAL since 0.5.0, and only on command lists: `omega_gpu_session_extra_queue` opens a
185second queue (behind `AIEN_OMEGA_GPU_CHANNELS=2`), `omega_gpu_cmdlist_submit_pair` submits two lists on two queues before
186waiting for either, `omega_gpu_cmdlist_wait_for` makes one list wait for a launch of the other, and
187`OmegaGpuCmdListOpts.first_barrier_none` drops the leading barrier. There is no stream or event object, and
188`omega_gpu_session_launch` still returns only when the chip has finished. Chip qualification is CUDApp#113; the `.om`
189successor is tracked in CUDApp#115.
190
191**Job engine.** `omega_gpu_execute` runs one already-built job (today only a 1-D vector job: two inputs, one output) through
192named states and returns success or exactly one named failure. EXPERIMENTAL.
193
194**Errors, the latch and parked buffers.**
195- A failing call returns a non-zero value and names its stage in text: `omega_gpu_session_last_error()`. A device-open failure
196 carries the driver's own text. Do not read a bare return code as the cause.
197- If the chip's completion cannot be confirmed (a completion wait ran out of time, the completion poll was refused, or a launch was cancelled after submit),
198 the work may still be running and still be reading or writing your buffers. The process then **latches**:
199 `omega_gpu_session_is_blocked()` returns 1 for the rest of the process, every later launch is refused, close and reopen are
200 refused, and nothing is returned to the platform.
201- After the latch, every buffer freed through `omega_gpu_session_free` is **parked**: kept allocated, counted by
202 `omega_gpu_session_parked`, never released. Handles stay valid for inspection (`omega_gpu_session_is_parked`).
203- Today there is no way back from a latch except ending the process. Recovery is open work (omega-mv#518).
204
205**Threads.** One process-wide lock (the platform LOCK service, lock id `OMEGA_GPU_SESSION_LOCK_ID`, which is 0). A call
206sequence that touches the device (open, alloc, launch, readback) is done between `omega_gpu_session_lock()` and
207`omega_gpu_session_unlock()`. Threads therefore take turns on the one channel. The Linux reference lock is a plain
208(non-recursive) pthread mutex (`locks[id]`, `src/omega_gpu_platform_linux.c:29` and `:119`), so taking it twice from one thread
209deadlocks. These take the lock themselves and must be called without it: `omega_gpu_session_close`, `omega_gpu_cmdlist_create`,
210`omega_gpu_cmdlist_free`, and every library call of section 9.5 (matmul, elementwise, attention, serving).
211`omega_gpu_session_cancel` may be called from any thread without the lock (header). `omega_gpu_session_is_blocked` reads the latch with an atomic load (`src/omega_gpu_session.c:157`), so it is safe without the lock too.
212`omega_gpu_session_last_error` returns a pointer into one process-wide text buffer: read it under the lock, before the next call.
213
214### 3.1 A minimal sequence (sketch)
215
216```c example
217omega_gpu_session_lock();
218OmegaGpuSession *s = omega_gpu_session_open(); /* NULL: see omega_gpu_session_last_error() */
219OmegaGpuMem in, code;
220omega_gpu_session_alloc(bytes, &in); /* GPU-uncached data buffer */
221omega_gpu_session_alloc_code(code_size, &code); /* write the machine code to code.cpu */
222omega_gpu_session_sync_to_gpu(&in);
223OmegaGpuLaunch L = { .code_va = code.va, .timeout_ms = 1000, /* gpr_count, threads_*, grid_*, args, n_args ... */ };
224uint64_t elapsed_ns = 0; uint32_t marker = 0; /* launch adds to elapsed_ns: start it at 0 */
225int rc = omega_gpu_session_launch(&L, &elapsed_ns, &marker);
226omega_gpu_session_sync_to_cpu(&in);
227omega_gpu_session_free(&in);
228omega_gpu_session_unlock();
229```
230
231This is a shape sketch, not a worked example (the worked example is slice R2).
232
233## 4. Session: device, lock and state
234
235#### `omega_gpu_session_lock`
236STABLE: used by every library API and chip-proven; the lock model is the documented one.
237```c
238void omega_gpu_session_lock(void);
239```
240Takes the process-wide session lock (platform LOCK service, id `OMEGA_GPU_SESSION_LOCK_ID`). Does not touch the device.
241With no platform installed it does nothing, and the open that follows refuses.
242
243#### `omega_gpu_session_unlock`
244STABLE: pairs with the lock.
245```c
246void omega_gpu_session_unlock(void);
247```
248
249#### `omega_gpu_session_open`
250STABLE: used by every library API and chip-proven. Treat the returned pointer as "the device is open"; the fields of
251`OmegaGpuSession` are EXPERIMENTAL (the session's own launch buffers) and a caller needs none of them.
252```c
253OmegaGpuSession *omega_gpu_session_open(void);
254```
255Caller holds the lock. Opens the device on first use. Returns NULL when the process is latched, no platform is installed or the
256open failed; the stage is in `omega_gpu_session_last_error()`.
257
258#### `omega_gpu_session_target_sm`
259EXPERIMENTAL: physical target selection for the prepared Ampere path; device qualification is NOT_RUN.
260```c
261uint32_t omega_gpu_session_target_sm(void);
262```
263Caller holds the lock. Returns the opened device's exact target (`86` or `121`),
264or zero with no open device. It does not open a device.
265
266#### `omega_gpu_session_is_open`
267STABLE: simple state query.
268```c
269bool omega_gpu_session_is_open(void);
270```
271
272#### `omega_gpu_session_is_blocked`
273STABLE: the latch query that every caller needs.
274```c
275int omega_gpu_session_is_blocked(void);
276```
277Returns 1 once an uncertain completion has latched this process, else 0. Any thread.
278
279#### `omega_gpu_session_close`
280STABLE: the only way to close the device; its refusal after a latch is part of the error model.
281```c
282void omega_gpu_session_close(void);
283```
284Closes the device and frees every session buffer. **Takes the lock itself.** Refused (a no-op) after an uncertain completion.
285The next open reopens; every handle of the closed device is stale from then on.
286
287#### `omega_gpu_session_open_count`
288STABLE: diagnostic with a fixed meaning.
289```c
290uint32_t omega_gpu_session_open_count(void);
291```
292Device opens so far in this process (a persistent session shows 1).
293
294#### `omega_gpu_session_set_spin_us`
295STABLE: used by sovereign-core's binding; fixed meaning and limit.
296```c
297int omega_gpu_session_set_spin_us(uint32_t us);
298```
299Process-wide marker-poll spin window, used by every launch whose own `spin_us` is 0. 0 (the default) keeps the platform's
300sleep-poll. Returns 0 on success, -1 above `OMEGA_GPU_SESSION_MAX_SPIN_US` (setting unchanged).
301
302#### `omega_gpu_session_spin_us`
303STABLE: reads the setting above.
304```c
305uint32_t omega_gpu_session_spin_us(void);
306```
307
308## 5. Session: memory
309
310All allocation calls need the caller to hold the lock with the device open.
311
312#### `OmegaGpuMem`
313STABLE: the buffer type every API passes around.
314A device buffer: a typed handle, its kind, the CPU view, the GPU virtual address and the size. A `cpu` of NULL means there is no CPU view.
315
316| Field | Meaning (from `src/omega_gpu_session.h`) |
317| --- | --- |
318| `handle` | `OmegaGpuBufferHandle`: index and generation |
319| `kind` | `OMEGA_GPU_HANDLE_BUF_DATA`, `_BUF_CODE` or `_BUF_QUEUE` |
320| `cpu` | CPU view |
321| `va` | GPU virtual address |
322| `size` | bytes of both views |
323
324#### `OmegaGpuBufferHandle`
325STABLE: a field of `OmegaGpuMem`, so its layout is part of it.
326`{ uint32_t index; uint32_t generation; }`. Generation 0 is never issued, so a zeroed handle means "none".
327A handle is valid only while its slot generation matches; a closed handle is refused.
328
329#### `OmegaGpuDeviceHandle`
330STABLE: same shape and rule as the buffer handle; named in the platform contract.
331`{ uint32_t index; uint32_t generation; }`.
332
333#### `OmegaGpuQueueHandle`
334STABLE: same shape and rule as the buffer handle; named in the platform contract.
335`{ uint32_t index; uint32_t generation; }`.
336
337#### `omega_gpu_session_alloc`
338STABLE: the ordinary buffer call, used by every library.
339```c
340int omega_gpu_session_alloc(size_t bytes, OmegaGpuMem *out);
341```
342A GPU-uncached DATA buffer, CPU and GPU read/write, rounded up to a page. Returns 0 on success; non-zero with the stage named on
343failure (the driver can refuse, for example with no memory; the refusal is counted in `OmegaGpuAllocStats.alloc_failures`).
344
345#### `omega_gpu_session_alloc_code`
346STABLE: the only way to place kernel code; chip-proven.
347```c
348int omega_gpu_session_alloc_code(size_t code_size, OmegaGpuMem *out);
349```
350A CODE buffer (CPU writes, GPU executes, GPU never writes) for `code_size` bytes plus the 2 KB instruction-prefetch tail
351(`src/omega_gpu_code_alloc.h`), the tail zero-filled. The caller writes the code to `out->cpu`. A size of 0 still gets one page (`omega_gpu_code_alloc_bytes` rounds up to at least one page).
352
353#### `omega_gpu_session_free`
354STABLE: the release call; its latch behaviour is part of the error model.
355```c
356void omega_gpu_session_free(OmegaGpuMem *m);
357```
358Releases `m` to the platform and zeroes `*m`. **Latched: `m` is parked instead (never released).** A stale handle (from a
359closed device) or a closed session is refused: nothing is released, the refusal is counted
360(`OmegaGpuAllocStats.stale_refusals`) and `*m` is zeroed.
361
362#### `omega_gpu_session_sync_to_gpu`
363STABLE: the visibility rule for CPU writes.
364```c
365int omega_gpu_session_sync_to_gpu(const OmegaGpuMem *m);
366```
367Makes CPU writes to the whole buffer visible to the device (platform SYNC). Returns 0, also for a buffer with no CPU view;
368-1 with the stage named when refused or when there is no device.
369
370#### `omega_gpu_session_sync_to_cpu`
371STABLE: the visibility rule for GPU writes.
372```c
373int omega_gpu_session_sync_to_cpu(const OmegaGpuMem *m);
374```
375Makes device writes to the whole buffer visible to the CPU. Same return values as `sync_to_gpu`.
376
377#### `OmegaGpuScratch`
378STABLE: the staging-buffer type the library APIs use.
379A caller-owned staging buffer that grows to its high-water mark: `mem` (an `OmegaGpuMem`), `cap` (usable bytes), `high_water`
380(largest request so far) and `reserved` (a serving reservation is active, see `omega_gpu_session_scratch_reserve`).
381Zero-initialise it before first use. This is required: `omega_gpu_session_scratch` reads `reserved`, `cap`, `mem.cpu` and
382`high_water` before it writes them (`src/omega_gpu_session.c:290-296`).
383
384#### `omega_gpu_session_scratch`
385STABLE: used by every library API.
386```c
387int omega_gpu_session_scratch(OmegaGpuScratch *s, size_t bytes);
388```
389Makes `s->mem` at least `bytes` long (reallocated when it grows; **contents are not kept**). Returns 0 or -1; with a
390reservation active, a request past the reserved size returns `OMEGA_GPU_SESSION_SCRATCH_RESERVED` (-2) and allocates nothing.
391
392#### `omega_gpu_session_scratch_free`
393STABLE: the matching release.
394```c
395void omega_gpu_session_scratch_free(OmegaGpuScratch *s);
396```
397
398#### `OmegaGpuAllocStats`
399STABLE: used by sovereign-core's binding to show that serving asks the driver for nothing.
400Counters of driver allocations made through `omega_gpu_session_alloc` since the process started: `allocs`, `alloc_bytes`
401(page-rounded), `alloc_failures`, `frees`, `stale_refusals`. Covers the session layer only.
402
403#### `omega_gpu_session_alloc_stats`
404STABLE: reads the counters above.
405```c
406void omega_gpu_session_alloc_stats(OmegaGpuAllocStats *out);
407```
408
409## 6. Session: launch
410
411#### `OmegaGpuLaunch`
412STABLE: the launch descriptor; chip-proven by every library.
413One launch: a kernel already resident at `code_va`, argument words for constant bank 0 at 0x380 (buffer addresses, then
414parameters), and the grid.
415
416Argument layout and the checks `omega_gpu_session_launch` makes (`src/omega_gpu_session.c:433-446`):
417- a 64-bit GPU address takes two words, the low word first, then the high word;
418- `n_args` is 1 to `OMEGA_GPU_SESSION_MAX_ARGS`, `args` is not NULL, and `threads_x`, `grid_x` and `grid_y` are not 0 (a
419 `threads_y` of 0 means 1); otherwise the launch is refused with "launch arguments" and nothing runs;
420- `gpr_count` is rounded up to a multiple of 8, and to at least 64;
421- `elapsed_ns` is added to, not set: start it at 0.
422What the kernel itself may read in constant bank 0 besides these words, and where GB10 machine code comes from, is slice
423R2 (`examples/hello_gpu`, README "Run your first kernel").
424
425| Field | Meaning (from `src/omega_gpu_session.h`) |
426| --- | --- |
427| `code_va` | GPU address of the kernel code |
428| `gpr_count` | registers the QMD (the launch descriptor the hardware reads) declares; multiple of 8, at least 64 in practice |
429| `threads_x`, `threads_y` | block size |
430| `grid_x`, `grid_y` | grid size |
431| `num_elements` | QMD config num_elements (kept per API for identical words) |
432| `args`, `n_args` | `n_args` words written at constant bank + 0x380; `n_args` at most `OMEGA_GPU_SESSION_MAX_ARGS` (32) |
433| `timeout_ms` | one absolute submission-wide deadline covering queue submission, spin and both markers; completion at or after it is uncertain and **the process latches**. 0 is refused with "launch arguments"; an unrepresentable nanosecond deadline is refused with "launch watchdog deadline overflow" before submission |
434| `shared_bytes` | shared memory per block, rounded up to 128 bytes; 0 = the default (1024). At most `OMEGA_BW_QMD_MAX_SHARED_BYTES` (32768: the SM-config target the QMD declares); one byte more is refused before any device work |
435| `spin_us` | spin-poll window before the platform's sleep-poll; 0 = the process-wide setting |
436
437#### `omega_gpu_session_launch`
438STABLE: the single-kernel launch; chip-proven.
439```c
440int omega_gpu_session_launch(const OmegaGpuLaunch *L, uint64_t *elapsed_ns, uint32_t *marker_out);
441```
442Caller holds the lock, device open, not latched. Submits one launch and polls for both completion markers, so it returns when
443the chip is done. 0 on success; -1 with the stage named on failure; `OMEGA_GPU_SESSION_CANCELLED` (-3) when a cancel request
444was seen. A marker timeout latches the process. `elapsed_ns` (submit to second marker) is added to when the pointer is given;
445`marker_out` receives the first marker word observed.
446
447The deadline and acknowledged recovery decisions are implemented in
448`tools/c5/policy.om` and `tools/c5/runtime.om`, with import-free generated
449bindings. `CUDAPP_MIGRATION_PENDING_C_SESSION_TIMEOUT=1` selects the old
450per-marker timing only as a differential oracle; the default is OFF. Host
451fake-RM and deterministic channel-model coverage is described in
452[`tools/c5/README.md`](../../tools/c5/README.md). This does not replace the
453hardware receipt required to qualify the changed timeout path.
454
455## 7. Session: errors, the latch, parked buffers
456
457#### `omega_gpu_session_last_error`
458STABLE: the error-model entry point.
459```c
460const char *omega_gpu_session_last_error(void);
461```
462The stage of the most recent failure, `""` if none. Shared by every API. Points into one process-wide buffer: read it under
463the lock, before the next call.
464
465#### `OmegaGpuParkStats`
466STABLE: the parked-buffer report.
467`buffers` (parked, listed plus untracked), `untracked` (parked past the listed `OMEGA_GPU_SESSION_PARK_MAX` = 512) and
468`bytes`.
469
470#### `omega_gpu_session_parked`
471STABLE: how a caller sees what the latch kept.
472```c
473void omega_gpu_session_parked(OmegaGpuParkStats *out);
474```
475Buffers parked after an uncertain completion: kept allocated, never returned to the platform. The session's own launch
476buffers (ring, constant bank, marker, QMD page) are parked at the latch and every later free parks too.
477
478#### `omega_gpu_session_is_parked`
479STABLE: per-handle form of the above.
480```c
481int omega_gpu_session_is_parked(OmegaGpuBufferHandle h);
482```
4831 if this handle is parked and listed.
484
485## 8. Not in v0 (so nobody assumes it)
486
487Each line is a gap named in `docs/runtime/ROADMAP.md` section 1 (on branch `runtime/roadmap`, not yet merged); none of it is in the manifest.
488- A device query (name, SM count, memory): there is no API call for it.
489- More than one device in a process (a second channel in the same group is `omega_gpu_session_extra_queue`, EXPERIMENTAL); sharing the GPU between processes (a second channel failed under load: omega-mv#523).
490- Recovery after a latch beyond `omega_gpu_session_recover` (EXPERIMENTAL since 0.5.0: throw the device away and open a
491 new one in the same process; a driver teardown fault still ends GPU use for the process).
492- Async copy, stream and event objects, host callbacks (0.6.0 has only two-queue submission and cross-queue waits on command lists, EXPERIMENTAL).
493- Cached read-write buffers; unified memory.
494- Launches with more than the 32 argument words, or an asynchronous single launch.
495- A second real backend (WSL2 `/dev/dxg` is on branch `rig/gb20x`; native AIENOS is planned), so the platform contract has only been exercised by one.
496
497## 9. EXPERIMENTAL entries
498
499Listed in the manifest, may change in any minor version. Signatures are in the manifest and the headers; the names are
500checked there. The reason is why each is not STABLE yet.
501
502### 9.1 Session extras (`src/omega_gpu_session.h`, `src/omega_gpu_mem_cached.h`)
503
504| Entry | Reason it is EXPERIMENTAL |
505| --- | --- |
506| `omega_gpu_session_alloc_cached` | GPU-cached memory is correct only for write-once, never-polled, GPU-read-only weights; the API cannot enforce that (the caller must). |
507| `omega_gpu_session_scratch_reserve`, `omega_gpu_session_scratch_unreserve` | Serving-daemon feature (no driver call after warm-up); one user. |
508| `omega_gpu_session_cancel` | A cancel after submit cannot stop the chip: it latches the process. Semantics may tighten when recovery (#518) lands. |
509| `omega_gpu_session_extra_queue` | A second GPFIFO channel in the same group, only with `AIEN_OMEGA_GPU_CHANNELS` > 1 at open; one backend, chip qualification in CUDApp#113. |
510| `omega_gpu_session_recover`, `omega_gpu_session_recoveries` | Recovery after a latch (omega-mv#518, C5): closes and reopens the device in-process; every old handle and list goes stale. Chip qualification in CUDApp#119. |
511| `omega_gpu_session_set_platform`, `omega_gpu_session_platform`, `omega_gpu_session_submit_prefix_words`, `omega_gpu_session_completion_mode`, `omega_gpu_session_now_ns` | Tied to the platform contract, which has one real backend. |
512| `omega_gpu_host_alloc`, `omega_gpu_host_calloc`, `omega_gpu_host_free` | CPU-only memory from the platform HOST_MEM service; the freestanding build needs them, hosted code can use malloc. |
513| `OmegaGpuSession` | The session's own launch buffers; a caller needs none of its fields. |
514
515### 9.2 Platform contract (`src/omega_gpu_platform.h`, ABI 1.2)
516
517Types: `OmegaGpuPlatform` (the service table), `OmegaGpuPlatformCaps`, `OmegaGpuBufferDesc`, `OmegaCpuView`, `OmegaGpuVa`,
518`OmegaGpuBusAddr`, `OmegaGpuHandleTable`. Functions: `omega_gpu_platform_refusal_name`, `omega_gpu_platform_negotiate`,
519`omega_gpu_platform_check`, `omega_gpu_platform_check_for`, `omega_gpu_platform_check_buffer`, `omega_gpu_handles_init`,
520`omega_gpu_handles_open`, `omega_gpu_handles_check`, `omega_gpu_handles_close`. Enums and constants: the handle kinds,
521rights (`OMEGA_GPU_RIGHT_*`), cache policy, services (`OMEGA_GPU_SVC_*`) and refusal names (`OMEGA_GPU_PLAT_*`).
522
523Reason: the contract is written for three backends but only the Linux reference has run; the second backend (`rig/gb20x`) and
524the native one will likely force changes. What it already promises (from the header): resources are typed handles with a
525generation; every byte range carries a length and rights; anything the CPU polls is `OMEGA_GPU_RIGHT_HOST_POLLED` and must be
526GPU-uncached; polling a word is never claimed as interrupt support; a missing service is refused, never emulated.
527
528### 9.3 Command lists (`src/omega_gpu_cmdlist.h`)
529
530Types: `OmegaGpuCmdListOpts`, `OmegaGpuCmdListStats`, the opaque `OmegaGpuCmdList`. Functions: `omega_gpu_cmdlist_create`
531(takes the lock itself), `omega_gpu_cmdlist_free`, `omega_gpu_cmdlist_reset`, `omega_gpu_cmdlist_count`,
532`omega_gpu_cmdlist_add`, `omega_gpu_cmdlist_mark_independent`, `omega_gpu_cmdlist_submit`, `omega_gpu_cmdlist_submit_pair`,
533`omega_gpu_cmdlist_wait_for`, `omega_gpu_cmdlist_is_latched`, `omega_gpu_cmdlist_stamps`, `omega_gpu_cmdlist_barrier_name`.
534Up to `OMEGA_GPU_CMDLIST_MAX_LAUNCHES` (4096) launches per list.
535
536`OmegaGpuCmdListAccess` supplies a complete set of half-open GPU VA/byte ranges and
537`OMEGA_GPU_CMDLIST_ACCESS_READ` / `_WRITE` bits (combine both for in-place updates).
538Different virtual mappings of the same storage must be normalized to a common
539canonical interval namespace before annotation; the planner cannot discover
540physical aliases from distinct VAs. If the producer cannot establish that
541normalization, leave the record's effects unknown rather than claim independence.
542`omega_gpu_cmdlist_add_accesses` copies up to `OMEGA_GPU_CMDLIST_MAX_ACCESSES` ranges;
543zero ranges means known empty. `omega_gpu_cmdlist_set_accesses` attaches or replaces
544the complete set on an existing launch recorded by a kernel helper, without
545changing its launch bytes; a rejected replacement leaves the previous set intact.
546Legacy `add` records unknown effects.
547`omega_gpu_cmdlist_plan_program` returns `OmegaGpuCmdListProgramPlan` counts without
548submitting; `omega_gpu_cmdlist_submit_program` emits exactly one submission, or
549refuses before queue commit when the ring plus platform prefix cannot hold it.
550Empty lists produce no submission. Callers hold the session lock.
551`waits` counts explicit WFI methods: admission, hazardous inter-launch drains,
552and the optional final timestamp WFI; the completion release is separate.
553The whole-program path rejects manual barrier/skip/first-barrier suppression and
554cross-list waits. A caller must describe every buffer the kernel reads or writes;
555an incomplete effect set is not safe. Unknown legacy effects force drains.
556The planner compares every launch since the previous drain, not just its immediate
557predecessor. The serialized legacy API remains available for controlled comparison.
558See `om/cmdlist/README.md` for method-source pins, tests and the chip runbook.
559
560Reason: omega-mv#580 is building pipelined and dependency-ordered execution on this module, so the options, statistics
561and barrier modes will grow. The measured extra cost of each launch in a list is about 30 us with a wait-for-idle barrier
562(`evidence/OWN30B-LAUNCH-COST-20261014T0120Z/r1/receipt.json`, verdict FAIL on 4 of 11 checks). A timeout latches the list
563and then the session. The `OMEGA_GPU_CMDLIST_BARRIER_NONE` mode and `skip_launch` option are test-only.
564
565### 9.4 Job engine (`src/omega_gpu_engine.h`)
566
567Types: `OmegaGpuJob`, `OmegaGpuResult`, `OmegaGpuTimeouts`, `OmegaGpuBackend`, `OmegaGpuBackendDiag`. Functions:
568`omega_gpu_execute`, `omega_gpu_engine_set_backend`, `omega_gpu_engine_is_blocked`, `omega_gpu_engine_set_clock`,
569`omega_gpu_engine_failure_name`, `omega_gpu_engine_state_name`, `omega_gpu_engine_wait_name`, `omega_gpu_engine_step_name`. One failure name per run
570(`OMEGA_GPU_ENGINE_*`), states `INITIAL` to `SUCCESS`, the failed step recorded, and an uncertain completion blocks every
571later `omega_gpu_execute` in the process with `UNCERTAIN_COMPLETION_BLOCKED`.
572
573Reason: accepts one job shape (`OMEGA_GPU_LAYOUT_VECTOR_1D`); #580 widens it; the chip receipt for the vector-add job is on an
574unmerged branch (`hive/DEEP2-A3-gpu-engine-impl`). Note: the status paragraph at the top of `omega_gpu_engine.h` says only a
575fake backend exists; `src/omega_blackwell_engine.c` is on main and `src/omega_blackwell_submit.c` installs it, so that
576paragraph is out of date (whether it is chip-qualified on main is UNVERIFIED here).
577
578### 9.5 Libraries (matmul, elementwise, attention, serving)
579
580The entries carried over from aien-sovereign-core's manifest: `src/omega_gpu_matmul_api.h`, `omega_gpu_elementwise_api.h`,
581`omega_gpu_attention_api.h`, `omega_gpu_serving.h` (the functions and structs after the `libraries` comment in the
582manifest). Reason: shapes and formats follow one model (Qwen3-30B); the general any-shape GEMM is the separate entry of
583section 9.8. Attention is the exception since 0.6.0: `omega_gpu_attention_general` (declared after the carried block) takes every head_dim 1..256 and any MHA / GQA / MQA head split, and the carried attention entries fall back to it for the shapes their tuned kernels refuse. They are the surface sovereign-core's Rust binding uses today. They are not described entry by entry in v0;
584their headers are the description. One value differs from sovereign-core's pinned copy: `OMEGA_GPU_MATMUL_MAX_CTAS` is 1024 in
585the header (changed by omega #473, commit 98cecadc), 64 in their manifest. Omega's manifest is canonical; R12 brings theirs level.
586
587
588### 9.6 Library entries (manifest spelling)
589
590Types are the manifest's Rust spelling (`*const`, `*mut`, `u32`, ...); the headers hold the C. Every one is EXPERIMENTAL except the three STABLE session entries noted in section 4 and 5.
591
592| Entry | Signature |
593| --- | --- |
594| `OmegaGpuMatmulInfo` | struct, 160 bytes (fields in the manifest) |
595| `OmegaGpuServingBounds` | struct, 44 bytes (fields in the manifest) |
596| `OmegaGpuEwInfo` | struct, 120 bytes (fields in the manifest) |
597| `OmegaGpuAttnInfo` | struct, 176 bytes (fields in the manifest) |
598| `OmegaGpuKvLayout` | struct, 64 bytes (fields in the manifest) |
599| `OmegaGpuAttnGeneralDesc` | struct, 64 bytes (fields in the manifest) |
600| `omega_gpu_matmul_bf16` | `fn(u32, u32, u32, *const u16, *const u16, *mut f32, *mut OmegaGpuMatmulInfo) -> i32` |
601| `omega_gpu_matmul_f32` | `fn(u32, u32, u32, *const f32, *const f32, *mut f32, *mut OmegaGpuMatmulInfo) -> i32` |
602| `omega_gpu_matmul_rc_name` | `fn(i32) -> *const c_char` |
603| `omega_gpu_matmul_cache_clear` | `fn() -> ()` |
604| `omega_gpu_tensor_upload_bf16` | `fn(u32, u32, *const u16, *mut *mut OmegaGpuTensor) -> i32` |
605| `omega_gpu_tensor_upload_f32` | `fn(u32, u32, *const f32, *mut *mut OmegaGpuTensor) -> i32` |
606| `omega_gpu_tensor_free` | `fn(*mut OmegaGpuTensor) -> ()` |
607| `omega_gpu_tensor_shape` | `fn(*const OmegaGpuTensor, *mut u32, *mut u32) -> ()` |
608| `omega_gpu_matmul_resident_bf16` | `fn(u32, *const u16, *const OmegaGpuTensor, *mut f32, *mut OmegaGpuMatmulInfo) -> i32` |
609| `omega_gpu_matmul_resident_f32` | `fn(u32, *const f32, *const OmegaGpuTensor, *mut f32, *mut OmegaGpuMatmulInfo) -> i32` |
610| `omega_gpu_matmul_last_error` | `fn() -> *const c_char` |
611| `omega_gpu_matmul_is_blocked` | `fn() -> i32` |
612| `omega_gpu_device_close` | `fn() -> ()` |
613| `omega_gpu_matmul_set_cta_budget` | `fn(u32) -> ()` |
614| `omega_gpu_matmul_cta_budget` | `fn() -> u32` |
615| `omega_gpu_reserve_serving` | `fn(*const OmegaGpuServingBounds) -> i32` |
616| `omega_gpu_serving_release` | `fn() -> ()` |
617| `omega_gpu_matmul_prepare` | `fn(u32, u32, u32) -> i32` |
618| `omega_gpu_serving_seal` | `fn() -> ()` |
619| `omega_gpu_rmsnorm_f32` | `fn(u32, u32, *const f32, *const f32, f32, *mut f32, *mut OmegaGpuEwInfo) -> i32` |
620| `omega_gpu_rope_f32` | `fn(u32, u32, *const f32, *const f32, *const f32, *mut f32, *mut OmegaGpuEwInfo) -> i32` |
621| `omega_gpu_swiglu_f32` | `fn(u32, *const f32, *const f32, *mut f32, *mut OmegaGpuEwInfo) -> i32` |
622| `omega_gpu_elementwise_rc_name` | `fn(i32) -> *const c_char` |
623| `omega_gpu_gqa_attention_f32` | `fn(*const f32, *const f32, *const f32, u32, u32, u32, u32, *mut f32, *mut OmegaGpuAttnInfo) -> i32` |
624| `omega_gpu_gqa_attention_rows_f32` | `fn(*const f32, *const f32, *const f32, u32, u32, u32, u32, u32, *mut f32, *mut OmegaGpuAttnInfo) -> i32` |
625| `omega_gpu_attention_pool_alloc` | `fn(usize, *mut *mut c_void) -> i32` |
626| `omega_gpu_attention_pool_free` | `fn() -> ()` |
627| `omega_gpu_paged_attention_bf16` | `fn(*const f32, *const c_void, *const OmegaGpuKvLayout, *const u32, u32, u32, u32, u32, u32, u32, *mut f32, *mut OmegaGpuAttnInfo) -> i32` |
628| `omega_gpu_paged_attention_batch_bf16` | `fn(*const f32, *const c_void, *const OmegaGpuKvLayout, *const i32, *const i32, u32, u32, u32, u32, u32, u32, *mut f32, *mut OmegaGpuAttnInfo) -> i32` |
629| `omega_gpu_attention_rc_name` | `fn(i32) -> *const c_char` |
630| `omega_gpu_attention_last_error` | `fn() -> *const c_char` |
631| `omega_gpu_attention_general` | `fn(*const OmegaGpuAttnGeneralDesc, *const f32, *const c_void, *const c_void, *mut f32, *mut OmegaGpuAttnInfo) -> i32` |
632
633### 9.7 Decode path (ADR 0043 task P2.2)
634
635The kernel APIs the serving decode and prefill paths call, listed so the check sees any change to them. All are
636EXPERIMENTAL for the same three reasons: each serves one model (Qwen3-30B-A3B, the OWN-30B lane), each is proven on one
637chip (sm_121), and each is tied to its kernel generator in `src/omega_blackwell_codegen_*.h`, which ADR 0043 moves behind
638a backend. Signatures and struct layouts are in the manifest. They were added in 0.3.0, a MINOR bump (section 2).
639Their result codes (`*_OK`, `*_BAD_ARGS`, `*_TOO_LARGE`, `*_CODEGEN_FAIL`, `*_CHIP_FAIL`, `*_NAN_WEIGHT`, `*_BAD_TRIT`) are
640EXPERIMENTAL constants in the manifest; the other constants these headers define (shape limits, kernel slot ids, mode
641values, poison patterns) are in the INTERNAL list.
642
643| Header | Entries | Reason it is EXPERIMENTAL |
644| --- | --- | --- |
645| `src/omega_gpu_fp8_api.h` | `OmegaGpuFp8Info`, `omega_gpu_fp8_tensor_upload`, `omega_gpu_fp8_tensor_free`, `omega_gpu_fp8_tensor_shape`, `omega_gpu_fp8_gemv_f32`, `omega_gpu_fp8_gemv_bf16`, `omega_gpu_fp8_gemv_grouped_f32`, `omega_gpu_fp8_gemv_grouped_dev`, `omega_gpu_fp8_gemv_grouped_record`, `omega_gpu_fp8_tensor_entry`, `omega_gpu_fp8_prepare`, `omega_gpu_fp8_seal`, `omega_gpu_fp8_rc_name`, `omega_gpu_fp8_last_error`, `omega_gpu_fp8_cache_clear`, `omega_gpu_fp8_set_shape`, `omega_gpu_fp8_set_depth`, `omega_gpu_fp8_set_cta_budget`, `omega_gpu_fp8_set_weight_cache`, `omega_gpu_fp8_set_variant`, `omega_gpu_fp8_variant`, `omega_gpu_fp8_weight_cache`, `omega_gpu_fp8_set_gpr_pad`, `omega_gpu_fp8_shape_for`, `omega_gpu_fp8_set_bigk`, `omega_gpu_fp8_bigk`, `omega_gpu_fp8_set_coal`, `omega_gpu_fp8_coal`, `omega_gpu_fp8_set_deep`, `omega_gpu_fp8_deep`, `omega_gpu_fp8_set_sched`, `omega_gpu_fp8_sched`, `omega_gpu_fp8_set_wfirst`, `omega_gpu_fp8_wfirst`, `omega_gpu_fp8_quantize_bf16`, `omega_gpu_fp8_e4m3_rne`, `omega_gpu_fp8_grouped_ctas_rule`, `omega_gpu_fp8_grouped_ctas_auto` | FP8 e4m3 block-scaled GEMV for the OWN-30B lane (Qwen3-30B-A3B): decode GEMV and grouped experts; depth and weight-cache knobs are tuned on one chip. |
646| `src/omega_gpu_fp8gemm_api.h` | `OmegaGpuFp8GemmInfo`, `omega_gpu_fp8gemm_f32`, `omega_gpu_fp8gemm_bf16`, `omega_gpu_fp8gemm_prepare`, `omega_gpu_fp8gemm_rc_name`, `omega_gpu_fp8gemm_last_error`, `omega_gpu_fp8gemm_cache_clear`, `omega_gpu_fp8gemm_shape_for`, `omega_gpu_fp8gemm_set_shape`, `omega_gpu_fp8gemm_set_cta_budget`, `omega_gpu_fp8gemm_prepare_shape`, `omega_gpu_fp8gemm_cta_budget_for`, `omega_gpu_fp8gemm_record` | FP8 e4m3 grouped GEMM for OWN-30B prefill; one model's shapes. |
647| `src/omega_gpu_bf16_gemv_api.h` | `OmegaGpuBf16Info`, `omega_gpu_bf16_tensor_upload`, `omega_gpu_bf16_tensor_free`, `omega_gpu_bf16_tensor_shape`, `omega_gpu_bf16_gemv_f32`, `omega_gpu_bf16_gemv_bf16`, `omega_gpu_bf16_gemv_record`, `omega_gpu_bf16_prepare`, `omega_gpu_bf16_rc_name`, `omega_gpu_bf16_last_error`, `omega_gpu_bf16_cache_clear`, `omega_gpu_bf16_shape_for`, `omega_gpu_bf16_set_shape`, `omega_gpu_bf16_set_cta_budget`, `omega_gpu_bf16_gemv_mask_record`, `omega_gpu_bf16_gemv_rows_record`, `omega_gpu_bf16_gemv_xbatch_record`, `omega_gpu_bf16_prepare_mask`, `omega_gpu_bf16_prepare_xbatch` | bf16 streaming GEMV for the OWN-30B lm_head (vocab 151936 x hidden 2048); one shape. |
648| `src/omega_gpu_decode_attn_api.h` | `OmegaGpuDecodeAttnInfo`, `OmegaGpuDecodeAttnCacheView`, `omega_gpu_decode_attn_cache_alloc`, `omega_gpu_decode_attn_cache_free`, `omega_gpu_decode_attn_set_norms`, `omega_gpu_decode_attn`, `omega_gpu_decode_attn_record`, `omega_gpu_decode_attn_counters_check`, `omega_gpu_decode_attn_cache_write`, `omega_gpu_decode_attn_cache_read`, `omega_gpu_decode_attn_cache_view`, `omega_gpu_decode_attn_last_error`, `omega_gpu_decode_attn_rc_name`, `omega_gpu_decode_attn_set_depth`, `omega_gpu_decode_attn_set_per_split` | One-launch decode attention for Qwen3-30B-A3B with its own KV cache; the cache view hands out device addresses. |
649| `src/omega_gpu_router_api.h` | `OmegaGpuRouterInfo`, `OmegaGpuRouterDevOut`, `omega_gpu_router_alloc`, `omega_gpu_router_free`, `omega_gpu_router_set_layer`, `omega_gpu_router_set_directory`, `omega_gpu_router_set_directory_fp8`, `omega_gpu_router`, `omega_gpu_router_device_outputs`, `omega_gpu_router_record`, `omega_gpu_router_read_back`, `omega_gpu_router_last_error`, `omega_gpu_router_rc_name`, `omega_gpu_router_set_shape`, `omega_gpu_router_alloc_shape`, `omega_gpu_router_layout_bytes`, `omega_gpu_router_prepare_rows`, `omega_gpu_router_record_to`, `omega_gpu_router_record_rows` | One-launch MoE router for Qwen3-30B-A3B; the device-output path writes device addresses. |
650| `src/omega_gpu_tern_api.h` | `OmegaGpuTernSegments`, `OmegaGpuTernInfo`, `omega_gpu_tern_tensor_upload`, `omega_gpu_tern_tensor_free`, `omega_gpu_tern_tensor_shape`, `omega_gpu_tern_tensor_bytes`, `omega_gpu_tern_gemv_i32`, `omega_gpu_tern_gemv_f32`, `omega_gpu_tern_gemv_record`, `omega_gpu_tern_rc_name`, `omega_gpu_tern_last_error`, `omega_gpu_tern_cache_clear`, `omega_gpu_tern_pack`, `omega_gpu_tern_padded_rows`, `omega_gpu_tern_segment_bounds`, `omega_gpu_tern_shape_for`, `omega_gpu_tern_set_layout`, `omega_gpu_tern_set_shape`, `omega_gpu_tern_set_cta_budget`, `omega_gpu_tern_set_weight_cache` | Ternary engine stage T0 (W2A8 ternary GEMV); the packing layout is still being designed. |
651| `src/omega_gpu_tcgemm_api.h` | `OmegaGpuTcGemmInfo`, `omega_gpu_tcgemm_f32`, `omega_gpu_tcgemm_prepare`, `omega_gpu_tcgemm_rc_name`, `omega_gpu_tcgemm_last_error`, `omega_gpu_tcgemm_cache_clear`, `omega_gpu_tcgemm_set_shape` | OWN-30B T3 cut 1: FP8 grouped GEMM on the tensor cores; one model's shapes. |
652| `src/omega_gpu_prefill_attn_api.h` | `OmegaGpuPrefillAttnInfo`, `OmegaGpuPrefillAttnMirrorView`, `omega_gpu_prefill_attn`, `omega_gpu_prefill_attn_release`, `omega_gpu_prefill_attn_dev`, `omega_gpu_prefill_attn_set_warps`, `omega_gpu_prefill_attn_set_fused`, `omega_gpu_prefill_attn_set_kv_mirror`, `omega_gpu_prefill_attn_kv_mirror_view`, `omega_gpu_prefill_attn_kv_mirror_invalidate`, `omega_gpu_prefill_attn_kv_mirror_forget`, `omega_gpu_prefill_attn_kv_mirror_available` | Causal prefill attention for Qwen3-30B-A3B, with an optional KV mirror; one model. |
653| `src/omega_gpu_moe_api.h` | `omega_gpu_moe_tensor_upload_bf16`, `omega_gpu_moe_tensor_upload_f32`, `omega_gpu_moe_tensor_free`, `omega_gpu_moe_tensor_shape`, `omega_gpu_matmul_resident_window_f32`, `omega_gpu_matmul_resident_window_bf16`, `omega_gpu_matmul_resident_windows_f32`, `omega_gpu_moe_reserve`, `omega_gpu_moe_prepare`, `omega_gpu_moe_seal`, `omega_gpu_moe_unreserve`, `omega_gpu_moe_cache_clear`, `omega_gpu_moe_set_cta_budget`, `omega_gpu_moe_cta_budget`, `omega_gpu_moe_window_byte_offset` | Column windows over a resident bf16 expert tensor (OWN-30B); tied to the serving pool. |
654| `src/omega_gpu_decode_graph.h` | `OmegaGpuDecodeGraphConfig`, `OmegaGpuDecodeGraphStats`, `OmegaGpuDecodeGraphVas`, `omega_gpu_decode_graph_create`, `omega_gpu_decode_graph_free`, `omega_gpu_decode_graph_set_layer`, `omega_gpu_decode_graph_set_final_norm`, `omega_gpu_decode_graph_token`, `omega_gpu_decode_graph_begin_token`, `omega_gpu_decode_graph_record_layer`, `omega_gpu_decode_graph_record_final`, `omega_gpu_decode_graph_end_token`, `omega_gpu_decode_graph_abort_token`, `omega_gpu_decode_graph_record_res`, `omega_gpu_decode_graph_record_swiglu`, `omega_gpu_decode_graph_list`, `omega_gpu_decode_graph_vas`, `omega_gpu_decode_graph_read`, `omega_gpu_decode_graph_set_stamps`, `omega_gpu_decode_graph_set_barrier`, `omega_gpu_decode_graph_barrier`, `omega_gpu_decode_graph_stamps`, `omega_gpu_decode_graph_kind_name`, `omega_gpu_decode_graph_set_flush_each`, `omega_gpu_decode_graph_set_prefetch`, `omega_gpu_decode_graph_prefetch` | One Qwen3-30B-A3B decode token as one command list; scheduling, barrier and prefetch modes are still measured. |
655| `src/omega_gpu_prefill.h` | `OmegaPfWeights`, `omega_gpu_pf_rc_name`, `omega_gpu_pf_alloc_dev`, `omega_gpu_pf_alloc_host`, `omega_gpu_pf_free`, `omega_gpu_pf_upload`, `omega_gpu_pf_download`, `omega_gpu_pf_copy_va`, `omega_gpu_pf_stats`, `omega_gpu_pf_stats_reset`, `omega_gpu_pf_weights_upload`, `omega_gpu_pf_weights_free`, `omega_gpu_pf_weights_host_form`, `omega_gpu_pf_gemm_bm`, `omega_gpu_pf_gemm_tiles`, `omega_gpu_pf_gemm`, `omega_gpu_pf_gemm_set_shape`, `omega_gpu_pf_quant`, `omega_gpu_pf_qgemm_bm`, `omega_gpu_pf_qgemm_tiles`, `omega_gpu_pf_qgemm_tiles_va`, `omega_gpu_pf_qgemm`, `omega_gpu_pf_qgemm_set_shape`, `omega_gpu_pf_qgemm_set_group`, `omega_gpu_pf_quant_record`, `omega_gpu_pf_qgemm_record` | Device-resident one-pass prefill for OWN-30B; arguments carry raw device addresses. |
656| `src/omega_gpu_pfhost.h` | `omega_gpu_pf_router_rows`, `omega_gpu_pf_router_packed_bytes`, `omega_gpu_pf_router_pack`, `omega_gpu_pf_router_logits`, `omega_gpu_pf_moe_combine`, `omega_gpu_pf_router_set_rows` | Whole-prompt prefill router logits and MoE combine for OWN-30B; arguments carry raw device addresses. |
657
658### 9.8 General matrix multiply (`src/omega_gpu_gemm_ex.h`, added in 0.8.0)
659
660One entry with the shape contract of `cblas_?gemm` (RowMajor): `C_b = alpha * s * op(A_b) op(B_b) + beta * C_b` for any
661M, N, K >= 1 (up to `OMEGA_GPU_GEMM_EX_MAX_DIM`), op N or T for each input, any leading dimension, strided batches,
662alpha/beta, A and B each f32, bf16, f16, e4m3 or e5m2, C f32, bf16 or f16, and per-tensor or block fp8 scales. The header
663comment is the full contract (which input pairs run natively on HMMA/QMMA, which are widened exactly, which go through
664bf16x3, how inf and NaN propagate, how block scales cut k). Result codes are the `OMEGA_GPU_GEMM_*` codes of
665`src/omega_gpu_gemm.h`, which is not a manifest header.
666
667It is EXPERIMENTAL for four reasons, each one a stated limit rather than a defect:
668- **Host memory, host orchestration.** A, B and C are host pointers, and every call with alpha != 0 scans A and B on the
669 host for inf and NaN (one read of each). The common case, the native route with one k part, alpha s 1, beta 0, C f32
670 with ldc n, n <= 16384 and finite inputs, is one call of the C3 kernels (`omega_gpu_gemm_ld`, which copies its operands
671 to the GPU) per 16384 rows of C, writing C in place. Every other call cuts C into host tiles of at most 4096 x 4096 and
672 k into parts of at most 16384 (1808 on the bf16x3 route), runs every part as one C3 call, and sums the parts and
673 applies alpha, beta and the scales on the host in double. There is no device-resident form and no
674 record-into-command-list form, so it is not a serving path: the tuned per-model kernels of sections 9.5 and 9.7 stay
675 the fast path for the shapes they take.
676 Measured cost at the nine served 35B shapes, bf16 and e4m3 (GB10, predeclared A/B against `omega_gpu_gemm_ld`,
677 `evidence/GEMM-GENERAL-AB-20261027/`): after the 0d2b14a host-overhead fix the median ratio is 0.94-1.24
678 (ab-2), over the plan's 1.10 limit in five small cells: e4m3 64x1024x2048 1.24, e4m3 64x2048x512 1.20, bf16
679 64x1024x2048 1.17, e4m3 16x12288x2048 1.10, e4m3 1x8192x2048 1.10 (about 0.1-0.35 ms per call; not yet attributed).
680 Before the fix it was 2.17-3.25 (ab-1).
681- **f32 is not IEEE fp32.** f32 inputs run as bf16x3 (three bf16 planes, nine plane products); accuracy is stated
682 against a double reference in `tests/gpu_gemm_ex_test.c`, and parts of a value below 2^-133 are dropped.
683 `OMEGA_GEMM_EX_F32_FFMA_REF` is the slow per-k FFMA comparator, not a fast path.
684- **fp8 output is refused** (`OMEGA_GPU_GEMM_UNSUPPORTED`).
685- **Omega with a migration-pending C oracle, one chip.** The plan, routes, k parts, operand conversion, k-part sums,
686 host recompute, epilogue and fp8 dequantization are seeded Omega (`om/gemmex/*.om`, generated
687 `src/cudapp_om_gemm_ex_*.c`, CUDApp#144); `src/omega_gpu_gemm_ex.c` is their memory shell. The old C stays behind
688 `CUDAPP_MIGRATION_PENDING_GEMM_EX` (`mk/gemm-ex.mk`, default 0; 1 builds the C path) as the differential oracle
689 (`make test-gpu-gemm-ex-diff`). An Omega unit refusing its window returns `OMEGA_GPU_GEMM_CODEGEN_FAIL`.
690 Exercised on sm_121 (GB10) only, by the C path; the Omega path's chip tier is NOT_RUN.
691
692The fp8 GEMV and grouped GEMM of section 9.7 call `omega_gpu_gemm_ex_fp8_block_rows` for shapes their tuned kernels
693refuse, and report it in `OmegaGpuFp8Info.general` / `OmegaGpuFp8GemmInfo.general`; those rows carry the bf16x3
694accuracy, not the tuned kernels' bit pattern. Shapes the tuned kernels take never reach the fallback.
695
696| Entry | Signature (manifest spelling) |
697| --- | --- |
698| `OmegaGemmExArgs` | struct, 200 bytes (fields in the manifest) |
699| `OmegaGemmExInfo` | struct, 24 bytes: `route`, `core_type`, `core_calls`, `host_fixed` |
700| `omega_gpu_gemm_ex` | `fn(*const OmegaGemmExArgs) -> i32` |
701| `omega_gpu_gemm_ex_fp8_block_rows` | `fn(*const u8, *const f32, f64, u32, u32, u32, *const f32, *const u16, u32, *mut f32, u64, *mut OmegaGemmExInfo) -> i32` |
702
703The enumerators of `OmegaGemmOp`, `OmegaGemmDtype`, `OmegaGemmExCompute`, `OmegaGemmScale` and `OmegaGemmRoute` and the two
704maxima are EXPERIMENTAL constants in the manifest. `omega_gpu_gemm_ex_set_backend` and `omega_gpu_gemm_ex_test_set_mutant`
705are TEST ONLY (INTERNAL list).
706
707### 9.9 Version query (`src/omega_runtime_api.h`, added in 0.14.0)
708
709`omega_runtime_api_version()` returns `OMEGA_RUNTIME_API_VERSION`, `(MAJOR << 16) | MINOR`, of the library that was linked,
710so a program can compare it with the macro it was compiled against. While MAJOR is 0 the library serves a program only
711when MAJOR and MINOR are both equal (section 2); `examples/hello_gpu` prints both and stops with exit 2 when they differ.
712EXPERIMENTAL because it has no chip coverage yet and one user.
713
714| Entry | Signature (manifest spelling) |
715| --- | --- |
716| `omega_runtime_api_version` | `fn() -> u32` |
717
718### 9.10 Random numbers and FFT (`src/omega_gpu_mathlibs_api.h`, added in 0.15.0)
719
720The cuRAND-class and cuFFT-class entries. Every kernel, and the pass plan of the real and multi-dimensional transforms, is
721generated by the seeded Omega unit `om/mathlibs/mathlibs_ir.om` (generated C `src/cudapp_om_mathlibs_ir.c`); the C file
722`src/omega_gpu_mathlibs_api.c` stages buffers and launches. The header comment is the full contract. In short:
723- `omega_gpu_rng_generate` (`OMEGA_GPU_RNG_U64`, `OMEGA_GPU_RNG_UNIFORM`, `OMEGA_GPU_RNG_NORMAL`): xoshiro256**, the
724 aien-math stream. `omega_gpu_philox_generate`: Philox4x32-10, the `curand()` stream of `curandStatePhilox4_32_10_t`
725 after `curand_init(seed, subseq0 + g, offset)`, raw 32-bit words only; `offset` and `per_stream` must be multiples of 4
726 and output blocks of four words interleave across streams. Checked against the Random123 known answers and 1024 rows
727 of a host cuRAND 10.4.0 oracle (`tests/fixtures/philox_curand_oracle.txt`).
728- `omega_gpu_fft_c2c`: batched complex f32, n = 4..2048 (`OMEGA_GPU_FFT_MIN_N`, `OMEGA_GPU_FFT_MAX_N`), inverse not
729 normalised. `omega_gpu_fft_r2c` and `omega_gpu_fft_c2r`: cuFFT's R2C/C2R layout (n / 2 + 1 complex outputs per row),
730 n = 8..4096 (`OMEGA_GPU_FFT_REAL_MIN_N`, `OMEGA_GPU_FFT_REAL_MAX_N`); C2R is not normalised and needs Hermitian input
731 (Im X[0] = Im X[n/2] = 0, not cleared by the kernel). `omega_gpu_fft_c2c_nd`: 1-D to 3-D row-major complex transforms,
732 each dimension 4..2048, one batched 1-D pass per axis followed by a transpose. Batch times points is at most
733 `OMEGA_GPU_FFT_MAX_ELEMENTS`.
734- `omega_gpu_fft_plan_walk` lists a plan's launches (`OmegaGpuFftLaunch`, modes `OMEGA_GPU_FFT_C2C_ND`,
735 `OMEGA_GPU_FFT_R2C`, `OMEGA_GPU_FFT_C2R`) and the in, out and scratch sizes. Host only; the plan and private copies of
736 its twiddle tables are built under the session lock and the callback runs after the lock is released, so it may call
737 this API.
738- `omega_gpu_philox_generate_dist` (`OmegaGpuPhiloxDist`: `OMEGA_GPU_PHILOX_RAW`, `OMEGA_GPU_PHILOX_UNIFORM`,
739 `OMEGA_GPU_PHILOX_UNIFORM_DOUBLE`, `OMEGA_GPU_PHILOX_UNIFORM2_DOUBLE`, `OMEGA_GPU_PHILOX_NORMAL`): cuRAND's
740 `curand`, `curand_uniform`, `curand_uniform_double`, `curand_uniform2_double` and `curand_normal` drawn from the
741 Philox stream above, any offset and any `per_stream`. The integer and uniform outputs are bit-identical to a host
742 cuRAND 10.4.0 oracle (`tests/fixtures/philox_curand_dist_oracle.txt`, 4480 rows); the normal output is within
743 2^-21 sqrt(-2 log u) of it (the chip's MUFU.RSQ; bound derived with Wolfram in `evidence/MATHLIBS-GAPS-2026-11-06/`).
744- `omega_gpu_fft_many` is cufftPlanMany: `OmegaGpuFftMany` gives rank 1..3, the lengths n[] (any length 2..4096,
745 `OMEGA_GPU_FFT_MANY_MAX_N`), `inembed`/`istride`/`idist`, `onembed`/`ostride`/`odist`, the batch and the type
746 (`OMEGA_GPU_FFT_TYPE_C2C`, `OMEGA_GPU_FFT_TYPE_R2C`, `OMEGA_GPU_FFT_TYPE_C2R`). All-zero embeds select cuFFT's
747 basic layout; in place (in == out) pads each real row of R2C and C2R to 2 (n / 2 + 1) floats, as cuFFT. Each axis
748 runs Stockham passes of radix 4, 2, 3, 5 and 7 when its length factors over them, else Bluestein's chirp-z algorithm
749 on a power-of-two length M >= 2n - 1. C2R is unnormalised, as cuFFT: C2R(R2C(x)) = prod(n) x, and it ignores Im of
750 the DC and Nyquist bins. `omega_gpu_fft_many_walk` lists the launches (`OmegaGpuFftManyLaunch`) and the sizes of the
751 `OMEGA_GPU_FFT_MANY_BUFS` buffers (`OMEGA_GPU_FFT_BUF_IN` .. `OMEGA_GPU_FFT_BUF_TABLE`); host only, its callback
752 runs unlocked. `omega_gpu_fft_c2c`, `_r2c`, `_c2r` and `_c2c_nd` route lengths outside their power-of-two ranges
753 (still 2..4096) through the same plans.
754- `omega_gpu_rng_codegen`, `omega_gpu_fft_codegen` and `omega_gpu_philox_codegen` build a kernel on the host and fill
755 `OmegaGpuMathInfo` without opening a device. `omega_gpu_fft_twiddles` returns the f32 table the C2C kernel reads.
756 Result codes: `OMEGA_GPU_ML_OK`, `OMEGA_GPU_ML_BAD_ARGS`, `OMEGA_GPU_ML_TOO_LARGE`, `OMEGA_GPU_ML_CODEGEN_FAIL`,
757 `OMEGA_GPU_ML_CHIP_FAIL`, `OMEGA_GPU_ML_UNWRITTEN`; `omega_gpu_mathlibs_last_error` names the failure and
758 `omega_gpu_mathlibs_cache_clear` drops the cached kernels.
759- Launch limits: `OMEGA_GPU_RNG_THREADS`, `OMEGA_GPU_RNG_MAX_STREAMS`, `OMEGA_GPU_RNG_MAX_OUTPUTS`,
760 `OMEGA_GPU_FFT_MAX_CTAS`, `OMEGA_GPU_PHILOX_THREADS`, `OMEGA_GPU_PHILOX_MAX_STREAMS`, `OMEGA_GPU_FFT_MANY_THREADS`.
761
762It is EXPERIMENTAL because:
763- **Host memory.** Inputs and outputs are host pointers copied through uncached session buffers on every call; there is
764 no device-resident or command-list form.
765- **Chip evidence is partial.** The xoshiro256** generator and the complex FFT have one GB10 run
766 (`evidence/MATHLIBS-RNG-FFT-2026-10-27/`). Philox and its distributions, R2C, C2R, the 2-D/3-D transforms and the
767 many plans (Stockham radix 2/3/4/5/7, Bluestein, strided copies) are checked on the host and in the warp simulator
768 (`make test-gpu-mathlibs`); their chip tier is NOT_RUN.
769- **Missing pieces.** No `curand_normal_double` (it needs f64 arithmetic in the IR). Buffers are host-staged (see above).
770
771| Entry | Signature (manifest spelling) |
772| --- | --- |
773| `OmegaGpuMathInfo` | struct, 96 bytes (fields in the manifest) |
774| `OmegaGpuFftLaunch` | struct, 88 bytes (fields in the manifest) |
775| `OmegaGpuFftMany` | struct, 68 bytes (fields in the manifest) |
776| `OmegaGpuFftManyLaunch` | struct, 160 bytes (fields in the manifest) |
777| `omega_gpu_philox_generate_dist` | `fn(OmegaGpuPhiloxDist, u64, u64, u32, u64, u32, *mut c_void, *mut OmegaGpuMathInfo) -> i32` |
778| `omega_gpu_fft_many` | `fn(*const OmegaGpuFftMany, *const f32, *mut f32, *mut OmegaGpuMathInfo) -> i32` |
779| `omega_gpu_fft_many_walk` | `fn(*const OmegaGpuFftMany, i32, *mut usize, fn(*mut c_void, *const OmegaGpuFftManyLaunch) -> i32, *mut c_void) -> i32` |
780| `omega_gpu_philox_generate` | `fn(u64, u64, u32, u64, u32, *mut u32, *mut OmegaGpuMathInfo) -> i32` |
781| `omega_gpu_fft_r2c` | `fn(*const f32, *mut f32, u32, u32, *mut OmegaGpuMathInfo) -> i32` |
782| `omega_gpu_fft_c2r` | `fn(*const f32, *mut f32, u32, u32, *mut OmegaGpuMathInfo) -> i32` |
783| `omega_gpu_fft_c2c_nd` | `fn(*const f32, *mut f32, u32, *const u32, u32, i32, *mut OmegaGpuMathInfo) -> i32` |
784| `omega_gpu_fft_plan_walk` | `fn(OmegaGpuFftPlanMode, u32, *const u32, u32, i32, *mut usize, fn(*mut c_void, *const OmegaGpuFftLaunch) -> i32, *mut c_void) -> i32` |
785
786The other signatures are in the manifest. `omega_gpu_mathlibs_test_set_mutant` is TEST ONLY (INTERNAL list).
787
788## 10. INTERNAL (not part of the API)
789
790The INTERNAL CPU verification helpers `omega_matmul_cpu_oracle_i32`,
791`omega_matmul_cpu_oracle_f16` and `omega_matmul_cpu_oracle_bf16` in
792`src/omega_blackwell_matmul.h` take positive row-major m/k/n dimensions. The output
793must not overlap either input; read-only inputs may overlap. Hosted checked Omega
794views return -1 before touching an aliased output. The hosted implementation uses
795runtime extents; the `OMEGA_GPU_NO_POSIX` C exception is pending omega-bridge#72.
796These verification helpers are not production GPU dispatch and are not manifest
797entries. No public ABI signature or layout changes with this migration.
798
799Not in the manifest; may change or vanish without notice. The complete list of such names in the manifest headers, each
800with its reason, is `docs/runtime/omega_runtime_api.internal` (195 names in 0.9.0: test hooks, kernel builders, encoder
801probes, serving-daemon internals and launch limits; the 25 serving internals and launch limits are marked "candidate
802EXPERIMENTAL", the ones a caller is most likely to want promoted). `make test-runtime-api` fails on a name in a manifest header that is in neither file. Notable ones:
803- `omega_gpu_session_set_error` (library code names its failure stage through it).
804- `omega_gpu_session_on_close` (lets a library drop its resident kernels before the session closes; up to 8 hooks).
805- `omega_gpu_engine_test_reset_block`, `omega_gpu_engine_test_force_block`, `omega_gpu_engine_test_set_clock`: TEST ONLY. A blocked process must stay blocked because the GPU may still be running.
806- Take or return a kernel-generator type, which is backend (ADR 0043): `omega_gpu_fp8_depth_for`, `omega_gpu_fp8_kernel_fits`, `omega_gpu_fp8gemm_kernel_fits`, `omega_gpu_bf16_kernel_fits`, `omega_gpu_tern_kernel_fits`, `omega_gpu_tcgemm_spec_for`, `omega_gpu_prefill_attn_encode`.
807- TEST ONLY (mutant and fault-injection setters in the decode-path headers): `omega_gpu_fp8_test_set_mutant`, `omega_gpu_fp8_test_set_no_fold`, `omega_gpu_fp8gemm_test_set_mutant`, `omega_gpu_bf16_test_set_mutant`, `omega_gpu_decode_attn_test_set_mutant`, `omega_gpu_router_test_set_mutant`, `omega_gpu_tern_test_set_mutant`, `omega_gpu_tcgemm_test_set_mutant`, `omega_gpu_prefill_attn_test_set_mutant`, `omega_gpu_prefill_attn_test_set_mirror_per_call`, `omega_gpu_prefill_attn_test_launch_ns`, `omega_gpu_moe_test_set_mutant`, `omega_gpu_moe_test_set_window_skew`, `omega_gpu_moe_test_a_row0_hits`, `omega_gpu_decode_graph_test_set_mutant`, `omega_gpu_decode_graph_test_set_barrier_none`, `omega_gpu_decode_graph_test_set_prefetch_red`, `omega_gpu_pf_gemm_test_set_mutant`, `omega_gpu_pf_quant_test_set_mutant`, `omega_gpu_pf_qgemm_test_set_mutant`, `omega_gpu_pf_router_test_set_mutant`, `omega_gpu_pf_combine_test_set_mutant`.
808- Random numbers and FFT (section 9.10): `omega_gpu_mathlibs_test_set_mutant` (TEST ONLY: selects a mutant of the Omega unit).
809- General GEMM (section 9.8): `omega_gpu_gemm_ex_set_backend` (TEST ONLY: swaps the C3 core for the simulator or a host model), `omega_gpu_gemm_ex_test_set_mutant` (TEST ONLY), and `omega_gpu_fp8_general_rows`, the fp8 GEMV and grouped GEMM bridge to `omega_gpu_gemm_ex_fp8_block_rows`.
810- Host reference and packing helpers in the decode-path headers (not `omega_gpu_` entries): `omega_fp8_e4m3_ref`, `omega_fp8_e4m3_kernel_bits`, `omega_fp8_e4m3_is_nan`, `omega_fp8_pack_scan_nan`, `omega_fp8_pack_scales`, `omega_fp8_pack_x_f32`, `omega_fp8_pack_x_bf16`, `omega_fp8_gemv_oracle`, `omega_fp8gemm_permute_x`, `omega_dattn_bf16_rne`, `omega_dattn_bf16_f32`, `omega_dattn_rope_row`.
811- Launch helpers whose caller already holds the session lock: `omega_gpu_pf_kernel_locked`, `omega_gpu_pf_launch_locked`, `omega_gpu_pf_open_locked`.
812- Everything under `src/omega_gpu_*` and `src/omega_blackwell_*` in headers the manifest does not name (kernel builder, encoder, per-model APIs, launch helpers).
813
814The private `omega_gpu_native_runtime.h` and `omega_gpu_q36_native.h` headers
815bind generated Omega residency/selection policy to existing runtime handles.
816They are not public API or a caller-controlled qualification interface. A
817prepared lease pins code; recording takes a distinct pin; submission acquires
818an inflight reference before queueing. A timeout is not completion: reset and
819cache clearing must retain pending code, and freeing the host command-list
820object cannot release its inflight code reference. A confirmed device teardown
821advances the private session epoch; only then may stale cache ownership be
822invalidated. Exact-native recording consumes the selected canonical artifact's
823uploaded code address and validated launch declaration rather than generating
824an incumbent kernel for the same shape.
825
826Canonical manifests and the existing independent qualification/admission path
827remain authoritative. Realization digests and live closure digests are binding
828metadata, not alternative trust stores. No native candidate is activated by
829these private interfaces, host fixture handles, manifest text or caller flags.
830The public header inventory, version and manifest are intentionally unchanged.
831The private `omega_native_artifact_snapshot.h` interface retains exactly the
832manifest, text, cubin, QMD and constant-bank bytes checked by existing artifact
833admission. Digest and semantic checks share those read-once buffers; reopening
834a mutable path cannot substitute unchecked bytes. A snapshot transfers byte
835custody only, not independent qualification or permission to activate code.
836
837### 10.1 Private API-plan policy
838
839The six RuntimeHost adapters use `om/components/api_{mm,at,ew,bf,da,rt}_plan.om`
840for scalar validation, refusal selection, padding, scratch sizing, kernel-plan
841selection and launch/chunk geometry. `src/omega_api_plan.h` is private glue,
842not a public header. Each root takes a mode and a fixed 16-word edit view:
843words 0..7 are inputs, words 8..15 are results. Router allocation also returns
844whether the caller's output pointer must be cleared in word 7, preserving
845the original order of argument refusal and that observable write. Policy
846refusals 1/2/3 map to the existing negative BAD_ARGS/TOO_LARGE/CODEGEN_FAIL
847codes. No public signature, manifest entry or version changes.
848Private locals also avoid OM2 reserved words: the attention allocation-size
849temporary is `partsz`, not the reserved `part`, so whole-unit OM2 composition
850does not fail at that identifier.
851
852The default is Omega. `CUDAPP_MIGRATION_PENDING_C_API_PLAN=1` selects the C
853oracle in that private header, not a fallback after an Omega refusal.
854Both implementations repair the old BF16 `k < 256` divide-by-zero in default
855depth derivation, and widen decode's `pos + per_split` before division to
856avoid a zero-split plan on unsigned overflow. Shell chunk counters are wide
857enough to terminate at the upper u32 input boundary.
858
859The C adapters retain pointer/object admission, ABI marshalling, buffer
860ownership, cache/session state, code generation, data packing, copies and
861acting on the returned plan. Host numerical reference kernels and the
862adapter-local device-code generators are not converted by this policy
863change. These units neither access a device nor replace independent artifact
864qualification or launch admission.
865
866`tests/runtime/api_plan_unit.c` is the executable definition of the bounded
867differential domain. Every call compares the return code and **all 16 words**,
868including unchanged inputs, unused output canaries and refusal-side writes.
869The bounds are chosen from API limits and the threshold/divisibility classes
870used by the policy, rather than from typical model shapes:
871
872| Root / adapter | Exhaustive bounds and boundary products |
873| --- | --- |
874| `api_mm_plan` / matmul | Every M 0..8193, K 0..16385 and N 0..262145 on the independent admission axes; edge Cartesian products include simultaneous invalid fields. Every column-tile count 1..32768 crosses representative row-tile and CTA-budget classes; every row-tile count 1..512 crosses budgets 0..1024 and column counts 1..8. These cover the full admitted padded dimensions, all tile divisibility residues and the 1024-CTA default. All K values cover the packing quotient; all N values cover tail width. Every K-slice count 1..1024, rt/ct in {1,2,4}, unroll override 0..128 and mutant bit covers selection and halving; every row/chunk count 1..512 crosses rt in {1,2,4}. |
875| `api_at_plan` / attention | Every query/KV-head pair 0..1025 crosses head-dimension threshold representatives and the general-path force bit; every head dimension 1..256 also crosses every legal query-head count. Head-map tests enumerate every legal divisor and every query head through 1024. All contexts 0..131073 cross both tuned dimensions; every u32 power of two and its neighbours covers exact-log refusal classes. Every legal query count crosses row/capacity edges and split logs 0..4. Causal/window tests exhaust positions and lengths 0..128, windows {-2,-1,0,1,2,INT32_MAX} and the causal bit. Layout, capacity, block, staging, reserve and overflow modes cross the u32 threshold-edge set. Scale tests cross every f32 sign/exponent with mantissas {0,1,all-ones}, both scale modes and every admitted head dimension, plus neighbours of the scale ceiling. |
876| `api_ew_plan` / elementwise | Every dimension 0..16385 crosses row-count edges; every 1-D length 0..262145 covers the 131072-element chunk cap, 128-thread residues and exchange alignment. Rope's even/odd and 2048 ceiling classes and RMS's 128 divisibility and 16384 ceiling are exhaustive within their admitted dimensions. All reconvergence operation offsets 0..6 cross length edges. |
877| `api_bf_plan` / BF16 GEMV | Every K 0..16385 crosses all combinations of default/nondefault tuning knobs; individual overrides also cross u32 edges. Every N 0..65536 crosses rows 1..4 and 16/32 warps, covering row divisibility and capped-grid classes. Every recorded row count 0..65536 crosses record, mask, tau, xbatch 0..5 and y-stride threshold classes. Register budgets exhaust warps 0..1024 and declarations 0..512. |
878| `api_da_plan` / decode attention | Every position/capacity 0..131073 crosses layers 0..65. Every legal position 0..131071 crosses every 256-aligned split size through 131072; every larger representable u32 aligned split size is exercised at the maximum legal position (the split count is then always one). The explicit UINT32_MAX-adjacent split case catches the old addition overflow. Layer/head/span boundaries cross the edge set; theta tests cover signed zero, subnormal, finite positive/negative, infinity and NaN; every declaration 0..1024 crosses the register bound. |
879| `api_rt_plan` / router | Every layer 0..65 crosses experts 0..257 and shared 0..2, including both supported expert counts and their neighbours. Every row count 0..65 crosses x-strides 8176..8224 and launch-buffer strides 16640..17152 for both launch-buffer sizes. Those stride intervals include both refusal thresholds and every modulo-16/modulo-256 class. Layer/rows/record/buffer-selection products and all tuning/stride edges exercise plan results; register budgets exhaust warps 0..1024 and declarations 0..512. |
880
881Codegen admission additionally exhausts general/tuned attention selection,
882block logs 0..33, GQA logs 0..8 and head dimensions 0..257, including refusal
883precedence when several fields are invalid. Split and elementwise mutant
884controls cross every accepted value, both rejection/clamping sides and signed
885int extremes. The matmul CTA setter crosses every budget 0..1025 and edges.
886
887The shared edge set includes zero, all policy thresholds and their neighbours,
888power-of-two/divisibility transitions, and UINT32_MAX-1/UINT32_MAX. Bounds
889cover all finite admitted shape axes; larger values select rejection,
890saturation or the same quotient/bit-mask classes, with explicit overflow
891edges. This is bounded exhaustive differential evidence, **not** a formal
892equivalence proof over the Cartesian product of arbitrary u32/u64 words or
893every floating-point mantissa. No such unbounded proof is claimed.
894
895The short-view ABI negative control must refuse before writing its result.
896`tests/runtime/api_plan_mutants.py` changes two unique source expressions in
897each root, compiles each changed `.om` with the pinned compiler, and requires
898the unchanged differential to fail. A compiler error does not count as a
899killed mutant. `test-api-plan` is registered in `CARRIED_HOST_TESTS`;
900source mutation is separate because it executes the AArch64 compiler.
901
902The max-position adapter gate retains seven controls against five checked
903generated-binding mutants. Its read-position, write-count and step-position
904controls now target the same shared Omega span predicate, but must each emit
905their own failed API expectation. The other controls cover both cap boundaries,
906the separate write-position guard, and short RoPE allocation. A
907`--revert-first` runner invocation deliberately restores the first mutation;
908the unchanged binding must pass the API battery, and the mutation gate must
909reject it with exit 1. Both the ordinary and reverted runs use the device-free
910wrapper below. These portable binding controls do not replace the two pinned
911`.om` source mutants per new unit.
912
913Focused host-only reproduction, with the existing pinned compiler/bridge:
914
915```sh
916export OMEGA_OMC=/path/to/omega-mv/seed/out/omc
917export OMEGA_BRIDGE=/path/to/omega-bridge
918bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 sh om/units.sh
919bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 test-api-plan test-api-plan-mutants
920bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 test-gpu-matmul-api test-gpu-elementwise \
921 test-gpu-attention test-gpu-bf16-gemv test-gpu-decode-attn test-gpu-router
922bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 make -j3 OUT_DIR=build/api-plan-c \
923 CC='cc -DCUDAPP_MIGRATION_PENDING_C_API_PLAN=1' \
924 test-gpu-matmul-api test-gpu-elementwise test-gpu-attention \
925 test-gpu-bf16-gemv test-gpu-decode-attn test-gpu-router
926```
927
928The separate output directory prevents stale objects from hiding a switch
929change. These targets exercise existing host and simulator cases only.
930Full host integration remains a separate integrator gate; chip qualification
931and deployment require their own authorization and receipts.
932
933The f32 ceiling-neighbour literals in the differential come from
934`WolframLanguageEvaluator:
935n=Round[(3*10^38/2^127)*2^23];
936Table[IntegerString[(127+127)*2^23+n-2^23+i,16],{i,-2,2}]`
937→ `{"7f61b1e4","7f61b1e5","7f61b1e6","7f61b1e7","7f61b1e8"}`.
938Other numerical policy literals are unchanged from the incumbent adapters.
939
940## 11. Checking this file
941
942`make test-runtime-api` runs `tools/runtime_api_check.sh` on the real headers and then `tools/runtime_api_negative.sh`. The
943negative script breaks a copy of the headers (or this file) in fourteen ways and requires the check to fail each time: a
944removed function, a missing MAJOR and a missing PATCH version macro, a changed function signature, a changed struct, a
945changed constant, a version line in this file that disagrees with the macro, a quoted signature in this file that no header
946has, a quoted signature that only appears inside a longer one (`int32_t` inside `uint32_t`), a STABLE entry with no section
947here, an added undeclared function, an added undeclared macro, an added undeclared enumerator, and a stale INTERNAL entry.
948The scratch header tree includes all `src/*.h` dependencies, including generated
949bridge declarations, so a control must fail for its intended API mismatch rather
950than an unrelated missing include.
951It then breaks a copy of the manifest five ways and requires `tools/runtime_api_semver.sh` to fail each time (a removed
952STABLE function with no bump on a 0.x base, a removed STABLE function with only a MINOR bump on a base already at 1.x, a
953changed STABLE signature with no bump, an added function with no bump, a version that goes down) and to pass two correct
954changes (a removed STABLE function with a MINOR bump on a 0.x base; an added function with a MINOR bump).
955`make test-runtime-api-semver` compares the real manifest with the base branch's. None of it needs a GPU or a physics
956checkout. It checks: every manifest function against its header with exact types; sizes, offsets and constants against a
957compiled probe; the version macros against the manifest and this file; every public name in the manifest headers against
958the manifest and the INTERNAL list; that every STABLE entry has a `####` section here and every EXPERIMENTAL one is named
959here; that every C signature quoted in this file appears verbatim in a header; and the size of the version bump. It does
960not check that the prose is true. A struct field added inside padding is not seen, nor a field that changes type but keeps
961its size, nor a constant value quoted in prose, nor a new type (struct or typedef) that no function uses yet, nor a
962function-like macro.
963
964## 12. Any-shape attention (EXPERIMENTAL)
965
966Header: `src/omega_gpu_attn_any_api.h`. `OmegaGpuAttnAnyShape` carries
967`seq_q`, `seq_kv`, `head_dim`, `q_heads`, `kv_heads`, `causal`, `dtype` (u32)
968and `scale` (f32), in that order. Contiguous `[head][sequence][component]`
969Q/K/V use dtype `OMEGA_GPU_ATTN_ANY_F32` (0), `OMEGA_GPU_ATTN_ANY_BF16` (1)
970or `OMEGA_GPU_ATTN_ANY_F16` (2);
971output is f32. Head dimensions 1..`OMEGA_GPU_ATTN_ANY_MAX_HEAD_DIM` (256),
972sequence lengths 1..65535 and head counts 1..65535 are admitted when KV heads
973divide Q heads and each tensor has at most 1073741824 elements. No padding or
974power-of-two restriction exists. Causal mode 1 means top-left alignment
975(`key <= query`), including rectangular matrices; mode 0 is non-causal.
976Scale is a finite caller-provided multiplier, including zero and negative values.
977Inputs and intermediate dots must be finite; the call does not scan input values.
978All other dtype values are refused, not widened or reinterpreted.
979
980```c
981int omega_gpu_attn_any(const OmegaGpuAttnAnyShape *shape, const void *q, const void *k, const void *v, float *out);
982int omega_gpu_attn_any_codegen(const OmegaGpuAttnAnyShape *shape, BlackwellIRProgram *program, uint8_t *code, size_t capacity, OmegaBlackwellKernel *kernel);
983```
984`omega_gpu_attn_any_codegen` generates an admitted shape's IR and encoded kernel
985without opening a device. The execution entry point `omega_gpu_attn_any` owns
986allocations, copies and launches; both use the same seeded admission unit.
987
988
989Both return `OMEGA_GPU_ATTN_ANY_OK` (0), `REFUSED` (1) for unsupported
990geometry/format, `BAD_ARGS` (2) for null arguments, `CODEGEN` (3) for
991generation/encoding/storage failure, or `CHIP` (4) for device execution failure.
992These names all have prefix `OMEGA_GPU_ATTN_ANY_`. Refusals happen before
993device open. Codegen is CPU-only and writes caller-owned storage; kernel code
994aliases `code` and owns nothing. The execution entry allocates GPU memory,
995launches one warp per query row per query head, then copies output back.
996The session retains its normal uncertain-completion latch/parking policy.
997Online softmax uses f32 dot/accumulator/running maximum and sum.
998See `om/attn-any/README.md` for the tested numerical envelope and
999`om/attn-any/CHIP.md` for the operator-gated chip procedure. No performance or
1000chip-qualification claim is made.
1001
1002
1003## 13. DNN layers (EXPERIMENTAL)
1004
1005### 13.1 Scalar formats (`src/omega_gpu_dnn_types.h`)
1006
1007`OMEGA_GPU_DNN_F32` (0), `OMEGA_GPU_DNN_BF16` (1) and
1008`OMEGA_GPU_DNN_F16` (2) identify distinct contiguous scalar input storage
1009formats. DNN kernels use f32 accumulation and f32 output. Neither 16-bit
1010format is an alias for the other. These constants are EXPERIMENTAL;
1011native conversion encoding is host/oracle exercised, not chip qualified.
1012
1013### 13.2 Row softmax and normalization (`src/omega_gpu_dnn_rows_api.h`)
1014
1015CPU-only builder: `omega_gpu_dnn_rows_codegen`. Execution shell:
1016`omega_gpu_dnn_rows`.
1017
1018```c
1019int omega_gpu_dnn_rows_codegen(const OmegaGpuDnnRowsShape *shape, BlackwellIRProgram *program, uint8_t *code, size_t capacity, OmegaBlackwellKernel *kernel);
1020int omega_gpu_dnn_rows(const OmegaGpuDnnRowsShape *shape, const void *input, float *output);
1021```
1022
1023`OmegaGpuDnnRowsShape` contains `uint32_t rows, length, dtype, op` and
1024`float epsilon`. Input and output are contiguous `[rows][length]`; output is
1025f32 for every storage type. Rows and length are independently 1..65535,
1026with at most 1073741824 elements. `OMEGA_GPU_DNN_SOFTMAX` (0) selects stable
1027row softmax, `OMEGA_GPU_DNN_LAYERNORM` (1) mean-centered normalization, and
1028`OMEGA_GPU_DNN_RMSNORM` (2) root-mean-square normalization. Norms have no
1029affine transform. Their epsilon must be positive finite **normal** f32;
1030softmax ignores epsilon.
1031
1032Finite inputs and finite intermediate differences, sums, squares,
1033variance-plus-epsilon and output are caller preconditions. The codegen entry
1034is CPU-only. The execution entry requires an authorized GPU window; Omega
1035rejects unsupported geometry, storage, operation and epsilon before session
1036access. Status constants are `OMEGA_GPU_DNN_ROWS_OK` (0),
1037`OMEGA_GPU_DNN_ROWS_REFUSED` (1), `OMEGA_GPU_DNN_ROWS_BAD_ARGS` (2),
1038`OMEGA_GPU_DNN_ROWS_CODEGEN` (3), and `OMEGA_GPU_DNN_ROWS_CHIP` (4).
1039See `om/dnn-rows/README.md` for the independent double oracle, MODELED test
1040envelope and finite numerical test domain, and `om/dnn-rows/CHIP.md` for the
1041operator-gated NOT_RUN procedure. MUFU simulation is not a chip accuracy bound.
1042
1043### 13.3 Elementwise activations (`src/omega_gpu_dnn_activations_api.h`)
1044
1045CPU-only builder: `omega_gpu_dnn_activations_codegen`. Execution shell:
1046`omega_gpu_dnn_activations`.
1047
1048```c
1049int omega_gpu_dnn_activations_codegen(const OmegaGpuDnnActivationsShape *shape, BlackwellIRProgram *program, uint8_t *code, size_t capacity, OmegaBlackwellKernel *kernel);
1050int omega_gpu_dnn_activations(const OmegaGpuDnnActivationsShape *shape, const void *input, float *output);
1051```
1052
1053`OmegaGpuDnnActivationsShape` contains `uint64_t elements` and
1054`uint32_t operation, dtype`. Nonempty contiguous counts through `UINT32_MAX`
1055are admitted, including non-warp multiples. Input uses the shared storage
1056constants; arithmetic and output are f32. `OMEGA_GPU_DNN_RELU` (0),
1057`OMEGA_GPU_DNN_GELU_ERF` (1), `OMEGA_GPU_DNN_GELU_TANH` (2) and
1058`OMEGA_GPU_DNN_SILU` (3) select the operation. Inputs must be finite and caller
1059buffers large enough; input values are not scanned on the host.
1060
1061Erf GELU uses the documented A&S 7.1.26 approximation; tanh GELU and SiLU use
1062stable negative-exponential forms. Signed zero is preserved. The codegen
1063entry is CPU-only; execution requires an authorized GPU window. Admission
1064precedes session access. Status constants are
1065`OMEGA_GPU_DNN_ACTIVATIONS_OK` (0), `OMEGA_GPU_DNN_ACTIVATIONS_BAD_ARGS` (1),
1066`OMEGA_GPU_DNN_ACTIVATIONS_REFUSED` (2),
1067`OMEGA_GPU_DNN_ACTIVATIONS_CODEGEN` (3), and
1068`OMEGA_GPU_DNN_ACTIVATIONS_CHIP` (4).
1069See `om/dnn-activations/README.md` for formulas, saturation, the Wolfram
1070queries/results and the independent reference envelope, and
1071`om/dnn-activations/CHIP.md` for the operator-gated NOT_RUN procedure.
1072
1073### 13.4 Implicit conv2d (`src/omega_gpu_conv2d_api.h`)
1074
1075CPU-only planner: `omega_gpu_conv2d_plan`; builder:
1076`omega_gpu_conv2d_codegen`. Execution shell: `omega_gpu_conv2d`.
1077
1078```c
1079int omega_gpu_conv2d_plan(const OmegaGpuConv2dShape *shape, uint64_t launch, uint64_t plan[32]);
1080int omega_gpu_conv2d_codegen(const OmegaGpuConv2dShape *shape, BlackwellIRProgram *program, uint8_t *code, size_t capacity, OmegaBlackwellKernel *kernel);
1081int omega_gpu_conv2d(const OmegaGpuConv2dShape *shape, const void *image, const void *filter, float *output);
1082```
1083
1084`OmegaGpuConv2dShape` has eighteen `uint32_t` fields in declaration order:
1085`batch, in_channels, height, width, out_channels, kernel_h, kernel_w,
1086stride_h, stride_w, pad_top, pad_bottom, pad_left, pad_right, dilation_h,
1087dilation_w, groups, layout, dtype`. Image/output layout is contiguous
1088NCHW (`layout=0`) or NHWC (`layout=1`); filters are always OIHW
1089`[out_channels][in_channels/groups][kernel_h][kernel_w]`.
1090This is cross-correlation with independent top/bottom/left/right zero
1091padding, positive stride/dilation and groups, including depthwise cases.
1092There is no fused bias or activation. Input/filter storage uses the shared
1093DNN constants; accumulation/output are f32.
1094
1095Positive dimensions, strides, dilations and groups are at most 65535;
1096padding is 0..65535. Channels must divide by groups, output must be nonempty,
1097and every tensor element count and launch count must be below 1073741824.
1098The CPU-only planner returns output extents, byte counts, grid and launch
1099offsets in `plan[32]`; caller storage must cover those byte counts. The
1100codegen entry is CPU-only. The execution entry is a memory/session shell
1101requiring an authorized GPU window; admission occurs first.
1102
1103Convolution supplies virtual image/filter addresses to the same seeded
1104scalar dot-product reduction as default dense f32 GEMM. No global im2col or
1105production host arithmetic kernel is used. Existing tensor GEMM interfaces
1106remain unchanged; the old C scalar generator is a default-OFF differential
1107oracle. Status constants are `OMEGA_GPU_CONV2D_OK` (0),
1108`OMEGA_GPU_CONV2D_BAD_ARGS` (1), `OMEGA_GPU_CONV2D_REFUSED` (2),
1109`OMEGA_GPU_CONV2D_CODEGEN` (3), and `OMEGA_GPU_CONV2D_CHIP` (4).
1110See `om/conv2d/README.md` for planner output slots, independent reference
1111tolerances and test scope, and `om/conv2d/CHIP.md` for the operator-gated
1112NOT_RUN procedure. Performance and chip qualification remain NOT_RUN.