Pacific-i64 commited on
Commit
dbb60a8
·
verified ·
1 Parent(s): 46e4d76

Upload 6 files

Browse files
README.md CHANGED
@@ -4,51 +4,101 @@ license: cc-by-nc-4.0
4
  tags:
5
  - complexity-deep
6
  - token-routed
7
- - checkpoint
8
- - resumable
9
- - chinchilla
 
 
 
10
  ---
11
 
12
- # COMPLEXITY-DEEP Token-Routed MoE (383.5M) — Training Checkpoint (Step 15,259)
13
 
14
- Resumable training checkpoint with full optimizer state at the end of 8B tokens training.
15
 
16
- **Note**: This model was trained with a Chinchilla-like token budget (8B tokens for 383.5M parameters, ~21 tokens/param). The model may benefit from continued training beyond this point.
 
 
 
 
 
 
 
 
 
17
 
18
- ## Contents
19
 
20
- - `checkpoint.pt` - Model weights + training state
21
- - `model.safetensors` - Model weights (safetensors format)
22
- - `optimizer_rank0.pt` - AdamW optimizer state (GPU 0)
23
- - `optimizer_rank1.pt` - AdamW optimizer state (GPU 1)
24
- - `training_state.json` - Step counter, LR, etc.
 
 
 
25
 
26
- ## Model Config
27
 
28
- - **Parameters**: 383.5M total, ~105M active per token
29
- - **Hidden**: 1024, Layers: 20, Heads: 16, KV Heads: 4
30
- - **Experts**: 4, Intermediate: 3200 (800/expert), Shared: 800
31
- - **Training**: 8B tokens (15,259 steps), AdamW lr=2.1e-4, cosine 5% warmup
32
 
33
- ## Resume Training
 
 
 
 
 
34
 
35
- ```python
36
- import torch
 
 
 
 
 
 
 
 
 
 
37
 
38
- checkpoint = torch.load("checkpoint.pt", map_location="cpu")
39
- model.load_state_dict(checkpoint["model"])
40
 
41
- # Load optimizer for your GPU rank (0 or 1)
42
- rank = torch.distributed.get_rank()
43
- optimizer_state = torch.load(f"optimizer_rank{rank}.pt", map_location="cpu")
44
- optimizer.load_state_dict(optimizer_state)
45
 
46
- # Resume from step 15,259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  ```
48
 
49
- ## Pretrained Weights (inference)
50
 
51
- For inference use the safetensors checkpoint in `../final/` instead.
52
 
53
  ## License
54
 
 
4
  tags:
5
  - complexity-deep
6
  - token-routed
7
+ - moe
8
+ - deterministic-routing
9
+ - zipf-routing
10
+ - mu-guidance
11
+ library_name: complexity-framework
12
+ pipeline_tag: text-generation
13
  ---
14
 
15
+ # COMPLEXITY-DEEP Token-Routed MoE (383.5M)
16
 
17
+ ## Model Details
18
 
19
+ - **Architecture**: Token-Routed MLP + Mu-Guidance + Shared Lexical Expert
20
+ - **Parameters**: 383.5M total, ~105M active per token
21
+ - **Hidden size**: 1024
22
+ - **Layers**: 20
23
+ - **Attention heads**: 16 (GQA, 4 KV heads)
24
+ - **Intermediate size**: 3200 (800 per expert)
25
+ - **Experts**: 4 (deterministic Zipf-balanced routing)
26
+ - **Shared expert**: 800 intermediate
27
+ - **Vocabulary**: 32,000
28
+ - **Max context**: 4,096
29
 
30
+ ## Training
31
 
32
+ - **Dataset**: FineWeb-Edu (streaming)
33
+ - **Tokens**: 8B (15,259 steps)
34
+ - **Batch size**: 128 per GPU x 2 GPUs = 256 effective
35
+ - **Optimizer**: AdamW (lr=2.1e-4, auto-scaled to 4.2e-4)
36
+ - **Scheduler**: Cosine with 5% warmup (762 steps)
37
+ - **Precision**: BF16
38
+ - **Hardware**: 2x NVIDIA RTX PRO 6000 (96GB each)
39
+ - **Training time**: ~30 hours
40
 
41
+ ## Results
42
 
43
+ ### Loss
44
+ - **Final loss**: ~2.96
45
+ - **vs Dense baseline (384.5M)**: +0.09 gap (stable from step 5K)
46
+ - **Gap trend**: 0.28 (step 1K) -> 0.09 (step 5K+)
47
 
48
+ ### Zero-Shot Benchmarks
49
+ | Benchmark | MoE (383.5M) | Dense (384.5M) |
50
+ |-----------|-------------|----------------|
51
+ | ARC-Easy | 43.6% | 45.9% |
52
+ | HellaSwag | 28.7% | 30.1% |
53
+ | MMLU | 23.0% | 23.1% |
54
 
