From d2aaa308d925bf628b3fbe3bd0809cad34b2fba0 Mon Sep 17 00:00:00 2001 From: Drake Stapleton <213298340+drakestapleton@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:34:59 -0600 Subject: [PATCH] Add a seeded Omega training harness for CPU and GB10 --- CONTRIBUTORS.md | 1 + train/omega-llm/README.md | 20 +++ train/omega-llm/tools/wdrive/wtrain.om | 206 +++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 train/omega-llm/tools/wdrive/wtrain.om diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 28d22900a..d0bd5ba8c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -358,3 +358,4 @@ Update this table in the same commit as the work it credits. | Antigravity (under Drake Stapleton's direction) | Pure seeded OM-2 runtime migration (`om/runtime/`, 11 units bound via `om/units.sh`): migrated regulator decision/envelope/step (`rx_regulate.om`), canonical Machine ID codec/hash/compare (`rx_mid.om`), Cortex crumb classification/digest/link dedup (`rx_cortex_rec.om`), plan word/predicate sort/arrangement fact pack (`rx_plan_core.om`), state projection summary/classification (`rx_projection.om`), capability query hash/ranking/Pareto dominance/128-bit tolerance band (`rx_capq_core.om`), Bayesian cost model Cholesky/Student-t/rank-1 update (`rx_costmodel_core.om`), cognitive routing binning/Wilson interval (`rx_route_core.om`), World lifecycle FSM/resource admission/priority ordering (`rx_world_core.om`), skill router rejection bitmask/digest-zero (`rx_skillroute_core.om`), and workflow fusion eligibility/word64 (`rx_fusion_core.om`). Verified on Spark (`om/units.sh --check` + 14 host runtime test suites). | | Codex (under Drake Stapleton's direction) | Integrated Antigravity's runtime units with current bindings and restored large and overlapping projection summary inputs. | | Codex (under Drake Stapleton's direction) | Ported OSC integer-literal decoding and overflow detection to seeded Omega and connected the lexer to the generated binding. | +| Codex (under Drake Stapleton’s direction) | Implemented the seeded Omega training harness for native tokenization, CPU and GB10 fine-tuning and held-out evaluation. | diff --git a/train/omega-llm/README.md b/train/omega-llm/README.md index 08f377aea..73a42d130 100644 --- a/train/omega-llm/README.md +++ b/train/omega-llm/README.md @@ -15,6 +15,26 @@ The Python corpus builder and compile feedback loop live in `tools/omega-llm/` a Stays in aien-train (listed in `train/NOT-YET-OMEGA.tsv`): the shell/Python harness `tests/omegallm/` (`build.sh`, `oracle.py`, `pre-review.py`, ...), `evidence/OMEGALLM/` receipts, and the C++ llama.cpp UI bridge `tools/omegallm-ui/`. The docs here still cite those upstream paths and commits. Unless a citation names a different commit, upstream paths refer to aien-train `f1bebdf3c5b08ec624005e5bc39d0427a87f9537`; they are not local omega-mv paths. +## Training from source text + +The seeded `wtrain` harness fine-tunes an existing checkpoint on a training text file and evaluates both checkpoints on the same held-out text. For a coding run, supply Omega source or instruction-and-function records. Keep the evaluation corpus separate before starting the run. The trainer uses full-token loss. + +Build on AArch64 Linux from the repository root with the seeded compiler. The first source supplies the existing Omega driver library. + +```sh +driver=train/omega-llm/tools/wdrive +{ sed "s/^fn main to int$/fn wbmain to int/" "$driver/wbuild.om"; cat "$driver/wtrain.om"; } | seed/out/omc > wtrain && chmod +x wtrain +``` + +Pass an Omega LLM executable, base checkpoint, tokenizer merges, training file, held-out file, new output directory, step count, learning rate in millionths and number of held-out windows. Byte checkpoints use `-` for the merges argument. BPE checkpoints use the native `bpeenc` command with the vocabulary size from the base checkpoint. Each corpus must supply at least one context window plus the next token. The held-out file must cover the requested number of windows. + +```sh +./wtrain cpu ./ollm base.ck merges.bin training.om held-out.om run-01 100 250 3 +spark-window run ./wtrain gb10 ./ollm-gb10 base.ck merges.bin training.om held-out.om run-02 100 250 3 +``` + +The GPU invocation runs inside an authorized exclusive Spark window. The harness creates a private directory, writes the token streams and `candidate.ck` there, and records native tokenizer, optimizer and evaluator output in `run.log`. An existing output directory is refused. A failed run retains its partial files. A successful run ends with `TRAINING_COMPLETE` after the final evaluation. The E lines report held-out language-model loss. Coding accuracy requires separate execution tests. + ## Units Built by `seed/out/omc` and gated by `train/units-gate.om` (`OMEGA-TRAIN-UNITS`), rows in `train/units.tsv`, composed as upstream `tests/omegallm/build.sh` does (`math data model adam ckpt bpe spec cli `); `build.sh` has no Darwin target, so the `ollm_darwin` row follows upstream `tests/omegallm/ollm_metrics_bench.py` (`darwin-arm64`): diff --git a/train/omega-llm/tools/wdrive/wtrain.om b/train/omega-llm/tools/wdrive/wtrain.om new file mode 100644 index 000000000..68233ed07 --- /dev/null +++ b/train/omega-llm/tools/wdrive/wtrain.om @@ -0,0 +1,206 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Compose after wbuild.om with its main renamed to wbmain. +text ftusage "usage: wtrain cpu|gb10 OLLM BASE MERGES TRAIN_TEXT HELD_TEXT NEW_DIR STEPS LRMICRO WINDOWS\n" +text ftgpu "gb10" +text ftcpu "cpu" +text ftlock "AIEN_GB10_LOCK_HELD" +text ftwindow "SPARK_WINDOW" +text ftneed "gb10 training requires an exclusive spark-window run\n" +text ftoutfail "cannot create fresh run directory\n" +text ftbad "invalid checkpoint or numeric argument\n" +text fttrain "/train.tok" +text ftheld "/held.tok" +text ftck "/candidate.ck" +text ftlog "/run.log" +text ftencode "bpeenc" +text fttune "tune" +text fttr "train" +text ftgtr "gtrainf" +text ftev "eval" +text ftgev "geval" +text ftbase "baseline\n" +text ftafter "candidate\n" +text ftcomplete "TRAINING_COMPLETE\n" + +fn ftfail msg view uchar * code int to void +wdwrall 2 msg len msg +exit code +end +fn ftmatch i ulong word view uchar * to bool +n = wdarg i +if ne n len word +ret false +end +for j ulong n +if ne get wdab j get word j +ret false +end +end +ret true +end +fn ftpositive i ulong to void +n = wdarg i +v = ulong 0 +for j ulong n +c = ulong get wdab j +if or lt c 48 gt c 57 +ftfail ftbad 2 +end +d = sub c 48 +if gt v div sub 18446744073709551615 d 10 +ftfail ftbad 2 +end +v = add mul v 10 d +end +if eq v 0 +ftfail ftbad 2 +end +end +fn ftpath suffix view uchar * to void +wdpclr +wdpa 7 +wdpt suffix +end +fn ftpush suffix view uchar * to void +ftpath suffix +wdkp +end +fn ftstart cmd view uchar * to void +wdkclr +wdka 2 +wdkt cmd +end +fn ftrun fd int to void +rc = wdwait wdspawn -1 fd fd +if ne rc 0 +exit int rc +end +end +fn ftvocab to ulong +wdpclr +wdpa 3 +fd = wdopen 0 0 +if lt fd 0 +ftfail ftbad 3 +end +h = new uchar 16 0 +n = read fd h 0 16 +z = fclose fd +if ne n 16 +ftfail ftbad 3 +end +v = ulong 0 +for i ulong 8 +v = or v shl ulong get h add 8 i mul 8 i +end +ret v +end +fn ftdata src ulong suffix view uchar * vocab ulong logfd int to void +if eq vocab 256 +wdpclr +wdpa src +fi = wdopen 0 0 +ftpath suffix +fo = wdopen 193 384 +if or lt fi 0 lt fo 0 +exit 70 +end +wdcopyfd fi fo +c1 = fclose fi +c2 = fclose fo +if or ne c1 0 ne c2 0 +exit 70 +end +else +ftstart ftencode +wdka 4 +wdpclr +wdpd vocab +wdkp +wdka src +ftpush suffix +ftrun logfd +end +end +fn ftmeasure gpu bool trained bool vocab ulong fd int to void +if gpu +ftstart ftgev +else +ftstart ftev +end +if trained +wdwrall fd ftafter len ftafter +ftpush ftck +else +wdwrall fd ftbase len ftbase +wdka 3 +end +ftpush ftheld +wdka 10 +if gt vocab 256 +wdka 4 +end +ftrun fd +end +fn main to int +if ne argcnt 11 +ftfail ftusage 2 +end +gpu = ftmatch 1 ftgpu +if and not gpu not ftmatch 1 ftcpu +ftfail ftusage 2 +end +if gpu +if not wdenv ftlock +ftfail ftneed 3 +end +if or ne get wdvn 0 1 ne get wdv 0 49 +ftfail ftneed 3 +end +if not wdenv ftwindow +ftfail ftneed 3 +end +end +ftpositive 8 +ftpositive 9 +ftpositive 10 +v = ftvocab +wdpclr +wdpa 7 +r = makedir wdp 0 get wdpn 0 448 +if ne r 0 +ftfail ftoutfail 3 +end +ftpath ftlog +fd = wdopen 193 384 +if lt fd 0 +exit 70 +end +ftdata 5 fttrain v fd +ftdata 6 ftheld v fd +ftmeasure gpu false v fd +ftstart fttune +wdka 3 +ftpush ftck +wdka 8 +wdka 9 +ftrun fd +if gpu +ftstart ftgtr +else +ftstart fttr +end +ftpush ftck +ftpush fttrain +wdka 8 +wdka 8 +ftrun fd +ftmeasure gpu true v fd +wdwrall fd ftcomplete len ftcomplete +z = fclose fd +if ne z 0 +exit 70 +end +wdwrall 1 ftcomplete len ftcomplete +ret 0 +end