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 / typed-views.md

231 lines · 15279 bytes Raw Blame History Rendered
1# Typed views and explicit float profiles
2
3## Revision and scope
4
5IMPLEMENTED and EXERCISED on branch `feat/portable-typed-views` in
6`~/work/cudastack/lanes/BridgeViews`. A fresh `git fetch origin main` still reported
7base `3d01b49be9503d967a9f891c747222aff0aaf67d` before publication.
8The accompanying commit fixes the exact sources below:
9
10| Source | SHA-256 |
11| --- | --- |
12| `src/toc.om` | `b6abf22d1bd26da164e6b3a883806511ba3f63cfa633d832b735f4583ff3b09e` |
13| `tools/bridge-seeded` | `65778db0d82c994f8606f6b868645f7b89c0a5062a1f23d1eccc65690f1b55d0` |
14| `src/native.om` | `62e606762de623d611d05dd8764a35d343eb82e4b625bb65643a22debdcc9913` |
15| `tools/native` | `8ee0fc4668f2a4438a4d3f09c63da4a9993aebb054edaa3b01cec9e95c1fa873` |
16| `tests/seeded_next_literals.want` | `069ce343ddb4b88e076b26368b6bcaccec473402b0b7b860f7fd2d9b4b89c8b0` |
17
18Native generator/tool/documentation edits were coordinated with BridgeHost.
19Their default compiler pins, existing `sp[7]` zero-initialization, and freestanding
20OM-2/array lane were not replaced. Public native floats require explicit profiles;
21they are not admitted through the default or freestanding generator.
22
23## Source semantics checked before lowering
24
25The frozen reference is omega-mv `e5b32567a7aff3ce594e3254a622a846a6cd190b`:
26`seed/omc/omc.om` SHA-256
27`7703da00055fc0c7a91fcae43071df76a3f277dbe867cb284a3bdff3bedb7e1b`,
28compiler SHA-256
29`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`.
30The source checks covered `twid`/`tlog`, `ldop`/`stop`, `elemtype`, and `fintr`
31(`omc.om` lines 2130, 2156, 2225, 2259, 2684 and 3142 at that revision),
32plus OMEGESE.md's unsigned/view and floating contracts (lines 429–474 and
33548–578). MCP keyword lookup/run evidence was used alongside the source.
34
35* `ushort`/`uint` arithmetic wraps at its declared unsigned width. Storage is
36 little-endian. The emitter uses `uint16_t`/`uint32_t` backing storage and explicit
37 byte assembly/disassembly, not incompatible typed-pointer aliasing.
38* `f32` array storage is raw `uint32_t` IEEE bits. Loads/stores preserve NaN
39 payloads, subnormals and signed zero. Arithmetic retains the existing seeded
40 AArch64 rounding, NaN and conversion rules. Unsupported endian/FP environments
41 fail at C compilation; no approximate substitute is emitted.
42* The seeded function ABI transports f32/f64 scalars as raw integer-slot bits.
43 Public C `float`/`double` adapters therefore bit-copy, rather than pass hardware
44 float registers directly to the Omega entry. Result size/alignment/store and
45 overlap checks use 4 or 8 bytes, respectively. Only success stores a result.
46* `fsqrt` already exists in e5. Portable lowering uses AArch64 FSQRT or x86 SSE
47 scalar sqrt with the established AArch64 NaN handling, without libm.
48* `fma` does not exist in e5. It is never silently enabled there. The draft-next
49 profile uses the separately qualified compiler candidate below.
50* e5's decimal conversion is not generally correctly rounded (#1024). Its two
51 recorded misroundings remain deliberately reproducible in the frozen profile.
52 Correct rounding belongs only to the explicit candidate profile.
53* Global arrays work in standalone programs. The e5 function-mode compiler itself
54 refuses its global pool with error 9; this is not bypassed by conversion.
55
56The portable extension is `bridge-seeded`, the path used by GemmEx. The separate
57`bridge-freest` stateless, nontrapping, import-free integer-scalar profile remains
58unchanged; it did not previously support array views. Native OM-2 floats and
59freestanding floats are not claimed by this change. `f64` arrays still refuse 24.
60
61## Explicit candidate and compiler contribution
62
63Draft compiler PR: https://github.com/aien-dev/omega-mv/pull/1049
64
65* Branch `feat/seeded-fma-exact-literals`, base
66 `5287336a50b4b75a357bfc330f599cc604209e40`, head
67 `7e93ca8e29b3fe81314a88c9f1cb70666fca27f5`.
68* Compiler source SHA-256
69 `0a0f4bbc361e555de223d93e774ed5c8d96da401ab574983897ecc82539e0549`;
70 executable SHA-256
71 `d89bdc08ca21ea9726f1117adc791f683287d3698ea112a9db5519df2e79aeec`.
72* `fma a b c` requires equal explicit f32/f64 operands. AArch64 emits one FMADD;
73 x86linux/x86efi refuse 9 instead of substituting an unfused sequence. The C
74 emitter preserves left-to-right operand evaluation before its single FMADD.
75* #1024 is in scope: this compiler contribution reuses the exact-literal core
76 from draft #1027, revision `681d6f487ac3c237e0b8d73c287e0a8f232b1434`, rather
77 than inventing a competing converter. The bridge ports that bounded Omega core
78 into a separately selected literal path.
79* Select portable C/header with `tools/bridge-seeded --float-next c|h SOURCE.om`
80 and `OMEGA_SEEDED_NEXT_OMC`. Select native bindings with
81 `tools/native --float-next OUTDIR unit.om...` and
82 `OMEGA_NATIVE_FLOAT_NEXT_OMC`. Both check the exact candidate digest.
83* e5 native public floats use `--float` and `OMEGA_NATIVE_FLOAT_OMC`; the existing
84 `OMEGA_NATIVE_OMC` still builds the generator at its unchanged baseline pin.
85 Direct framed-input users must select `float` or `fhost`. Unprofiled public
86 float signatures refuse 110 without stdout in every binding mode.
87
88Compiler worker evidence is filed at
89`~/work/cudastack/lanes/OmcFloat/evidence/SEED-0/fma-exact-literals/REPORT.md` and
90in #1049. Its recorded commands, all under `taskset -c 10-14 nice -n 10`, were:
91
92| Command | rc | Observed result |
93| --- | --- | --- |
94| `sh seed/omega-from-seed.sh` | 0 | all three bootstrap/fixpoint stages identical |
95| `make -j3 build/omegese/omegese build/omega_emit/omega_emit build/checker2/checker2` | 0 | existing oracle tools built |
96| `sh seed/host/check.sh` | 0 | `PASS native-host qualification; seeded build, C tools are comparison oracles only` |
97
98That receipt also records 48 FMA cases, 512 exact literals, wrong-opcode,
99unfused, remainder and ties-down mutants killed, 300 gate-17 programs identical,
100and 163 gate-18 keyword packs. These are worker-filed CPU receipts, not an
101independent chip qualification. They predate Main's device-namespace instruction;
102they are not retroactively described as namespace-isolated.
103
104At the publication check, both #1049 and shared-core #1027 were OPEN/DRAFT and
105CONFLICTING against current main. No merge or default-pin refresh was performed.
106Integrating the common source into current main requires a fresh fixpoint/host
107receipt and explicit pin refresh under Main's integration decision, preserving
108BridgeHost's integrated-pin priority. The immutable candidate above is what the
109bridge tests actually executed.
110
111## Bridge execution evidence
112
113`typed-views-commands.json` records exact argv, environment, start time, rc,
114final line and final-source digests. All new logs replace the home directory
115prefix with `~`; source and result bytes are not altered.
116Historical rows and logs are retained rather than edited into successful runs.
117The final runs below use Main's device-free wrapper literally:
118
119```sh
120bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10 <command>
121```
122
123The JSON records the complete expanded argv for each command. Environment pins
124are the frozen bridge bootstrap (`191b776e...`), e5 frontend (`2c824805...`),
125native generator compiler (`734f0a39...`), OM-2 compiler (`c000ec02...`), and the
126explicit candidate (`d89bdc08...`). It records executable paths for Rust, Zig
1270.13.0, Go 1.27.3 and the x86 QEMU/Python oracles. No GPU gate was opened.
128
129| Command after the wrapper | rc | Final line / result | Log suffix after `typed-views-` |
130| --- | --- | --- | --- |
131| `sh tools/test.sh` | 0 | `ALL SUITES RC=0` | `baseline-device-free.log` |
132| `python3 tests/seeded.py` | 0 | `SEEDED CONVERTER differential C/Python/native/x86 and pin/arithmetic/ABI controls PASS; device NOT_RUN` | `seeded-device-free.log` |
133| `python3 tests/seeded_float.py` | 0 | `PASS seeded binary32/binary64 byte differential (native/C/x86, 132 constants vs exact oracle, one-ulp mutant detected); baseline/Python/f64-array/converter refusals` | `float-sqrt-final.log` |
134| `python3 tests/seeded_views.py` | 0 | `SEEDED-VIEWS PASS` | `views-device-free.log` |
135| `python3 tests/seeded_next.py` | 0 | `SEEDED-NEXT PASS` | `next-device-free.log` |
136| `python3 tests/freest.py` | 0 | `PASS direct structural converter refusals independently of frontend, including recursive call graph` | `freest-device-free.log` |
137| `python3 tests/native/float.py` (e5) | 0 | `NATIVE-FLOAT PASS (see per-language NOT_RUN lines)`; all five languages actually PASS | `native-float-e5-mixed-final.log` |
138| `env OMEGA_NATIVE_FLOAT_PROFILE=next python3 tests/native/float.py` | 0 | same final line; all five languages actually PASS | `native-float-next-mixed-final.log` |
139| `sh tests/native/test_build_failures.sh` | 0 | `PASS native callers: Zig and Go built and executed; no missing languages` | `native-build-controls-profile.log` |
140| `sh tests/native/kinds.sh` | 0 | `NATIVE-KINDS PASS` | `native-kinds-profile.log` |
141| `sh tests/native/v2/run.sh` | 1 | `NATIVE-V2 FAIL 1` — unchanged, permitted baseline | `native-v2-profile.log` |
142| `sh tests/native/x86/run.sh` | 0 | `NATIVE-X86 EMULATED PASS (six languages built and run; native x86 NOT_RUN)` | `native-x86-device-free.log` |
143| `python3 tests/native/x86/test_build_failures.py` | 0 | `NATIVE-X86 CONTROLS PASS (EMULATED; native x86 NOT_RUN)` | `native-x86-controls-device-free.log` |
144
145The v2 failure is exactly the frozen OM-2 compiler not hoisting: 0 writes of
146x20–x26 and 3 of d8–d15. Its 72 unit/output ABI-v1 parity cases and the rest of
147that gate still pass. No baseline, refusal, parity comparison or gate was weakened.
148The controls mutation-site update follows the changed bytewise helper text;
149it still deletes the same bounds check, and all seven controls are killed.
150
151### Differential coverage and negative controls
152
153* `seeded_views.py`: exhaustive 65,536 u16 values; 15 explicit u32/f32 bit edges;
154 exactly 1,048,576 deterministic random u32/f32 patterns, plus zero padding to
155 the fixed array shape. Both host C and x86-emulated C match the e5 program's
156 complete output. Operations include ushort/uint increment with wrap, f32 raw
157 copies, add-one and fsqrt, and explicit little-endian serialization.
158* Each new type has error-21 compile-time out-of-range fixtures, standalone
159 global-array parity, runtime bounds/count/null/alignment/pointer-wrap/alias/
160 overlap/recovery checks, and a killed storage mutant. Both portable public
161 float widths have typed-scalar and ABI-mutant controls.
162* `seeded_float.py` adds fsqrt32/fsqrt64 edge differentials on host and x86 C,
163 with a killed identity-instead-of-sqrt mutant for each width. Existing decimal
164 oracle and refusal controls remain present.
165* `seeded_next.py`: edge triples and exactly 1,048,576 random triples per float
166 width against candidate machine code; one wrong-FMA-opcode mutant per width;
167 all 512 f32/f64 literal patterns against both native bits and the filed exact
168 oracle, including both #1024 counterexamples; literal-emitter mutant killed;
169 candidate digest refused by the frozen profile.
170* `native/float.py`: the same f32/f64 identity units called by C, Python ctypes,
171 Rust, Zig and Go with NaN payloads, signed zero, denormals and infinities;
172 every language passed under both e5 and candidate profiles. No missing-language
173 NOT_RUN was hidden. C additionally executes mixed f32 scalar/view/edit slots,
174 count and alias refusals, null-result checks and explicit `--host` marshalling.
175 Unsupported targets/freestanding combinations refuse before output, and every
176 unprofiled direct binding mode refuses 110 without stdout. Per-width result
177 marshalling mutants are killed.
178* The pre-existing import-free freest gate still has empty `nm -u` after O0/O2
179 object and `-r -nostdlib` links, no TLS, 28 whole-unit refusals and empty stdout.
180
181An intermediate final-profile attempt failed with `omc: line 472: error 3` because
182its new global flag was declared after its first use. The flag was moved before
183use; the failed source digest/log remain in the JSON and
184`typed-views-native-float-e5-final.log`. Subsequent profile and mixed-unit runs
185pass. Earlier development attempts also exposed, then corrected, a test that
186incorrectly used a global pool in function mode and a freest invocation missing
187`OMEGA_SEED`; neither was suppressed or reclassified as a passing invocation.
188
189Wolfram receipts used by the test sizing and exact-literal oracle:
190
191* `WolframLanguageEvaluator: {2^16,2^20,2^32-1,FromDigits[Reverse[ToCharacterCode["fsqrt"]],256],FromDigits[Reverse[ToCharacterCode["fma"]],256]} -> {65536,1048576,4294967295,500136244070,6384998}`.
192* `WolframLanguageEvaluator: {Table[{w,3*w/8*256,w/8*256,3*w/8,w/8},{w,{32,64}}],2^20} -> {{{32,3072,1024,12,4},{64,6144,2048,24,8}},1048576}` (byte sizes).
193* The 512-row literal fixture is copied byte-for-byte from #1049's
194 `seed/omc/tests/float/lit_round.want`. Its `oracle.wl` query and recorded
195 Wolfram result `{512,0,{}}` are filed beside the compiler receipt: 512 checked,
196 zero mismatches. This is an independent exact-literal oracle, not a C-libm answer.
197
198## Required omega-harness guide text
199
200The matching guide is `skills/omega-encoding/SKILL.md`, including the observed
201limits in harness draft #183. This lane does not own that repository or #183.
202The exact updates needed are:
203
2041. Keep the frozen CUDApp consumer's bc11b30b/69d629df refusal observation as
205 historical evidence; add the separately pinned bridge draft's `ushort`,
206 `uint`, `f32` views/local arrays and standalone globals, fixed-width LE
207 storage, wrap, counts/alias/alignment checks and status-preserving ABI.
2082. Distinguish portable C public float/double scalars from the native
209 `--float`/`--float-next` profiles. Document the native raw integer-slot ABI,
210 4/8-byte result contracts, all five language bindings and direct-generator
211 profile requirement. Do not imply OM-2/freestanding floats or f64 arrays work.
2123. State that `fsqrt` already exists in e5; compatibility C uses AArch64/x86
213 instructions without libm. Do not call sqrt a new compiler keyword.
2144. State that `fma` is absent in e5 and only available through the exact #1049
215 candidate above. Record single rounding and left-to-right evaluation;
216 x86 compiler targets refuse 9 and the portable candidate profile is AArch64-only.
2175. Retain #1024's e5 limitation. Describe correct rounding only under the
218 candidate's explicit source/executable pins, with shared #1027 provenance,
219 fixpoint/host/mutant evidence, current merge conflicts and no automatic reseed.
2206. Keep #183's unrelated bool-to-integer function-mode error-9 witness unchanged.
221 Cite the current CUDApp #295 consumer when adding these new typed-view results.
2227. Label these results CPU/EMULATED and EXERCISED, not chip QUALIFIED, MERGED or
223 DEPLOYED. Keep BridgeHost's separate freestanding OM-2/array work distinct.
224
225## Deliberate non-claims
226
227PASS means only the exercised source/profile combinations above. The native-v2
228aggregate remains FAIL 1 at its known baseline. Physical x86 execution, GPU/chip
229qualification, deployment and merge are NOT_RUN. The external Wycheproof corpus
230is NOT_RUN (not vendored), as stated in the compiler receipt. Both contributions
231remain draft and require Drake's approval to merge.