55
+ ### Inference (vLLM 0.18, RTX PRO 6000 96GB)
56
+ - **Sustained throughput**: 4,900 tok/s
57
+ - **Peak throughput**: 5,700 tok/s
58
+ - **Median TTFT**: 39.6 ms
59
+ - **Median ITL**: 16.0 ms
60
+ - **CUDA graph**: natively compatible (deterministic routing)
61
+
62
+ ## Expert Specialization (3D t-SNE)
63
+
64
+ Interactive visualization of expert activations across layers. Each point is an expert at a given layer; proximity = similar activation patterns.
65
+
66
+ **[▶ Open Interactive 3D t-SNE Visualization](https://www.complexity-ai.fr/expert_tsne_3d.html)**
67
 
68
+ ## Generation Example
 
69
 
70
+ No supervised fine-tuning. Raw base model output:
 
 
 
71
 
72
+ **Prompt:** "The meaning of life is"
73
+
74
+ **Output:** "very much the same. The same thing happens to all living things. They live in a constant
75
+ state of flux. The single cell of a living cell, in this case a cell nucleus, constantly changes to become
76
+ an organism, and that organism is the organism. The human body is a system of interconnected
77
+ cells. Each cell is made up of a set of parts, which are connected by a network of specialized cells."
78
+
79
+ ## Files
80
+
81
+ - `model.safetensors` - Model weights
82
+ - `model_config.yaml` - Architecture configuration
83
+ - `config.json` - HuggingFace-compatible config
84
+
85
+ ## Usage
86
+
87
+ ```python
88
+ from complexity.config import ModelConfig
89
+ from complexity.models import ComplexityModel
90
+ from safetensors.torch import load_file
91
+
92
+ config = ModelConfig.load("model_config.yaml")
93
+ model = ComplexityModel(config)
94
+ state = load_file("model.safetensors", device="cpu")
95
+ model.load_state_dict(state, strict=False)
96
+ model.eval().cuda()
97
  ```
98
 
99
+ ## Paper
100
 
101
+ Under review at TMLR: https://openreview.net/forum?id=jZq6EVboC6
102
 
103
  ## License
104
 
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "deep",
3
+ "architectures": ["DeepForCausalLM"],
4
+ "hidden_size": 1024,
5
+ "num_hidden_layers": 20,
6
+ "intermediate_size": 3200,
7
+ "vocab_size": 32000,
8
+ "num_attention_heads": 16,
9
+ "num_key_value_heads": 4,
10
+ "attention_type": "gqa",
11
+ "attention_dropout": 0.0,
12
+ "use_qk_norm": true,
13
+ "sliding_window": null,
14
+ "max_position_embeddings": 4096,
15
+ "rope_theta": 10000.0,
16
+ "rope_type": "standard",
17
+ "mlp_type": "token_routed",
18
+ "hidden_act": "silu",
19
+ "num_experts": 4,
20
+ "shared_expert": true,
21
+ "shared_intermediate_size": 800,
22
+ "use_mu_guidance": true,
23
+ "use_mu_projection": false,
24
+ "disable_mu_guidance": false,
25
+ "norm_type": "rmsnorm",
26
+ "norm_eps": 1e-06,
27
+ "tie_word_embeddings": true,
28
+ "use_sdpa": true,
29
+ "use_cache": true,
30
+ "initializer_range": 0.02,
31
+ "extra_config": {}
32
+ }
model_config.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ attention_dropout: 0.0
2
+ attention_type: gqa
3
+ disable_mu_guidance: false
4
+ extra_config: {}
5
+ hidden_act: silu
6
+ hidden_size: 1024
7
+ initializer_range: 0.02
8
+ intermediate_size: 3200
9
+ max_position_embeddings: 4096
10
+ mlp_type: token_routed
11
+ norm_eps: 1.0e-06
12
+ norm_type: rmsnorm
13
+ num_attention_heads: 16
14
+ num_experts: 4
15
+ num_hidden_layers: 20
16
+ num_key_value_heads: 4
17
+ rope_theta: 10000.0
18
+ rope_type: standard
19
+ shared_expert: true
20
+ shared_intermediate_size: null
21
+ sliding_window: null
22
+ tie_word_embeddings: true
23
+ use_cache: true
24
+ use_mu_guidance: true
25
+ use_mu_projection: false
26
+ use_qk_norm: true
27
+ use_sdpa: true
28
+ vocab_size: 32000
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>",
4
+ "pad_token": "<pad>",
5
+ "unk_token": "<unk>"
6
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": true,
4
+ "chat_template": "{% if messages[0]['role'] == 'system' %}{{ messages[0]['content'] }}\n\n{% set ns = namespace(messages=messages[1:]) %}{% else %}{% set ns = namespace(messages=messages) %}{% endif %}{% for message in ns.messages %}{% if message['role'] == 'user' %}User: {{ message['content'] }}\n\n{% elif message['role'] == 'assistant' %}Assistant: {{ message['content'] }}{{ eos_token }}\n{% endif %}{% endfor %}{% if add_generation_prompt %}Assistant:{% endif %}",
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "</s>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<pad>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "<s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "3": {
31
+ "content": "<unk>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ }
38
+ },
39
+ "bos_token": "<s>",
40
+ "clean_up_tokenization_spaces": false,
41
+ "eos_token": "</s>",
42
+ "extra_special_tokens": {},
43
+ "model_max_length": 2048,
44
+ "pad_token": "<pad>",
45
+ "tokenizer_class": "PreTrainedTokenizerFast",
46
+ "unk_token": "<unk>"
47
+ }