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/omega-mv/blob/main/seed/stablehlo/README.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / stablehlo / README.md` 103 lines · 6310 bytes Raw Blame History Rendered 1 # seed/stablehlo: OSC IR scalar unit to StableHLO (Google TPU path, first rung) 2 3 `irstablehlo.om` is a handwritten Omega program. It reads one OSC IR unit on stdin and writes a 4 StableHLO MLIR module that applies one named scalar function elementwise to `N`-element tensors: 5 6 ``` 7 irstablehlo N FUNCTION < unit.ir > module.mlir 8 ``` 9 10 For `fn vaddi32 a int b int to int / ret add a b` and `N = 8` it writes: 11 12 ``` 13 module { 14 func.func public @main(%p0: tensor<8xi32>, %p1: tensor<8xi32>) -> tensor<8xi32> { 15 %i0 = stablehlo.add %p0, %p1 : tensor<8xi32> 16 func.return %i0 : tensor<8xi32> 17 } 18 } 19 ``` 20 21 ## Run the gate 22 23 ``` 24 IREE_COMPILE=... IREE_RUN=... PYTHON=... nice -n 19 sh seed/stablehlo/gate-irstablehlo.sh 25 ``` 26 27 Exit 0 PASS, 1 FAIL, 3 NOT_RUN (not AArch64 Linux, or an oracle missing). Artifacts go to 28 `build/seed/stablehlo`. The gate pins `seed/out/omc` by sha256, builds the translator, translates every 29 row of `cases.tsv` twice (byte-identical), compiles and runs each module on two oracles, and compares 30 every element exactly. Integer rows are also run through the same Omega function compiled natively by 31 omc. It then requires these to be caught: a wrong op (add to subtract, add to multiply), a wrong 32 expected value (including one f32 ulp), three malformed modules both oracles must refuse, and 16 33 translator refusals that must leave stdout empty. 34 35 ## Oracles (interop oracle, not Omega-native) 36 37 Neither oracle writes the module; both only read what Omega wrote. jax.jit and JAX tracing are unused. 38 39 | Oracle | Version (installed 2026-10-26 in a user venv) | Wheel sha256 | Licence | 40 |---|---|---|---| 41 | IREE `iree-compile` (llvm-cpu) | iree-base-compiler 3.13.0 (`3.13.0rc20261016 @ `89ece87b``) | ``230aec9b5d63c49f3f1ba228c35a7ce950075ce7b7780b786c85fa6fb0be3dbb`` | Apache-2.0 | 42 | IREE `iree-run-module` (`--equality_mode=exact`) | iree-base-runtime 3.13.0 | ``2a46a517c7dbdaa8701f9ee324dd94089af51a8251f36bd689949ee37e30d1d1`` | Apache-2.0 | 43 | XLA CPU PJRT client, via `pjrt-oracle.py` | jaxlib 0.12.0.1 | ``40812201c3bcd4cb104b88f71f58fec4cbd0c32ba90e5c92b3fa8f40819f6774`` | Apache-2.0 | 44 | (driver dependency) | jax 0.12.0.1 / numpy 2.5.4 | ``e9dfd256`…` / ``fe4d21ab`…` | Apache-2.0 / BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0 | 45 46 `pjrt-oracle.py` is a foreign-language oracle driver: it only compiles and runs an existing module and 47 compares numbers. Its Omega replacement is a PJRT C API caller written in `.om`, which needs shared 48 object and C ABI support (FR-7 in `docs/one_layer/OM_COMPLETION.md`, absent at this pin). 49 50 IREE is called with `--iree-input-demote-f64-to-f32=false --iree-input-demote-i64-to-i32=false`; 51 without them IREE 3.13 rewrites f64 functions to f32 by default. 52 53 ## What is established, and what is not 54 55 - IMPLEMENTED: the translator for one-block functions over one element type: BIN add, subtract, 56 multiply (all types), divide (f32/f64 only), and, or, xor (integers), integer CONST, MOV, RET. 57 Types ui8..ui64, i8..i64, f32, f64. Wire v1 (as `omc ir` writes it) and wire v7 for f32/f64. 58 - EXERCISED on the oracles: i32, ui32, i64, multiply-add and constant rows, plus f32 and f64 add, 59 all matching exactly on both oracles at N = 8. 60 - f32/f64 IR is a hand-written wire v7 fixture in the gate, because `omc ir` refuses float words at 61 this pin. No Omega producer of float IR exists yet, so the float rows have no native cross-check. 62 - NOT_RUN: any TPU. No result here is hardware qualification. 63 64 Refused (with the class on stderr and nothing on stdout): integer div, rem, shl, shr; UN, CMP, CAST, 65 CALL, TRAP, BR, CBR; more than one block; requires/ensures contracts; bool; float constants; mixed 66 element types; structs, regions, refs; f32/f64 tags in wire v1. 67 68 ### Semantics 69 70 | Omega rule | StableHLO (spec, read 2026-10-26) | Status | 71 |---|---|---| 72 | Signed add/sub/mul trap 1 on overflow | Integer overflow is implementation-defined ("Errors") | NOT preserved. The gate shows Omega exiting 101 while both oracles return -`2147483648` | 73 | Unsigned add/sub/mul wrap | Implementation-defined | Same on both oracles; not a spec guarantee | 74 | IEEE-754 float add/sub/mul/div | IEEE-754, exceptions give the default result, no flags | Preserved; NaN payloads are not compared | 75 | div/rem trap 2, shift trap 7 | No trap | Refused | 76 77 ## Openness of the Google TPU stack (read 2026-10-26) 78 79 | Layer | Status | Source | 80 |---|---|---| 81 | StableHLO opset and spec | Open, Apache-2.0 | https://github.com/openxla/stablehlo (`docs/spec.md`, main ``44151da3``) | 82 | XLA compiler, PJRT C API | Open, Apache-2.0 | https://github.com/openxla/xla | 83 | JAX, jaxlib (CPU PJRT client) | Open, Apache-2.0 | https://github.com/jax-ml/jax | 84 | Mosaic TPU dialect (Pallas TPU) | Dialect definition public (`jaxlib/mosaic/dialect/tpu/tpu.td`), but it reaches the chip only as a `tpu_custom_call` that libtpu compiles | https://github.com/jax-ml/jax/blob/main/jaxlib/mosaic/dialect/tpu/tpu.td | 85 | libtpu (TPU compiler backend and runtime) | Closed binary; PyPI licence field "Google Cloud Platform Terms of Service"; x86_64 wheels only (0.0.51) | https://pypi.org/project/libtpu/ | 86 | TPU instruction set | No public ISA document found | — | 87 | StableHLO reference interpreter | Open, but prebuilt `stablehlo-translate` wheels are linux x86_64 only | https://github.com/openxla/stablehlo/releases | 88 89 So the lowest level Omega can write without closed tools is StableHLO text (or Mosaic TPU-dialect MLIR, 90 which only libtpu can lower). Everything below that is inside libtpu. 91 92 ## Path to a TPU receipt (NOT_RUN) 93 94 1. Get a Cloud TPU VM through the TPU Research Cloud (https://sites.research.google/trc/). It needs a 95 Google Cloud account and acceptance of Google's terms; libtpu ships on the VM. 96 2. Copy `build/seed/stablehlo/case-*.mlir` (made here, sha256 values from the gate output) to the VM. 97 Do not regenerate them there. 98 3. Run `pjrt-oracle.py` unchanged with `PJRT_ORACLE_PLATFORM=tpu`: the same `client.compile_and_load` on the 99 TPU PJRT client, with the `cases.tsv` inputs and expected vectors. 100 4. Record the libtpu version, TPU generation, module sha256 values and output. Even then the label is 101 "EXERCISED on TPU via closed libtpu": the kernel code below StableHLO is Google's, not Omega's. 102 103 f64 is not native on TPUs; expect f64 rows to be refused or emulated, and record which.