M4: levels 2-4 - cd_mul op, hypercomplex linears, converter + parity #6

Closed
opened 2026-11-11 19:07:28 +00:00 by dsh · 2 comments
Member

Extend the port from level 1 (complex) to Cayley-Dickson levels 2-4 (quaternion, octonion, sedenion).

  • ggml_cd_mul (elementwise, level in op params, CPU f32) + cd_conjugate; level 4 is non-alternative, no scan shortcuts.
  • HyperLinear level >= 2: real spread matrix from the CD table at load -> stock MUL_MAT (4x/16x/64x memory), or a later cd_mul_mat kernel.
  • Converter: level >= 2 tensor layout, gamma [H,hs,hs,hd], out_proj spread; reconvert quaternion/octonion/sedenion configs.
  • RAT 2-4: hypercomplex recurrence + recall. ggml_tardits_scan is level-1-only today - extend with a level/CD table or add a separate op; keep level-1 byte-identical.
  • HyperFormer 2-4: GyRoPE rotors for arbitrary level, HyperRMSNorm, attention flatten 2hdhs channels.
  • Goldens + parity for the shipped configs; tolerance documented.
  • Follow-up from #5: a true CTest fixture that generates a tiny random-init TARDITS GGUF in the build tree and checks parity.

Start with converter + cd_mul on standalone tensor fixtures, then RAT level 2, then 3-4. Reference: devops/tardits.md, devops/runtime.md, devops/research/tardits-inventory.md.

Extend the port from level 1 (complex) to Cayley-Dickson levels 2-4 (quaternion, octonion, sedenion). - `ggml_cd_mul` (elementwise, level in op params, CPU f32) + `cd_conjugate`; level 4 is non-alternative, no scan shortcuts. - `HyperLinear` level >= 2: real spread matrix from the CD table at load -> stock MUL_MAT (4x/16x/64x memory), or a later cd_mul_mat kernel. - Converter: level >= 2 tensor layout, gamma [H,hs,hs,hd], out_proj spread; reconvert quaternion/octonion/sedenion configs. - RAT 2-4: hypercomplex recurrence + recall. `ggml_tardits_scan` is level-1-only today - extend with a level/CD table or add a separate op; keep level-1 byte-identical. - HyperFormer 2-4: GyRoPE rotors for arbitrary level, HyperRMSNorm, attention flatten 2*hd*hs channels. - Goldens + parity for the shipped configs; tolerance documented. - Follow-up from #5: a true CTest fixture that generates a tiny random-init TARDITS GGUF in the build tree and checks parity. Start with converter + cd_mul on standalone tensor fixtures, then RAT level 2, then 3-4. Reference: devops/tardits.md, devops/runtime.md, devops/research/tardits-inventory.md.
dsh self-assigned this 2026-11-11 19:07:29 +00:00
Author
Member

