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