interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / bench / upstream / PR.md

143 lines · 6334 bytes Raw Blame History Rendered
1# Upstream package for nuprl/MultiPL-E (PUBLISH-QUEUE, not submitted)
2
3This is not sent. Submitting it posts outside aien-dev and needs Drake's OK for
4this one item.
5
6- Target: `nuprl/MultiPL-E`, branch `main`, based on
7 `3025a531af7450e7df8b96fe0440e9804480bbad`.
8- Patch: `0001-Add-Omega-OM-2-translator-and-evaluator.patch`. Apply it with
9 `git am` or `git apply`. It adds 610 lines in 5 files and deletes none.
10- `dataset_builder/terms.csv` uses CRLF line endings. The patch keeps them, and
11 `bench/.gitattributes` stops git from rewriting the patch file.
12
13How it was checked (2026-10-27, Linux AArch64):
14
151. `git apply --check` succeeded on a fresh clone at the base commit, and the patch
16 then applied.
172. MultiPL-E's own `dataset_builder/prepare_prompts_for_hfhub.py` ran in the patched
18 tree with `--lang humaneval_to_om.py --doctests transform --prompt-terminology
19 reworded`. HumanEval gave 129 problems and `mbpp-typed` gave 272. Their `prompt`,
20 `tests`, `stop_tokens` and `language` fields equal `bench/prompts/*.jsonl` for
21 every problem. The script imports `datasets`, so this check ran in a throwaway
22 venv with `datasets` 5.1.0.
233. In the patched `evaluation/src`, `containerized_eval.eval_string_script("om", …)`
24 ran on the two completions in `evaluation/test_inputs/om-hand-0.0-keep-HumanEval53.json`
25 with `OMEGA_OMC` set. The results were `OK` (exit 0) and `SyntaxError` (omc error 4),
26 which is the "first OK, second fails" shape the other `test_inputs` use.
27
28NOT_RUN:
29
30- The MultiPL-E evaluation container. Its Dockerfile is `ubuntu:22.04` with amd64-only
31 apt sources, and omc writes AArch64 executables.
32- Any model.
33- `evaluation/src/main.py --testing`, because the host has no `tqdm`.
34
35---
36
37## PR title
38
39Add Omega (OM-2) as a MultiPL-E language
40
41## PR body
42
43This adds [Omega](https://github.com/aien-dev/omega-mv) as a MultiPL-E target
44language with file extension `.om`. Omega is a small systems language with its
45own compiler, `omc`, which writes static AArch64 Linux executables directly.
46
47**What is added**
48
49- `dataset_builder/humaneval_to_om.py` is the `Translator`. Each problem becomes an
50 OM-2 `fn` signature preceded by `note` lines that carry the docstring. Doctests
51 are transformed into Omega call syntax.
52 - Type mapping: `int`→`long`, `float`→`f64`, `bool`→`bool`,
53 `List[int]`/`List[float]`→`view long *`/`view f64 *`, `str`→`view uchar *`,
54 and homogeneous numeric tuples→views.
55 - A list, string or tuple result becomes a trailing `res edit T *` parameter, and
56 the function returns the element count.
57 - The tests become one Omega function per assertion plus a `main`. `main` exits
58 with `K+1` when case K fails. When every case holds, it prints
59 `MultiPL-E Omega: all tests passed` and exits 0.
60 - The translator refuses (returns `None`, with a reason) every type or value it
61 can't express faithfully: `List[str]`, nested lists, mixed tuples,
62 `Optional`, `Union`, `Dict`, `Set`, `Any`, non-ASCII strings, ints outside
63 i64, and calls with more than 6 argument slots.
64 - Coverage at this base commit: HumanEval 129 of the 161 originals (161 of the
65 164 problems), MBPP (`mbpp-typed`) 272 of 400.
66- `evaluation/src/eval_om.py` compiles with `omc` and runs the program. It uses
67 only the standard library.
68 - Compile failure, or any omc diagnostic, is `SyntaxError`.
69 - A pass is `OK` and requires exit 0 **and** the final pass line.
70 - A wrong answer or a trap is `Exception`, and a time-out is `Timeout`.
71 - Each run gets its own process group, which is killed on time-out.
72- `terms.csv` gets the row `Omega,om,array,array,array,dictionary,none,true,false`.
73 Omega has no dictionary or None value, and problems that use them are refused.
74- `containerized_eval.py` gets the `"om"` entry.
75- `evaluation/test_inputs/om-hand-0.0-keep-HumanEval53.json` holds one passing and
76 one non-compiling completion.
77
78**Running it**
79
80Set `OMEGA_OMC` to an `omc` binary. `eval_om.py` checks its sha256 against
81`OMEGA_OMC_SHA256`, which defaults to the pinned build: omega-mv
82`e5b32567a7aff3ce594e3254a622a846a6cd190b`, sha256
83`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. If the hash
84doesn't match, it refuses to evaluate, so results always name one compiler.
85`OMEGA_EVAL_TIMEOUT` sets the per-program limit in seconds (default 15).
86
87omc targets Linux AArch64 only. The current evaluation image is amd64, so this PR
88does **not** change the Dockerfile. Two options, neither tried:
89
90- Build the image for `linux/arm64`.
91- Add `qemu-user` to the amd64 image and set `OMEGA_EVAL_WRAP=qemu-aarch64`.
92 omc is itself an AArch64 executable, and the prefix applies to both omc and the
93 compiled program.
94
95An arm64 image could fetch the pinned compiler as follows:
96
97```dockerfile
98RUN git clone https://github.com/aien-dev/omega-mv /omega && \
99 git -C /omega checkout e5b32567a7aff3ce594e3254a622a846a6cd190b
100ENV OMEGA_OMC=/omega/seed/out/omc
101```
102
103`seed/omega-from-seed.sh` in that repository can instead rebuild omc from its
104408-byte seed.
105
106**Evidence**
107
108The adapter's own gate suite is `bench/check.sh` in
109[aien-dev/omega-rosetta](https://github.com/aien-dev/omega-rosetta). It compiles
110every translated HumanEval and MBPP problem with a stub body.
111
112| completions | pass@1 |
113|---|---|
114| 10 hand-written HumanEval solutions | 1.0 |
115| constant wrong answers | 0.0 (all `wrong_answer`) |
116| invalid syntax | 0.0 (all `SyntaxError`) |
117| traps | 0.0 (all `trap`) |
118| infinite loops | 0.0 (all `Timeout`) |
119
120No language model was evaluated for this PR.
121
122**Licence**
123
124The contribution is offered under MultiPL-E's licence (BSD 3-Clause with the
125Machine Learning Restriction in `LICENSE`).
126
127---
128
129## Wolfram check of the pass@k values
130
131The `bench/score.py` estimator matches MultiPL-E's `pass_k.estimator`. Its pass@k
132values were checked with Wolfram:
133
134```
135WolframLanguageEvaluator:
136 est[n_,c_,k_] := If[n - c < k, 1, 1 - Binomial[n - c, k]/Binomial[n, k]];
137 {Mean[Table[est[1,1,1],10]], Mean[Table[est[1,0,1],10]],
138 N[est[20,7,1],17], N[est[20,7,10],17], N[est[200,13,100],17], N[est[5,3,10],17]}
139-> {1, 0, 0.35, 0.99845201238390093, 0.99991949719880544, 1.}
140```
141
142`score.estimator` gave `0.3500000000000001`, `0.9984520123839009`,
143`0.9999194971988055` and `1.0` for the last four. They agree to double precision.