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
CUDApp / evidence / mathlibs-host-20261106 / README.md
| 1 | # Mathlibs host policy and planner migration |
| 2 | |
| 3 | Date: 2026-11-06. Branch: `feat/mathlibs-host-om`. |
| 4 | |
| 5 | ## Scope and provenance |
| 6 | |
| 7 | Base: `feat/mathlibs-gaps` (#317), `3d28358d48814779106588b19c94f62fc363d960`. |
| 8 | `git merge-base --is-ancestor origin/feat/mathlibs-rfft-2d-philox HEAD` |
| 9 | returned 0: this base already contains #303's RFFT, 2D and Philox additions. |
| 10 | Stack order is #303, then #317, then this draft; do not merge this directly |
| 11 | onto a main revision that omits either prerequisite. |
| 12 | |
| 13 | `664f21c3` registers the seeded unit first. `27919d0a` adds its typed ABI |
| 14 | entries, generated bindings and differential gate before the C cutover. |
| 15 | The cutover and this receipt follow those commits. `sources.sha256` records |
| 16 | the exercised implementation and test source identities. |
| 17 | |
| 18 | - **IMPLEMENTED:** default seeded Omega RNG admission/seed/count/poison |
| 19 | arithmetic, clock arithmetic, legacy FFT admission/walk expansion, and |
| 20 | PlanMany Stockham/Bluestein/axis/copy/layout/overlap planning. |
| 21 | - **EXERCISED:** device-masked host differential and existing host/sim gates PASS. |
| 22 | - **QUALIFIED:** chip, live RM, VFIO and other hardware tiers NOT_RUN. |
| 23 | - **MERGED / DEPLOYED:** no; this is a draft stacked change. |
| 24 | |
| 25 | No public API or capability changes: public headers, manifest and API.md are |
| 26 | intentionally unchanged. The README describes the default path and focused |
| 27 | gate; ROADMAP has one dated note and no status-row upgrades. No language, |
| 28 | compiler, bridge pin, host word or harness protocol changes are introduced. |
| 29 | |
| 30 | ## Implementation boundary |
| 31 | |
| 32 | `om/mathlibs/host.om` owns the computation. Its six small entry units are |
| 33 | `host_scalar.om`, `host_walk.om`, `host_step.om`, `host_many.om`, |
| 34 | `host_index.om` and `host_fft.om`. Separate typed entries follow the pinned |
| 35 | bridge's existing single-export/fixed-view ABI; there is no new converter or |
| 36 | second pin. `om/units.sh` registers them and generates six committed C units, |
| 37 | private declarations and identity receipts. Every entry is a strong reference. |
| 38 | |
| 39 | `CUDAPP_MIGRATION_PENDING_C_MATHLIBS_HOST` defaults to 0. The old C computation |
| 40 | is retained only behind that flag as the differential oracle. The default |
| 41 | adapter serializes inputs, calls Omega and performs effects: clock_gettime, |
| 42 | session locking, codegen/cache calls, allocation/free, byte loads/stores/copies, |
| 43 | callbacks, device launch, scratch transfers and synchronization. It does not |
| 44 | fall back to C when an Omega entry is absent or refuses an input. Clock reads |
| 45 | remain C effects; seconds/nanoseconds and elapsed-time arithmetic use Omega. |
| 46 | No new production dependency or GPU launcher is introduced. |
| 47 | |
| 48 | The fixed PlanMany output workspace has 8192 ulong cells. Like the existing |
| 49 | `g_words` effect workspace, it is protected by the session lock; completed |
| 50 | launches and table bytes are materialized into owned storage before public |
| 51 | callbacks. This avoids both a per-plan workspace allocation and a large |
| 52 | per-thread stack frame. No plan record survives by referencing the workspace. |
| 53 | The unit initializes all consumed fields and records; stale unused cells are |
| 54 | not read. The descriptor bound is 204 records; the source-derived conservative |
| 55 | upper bound for admitted rank-three transforms is 96, including table records. |
| 56 | At most nine distinct table keys are needed, below the existing 16-key cache. |
| 57 | These are modeled bounds, not hardware measurements; queries appear below. |
| 58 | |
| 59 | ## Reproduce the exercised commands |
| 60 | |
| 61 | All commands ran in this private worktree. The wrapper hides NVIDIA/VFIO |
| 62 | nodes, pins CPUs 10-14 and lowers priority. Builds use at most three jobs. |
| 63 | The runner refuses visible NVIDIA/VFIO nodes and executes its compilation, |
| 64 | coverage, differential, red, link-negative and mutant children inside the same |
| 65 | wrapper. No full `make test`, chip command or live service action was run. |
| 66 | Paths in retained logs replace `/home/drakestapleton` with `~`. |
| 67 | |
| 68 | ```sh |
| 69 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 \ |
| 70 | env OMEGA_OMC="$HOME/work/cudastack/omega-mv/seed/out/omc" \ |
| 71 | OMEGA_BRIDGE="$HOME/work/cudastack/omega-bridge" \ |
| 72 | make test-mathlibs-host-om |
| 73 | |
| 74 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 \ |
| 75 | make -j3 test-gpu-mathlibs |
| 76 | |
| 77 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 \ |
| 78 | env OMEGA_OMC="$HOME/work/cudastack/omega-mv/seed/out/omc" \ |
| 79 | OMEGA_BRIDGE="$HOME/work/cudastack/omega-bridge" \ |
| 80 | sh om/units.sh --check |
| 81 | ``` |
| 82 | |
| 83 | | Command / tier | rc | Observed final result | |
| 84 | | --- | ---: | --- | |
| 85 | | `make test-mathlibs-host-om` inside wrapper | 0 | `MATHLIBS-HOST-OM GATE PASS: differential, red, strong-link negative, gcov, 8 killed .om mutants` | |
| 86 | | Differential child, `-O0 --coverage -ffp-contract=off` | 0 | `MATHLIBS-HOST-OM PASS cases=2477` | |
| 87 | | Intentional wrong-index red child | 1, expected | `FAIL line 232 case 2477: omega_mh_index(l,e,1,1)==2` | |
| 88 | | Missing-six-units link child | 1, expected | `collect2: error: ld returned 1 exit status` | |
| 89 | | `make -j3 test-gpu-mathlibs` inside wrapper | 0 | `mathlibs sim: PASS (6265 checks)` | |
| 90 | | `sh om/units.sh --check` inside wrapper | 0 | `PASS portable Omega units regenerate byte for byte` | |
| 91 | | `crumb compile . && crumb verify .` before commits | 0 | `crumb verify: OK: 39 crumbs current` | |
| 92 | |
| 93 | The missing-unit log contains unresolved `omega_native_mhval`, `mhwalk`, |
| 94 | `mhstep`, `mhmany`, `mhidx` and `mhfft` references, including references from |
| 95 | the production API object. No weak-symbol or C fallback passes the control. |
| 96 | `acceptance.log` retains the complete combined command output; |
| 97 | `differential.log`, `red.log`, `missing-unit.log` and `mutants.tsv` retain the |
| 98 | focused results. |
| 99 | |
| 100 | The unchanged family gate also reports host RNG fixture 792 rows / zero |
| 101 | mismatches, Philox fixture 1024 rows / zero mismatches and the existing |
| 102 | Philox distribution negative controls. Its normal-double fixture rows are |
| 103 | explicitly not compared because that existing IR has no f64 normal path; |
| 104 | this receipt does not turn that inherited limitation into a PASS. |
| 105 | |
| 106 | ## Source-derived partitions |
| 107 | |
| 108 | | Surface | Exercised values / comparison | |
| 109 | | --- | --- | |
| 110 | | Legacy FFT | Every power of two 4..2048, both directions, all legacy modes; invalid dimensions and nonpowers; rank 1..3, summed-log bound rejection; batches 0, 1, 1023, 1024, 1025. Compare rc, byte requirements, every launch field and twiddle bytes. | |
| 111 | | PlanMany shapes | 2, 3, 5, 6, 7, 8, 11, 16, 30, 64, 127, 1024, 2047, 2048, 2049, 4095, 4096; rank 1..3 and C2C/R2C/C2R, both directions, in/out of place. Multi-Bluestein axis pairs (13,11), (11,31), (31,11) exercise workspace growth/reuse and distinct table keys. | |
| 112 | | Layout fields | For stride, distance, embed, rank and each dimension axis: 0, 1, 2, 3, 4, 5, 15, 16, 17, 4095, 4096, 4097, UINT32_MAX. Include zero stride, overlapping rows/batches and explicit collision bitmaps. Compare admission codes; successful plans compare all launches, bytes and table bytes. | |
| 113 | | Global and scratch products | n=4 batch 33554431/33554432/33554433; Bluestein n=11 batch 8388607/8388608/8388609; layout distance 268435451/268435452/268435453. These surround the source's point, scratch and byte-range bounds without allocating those extents in rejected cases. | |
| 114 | | RNG admission / seed | Every RNG kind and invalid kinds; stream bound 131071/131072/131073, zero and UINT32_MAX; per-stream limits and adjacent values; seeds 0, 1, UINT64_MAX and wrap-boundary values. Compare unsigned seed increment, poison predicates and count arithmetic against C. | |
| 115 | | Public effectful API admission | Default and C-oracle RNG, Philox and FFT calls with null/invalid inputs, bad sizes/types and overlapping valid host buffers. These return before GPU effects. Valid device execution remains NOT_RUN. | |
| 116 | | Failure controls | Null plan/bytes/dimensions, invalid mode/type/rank/inverse/in-place values; callback abort propagation; intentional wrong index; omitted mandatory unit symbols. | |
| 117 | | Float classes | Poison-scan words include positive/negative zero, subnormal, infinity and NaN encodings. These are raw sentinel classification/count tests, not a new floating arithmetic path: different NaN payloads are not asserted numerically equal. Plan/twiddle payloads compare exactly; existing simulator numeric checks remain unchanged. Compilation disables FP contraction. | |
| 118 | |
| 119 | ### Coverage limits and branch dispositions |
| 120 | |
| 121 | `coverage.log` is gcov from the separately compiled C-oracle/test translation |
| 122 | unit, **not** a claim of Omega branch coverage or whole-library chip coverage. |
| 123 | It reports 68.22% of 1010 lines overall; the API oracle alone reports 60.28% |
| 124 | of 798 lines. `many_build`, all many layout/index helpers, `many_axis`, |
| 125 | `many_copy`, `many_scan`, `lg_in` and `rng_args_ok` have 100% line execution; |
| 126 | `walk_locked` has 98.53% of 68 lines. Line coverage is not branch coverage. |
| 127 | `omega_gpu_mathlibs_api.c.gcov` retains the annotated oracle source. |
| 128 | `coverage-disposition.tsv` enumerates every uncovered oracle branch and maps |
| 129 | it to a disposition below; none is silently counted as covered. |
| 130 | |
| 131 | | Disposition | Why not exercised | |
| 132 | | --- | --- | |
| 133 | | `ALLOC` | Allocation-failure injection is not part of this gate; normal/reallocation paths and callback effects are exercised. Internal collector capacity is bounded by admitted IR steps. | |
| 134 | | `TABLE_INTERNAL` | Cache overflow requires more than 16 distinct keys, but admitted rank-three plans need at most nine. Other untaken legs require allocation failure or refusal of a validated internal table request. | |
| 135 | | `FACTOR_INTERNAL` | Invalid factor/radix/divisor responses require corrupted internal IR; validated dimensions supply nonzero divisors and valid factors. Remaining legs propagate allocation/IR failure. The real workspace-size rejection is exercised. | |
| 136 | | `COPY_INTERNAL` | Zero extents cannot reach copy construction from admitted nonempty dimensions; reciprocal-generation refusal requires invalid internal divisors. | |
| 137 | | `BASIC_BOUND` | The basic dense-layout embed bound is looser than the preceding global point bound, including the real in-place padding. Thus its overflow refusal is unreachable for admitted default layouts. | |
| 138 | | `PLAN_FAILURE` | Allocation/internal-IR failure propagation remains unexercised. The loop's rc-failure condition is bypassed by its explicit break. Both real length-versus-half-length outcomes are exercised. | |
| 139 | | `WALK_INTERNAL` | Untaken internal-codegen legs require malformed/refused validated IR or table allocation failure. Callback abort is injected at the first launch; later-stage callback-abort return legs are not separately injected. | |
| 140 | | `EFFECT_NOT_RUN` | Outside the pure-planner oracle comparison: device/session/launch/scratch/sync and cache/codegen effect management or their failure legs. Production host/sim codegen checks run separately; real device effects remain NOT_RUN. | |
| 141 | |
| 142 | ## Omega source mutants |
| 143 | |
| 144 | Each mutation is unique in `host.om`, regenerated through the pinned bridge |
| 145 | and compiled successfully. A regeneration or compilation failure is not |
| 146 | counted as a kill. Every executable below returned 1 instead of PASS. |
| 147 | |
| 148 | | Mutant | Generate rc | Compile rc | Run rc | Result | |
| 149 | | --- | ---: | ---: | ---: | --- | |
| 150 | | RNG stream limit 131072 -> 131073 | 0 | 0 | 1 | KILLED: admission mismatch | |
| 151 | | Seed increment i+1 -> i+2 | 0 | 0 | 1 | KILLED: seed mismatch | |
| 152 | | 64-bit poison constant last digit | 0 | 0 | 1 | KILLED: sentinel mismatch | |
| 153 | | Chunk grid bound 1024 -> 1023 | 0 | 0 | 1 | KILLED: launch mismatch | |
| 154 | | Zero-stride predicate 0 -> 1 | 0 | 0 | 1 | KILLED: admission mismatch | |
| 155 | | Real half-length +1 -> +0 | 0 | 0 | 1 | KILLED: plan byte mismatch | |
| 156 | | Axis rotation chooses wrong first axis | 0 | 0 | 1 | KILLED: plan collection mismatch | |
| 157 | | Overlap bitmap bit mask 7 -> 6 | 0 | 0 | 1 | KILLED: fill/index mismatch | |
| 158 | |
| 159 | ## Pins and arithmetic receipts |
| 160 | |
| 161 | - Seeded omc revision `e5b32567`; binary SHA-256 |
| 162 | `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. |
| 163 | - Existing toc pin: `69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84`. |
| 164 | - Existing bridge-seeded pin: `23ff7a2356bb5d980060a4685a27ac46587013069b7d24b37c2873d7ee659b37`. |
| 165 | - Existing freest pin: `836cbf9ef8a3c4ee82b0458070884405bc8296f83b10f933556bf27750bb3661`. |
| 166 | - Existing bridge-freest pin: `51b41794e7001c5606b715fd7de8a34ec935a6e4e4bc1da36ad08102c009537d`. |
| 167 | |
| 168 | WolframLanguageEvaluator queries (integer bounds/counts, not measurements): |
| 169 | |
| 170 | ```text |
| 171 | {FromDigits["ffbadbad",16],FromDigits["00badbad",16],FromDigits["ffbadbadffbadbad",16],2^28,2^27,1024*128,2^32,2^32-1,FromDigits["9e3779b97f4a7c15",16]} |
| 172 | -> {4290436013,12245933,18427282365706066861,268435456,134217728,131072,4294967296,4294967295,11400714819323198485} |
| 173 | |
| 174 | {2^28-4,2^28-4+{-1,0,1},Floor[(8192-32)/40],3*(4+3*Ceiling[13/2])+12+9,2^32-1,2^28-1} |
| 175 | -> {268435452,{268435451,268435452,268435453},204,96,4294967295,268435455} |
| 176 | |
| 177 | {2^27/4,2^27/4+{-1,0,1},2^28/32,2^28/32+{-1,0,1}} |
| 178 | -> {33554432,{33554431,33554432,33554433},8388608,{8388607,8388608,8388609}} |
| 179 | |
| 180 | {3*3,8192*8,Floor[(8192-32)/40],3*(4+3*Ceiling[13/2])+12+3*3} |
| 181 | -> {9,65536,204,96} |
| 182 | ``` |
| 183 | |
| 184 | The last query gives table-key count, workspace bytes, output capacity and |
| 185 | conservative maximum records. The maximum Stockham pass count uses M<=8192; |
| 186 | each admitted axis contributes at most four other Bluestein records and three |
| 187 | Stockham sequences. Twelve copy/rotation records and nine table records are |
| 188 | reserved conservatively. |
| 189 | |
| 190 | ## Chip runbook — NOT_RUN |
| 191 | |
| 192 | There is no authorized GPU window for this lane. The mandatory wrapper hides |
| 193 | devices and cannot produce hardware qualification. Do not remove that masking, |
| 194 | stop a serving process, touch the chip lock or load/unload a driver to run this |
| 195 | receipt. No historical authorization is reused. |
| 196 | |
| 197 | A future operator must first obtain a current exclusive hardware window and |
| 198 | follow the then-current GPU/session authorization procedure, including service |
| 199 | ownership and permitted device nodes. Build the same committed revision and |
| 200 | retain its source/binding identities in a **new** evidence directory. With the |
| 201 | operator-approved device-visible execution wrapper, the existing executable's |
| 202 | chip tier is selected by omitting `--sim` and `--host-only`: |
| 203 | |
| 204 | ```text |
| 205 | ./build/gpu_mathlibs_test --out <new-chip-receipt-directory> |
| 206 | ``` |
| 207 | |
| 208 | This is a runbook command, not a command run by this lane. There is no `--chip` |
| 209 | flag. Preserve the executable's RNG, FFT, Philox, real/ND, poison, repeat and |
| 210 | negative-control receipts; unexpected refusal, mismatch or untouched output |
| 211 | is FAIL/INCONCLUSIVE, never PASS. Record device/driver identity and restore |
| 212 | services only under the operator's current instructions. |
| 213 | |
| 214 | That existing chip entry point does not cover the complete PlanMany matrix. |
| 215 | Before qualifying PlanMany, an authorized device run must additionally exercise |
| 216 | C2C/R2C/C2R, Stockham and multi-Bluestein ranks, explicit layouts, overlap |
| 217 | refusals and batch/stride boundaries through the public API against the host |
| 218 | reference, including repeat/poison controls. The current host plans and |
| 219 | simulator results are not substitutes for that hardware check. All hardware |
| 220 | results, including PlanMany, remain NOT_RUN here; the integrator also owns the |
| 221 | full combined repository gate, which this focused lane did not run. |