Delon Swartz commited on
Commit
b6cab78
Β·
verified Β·
1 Parent(s): e68ea0d

Repopulate as fully-oscillatory KOLM-Alpha (KOLM-True data); hybrid moved to KOLM-Hybrid-1

Browse files
Files changed (1) hide show
  1. README.md +89 -84
README.md CHANGED
@@ -4,113 +4,117 @@ tags:
4
  - kuramoto
5
  - oscillator
6
  - language-model
 
7
  - tinystories
8
  library_name: pytorch
9
  ---
10
 
11
- # KOLM-Alpha β€” Kuramoto Oscillator Language Model
12
 
13
  *Delon Swartz β€” AI Researcher | Engineer*
14
 
15
- **KOLM-Alpha is, to our knowledge, the first language model whose per-token
16
- processing layers are networks of coupled Kuramoto oscillators, trained
17
- natively from scratch.** Each layer uses standard causal attention for
18
- routing between tokens and a **Kuramoto block** for processing: *H*
19
- oscillators, each a unit vector on a sphere, relax over *K* settling steps
20
- under trained pairwise couplings, conditioned on the attention output. The
21
- oscillator block replaces the Transformer's feed-forward network; attention
22
- is retained.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  ## The result
25
 
26
- Under a strictly controlled **twin protocol** β€” identical tokenizer, data,
27
- data order, context length, optimizer, schedule and seed, with *only* the
28
- feed-forward slot differing β€” KOLM-Alpha is compared against **TMT**
29
- (Transformer Model Twin), a standard attention + MLP model. Both were
30
- trained from scratch on 11.3M tokens of TinyStories on a single consumer
31
- laptop.
32
 
33
- ![Validation loss](assets/val_loss_curve.png)
34
-
35
- TMT leads early; KOLM-Alpha closes the gap steadily, crosses near 7M tokens,
36
- and finishes ahead β€” **with 3.5% fewer parameters.**
37
-
38
- ![Final scores](assets/final_scores.png)
39
-
40
- | Model | Parameters | Val loss | Perplexity |
41
  |---|---|---|---|
42
- | **KOLM-Alpha** | **16,916,224** | **2.6946** | **14.80** |
43
- | TMT (Transformer twin) | 17,538,816 | 2.7188 | 15.16 |
44
-
45
- Both models generate coherent TinyStories-grade prose. Prompt *"Once upon a
46
- time there was a little red shoe"*:
47
-
48
- > **KOLM-Alpha:** …The little boy would come home and play with his friends.
49
- > One day, the little girl was playing with the big castle in the sky…
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  ## Why it matters
52
 
53
- A Transformer computes with a fixed number of operations per token. A
54
- Kuramoto block computes by **iterative settling** β€” the oscillator field
55
- relaxes toward a configuration over *K* steps β€” which opens a second axis of
56
- scale that costs no additional memory, only settling time. KOLM-Alpha
57
- establishes the first point: at matched parameters, oscillatory processing
58
- is not merely competitive with a Transformer feed-forward network β€” it edges
59
- it out.
60
 
61
- ## Files
62
 
63
  | File | Purpose |
64
  |---|---|
65
- | `native_kolm.py` | model + twin trainer (`--arch kolm` / `--arch transformer`) |
66
- | `kuramoto_torch.py` | the Kuramoto block (parity-tested to 2.2e-16 vs a NumPy reference) |
67
- | `kolm.py`, `olm.py` | pure-NumPy reference core with hand-derived, gradient-checked backprop |
68
- | `sample_native.py` | generation from the trained weights |
69
- | `native_kolm.pt` | **KOLM-Alpha weights** (16.9M) |
70
- | `native_transformer.pt` | TMT weights (17.5M) |
71
- | `tiny8k.json` | tokenizer (required to run the model) |
72
- | `curve_kolm.csv`, `curve_transformer.csv` | validation-loss curves |
73
-
74
- ## Run it
75
-
76
- ```bash
77
- python3 -m venv --system-site-packages .venv
78
- .venv/bin/pip install torch tokenizers
79
-
80
- # generate from the released weights
81
- .venv/bin/python sample_native.py --prompt "Once upon a time"
82
-
83
- # verify the hand-derived gradients of the NumPy reference (no PyTorch needed)
84
- python3 kolm.py --gradcheck
85
- ```
86
-
87
- ## Reproduce the comparison
88
-
89
- ```bash
90
- .venv/bin/pip install transformers accelerate
91
- .venv/bin/python native_kolm.py --prep # build tokenizer + data
92
- .venv/bin/python native_kolm.py --arch kolm --steps 5500
93
- .venv/bin/python native_kolm.py --arch transformer --steps 5500
94
- ```
95
 