M4a landed (869c8ed7f): llama.cpp now speaks hypercomplex - HyperFormer at levels 2, 3 and 4 runs, not just complex.

  • ggml_cd_mul op (CPU f32, levels 1-4, elementwise Cayley-Dickson product) - the kernel that unlocks CD levels anywhere in the graph.
  • Converter level >= 2: single real tensors, interleaved component layout per channel, and spread matrices for every hypercomplex linear obtained by probing the reference module (the module's multiplication convention is not the textbook one - a paper derivation was off by 1.66 right away). Also lm-head column permutation, GyRoPE theta/axis, same tardits-hyper arch string.
  • Graph level >= 2: custom token-id input (embeddings are n*C wide), {n,C,T} activations, GyRoPE rotor via ggml_cos/ggml_sin + cd_mul, attention over n*hs real channels with wo=nullptr then spread out_proj, generalised HyperRMSNorm.
  • Fixtures: deterministic random-init quat/oct/sed checkpoints (tools/make_random_fixtures.py) + committed goldens; check_parity.sh now runs 10 checks - 10/10 PASS:
level single-step prefill-44 greedy
quaternion (2) 5.066e-07 6.557e-07 exact
octonion (3) 5.364e-07 4.768e-07 exact
sedenion (4) 3.278e-07 3.874e-07 exact

Level-1 RAT and hyper regression unchanged; all five GGUFs generate via stock llama-completion. Docs: devops/runtime.md M4a section, devops/gguf-bridge.md level>=2 tensor table.

Remaining for this issue (M4b): RAT levels 2-4 - hypercomplex state (gamma), ingest (v (x) conj(k)) and recall are bilinear, so this needs an outer-product CD op plus a level-aware scan; the level-1 ggml_tardits_scan stays byte-identical. Plus the true CTest fixture (generates a tiny GGUF in the build tree). Keeping the issue open for that.

**M4a landed** (`869c8ed7f`): llama.cpp now speaks hypercomplex - HyperFormer at levels 2, 3 and 4 runs, not just complex. - `ggml_cd_mul` op (CPU f32, levels 1-4, elementwise Cayley-Dickson product) - the kernel that unlocks CD levels anywhere in the graph. - Converter level >= 2: single real tensors, interleaved component layout per channel, and **spread matrices for every hypercomplex linear obtained by probing the reference module** (the module's multiplication convention is not the textbook one - a paper derivation was off by 1.66 right away). Also lm-head column permutation, GyRoPE theta/axis, same `tardits-hyper` arch string. - Graph level >= 2: custom token-id input (embeddings are `n*C` wide), `{n,C,T}` activations, GyRoPE rotor via `ggml_cos`/`ggml_sin` + `cd_mul`, attention over `n*hs` real channels with `wo=nullptr` then spread out_proj, generalised HyperRMSNorm. - Fixtures: deterministic random-init quat/oct/sed checkpoints (`tools/make_random_fixtures.py`) + committed goldens; `check_parity.sh` now runs 10 checks - **10/10 PASS**: | level | single-step | prefill-44 | greedy | |---|---|---|---| | quaternion (2) | 5.066e-07 | 6.557e-07 | exact | | octonion (3) | 5.364e-07 | 4.768e-07 | exact | | sedenion (4) | 3.278e-07 | 3.874e-07 | exact | Level-1 RAT and hyper regression unchanged; all five GGUFs generate via stock `llama-completion`. Docs: `devops/runtime.md` M4a section, `devops/gguf-bridge.md` level>=2 tensor table. **Remaining for this issue (M4b):** RAT levels 2-4 - hypercomplex state (`gamma`), ingest (`v (x) conj(k)`) and recall are bilinear, so this needs an outer-product CD op plus a level-aware scan; the level-1 `ggml_tardits_scan` stays byte-identical. Plus the true CTest fixture (generates a tiny GGUF in the build tree). Keeping the issue open for that.
Author
Member

M4 is complete for both families (44411d817 + 8703c4965):

M4b - RAT levels 2-4 (44411d817)

  • New ggml_tardits_scan_cd: one fused node per layer/token-block doing S_t = cd_mul(S,gamma) + cd_mul(v,conj(k)), out = scale*sum_k cd_mul(S,q). Ingest/recall are bilinear, so an elementwise expansion would blow up the graph; level is in op params, gamma [n,hs_v,hs_k,H], state [n*hs*hs*H]. Level-1 ggml_tardits_scan untouched.
  • Level >= 2 graph now serves both families (RAT recurrent scan vs HyperFormer GyRoPE+attention); converter level >= 2 moved to convert_hc.py for both arch strings.
  • Parity (vs Python RAT.step): quaternion 1.587e-06 / 1.311e-06, octonion 8.345e-07 / 8.941e-07, sedenion 5.513e-07 / 5.215e-07 (single-step / prefill-44), greedy chains exact. check_parity.sh now runs 16 checks, 16/16 PASS.

M4c - SmolLM2 BPE tokenizer (8703c4965)

  • --tokenizer-dir writes a GPT-2-style BPE (pre=smollm), verified against HF on 95/95 encode + 95/95 detok + special probes; char GGUFs byte-identical. This is what the trained Colab checkpoint will use so llama.cpp speaks words instead of characters.

Remaining follow-up (not blocking): a true CTest parity fixture that generates a tiny GGUF in the build tree - moving that to a fresh issue. Closing this one.

**M4 is complete for both families** (`44411d817` + `8703c4965`): **M4b - RAT levels 2-4** (`44411d817`) - New `ggml_tardits_scan_cd`: one fused node per layer/token-block doing `S_t = cd_mul(S,gamma) + cd_mul(v,conj(k))`, `out = scale*sum_k cd_mul(S,q)`. Ingest/recall are bilinear, so an elementwise expansion would blow up the graph; level is in op params, gamma `[n,hs_v,hs_k,H]`, state `[n*hs*hs*H]`. Level-1 `ggml_tardits_scan` untouched. - Level >= 2 graph now serves both families (RAT recurrent scan vs HyperFormer GyRoPE+attention); converter level >= 2 moved to `convert_hc.py` for both arch strings. - Parity (vs Python `RAT.step`): quaternion **1.587e-06 / 1.311e-06**, octonion **8.345e-07 / 8.941e-07**, sedenion **5.513e-07 / 5.215e-07** (single-step / prefill-44), greedy chains exact. `check_parity.sh` now runs **16 checks, 16/16 PASS**. **M4c - SmolLM2 BPE tokenizer** (`8703c4965`) - `--tokenizer-dir` writes a GPT-2-style BPE (`pre=smollm`), verified against HF on 95/95 encode + 95/95 detok + special probes; char GGUFs byte-identical. This is what the trained Colab checkpoint will use so llama.cpp speaks words instead of characters. Remaining follow-up (not blocking): a true CTest parity fixture that generates a tiny GGUF in the build tree - moving that to a fresh issue. Closing this one.
dsh closed this issue 2026-11-12 20:42:14 +00:00
Sign in to join this conversation.
No description provided.