interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / evidence / native-freestanding-f32 / README.md

200 lines · 13840 bytes Raw Blame History Rendered
1# Private FP32 behind the integer-only freestanding native ABI
2
3Status: **IMPLEMENTED and EXERCISED**, draft only; not merged or deployed. This is the
4separate private-FP32 followup to bridge #72 at `12f8132c2fe0ad240430583c85e0d9c4f7bd1c33`.
5The preceding OM2-array/private-FP64 receipt remains immutable in
6`../native-freestanding-om2-nolibc/`. Its whole-attention refusal describes that earlier
7profile, not this extension. Drake must review and approve the profile and gate-expectation
8change before merge. No physical-x86, firmware, NVIDIA-driver or GPU qualification is claimed.
9
10## What changed
11
12The first-party implementation is `src/native.om`, sha256
13`d1ee759748139bb703b20e4da43d8508fe8e15a9f2bb6cdcf8e682963ec3ef3c`.
14Its bounded whole-source scanner now admits private `f32` operations and explicit `f32`
15literal suffixes, alongside the already admitted private `f64`. A small scalar branch
16keeps the scanner within the seeded compiler's live-value limit. No compiler, public ABI,
17view runtime, native trampoline, host-word allowlist or portable converter changes.
18`src/toc.om` remains sha256
19`69d629df170a24ba0c2cb6d41dbfaed520e248e0d723236dd32abf0581524d84`.
20The C files added/extended here are verification oracles, not production implementations.
21
22Public floating parameters, results and view elements remain refused. Both widths are
23covered in fourteen genuinely compiled fixtures: scalar parameter/result, fixed view/edit/out,
24and dynamic view/edit. Each actual compiled frame must produce direct generator **exit110
25and empty stdout**, then CLI exit110 without installed wrapper output. The direct check
26prevents the CLI's generic generator-error mapping from disguising a crash as refusal.
27
28The unused host-helper negative control is deliberately scanner-only: the pure e5/be8c
29compilers do not admit that host word in function mode. The test appends an unused helper
30to a clean source frame and reuses its code solely to reach the whole-source scanner,
31requires exact generator110/empty output, and never executes the mismatched frame.
32This 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
37FP32 identity, add, divide, negate, a helper call, separate multiply/add, and comparison
38flags are exercised over the raw operand matrix in `f32.c`. That C oracle uses volatile
39FP32 operands and `-ffp-contract=off`; it checks signed zero, subnormals, infinities,
40finite extremes, NaNs, RNE ties and a non-contracting witness. The bare and hosted callers
41consume the same actual Omega code and must emit identical **raw**, unmodified bytes on
42the same target. This is not cross-architecture NaN-payload equality.
43
44The 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
54The oracle's own controls accept a different NaN payload as the same class, but reject an
55infinity substituted for NaN, a one-bit finite change, wrong status and a high-word change.
56A wrong-result caller exits90. Three exactly-one-site source mutants are caught: add->sub
57exits2; widening the intermediate product to FP64 exits2 on the non-contracting witness;
58normalizing the integer identity's NaN output exits3. Two exactly-counted generator mutants
59remove private-FP32 keyword admission or its literal suffix and restore refusal110 without
60installed wrapper output. Neither a mutant nor the oracle normalizes production results.
61
62WolframLanguageEvaluator queries and results are committed verbatim in `wolfram-fp32.txt`,
63`wolfram-attention.txt` and `wolfram-newton.txt`. They use exact rational IEEE rounding,
64including RNE/subnormal packing, rather than an ad-hoc host floating calculation. Selected
65query 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
75These are **modeled expectations**, not measured performance figures. Each query is paired
76with its full tool result in the named text files; observed execution is in the logs.
77The earlier binary64 oracle/comparison policy is unchanged.
78
79## Whole actual nine-unit composition
80
81One invocation binds all nine separately copied units into one library; no concatenation,
82mode extraction, reduced attention source, C algorithm substitution or ignored branch:
83
841. RegAllocOm `om/codegen/regalloc.om`, `regalloc_ir.om`, `regalloc_live.om`;
852. CoreUtilOm `om/core/native.om`, `cubin.om`, `ampere.om`;
863. ApiPlanOm `om/components/api_policy.om`, `api_mm_plan.om`, **whole `api_at_plan.om`**.
87
88The portable allocator/API sources receive exactly the approved `om2\n` prefix and no
89other byte transformation; the core sources are already OM2. `nine-{a64,x86}-sources.json`
90records original-source and actual-input SHA256 values. These byte identities are
91authoritative; they do not assert another owner's worktree is clean. The whole attention
92source SHA256 is `927e668a2dee55f0fc0b5d07f0311e75f03562e38ee13a2ace990762ab89f87f`,
93composed-input SHA256 `1920de0d7e9993c09aef93740bc2cfb7dbb68b8e7b2ddbc98e275dd52af9a821`.
94Its owner's reserved-name repair `part`->`partsz` is included; no local source repair or
95algorithm change is hidden in the bridge fixture.
96
97The caller retains the allocator/IR/liveness/graph/CUBIN/private-FP64 checks, then exercises
98actual policy remainder and matmul-view decisions, attention mode0 plan/refusal paths,
99mode7 scale validation, and modes22/23 raw integer FP results against the Wolfram bit oracle.
100Short spans return32 without changing the result or any caller word; untouched slots are
101checked. The bare ELF has **no undefined symbols at all**, no interpreter and no TLS.
102No `_exit`, setjmp/longjmp, memory helper, 128-bit-division runtime or libc is linked.
103Raw hosted/bare byte streams must match on each target.
104
105Four exactly-one-site source mutants compile and link under the same bare constraints:
106policy remainder reversal -> exit14; matmul view edit -> exit15; attention scale acceptance
107reversal -> exit19; attention packed result change -> exit20. Each is caught before stdout.
108The baseline snapshots are never mutated. A wrong-result control exits90. This qualifies
109selected 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,
114rc and receipt-log name for each final command and the two selected red probes. Environment
115was inherited, not `env -i`. Final builds use `GOMAXPROCS=3`, `GOFLAGS=-p=3`; every test,
116compiler/linker child and mutant stays inside this device-free namespace:
117
118```sh
119bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 <command>
120```
121
122There is no rerun outside it. `~` replaces `/home/drakestapleton` in all published text.
123Receipt transport verifies each complete raw source byte count before that one HOME-prefix
124normalization; `transfers.json` records both byte counts. Command traces encode captured
125binary stdout as `stdout_hex`; no executable, NVIDIA binary, cubin, PTX or disassembly is
126committed. `tools-and-source.txt` records source and verification-tool custody.
127
128The commands below are the payload after the wrapper; exact environments and full source
129paths 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
143The exact common FP32 final line is:
144
145```text
146PASS 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
149Pure AArch64 uses the pinned e5 compiler (SHA256 `2c824805...`), pure x86 the existing
150be8c binary. Full hosted AArch64 uses the existing A5 b8f8 binary; the hosted x86-device
151regression 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
153734f0a39, 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
158hard-coded claim that `hoist.om` exported float arrays and must still refuse110. Inspection
159and the read-only consultant established the decisive point: its sole export `hadd` takes
160an editable **ulong** array plus **ulong**, returning **ulong**; FP64/FP32 conversions are
161private. It therefore belongs in this approved profile.
162
163The correction deletes only the obsolete `FREEST_REFUSED` constant/comment and its branch.
164The existing OM2 predicate still requires baseline f637021 **110 with empty stdout** and
165candidate **0 with nonempty stdout**. It does not skip hoist or accept arbitrary status.
166All other byte comparisons, baseline pins, exact span-zero-initialization normalization,
167its per-fixture counts and its one-byte negative control remain untouched. This is a
168profile-specific expectation change requiring Drake's review, not a new normalization.
169Generation acceptance alone is not a hoisting/register-preservation qualification.
170
171The distinct full AArch64 V2 gate still reports exactly one unchanged failure:
172
173```text
174FAIL hoist writes 0 of x20..x26 and 3 of d8..d15: OMEGA_NATIVE_OMC2 does not hoist (omega-mv perf/omc-loop-checks)
175NATIVE-V2 FAIL 1
176```
177
178It was not suppressed, reclassified or changed to green. The separate compiler-profile
179repair from BridgeV2Fix is not adopted here. The x86 gate's former false refusal assertion
180is not that AArch64 register-hoist failure. `red-before-private-f32.log` independently
181preserves 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
194The harness/encoding guidance delta is the explicit freestanding OM2-array/private-FP32/FP64
195profile, integer-only public ABI, inherited FP control, exact NaN-comparison limitations,
196whole-source host-word refusal, no-libc link requirement and target-specific tool custody.
197This 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
199receipt instead of silently editing global skills. Re-run changed guide examples and
200refresh pins when Drake approves adoption. No portable converter capability is claimed.