96
  ## Roadmap
97
 
98
- KOLM-Alpha is the first release. In progress:
99
-
100
- - **KOLM-Beta** β€” a larger model with frustrated coupling and a broader
101
- training corpus, grown from Alpha via function-preserving depth growth.
102
- - **KOLM-Chat** β€” an instruction-tuned conversational KOLM, exposing the
103
- settling depth as a user-facing "think-harder" control.
104
 
105
- ## Details
106
 
107
- - **Architecture:** 8 layers, d=384, 6 heads, context 256, 8k byte-level BPE.
108
- Feed-forward slot = Kuramoto block (H=320 oscillators on SΒ³, K=4 settling
109
- steps, 32 order-parameter readouts).
110
- - **Training:** AdamW, lr 1e-4 cosine, gradient clip 1.0, single seed.
111
- - **Hardware:** one Apple-silicon laptop (MPS), ~6 hours.
112
- - **Status:** research preview. The headline comparison is single-seed; a
113
- second seed is queued.
114
 
115
  ## License
116
 
@@ -119,4 +123,5 @@ Apache-2.0.
119
  ## Acknowledgements
120
 
121
  Builds on the Kuramoto-oscillator formulation of **AKOrN** (Miyato et al.,
122
- ICLR 2025) and the **TinyStories** corpus (Eldan & Li, 2023).
 
 
4
  - kuramoto
5
  - oscillator
6
  - language-model
7
+ - synchronization-routing
8
  - tinystories
9
  library_name: pytorch
10
  ---
11
 
12
+ # KOLM-Alpha β€” Fully-Oscillatory Kuramoto Language Model
13
 
14
  *Delon Swartz β€” AI Researcher | Engineer*
15
 
