omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / bench / README.md
| 1 | # MultiPL-E for Omega |
| 2 | |
| 3 | `bench/` adapts [MultiPL-E](https://github.com/nuprl/MultiPL-E) (pinned at |
| 4 | `3025a531af7450e7df8b96fe0440e9804480bbad`) to Omega's OM-2 profile. It turns the |
| 5 | HumanEval and MBPP problems into Omega prompts plus test programs and grades |
| 6 | completions with the pinned `omc` (`omega.ref`). |
| 7 | |
| 8 | Status: IMPLEMENTED, and EXERCISED on a Linux AArch64 host (the DGX Spark's Grace |
| 9 | cores) with the stub model below. No language model has been evaluated yet, so no |
| 10 | model pass@k exists. |
| 11 | |
| 12 | ## Not first-party Omega |
| 13 | |
| 14 | All Python here (`multipl-e/*.py`, `stub_model.py`, `score.py`) is a |
| 15 | **foreign-harness adapter**. MultiPL-E loads translators as Python classes |
| 16 | (`dataset_builder/humaneval_to_<ext>.py`) and evaluators as Python modules |
| 17 | (`evaluation/src/eval_<ext>.py`), so its plugin API can only be met in Python. |
| 18 | None of this code is first-party Omega. It sits outside every Omega product |
| 19 | path: nothing in omc, the seed or any shipped `.om` program depends on it. The |
| 20 | programs it writes are plain OM-2 compiled by the unmodified pinned omc. |
| 21 | `DEPENDENCIES.md` lists what it needs. |
| 22 | |
| 23 | ## Layout |
| 24 | |
| 25 | | path | what | |
| 26 | |---|---| |
| 27 | | `multipl-e/humaneval_to_om.py` | The MultiPL-E `Translator` for Omega (`.om`). | |
| 28 | | `multipl-e/eval_om.py` | The MultiPL-E evaluator. `eval_script(path)` returns the MultiPL-E result dict. | |
| 29 | | `multipl-e/build_prompts.py` | Runs the translator through the pinned MultiPL-E `generic_translator`. It writes `prompts/`. | |
| 30 | | `prompts/{humaneval,mbpp}-om.jsonl` | The translated problems (name, language, prompt, tests, stop_tokens, …). | |
| 31 | | `prompts/*.coverage.json`, `prompts/COVERAGE.md` | Each problem's translation result, with a reason for every refusal. | |
| 32 | | `solutions/HumanEval_<n>.om` | Ten hand-written completions: function bodies up to and including `end`. | |
| 33 | | `stub_model.py` | Writes MultiPL-E completion files without a model. | |
| 34 | | `score.py` | Evaluates completion files and writes `<name>.results.json` and `summary.json` (pass@k). | |
| 35 | | `check.sh` | The gates. | |
| 36 | | `results/<mode>/` | The completions, results and summary from the last `check.sh` run. | |
| 37 | | `upstream/` | A prepared contribution to nuprl/MultiPL-E. It is **not submitted**. | |
| 38 | |
| 39 | ## Translation |
| 40 | |
| 41 | Each problem becomes: |
| 42 | |
| 43 | ``` |
| 44 | om2 |
| 45 | note <docstring, MultiPL-E "reworded" terminology, doctests in Omega call syntax> |
| 46 | note <interface notes: renamed names, the result-array convention> |
| 47 | fn NAME PARAM TYPE ... to TYPE |
| 48 | <completion: the body and its closing end> |
| 49 | <tests> |
| 50 | ``` |
| 51 | |
| 52 | | Python | Omega | |
| 53 | |---|---| |
| 54 | | `int` | `long` | |
| 55 | | `float` | `f64` | |
| 56 | | `bool` | `bool` | |
| 57 | | `List[int]` / `List[float]` | `view long *` / `view f64 *` | |
| 58 | | `str` | `view uchar *` (bytes; a non-ASCII test string is refused) | |
| 59 | | `Tuple[int, int]`, `Tuple[float, float]` (homogeneous) | `view long *` / `view f64 *` | |
| 60 | | list, string or tuple **result** | an extra last parameter `res edit T *`; the function returns the element count as `long` | |
| 61 | |
| 62 | The tests become one `fn tc_K to bool` per assertion, then `fn main`. |
| 63 | |
| 64 | - `main` returns `K+1` for the first failing case K. A translation holds at most |
| 65 | 98 cases, so this is 1..98. |
| 66 | - When every case holds, `main` writes the line `MultiPL-E Omega: all tests passed` |
| 67 | and returns 0. The evaluator requires exit 0 **and** that final line. A completion |
| 68 | that ends the process early with status 0 is therefore not a pass. |
| 69 | - A trap exits `100 + code`. |
| 70 | - Floats compare with exact `eq`, as MultiPL-E's Python tests compare with `==`. |
| 71 | |
| 72 | ### Refusals |
| 73 | |
| 74 | The translator refuses a problem when OM-2 or the harness can't express it |
| 75 | faithfully. MultiPL-E then skips that problem. |
| 76 | |
| 77 | - **Types:** `List[str]`, `List[bool]` (omc has no bool arrays), nested or compound |
| 78 | lists, mixed tuples, `Optional`, `Union`, `Dict`, `Set`, `Any`, and unannotated or |
| 79 | `None` results. |
| 80 | - **Values:** a non-ASCII string, an int outside i64, or a non-finite float. |
| 81 | - **ABI:** more than 6 argument slots. |
| 82 | - **Tests:** more than 98 cases, or a test that calls something other than the |
| 83 | candidate. |
| 84 | |
| 85 | ### Renaming |
| 86 | |
| 87 | The translator renames a name and adds a `note Omega name: X is Y here.` line |
| 88 | when the name: |
| 89 | |
| 90 | - is a keyword; |
| 91 | - collides with a harness name; |
| 92 | - is a parameter longer than omc's 8-character local limit; |
| 93 | - is a function name longer than 8 characters whose first 8 bytes spell an |
| 94 | 8-letter keyword, such as `truncate_number`. Function names in this case get |
| 95 | their first letter capitalised. |
| 96 | |
| 97 | ## Coverage (MEASURED, `prompts/COVERAGE.md`) |
| 98 | |
| 99 | - **HumanEval: 129 of 164 translate.** MultiPL-E's originals already drop 3 of the |
| 100 | 164 (HumanEval_32, _38 and _50). Of its 161, the translator refuses 32: |
| 101 | `List[str]` 17, compound list 4, `Optional` 3, `Union` 3, mixed tuple 3, `Dict` 2. |
| 102 | - **MBPP (`mbpp-typed`): 272 of 400 translate; 128 are refused.** The largest |
| 103 | reasons are compound list 67, `List[str]` 22, mixed tuple 11 and `Dict` 10. |
| 104 | |
| 105 | ## Running |
| 106 | |
| 107 | ```sh |
| 108 | # prompts (needs a MultiPL-E clone at the pin; plain python3, no extra modules) |
| 109 | python3 bench/multipl-e/build_prompts.py --multipl-e ../MultiPL-E |
| 110 | |
| 111 | # completions -> results -> pass@1 |
| 112 | python3 bench/stub_model.py hand /tmp/run |
| 113 | OMEGA_OMC=/path/to/omc python3 bench/score.py /tmp/run |
| 114 | |
| 115 | # all gates |
| 116 | sh bench/check.sh --omc /path/to/omc [--multipl-e ../MultiPL-E] |
| 117 | ``` |
| 118 | |
| 119 | `eval_om.py` reads these settings from the environment: |
| 120 | |
| 121 | - `OMEGA_OMC`: the omc path (required). |
| 122 | - `OMEGA_OMC_SHA256`: the pin. It defaults to `omega.ref`'s; on a mismatch the |
| 123 | evaluator raises and records nothing. |
| 124 | - `OMEGA_EVAL_TIMEOUT`: seconds per program (default 15). |
| 125 | - `OMEGA_EVAL_WRAP`: an optional command prefix, for example |
| 126 | `nice -n 19 taskset -c 10-14`. |
| 127 | |
| 128 | omc writes static AArch64 Linux executables, so evaluation needs an AArch64 Linux |
| 129 | host. An x86-64 host would need qemu-user, which is NOT_RUN. |
| 130 | |
| 131 | Outcome mapping: |
| 132 | |
| 133 | | outcome | `om_status` | MultiPL-E `status` | |
| 134 | |---|---|---| |
| 135 | | omc exits nonzero or writes to stderr; the output is never run | `compile_error` | `SyntaxError` | |
| 136 | | exit 0 and the final pass line | `pass` | `OK` | |
| 137 | | exit 1..98 | `wrong_answer`, `om_case` = exit − 1 | `Exception` | |
| 138 | | exit 100..199 | `trap`, `om_case` = trap code | `Exception` | |
| 139 | | exit 0 without the pass line | `no_pass_line` | `Exception` | |
| 140 | | any other exit or a signal | `exit_other` | `Exception` | |
| 141 | | over the time limit (the process group is killed) | `timeout` | `Timeout` | |
| 142 | |
| 143 | ## Gates (`check.sh`) |
| 144 | |
| 145 | Each gate has a negative control that must be observed failing: |
| 146 | |
| 147 | | gate | passes when | negative control | |
| 148 | |---|---|---| |
| 149 | | `constants` | eval_om's pin equals `omega.ref`, and both files use the same pass line | a mismatch fails it | |
| 150 | | `prompts-rebuild` | rebuilding the prompts reproduces the committed files | a translator change fails it | |
| 151 | | `stub-sweep-{humaneval,mbpp}` | every translated problem compiles with the stub body `trap 14` and exits 114 in its first case | a broken test harness fails to compile or exits otherwise | |
| 152 | | `mode-hand` | the 10 hand solutions all reach `pass` | a deliberately broken solution is classified `wrong_answer` | |
| 153 | | `mode-wrong` | constant answers are all `wrong_answer` | — | |
| 154 | | `mode-invalid` | non-Omega text is always `compile_error` | — | |
| 155 | | `mode-trap` | `trap 5` is classified `trap` with case 5 | — | |
| 156 | | `mode-timeout` | a loop of about 2^72 steps is a `timeout` at 2 s | — | |
| 157 | | `pin-refusal` | eval_om refuses to evaluate when the omc hash is not the pin | — | |
| 158 | | `no-pass-line` | exit 0 without the pass line is not a pass | — | |
| 159 | |
| 160 | The `wrong`, `invalid`, `trap` and `timeout` modes are themselves the negative |
| 161 | controls for `mode-hand`. A grader that passed everything would fail them. |
| 162 | |
| 163 | The 10 hand solutions are HumanEval 0, 2, 3, 9, 13, 16, 27, 30, 48 and 53. They |
| 164 | cover these signatures: |
| 165 | |
| 166 | - `List[float]` → `bool` |
| 167 | - `float` → `float` |
| 168 | - `List[int]` → `bool` |
| 169 | - `List[int]` → `List[int]` (twice) |
| 170 | - `int` → `int` |
| 171 | - `str` → `int` |
| 172 | - `str` → `str` |
| 173 | - `str` → `bool` |
| 174 | |
| 175 | In the last run, pass@1 was 1.0 for `hand` and 0.0 for every other mode |
| 176 | (`results/*/summary.json`). With one completion per problem, pass@1 is c/n. The |
| 177 | values were checked with Wolfram (see the PR text in `upstream/`). |
| 178 | |
| 179 | ## omc defects worked around (pin e5b32567) |
| 180 | |
| 181 | - **Keyword-prefix function names.** omc looks a function name up in the keyword |
| 182 | table by its first 8 bytes. A longer name that starts with an 8-letter keyword, |
| 183 | such as `truncate_number`, is refused with error 16 (`omc.om` `fn kw` caller near |
| 184 | line 6681). The translator renames such names. |
| 185 | - **Empty text passed to a view.** An empty `text ""` passed to an unsized `view` |
| 186 | parameter gives the callee a stale register as its length. `omc.om` arrarg takes |
| 187 | `nm_len 0` to mean an unsized parameter. The result was a garbage `len`, and a |
| 188 | segfault when the callee indexed the view. The translator passes `""` as |
| 189 | `part a 0 0` instead. |
| 190 | |
| 191 | Both are reported to the omega-mv omc owner. The pin is unchanged. |