llm_moe: the union operator (route/max-merge) vs fusion — and the regime flips at scale
Adds the union-preserving recombination operator that llm_merge lacked (E8's max,
not mean): keep each specialist LoRA intact and SELECT the right one per prompt
(MoE router: oracle, or training-free nearest-centroid over base embeddings) or
per module (max_merge = winner-take-all by delta norm). src/llm/moe.py, kind
llm_moe, reuses the cached specialists.
Result — a clean regime boundary for "merge, don't average":
- 0.5B: union wins. Routing 0.74 / worst-family 0.43 > soup 0.64 / 0.26, with no
dilution (recovers each specialist's own-family peak). E8's max > mean in real
weights, because at a weak base averaging dilutes.
- 7B (Imperial CX3, L40S, 9 min): the ordering INVERTS. Fusion wins — soup 0.87 >
routing 0.84 > max_merge 0.78. Routing is capped at the best parent per family;
fusion blends and, given a capable base, COMPOSES beyond any parent (soup lists
0.62 > spec 0.57). Selection can't synthesise better than its best component;
averaging-that-composes can.
So "merge, don't average" (E4/E8) is a weak-parent / small-model law, not
universal: union wins under dilution, fusion wins under composition. Refines E8
(its additive-landscape max>mean assumed no compositional headroom). The operator
to want is fusion-that-composes + offspring selection = the directed-sex ideal
(E10) — the natural next experiment.
Honest riders: the learned router is trivially perfect (lexically-distinct
families), and router-free max_merge is the weakest union (not input-adaptive).
+2 router unit tests (127 green). Results in results/llm_moe{,_hpc}/ (parquet
gitignored per the reproducibility contract).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
585264d0b4
commit
8da0dac007
18 changed files with 647 additions and 6 deletions
58
results/llm_moe/README.md
Normal file
58
results/llm_moe/README.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# llm_moe — union-preserving recombination (route / max-merge) vs fusion (the real-weight E8 *max*)
|
||||
|
||||
**Claim tested.** E8 (analytic) found that the recombination *operator* matters: a **union** over
|
||||
parents (`max`) assembles a child fitter than any parent, while an **average** (`mean`, the model
|
||||
soup) conserves collapse. `llm_merge` showed fusion (soup/ties, which *average* the LoRA deltas). This
|
||||
experiment adds the **union** operator to real LLM weights — never average the parents, keep each
|
||||
specialist intact and **select** the right one per input (a Mixture-of-Experts *router*) or per module
|
||||
(winner-take-all) — and asks whether union beats fusion, and *where*.
|
||||
|
||||
**Setup.** Base **Qwen2.5-0.5B-Instruct**, reusing the three cached LoRA specialists from `llm_merge`
|
||||
(disjoint families `lists`/`strings`/`arith`, exact-match verifier), 100 test tasks/family, seed 1.
|
||||
Five recombination operators on the same test set:
|
||||
- **Fusion** (blend the deltas): `soup` = mean(Δₖ); `ties` = sign-reconciled union.
|
||||
- **Union** (never average): `route:oracle`/`route:learned` keep all adapters live and route each
|
||||
prompt to one specialist (MoE); `max-merge` builds one adapter taking, per module, the specialist
|
||||
with the largest-norm delta. The learned router is training-free — nearest-centroid over the *base*
|
||||
model's own prompt embeddings; its routing accuracy is reported.
|
||||
|
||||
### Results (accuracy)
|
||||
| operator | lists | strings | arith | overall | worst-family | router |
|
||||
|---|---|---|---|---|---|---|
|
||||
| base | 0.15 | 0.15 | 0.53 | 0.28 | 0.15 | — |
|
||||
| best specialist (strings) | 0.08 | 1.00 | 0.80 | 0.63 | 0.08 | — |
|
||||
| fuse: soup | 0.26 | 0.74 | 0.91 | 0.64 | 0.26 | — |
|
||||
| fuse: ties | 0.23 | 0.71 | 0.90 | 0.61 | 0.23 | — |
|
||||
| **route: oracle** | 0.43 | 1.00 | 0.78 | **0.74** | **0.43** | 1.00 |
|
||||
| **route: learned** | 0.43 | 1.00 | 0.78 | **0.74** | **0.43** | **1.00** |
|
||||
| max-merge | 0.18 | 0.34 | 0.87 | 0.46 | 0.18 | — |
|
||||
|
||||
### What holds
|
||||
- **Union (routing) beats fusion at a weak base — decisively.** Routing reaches **0.74 overall /
|
||||
0.43 worst-family**, above both fusion merges (soup 0.64/0.26) and every specialist. It recovers
|
||||
*each* specialist's own-family peak exactly (lists 0.43, strings 1.00, arith 0.78) because it *is*
|
||||
that specialist there — **no dilution**. This is E8's `max` (union) beating `mean` (average) in real
|
||||
LLM weights: exactly where fusion diluted the lists-specialist (0.43→0.26), routing keeps 0.43.
|
||||
- **The learned router is perfect here (1.00) — stated as a caveat, not a triumph.** The three families
|
||||
are lexically distinct, so nearest-centroid routing over base embeddings is trivially easy;
|
||||
`route:learned` equals `route:oracle`. Routing's advantage on *these* tasks therefore rests partly on
|
||||
the routing problem being easy — the honest scope. On overlapping/ambiguous skills the router would
|
||||
be the bottleneck, and that is the interesting failure mode to probe next.
|
||||
- **Static per-module `max-merge` is a poor union (0.46) — an informative negative.** Picking, per
|
||||
module, the largest-norm specialist delta is *not* input-adaptive: it collapses toward whichever
|
||||
specialist dominates the weight norms (arith 0.87, but lists 0.18, strings 0.34). The union benefit
|
||||
needs **routing** (input-adaptive selection), not weight-space surgery — "keep the parents whole"
|
||||
only pays off if you also *choose* the right parent per input.
|
||||
|
||||
### Takeaway
|
||||
Adds the union half of E8's operator dichotomy to real LLM weights and confirms its sign at a weak
|
||||
base: **route-don't-average > average**, with no dilution, mirroring the analytic `max > mean`. Two
|
||||
honest riders — the learned router is trivially good because the families are lexically separable, and
|
||||
the router-free `max-merge` union fails because it isn't input-adaptive. The regime question the 0.5B
|
||||
result raises — *does routing still help once a capable base lets fusion **compose** rather than
|
||||
dilute?* (`llm_merge_hpc` showed 7B soup already beats its specialists with no dilution) — is answered
|
||||
by **`results/llm_moe_hpc/`: the ordering flips.** At 7B fusion wins (soup 0.87 > routing 0.84),
|
||||
because routing is capped at the best parent while fusion composes beyond it. So "merge, don't average"
|
||||
is a **weak-base law**: union wins here (0.5B, dilution regime), fusion wins there (7B, composition
|
||||
regime). **Falsifier (not triggered at 0.5B):** fusion matching the routing ceiling, i.e. averaging
|
||||
never diluting.
|
||||
BIN
results/llm_moe/llm_moe.pdf
Normal file
BIN
results/llm_moe/llm_moe.pdf
Normal file
Binary file not shown.
BIN
results/llm_moe/llm_moe.png
Normal file
BIN
results/llm_moe/llm_moe.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
52
results/llm_moe_hpc/README.md
Normal file
52
results/llm_moe_hpc/README.md
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# llm_moe_hpc — union vs fusion recombination at scale (7B, Imperial CX3): the regime *flips*
|
||||
|
||||
**Claim tested.** The 0.5B `llm_moe` found that a **union** operator (route/select, never average) beats
|
||||
**fusion** (soup/ties, average the deltas), because at a weak base averaging *dilutes*. But
|
||||
`llm_merge_hpc` showed that at 7B fusion stops diluting and starts *composing* (soup 0.87 beat every
|
||||
specialist). So the sharp question: **does routing still beat fusion once the base is capable — or does
|
||||
a strong base invert the ordering?** Run on one **L40S (46 GB)** GPU of Imperial's CX3 HPC, 9 min
|
||||
walltime, reusing the cached 7B specialists.
|
||||
|
||||
**Setup.** Base **Qwen2.5-7B-Instruct**, the three cached LoRA specialists from `llm_merge_hpc`
|
||||
(`lists`/`strings`/`arith`, exact-match verifier), 200 test tasks/family, seed 1. Same five operators
|
||||
as the 0.5B run: fusion (`soup`, `ties`) vs union (`route:oracle`, `route:learned`, `max-merge`).
|
||||
|
||||
### Results (accuracy)
|
||||
| operator | lists | strings | arith | overall | worst-family | router |
|
||||
|---|---|---|---|---|---|---|
|
||||
| base | 0.46 | 0.69 | 1.00 | 0.71 | 0.46 | — |
|
||||
| best specialist (lists) | 0.57 | 0.74 | 1.00 | 0.77 | 0.57 | — |
|
||||
| **fuse: soup** | **0.62** | **1.00** | 1.00 | **0.87** | **0.62** | — |
|
||||
| fuse: ties | 0.62 | 1.00 | 0.99 | 0.87 | 0.62 | — |
|
||||
| route: oracle | 0.57 | 0.97 | 0.96 | 0.84 | 0.57 | 1.00 |
|
||||
| route: learned | 0.57 | 0.97 | 0.96 | 0.84 | 0.57 | 1.00 |
|
||||
| max-merge | 0.48 | 0.90 | 0.96 | 0.78 | 0.48 | — |
|
||||
|
||||
### The finding: "merge, don't average" is regime-dependent, and inverts at scale
|
||||
- **The ordering flips.** At 0.5B, union > fusion (routing 0.74 > soup 0.64). At 7B, **fusion > union**
|
||||
(soup **0.87** > routing 0.84 > max-merge 0.78). The exact opposite winner.
|
||||
- **Why: routing is capped at the best parent; fusion can *exceed* it.** Routing *selects* one intact
|
||||
specialist, so per family it can only reach that specialist's own score (lists 0.57 = spec_lists,
|
||||
strings 0.97 = spec_strings). Fusion *blends* the deltas — and at a capable base the blend
|
||||
**composes beyond any parent**: soup scores lists 0.62 (> spec_lists 0.57) and strings 1.00
|
||||
(> spec_strings 0.97). Selection cannot synthesise something better than its best component;
|
||||
averaging, when it composes rather than dilutes, can. So fusion's worst-family (0.62) also beats
|
||||
routing's (0.57).
|
||||
- **The regime boundary is dilution.** Union wins exactly when averaging *dilutes* (weak base, 0.5B);
|
||||
fusion wins once the base has enough headroom that averaging *composes* (7B). "Merge, don't average"
|
||||
(E4/E8) is therefore a **small-model / weak-parent** law, not a universal one — a genuine refinement
|
||||
of the analytic claim, not a contradiction of it (E8's additive-landscape `max > mean` assumed no
|
||||
such compositional headroom).
|
||||
- **Riders unchanged.** The learned router is still perfect (1.00, lexically-distinct families), and
|
||||
`max-merge` remains the weakest union (0.78) — static per-module winner-take-all is not
|
||||
input-adaptive.
|
||||
|
||||
### Takeaway
|
||||
A clean, honest regime result: **route-don't-average wins at a weak base; average-that-composes wins at
|
||||
a strong one.** Pure selection (routing) never dilutes but is bounded by the best parent; fusion risks
|
||||
dilution but, given a capable base, transcends the parents — which is what the Fisher–Muller "exceed
|
||||
every parent" claim actually needs at scale. The operator to want is therefore *fusion that composes
|
||||
plus selection over candidates* — the "directed sex" ideal (offspring selection over recombinants),
|
||||
the natural next experiment. **Falsifier for this run (not triggered):** routing beating fusion at 7B,
|
||||
i.e. dilution persisting at scale — instead it inverted. Provenance in `manifest.json` (L40S, torch
|
||||
2.12.1 / transformers 5.13.0 / peft 0.19.1; `git_commit: null` — produced on an rsync'd node copy).
|
||||
BIN
results/llm_moe_hpc/llm_moe.pdf
Normal file
BIN
results/llm_moe_hpc/llm_moe.pdf
Normal file
Binary file not shown.
BIN
results/llm_moe_hpc/llm_moe.png
Normal file
BIN
results/llm_moe_hpc/llm_moe.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 131 KiB |
27
results/llm_moe_hpc/manifest.json
Normal file
27
results/llm_moe_hpc/manifest.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"experiment": "llm_moe_hpc",
|
||||
"master_seed": 1,
|
||||
"git_commit": null,
|
||||
"python": "3.11.13",
|
||||
"libraries": {
|
||||
"numpy": "2.4.6",
|
||||
"scipy": "1.17.1",
|
||||
"pandas": "3.0.3",
|
||||
"pyarrow": "24.0.0",
|
||||
"torch": "2.12.1",
|
||||
"transformers": "5.13.0",
|
||||
"peft": "0.19.1"
|
||||
},
|
||||
"rows": 47,
|
||||
"results_sha256": "bd91413c4cf174980c222dca5f435cb6957dee775d2f27bfb7a30dedc0f36c9f",
|
||||
"layer": "2",
|
||||
"tier": "llm",
|
||||
"base_model": "Qwen/Qwen2.5-7B-Instruct",
|
||||
"operators": [
|
||||
"soup",
|
||||
"ties",
|
||||
"moe_oracle",
|
||||
"moe_learned",
|
||||
"max_merge"
|
||||
]
|
||||
}
|
||||
28
results/llm_moe_hpc/resolved_config.yaml
Normal file
28
results/llm_moe_hpc/resolved_config.yaml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
experiment: llm_moe_hpc
|
||||
seed: 1
|
||||
n_replicates: 1
|
||||
source_config:
|
||||
experiment: llm_moe_hpc
|
||||
kind: llm_moe
|
||||
seed: 1
|
||||
n_replicates: 1
|
||||
base_model: Qwen/Qwen2.5-7B-Instruct
|
||||
families:
|
||||
- lists
|
||||
- strings
|
||||
- arith
|
||||
n_train: 800
|
||||
n_test: 200
|
||||
n_route: 48
|
||||
epochs: 3
|
||||
lora:
|
||||
r: 16
|
||||
alpha: 32
|
||||
operators:
|
||||
- soup
|
||||
- ties
|
||||
- moe_oracle
|
||||
- moe_learned
|
||||
- max_merge
|
||||
output:
|
||||
dir: results/llm_moe_hpc
|
||||
Loading…
Add table
Add a link
Reference in a new issue