initium-deeplearning 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- initium/LNN_controller/cfc_backbone_parallel.py +265 -0
- initium/LNN_controller/cfc_controller.py +325 -0
- initium/LNN_controller/chained_controller.py +83 -0
- initium/LNN_controller/hybrid_controller.py +90 -0
- initium/MoE/README.md +1 -0
- initium/MoE/moe_layer.py +552 -0
- initium/__init__.py +1 -0
- initium/config/controller_config.py +86 -0
- initium/config/train_config.py +64 -0
- initium/core_training.py +2182 -0
- initium/data/__init__.py +0 -0
- initium/data/audio/__init__.py +0 -0
- initium/data/audio/audio_dataset.py +96 -0
- initium/data/base_dataset.py +75 -0
- initium/data/common/__init__.py +0 -0
- initium/data/common/chain_task.py +542 -0
- initium/data/common/digit_codec.py +85 -0
- initium/data/common/graph_io.py +123 -0
- initium/data/common/real_data.py +747 -0
- initium/data/dataset_registry.py +59 -0
- initium/data/graph_traversal/__init__.py +0 -0
- initium/data/graph_traversal/graph_traversal.py +746 -0
- initium/data/multimodal/__init__.py +0 -0
- initium/data/multimodal/multimodal_dataset.py +401 -0
- initium/data/text/__init__.py +0 -0
- initium/data/text/text_dataset.py +79 -0
- initium/data/video/__init__.py +0 -0
- initium/data/video/video_dataset.py +85 -0
- initium/inference/__init__.py +1 -0
- initium/inference/cache/__init__.py +1 -0
- initium/inference/cache/base_cache.py +112 -0
- initium/inference/cache/cache_config.py +21 -0
- initium/inference/cache/cache_registry.py +99 -0
- initium/inference/cache/cached_engine.py +264 -0
- initium/inference/cache/keys.py +77 -0
- initium/inference/cache/prefix_cache.py +59 -0
- initium/inference/cache/result_cache.py +57 -0
- initium/inference/cache/state_utils.py +74 -0
- initium/inference/cache/stores.py +167 -0
- initium/inference/capabilities.py +86 -0
- initium/inference/checkpoint_io.py +63 -0
- initium/inference/engine.py +88 -0
- initium/inference/inference_config.py +22 -0
- initium/inference/metrics.py +103 -0
- initium/inference/model_loader.py +270 -0
- initium/inference/run_inference.py +526 -0
- initium/inference/run_logging.py +173 -0
- initium/inference/tasks/__init__.py +1 -0
- initium/inference/tasks/audio_task.py +114 -0
- initium/inference/tasks/base_task.py +60 -0
- initium/inference/tasks/graph_traversal_task.py +235 -0
- initium/inference/tasks/multimodal_task.py +74 -0
- initium/inference/tasks/task_registry.py +68 -0
- initium/inference/tasks/text_task.py +114 -0
- initium/inference/tasks/video_task.py +114 -0
- initium/mamba_controller/mamba2_controller.py +433 -0
- initium/mamba_controller/mamba3_controller.py +242 -0
- initium/mamba_controller/mamba_backbone_parallel.py +291 -0
- initium/mamba_controller/mamba_controller.py +983 -0
- initium/mamba_controller/split_graph_dnc.py +623 -0
- initium/memory_manipulation/dynamic_memory_resize.py +157 -0
- initium/memory_manipulation/dynamic_n_controller.py +152 -0
- initium/memory_manipulation/link_matrix_ablation.py +130 -0
- initium/memory_manipulation/nvrtc_compat.py +143 -0
- initium/memory_manipulation/stochastic_write_head_v2.py +545 -0
- initium/setup_wheels.py +175 -0
- initium_deeplearning-0.1.0.dist-info/METADATA +253 -0
- initium_deeplearning-0.1.0.dist-info/RECORD +71 -0
- initium_deeplearning-0.1.0.dist-info/WHEEL +4 -0
- initium_deeplearning-0.1.0.dist-info/entry_points.txt +3 -0
- initium_deeplearning-0.1.0.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""
|
|
2
|
+
file: controller_config.py
|
|
3
|
+
|
|
4
|
+
Controller and memory-feature configuration. Each block is only meaningful for
|
|
5
|
+
its own controller / feature; defaults reproduce the baseline LSTM + dense
|
|
6
|
+
fixed-N run. Imported explicitly by core_training.py.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# ---- Controller selection ---------------------------------------------------
|
|
10
|
+
# "lstm" reproduces Phase 2 exactly. Overridable via --controller.
|
|
11
|
+
CONTROLLER_TYPE = "lstm"
|
|
12
|
+
|
|
13
|
+
# Mamba-1 (paper defaults, Gu & Dao 2024, Sec 3.4)
|
|
14
|
+
MAMBA_D_STATE = 16
|
|
15
|
+
MAMBA_D_CONV = 4
|
|
16
|
+
MAMBA_EXPAND = 2
|
|
17
|
+
|
|
18
|
+
# Mamba-2 standalone per-timestep controller (--controller mamba2). NOT the same
|
|
19
|
+
# as SPLIT_GRAPH_MAMBA_VARIANT="mamba2" (whole-sequence backbone, no memory dependency).
|
|
20
|
+
MAMBA2_D_STATE = 64
|
|
21
|
+
MAMBA2_D_CONV = 4
|
|
22
|
+
MAMBA2_EXPAND = 2
|
|
23
|
+
MAMBA2_HEADDIM = 64
|
|
24
|
+
MAMBA2_NGROUPS = 1
|
|
25
|
+
|
|
26
|
+
# Mamba-3 (SISO). d_state=64 matches the Mamba-2 setting. If the interleaved run
|
|
27
|
+
# OOMs, drop MAMBA3_D_STATE to 32 first.
|
|
28
|
+
MAMBA3_D_STATE = 64
|
|
29
|
+
MAMBA3_EXPAND = 2
|
|
30
|
+
MAMBA3_HEADDIM = 64
|
|
31
|
+
MAMBA3_ROPE_FRACTION = 0.5
|
|
32
|
+
|
|
33
|
+
# CfC (LNN, ncps) -- CONTROLLER_TYPE == "cfc"
|
|
34
|
+
CFC_MODE = "default" # "default" | "pure" | "no_gate"
|
|
35
|
+
CFC_BACKBONE_UNITS = 512
|
|
36
|
+
CFC_BACKBONE_LAYERS = 1
|
|
37
|
+
CFC_BACKBONE_DROPOUT = 0.0
|
|
38
|
+
CFC_ACTIVATION = "lecun_tanh"
|
|
39
|
+
CFC_MIXED_MEMORY = False # True = CfC-mmRNN (adds an LSTM cell)
|
|
40
|
+
CFC_RESIDUAL = True
|
|
41
|
+
HYBRID_CFC_NUM_BLOCKS = (
|
|
42
|
+
1 # CfC stage depth for "<mamba*>+cfc" (Mamba stage depth = num_hidden_layers)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# ---- Option 4: MoE in controller (mamba / mamba2 / mamba3 only) --------------
|
|
46
|
+
# num_experts >= 4 required by SwitchMoE; expert_dim None -> 3*hidden_size;
|
|
47
|
+
# alpha=0.01 is Switch Transformers' tuned value.
|
|
48
|
+
MOE_ENABLED = False
|
|
49
|
+
MOE_NUM_EXPERTS = 8
|
|
50
|
+
MOE_EXPERT_DIM: int | None = None
|
|
51
|
+
MOE_CAPACITY_FACTOR = 1.5
|
|
52
|
+
MOE_LOAD_BALANCE_ALPHA = 0.01
|
|
53
|
+
MOE_LOAD_BALANCE_ALPHA = 0.01
|
|
54
|
+
MOE_TOP_K = 1 # experts simultaneously active per token/source (Top-K routing)
|
|
55
|
+
SPLIT_GRAPH_COMBINER_CFC_MULTI_SOURCE_MOE = True # combiner_variant="cfc" + moe: route
|
|
56
|
+
# [backbone_output, prev_read_vector] through
|
|
57
|
+
# per-source specialized experts (see
|
|
58
|
+
# cfc_controller.py / moe_layer.MultiSourceMoEBlock)
|
|
59
|
+
|
|
60
|
+
# ---- Option 5: split-compute-graph controller (off unless --split-graph) ------
|
|
61
|
+
SPLIT_GRAPH_ENABLED = False
|
|
62
|
+
SPLIT_GRAPH_MAMBA_VARIANT = "mamba1" # "mamba1" | "mamba2" | "mamba3" | "cfc" | "<mamba*>+cfc"
|
|
63
|
+
SPLIT_GRAPH_NUM_BLOCKS = 2
|
|
64
|
+
SPLIT_GRAPH_MAMBA_HEADDIM = 64 # mamba2/3 only
|
|
65
|
+
SPLIT_GRAPH_COMBINE_READS = True # False = built-in ablation
|
|
66
|
+
SPLIT_GRAPH_COMBINER_MODE = "linear" # "linear" (default) | "controller"
|
|
67
|
+
SPLIT_GRAPH_COMBINER_VARIANT = "mamba1"
|
|
68
|
+
SPLIT_GRAPH_COMBINER_NUM_BLOCKS = 1
|
|
69
|
+
|
|
70
|
+
# ---- Option 1: link-matrix ablation/sparsification at fixed N -----------------
|
|
71
|
+
LINK_MATRIX_MODE = "dense" # "dense" | "ablated" | "sparse_topk"
|
|
72
|
+
LINK_MATRIX_TOPK: int | None = None # int, required only for "sparse_topk"
|
|
73
|
+
ISOLATE_LINK_ABLATION = False # True: hold nr_cells fixed at MODEL_NR_CELLS for the
|
|
74
|
+
# whole run so only the link-matrix change is measured
|
|
75
|
+
|
|
76
|
+
# ---- Dynamic-N, macro-scale (usage-triggered nr_cells growth between episodes) ---
|
|
77
|
+
# Mutually exclusive with curriculum-indexed resize (the core overrides the
|
|
78
|
+
# curriculum's lesson_nr_cells to a constant when this is on).
|
|
79
|
+
DYNAMIC_N_MODE = False
|
|
80
|
+
DYNAMIC_N_FLOOR = 128 # starting nr_cells
|
|
81
|
+
DYNAMIC_N_CEILING = 512 # hard ceiling (sparse-link approx only validated to 512)
|
|
82
|
+
DYNAMIC_N_GROWTH_FACTOR = 2.0 # 128 -> 256 -> 512
|
|
83
|
+
DYNAMIC_N_USAGE_HIGH = 0.90 # a cell counts as "saturated" above this usage
|
|
84
|
+
DYNAMIC_N_TRIGGER_FRAC = 0.75 # growth when EMA of saturated fraction exceeds this
|
|
85
|
+
DYNAMIC_N_EMA_DECAY = 0.98 # "sustained, not a single-step spike" window
|
|
86
|
+
DYNAMIC_N_COOLDOWN_STEPS = 2000 # wait after a growth event before another
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""
|
|
2
|
+
file: train_config.py
|
|
3
|
+
|
|
4
|
+
Core training-loop configuration (dataset-agnostic). Pure constants; imported
|
|
5
|
+
explicitly by core_training.py. Controller / memory-feature options live in
|
|
6
|
+
controller_config.py.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import math
|
|
10
|
+
|
|
11
|
+
# ---- Loop / optimisation ----------------------------------------------------
|
|
12
|
+
BATCH_SIZE = 16 # bucketed, so padding waste stays low even >1
|
|
13
|
+
TOTAL_STEPS = 120000
|
|
14
|
+
LOG_EVERY = 100
|
|
15
|
+
EVAL_EVERY = 1000 # curriculum-advance eval cadence
|
|
16
|
+
LR = 3e-4
|
|
17
|
+
LR_MIN = 3e-5
|
|
18
|
+
LR_DECAY_STEPS = TOTAL_STEPS # cosine anneal length. Derived from TOTAL_STEPS here on
|
|
19
|
+
# purpose: --total-steps does NOT change it (pilot runs
|
|
20
|
+
# still anneal on the full schedule).
|
|
21
|
+
WARMUP_STEPS = 1000 # linear LR warmup 0 -> LR before the cosine anneal
|
|
22
|
+
USE_AMP = True
|
|
23
|
+
SEED = 0
|
|
24
|
+
AMP_INIT_SCALE = 128.0 # GradScaler start scale (default 65536 wasted ~14k steps
|
|
25
|
+
# halving its way down before training worked)
|
|
26
|
+
|
|
27
|
+
# ---- Model size -------------------------------------------------------------
|
|
28
|
+
MODEL_HIDDEN_SIZE = 512
|
|
29
|
+
MODEL_NR_CELLS = 256 # link matrix is O(N^2) in memory, so left unchanged
|
|
30
|
+
MODEL_CELL_SIZE = 192
|
|
31
|
+
MODEL_READ_HEADS = 8
|
|
32
|
+
|
|
33
|
+
# ---- Dataset selection (see data/dataset_registry.py) -----------------------
|
|
34
|
+
# Overridable via --dataset-type / --dataset-link.
|
|
35
|
+
DATASET_TYPE = "graph" # "graph" | "text" | "audio" | "video" (only graph implemented)
|
|
36
|
+
DATASET_LINK: str | None = None # None / "graph-traversal" -> built-in synthetic graph curriculum
|
|
37
|
+
|
|
38
|
+
# ---- KL -----------------------------------------------------------
|
|
39
|
+
BETAS_TO_SWEEP = [0.0]
|
|
40
|
+
KL_ANNEAL_STEPS = 8000 # ramp beta 0 -> target over this many steps
|
|
41
|
+
LESSON_KL_DIP_STEPS = 100
|
|
42
|
+
FREE_BITS = 0.02 # per-dimension KL floor (nats); 0.0 disables
|
|
43
|
+
LOG_DIR = "./logs"
|
|
44
|
+
OOD_EVAL_EPISODES = 200 # terminal OOD eval
|
|
45
|
+
OOD_EVAL_EPISODES_PERIODIC = 50 # lighter periodic OOD read every EVAL_EVERY steps
|
|
46
|
+
|
|
47
|
+
# ---- Dynamic beta (GECO-style dual ascent), task-accuracy constrained --------
|
|
48
|
+
# beta_target is reused as the controller's live value (checkpointed/logged as before).
|
|
49
|
+
BETA_MODE = "static" # "static" or "dynamic"
|
|
50
|
+
BETA_CTRL_ACC_TARGET = None # accuracy floor (0-1 frac); None -> dataset.advance_threshold
|
|
51
|
+
BETA_CTRL_LR = 2e-5 # max step per EVAL_EVERY cycle at constraint==1.0
|
|
52
|
+
BETA_CTRL_MIN = 0.0
|
|
53
|
+
BETA_CTRL_MAX = 2e-4 # hard ceiling -- 1e-3 is known to collapse
|
|
54
|
+
BETA_CTRL_EMA_DECAY = 0.9 # smooths the constraint signal across eval cycles
|
|
55
|
+
|
|
56
|
+
# ---- Learned prior ---------------------------------------------
|
|
57
|
+
# See stochastic_write_head_v2.py (update_prior_snapshot) for what these gate.
|
|
58
|
+
PRIOR_SNAPSHOT_EVERY = 2000
|
|
59
|
+
PRIOR_MIN_LOGVAR = -6.0 # floor on log(Sigma_g), prevents silent collapse
|
|
60
|
+
PRIOR_MAX_LOGVAR = math.log(6) # symmetric ceiling
|
|
61
|
+
|
|
62
|
+
# ---- Checkpointing ----------------------------------------------------------
|
|
63
|
+
CHECKPOINT_DIR = "./checkpoints"
|
|
64
|
+
CHECKPOINT_EVERY = 2000 # periodic safety checkpoint, in addition to end-of-run
|