mirror alephllm 0.8.9 (same-session law): presets.py (v3 preset builder + registrations guarded for copies without the data stack; TrainConfig.phase_lr_scale/phase_seed_offset; Preset.data_scale/epoch_cap/rebalance_to), governor.py (raw_block: nested wrappers), alephlm.py (compile_hubs via raw_block). Gated: strict load of model.safetensors through the vendored path, logits parity 0.0 vs geolip.
Browse files- governor.py +10 -2
governor.py
CHANGED
|
@@ -80,6 +80,14 @@ def minsep_project_(codebook: torch.nn.Parameter, theta_min_deg: float,
|
|
| 80 |
return hits
|
| 81 |
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
def _hub_addresses(attn):
|
| 84 |
"""Every AlephAddress a hub carries (single- or multi-constellation)."""
|
| 85 |
if hasattr(attn, "consts"):
|
|
@@ -103,7 +111,7 @@ def govern_model(model, theta_min_deg: float,
|
|
| 103 |
books: list[torch.nn.Parameter] = []
|
| 104 |
if "hub" in include:
|
| 105 |
for wrap in getattr(model, "blocks", []):
|
| 106 |
-
blk =
|
| 107 |
if getattr(blk, "is_hub", False):
|
| 108 |
books += [a.codebook for a in _hub_addresses(blk.attn)]
|
| 109 |
if "head" in include and hasattr(model, "head"):
|
|
@@ -112,7 +120,7 @@ def govern_model(model, theta_min_deg: float,
|
|
| 112 |
books.append(addr.codebook)
|
| 113 |
if "bank" in include:
|
| 114 |
for wrap in getattr(model, "blocks", []):
|
| 115 |
-
blk =
|
| 116 |
addr = getattr(getattr(blk, "bank", None), "addr", None)
|
| 117 |
if isinstance(addr, AlephAddress):
|
| 118 |
books.append(addr.codebook)
|
|
|
|
| 80 |
return hits
|
| 81 |
|
| 82 |
|
| 83 |
+
def raw_block(wrap):
|
| 84 |
+
"""The model's own Block under any depth of adapter wrappers (amoe
|
| 85 |
+
BlockWithAdapter nests one wrapper per attached arm: .block.block...)."""
|
| 86 |
+
while hasattr(wrap, "block"):
|
| 87 |
+
wrap = wrap.block
|
| 88 |
+
return wrap
|
| 89 |
+
|
| 90 |
+
|
| 91 |
def _hub_addresses(attn):
|
| 92 |
"""Every AlephAddress a hub carries (single- or multi-constellation)."""
|
| 93 |
if hasattr(attn, "consts"):
|
|
|
|
| 111 |
books: list[torch.nn.Parameter] = []
|
| 112 |
if "hub" in include:
|
| 113 |
for wrap in getattr(model, "blocks", []):
|
| 114 |
+
blk = raw_block(wrap)
|
| 115 |
if getattr(blk, "is_hub", False):
|
| 116 |
books += [a.codebook for a in _hub_addresses(blk.attn)]
|
| 117 |
if "head" in include and hasattr(model, "head"):
|
|
|
|
| 120 |
books.append(addr.codebook)
|
| 121 |
if "bank" in include:
|
| 122 |
for wrap in getattr(model, "blocks", []):
|
| 123 |
+
blk = raw_block(wrap)
|
| 124 |
addr = getattr(getattr(blk, "bank", None), "addr", None)
|
| 125 |
if isinstance(addr, AlephAddress):
|
| 126 |
books.append(addr.codebook)
|