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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Mission presets β the Mini-Beatrix ladder.
|
| 2 |
+
|
| 3 |
+
Naming convention (voyager style): numbered missions, each a fixed craft.
|
| 4 |
+
Small crafts are "mini-beatrix-N"; the BPE flagship is "beatrix-voyager".
|
| 5 |
+
Beatrix is the lineage collective name; missions are launched in order and
|
| 6 |
+
all upload to the one training repo (TRAINING_REPO), each craft under its
|
| 7 |
+
own path prefix (checkpoints + manifest + tensorboard).
|
| 8 |
+
|
| 9 |
+
mini-beatrix-0 d512 L12 ctx1024 byte-trigram 37.6M gate craft:
|
| 10 |
+
its first toggle evals ARE the anchored-bank-under-AR
|
| 11 |
+
screen (P1) running live.
|
| 12 |
+
mini-beatrix-1 d768 L16 ctx2048 byte-trigram 112.5M first Colab
|
| 13 |
+
mission (default).
|
| 14 |
+
mini-beatrix-2 d1024 L32 ctx8192 byte-trigram ~873.7M FULL SPLAT:
|
| 15 |
+
a governed multi-constellation hub in EVERY block
|
| 16 |
+
(2026-08-26 rescale; the v1 249M 3-hub shape retired
|
| 17 |
+
untrained β plan 2026-08-26_mini_beatrix_v2_shape.md).
|
| 18 |
+
mini-beatrix-2s d1024 L20 ctx4096 byte-trigram ~233M the lawful
|
| 19 |
+
screen craft: every v2 gating cell runs here first.
|
| 20 |
+
beatrix-voyager d1536 L24 ctx4096 BPE(gpt2 50k) 775.3M flagship;
|
| 21 |
+
vocab-scale head + BPE screens (P2/P5) still open β
|
| 22 |
+
launch only after mini-beatrix verdicts.
|
| 23 |
+
|
| 24 |
+
Every craft is inference-capable on consumer hardware in its shipped
|
| 25 |
+
form (fp8-e4m3 safetensors variants are exported alongside checkpoints).
|
| 26 |
+
"""
|
| 27 |
+
from __future__ import annotations
|
| 28 |
+
|
| 29 |
+
from dataclasses import dataclass, field, asdict
|
| 30 |
+
from typing import Optional
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@dataclass
|
| 34 |
+
class AlephLMConfig:
|
| 35 |
+
name: str = "mini-beatrix-0"
|
| 36 |
+
d_model: int = 512
|
| 37 |
+
n_layers: int = 12
|
| 38 |
+
n_heads: int = 8
|
| 39 |
+
context: int = 1024
|
| 40 |
+
vocab_size: int = 256 # bytes; BPE presets override
|
| 41 |
+
tokenizer: str = "byte-trigram" # "byte-trigram" | "hf:<repo or name>"
|
| 42 |
+
hub_layers: tuple = (3, 7, 11) # CausalSplatHUB depths; () = pure sdpa control
|
| 43 |
+
hub_K: int = 512
|
| 44 |
+
hub_D: int = 32
|
| 45 |
+
tau: float = 0.1
|
| 46 |
+
bank_experts: int = 3 # E1-validated fat-expert count
|
| 47 |
+
bank_ff: Optional[int] = None # None -> d_model (E1 ratio)
|
| 48 |
+
head_K: int = 512
|
| 49 |
+
head_D: int = 32
|
| 50 |
+
gate_init: float = -3.0
|
| 51 |
+
tie_embeddings: bool = False # BPE crafts tie; byte crafts cannot (trigram)
|
| 52 |
+
hub_chunk: int = 128 # chunked-scan block for the hub prefix memories
|
| 53 |
+
# v2 (2026-08-26): multi-constellation hubs β the product-code form at
|
| 54 |
+
# lawful supply (K <= 2*hub_D per book; ROUND 5e). 1 = the v1 layout,
|
| 55 |
+
# bit-identical state dict. Old manifests load via the default.
|
| 56 |
+
hub_const: int = 1
|
| 57 |
+
# Activation checkpointing (training only; inference/decode untouched).
|
| 58 |
+
# 0 = off (v1 verbatim). 1 = recompute the hub read in backward.
|
| 59 |
+
# 2 = also recompute the bank branch. At v2 scale (16 books x ctx 8192
|
| 60 |
+
# x 32 layers) the retained scan tensors alone exceed a 95GB card β
|
| 61 |
+
# measured OOM, Blackwell preflight 2026-08-26. ~2x hub recompute cost.
|
| 62 |
+
hub_ckpt: int = 0
|
| 63 |
+
|
| 64 |
+
def to_dict(self):
|
| 65 |
+
d = asdict(self)
|
| 66 |
+
d["hub_layers"] = list(self.hub_layers)
|
| 67 |
+
return d
|
| 68 |
+
|
| 69 |
+
@staticmethod
|
| 70 |
+
def from_dict(d):
|
| 71 |
+
d = dict(d)
|
| 72 |
+
d["hub_layers"] = tuple(d.get("hub_layers", ()))
|
| 73 |
+
return AlephLMConfig(**d)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@dataclass
|
| 77 |
+
class TrainConfig:
|
| 78 |
+
# Optimizer split (measured: momentum-geometric +.09 on the aleph;
|
| 79 |
+
# the mechanism is ~20x more optimizer-sensitive than sdpa).
|
| 80 |
+
muon_lr: float = 2e-2
|
| 81 |
+
muon_momentum: float = 0.95
|
| 82 |
+
adam_lr: float = 3e-4 # pure Adam, wd=0 β never AdamW
|
| 83 |
+
warmup_steps: int = 200 # scale insurance; flat after (flat-LR law)
|
| 84 |
+
grad_clip: float = 1.0
|
| 85 |
+
micro_batch: int = 24
|
| 86 |
+
grad_accum: int = 1
|
| 87 |
+
# Cadences (steps)
|
| 88 |
+
log_every: int = 50
|
| 89 |
+
health_every: int = 500
|
| 90 |
+
eval_every: int = 2000
|
| 91 |
+
ckpt_every: int = 2000 # safetensors + resume .pt
|
| 92 |
+
fp8_every_ckpts: int = 5 # every Nth checkpoint also exports fp8
|
| 93 |
+
tb_upload_every: int = 1000
|
| 94 |
+
# Eval sizes
|
| 95 |
+
val_tokens: int = 262144
|
| 96 |
+
canary_episodes: int = 128
|
| 97 |
+
seed: int = 1337
|
| 98 |
+
compile: bool = False
|
| 99 |
+
# The anchor governor (ROUND 5f, 2026-08-25): post-optimizer-step
|
| 100 |
+
# min-separation projection over hub/head codebooks β preventive
|
| 101 |
+
# anti-crowding, identity when slack, zero parameters, outside the
|
| 102 |
+
# task gradient (the no-balance-machinery law is untouched).
|
| 103 |
+
governor: str = "" # "" off (v1 verbatim) | "minsep"
|
| 104 |
+
governor_theta: float = 45.0 # deg; scale ~ gamma*(D): 45 at D=256
|
| 105 |
+
governor_every: int = 8 # steps between slack checks (~free)
|
| 106 |
+
# Post-revival address freeze (0.8.2; RIDERS 11-12): after the
|
| 107 |
+
# BOUNDARY-WRITE head revival, proj + head codebook freeze so the
|
| 108 |
+
# self-burial channel (proj rotating to codebook-orthogonality,
|
| 109 |
+
# measured 2/2 crafts) is structurally closed β only W_s trains.
|
| 110 |
+
# requires_grad-only: optimizer param groups are UNCHANGED, so resume
|
| 111 |
+
# state loads verbatim (Muon skips grad-less params).
|
| 112 |
+
head_addr_frozen: bool = False
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
# All missions upload to the one training repo, each under its own prefix
|
| 116 |
+
# (Phil's repo: checkpoints + manifests + tensorboard for every craft).
|
| 117 |
+
TRAINING_REPO = "AbstractPhil/alephllm-mini-beatrix-training"
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
@dataclass
|
| 121 |
+
class Preset:
|
| 122 |
+
model: AlephLMConfig
|
| 123 |
+
train: TrainConfig
|
| 124 |
+
hf_repo: str = TRAINING_REPO # run repo (ckpts+manifest+tb)
|
| 125 |
+
curriculum: list = field(default_factory=list) # [(phase, dataset, planned_tokens)]
|
| 126 |
+
|
| 127 |
+
@property
|
| 128 |
+
def prefix(self) -> str: # path prefix inside hf_repo
|
| 129 |
+
return self.model.name
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def _curriculum(warm: int, main: int, ext: int):
|
| 133 |
+
return [
|
| 134 |
+
dict(name="warmup_wikitext", dataset="wikitext-103", planned_tokens=warm,
|
| 135 |
+
status="planned"),
|
| 136 |
+
dict(name="fineweb_main", dataset="fineweb-edu", planned_tokens=main,
|
| 137 |
+
status="planned"),
|
| 138 |
+
# Deliberately not prepped beyond a name β the full plan exists in the
|
| 139 |
+
# manifest, the data work happens when the phase activates.
|
| 140 |
+
dict(name="fineweb_extended", dataset="fineweb-edu", planned_tokens=ext,
|
| 141 |
+
status="deferred"),
|
| 142 |
+
# phase C: distribution shift toward chat format / simple register /
|
| 143 |
+
# narrative (incl. moral texture) / binding demand β see streams.ANNEAL_MIX
|
| 144 |
+
dict(name="anneal_mix", dataset="anneal-mix",
|
| 145 |
+
planned_tokens=2_000_000_000, status="deferred"),
|
| 146 |
+
]
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
PRESETS: dict[str, Preset] = {
|
| 150 |
+
"mini-beatrix-0": Preset(
|
| 151 |
+
model=AlephLMConfig(name="mini-beatrix-0"),
|
| 152 |
+
train=TrainConfig(micro_batch=96, grad_accum=1),
|
| 153 |
+
curriculum=_curriculum(150_000_000, 1_000_000_000, 2_000_000_000),
|
| 154 |
+
),
|
| 155 |
+
"mini-beatrix-1": Preset(
|
| 156 |
+
model=AlephLMConfig(name="mini-beatrix-1", d_model=768, n_layers=16,
|
| 157 |
+
n_heads=12, context=2048, hub_layers=(4, 9, 14)),
|
| 158 |
+
train=TrainConfig(micro_batch=48, grad_accum=3),
|
| 159 |
+
curriculum=_curriculum(300_000_000, 3_000_000_000, 6_000_000_000),
|
| 160 |
+
),
|
| 161 |
+
# v2 (2026-08-26, Phil's draft off the Foundry console): FULL-SPLAT β
|
| 162 |
+
# a hub in every block, multi-constellation product code at lawful
|
| 163 |
+
# supply (16 books x 256 anchors in 256-dim spaces = 1.0x supply;
|
| 164 |
+
# v1's single book ran 16x and crowded), governed from birth, ctx 8192
|
| 165 |
+
# where the O(L) read is ~4.5x cheaper than the MHA equivalent.
|
| 166 |
+
# ~873.7M params. Plan: history/plans/2026-08-26_mini_beatrix_v2_shape.md.
|
| 167 |
+
"mini-beatrix-2": Preset(
|
| 168 |
+
model=AlephLMConfig(name="mini-beatrix-2", d_model=1024, n_layers=32,
|
| 169 |
+
n_heads=16, context=8192,
|
| 170 |
+
hub_layers=tuple(range(32)),
|
| 171 |
+
hub_K=256, hub_D=256, hub_const=16,
|
| 172 |
+
bank_experts=6, bank_ff=1024,
|
| 173 |
+
# chunk 1024 MEASURED on the mission card (C2e,
|
| 174 |
+
# Blackwell 2026-08-26): 72.2 vs 83.2 ms/layer
|
| 175 |
+
# fwd+bwd at chunk 256, peak 39.4 -> 26.6 GB.
|
| 176 |
+
# S/P traffic ~ 1/C, att work ~ C; config-only,
|
| 177 |
+
# checkpoint-compatible, exactness C-independent.
|
| 178 |
+
head_K=256, head_D=256, hub_chunk=1024,
|
| 179 |
+
hub_ckpt=2),
|
| 180 |
+
train=TrainConfig(micro_batch=4, grad_accum=16,
|
| 181 |
+
governor="minsep", governor_theta=45.0),
|
| 182 |
+
curriculum=_curriculum(500_000_000, 8_000_000_000, 16_000_000_000),
|
| 183 |
+
),
|
| 184 |
+
# THE ACTIVE MISSION (2026-08-26, Phil: "train the next stage up from
|
| 185 |
+
# the beatrix v1; we can't train the large one currently"): the lawful
|
| 186 |
+
# full-splat craft one rung above v1 β d1024 L20 ctx4096, governed
|
| 187 |
+
# 4x64@128 books (4x supply headroom vs v1's crowded 16x). Also the
|
| 188 |
+
# screen bed for every v2-era gating cell. hub_ckpt=0: at 237M the
|
| 189 |
+
# retained scan fits the 96GB card, so the recompute tax is pure waste
|
| 190 |
+
# (fallback: set hub_ckpt=2 if the preflight bench gate aborts >88GB).
|
| 191 |
+
"mini-beatrix-2s": Preset(
|
| 192 |
+
model=AlephLMConfig(name="mini-beatrix-2s", d_model=1024, n_layers=20,
|
| 193 |
+
n_heads=16, context=4096,
|
| 194 |
+
hub_layers=tuple(range(20)),
|
| 195 |
+
hub_K=64, hub_D=128, hub_const=4,
|
| 196 |
+
bank_experts=3, bank_ff=1024,
|
| 197 |
+
head_K=256, head_D=256, hub_chunk=256,
|
| 198 |
+
hub_ckpt=0),
|
| 199 |
+
train=TrainConfig(micro_batch=16, grad_accum=4,
|
| 200 |
+
governor="minsep", governor_theta=45.0,
|
| 201 |
+
head_addr_frozen=True),
|
| 202 |
+
curriculum=_curriculum(300_000_000, 5_000_000_000, 10_000_000_000),
|
| 203 |
+
),
|
| 204 |
+
"beatrix-voyager": Preset(
|
| 205 |
+
model=AlephLMConfig(name="beatrix-voyager", d_model=1536, n_layers=24,
|
| 206 |
+
n_heads=16, context=4096, vocab_size=50257,
|
| 207 |
+
tokenizer="hf:gpt2", tie_embeddings=True,
|
| 208 |
+
hub_layers=(6, 13, 20)),
|
| 209 |
+
train=TrainConfig(micro_batch=8, grad_accum=16),
|
| 210 |
+
curriculum=_curriculum(500_000_000, 12_000_000_000, 24_000_000_000),
|
| 211 |
+
),
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
# Pure-sdpa control crafts (hub layers removed) β the running architecture
|
| 215 |
+
# control for any mission: same params otherwise, suffix "-control".
|
| 216 |
+
for _name in list(PRESETS):
|
| 217 |
+
_p = PRESETS[_name]
|
| 218 |
+
_m = AlephLMConfig.from_dict(_p.model.to_dict())
|
| 219 |
+
_m.name = _name + "-control"
|
| 220 |
+
_m.hub_layers = ()
|
| 221 |
+
PRESETS[_name + "-control"] = Preset(
|
| 222 |
+
model=_m, train=_p.train,
|
| 223 |
+
curriculum=[dict(x) for x in _p.curriculum])
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
def get_preset(name: str) -> Preset:
|
| 227 |
+
if name not in PRESETS:
|
| 228 |
+
raise KeyError(f"unknown preset '{name}' β have: {sorted(PRESETS)}")
|
| 229 |
+
return PRESETS[name]
|