diff --git a/native/collective/README.md b/native/collective/README.md new file mode 100644 index 0000000..c14862a --- /dev/null +++ b/native/collective/README.md @@ -0,0 +1,86 @@ +# SI sparse collective: native .om algebraic pilot + +**Status:** Review branch. Seeded omc rejected `bestscore` (error 13: names at most 8 characters). This commit renames that local to `bscore`. Host sandbox execution of the pinned compiler is filed with the PR comment request; it is not repository qualification. Live model training and DGX Spark qualification remain **NOT_RUN**. + +**Issue:** [aien-train #26](https://github.com/aien-dev/aien-train/issues/26) under [SI Fusion architecture #306](https://github.com/aien-dev/aien-architecture-mv/issues/306) and [SI Genesis #307](https://github.com/aien-dev/aien-architecture-mv/issues/307). + +This is deliberately a small first-party handwritten seeded Omega experiment. The branch does **not** introduce a neural trainer, a new runtime, a model router, another Cortex store, a GPU scheduler or a public endpoint. It does not import, modify or download any model checkpoint. Existing [Omega #694](https://github.com/aien-dev/omega-mv/issues/694) owns native 0.8B/2B inference; [Omega #695](https://github.com/aien-dev/omega-mv/issues/695) owns physical batching; [Core #737](https://github.com/aien-dev/aien-sovereign-core-mv/issues/737) owns Spark admission. + +## What the small program actually does + +[`shared_bank_p0.om`](shared_bank_p0.om) creates a synthetic common integer matrix B of shape 2x3 and a 3-vector x. The 8 specialist candidates are *rank-one* differences U_i V_i^T where U_i has 2 entries and V_i has 3. Their response is: + + y(i, sign) = B*x + sign*U_i*(V_i^T*x) ; sign in {+1,-1} + +- It computes the common B*x **once** into a two-element scratch array. +- It calls the same rank-one adapter evaluator for eight candidate indices in positive and negative phases, checking all **16 outputs**. +- It checks two selected candidate IDs by a deterministic score and allowed mask: [1,3]. It is a toy proposal policy, **not** AEGIS authority or a trained router. +- Denying ID 1 makes the top choice ID 3. Refusing all 8 returns sentinel ID 8 rather than executing an invented model. +- It refuses out-of-range candidate ID, denied candidate and unsupported phase. A nonzero program exit indicates a failed self-test. +- It separately asserts the shared base was computed exactly once, and 16 admitted adapter calls occurred. + +Only exact bounded signed integer arithmetic is used. This fixture does not check numerical FP8/GDN/attention, train a LoRA, allocate GPUs or implement multi-tenant security. + +## Independent mathematical reference + +[`fixtures/golden_v0.json`](fixtures/golden_v0.json) is a frozen independent Wolfram integer-matrix oracle, not calculated by the proposed native .om kernel. The test's expected common response is [16,-8]. + +| Candidate i | positive output | negative output | +| --- | --- | --- | +| 0 | [-2,-2] | [34,-14] | +| 1 | [10,-2] | [22,-14] | +| 2 | [16,-8] | [16,-8] | +| 3 | [16,-20] | [16,4] | +| 4 | [10,-38] | [22,22] | +| 5 | [-2,-62] | [34,46] | +| 6 | [-20,-92] | [52,76] | +| 7 | [-44,-128] | [76,112] | + +Reproduce reference values with an independently obtained Wolfram Language kernel: + +```wolfram +x={2,3,5}; +b={{2,-1,3},{1,0,-2}}; +out[i_,sgn_]:=(b+sgn Outer[Times,{i-3,i+1},{1,3-i,-1}]).x; +Table[{i,out[i,1],out[i,-1]},{i,0,7}] +``` + +## Native execution instructions + +In a **claimed isolated AArch64 worktree** with the current owner-approved Omega seed compiler, and a separate checkout of `aien-train` at the PR head: + +```sh +cd /path/to/pinned/omega-mv +sh seed/omega-from-seed.sh +mkdir -p build/si-sparse +seed/out/omc < /path/to/aien-train/native/collective/shared_bank_p0.om > build/si-sparse/shared-bank +chmod +x build/si-sparse/shared-bank +timeout 10 build/si-sparse/shared-bank +printf 'native_exit=%s\n' "$?" +sha256sum seed/out/omc build/si-sparse/shared-bank +``` + +Expected executable exit: 0. + +Observed host record (HOST aarch64 only, 2026-10-30, reviewer-run): omc sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` (omega-mv e5b32567 pin) compiled `shared_bank_p0.om` to a binary with sha256 `b3368c5e9cf2b238fee63c0c04b38223205d6b634ce871dba8c9ceaf50f3bba8`, exit 0. Source mutant: changing the single `sub sid 3` to `sub sid 4` makes the program exit 4, so the self-test catches it. This is host execution only; it is not emulator, GPU or Spark qualification. A future compile failure must be recorded and fixed by the existing seeded compiler/profile owner or in this branch's source; do not replace it with Python/C/PyTorch product execution. On an x86-64 system without a qualified AArch64 emulator, a native execution is NOT_RUN, not PASS or FAIL. + +Do not use this AArch64 smoke to infer an sm_121 GPU kernel already exists. Preserve raw commands, compiler/source hashes, program output and independent checker review when executed. + +## Engineering hypothesis, and an intentionally weak example + +For **eight full 2x3 expert matrices** the raw dense baseline has 8*6 = 48 scalar weight entries. The shared representation stores 6 common + 8*(2+3) = 46 scalar entries **before** counting routing scores, masks, dictionary metadata, provenance, padding, tensor formats or code. This tiny example is likely *not profitable* in total serialized bytes or runtime work; it exists to check correctness and illustrate reuse. + +Only with much larger matching matrix shapes and low-rank learned adapter deltas can a shared representation plausibly reduce external memory bytes. Rank-r factorization is evaluated over its full metadata and low-rank projection operations; quantized formats must be compared at identical quality. The real 35B and 27B have different architectures and cannot simply share parameter coordinates. + +**No physical memory-bandwidth saving, token speedup or model quality improvement is claimed.** + +## Next owner steps + +1. DONE (host aarch64, see the observed host record above): on existing approved seed/host chain, run the exact .om positive/negative cases and independently mutate one factor sign or one expected oracle entry; the gate should fail. Record SHA, command, exit and whether the test ran on host/emulator. +2. Verify the actual current 0.8B staging/model-license/quant/feature profile through [Core #737](https://github.com/aien-dev/aien-sovereign-core-mv/issues/737) and native Omega model requirements [#694](https://github.com/aien-dev/omega-mv/issues/694); do not acquire weights or take a Spark lock without approval. +3. In native aien-train #3/#6 work, train eight real same-base specialist adapters using independent admitted data. Compare eight exact standalone small models as a control, and a truly from-scratch experience model via existing #19 as a distinct origin. +4. Use verified microjob ABI [protocols #50](https://github.com/aien-dev/aien-protocols-mv/issues/50), Allen [#13](https://github.com/aien-dev/allen/issues/13), Omega [#695](https://github.com/aien-dev/omega-mv/issues/695) and current FORGE device owner to route a bounded number of qualified adapters **without duplicating full base weights**. +5. Freeze independent full-task quality/safety/economics in [benchmarks #38](https://github.com/aien-dev/benchmarks-mv/issues/38); only scale the candidate count 8 to 32 to 128 if the completed objective and physical cost improve at matched quality. +6. Final product-owned code/tooling remains seeded .om, and [architecture #300/#316](https://github.com/aien-dev/aien-architecture-mv/issues/300) controls elimination of first-party legacy runtime dependencies after separate verification. + +No code in this branch changes the production server or shared compiler. GitHub draft PR does not mean qualified execution. diff --git a/native/collective/fixtures/golden_v0.json b/native/collective/fixtures/golden_v0.json new file mode 100644 index 0000000..8dbf4fa --- /dev/null +++ b/native/collective/fixtures/golden_v0.json @@ -0,0 +1,37 @@ +{ + "schema": "si.sparse.synthetic.golden.v0", + "claim_class": "MATH_ORACLE_ONLY", + "provenance": "Wolfram Language exact integer arithmetic, 2026-10-24", + "trained_models": false, + "loaded_checkpoints": false, + "hardware_tested": false, + "arithmetic": "signed integer exact within the bounded fixture; no overflowing operations", + "base_matrix": [[2,-1,3],[1,0,-2]], + "input": [2,3,5], + "base_output": [16,-8], + "rank_per_adapter": 1, + "adapter_count": 8, + "adapter_formula": { + "u_i": ["i-3","i+1"], + "v_i": [1,"3-i",-1], + "positive": "B*x + U_i*(V_i^T*x)", + "negative": "B*x - U_i*(V_i^T*x)" + }, + "scores": [4,11,7,9,8,0,3,2], + "allowed": [1,1,1,1,1,1,1,1], + "selected_top2": [1,3], + "positive_outputs": [[-2,-2],[10,-2],[16,-8],[16,-20],[10,-38],[-2,-62],[-20,-92],[-44,-128]], + "negative_outputs": [[34,-14],[22,-14],[16,-8],[16,4],[22,22],[34,46],[52,76],[76,112]], + "negative_controls": { + "deny_specialist_1_then_top1": 3, + "all_denied_refusal_id": 8, + "invalid_index_status": -1, + "denied_status": -2, + "invalid_phase_status": -3 + }, + "expected_shared_matvec_count": 1, + "expected_successful_adapter_call_count": 16, + "storage_scalars_full_eight_matrices": 48, + "storage_scalars_shared_base_plus_rank_one": 46, + "storage_note": "46 excludes scores, allowed bits, identity, metadata, binary and decoder; no net-storage or performance win established for this tiny fixture" +} diff --git a/native/collective/shared_bank_p0.om b/native/collective/shared_bank_p0.om new file mode 100644 index 0000000..9269326 --- /dev/null +++ b/native/collective/shared_bank_p0.om @@ -0,0 +1,224 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note aien-train#26: first native .om sparse-collective algebraic experiment. +note ONE shared 2x3 matrix + EIGHT rank-one signed specialist differences. +note All data and scores are synthetic. No model checkpoint is loaded. +note This is neither a trained specialist nor a GPU/runtime dispatch implementation. +note Seeded omc names are at most 8 characters (error 13). bscore replaces bestscore. +note Full reference numbers independently calculated in Wolfram Language. + +global B long 6 +global U long 16 +global V long 24 +global X long 3 +global Shared long 2 +global Out long 2 +global Scores long 8 +global Allowed uchar 8 +global Counts ulong 2 +global Plus long 16 +global Minus long 16 + +fn init to void +put B 0 2 +put B 1 -1 +put B 2 3 +put B 3 1 +put B 4 0 +put B 5 -2 +put X 0 2 +put X 1 3 +put X 2 5 +put Scores 0 4 +put Scores 1 11 +put Scores 2 7 +put Scores 3 9 +put Scores 4 8 +put Scores 5 0 +put Scores 6 3 +put Scores 7 2 +for id ulong 8 +put Allowed id 1 +sid = long id +ui = mul id 2 +vi = mul id 3 +put U ui sub sid 3 +put U add ui 1 add sid 1 +put V vi 1 +put V add vi 1 sub 3 sid +put V add vi 2 -1 +end +put Counts 0 0 +put Counts 1 0 +put Plus 0 -2 +put Plus 1 -2 +put Plus 2 10 +put Plus 3 -2 +put Plus 4 16 +put Plus 5 -8 +put Plus 6 16 +put Plus 7 -20 +put Plus 8 10 +put Plus 9 -38 +put Plus 10 -2 +put Plus 11 -62 +put Plus 12 -20 +put Plus 13 -92 +put Plus 14 -44 +put Plus 15 -128 +put Minus 0 34 +put Minus 1 -14 +put Minus 2 22 +put Minus 3 -14 +put Minus 4 16 +put Minus 5 -8 +put Minus 6 16 +put Minus 7 4 +put Minus 8 22 +put Minus 9 22 +put Minus 10 34 +put Minus 11 46 +put Minus 12 52 +put Minus 13 76 +put Minus 14 76 +put Minus 15 112 +end + +fn makebase to void +for row ulong 2 +acc = long 0 +for col ulong 3 +idx = add mul row 3 col +z = mul get B idx get X col +acc = add acc z +end +put Shared row acc +end +put Counts 0 add get Counts 0 1 +end + +note Tiny synthetic admission only. Capability authority remains Omega/AEGIS. +note Returns index 8 if no candidate allowed, rather than silently dispatching. +fn pick used ulong to ulong +best = ulong 8 +bscore = long -9999 +for id ulong 8 +if eq get Allowed id 1 +flag = and used shl ulong 1 id +if eq flag 0 +score = get Scores id +if gt score bscore +bscore = score +best = id +end +end +end +end +ret best +end + +note Status 0=success; -1=bad index; -2=refused; -3=bad phase. +note Outputs are written only for successful calls. +note Formula: y = B*x + phase*U[id]*(V[id]^T*x), phase in {-1,+1}. +fn apply id ulong phase long to long +if ge id 8 +ret -1 +end +if ne get Allowed id 1 +ret -2 +end +if ne phase 1 +if ne phase -1 +ret -3 +end +end +dot = long 0 +vi = mul id 3 +for col ulong 3 +v = get V add vi col +dot = add dot mul v get X col +end +ui = mul id 2 +for row ulong 2 +diff = mul get U add ui row dot +result = add get Shared row mul phase diff +put Out row result +end +put Counts 1 add get Counts 1 1 +ret 0 +end + +fn main to int +init +makebase +if ne get Shared 0 16 +ret 1 +end +if ne get Shared 1 -8 +ret 2 +end +for id ulong 8 +idx = mul id 2 +a = apply id 1 +if ne a 0 +ret 3 +end +if ne get Out 0 get Plus idx +ret 4 +end +if ne get Out 1 get Plus add idx 1 +ret 5 +end +b = apply id -1 +if ne b 0 +ret 6 +end +if ne get Out 0 get Minus idx +ret 7 +end +if ne get Out 1 get Minus add idx 1 +ret 8 +end +end +if ne get Counts 0 1 +ret 9 +end +if ne get Counts 1 16 +ret 10 +end +first = pick 0 +if ne first 1 +ret 11 +end +used = shl ulong 1 first +second = pick used +if ne second 3 +ret 12 +end +put Allowed 1 0 +if ne pick 0 3 +ret 13 +end +a = apply 1 1 +if ne a -2 +ret 14 +end +if ne apply 8 1 -1 +ret 15 +end +if ne apply 3 0 -3 +ret 16 +end +for id ulong 8 +put Allowed id 0 +end +if ne pick 0 8 +ret 17 +end +if ne get Counts 0 1 +ret 18 +end +if ne get Counts 1 16 +ret 19 +end +ret 0 +end