omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / examples / deepinfer / README.md
| 1 | # DeepInfer FlopsEstimator pair counts in Omega |
| 2 | |
| 3 | `flops_pairs.om` is `FlopsEstimator::floor_prefix`, `capped_prefix` and `pairs` from |
| 4 | [deepseek-ai/DeepInfer](https://github.com/deepseek-ai/DeepInfer) `553741557a57df44a46fb3ab72b6aafeaf945337` |
| 5 | `csrc/engine/flops_estimator.hpp` lines 237-257 (Apache-2.0), as an OM-2 unit bound by `tools/native` |
| 6 | into `omega2_floor_prefix`, `omega2_capped_prefix` and `omega2_pairs`. |
| 7 | |
| 8 | - Each step is the C++ expression's step in the same order, so a step that leaves `long` traps 1 |
| 9 | exactly where the C++ is undefined behaviour (the pinned compilers trap on long add, sub and mul: |
| 10 | `overflow.sh`, `evidence/deepinfer-flops-pairs/overflow-measurement.log`). |
| 11 | - Outside n >= 0, ratio > 0, cap >= 0, 0 <= begin <= end a `requires` clause traps 9. OM-2 is used |
| 12 | because the pinned compilers do not check an OM-1 `requires` (same log). |
| 13 | - The C++ parameter `end` is `finish`: `end` is an Omega keyword (error 16). |
| 14 | |
| 15 | Files: |
| 16 | |
| 17 | | File | Role | |
| 18 | |---|---| |
| 19 | | `flops_pairs.om` | the unit | |
| 20 | | `diff.cpp` | upstream bytes (extracted, sha256-checked, GCC UBSan) vs Omega vs enumeration / step model / second closed form | |
| 21 | | `diff.py` | the generated Python binding vs Python oracles | |
| 22 | | `boundary.txt` | overflow and domain edges with Wolfram-checked values | |
| 23 | | `flops_estimator-omega.patch` | the pinned header with the three bodies calling `omega_native.h`; a trap becomes `TORCH_CHECK` | |
| 24 | | `patched.cpp` | original vs patched header on `PairTerm::count` and `query_ranges`, stub `TORCH_CHECK` | |
| 25 | | `callers/` | c (also BTI-enforced), cpp, python, rust, zig and go callers using only the generated bindings | |
| 26 | | `run.sh` | everything above plus three mutants that must be caught | |
| 27 | | `overflow.sh` | long overflow, `requires` and `end` probes per compiler | |
| 28 | |
| 29 | Run (host only, no GPU): |
| 30 | |
| 31 | ```sh |
| 32 | DEEPINFER_SRC=<DeepInfer checkout at 5537415> OMEGA_NATIVE_OMC=<seeded omc pinned by tools/native> \ |
| 33 | OMEGA_NATIVE_OMC2=<omega-mv e5b32567 seed/out/omc> [TORCH_INC=<torch/include>] sh examples/deepinfer/run.sh |
| 34 | ``` |
| 35 | |
| 36 | Applying the patch to DeepInfer also needs `omega_native.h` on its include path and |
| 37 | `libomega_native.so` linked into `deepinfer._C`; that build and the upstream pytest |
| 38 | `tests/engine/test_flops_estimator.py` (needs the model config) were not run. Evidence: |
| 39 | `evidence/deepinfer-flops-pairs/`. |