16
+ **KOLM-Alpha is, to our knowledge, the first language model with *no
17
+ transformer computation anywhere* β€” both routing between tokens and
18
+ processing within them are performed by networks of coupled Kuramoto
19
+ oscillators.** It is the successor to [KOLM-Hybrid-1](https://huggingface.co/Dbrent/KOLM-Hybrid-1),
20
+ which kept standard attention and made only the feed-forward slot
21
+ oscillatory. KOLM-Alpha replaces attention itself with **synchronization
22
+ routing**.
23
+
24
+ > **Naming note:** the name *KOLM-Alpha* previously labelled the hybrid twin
25
+ > study, now published as **KOLM-Hybrid-1**. Under the project naming
26
+ > registry (2026-07), *KOLM-Alpha* denotes this fully-oscillatory line
27
+ > (working name "KOLM-True").
28
+
29
+ ## The mechanism: KuramotoRouter A
30
+
31
+ Each layer's routing is a competitive synchronization process, not static
32
+ attention:
33
+
34
+ - **Softmax competition** over the causal past β€” sharp selection, not
35
+ blurry averaging.
36
+ - **RoPE on the routing scores** β€” position is *in* the routing, not just
37
+ the moved content.
38
+ - **Dynamic query modulation** β€” routing weights are *recomputed at every
39
+ settling step*, modulated by the evolving oscillator state. This is
40
+ genuinely dynamic routing that static attention cannot express.
41
+
42
+ The routed value drives each token's oscillators, which settle via Kuramoto
43
+ dynamics under trained couplings, natural rotations, and (optionally)
44
+ frustrated (phase-offset) coupling. Normalization is **SphereNorm**. Every
45
+ block is an exact identity at initialization.
46
 
47
  ## The result
48
 
49
+ Under the same controlled protocol as KOLM-Hybrid-1 (identical tokenizer,
50
+ data, order, budget, seed; 11.26M TinyStories tokens; single laptop):
 
 
 
 
51
 
52
+ | Model | Params | Val loss | Perplexity |
 
 
 
 
 
 
 
53
  |---|---|---|---|
54
+ | **KOLM-Alpha (Router A)** | 17.06M | **2.3170** | **10.14** |
55
+ | KOLM-Hybrid-1 (attention + osc-FFN) | 16.92M | 2.6946 | 14.80 |
56
+ | Transformer twin (TMT) | 17.54M | 2.7188 | 15.16 |
57
+
58
+ **KOLM-Alpha wins decisively β€” 0.38 nats below the hybrid, 0.40 below the
59
+ transformer twin** β€” while doing *zero* transformer computation. It crossed
60
+ the hybrid's final score at 5M tokens (41% through training).
61
+
62
+ An honest negative precedes this win: **Router v1** (sigmoid-gated,
63
+ position-blind, routing frozen across settle steps) *lost* at 3.0273. The
64
+ three diagnosed failures motivated Router A's softmax + RoPE + dynamic
65
+ modulation.
66
+
67
+ ## Scaling to 42M from scratch (the flagship)
68
+
69
+ **KOLM-Alpha-42M** ("W42") is the same architecture at 16 layers, d=384,
70
+ H=320, frustrated coupling, randomized settling depth *K ~ U[1,4]*, trained
71
+ from scratch on 188M tokens (32k vocabulary, TinyStories + Simple English
72
+ Wikipedia):
73
+
74
+ - **Val loss 1.7141 / perplexity 5.55** β€” from scratch, matching
75
+ function-preserving-transfer-warmed comparables (K-sweep K1 1.7162 /
76
+ K2 1.6848 / K4 1.7044).
77
+ - **Chat**, via staged SFT: broad chat mixture β†’ single-turn discipline
78
+ (Alpaca). The staged order beats Alpaca-from-base by 0.35 nats
79
+ (alpaca-val 3.19 vs 3.55). Turn discipline is clean (answers once, stops
80
+ at `<|end|>`); simple facts land ("The capital of France is Paris").
81
+ Entity binding and counting remain beyond 42M β€” capacity limits, not
82
+ recipe bugs.
83
 
84
  ## Why it matters
85
 
86
+ The hybrid showed oscillators can *process* as well as an MLP. KOLM-Alpha
87
+ shows they can *route* better than attention β€” the whole layer is now
88
+ synchronization dynamics, with a settling-depth **compute dial** that adds a
89
+ memory-free axis of scale. Randomized-depth training makes that dial
90
+ extrapolate past its trained depth.
 
 
91
 
92
+ ## Files (weights to follow)
93
 
94
  | File | Purpose |
95
  |---|---|
96
+ | `kolm_true.py` | full-oscillator model + trainer (Router A) |
97
+ | `kuramoto_torch.py` | Kuramoto block (parity-tested to 2.2e-16 vs NumPy) |
98
+ | `chat_true.py` | REPL / sampler with the `/think K` settling dial |
99
+ | `native_true_A.pt` | **KOLM-Alpha 17M weights** (Router A) |
100
+ | `native_w42.pt` | **KOLM-Alpha-42M** pretrain weights |
101
+ | `native_w42chat_alp.pt` | 42M chat model (staged SFT) |
102
+ | `tiny32k.json` | 32k tokenizer |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  ## Roadmap
105
 
106
+ - **KOLM-Beta-T** ([repo](https://huggingface.co/Dbrent/KOLM-Beta-T)) β€”
107
+ transplanting pretrained transformer weights into this architecture to
108
+ reach billion-parameter capability without pretraining.
109
+ - Larger from-scratch KOLM-Alpha rungs exposing the settling dial as a
110
+ user-facing "think-harder" control.
 
111
 
112
+ ## Status & limitations
113
 
114
+ Research preview. Headline comparisons are single-seed; the 17M Router-A run
115
+ used a settling/lr protocol that differs slightly from the twin runs (a
116
+ matched rerun is queued before external citation). Corpora are easy and all
117
+ budgets are far below Chinchilla-optimal; factual recall at 42M is limited.
 
 
 
118
 
119
  ## License
120
 
 
123
  ## Acknowledgements
124
 
125
  Builds on the Kuramoto-oscillator formulation of **AKOrN** (Miyato et al.,
126
+ ICLR 2025), the frustrated-synchronization principle of **FSN**
127
+ (arXiv:2606.18694), and the **TinyStories** corpus (Eldan & Li, 2023).