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 / om / codegen / README.md

131 lines · 7393 bytes Raw Blame History Rendered
1# Seeded Blackwell codegen: remaining families
2
3The default implementations of the attn256, pattn256, router, FP8 GEMM,
4BF16 GEMV, activation quantizer (pq), and grouped quantized GEMM (qg)
5builders are the `cg_*.om` units in this directory. The public C signatures
6are unchanged. The original builders remain differential oracles behind
7`CUDAPP_MIGRATION_PENDING_C_CODEGEN_<FAMILY>=1`, default off, where FAMILY is
8ATTN256, PATTN256, ROUTER, GEMM, BF16, or QG.
9
10## Ownership and data flow
11
12`src/omega_codegen_rest_wire.h` only widens public structure fields and copies
13query results. It contains no configuration validation, instruction selection,
14scheduling, geometry calculation, register assignment, or encoding policy.
15Each root copies its configuration prefix before replacing the buffer with
16IR records. The builder's memory shell calls `omega_gpu_om_ir_replay` with
17that root callback; the common CUDApp replay path owns IR decoding,
18loop-aware liveness, one register-allocation solve, and seeded encoding.
19
20The roots share `cg_rest_emit.om`. Its instruction scheduling is the existing
21non-256 attention lane's emitter convention, reused without changing that
22lane's files. Qg additionally composes the existing
23`om/prefill-shape/admit.om` and `order.om` policies through `om/units.sh`.
24There is no host-language interpreter or source converter in the production
25path. The committed `.om` is compiled by the pinned seeded compiler through
26the existing Omega Bridge exporter.
27
28Function-local state is explicitly indexed in a bounded array to respect the
29seeded function-mode parameter and live-name limits. Input/output slot maps
30follow each helper declaration; local declarations carry their C name, type,
31and state slot. Instruction values occupy separate state records: initializing
32an instruction before an intervening helper emits another instruction must
33not lose the first instruction's value. Conditional calls and conditional
34allocations retain C's short-circuit and lazy-branch semantics. Array initializer
35elements are emitted sequentially: allocating a conditional second scale
36register must not move it ahead of the first initializer. The qg SwiGLU
3732-row, four-warp, 256-column configuration is a focused regression for that
38ordering, as well as part of the output-span corpus.
39
40## Root ABI
41
42Each `cg_<family>` root takes four scalars (`kind`, reserved `a`, `b`, `c`),
43an edit array of 8192 words, and an edit metadata array of 512 words.
44The memory shell places each spec's fields, in declaration order, in words
450 onward. Signed `mutant` fields are sign-extended. Word 15 indicates a
46non-null spec and word 16 a non-null query-output structure. Invalid kinds
47are refused. Query roots place their scalar result in metadata word 48 and
48structure fields, in declaration order, in words 32 onward.
49
50| Unit | Query kinds | Builder kind |
51| --- | --- | --- |
52| attn256 | 0 shape | 1 decode attention |
53| pattn256 | 0 shape, 1 spec admission | 2 prefill attention |
54| router | 0 shared-memory layout | 1 router |
55| gemm | 0 steps, 1 shared bytes | 2 FP8 GEMM |
56| bf16 | 0 steps, 1 shared bytes | 2 BF16 GEMV |
57| qg | 0 pq admission, 2 qg admission, 3 shared bytes, 4 span | 1 pq, 5 qg |
58
59Successful builders return the existing eight-word IR-record ABI documented
60in `src/omega_gpu_om_ir.h`. Metadata word 6 is the opt-in physical GPR limit:
61zero preserves the historical `omega_bw_ir_init` default; a nonzero value
62must be greater than `BW_PHYS_GPR_MAX` and no greater than
63`BW_PHYS_GPR_HW_LIMIT`. Replay validates the full-width value before changing
64the destination program. The qg rt=8 geometry requests the existing hardware
65limit; the other geometries retain zero. The metadata word 7 scheduler scratch
66is cleared by the terminal unconditional EXIT before the root returns; this
67lane does not define any exact-last-use-override schema.
68
69## Admission repair
70
71The legacy FP8 GEMM admission check multiplied full-width `mt` before checking
72the shared-memory bound. A large power-of-two `mt` could wrap the product to
73zero and admit a geometry that overruns fixed accumulator arrays. Both the C
74oracle and Omega now compare `mt` against the shared-memory bound divided by
75the already validated lane-byte factor, before any multiplication. The
76boundary corpus includes the high-bit `mt` counterexample. Ordinary admitted
77geometries are unchanged.
78For multi-token attention, a valid head ratio can still have a non-power-of-two
79virtual-row count above the high bit. The old logarithm shifted a 32-bit value
80by 32 before reaching its refusal. UBSan reproduced this with equal
81`UINT32_MAX` query/KV head counts and one query per CTA. C and Omega now reject
82non-powers before the logarithm. The corpus includes the high-bit boundary on
83both sides, the maximum, and a small non-power; valid power-of-two rows retain
84the same instruction stream.
85
86
87## Reproduction
88
89Use omega-mv e5b32567 and seeded omc SHA256
90`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`.
91Set `OMEGA_MV`, `OMEGA_OMC`, and `OMEGA_BRIDGE` to the checked sibling trees.
92All host tests, simulations, differentials and mutants must run with a minimal
93`/dev`; none of these commands authorize hardware access:
94
95```sh
96bwrap --dev-bind / / --dev /dev --proc /proc -- \
97 taskset -c 10-14 nice -n 10 make -j3 test-codegen-rest
98bwrap --dev-bind / / --dev /dev --proc /proc -- \
99 taskset -c 10-14 nice -n 10 make -j3 test-codegen-rest-sim
100bwrap --dev-bind / / --dev /dev --proc /proc -- \
101 taskset -c 10-14 nice -n 10 make -j3 test-om-ir-limit
102bwrap --dev-bind / / --dev /dev --proc /proc -- \
103 taskset -c 10-14 nice -n 10 sh om/units.sh --check
104```
105The make target supplies `CODEGEN_REST_BINDING` from the shared
106`BW_CODEGEN_BINDING` provider list plus `src/sha256.c`. The differential uses
107the portable encoder ABI, with explicit retained C allocator/matmul/packing
108prerequisites; it does not select the separate native NO_POSIX encoder ABI.
109Hosted BF16 allocation wrappers are renamed in the C oracle as well.
110
111
112`tests/codegen_rest_check.py` independently compiles the C oracle with renamed
113symbols and the default Omega path. It checks IR fields, the complete allocator
114state, encoded bytes, public geometry queries, and refusals, including null
115builder inputs. The grids cover every admitted K step, discrete geometry axes,
116all pq group counts through 32, BF16 mask/batch/stride/mutant interactions,
117and qg output-span/group interactions. Attention includes full-width valid
118head-count pairs, not only individually invalid field perturbations.
119Every family also receives zero and `UINT32_MAX` for every scalar input,
120each branch-threshold center and its immediate neighbours, and deterministic
121generated single-field perturbations. The domain is a **partition plus
122boundaries derived from the C branch conditions**; it is not an enumeration
123of the uint32 Cartesian product. The carried target builds the retained
124builders with `-O0 --coverage` and writes per-source line/branch counts and
125uncovered arc locations to `coverage.json` in its build directory. The dated
126receipt records branch coverage X/Y and accounts for every uncovered arc.
127The runner flips an IR record and recompiles semantic scheduler mutants for
128every unit, plus the required ignore-meta[6] qg mutant.
129
130Hardware qualification is separate. See [CHIP.md](CHIP.md) and the dated
131receipt under `evidence/codegen-rest/2026-11-06/`.