omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / evidence / native-freestanding-f32 / README.md
| 1 | # Private FP32 behind the integer-only freestanding native ABI |
| 2 | |
| 3 | Status: **IMPLEMENTED and EXERCISED**, draft only; not merged or deployed. This is the |
| 4 | separate private-FP32 followup to bridge #72 at `12f8132c2fe0ad240430583c85e0d9c4f7bd1c33`. |
| 5 | The preceding OM2-array/private-FP64 receipt remains immutable in |
| 6 | `../native-freestanding-om2-nolibc/`. Its whole-attention refusal describes that earlier |
| 7 | profile, not this extension. Drake must review and approve the profile and gate-expectation |
| 8 | change before merge. No physical-x86, firmware, NVIDIA-driver or GPU qualification is claimed. |
| 9 | |
| 10 | ## What changed |
| 11 | |
| 12 | The first-party implementation is `src/native.om`, sha256 |
| 13 | `d1ee759748139bb703b20e4da43d8508fe8e15a9f2bb6cdcf8e682963ec3ef3c`. |
| 14 | Its bounded whole-source scanner now admits private `f32` operations and explicit `f32` |
| 15 | literal suffixes, alongside the already admitted private `f64`. A small scalar branch |
| 16 | keeps the scanner within the seeded compiler's live-value limit. No compiler, public ABI, |
| 17 | view runtime, native trampoline, host-word allowlist or portable converter changes. |
| 18 | `src/toc.om` remains sha256 |
| 19 | `69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84`. |
| 20 | The C files added/extended here are verification oracles, not production implementations. |
| 21 | |
| 22 | Public floating parameters, results and view elements remain refused. Both widths are |
| 23 | covered in fourteen genuinely compiled fixtures: scalar parameter/result, fixed view/edit/out, |
| 24 | and dynamic view/edit. Each actual compiled frame must produce direct generator **exit110 |
| 25 | and empty stdout**, then CLI exit110 without installed wrapper output. The direct check |
| 26 | prevents the CLI's generic generator-error mapping from disguising a crash as refusal. |
| 27 | |
| 28 | The unused host-helper negative control is deliberately scanner-only: the pure e5/be8c |
| 29 | compilers do not admit that host word in function mode. The test appends an unused helper |
| 30 | to a clean source frame and reuses its code solely to reach the whole-source scanner, |
| 31 | requires exact generator110/empty output, and never executes the mismatched frame. |
| 32 | This is not a claim that the pure compiler compiled a host helper. |
| 33 | |
| 34 | ## FP32 semantics and independent oracle |
| 35 | |
| 36 | `tests/native/freestanding/f32.om` exports only an integer bit-pattern interface. Private |
| 37 | FP32 identity, add, divide, negate, a helper call, separate multiply/add, and comparison |
| 38 | flags are exercised over the raw operand matrix in `f32.c`. That C oracle uses volatile |
| 39 | FP32 operands and `-ffp-contract=off`; it checks signed zero, subnormals, infinities, |
| 40 | finite extremes, NaNs, RNE ties and a non-contracting witness. The bare and hosted callers |
| 41 | consume the same actual Omega code and must emit identical **raw**, unmodified bytes on |
| 42 | the same target. This is not cross-architecture NaN-payload equality. |
| 43 | |
| 44 | The approved comparison contract is deliberately narrower than a NaN-payload promise: |
| 45 | |
| 46 | - Non-NaN results are bit-exact against the raw IEEE results produced by the seeded code. |
| 47 | - Include canonical-qNaN operand `0x7fffffff` and other positive/negative NaN payloads. |
| 48 | - Arithmetic NaN results are compared by **NaN class only**. `0x7fffffff` is a documented |
| 49 | comparison canonicalization on local comparison copies, not an omc semantic or payload assertion. |
| 50 | - Identity and comparison flags remain exact. Never rewrite the integer-ABI output array. |
| 51 | - No claim that raw `0/0` bits equal `0x7fffffff`. |
| 52 | - FP control state is inherited; this does not add soft-float or qualify a firmware FP setup. |
| 53 | |
| 54 | The oracle's own controls accept a different NaN payload as the same class, but reject an |
| 55 | infinity substituted for NaN, a one-bit finite change, wrong status and a high-word change. |
| 56 | A wrong-result caller exits90. Three exactly-one-site source mutants are caught: add->sub |
| 57 | exits2; widening the intermediate product to FP64 exits2 on the non-contracting witness; |
| 58 | normalizing the integer identity's NaN output exits3. Two exactly-counted generator mutants |
| 59 | remove private-FP32 keyword admission or its literal suffix and restore refusal110 without |
| 60 | installed wrapper output. Neither a mutant nor the oracle normalizes production results. |
| 61 | |
| 62 | WolframLanguageEvaluator queries and results are committed verbatim in `wolfram-fp32.txt`, |
| 63 | `wolfram-attention.txt` and `wolfram-newton.txt`. They use exact rational IEEE rounding, |
| 64 | including RNE/subnormal packing, rather than an ad-hoc host floating calculation. Selected |
| 65 | query results, expressed as dimensionless raw uint32 bit patterns: |
| 66 | |
| 67 | - canonical-qNaN =2147483647, payload NaN =2143363909, negative payload NaN =4290847557; |
| 68 | - min subnormal =1, half minimum normal =4194304, RNE halfway-to-one =1065353216; |
| 69 | - the separate-vs-fused multiply/add witness yields `{0,2826960896}`; |
| 70 | - attention scale1.5 output =1074429868; |
| 71 | - the actual per-operation binary64 Newton model for64 takes8 iterations, reaches root8, |
| 72 | and yields attention output bits1043900987; the128 case yields1040356334; |
| 73 | - attention's finite3.0e38 FP32 threshold has bits2137108966. |
| 74 | |
| 75 | These are **modeled expectations**, not measured performance figures. Each query is paired |
| 76 | with its full tool result in the named text files; observed execution is in the logs. |
| 77 | The earlier binary64 oracle/comparison policy is unchanged. |
| 78 | |
| 79 | ## Whole actual nine-unit composition |
| 80 | |
| 81 | One invocation binds all nine separately copied units into one library; no concatenation, |
| 82 | mode extraction, reduced attention source, C algorithm substitution or ignored branch: |
| 83 | |
| 84 | 1. RegAllocOm `om/codegen/regalloc.om`, `regalloc_ir.om`, `regalloc_live.om`; |
| 85 | 2. CoreUtilOm `om/core/native.om`, `cubin.om`, `ampere.om`; |
| 86 | 3. ApiPlanOm `om/components/api_policy.om`, `api_mm_plan.om`, **whole `api_at_plan.om`**. |
| 87 | |
| 88 | The portable allocator/API sources receive exactly the approved `om2\n` prefix and no |
| 89 | other byte transformation; the core sources are already OM2. `nine-{a64,x86}-sources.json` |
| 90 | records original-source and actual-input SHA256 values. These byte identities are |
| 91 | authoritative; they do not assert another owner's worktree is clean. The whole attention |
| 92 | source SHA256 is `927e668a2dee55f0fc0b5d07f0311e75f03562e38ee13a2ace990762ab89f87f`, |
| 93 | composed-input SHA256 `1920de0d7e9993c09aef93740bc2cfb7dbb68b8e7b2ddbc98e275dd52af9a821`. |
| 94 | Its owner's reserved-name repair `part`->`partsz` is included; no local source repair or |
| 95 | algorithm change is hidden in the bridge fixture. |
| 96 | |
| 97 | The caller retains the allocator/IR/liveness/graph/CUBIN/private-FP64 checks, then exercises |
| 98 | actual policy remainder and matmul-view decisions, attention mode0 plan/refusal paths, |
| 99 | mode7 scale validation, and modes22/23 raw integer FP results against the Wolfram bit oracle. |
| 100 | Short spans return32 without changing the result or any caller word; untouched slots are |
| 101 | checked. The bare ELF has **no undefined symbols at all**, no interpreter and no TLS. |
| 102 | No `_exit`, setjmp/longjmp, memory helper, 128-bit-division runtime or libc is linked. |
| 103 | Raw hosted/bare byte streams must match on each target. |
| 104 | |
| 105 | Four exactly-one-site source mutants compile and link under the same bare constraints: |
| 106 | policy remainder reversal -> exit14; matmul view edit -> exit15; attention scale acceptance |
| 107 | reversal -> exit19; attention packed result change -> exit20. Each is caught before stdout. |
| 108 | The baseline snapshots are never mutated. A wrong-result control exits90. This qualifies |
| 109 | selected paths of the **whole** composition, not every mode or the full CUDApp API suite. |
| 110 | |
| 111 | ## Commands and observed results |
| 112 | |
| 113 | `commands.json` contains the actual argument arrays, relevant explicit environment values, |
| 114 | rc and receipt-log name for each final command and the two selected red probes. Environment |
| 115 | was inherited, not `env -i`. Final builds use `GOMAXPROCS=3`, `GOFLAGS=-p=3`; every test, |
| 116 | compiler/linker child and mutant stays inside this device-free namespace: |
| 117 | |
| 118 | ```sh |
| 119 | bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 <command> |
| 120 | ``` |
| 121 | |
| 122 | There is no rerun outside it. `~` replaces `/home/drakestapleton` in all published text. |
| 123 | Receipt transport verifies each complete raw source byte count before that one HOME-prefix |
| 124 | normalization; `transfers.json` records both byte counts. Command traces encode captured |
| 125 | binary stdout as `stdout_hex`; no executable, NVIDIA binary, cubin, PTX or disassembly is |
| 126 | committed. `tools-and-source.txt` records source and verification-tool custody. |
| 127 | |
| 128 | The commands below are the payload after the wrapper; exact environments and full source |
| 129 | paths for the composition are in `commands.json`. |
| 130 | |
| 131 | | Command / tier | rc | Observed last line | Receipt | |
| 132 | |---|---:|---|---| |
| 133 | | `python3 tests/native/test_freestanding.py` (OM1 host) |0| `PASS source-swap control refuses original non-pure snapshot; reread mutant admits mismatched source/code and is caught` | om1-host.log | |
| 134 | | `python3 tests/native/test_freestanding_f32.py --out /tmp/bh/freestanding-f32-a64-compiled14` |0| FP32 bare-ELF PASS line quoted below | fp32-a64.log | |
| 135 | | Same with `--target x86linux --out /tmp/bh/freestanding-f32-x86-compiled14` |0| Same FP32 PASS line; EMULATED only | fp32-x86-emulated.log | |
| 136 | | `python3 tests/native/test_freestanding_om2.py` (OM2 host) |0| Same FP32 PASS line, after the OM2 controls | om2-host.log | |
| 137 | | `python3 tests/native/test_freestanding_aggregate.py --regalloc ~/work/cudastack/lanes/RegAllocOm --core ~/work/cudastack/lanes/CoreUtilOm --target aarch64linux --out /tmp/bh/freestanding-nine-a64 --api ~/work/cudastack/lanes/ApiPlanOm` |0| `PASS whole policy/mm/attention without libc: views/rem/private f32/f64, RNE conversion/Newton outputs, bad span untouched; four source mutants caught` | nine-a64.log | |
| 138 | | Same with `--target x86linux --out /tmp/bh/freestanding-nine-x86` |0| Same whole-composition PASS line; EMULATED only | nine-x86-emulated.log | |
| 139 | | `sh tests/native/v2/run.sh` (hosted A5 compiler) |1| **`NATIVE-V2 FAIL 1`** | v2-known-fail-one.log | |
| 140 | | `sh tests/native/x86/run.sh /tmp/bh/f32-native-x86-compiled14` |0| `NATIVE-X86 EMULATED PASS (six languages built and run; native x86 NOT_RUN)` | x86-emulated.log | |
| 141 | | `python3 tests/native/x86/device.py /tmp/bh/f32-native-device-compiled14` |0| `NATIVE-X86-DEVICE EMULATED PASS shared fixtures, 15 word controls, 5 ABI1 controls, 3-unit context ABI, 12 mutants; native/driver/chip NOT_RUN` | x86-device-emulated.log | |
| 142 | |
| 143 | The exact common FP32 final line is: |
| 144 | |
| 145 | ```text |
| 146 | PASS FP32 bare ELF: no undefined symbols, interpreter, TLS or libc; raw hosted bytes identical; three source and two generator mutants caught; 14 compiled public float interfaces and scanner-only host helper refused110 |
| 147 | ``` |
| 148 | |
| 149 | Pure AArch64 uses the pinned e5 compiler (SHA256 `2c824805...`), pure x86 the existing |
| 150 | be8c binary. Full hosted AArch64 uses the existing A5 b8f8 binary; the hosted x86-device |
| 151 | regression uses the #1050 c5ac binary. Full binary SHA256 values and exact paths appear in |
| 152 | `tools-and-source.txt`; no compiler pin silently changed. The OM1 generator compiler is |
| 153 | 734f0a39, not the OM2 compiler. |
| 154 | |
| 155 | ## Two different hoist observations, not a waiver |
| 156 | |
| 157 | `red-x86-obsolete-hoist-expectation.log` records the first x86 gate failing only its old |
| 158 | hard-coded claim that `hoist.om` exported float arrays and must still refuse110. Inspection |
| 159 | and the read-only consultant established the decisive point: its sole export `hadd` takes |
| 160 | an editable **ulong** array plus **ulong**, returning **ulong**; FP64/FP32 conversions are |
| 161 | private. It therefore belongs in this approved profile. |
| 162 | |
| 163 | The correction deletes only the obsolete `FREEST_REFUSED` constant/comment and its branch. |
| 164 | The existing OM2 predicate still requires baseline f637021 **110 with empty stdout** and |
| 165 | candidate **0 with nonempty stdout**. It does not skip hoist or accept arbitrary status. |
| 166 | All other byte comparisons, baseline pins, exact span-zero-initialization normalization, |
| 167 | its per-fixture counts and its one-byte negative control remain untouched. This is a |
| 168 | profile-specific expectation change requiring Drake's review, not a new normalization. |
| 169 | Generation acceptance alone is not a hoisting/register-preservation qualification. |
| 170 | |
| 171 | The distinct full AArch64 V2 gate still reports exactly one unchanged failure: |
| 172 | |
| 173 | ```text |
| 174 | FAIL hoist writes 0 of x20..x26 and 3 of d8..d15: OMEGA_NATIVE_OMC2 does not hoist (omega-mv perf/omc-loop-checks) |
| 175 | NATIVE-V2 FAIL 1 |
| 176 | ``` |
| 177 | |
| 178 | It was not suppressed, reclassified or changed to green. The separate compiler-profile |
| 179 | repair from BridgeV2Fix is not adopted here. The x86 gate's former false refusal assertion |
| 180 | is not that AArch64 register-hoist failure. `red-before-private-f32.log` independently |
| 181 | preserves the test-first pre-admission refusal110; preliminary red probes are not final PASS. |
| 182 | |
| 183 | ## Remaining gates and guide delta |
| 184 | |
| 185 | - **PASS / EXERCISED:** selected AArch64 no-libc and hosted differentials, explicit refusal |
| 186 | boundaries, actual nine-unit composition, all named mutants and negative controls. |
| 187 | - **PASS / EMULATED:** six-language x86 gate, FP32/nine-unit no-libc differentials and |
| 188 | hosted x86-device regression. Physical x86 remains **NOT_RUN**. |
| 189 | - **FAIL:** full AArch64 V2 retains exactly its known single compiler-hoist-pin failure. |
| 190 | - **NOT_RUN:** firmware FP setup, physical x86, NVIDIA driver, WC timing, GPU/chip and full |
| 191 | CUDApp API acceptance. No GPU window was authorized; no live service was touched. |
| 192 | - **NOT_MERGED / NOT_DEPLOYED:** Drake must approve this draft contract/profile and pins. |
| 193 | |
| 194 | The harness/encoding guidance delta is the explicit freestanding OM2-array/private-FP32/FP64 |
| 195 | profile, integer-only public ABI, inherited FP control, exact NaN-comparison limitations, |
| 196 | whole-source host-word refusal, no-libc link requirement and target-specific tool custody. |
| 197 | This lane does not own the harness checkout or mounted skills; update the existing |
| 198 | `aien-dev/omega-harness#181` guide-update issue with the published bridge head and this |
| 199 | receipt instead of silently editing global skills. Re-run changed guide examples and |
| 200 | refresh pins when Drake approves adoption. No portable converter capability is claimed. |