qingy2024 commited on
Commit
560b0e9
·
verified ·
1 Parent(s): 0f464ac

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  ring-mini-2.0-9b/tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  ring-mini-2.0-9b/tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
chat_template.jinja ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ {% for message in messages %}{% set role = message['role'] | lower %}{% if role == 'user' %}{% set role = 'HUMAN' %}{% endif %}{% set role = role | upper %}{{ '<role>' + role + '</role>' + message['content'] }}{% endfor %}{% if add_generation_prompt %}{{ '<role>ASSISTANT</role><think>
2
+ ' }}{% endif %}
config.json CHANGED
@@ -1,50 +1,54 @@
1
  {
2
- "architectures": [
3
- "BailingMoeV2ForCausalLM"
4
- ],
5
- "attention_dropout": 0.0,
6
- "auto_map": {
7
- "AutoConfig": "configuration_bailing_moe_v2.BailingMoeV2Config",
8
- "AutoModel": "modeling_bailing_moe_v2.BailingMoeV2Model",
9
- "AutoModelForCausalLM": "modeling_bailing_moe_v2.BailingMoeV2ForCausalLM"
10
- },
11
- "num_hidden_layers": 20,
12
- "hidden_size": 2048,
13
- "intermediate_size": 5120,
14
- "eos_token_id": 156892,
15
- "pad_token_id": 156892,
16
- "first_k_dense_replace": 1,
17
- "hidden_act": "silu",
18
- "max_position_embeddings": 32768,
19
- "model_type": "bailing_moe",
20
- "moe_intermediate_size": 512,
21
- "norm_topk_prob": true,
22
- "num_experts_per_tok": 8,
23
- "num_attention_heads": 16,
24
- "num_experts": 256,
25
- "num_key_value_heads": 4,
26
- "rope_theta": 600000,
27
- "rope_scaling": null,
28
- "tie_word_embeddings": false,
29
- "torch_dtype": "bfloat16",
30
- "transformers_version": "4.52.3",
31
- "use_bias": false,
32
- "use_rmsnorm": true,
33
- "rms_norm_eps": 1e-06,
34
- "head_dim": 128,
35
- "num_shared_experts": 1,
36
- "use_cache": true,
37
- "use_qkv_bias": false,
38
- "embedding_dropout": 0.0,
39
- "output_dropout": 0.0,
40
- "vocab_size": 157184,
41
- "partial_rotary_factor": 0.5,
42
- "router_dtype": "fp32",
43
- "moe_router_enable_expert_bias": true,
44
- "routed_scaling_factor": 2.5,
45
- "n_group": 8,
46
- "topk_group": 4,
47
- "use_qk_norm": true,
48
- "score_function": "sigmoid",
49
- "moe_shared_expert_intermediate_size": 512
50
- }
 
 
 
 
 
1
  {
2
+ "architectures": [
3
+ "BailingMoeV2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_bailing_moe_v2.BailingMoeV2Config",
8
+ "AutoModel": "modeling_bailing_moe_v2.BailingMoeV2Model",
9
+ "AutoModelForCausalLM": "modeling_bailing_moe_v2.BailingMoeV2ForCausalLM"
10
+ },
11
+ "dtype": "bfloat16",
12
+ "embedding_dropout": 0.0,
13
+ "eos_token_id": 156892,
14
+ "first_k_dense_replace": 1,
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2048,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 5120,
20
+ "max_position_embeddings": 32768,
21
+ "max_window_layers": 20,
22
+ "moe_intermediate_size": 512,
23
+ "moe_router_enable_expert_bias": true,
24
+ "moe_shared_expert_intermediate_size": 512,
25
+ "mtp_loss_scaling_factor": 0,
26
+ "n_group": 8,
27
+ "norm_topk_prob": true,
28
+ "num_attention_heads": 16,
29
+ "num_experts": 128,
30
+ "num_experts_per_tok": 8,
31
+ "num_hidden_layers": 20,
32
+ "num_key_value_heads": 4,
33
+ "num_nextn_predict_layers": 0,
34
+ "num_shared_experts": 1,
35
+ "output_dropout": 0.0,
36
+ "output_router_logits": false,
37
+ "pad_token_id": 156892,
38
+ "partial_rotary_factor": 0.5,
39
+ "rms_norm_eps": 1e-06,
40
+ "rope_scaling": null,
41
+ "rope_theta": 600000,
42
+ "routed_scaling_factor": 2.5,
43
+ "router_dtype": "fp32",
44
+ "score_function": "sigmoid",
45
+ "tie_word_embeddings": false,
46
+ "topk_group": 4,
47
+ "transformers_version": "4.56.2",
48
+ "use_bias": false,
49
+ "use_cache": true,
50
+ "use_qk_norm": true,
51
+ "use_qkv_bias": false,
52
+ "use_rmsnorm": true,
53
+ "vocab_size": 157184
54
+ }
expert_selection.json ADDED
@@ -0,0 +1,2472 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "layer_1": [
3
+ 22,
4
+ 13,
5
+ 29,
6
+ 1,
7
+ 9,
8
+ 20,
9
+ 27,
10
+ 16,
11
+ 19,
12
+ 21,
13
+ 17,
14
+ 28,
15
+ 11,
16
+ 14,
17
+ 31,
18
+ 15,
19
+ 57,
20
+ 42,
21
+ 45,
22
+ 55,
23
+ 48,
24
+ 38,
25
+ 34,
26
+ 61,
27
+ 62,
28
+ 63,
29
+ 51,
30
+ 47,
31
+ 49,
32
+ 58,
33
+ 52,
34
+ 46,
35
+ 71,
36
+ 73,
37
+ 81,
38
+ 87,
39
+ 86,
40
+ 65,
41
+ 67,
42
+ 64,
43
+ 92,
44
+ 85,
45
+ 95,
46
+ 74,
47
+ 94,
48
+ 91,
49
+ 76,
50
+ 77,
51
+ 104,
52
+ 107,
53
+ 126,
54
+ 102,
55
+ 105,
56
+ 121,
57
+ 116,
58
+ 117,
59
+ 110,
60
+ 127,
61
+ 106,
62
+ 122,
63
+ 96,
64
+ 103,
65
+ 109,
66
+ 115,
67
+ 147,
68
+ 134,
69
+ 155,
70
+ 148,
71
+ 152,
72
+ 157,
73
+ 156,
74
+ 146,
75
+ 142,
76
+ 149,
77
+ 145,
78
+ 153,
79
+ 158,
80
+ 135,
81
+ 143,
82
+ 133,
83
+ 166,
84
+ 190,
85
+ 163,
86
+ 187,
87
+ 167,
88
+ 174,
89
+ 170,
90
+ 183,
91
+ 169,
92
+ 182,
93
+ 188,
94
+ 168,
95
+ 171,
96
+ 186,
97
+ 162,
98
+ 161,
99
+ 197,
100
+ 209,
101
+ 211,
102
+ 201,
103
+ 221,
104
+ 210,
105
+ 206,
106
+ 192,
107
+ 213,
108
+ 217,
109
+ 207,
110
+ 212,
111
+ 193,
112
+ 216,
113
+ 196,
114
+ 218,
115
+ 236,
116
+ 237,
117
+ 242,
118
+ 245,
119
+ 229,
120
+ 227,
121
+ 248,
122
+ 250,
123
+ 247,
124
+ 243,
125
+ 255,
126
+ 244,
127
+ 232,
128
+ 249,
129
+ 239,
130
+ 234
131
+ ],
132
+ "layer_2": [
133
+ 4,
134
+ 24,
135
+ 18,
136
+ 29,
137
+ 26,
138
+ 8,
139
+ 16,
140
+ 12,
141
+ 7,
142
+ 31,
143
+ 28,
144
+ 5,
145
+ 9,
146
+ 3,
147
+ 17,
148
+ 13,
149
+ 58,
150
+ 35,
151
+ 57,
152
+ 63,
153
+ 48,
154
+ 40,
155
+ 45,
156
+ 50,
157
+ 38,
158
+ 47,
159
+ 41,
160
+ 53,
161
+ 39,
162
+ 46,
163
+ 62,
164
+ 43,
165
+ 83,
166
+ 86,
167
+ 91,
168
+ 85,
169
+ 93,
170
+ 73,
171
+ 94,
172
+ 64,
173
+ 71,
174
+ 69,
175
+ 81,
176
+ 66,
177
+ 95,
178
+ 68,
179
+ 89,
180
+ 92,
181
+ 124,
182
+ 126,
183
+ 111,
184
+ 122,
185
+ 97,
186
+ 110,
187
+ 112,
188
+ 119,
189
+ 101,
190
+ 116,
191
+ 117,
192
+ 127,
193
+ 100,
194
+ 123,
195
+ 98,
196
+ 121,
197
+ 140,
198
+ 128,
199
+ 138,
200
+ 134,
201
+ 158,
202
+ 154,
203
+ 144,
204
+ 145,
205
+ 137,
206
+ 157,
207
+ 153,
208
+ 159,
209
+ 150,
210
+ 146,
211
+ 156,
212
+ 133,
213
+ 181,
214
+ 161,
215
+ 189,
216
+ 190,
217
+ 177,
218
+ 167,
219
+ 173,
220
+ 191,
221
+ 176,
222
+ 165,
223
+ 180,
224
+ 187,
225
+ 168,
226
+ 178,
227
+ 186,
228
+ 170,
229
+ 216,
230
+ 194,
231
+ 195,
232
+ 211,
233
+ 219,
234
+ 212,
235
+ 223,
236
+ 197,
237
+ 215,
238
+ 221,
239
+ 203,
240
+ 199,
241
+ 220,
242
+ 207,
243
+ 210,
244
+ 218,
245
+ 252,
246
+ 225,
247
+ 240,
248
+ 250,
249
+ 254,
250
+ 227,
251
+ 247,
252
+ 244,
253
+ 249,
254
+ 228,
255
+ 242,
256
+ 226,
257
+ 233,
258
+ 232,
259
+ 248,
260
+ 251
261
+ ],
262
+ "layer_3": [
263
+ 8,
264
+ 2,
265
+ 11,
266
+ 16,
267
+ 10,
268
+ 12,
269
+ 21,
270
+ 1,
271
+ 3,
272
+ 24,
273
+ 29,
274
+ 23,
275
+ 17,
276
+ 13,
277
+ 5,
278
+ 14,
279
+ 50,
280
+ 45,
281
+ 49,
282
+ 52,
283
+ 61,
284
+ 53,
285
+ 32,
286
+ 42,
287
+ 56,
288
+ 63,
289
+ 58,
290
+ 41,
291
+ 47,
292
+ 40,
293
+ 36,
294
+ 59,
295
+ 89,
296
+ 66,
297
+ 69,
298
+ 83,
299
+ 82,
300
+ 72,
301
+ 94,
302
+ 75,
303
+ 87,
304
+ 92,
305
+ 73,
306
+ 85,
307
+ 67,
308
+ 88,
309
+ 71,
310
+ 91,
311
+ 123,
312
+ 96,
313
+ 121,
314
+ 118,
315
+ 112,
316
+ 127,
317
+ 114,
318
+ 122,
319
+ 100,
320
+ 103,
321
+ 109,
322
+ 107,
323
+ 111,
324
+ 113,
325
+ 117,
326
+ 115,
327
+ 131,
328
+ 158,
329
+ 157,
330
+ 153,
331
+ 138,
332
+ 129,
333
+ 149,
334
+ 156,
335
+ 137,
336
+ 154,
337
+ 152,
338
+ 145,
339
+ 147,
340
+ 142,
341
+ 150,
342
+ 134,
343
+ 185,
344
+ 177,
345
+ 178,
346
+ 181,
347
+ 173,
348
+ 164,
349
+ 186,
350
+ 161,
351
+ 165,
352
+ 172,
353
+ 190,
354
+ 184,
355
+ 188,
356
+ 179,
357
+ 175,
358
+ 182,
359
+ 213,
360
+ 222,
361
+ 203,
362
+ 216,
363
+ 221,
364
+ 198,
365
+ 211,
366
+ 199,
367
+ 220,
368
+ 207,
369
+ 205,
370
+ 210,
371
+ 214,
372
+ 208,
373
+ 217,
374
+ 204,
375
+ 250,
376
+ 229,
377
+ 252,
378
+ 243,
379
+ 233,
380
+ 227,
381
+ 245,
382
+ 242,
383
+ 230,
384
+ 231,
385
+ 244,
386
+ 255,
387
+ 224,
388
+ 246,
389
+ 247,
390
+ 234
391
+ ],
392
+ "layer_4": [
393
+ 21,
394
+ 31,
395
+ 23,
396
+ 5,
397
+ 17,
398
+ 22,
399
+ 28,
400
+ 24,
401
+ 8,
402
+ 1,
403
+ 14,
404
+ 18,
405
+ 29,
406
+ 2,
407
+ 10,
408
+ 19,
409
+ 61,
410
+ 58,
411
+ 43,
412
+ 44,
413
+ 54,
414
+ 34,
415
+ 53,
416
+ 55,
417
+ 41,
418
+ 42,
419
+ 45,
420
+ 35,
421
+ 63,
422
+ 32,
423
+ 37,
424
+ 62,
425
+ 93,
426
+ 90,
427
+ 86,
428
+ 83,
429
+ 76,
430
+ 89,
431
+ 70,
432
+ 66,
433
+ 71,
434
+ 92,
435
+ 88,
436
+ 64,
437
+ 72,
438
+ 79,
439
+ 95,
440
+ 75,
441
+ 127,
442
+ 109,
443
+ 110,
444
+ 101,
445
+ 107,
446
+ 100,
447
+ 123,
448
+ 99,
449
+ 108,
450
+ 115,
451
+ 120,
452
+ 119,
453
+ 113,
454
+ 96,
455
+ 98,
456
+ 116,
457
+ 144,
458
+ 134,
459
+ 152,
460
+ 141,
461
+ 151,
462
+ 159,
463
+ 156,
464
+ 153,
465
+ 136,
466
+ 149,
467
+ 148,
468
+ 157,
469
+ 138,
470
+ 128,
471
+ 139,
472
+ 155,
473
+ 184,
474
+ 174,
475
+ 178,
476
+ 175,
477
+ 170,
478
+ 186,
479
+ 187,
480
+ 189,
481
+ 177,
482
+ 190,
483
+ 176,
484
+ 188,
485
+ 172,
486
+ 183,
487
+ 160,
488
+ 182,
489
+ 200,
490
+ 217,
491
+ 207,
492
+ 218,
493
+ 214,
494
+ 212,
495
+ 208,
496
+ 197,
497
+ 204,
498
+ 206,
499
+ 196,
500
+ 220,
501
+ 192,
502
+ 213,
503
+ 210,
504
+ 194,
505
+ 226,
506
+ 242,
507
+ 248,
508
+ 246,
509
+ 234,
510
+ 253,
511
+ 250,
512
+ 255,
513
+ 249,
514
+ 245,
515
+ 233,
516
+ 241,
517
+ 231,
518
+ 239,
519
+ 237,
520
+ 235
521
+ ],
522
+ "layer_5": [
523
+ 26,
524
+ 4,
525
+ 27,
526
+ 2,
527
+ 22,
528
+ 11,
529
+ 29,
530
+ 14,
531
+ 6,
532
+ 8,
533
+ 25,
534
+ 5,
535
+ 18,
536
+ 21,
537
+ 20,
538
+ 24,
539
+ 62,
540
+ 40,
541
+ 46,
542
+ 51,
543
+ 63,
544
+ 55,
545
+ 50,
546
+ 32,
547
+ 37,
548
+ 49,
549
+ 33,
550
+ 52,
551
+ 59,
552
+ 43,
553
+ 36,
554
+ 41,
555
+ 81,
556
+ 95,
557
+ 74,
558
+ 68,
559
+ 72,
560
+ 76,
561
+ 70,
562
+ 77,
563
+ 93,
564
+ 65,
565
+ 94,
566
+ 87,
567
+ 82,
568
+ 88,
569
+ 84,
570
+ 71,
571
+ 118,
572
+ 108,
573
+ 125,
574
+ 109,
575
+ 117,
576
+ 121,
577
+ 96,
578
+ 97,
579
+ 113,
580
+ 99,
581
+ 122,
582
+ 101,
583
+ 111,
584
+ 123,
585
+ 114,
586
+ 106,
587
+ 152,
588
+ 145,
589
+ 158,
590
+ 139,
591
+ 130,
592
+ 138,
593
+ 142,
594
+ 136,
595
+ 148,
596
+ 133,
597
+ 144,
598
+ 146,
599
+ 143,
600
+ 128,
601
+ 135,
602
+ 134,
603
+ 168,
604
+ 172,
605
+ 186,
606
+ 162,
607
+ 187,
608
+ 173,
609
+ 175,
610
+ 183,
611
+ 160,
612
+ 166,
613
+ 169,
614
+ 179,
615
+ 180,
616
+ 164,
617
+ 188,
618
+ 184,
619
+ 201,
620
+ 213,
621
+ 202,
622
+ 217,
623
+ 206,
624
+ 199,
625
+ 223,
626
+ 207,
627
+ 212,
628
+ 197,
629
+ 221,
630
+ 219,
631
+ 200,
632
+ 193,
633
+ 198,
634
+ 196,
635
+ 230,
636
+ 227,
637
+ 251,
638
+ 238,
639
+ 245,
640
+ 228,
641
+ 255,
642
+ 226,
643
+ 232,
644
+ 246,
645
+ 224,
646
+ 225,
647
+ 243,
648
+ 254,
649
+ 236,
650
+ 234
651
+ ],
652
+ "layer_6": [
653
+ 21,
654
+ 11,
655
+ 22,
656
+ 14,
657
+ 19,
658
+ 3,
659
+ 5,
660
+ 27,
661
+ 29,
662
+ 6,
663
+ 15,
664
+ 0,
665
+ 12,
666
+ 4,
667
+ 2,
668
+ 31,
669
+ 61,
670
+ 44,
671
+ 59,
672
+ 41,
673
+ 33,
674
+ 42,
675
+ 53,
676
+ 47,
677
+ 54,
678
+ 55,
679
+ 57,
680
+ 38,
681
+ 48,
682
+ 63,
683
+ 56,
684
+ 34,
685
+ 89,
686
+ 95,
687
+ 80,
688
+ 71,
689
+ 77,
690
+ 64,
691
+ 74,
692
+ 90,
693
+ 66,
694
+ 67,
695
+ 75,
696
+ 93,
697
+ 91,
698
+ 69,
699
+ 92,
700
+ 79,
701
+ 102,
702
+ 109,
703
+ 110,
704
+ 126,
705
+ 120,
706
+ 108,
707
+ 98,
708
+ 125,
709
+ 123,
710
+ 112,
711
+ 118,
712
+ 113,
713
+ 97,
714
+ 104,
715
+ 96,
716
+ 127,
717
+ 155,
718
+ 138,
719
+ 147,
720
+ 151,
721
+ 132,
722
+ 136,
723
+ 128,
724
+ 140,
725
+ 154,
726
+ 156,
727
+ 150,
728
+ 139,
729
+ 130,
730
+ 149,
731
+ 157,
732
+ 129,
733
+ 176,
734
+ 178,
735
+ 175,
736
+ 168,
737
+ 187,
738
+ 169,
739
+ 190,
740
+ 170,
741
+ 180,
742
+ 179,
743
+ 166,
744
+ 165,
745
+ 172,
746
+ 167,
747
+ 160,
748
+ 185,
749
+ 196,
750
+ 200,
751
+ 212,
752
+ 205,
753
+ 219,
754
+ 193,
755
+ 214,
756
+ 215,
757
+ 210,
758
+ 222,
759
+ 217,
760
+ 206,
761
+ 208,
762
+ 203,
763
+ 221,
764
+ 201,
765
+ 232,
766
+ 231,
767
+ 248,
768
+ 227,
769
+ 249,
770
+ 250,
771
+ 235,
772
+ 239,
773
+ 229,
774
+ 240,
775
+ 225,
776
+ 228,
777
+ 242,
778
+ 254,
779
+ 244,
780
+ 247
781
+ ],
782
+ "layer_7": [
783
+ 22,
784
+ 21,
785
+ 14,
786
+ 28,
787
+ 3,
788
+ 31,
789
+ 29,
790
+ 26,
791
+ 27,
792
+ 15,
793
+ 20,
794
+ 0,
795
+ 30,
796
+ 10,
797
+ 5,
798
+ 18,
799
+ 50,
800
+ 37,
801
+ 39,
802
+ 60,
803
+ 33,
804
+ 53,
805
+ 62,
806
+ 63,
807
+ 43,
808
+ 42,
809
+ 57,
810
+ 34,
811
+ 61,
812
+ 52,
813
+ 47,
814
+ 35,
815
+ 68,
816
+ 73,
817
+ 87,
818
+ 78,
819
+ 74,
820
+ 94,
821
+ 85,
822
+ 69,
823
+ 91,
824
+ 84,
825
+ 95,
826
+ 77,
827
+ 93,
828
+ 86,
829
+ 83,
830
+ 71,
831
+ 97,
832
+ 111,
833
+ 123,
834
+ 118,
835
+ 110,
836
+ 125,
837
+ 119,
838
+ 122,
839
+ 96,
840
+ 112,
841
+ 109,
842
+ 114,
843
+ 120,
844
+ 108,
845
+ 98,
846
+ 99,
847
+ 143,
848
+ 153,
849
+ 135,
850
+ 129,
851
+ 148,
852
+ 156,
853
+ 133,
854
+ 150,
855
+ 137,
856
+ 157,
857
+ 138,
858
+ 146,
859
+ 132,
860
+ 130,
861
+ 128,
862
+ 159,
863
+ 180,
864
+ 181,
865
+ 186,
866
+ 168,
867
+ 184,
868
+ 166,
869
+ 189,
870
+ 160,
871
+ 173,
872
+ 185,
873
+ 178,
874
+ 163,
875
+ 183,
876
+ 177,
877
+ 172,
878
+ 162,
879
+ 199,
880
+ 203,
881
+ 202,
882
+ 209,
883
+ 204,
884
+ 207,
885
+ 220,
886
+ 197,
887
+ 200,
888
+ 212,
889
+ 215,
890
+ 218,
891
+ 214,
892
+ 219,
893
+ 211,
894
+ 193,
895
+ 238,
896
+ 240,
897
+ 231,
898
+ 224,
899
+ 227,
900
+ 226,
901
+ 251,
902
+ 253,
903
+ 254,
904
+ 252,
905
+ 232,
906
+ 249,
907
+ 244,
908
+ 247,
909
+ 248,
910
+ 225
911
+ ],
912
+ "layer_8": [
913
+ 21,
914
+ 12,
915
+ 24,
916
+ 13,
917
+ 0,
918
+ 22,
919
+ 18,
920
+ 8,
921
+ 15,
922
+ 7,
923
+ 17,
924
+ 5,
925
+ 2,
926
+ 16,
927
+ 6,
928
+ 9,
929
+ 42,
930
+ 50,
931
+ 33,
932
+ 58,
933
+ 56,
934
+ 47,
935
+ 34,
936
+ 60,
937
+ 54,
938
+ 32,
939
+ 62,
940
+ 55,
941
+ 41,
942
+ 43,
943
+ 48,
944
+ 45,
945
+ 67,
946
+ 71,
947
+ 80,
948
+ 93,
949
+ 87,
950
+ 76,
951
+ 69,
952
+ 72,
953
+ 79,
954
+ 78,
955
+ 90,
956
+ 77,
957
+ 82,
958
+ 92,
959
+ 81,
960
+ 83,
961
+ 126,
962
+ 120,
963
+ 101,
964
+ 110,
965
+ 97,
966
+ 124,
967
+ 112,
968
+ 122,
969
+ 117,
970
+ 102,
971
+ 115,
972
+ 121,
973
+ 104,
974
+ 99,
975
+ 96,
976
+ 111,
977
+ 143,
978
+ 158,
979
+ 136,
980
+ 138,
981
+ 146,
982
+ 153,
983
+ 137,
984
+ 150,
985
+ 130,
986
+ 135,
987
+ 151,
988
+ 132,
989
+ 142,
990
+ 152,
991
+ 154,
992
+ 131,
993
+ 186,
994
+ 177,
995
+ 191,
996
+ 172,
997
+ 181,
998
+ 175,
999
+ 167,
1000
+ 179,
1001
+ 190,
1002
+ 188,
1003
+ 171,
1004
+ 170,
1005
+ 189,
1006
+ 161,
1007
+ 187,
1008
+ 173,
1009
+ 209,
1010
+ 207,
1011
+ 223,
1012
+ 214,
1013
+ 215,
1014
+ 196,
1015
+ 205,
1016
+ 194,
1017
+ 192,
1018
+ 193,
1019
+ 202,
1020
+ 213,
1021
+ 217,
1022
+ 222,
1023
+ 219,
1024
+ 221,
1025
+ 254,
1026
+ 226,
1027
+ 249,
1028
+ 229,
1029
+ 244,
1030
+ 253,
1031
+ 250,
1032
+ 224,
1033
+ 248,
1034
+ 251,
1035
+ 235,
1036
+ 232,
1037
+ 243,
1038
+ 227,
1039
+ 238,
1040
+ 230
1041
+ ],
1042
+ "layer_9": [
1043
+ 27,
1044
+ 29,
1045
+ 26,
1046
+ 16,
1047
+ 4,
1048
+ 0,
1049
+ 13,
1050
+ 28,
1051
+ 5,
1052
+ 11,
1053
+ 24,
1054
+ 19,
1055
+ 21,
1056
+ 7,
1057
+ 30,
1058
+ 15,
1059
+ 33,
1060
+ 51,
1061
+ 40,
1062
+ 37,
1063
+ 38,
1064
+ 43,
1065
+ 48,
1066
+ 49,
1067
+ 61,
1068
+ 56,
1069
+ 54,
1070
+ 59,
1071
+ 39,
1072
+ 52,
1073
+ 63,
1074
+ 50,
1075
+ 93,
1076
+ 80,
1077
+ 83,
1078
+ 79,
1079
+ 78,
1080
+ 77,
1081
+ 74,
1082
+ 87,
1083
+ 95,
1084
+ 72,
1085
+ 94,
1086
+ 92,
1087
+ 90,
1088
+ 73,
1089
+ 86,
1090
+ 69,
1091
+ 120,
1092
+ 122,
1093
+ 99,
1094
+ 123,
1095
+ 96,
1096
+ 124,
1097
+ 112,
1098
+ 103,
1099
+ 108,
1100
+ 114,
1101
+ 98,
1102
+ 110,
1103
+ 101,
1104
+ 113,
1105
+ 117,
1106
+ 105,
1107
+ 137,
1108
+ 156,
1109
+ 131,
1110
+ 150,
1111
+ 129,
1112
+ 151,
1113
+ 159,
1114
+ 146,
1115
+ 135,
1116
+ 141,
1117
+ 132,
1118
+ 139,
1119
+ 158,
1120
+ 140,
1121
+ 152,
1122
+ 153,
1123
+ 181,
1124
+ 169,
1125
+ 191,
1126
+ 162,
1127
+ 184,
1128
+ 161,
1129
+ 170,
1130
+ 185,
1131
+ 164,
1132
+ 177,
1133
+ 183,
1134
+ 186,
1135
+ 160,
1136
+ 166,
1137
+ 175,
1138
+ 176,
1139
+ 203,
1140
+ 222,
1141
+ 216,
1142
+ 209,
1143
+ 218,
1144
+ 195,
1145
+ 204,
1146
+ 220,
1147
+ 214,
1148
+ 193,
1149
+ 205,
1150
+ 192,
1151
+ 215,
1152
+ 197,
1153
+ 221,
1154
+ 211,
1155
+ 237,
1156
+ 230,
1157
+ 228,
1158
+ 229,
1159
+ 225,
1160
+ 248,
1161
+ 234,
1162
+ 233,
1163
+ 246,
1164
+ 245,
1165
+ 226,
1166
+ 227,
1167
+ 236,
1168
+ 252,
1169
+ 240,
1170
+ 241
1171
+ ],
1172
+ "layer_10": [
1173
+ 18,
1174
+ 12,
1175
+ 15,
1176
+ 6,
1177
+ 16,
1178
+ 20,
1179
+ 25,
1180
+ 24,
1181
+ 7,
1182
+ 9,
1183
+ 21,
1184
+ 0,
1185
+ 23,
1186
+ 13,
1187
+ 26,
1188
+ 2,
1189
+ 44,
1190
+ 34,
1191
+ 62,
1192
+ 47,
1193
+ 63,
1194
+ 38,
1195
+ 40,
1196
+ 55,
1197
+ 35,
1198
+ 41,
1199
+ 53,
1200
+ 58,
1201
+ 39,
1202
+ 37,
1203
+ 50,
1204
+ 51,
1205
+ 89,
1206
+ 78,
1207
+ 93,
1208
+ 65,
1209
+ 64,
1210
+ 90,
1211
+ 80,
1212
+ 83,
1213
+ 95,
1214
+ 84,
1215
+ 79,
1216
+ 86,
1217
+ 91,
1218
+ 74,
1219
+ 81,
1220
+ 67,
1221
+ 104,
1222
+ 116,
1223
+ 126,
1224
+ 102,
1225
+ 111,
1226
+ 115,
1227
+ 119,
1228
+ 121,
1229
+ 109,
1230
+ 103,
1231
+ 122,
1232
+ 110,
1233
+ 100,
1234
+ 107,
1235
+ 108,
1236
+ 101,
1237
+ 143,
1238
+ 154,
1239
+ 131,
1240
+ 138,
1241
+ 130,
1242
+ 142,
1243
+ 155,
1244
+ 151,
1245
+ 159,
1246
+ 133,
1247
+ 134,
1248
+ 129,
1249
+ 150,
1250
+ 135,
1251
+ 149,
1252
+ 153,
1253
+ 183,
1254
+ 167,
1255
+ 174,
1256
+ 166,
1257
+ 175,
1258
+ 179,
1259
+ 164,
1260
+ 188,
1261
+ 176,
1262
+ 181,
1263
+ 160,
1264
+ 184,
1265
+ 185,
1266
+ 165,
1267
+ 173,
1268
+ 189,
1269
+ 218,
1270
+ 196,
1271
+ 201,
1272
+ 193,
1273
+ 211,
1274
+ 223,
1275
+ 212,
1276
+ 216,
1277
+ 219,
1278
+ 208,
1279
+ 213,
1280
+ 205,
1281
+ 207,
1282
+ 220,
1283
+ 199,
1284
+ 214,
1285
+ 253,
1286
+ 231,
1287
+ 232,
1288
+ 251,
1289
+ 230,
1290
+ 250,
1291
+ 247,
1292
+ 244,
1293
+ 226,
1294
+ 246,
1295
+ 241,
1296
+ 227,
1297
+ 225,
1298
+ 249,
1299
+ 229,
1300
+ 254
1301
+ ],
1302
+ "layer_11": [
1303
+ 23,
1304
+ 14,
1305
+ 3,
1306
+ 16,
1307
+ 17,
1308
+ 2,
1309
+ 6,
1310
+ 18,
1311
+ 31,
1312
+ 29,
1313
+ 4,
1314
+ 0,
1315
+ 8,
1316
+ 30,
1317
+ 5,
1318
+ 21,
1319
+ 62,
1320
+ 49,
1321
+ 55,
1322
+ 54,
1323
+ 60,
1324
+ 48,
1325
+ 45,
1326
+ 51,
1327
+ 53,
1328
+ 58,
1329
+ 46,
1330
+ 37,
1331
+ 35,
1332
+ 47,
1333
+ 32,
1334
+ 36,
1335
+ 94,
1336
+ 79,
1337
+ 90,
1338
+ 70,
1339
+ 95,
1340
+ 88,
1341
+ 91,
1342
+ 84,
1343
+ 87,
1344
+ 93,
1345
+ 81,
1346
+ 64,
1347
+ 82,
1348
+ 89,
1349
+ 66,
1350
+ 83,
1351
+ 109,
1352
+ 115,
1353
+ 124,
1354
+ 99,
1355
+ 105,
1356
+ 127,
1357
+ 106,
1358
+ 121,
1359
+ 97,
1360
+ 100,
1361
+ 108,
1362
+ 98,
1363
+ 125,
1364
+ 103,
1365
+ 120,
1366
+ 102,
1367
+ 128,
1368
+ 155,
1369
+ 129,
1370
+ 136,
1371
+ 138,
1372
+ 146,
1373
+ 148,
1374
+ 133,
1375
+ 132,
1376
+ 158,
1377
+ 137,
1378
+ 156,
1379
+ 142,
1380
+ 141,
1381
+ 143,
1382
+ 134,
1383
+ 170,
1384
+ 180,
1385
+ 179,
1386
+ 183,
1387
+ 169,
1388
+ 184,
1389
+ 190,
1390
+ 175,
1391
+ 185,
1392
+ 181,
1393
+ 160,
1394
+ 165,
1395
+ 172,
1396
+ 171,
1397
+ 168,
1398
+ 167,
1399
+ 192,
1400
+ 199,
1401
+ 214,
1402
+ 194,
1403
+ 202,
1404
+ 204,
1405
+ 223,
1406
+ 215,
1407
+ 205,
1408
+ 221,
1409
+ 208,
1410
+ 195,
1411
+ 200,
1412
+ 212,
1413
+ 196,
1414
+ 210,
1415
+ 236,
1416
+ 235,
1417
+ 252,
1418
+ 225,
1419
+ 227,
1420
+ 234,
1421
+ 241,
1422
+ 253,
1423
+ 228,
1424
+ 242,
1425
+ 249,
1426
+ 248,
1427
+ 244,
1428
+ 254,
1429
+ 231,
1430
+ 233
1431
+ ],
1432
+ "layer_12": [
1433
+ 24,
1434
+ 10,
1435
+ 25,
1436
+ 14,
1437
+ 8,
1438
+ 5,
1439
+ 1,
1440
+ 20,
1441
+ 30,
1442
+ 16,
1443
+ 7,
1444
+ 22,
1445
+ 23,
1446
+ 15,
1447
+ 13,
1448
+ 21,
1449
+ 61,
1450
+ 50,
1451
+ 36,
1452
+ 42,
1453
+ 56,
1454
+ 60,
1455
+ 34,
1456
+ 35,
1457
+ 53,
1458
+ 39,
1459
+ 37,
1460
+ 45,
1461
+ 48,
1462
+ 59,
1463
+ 40,
1464
+ 51,
1465
+ 87,
1466
+ 74,
1467
+ 90,
1468
+ 89,
1469
+ 67,
1470
+ 72,
1471
+ 79,
1472
+ 95,
1473
+ 71,
1474
+ 94,
1475
+ 78,
1476
+ 86,
1477
+ 65,
1478
+ 64,
1479
+ 91,
1480
+ 69,
1481
+ 96,
1482
+ 102,
1483
+ 118,
1484
+ 109,
1485
+ 123,
1486
+ 105,
1487
+ 108,
1488
+ 106,
1489
+ 120,
1490
+ 117,
1491
+ 115,
1492
+ 103,
1493
+ 114,
1494
+ 97,
1495
+ 119,
1496
+ 107,
1497
+ 128,
1498
+ 148,
1499
+ 152,
1500
+ 158,
1501
+ 145,
1502
+ 151,
1503
+ 138,
1504
+ 149,
1505
+ 154,
1506
+ 157,
1507
+ 142,
1508
+ 133,
1509
+ 143,
1510
+ 156,
1511
+ 131,
1512
+ 147,
1513
+ 169,
1514
+ 176,
1515
+ 173,
1516
+ 180,
1517
+ 163,
1518
+ 164,
1519
+ 165,
1520
+ 160,
1521
+ 190,
1522
+ 177,
1523
+ 187,
1524
+ 168,
1525
+ 182,
1526
+ 171,
1527
+ 172,
1528
+ 191,
1529
+ 199,
1530
+ 218,
1531
+ 221,
1532
+ 210,
1533
+ 211,
1534
+ 203,
1535
+ 212,
1536
+ 202,
1537
+ 219,
1538
+ 208,
1539
+ 197,
1540
+ 200,
1541
+ 214,
1542
+ 205,
1543
+ 217,
1544
+ 213,
1545
+ 251,
1546
+ 249,
1547
+ 230,
1548
+ 228,
1549
+ 252,
1550
+ 255,
1551
+ 231,
1552
+ 226,
1553
+ 225,
1554
+ 246,
1555
+ 247,
1556
+ 233,
1557
+ 250,
1558
+ 242,
1559
+ 245,
1560
+ 229
1561
+ ],
1562
+ "layer_13": [
1563
+ 7,
1564
+ 23,
1565
+ 11,
1566
+ 26,
1567
+ 3,
1568
+ 15,
1569
+ 12,
1570
+ 17,
1571
+ 24,
1572
+ 21,
1573
+ 22,
1574
+ 27,
1575
+ 1,
1576
+ 2,
1577
+ 9,
1578
+ 8,
1579
+ 43,
1580
+ 58,
1581
+ 38,
1582
+ 53,
1583
+ 32,
1584
+ 51,
1585
+ 36,
1586
+ 60,
1587
+ 40,
1588
+ 61,
1589
+ 41,
1590
+ 48,
1591
+ 54,
1592
+ 49,
1593
+ 50,
1594
+ 55,
1595
+ 67,
1596
+ 87,
1597
+ 81,
1598
+ 83,
1599
+ 68,
1600
+ 65,
1601
+ 80,
1602
+ 86,
1603
+ 64,
1604
+ 92,
1605
+ 72,
1606
+ 94,
1607
+ 85,
1608
+ 89,
1609
+ 77,
1610
+ 66,
1611
+ 105,
1612
+ 106,
1613
+ 96,
1614
+ 100,
1615
+ 109,
1616
+ 99,
1617
+ 127,
1618
+ 124,
1619
+ 101,
1620
+ 113,
1621
+ 102,
1622
+ 110,
1623
+ 126,
1624
+ 120,
1625
+ 108,
1626
+ 115,
1627
+ 142,
1628
+ 139,
1629
+ 130,
1630
+ 133,
1631
+ 148,
1632
+ 150,
1633
+ 135,
1634
+ 159,
1635
+ 149,
1636
+ 153,
1637
+ 158,
1638
+ 141,
1639
+ 147,
1640
+ 155,
1641
+ 131,
1642
+ 156,
1643
+ 164,
1644
+ 186,
1645
+ 173,
1646
+ 170,
1647
+ 174,
1648
+ 172,
1649
+ 183,
1650
+ 187,
1651
+ 177,
1652
+ 167,
1653
+ 178,
1654
+ 166,
1655
+ 176,
1656
+ 165,
1657
+ 191,
1658
+ 161,
1659
+ 200,
1660
+ 223,
1661
+ 215,
1662
+ 201,
1663
+ 196,
1664
+ 212,
1665
+ 207,
1666
+ 205,
1667
+ 211,
1668
+ 218,
1669
+ 219,
1670
+ 221,
1671
+ 206,
1672
+ 222,
1673
+ 208,
1674
+ 213,
1675
+ 246,
1676
+ 226,
1677
+ 238,
1678
+ 235,
1679
+ 242,
1680
+ 239,
1681
+ 232,
1682
+ 255,
1683
+ 227,
1684
+ 231,
1685
+ 230,
1686
+ 252,
1687
+ 224,
1688
+ 243,
1689
+ 237,
1690
+ 225
1691
+ ],
1692
+ "layer_14": [
1693
+ 19,
1694
+ 2,
1695
+ 12,
1696
+ 16,
1697
+ 3,
1698
+ 31,
1699
+ 6,
1700
+ 8,
1701
+ 7,
1702
+ 24,
1703
+ 20,
1704
+ 29,
1705
+ 17,
1706
+ 21,
1707
+ 9,
1708
+ 26,
1709
+ 44,
1710
+ 61,
1711
+ 59,
1712
+ 33,
1713
+ 45,
1714
+ 58,
1715
+ 48,
1716
+ 54,
1717
+ 49,
1718
+ 35,
1719
+ 55,
1720
+ 43,
1721
+ 53,
1722
+ 63,
1723
+ 39,
1724
+ 41,
1725
+ 70,
1726
+ 69,
1727
+ 85,
1728
+ 76,
1729
+ 73,
1730
+ 81,
1731
+ 94,
1732
+ 88,
1733
+ 82,
1734
+ 91,
1735
+ 64,
1736
+ 78,
1737
+ 75,
1738
+ 80,
1739
+ 95,
1740
+ 83,
1741
+ 113,
1742
+ 110,
1743
+ 126,
1744
+ 106,
1745
+ 119,
1746
+ 104,
1747
+ 125,
1748
+ 103,
1749
+ 97,
1750
+ 107,
1751
+ 98,
1752
+ 118,
1753
+ 96,
1754
+ 108,
1755
+ 102,
1756
+ 109,
1757
+ 136,
1758
+ 151,
1759
+ 156,
1760
+ 158,
1761
+ 147,
1762
+ 132,
1763
+ 130,
1764
+ 153,
1765
+ 141,
1766
+ 140,
1767
+ 138,
1768
+ 155,
1769
+ 145,
1770
+ 131,
1771
+ 143,
1772
+ 146,
1773
+ 181,
1774
+ 183,
1775
+ 180,
1776
+ 169,
1777
+ 175,
1778
+ 174,
1779
+ 171,
1780
+ 168,
1781
+ 166,
1782
+ 190,
1783
+ 188,
1784
+ 173,
1785
+ 189,
1786
+ 187,
1787
+ 178,
1788
+ 185,
1789
+ 214,
1790
+ 205,
1791
+ 207,
1792
+ 209,
1793
+ 221,
1794
+ 201,
1795
+ 217,
1796
+ 206,
1797
+ 192,
1798
+ 211,
1799
+ 216,
1800
+ 203,
1801
+ 199,
1802
+ 208,
1803
+ 218,
1804
+ 194,
1805
+ 255,
1806
+ 246,
1807
+ 224,
1808
+ 230,
1809
+ 250,
1810
+ 240,
1811
+ 225,
1812
+ 253,
1813
+ 247,
1814
+ 254,
1815
+ 251,
1816
+ 252,
1817
+ 238,
1818
+ 236,
1819
+ 228,
1820
+ 239
1821
+ ],
1822
+ "layer_15": [
1823
+ 5,
1824
+ 9,
1825
+ 31,
1826
+ 14,
1827
+ 29,
1828
+ 11,
1829
+ 13,
1830
+ 10,
1831
+ 8,
1832
+ 12,
1833
+ 27,
1834
+ 22,
1835
+ 19,
1836
+ 7,
1837
+ 2,
1838
+ 3,
1839
+ 56,
1840
+ 47,
1841
+ 43,
1842
+ 61,
1843
+ 45,
1844
+ 58,
1845
+ 41,
1846
+ 36,
1847
+ 51,
1848
+ 63,
1849
+ 39,
1850
+ 33,
1851
+ 35,
1852
+ 34,
1853
+ 40,
1854
+ 57,
1855
+ 79,
1856
+ 77,
1857
+ 85,
1858
+ 86,
1859
+ 73,
1860
+ 75,
1861
+ 89,
1862
+ 92,
1863
+ 66,
1864
+ 95,
1865
+ 94,
1866
+ 90,
1867
+ 87,
1868
+ 80,
1869
+ 67,
1870
+ 71,
1871
+ 110,
1872
+ 96,
1873
+ 104,
1874
+ 102,
1875
+ 124,
1876
+ 126,
1877
+ 115,
1878
+ 113,
1879
+ 120,
1880
+ 122,
1881
+ 98,
1882
+ 99,
1883
+ 107,
1884
+ 105,
1885
+ 123,
1886
+ 127,
1887
+ 150,
1888
+ 155,
1889
+ 139,
1890
+ 134,
1891
+ 141,
1892
+ 144,
1893
+ 146,
1894
+ 148,
1895
+ 159,
1896
+ 145,
1897
+ 142,
1898
+ 129,
1899
+ 152,
1900
+ 130,
1901
+ 154,
1902
+ 157,
1903
+ 185,
1904
+ 182,
1905
+ 167,
1906
+ 179,
1907
+ 181,
1908
+ 171,
1909
+ 186,
1910
+ 177,
1911
+ 178,
1912
+ 165,
1913
+ 173,
1914
+ 162,
1915
+ 180,
1916
+ 175,
1917
+ 191,
1918
+ 164,
1919
+ 197,
1920
+ 205,
1921
+ 219,
1922
+ 194,
1923
+ 214,
1924
+ 198,
1925
+ 217,
1926
+ 196,
1927
+ 204,
1928
+ 222,
1929
+ 213,
1930
+ 210,
1931
+ 202,
1932
+ 207,
1933
+ 199,
1934
+ 223,
1935
+ 228,
1936
+ 248,
1937
+ 234,
1938
+ 251,
1939
+ 250,
1940
+ 227,
1941
+ 237,
1942
+ 243,
1943
+ 246,
1944
+ 254,
1945
+ 231,
1946
+ 230,
1947
+ 239,
1948
+ 240,
1949
+ 225,
1950
+ 224
1951
+ ],
1952
+ "layer_16": [
1953
+ 12,
1954
+ 1,
1955
+ 6,
1956
+ 29,
1957
+ 8,
1958
+ 14,
1959
+ 27,
1960
+ 18,
1961
+ 3,
1962
+ 15,
1963
+ 20,
1964
+ 31,
1965
+ 5,
1966
+ 4,
1967
+ 26,
1968
+ 10,
1969
+ 36,
1970
+ 59,
1971
+ 48,
1972
+ 54,
1973
+ 41,
1974
+ 49,
1975
+ 46,
1976
+ 53,
1977
+ 37,
1978
+ 50,
1979
+ 33,
1980
+ 44,
1981
+ 42,
1982
+ 38,
1983
+ 52,
1984
+ 35,
1985
+ 86,
1986
+ 68,
1987
+ 93,
1988
+ 71,
1989
+ 85,
1990
+ 79,
1991
+ 70,
1992
+ 78,
1993
+ 72,
1994
+ 83,
1995
+ 77,
1996
+ 74,
1997
+ 91,
1998
+ 89,
1999
+ 95,
2000
+ 65,
2001
+ 98,
2002
+ 103,
2003
+ 96,
2004
+ 108,
2005
+ 102,
2006
+ 124,
2007
+ 99,
2008
+ 127,
2009
+ 100,
2010
+ 97,
2011
+ 101,
2012
+ 125,
2013
+ 116,
2014
+ 105,
2015
+ 111,
2016
+ 112,
2017
+ 138,
2018
+ 147,
2019
+ 137,
2020
+ 149,
2021
+ 136,
2022
+ 143,
2023
+ 140,
2024
+ 151,
2025
+ 135,
2026
+ 128,
2027
+ 141,
2028
+ 134,
2029
+ 145,
2030
+ 139,
2031
+ 142,
2032
+ 129,
2033
+ 170,
2034
+ 160,
2035
+ 182,
2036
+ 185,
2037
+ 163,
2038
+ 191,
2039
+ 169,
2040
+ 171,
2041
+ 186,
2042
+ 189,
2043
+ 187,
2044
+ 178,
2045
+ 190,
2046
+ 179,
2047
+ 168,
2048
+ 174,
2049
+ 213,
2050
+ 211,
2051
+ 194,
2052
+ 221,
2053
+ 204,
2054
+ 192,
2055
+ 212,
2056
+ 218,
2057
+ 205,
2058
+ 217,
2059
+ 198,
2060
+ 216,
2061
+ 193,
2062
+ 203,
2063
+ 220,
2064
+ 195,
2065
+ 231,
2066
+ 247,
2067
+ 250,
2068
+ 235,
2069
+ 224,
2070
+ 241,
2071
+ 251,
2072
+ 245,
2073
+ 248,
2074
+ 227,
2075
+ 252,
2076
+ 244,
2077
+ 234,
2078
+ 253,
2079
+ 243,
2080
+ 230
2081
+ ],
2082
+ "layer_17": [
2083
+ 24,
2084
+ 17,
2085
+ 22,
2086
+ 0,
2087
+ 6,
2088
+ 8,
2089
+ 2,
2090
+ 4,
2091
+ 14,
2092
+ 15,
2093
+ 9,
2094
+ 7,
2095
+ 29,
2096
+ 12,
2097
+ 11,
2098
+ 28,
2099
+ 37,
2100
+ 33,
2101
+ 59,
2102
+ 49,
2103
+ 45,
2104
+ 51,
2105
+ 53,
2106
+ 50,
2107
+ 43,
2108
+ 57,
2109
+ 34,
2110
+ 38,
2111
+ 44,
2112
+ 52,
2113
+ 46,
2114
+ 36,
2115
+ 80,
2116
+ 85,
2117
+ 86,
2118
+ 81,
2119
+ 68,
2120
+ 71,
2121
+ 67,
2122
+ 75,
2123
+ 88,
2124
+ 93,
2125
+ 74,
2126
+ 64,
2127
+ 77,
2128
+ 70,
2129
+ 83,
2130
+ 90,
2131
+ 109,
2132
+ 111,
2133
+ 103,
2134
+ 107,
2135
+ 123,
2136
+ 125,
2137
+ 116,
2138
+ 126,
2139
+ 114,
2140
+ 117,
2141
+ 104,
2142
+ 108,
2143
+ 118,
2144
+ 101,
2145
+ 99,
2146
+ 113,
2147
+ 147,
2148
+ 136,
2149
+ 146,
2150
+ 143,
2151
+ 154,
2152
+ 130,
2153
+ 135,
2154
+ 133,
2155
+ 128,
2156
+ 142,
2157
+ 153,
2158
+ 134,
2159
+ 129,
2160
+ 131,
2161
+ 159,
2162
+ 139,
2163
+ 165,
2164
+ 162,
2165
+ 177,
2166
+ 184,
2167
+ 171,
2168
+ 185,
2169
+ 161,
2170
+ 176,
2171
+ 183,
2172
+ 170,
2173
+ 169,
2174
+ 188,
2175
+ 172,
2176
+ 187,
2177
+ 167,
2178
+ 179,
2179
+ 204,
2180
+ 193,
2181
+ 220,
2182
+ 222,
2183
+ 213,
2184
+ 217,
2185
+ 214,
2186
+ 206,
2187
+ 197,
2188
+ 194,
2189
+ 198,
2190
+ 215,
2191
+ 195,
2192
+ 209,
2193
+ 199,
2194
+ 211,
2195
+ 239,
2196
+ 227,
2197
+ 224,
2198
+ 250,
2199
+ 233,
2200
+ 235,
2201
+ 231,
2202
+ 251,
2203
+ 234,
2204
+ 229,
2205
+ 238,
2206
+ 247,
2207
+ 225,
2208
+ 245,
2209
+ 236,
2210
+ 241
2211
+ ],
2212
+ "layer_18": [
2213
+ 25,
2214
+ 22,
2215
+ 30,
2216
+ 29,
2217
+ 1,
2218
+ 19,
2219
+ 9,
2220
+ 10,
2221
+ 23,
2222
+ 28,
2223
+ 12,
2224
+ 16,
2225
+ 4,
2226
+ 24,
2227
+ 2,
2228
+ 17,
2229
+ 39,
2230
+ 51,
2231
+ 42,
2232
+ 46,
2233
+ 61,
2234
+ 43,
2235
+ 60,
2236
+ 50,
2237
+ 37,
2238
+ 55,
2239
+ 58,
2240
+ 40,
2241
+ 54,
2242
+ 34,
2243
+ 44,
2244
+ 62,
2245
+ 64,
2246
+ 78,
2247
+ 77,
2248
+ 86,
2249
+ 89,
2250
+ 65,
2251
+ 70,
2252
+ 69,
2253
+ 93,
2254
+ 83,
2255
+ 95,
2256
+ 81,
2257
+ 94,
2258
+ 71,
2259
+ 84,
2260
+ 75,
2261
+ 114,
2262
+ 123,
2263
+ 124,
2264
+ 127,
2265
+ 120,
2266
+ 103,
2267
+ 106,
2268
+ 119,
2269
+ 97,
2270
+ 107,
2271
+ 121,
2272
+ 122,
2273
+ 115,
2274
+ 99,
2275
+ 110,
2276
+ 96,
2277
+ 145,
2278
+ 158,
2279
+ 148,
2280
+ 142,
2281
+ 132,
2282
+ 129,
2283
+ 154,
2284
+ 146,
2285
+ 150,
2286
+ 152,
2287
+ 136,
2288
+ 131,
2289
+ 147,
2290
+ 128,
2291
+ 130,
2292
+ 156,
2293
+ 170,
2294
+ 171,
2295
+ 163,
2296
+ 161,
2297
+ 185,
2298
+ 172,
2299
+ 174,
2300
+ 180,
2301
+ 179,
2302
+ 166,
2303
+ 164,
2304
+ 169,
2305
+ 173,
2306
+ 191,
2307
+ 183,
2308
+ 187,
2309
+ 192,
2310
+ 203,
2311
+ 216,
2312
+ 220,
2313
+ 215,
2314
+ 202,
2315
+ 213,
2316
+ 218,
2317
+ 209,
2318
+ 206,
2319
+ 208,
2320
+ 200,
2321
+ 219,
2322
+ 195,
2323
+ 193,
2324
+ 201,
2325
+ 227,
2326
+ 228,
2327
+ 234,
2328
+ 251,
2329
+ 243,
2330
+ 230,
2331
+ 240,
2332
+ 254,
2333
+ 252,
2334
+ 232,
2335
+ 250,
2336
+ 246,
2337
+ 236,
2338
+ 233,
2339
+ 226,
2340
+ 229
2341
+ ],
2342
+ "layer_19": [
2343
+ 2,
2344
+ 14,
2345
+ 20,
2346
+ 28,
2347
+ 12,
2348
+ 17,
2349
+ 24,
2350
+ 19,
2351
+ 27,
2352
+ 29,
2353
+ 21,
2354
+ 5,
2355
+ 30,
2356
+ 31,
2357
+ 16,
2358
+ 4,
2359
+ 49,
2360
+ 42,
2361
+ 52,
2362
+ 50,
2363
+ 54,
2364
+ 38,
2365
+ 36,
2366
+ 53,
2367
+ 43,
2368
+ 47,
2369
+ 58,
2370
+ 56,
2371
+ 62,
2372
+ 46,
2373
+ 61,
2374
+ 35,
2375
+ 75,
2376
+ 71,
2377
+ 78,
2378
+ 72,
2379
+ 68,
2380
+ 86,
2381
+ 66,
2382
+ 64,
2383
+ 95,
2384
+ 89,
2385
+ 82,
2386
+ 85,
2387
+ 83,
2388
+ 90,
2389
+ 69,
2390
+ 80,
2391
+ 121,
2392
+ 118,
2393
+ 104,
2394
+ 107,
2395
+ 127,
2396
+ 114,
2397
+ 96,
2398
+ 102,
2399
+ 115,
2400
+ 124,
2401
+ 105,
2402
+ 97,
2403
+ 108,
2404
+ 109,
2405
+ 117,
2406
+ 125,
2407
+ 137,
2408
+ 133,
2409
+ 140,
2410
+ 149,
2411
+ 134,
2412
+ 146,
2413
+ 151,
2414
+ 131,
2415
+ 129,
2416
+ 153,
2417
+ 147,
2418
+ 128,
2419
+ 132,
2420
+ 136,
2421
+ 156,
2422
+ 130,
2423
+ 172,
2424
+ 177,
2425
+ 164,
2426
+ 190,
2427
+ 188,
2428
+ 181,
2429
+ 182,
2430
+ 183,
2431
+ 189,
2432
+ 191,
2433
+ 174,
2434
+ 173,
2435
+ 167,
2436
+ 175,
2437
+ 176,
2438
+ 166,
2439
+ 216,
2440
+ 194,
2441
+ 222,
2442
+ 219,
2443
+ 207,
2444
+ 205,
2445
+ 215,
2446
+ 206,
2447
+ 211,
2448
+ 213,
2449
+ 210,
2450
+ 197,
2451
+ 196,
2452
+ 218,
2453
+ 195,
2454
+ 202,
2455
+ 239,
2456
+ 231,
2457
+ 253,
2458
+ 237,
2459
+ 229,
2460
+ 242,
2461
+ 249,
2462
+ 232,
2463
+ 243,
2464
+ 255,
2465
+ 245,
2466
+ 228,
2467
+ 235,
2468
+ 238,
2469
+ 252,
2470
+ 225
2471
+ ]
2472
+ }
generation_config.json CHANGED
@@ -1,9 +1,9 @@
1
  {
2
- "bos_token_id": 156891,
3
- "eos_token_id": [
4
- 156892,
5
- 156895
6
- ],
7
- "pad_token_id": 156892,
8
- "transformers_version": "4.52.3"
9
  }
 
1
  {
2
+ "bos_token_id": 156891,
3
+ "eos_token_id": [
4
+ 156892,
5
+ 156895
6
+ ],
7
+ "pad_token_id": 156892,
8
+ "transformers_version": "4.56.2"
9
  }
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cae8ccb790ea396e88288a81e62356445631c34020744690f133d67bf2e9c494
3
+ size 4998340808
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a461d1c12b98b5bd67e7b00f6f36bef0d7c2cd46a98adff63e73a7e60aee387
3
+ size 4998907736
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c92b3d0a351c1ab831365415fd7278a2f1b81f777ce62421971108243ef2a78
3
+ size 4998909232
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd15d9dc0dc949a6b508fc2dba53ce732a385695d8dcc37b756e810064bcc1d8
3
+ size 2205269520
model.safetensors.index.json CHANGED
The diff for this file is too large to render. See raw diff
 
modeling_bailing_moe_v2.py CHANGED
@@ -48,7 +48,7 @@ from transformers.utils import (
48
  replace_return_docstrings,
49
  )
50
  from transformers.utils.import_utils import is_torch_fx_available
51
- from configuration_bailing_moe_v2 import BailingMoeV2Config
52
  from transformers.generation.utils import GenerationMixin
53
  from dataclasses import dataclass
54
  from transformers.utils import ModelOutput
@@ -1530,3 +1530,4 @@ class BailingMoeV2ForCausalLM(BailingMoeV2PreTrainedModel, GenerationMixin):
1530
  attentions=outputs.attentions,
1531
  router_logits=outputs.router_logits,
1532
  )
 
 
48
  replace_return_docstrings,
49
  )
50
  from transformers.utils.import_utils import is_torch_fx_available
51
+ from .configuration_bailing_moe_v2 import BailingMoeV2Config
52
  from transformers.generation.utils import GenerationMixin
53
  from dataclasses import dataclass
54
  from transformers.utils import ModelOutput
 
1530
  attentions=outputs.attentions,
1531
  router_logits=outputs.router_logits,
1532
  )
1533
+
pruning-code/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 inclusionAI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
pruning-code/calib.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
pruning-code/config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BailingMoeV2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_bailing_moe_v2.BailingMoeV2Config",
8
+ "AutoModel": "modeling_bailing_moe_v2.BailingMoeV2Model",
9
+ "AutoModelForCausalLM": "modeling_bailing_moe_v2.BailingMoeV2ForCausalLM"
10
+ },
11
+ "num_hidden_layers": 20,
12
+ "hidden_size": 2048,
13
+ "intermediate_size": 5120,
14
+ "eos_token_id": 156892,
15
+ "pad_token_id": 156892,
16
+ "first_k_dense_replace": 1,
17
+ "hidden_act": "silu",
18
+ "max_position_embeddings": 32768,
19
+ "model_type": "bailing_moe",
20
+ "moe_intermediate_size": 512,
21
+ "norm_topk_prob": true,
22
+ "num_experts_per_tok": 8,
23
+ "num_attention_heads": 16,
24
+ "num_experts": 256,
25
+ "num_key_value_heads": 4,
26
+ "rope_theta": 600000,
27
+ "rope_scaling": null,
28
+ "tie_word_embeddings": false,
29
+ "torch_dtype": "bfloat16",
30
+ "transformers_version": "4.52.3",
31
+ "use_bias": false,
32
+ "use_rmsnorm": true,
33
+ "rms_norm_eps": 1e-06,
34
+ "head_dim": 128,
35
+ "num_shared_experts": 1,
36
+ "use_cache": true,
37
+ "use_qkv_bias": false,
38
+ "embedding_dropout": 0.0,
39
+ "output_dropout": 0.0,
40
+ "vocab_size": 157184,
41
+ "partial_rotary_factor": 0.5,
42
+ "router_dtype": "fp32",
43
+ "moe_router_enable_expert_bias": true,
44
+ "routed_scaling_factor": 2.5,
45
+ "n_group": 8,
46
+ "topk_group": 4,
47
+ "use_qk_norm": true,
48
+ "score_function": "sigmoid",
49
+ "moe_shared_expert_intermediate_size": 512
50
+ }
pruning-code/configuration_bailing_moe_v2.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Bailing MoE V2 model configuration"""
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+
5
+
6
+ class BailingMoeV2Config(PretrainedConfig):
7
+
8
+ def __init__(
9
+ self,
10
+ vocab_size=157184,
11
+ hidden_size=2048,
12
+ intermediate_size=5120,
13
+ num_hidden_layers=20,
14
+ num_attention_heads=16,
15
+ num_key_value_heads=4,
16
+ hidden_act="silu",
17
+ use_qkv_bias=False, # bailing only
18
+ use_bias=False, # bailing only
19
+ rms_norm_eps=1e-06,
20
+ tie_word_embeddings=False, # PretrainedConfig key, here change default value.
21
+ embedding_dropout=0.0,
22
+ attention_dropout=0.0,
23
+ output_dropout=0.0,
24
+ initializer_range=0.02,
25
+ max_position_embeddings=32768,
26
+ rope_theta=600000.0,
27
+ use_cache=True,
28
+ max_window_layers=20,
29
+ rope_scaling=None,
30
+ pad_token_id=156892,
31
+ eos_token_id=156892,
32
+ num_experts=256,
33
+ num_shared_experts=1,
34
+ num_experts_per_tok=8,
35
+ n_group=8,
36
+ topk_group=4,
37
+ moe_intermediate_size=512,
38
+ first_k_dense_replace=1,
39
+ head_dim=128,
40
+ output_router_logits=False,
41
+ use_qk_norm=True,
42
+ num_nextn_predict_layers=0,
43
+ mtp_loss_scaling_factor=0,
44
+ moe_router_enable_expert_bias=True,
45
+ routed_scaling_factor=1.0,
46
+ **kwargs,
47
+ ):
48
+ self.num_hidden_layers = num_hidden_layers
49
+ self.vocab_size = vocab_size
50
+ self.hidden_size = hidden_size
51
+ self.intermediate_size = intermediate_size
52
+ self.num_attention_heads = num_attention_heads
53
+ self.num_key_value_heads = num_key_value_heads
54
+ self.hidden_act = hidden_act
55
+ self.use_qkv_bias = use_qkv_bias
56
+ self.use_bias = use_bias
57
+ self.rms_norm_eps = rms_norm_eps
58
+ self.embedding_dropout = embedding_dropout
59
+ self.attention_dropout = attention_dropout
60
+ self.output_dropout = output_dropout
61
+ self.num_nextn_predict_layers = num_nextn_predict_layers
62
+ self.mtp_loss_scaling_factor = mtp_loss_scaling_factor
63
+ self.initializer_range = initializer_range
64
+ self.max_position_embeddings = max_position_embeddings
65
+ self.rope_theta = rope_theta
66
+ self.use_cache = use_cache
67
+ self.max_window_layers = max_window_layers
68
+ self.head_dim = head_dim or self.hidden_size // self.num_attention_heads
69
+ self.rope_scaling = rope_scaling
70
+ self.use_qk_norm = use_qk_norm
71
+ self.moe_router_enable_expert_bias = moe_router_enable_expert_bias
72
+ self.routed_scaling_factor = routed_scaling_factor
73
+
74
+ # MoE configs
75
+ self.num_experts = num_experts
76
+ self.num_shared_experts = num_shared_experts
77
+ self.num_experts_per_tok = num_experts_per_tok
78
+ self.n_group = n_group
79
+ self.topk_group = topk_group
80
+ self.moe_intermediate_size = moe_intermediate_size
81
+ self.first_k_dense_replace = first_k_dense_replace
82
+ self.output_router_logits = output_router_logits
83
+
84
+ super().__init__(pad_token_id=pad_token_id, eos_token_id=eos_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs)
pruning-code/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 156891,
3
+ "eos_token_id": [
4
+ 156892,
5
+ 156895
6
+ ],
7
+ "pad_token_id": 156892,
8
+ "transformers_version": "4.52.3"
9
+ }
pruning-code/model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
pruning-code/modeling_bailing_moe_v2.py ADDED
@@ -0,0 +1,1532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2025 Antgroup and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
5
+ # and OPT implementations in this library. It has been modified from its
6
+ # original forms to accommodate minor architectural differences compared
7
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ """PyTorch BailingMoE model."""
21
+
22
+ import math
23
+ import warnings
24
+ from typing import List, Optional, Tuple, Union
25
+
26
+ import torch
27
+ import torch.nn.functional as F
28
+ from torch import nn
29
+
30
+ from transformers.activations import ACT2FN
31
+ from transformers.cache_utils import Cache, DynamicCache
32
+ from transformers.modeling_attn_mask_utils import (
33
+ AttentionMaskConverter,
34
+ _prepare_4d_attention_mask,
35
+ _prepare_4d_causal_attention_mask,
36
+ _prepare_4d_causal_attention_mask_for_sdpa,
37
+ )
38
+ from transformers.modeling_outputs import MoeModelOutputWithPast
39
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
40
+ from transformers.modeling_utils import PreTrainedModel
41
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS, is_torch_greater_or_equal_than_1_13
42
+ from transformers.utils import (
43
+ add_start_docstrings,
44
+ add_start_docstrings_to_model_forward,
45
+ is_flash_attn_2_available,
46
+ is_flash_attn_greater_or_equal_2_10,
47
+ logging,
48
+ replace_return_docstrings,
49
+ )
50
+ from transformers.utils.import_utils import is_torch_fx_available
51
+ from configuration_bailing_moe_v2 import BailingMoeV2Config
52
+ from transformers.generation.utils import GenerationMixin
53
+ from dataclasses import dataclass
54
+ from transformers.utils import ModelOutput
55
+
56
+
57
+ if is_flash_attn_2_available():
58
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
59
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
60
+
61
+
62
+ # This makes `_prepare_4d_causal_attention_mask` a leaf function in the FX graph.
63
+ # It means that the function will not be traced through and simply appear as a node in the graph.
64
+ if is_torch_fx_available():
65
+ if not is_torch_greater_or_equal_than_1_13:
66
+ import torch.fx
67
+
68
+ _prepare_4d_causal_attention_mask = torch.fx.wrap(_prepare_4d_causal_attention_mask)
69
+
70
+
71
+ logger = logging.get_logger(__name__)
72
+
73
+ _CONFIG_FOR_DOC = "BailingMoeV2Config"
74
+
75
+
76
+ def roll_tensor(tensor, shifts=-1, dims=-1, fill_value=0):
77
+ """Roll the tensor input along the given dimension(s).
78
+ Inserted elements are set to be 0.0.
79
+ """
80
+ rolled_tensor = torch.roll(tensor, shifts=shifts, dims=dims)
81
+ rolled_tensor.select(dims, shifts).fill_(fill_value)
82
+ return rolled_tensor, rolled_tensor.sum()
83
+
84
+
85
+ @dataclass
86
+ class MoEV2CausalLMOutputWithPast(ModelOutput):
87
+ """
88
+ Base class for causal language model (or autoregressive) outputs as well as Mixture of Expert's router hidden
89
+ states terms, to train a MoE model.
90
+
91
+ Args:
92
+ loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
93
+ Language modeling loss (for next-token prediction).
94
+ logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
95
+ Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
96
+ past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
97
+ It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).
98
+
99
+ Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
100
+ `past_key_values` input) to speed up sequential decoding.
101
+ hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
102
+ Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
103
+ one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
104
+
105
+ Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
106
+ attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
107
+ Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
108
+ sequence_length)`.
109
+
110
+ Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
111
+ heads.
112
+ z_loss (`torch.FloatTensor`, *optional*, returned when `labels` is provided):
113
+ z_loss for the sparse modules.
114
+ aux_loss (`torch.FloatTensor`, *optional*, returned when `labels` is provided):
115
+ aux_loss for the sparse modules.
116
+ router_logits (`tuple(torch.FloatTensor)`, *optional*, returned when `output_router_logits=True` is passed or when `config.add_router_probs=True`):
117
+ Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, sequence_length, num_experts)`.
118
+
119
+ Router logits of the encoder model, useful to compute the auxiliary loss and the z_loss for the sparse
120
+ modules.
121
+ """
122
+
123
+ loss: Optional[torch.FloatTensor] = None
124
+ logits: Optional[torch.FloatTensor] = None
125
+ past_key_values: Optional[Cache] = None
126
+ hidden_states: Optional[tuple[torch.FloatTensor, ...]] = None
127
+ attentions: Optional[tuple[torch.FloatTensor, ...]] = None
128
+ z_loss: Optional[torch.FloatTensor] = None
129
+ aux_loss: Optional[torch.FloatTensor] = None
130
+ router_logits: Optional[tuple[torch.FloatTensor]] = None
131
+ mtp_loss: Optional[torch.FloatTensor] = None
132
+ mtp_logits: Optional[tuple[torch.FloatTensor, ...]] = None
133
+
134
+
135
+ class MoeV2ModelOutputWithPast(MoeModelOutputWithPast):
136
+
137
+ def __init__(self, mtp_hidden_states=None, **kwargs):
138
+ super().__init__(**kwargs)
139
+ self.mtp_hidden_states = mtp_hidden_states
140
+
141
+
142
+ def _get_unpad_data(attention_mask):
143
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
144
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
145
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
146
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
147
+ return (
148
+ indices,
149
+ cu_seqlens,
150
+ max_seqlen_in_batch,
151
+ )
152
+
153
+
154
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
155
+ warnings.warn(
156
+ "Calling `transformers.models.BailingMoeV2.modeling_BailingMoeV2._prepare_4d_attention_mask` is deprecated and will be removed in v4.37. Use `transformers.modeling_attn_mask_utils._prepare_4d_attention_mask"
157
+ )
158
+ return _prepare_4d_attention_mask(mask=mask, dtype=dtype, tgt_len=tgt_len)
159
+
160
+
161
+ def _make_causal_mask(
162
+ input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
163
+ ):
164
+ warnings.warn(
165
+ "Calling `transformers.models.BailingMoeV2.modeling_BailingMoeV2._make_causal_mask` is deprecated and will be removed in v4.37. Use `transformers.models.BailingMoeV2.modeling_BailingMoeV2.AttentionMaskConverter._make_causal_mask"
166
+ )
167
+ return AttentionMaskConverter._make_causal_mask(
168
+ input_ids_shape=input_ids_shape, dtype=dtype, device=device, past_key_values_length=past_key_values_length
169
+ )
170
+
171
+
172
+ class BailingMoeV2RMSNorm(nn.Module):
173
+ def __init__(self, hidden_size, eps=1e-6):
174
+ """
175
+ BailingMoeV2RMSNorm is equivalent to T5LayerNorm
176
+ """
177
+ super().__init__()
178
+ self.weight = nn.Parameter(torch.ones(hidden_size))
179
+ self.variance_epsilon = eps
180
+
181
+ def forward(self, hidden_states):
182
+ input_dtype = hidden_states.dtype
183
+ hidden_states = hidden_states.to(torch.float32)
184
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
185
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
186
+ return self.weight * hidden_states.to(input_dtype)
187
+
188
+
189
+ ALL_LAYERNORM_LAYERS.append(BailingMoeV2RMSNorm)
190
+
191
+
192
+ class BailingMoeV2RotaryEmbedding(nn.Module):
193
+ def __init__(self, config: BailingMoeV2Config, device=None):
194
+ super().__init__()
195
+ # BC: "rope_type" was originally "type"
196
+ if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
197
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
198
+ else:
199
+ self.rope_type = "default"
200
+ self.max_seq_len_cached = config.max_position_embeddings
201
+ self.original_max_seq_len = config.max_position_embeddings
202
+
203
+ self.config = config
204
+ self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
205
+
206
+ inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
207
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
208
+ self.original_inv_freq = self.inv_freq
209
+
210
+ @torch.no_grad()
211
+ @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
212
+ def forward(self, x, position_ids):
213
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
214
+ position_ids_expanded = position_ids[:, None, :].float()
215
+
216
+ device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
217
+ with torch.autocast(device_type=device_type, enabled=False): # Force float32
218
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
219
+ emb = torch.cat((freqs, freqs), dim=-1)
220
+ cos = emb.cos() * self.attention_scaling
221
+ sin = emb.sin() * self.attention_scaling
222
+
223
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
224
+
225
+
226
+ # Copied from transformers.models.llama.modeling_llama.rotate_half
227
+ def rotate_half(x):
228
+ """Rotates half the hidden dims of the input."""
229
+ x1 = x[..., : x.shape[-1] // 2]
230
+ x2 = x[..., x.shape[-1] // 2 :]
231
+ return torch.cat((-x2, x1), dim=-1)
232
+
233
+
234
+ # Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
235
+ def apply_rotary_pos_emb(q, k, cos, sin, unsqueeze_dim=1):
236
+ """Applies Rotary Position Embedding to the query and key tensors.
237
+
238
+ Args:
239
+ q (`torch.Tensor`): The query tensor.
240
+ k (`torch.Tensor`): The key tensor.
241
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
242
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
243
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
244
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
245
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
246
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
247
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
248
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
249
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
250
+ Returns:
251
+ `tuple(torch.Tensor)` comprising the query and key tensors rotated using the Rotary Position Embedding.
252
+ """
253
+ cos = cos.unsqueeze(unsqueeze_dim)
254
+ sin = sin.unsqueeze(unsqueeze_dim)
255
+
256
+ # Keep half or full tensor for later concatenation
257
+ rotary_dim = cos.shape[-1]
258
+ q_rot, q_pass = q[..., :rotary_dim], q[..., rotary_dim:]
259
+ k_rot, k_pass = k[..., :rotary_dim], k[..., rotary_dim:]
260
+
261
+ # Apply rotary embeddings on the first half or full tensor
262
+ q_embed = (q_rot * cos) + (rotate_half(q_rot) * sin)
263
+ k_embed = (k_rot * cos) + (rotate_half(k_rot) * sin)
264
+
265
+ # Concatenate back to full shape
266
+ q_embed = torch.cat([q_embed, q_pass], dim=-1)
267
+ k_embed = torch.cat([k_embed, k_pass], dim=-1)
268
+ return q_embed, k_embed
269
+
270
+
271
+ class BailingMoeV2MLP(nn.Module):
272
+ def __init__(self, config: BailingMoeV2Config, intermediate_size: int):
273
+ super().__init__()
274
+ self.config = config
275
+ self.hidden_size = config.hidden_size
276
+ self.intermediate_size = intermediate_size
277
+
278
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
279
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
280
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
281
+ self.act_fn = ACT2FN[config.hidden_act]
282
+
283
+ def forward(self, x):
284
+ return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
285
+
286
+
287
+ class BailingMoeV2Gate(nn.Module):
288
+ def __init__(self, config):
289
+ super().__init__()
290
+ self.config = config
291
+ self.top_k = config.num_experts_per_tok
292
+ self.num_experts = config.num_experts
293
+
294
+ self.n_group = config.n_group
295
+ self.topk_group = config.topk_group
296
+
297
+ # topk selection algorithm
298
+ self.gating_dim = config.hidden_size
299
+ self.weight = nn.Parameter(torch.empty((self.num_experts, self.gating_dim)))
300
+ self.routed_scaling_factor = config.routed_scaling_factor
301
+
302
+ self.register_buffer("expert_bias", torch.zeros((self.num_experts)))
303
+ self.reset_parameters()
304
+
305
+ def reset_parameters(self) -> None:
306
+ import torch.nn.init as init
307
+
308
+ init.kaiming_uniform_(self.weight, a=math.sqrt(5))
309
+
310
+ def group_limited_topk(
311
+ self,
312
+ scores: torch.Tensor,
313
+ ):
314
+ num_tokens, _ = scores.size()
315
+ # Organize the experts into groups
316
+ group_scores = scores.view(num_tokens, self.n_group, -1).topk(2, dim=-1)[0].sum(dim=-1)
317
+ group_idx = torch.topk(group_scores, k=self.topk_group, dim=-1, sorted=False)[1]
318
+ group_mask = torch.zeros_like(group_scores)
319
+ group_mask.scatter_(1, group_idx, 1)
320
+
321
+ # Mask the experts based on selection groups
322
+ score_mask = (
323
+ group_mask.unsqueeze(-1)
324
+ .expand(num_tokens, self.n_group, self.num_experts // self.n_group)
325
+ .reshape(num_tokens, -1)
326
+ )
327
+
328
+ masked_scores = scores.masked_fill(~score_mask.bool(), float('-inf'))
329
+ probs, top_indices = torch.topk(masked_scores, k=self.top_k, dim=-1)
330
+
331
+ return probs, top_indices
332
+
333
+ def forward(self, hidden_states):
334
+ # compute gating score
335
+ hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
336
+ logits = F.linear(hidden_states.type(torch.float32), self.weight.type(torch.float32))
337
+
338
+ scores = torch.sigmoid(logits.float()).type_as(logits)
339
+
340
+ scores_for_routing = scores + self.expert_bias
341
+ _, topk_idx = self.group_limited_topk(scores_for_routing)
342
+
343
+ scores = torch.gather(scores, dim=1, index=topk_idx).type_as(logits)
344
+
345
+ topk_weight = scores / (scores.sum(dim=-1, keepdim=True) + 1e-20) if self.top_k > 1 else scores
346
+ topk_weight = topk_weight * self.routed_scaling_factor
347
+
348
+ return topk_idx, topk_weight, logits
349
+
350
+
351
+ class BailingMoeV2SparseMoeBlock(nn.Module):
352
+ """
353
+ A mixed expert module containing shared experts.
354
+ """
355
+
356
+ def __init__(self, config: BailingMoeV2Config):
357
+ super().__init__()
358
+ self.config = config
359
+ self.num_experts_per_tok = config.num_experts_per_tok
360
+ self._setup_experts()
361
+ self.gate = BailingMoeV2Gate(config)
362
+ if config.num_shared_experts is not None:
363
+ self.shared_experts = BailingMoeV2MLP(
364
+ config=config, intermediate_size=config.moe_intermediate_size * config.num_shared_experts
365
+ )
366
+
367
+ def _setup_experts(self):
368
+ self.experts = nn.ModuleList(
369
+ [
370
+ BailingMoeV2MLP(config=self.config, intermediate_size=self.config.moe_intermediate_size)
371
+ for _ in range(self.config.num_experts)
372
+ ]
373
+ )
374
+
375
+ def forward(self, hidden_states):
376
+ identity = hidden_states
377
+ bsz, seq_len, h = hidden_states.shape
378
+ topk_idx, topk_weight, router_logits = self.gate(hidden_states)
379
+ hidden_states = hidden_states.view(-1, hidden_states.shape[-1])
380
+ flat_topk_idx = topk_idx.view(-1)
381
+ if self.training:
382
+ hidden_states = hidden_states.repeat_interleave(self.num_experts_per_tok, dim=0)
383
+ y = torch.empty_like(hidden_states)
384
+ for i, expert in enumerate(self.experts):
385
+ y[flat_topk_idx == i] = expert(hidden_states[flat_topk_idx == i])
386
+ y = (y.view(*topk_weight.shape, -1) * topk_weight.unsqueeze(-1)).sum(dim=1)
387
+ y = y.to(hidden_states.dtype).view(bsz, seq_len, h)
388
+ else:
389
+ y = self.moe_infer(hidden_states, topk_idx, topk_weight).view(bsz, seq_len, h)
390
+ if self.config.num_shared_experts is not None:
391
+ y = y + self.shared_experts(identity)
392
+ return y, (router_logits.view(bsz, seq_len, -1), topk_idx.view(bsz, seq_len, -1))
393
+
394
+ @torch.no_grad()
395
+ def moe_infer(self, x, topk_ids, topk_weight):
396
+ cnts = topk_ids.new_zeros((topk_ids.shape[0], len(self.experts)))
397
+ cnts.scatter_(1, topk_ids, 1)
398
+ tokens_per_expert = cnts.sum(dim=0)
399
+ idxs = topk_ids.view(-1).argsort()
400
+ sorted_tokens = x[idxs // topk_ids.shape[1]]
401
+ tokens_per_expert = tokens_per_expert.cpu().numpy()
402
+ outputs = []
403
+ start_idx = 0
404
+ for i, num_tokens in enumerate(tokens_per_expert):
405
+ end_idx = start_idx + num_tokens
406
+ if num_tokens == 0:
407
+ continue
408
+ expert = self.experts[i]
409
+ tokens_for_this_expert = sorted_tokens[start_idx:end_idx]
410
+ expert_out = expert(tokens_for_this_expert)
411
+ outputs.append(expert_out.to(x.device))
412
+ start_idx = end_idx
413
+
414
+ outs = torch.cat(outputs, dim=0) if len(outputs) else sorted_tokens.new_empty(0)
415
+ new_x = torch.empty_like(outs)
416
+ new_x[idxs] = outs
417
+ final_out = (
418
+ new_x.view(*topk_ids.shape, -1)
419
+ .type(topk_weight.dtype)
420
+ .mul_(topk_weight.unsqueeze(dim=-1))
421
+ .sum(dim=1)
422
+ .type(new_x.dtype)
423
+ )
424
+ return final_out
425
+
426
+
427
+ # Copied from transformers.models.llama.modeling_llama.repeat_kv
428
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
429
+ """
430
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
431
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
432
+ """
433
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
434
+ if n_rep == 1:
435
+ return hidden_states
436
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
437
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
438
+
439
+
440
+ # Copied from transformers.models.llama.modeling_llama.LlamaAttention with Llama->BailingMoeV2
441
+ class BailingMoeV2Attention(nn.Module):
442
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
443
+
444
+ def __init__(self, config: BailingMoeV2Config, layer_idx: Optional[int] = None):
445
+ super().__init__()
446
+ self.config = config
447
+ self.layer_idx = layer_idx
448
+ if layer_idx is None:
449
+ logger.warning_once(
450
+ f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
451
+ "to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
452
+ "when creating this class."
453
+ )
454
+
455
+ self.attention_dropout = config.attention_dropout
456
+ self.hidden_size = config.hidden_size
457
+ self.num_heads = config.num_attention_heads
458
+ self.head_dim = config.head_dim or self.hidden_size // self.num_heads
459
+ partial_rotary_factor = config.partial_rotary_factor if hasattr(config, "partial_rotary_factor") else 1.0
460
+ self.rope_dim = int(self.head_dim * partial_rotary_factor)
461
+ self.num_key_value_heads = config.num_key_value_heads
462
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
463
+ self.max_position_embeddings = config.max_position_embeddings
464
+ self.rope_theta = config.rope_theta
465
+ self.is_causal = True
466
+
467
+ self.query_key_value = nn.Linear(
468
+ self.hidden_size,
469
+ (self.num_heads + 2 * self.num_key_value_heads) * self.head_dim,
470
+ bias=config.use_qkv_bias,
471
+ )
472
+
473
+ if self.config.use_qk_norm:
474
+ self.query_layernorm = BailingMoeV2RMSNorm(self.head_dim, eps=config.rms_norm_eps)
475
+ self.key_layernorm = BailingMoeV2RMSNorm(self.head_dim, eps=config.rms_norm_eps)
476
+ self.dense = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.use_bias)
477
+
478
+ def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
479
+ return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
480
+
481
+ def forward(
482
+ self,
483
+ hidden_states: torch.Tensor,
484
+ attention_mask: Optional[torch.Tensor] = None,
485
+ position_ids: Optional[torch.LongTensor] = None,
486
+ past_key_value: Optional[Cache] = None,
487
+ output_attentions: bool = False,
488
+ use_cache: bool = False,
489
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
490
+ **kwargs,
491
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
492
+
493
+ bsz, q_len, _ = hidden_states.size()
494
+
495
+ qkv = self.query_key_value(hidden_states)
496
+ qkv = qkv.view(bsz, q_len, self.num_heads + 2 * self.num_key_value_heads, self.head_dim)
497
+
498
+ query_states, key_states, value_states = qkv.split(
499
+ [self.num_heads, self.num_key_value_heads, self.num_key_value_heads], dim=-2
500
+ )
501
+ query_states = query_states.transpose(1, 2)
502
+ key_states = key_states.transpose(1, 2)
503
+ value_states = value_states.transpose(1, 2)
504
+
505
+ if self.config.use_qk_norm:
506
+ query_states = self.query_layernorm(query_states)
507
+ key_states = self.key_layernorm(key_states)
508
+
509
+ cos, sin = position_embeddings
510
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
511
+
512
+ if past_key_value is not None:
513
+ if self.layer_idx is None:
514
+ raise ValueError(
515
+ f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
516
+ "for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
517
+ "with a layer index."
518
+ )
519
+ cache_kwargs = {"sin": sin, "cos": cos}
520
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
521
+
522
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
523
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
524
+
525
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
526
+
527
+ kv_seq_len = key_states.shape[-2]
528
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
529
+ raise ValueError(
530
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
531
+ f" {attn_weights.size()}"
532
+ )
533
+
534
+ if attention_mask is not None:
535
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
536
+ raise ValueError(
537
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
538
+ )
539
+ attn_weights = attn_weights + attention_mask
540
+
541
+ # upcast attention to fp32
542
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
543
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
544
+ attn_output = torch.matmul(attn_weights, value_states)
545
+
546
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
547
+ raise ValueError(
548
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
549
+ f" {attn_output.size()}"
550
+ )
551
+
552
+ attn_output = attn_output.transpose(1, 2).contiguous()
553
+
554
+ attn_output = attn_output.reshape(bsz, q_len, -1)
555
+
556
+ attn_output = self.dense(attn_output)
557
+
558
+ if not output_attentions:
559
+ attn_weights = None
560
+
561
+ return attn_output, attn_weights, past_key_value
562
+
563
+
564
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2 with Llama->BailingMoeV2
565
+ class BailingMoeV2FlashAttention2(BailingMoeV2Attention):
566
+ """
567
+ BailingMoeV2 flash attention module. This module inherits from `BailingMoeV2Attention` as the weights of the module stays
568
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
569
+ flash attention and deal with padding tokens in case the input contains any of them.
570
+ """
571
+
572
+ def __init__(self, *args, **kwargs):
573
+ super().__init__(*args, **kwargs)
574
+
575
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
576
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
577
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
578
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
579
+
580
+ def forward(
581
+ self,
582
+ hidden_states: torch.Tensor,
583
+ attention_mask: Optional[torch.LongTensor] = None,
584
+ position_ids: Optional[torch.LongTensor] = None,
585
+ past_key_value: Optional[Cache] = None,
586
+ output_attentions: bool = False,
587
+ use_cache: bool = False,
588
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
589
+ **kwargs,
590
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
591
+ # BailingMoeV2FlashAttention2 attention does not support output_attentions
592
+ output_attentions = False
593
+
594
+ bsz, q_len, _ = hidden_states.size()
595
+
596
+ # Flash attention requires the input to have the shape
597
+ # batch_size x seq_length x head_dim x hidden_dim
598
+ # therefore we just need to keep the original shape
599
+
600
+ qkv = self.query_key_value(hidden_states)
601
+ qkv = qkv.view(bsz, q_len, self.num_heads + 2 * self.num_key_value_heads, self.head_dim)
602
+
603
+ query_states, key_states, value_states = qkv.split(
604
+ [self.num_heads, self.num_key_value_heads, self.num_key_value_heads], dim=-2
605
+ )
606
+ query_states = query_states.transpose(1, 2)
607
+ key_states = key_states.transpose(1, 2)
608
+ value_states = value_states.transpose(1, 2)
609
+
610
+ if self.config.use_qk_norm:
611
+ query_states = self.query_layernorm(query_states)
612
+ key_states = self.key_layernorm(key_states)
613
+
614
+ cos, sin = position_embeddings
615
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
616
+
617
+ if past_key_value is not None:
618
+ cache_kwargs = {"sin": sin, "cos": cos}
619
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
620
+
621
+ # TODO: These transpose are quite inefficient but Flash Attention requires the layout [batch_size, sequence_length, num_heads, head_dim]. We would need to refactor the KV cache
622
+ # to be able to avoid many of these transpose/reshape/view.
623
+ query_states = query_states.transpose(1, 2)
624
+ key_states = key_states.transpose(1, 2)
625
+ value_states = value_states.transpose(1, 2)
626
+
627
+ dropout_rate = self.attention_dropout if self.training else 0.0
628
+
629
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
630
+ # therefore the input hidden states gets silently cast in float32. Hence, we need
631
+ # cast them back in the correct dtype just to be sure everything works as expected.
632
+ # This might slow down training & inference so it is recommended to not cast the LayerNorms
633
+ # in fp32. (BailingMoeV2RMSNorm handles it correctly)
634
+
635
+ input_dtype = query_states.dtype
636
+ if input_dtype == torch.float32:
637
+ # Handle the case where the model is quantized
638
+ if hasattr(self.config, "_pre_quantization_dtype"):
639
+ target_dtype = self.config._pre_quantization_dtype
640
+ elif torch.is_autocast_enabled():
641
+ target_dtype = torch.get_autocast_gpu_dtype()
642
+ else:
643
+ target_dtype = self.query_key_value.weight.dtype
644
+
645
+ logger.warning_once(
646
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
647
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
648
+ f" {target_dtype}."
649
+ )
650
+
651
+ query_states = query_states.to(target_dtype)
652
+ key_states = key_states.to(target_dtype)
653
+ value_states = value_states.to(target_dtype)
654
+
655
+ attn_output = self._flash_attention_forward(
656
+ query_states, key_states, value_states, attention_mask, q_len, dropout=dropout_rate
657
+ )
658
+
659
+ attn_output = attn_output.reshape(bsz, q_len, -1).contiguous()
660
+ attn_output = self.dense(attn_output)
661
+
662
+ if not output_attentions:
663
+ attn_weights = None
664
+
665
+ return attn_output, attn_weights, past_key_value
666
+
667
+ def _flash_attention_forward(
668
+ self, query_states, key_states, value_states, attention_mask, query_length, dropout=0.0, softmax_scale=None
669
+ ):
670
+ """
671
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
672
+ first unpad the input, then computes the attention scores and pad the final attention scores.
673
+
674
+ Args:
675
+ query_states (`torch.Tensor`):
676
+ Input query states to be passed to Flash Attention API
677
+ key_states (`torch.Tensor`):
678
+ Input key states to be passed to Flash Attention API
679
+ value_states (`torch.Tensor`):
680
+ Input value states to be passed to Flash Attention API
681
+ attention_mask (`torch.Tensor`):
682
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
683
+ position of padding tokens and 1 for the position of non-padding tokens.
684
+ dropout (`int`, *optional*):
685
+ Attention dropout
686
+ softmax_scale (`float`, *optional*):
687
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
688
+ query_length (`int`):
689
+ The length of the query sequence in terms of tokens. This represents the number of tokens in the
690
+ `query_states` tensor along the sequence dimension. It is used to determine the effective sequence
691
+ length for attention computations.
692
+ """
693
+ if not self._flash_attn_uses_top_left_mask:
694
+ causal = self.is_causal
695
+ else:
696
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in BailingMoeV2FlashAttention2 __init__.
697
+ causal = self.is_causal and query_length != 1
698
+
699
+ # Contains at least one padding token in the sequence
700
+ if attention_mask is not None:
701
+ batch_size = query_states.shape[0]
702
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
703
+ query_states, key_states, value_states, attention_mask, query_length
704
+ )
705
+
706
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
707
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
708
+
709
+ attn_output_unpad = flash_attn_varlen_func(
710
+ query_states,
711
+ key_states,
712
+ value_states,
713
+ cu_seqlens_q=cu_seqlens_q,
714
+ cu_seqlens_k=cu_seqlens_k,
715
+ max_seqlen_q=max_seqlen_in_batch_q,
716
+ max_seqlen_k=max_seqlen_in_batch_k,
717
+ dropout_p=dropout,
718
+ softmax_scale=softmax_scale,
719
+ causal=causal,
720
+ )
721
+
722
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
723
+ else:
724
+ attn_output = flash_attn_func(
725
+ query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=causal
726
+ )
727
+
728
+ return attn_output
729
+
730
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
731
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
732
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
733
+
734
+ key_layer = index_first_axis(
735
+ key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
736
+ )
737
+ value_layer = index_first_axis(
738
+ value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
739
+ )
740
+ if query_length == kv_seq_len:
741
+ query_layer = index_first_axis(
742
+ query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
743
+ )
744
+ cu_seqlens_q = cu_seqlens_k
745
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
746
+ indices_q = indices_k
747
+ elif query_length == 1:
748
+ max_seqlen_in_batch_q = 1
749
+ cu_seqlens_q = torch.arange(
750
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
751
+ ) # There is a memcpy here, that is very bad.
752
+ indices_q = cu_seqlens_q[:-1]
753
+ query_layer = query_layer.squeeze(1)
754
+ else:
755
+ # The -q_len: slice assumes left padding.
756
+ attention_mask = attention_mask[:, -query_length:]
757
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
758
+
759
+ return (
760
+ query_layer,
761
+ key_layer,
762
+ value_layer,
763
+ indices_q,
764
+ (cu_seqlens_q, cu_seqlens_k),
765
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
766
+ )
767
+
768
+
769
+ # Copied from transformers.models.llama.modeling_llama.LlamaSdpaAttention with Llama->BailingMoeV2
770
+ class BailingMoeV2SdpaAttention(BailingMoeV2Attention):
771
+ """
772
+ BailingMoeV2 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
773
+ `BailingMoeV2Attention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
774
+ SDPA API.
775
+ """
776
+
777
+ # Adapted from BailingMoeV2Attention.forward
778
+ def forward(
779
+ self,
780
+ hidden_states: torch.Tensor,
781
+ attention_mask: Optional[torch.Tensor] = None,
782
+ position_ids: Optional[torch.LongTensor] = None,
783
+ past_key_value: Optional[Cache] = None,
784
+ output_attentions: bool = False,
785
+ use_cache: bool = False,
786
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
787
+ **kwargs,
788
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
789
+ if output_attentions:
790
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
791
+ logger.warning_once(
792
+ "BailingMoeV2Model is using BailingMoeV2SdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
793
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
794
+ )
795
+ return super().forward(
796
+ hidden_states=hidden_states,
797
+ attention_mask=attention_mask,
798
+ position_ids=position_ids,
799
+ past_key_value=past_key_value,
800
+ output_attentions=output_attentions,
801
+ use_cache=use_cache,
802
+ )
803
+
804
+ bsz, q_len, _ = hidden_states.size()
805
+
806
+ qkv = self.query_key_value(hidden_states)
807
+ qkv = qkv.view(bsz, q_len, self.num_heads + 2 * self.num_key_value_heads, self.head_dim)
808
+
809
+ query_states, key_states, value_states = qkv.split(
810
+ [self.num_heads, self.num_key_value_heads, self.num_key_value_heads], dim=-2
811
+ )
812
+ query_states = query_states.transpose(1, 2)
813
+ key_states = key_states.transpose(1, 2)
814
+ value_states = value_states.transpose(1, 2)
815
+
816
+ if self.config.use_qk_norm:
817
+ query_states = self.query_layernorm(query_states)
818
+ key_states = self.key_layernorm(key_states)
819
+
820
+ cos, sin = position_embeddings
821
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
822
+
823
+ if past_key_value is not None:
824
+ cache_kwargs = {"sin": sin, "cos": cos}
825
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
826
+
827
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
828
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
829
+
830
+ if attention_mask is not None:
831
+ kv_seq_len = key_states.shape[-2]
832
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
833
+ raise ValueError(
834
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
835
+ )
836
+
837
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
838
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
839
+ if query_states.device.type == "cuda" and attention_mask is not None:
840
+ query_states = query_states.contiguous()
841
+ key_states = key_states.contiguous()
842
+ value_states = value_states.contiguous()
843
+
844
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
845
+ query_states,
846
+ key_states,
847
+ value_states,
848
+ attn_mask=attention_mask,
849
+ dropout_p=self.attention_dropout if self.training else 0.0,
850
+ # The q_len > 1 is necessary to match with AttentionMaskConverter.to_causal_4d that does not create a causal mask in case q_len == 1.
851
+ is_causal=self.is_causal and attention_mask is None and q_len > 1,
852
+ )
853
+
854
+ attn_output = attn_output.transpose(1, 2).contiguous()
855
+ attn_output = attn_output.reshape(bsz, q_len, -1)
856
+
857
+ attn_output = self.dense(attn_output)
858
+
859
+ return attn_output, None, past_key_value
860
+
861
+
862
+ ATTENTION_CLASSES = {
863
+ "eager": BailingMoeV2Attention,
864
+ "flash_attention_2": BailingMoeV2FlashAttention2,
865
+ "sdpa": BailingMoeV2SdpaAttention,
866
+ }
867
+
868
+
869
+ class BailingMoeV2MTPLayer(nn.Module):
870
+ def __init__(self, config: BailingMoeV2Config, layer_idx: int):
871
+ super().__init__()
872
+ self.layer_idx = layer_idx
873
+ self.input_layernorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
874
+ self.enorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
875
+
876
+ self.eh_proj = nn.Linear(config.hidden_size * 2, config.hidden_size, bias=False)
877
+ self.post_attention_layernorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
878
+ self.attention = ATTENTION_CLASSES[config._attn_implementation](config=config, layer_idx=layer_idx)
879
+ self.mlp = BailingMoeV2SparseMoeBlock(config)
880
+
881
+ self.hnorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
882
+ self.final_layernorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
883
+
884
+ def forward(
885
+ self,
886
+ input_embeds,
887
+ hidden_states: torch.Tensor,
888
+ attention_mask: Optional[torch.Tensor] = None,
889
+ position_ids: Optional[torch.LongTensor] = None,
890
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
891
+ output_attentions: Optional[bool] = False,
892
+ output_router_logits: Optional[bool] = False,
893
+ use_cache: Optional[bool] = False,
894
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
895
+ **kwargs,
896
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
897
+ input_embeds = self.enorm(input_embeds)
898
+ hidden_states = self.hnorm(hidden_states)
899
+ hidden_states = self.eh_proj(torch.cat([input_embeds, hidden_states], dim=-1))
900
+ residual = hidden_states
901
+
902
+ hidden_states = self.input_layernorm(hidden_states)
903
+
904
+ # Self Attention
905
+ hidden_states, self_attn_weights, present_key_value = self.attention(
906
+ hidden_states=hidden_states,
907
+ attention_mask=attention_mask,
908
+ position_ids=position_ids,
909
+ past_key_value=past_key_value,
910
+ output_attentions=output_attentions,
911
+ position_embeddings=position_embeddings,
912
+ use_cache=use_cache,
913
+ )
914
+ hidden_states = residual + hidden_states
915
+
916
+ # Fully Connected
917
+ residual = hidden_states
918
+ hidden_states = self.post_attention_layernorm(hidden_states)
919
+ hidden_states = self.mlp(hidden_states)
920
+ if isinstance(hidden_states, tuple):
921
+ hidden_states, router_logits = hidden_states
922
+ else:
923
+ router_logits = None
924
+ hidden_states = residual + hidden_states.to(residual.device)
925
+ hidden_states = self.final_layernorm(hidden_states)
926
+
927
+ outputs = (hidden_states,)
928
+
929
+ if output_attentions:
930
+ outputs += (self_attn_weights,)
931
+
932
+ if use_cache:
933
+ outputs += (present_key_value,)
934
+
935
+ if output_router_logits:
936
+ outputs += (router_logits,)
937
+
938
+ return outputs
939
+
940
+
941
+ class BailingMoeV2DecoderLayer(nn.Module):
942
+ def __init__(self, config: BailingMoeV2Config, layer_idx: int):
943
+ super().__init__()
944
+ self.hidden_size = config.hidden_size
945
+
946
+ self.attention = ATTENTION_CLASSES[config._attn_implementation](config=config, layer_idx=layer_idx)
947
+
948
+ self.mlp = (
949
+ BailingMoeV2SparseMoeBlock(config)
950
+ if (config.num_experts is not None and layer_idx >= config.first_k_dense_replace)
951
+ else BailingMoeV2MLP(config=config, intermediate_size=config.intermediate_size)
952
+ )
953
+ self.input_layernorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
954
+ self.post_attention_layernorm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
955
+
956
+ def forward(
957
+ self,
958
+ hidden_states: torch.Tensor,
959
+ attention_mask: Optional[torch.Tensor] = None,
960
+ position_ids: Optional[torch.LongTensor] = None,
961
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
962
+ output_attentions: Optional[bool] = False,
963
+ output_router_logits: Optional[bool] = False,
964
+ use_cache: Optional[bool] = False,
965
+ position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
966
+ **kwargs,
967
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
968
+ """
969
+ Args:
970
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
971
+ attention_mask (`torch.FloatTensor`, *optional*):
972
+ attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
973
+ query_sequence_length, key_sequence_length)` if default attention is used.
974
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
975
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
976
+ config.n_positions - 1]`.
977
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*):
978
+ cached past key and value projection states
979
+ output_attentions (`bool`, *optional*):
980
+ Whether to return the attentions tensors of all attention layers. See `attentions` under
981
+ returned tensors for more detail.
982
+ output_router_logits (`bool`, *optional*):
983
+ Whether or not to return the logits of all the routers. They are useful for computing the router loss,
984
+ and should not be returned during inference.
985
+ use_cache (`bool`, *optional*):
986
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
987
+ (see `past_key_values`).
988
+ """
989
+ residual = hidden_states
990
+
991
+ hidden_states = self.input_layernorm(hidden_states)
992
+
993
+ # Self Attention
994
+ hidden_states, self_attn_weights, present_key_value = self.attention(
995
+ hidden_states=hidden_states,
996
+ attention_mask=attention_mask,
997
+ position_ids=position_ids,
998
+ past_key_value=past_key_value,
999
+ output_attentions=output_attentions,
1000
+ position_embeddings=position_embeddings,
1001
+ use_cache=use_cache,
1002
+ )
1003
+ hidden_states = residual + hidden_states
1004
+
1005
+ # Fully Connected
1006
+ residual = hidden_states
1007
+ hidden_states = self.post_attention_layernorm(hidden_states)
1008
+ hidden_states = self.mlp(hidden_states)
1009
+ if isinstance(hidden_states, tuple):
1010
+ hidden_states, router_logits = hidden_states
1011
+ else:
1012
+ router_logits = None
1013
+ hidden_states = residual + hidden_states.to(residual.device)
1014
+
1015
+ outputs = (hidden_states,)
1016
+
1017
+ if output_attentions:
1018
+ outputs += (self_attn_weights,)
1019
+
1020
+ if use_cache:
1021
+ outputs += (present_key_value,)
1022
+
1023
+ if output_router_logits:
1024
+ outputs += (router_logits,)
1025
+
1026
+ return outputs
1027
+
1028
+
1029
+ BAILINGMOEV2_START_DOCSTRING = r"""
1030
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
1031
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
1032
+ etc.)
1033
+
1034
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
1035
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
1036
+ and behavior.
1037
+
1038
+ Parameters:
1039
+ config ([`BailingMoeV2Config`]):
1040
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
1041
+ load the weights associated with the model, only the configuration. Check out the
1042
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
1043
+ """
1044
+
1045
+
1046
+ @add_start_docstrings(
1047
+ "The bare BailingMoeV2 Model outputting raw hidden-states without any specific head on top.",
1048
+ BAILINGMOEV2_START_DOCSTRING,
1049
+ )
1050
+ class BailingMoeV2PreTrainedModel(PreTrainedModel):
1051
+ config_class = BailingMoeV2Config
1052
+ base_model_prefix = "model"
1053
+ supports_gradient_checkpointing = True
1054
+ _no_split_modules = ["BailingMoeV2DecoderLayer"]
1055
+ _skip_keys_device_placement = "past_key_values"
1056
+ _supports_flash_attn_2 = True
1057
+ _supports_sdpa = True
1058
+ _supports_cache_class = True
1059
+
1060
+ def _init_weights(self, module):
1061
+ std = self.config.initializer_range
1062
+ if isinstance(module, nn.Linear):
1063
+ module.weight.data.normal_(mean=0.0, std=std)
1064
+ if module.bias is not None:
1065
+ module.bias.data.zero_()
1066
+ elif isinstance(module, nn.Embedding):
1067
+ module.weight.data.normal_(mean=0.0, std=std)
1068
+ if module.padding_idx is not None:
1069
+ module.weight.data[module.padding_idx].zero_()
1070
+
1071
+
1072
+ BAILINGMOEV2_INPUTS_DOCSTRING = r"""
1073
+ Args:
1074
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
1075
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
1076
+ it.
1077
+
1078
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
1079
+ [`PreTrainedTokenizer.__call__`] for details.
1080
+
1081
+ [What are input IDs?](../glossary#input-ids)
1082
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
1083
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
1084
+
1085
+ - 1 for tokens that are **not masked**,
1086
+ - 0 for tokens that are **masked**.
1087
+
1088
+ [What are attention masks?](../glossary#attention-mask)
1089
+
1090
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
1091
+ [`PreTrainedTokenizer.__call__`] for details.
1092
+
1093
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
1094
+ `past_key_values`).
1095
+
1096
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
1097
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
1098
+ information on the default strategy.
1099
+
1100
+ - 1 indicates the head is **not masked**,
1101
+ - 0 indicates the head is **masked**.
1102
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1103
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
1104
+ config.n_positions - 1]`.
1105
+
1106
+ [What are position IDs?](../glossary#position-ids)
1107
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
1108
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
1109
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
1110
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
1111
+
1112
+ Two formats are allowed:
1113
+ - a [`~cache_utils.Cache`] instance;
1114
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
1115
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
1116
+ cache format.
1117
+
1118
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
1119
+ legacy cache format will be returned.
1120
+
1121
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
1122
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
1123
+ of shape `(batch_size, sequence_length)`.
1124
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
1125
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
1126
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
1127
+ model's internal embedding lookup matrix.
1128
+ use_cache (`bool`, *optional*):
1129
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
1130
+ `past_key_values`).
1131
+ output_attentions (`bool`, *optional*):
1132
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
1133
+ tensors for more detail.
1134
+ output_hidden_states (`bool`, *optional*):
1135
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
1136
+ more detail.
1137
+ return_dict (`bool`, *optional*):
1138
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
1139
+ """
1140
+
1141
+
1142
+ @add_start_docstrings(
1143
+ "The bare BailingMoeV2 Model outputting raw hidden-states without any specific head on top.",
1144
+ BAILINGMOEV2_START_DOCSTRING,
1145
+ )
1146
+ class BailingMoeV2Model(BailingMoeV2PreTrainedModel):
1147
+ """
1148
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`BailingMoeV2DecoderLayer`]
1149
+
1150
+ Args:
1151
+ config: BailingMoeV2Config
1152
+ """
1153
+
1154
+ def __init__(self, config: BailingMoeV2Config):
1155
+ super().__init__(config)
1156
+ self.padding_idx = config.pad_token_id
1157
+ self.vocab_size = config.vocab_size
1158
+ self.num_nextn_predict_layers = config.num_nextn_predict_layers
1159
+
1160
+ self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
1161
+ self.layers = []
1162
+ for layer_idx in range(config.num_hidden_layers + config.num_nextn_predict_layers):
1163
+ layer_cls = BailingMoeV2DecoderLayer if layer_idx < config.num_hidden_layers else BailingMoeV2MTPLayer
1164
+ self.layers.append(layer_cls(config, layer_idx))
1165
+
1166
+ self.layers = nn.ModuleList(self.layers)
1167
+
1168
+ self._use_sdpa = config._attn_implementation == "sdpa"
1169
+ self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
1170
+ self.norm = BailingMoeV2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
1171
+ self.rotary_emb = BailingMoeV2RotaryEmbedding(config=config)
1172
+ self.gradient_checkpointing = False
1173
+ # Initialize weights and apply final processing
1174
+ self.post_init()
1175
+
1176
+ def get_input_embeddings(self):
1177
+ return self.word_embeddings
1178
+
1179
+ def set_input_embeddings(self, value):
1180
+ self.word_embeddings = value
1181
+
1182
+ @add_start_docstrings_to_model_forward(BAILINGMOEV2_INPUTS_DOCSTRING)
1183
+ def forward(
1184
+ self,
1185
+ input_ids: torch.LongTensor = None,
1186
+ attention_mask: Optional[torch.Tensor] = None,
1187
+ position_ids: Optional[torch.LongTensor] = None,
1188
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1189
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1190
+ use_cache: Optional[bool] = None,
1191
+ output_attentions: Optional[bool] = None,
1192
+ output_hidden_states: Optional[bool] = None,
1193
+ output_router_logits: Optional[bool] = None,
1194
+ return_dict: Optional[bool] = None,
1195
+ **kwargs,
1196
+ ) -> Union[Tuple, MoeV2ModelOutputWithPast]:
1197
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1198
+ output_hidden_states = (
1199
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1200
+ )
1201
+ output_router_logits = (
1202
+ output_router_logits if output_router_logits is not None else self.config.output_router_logits
1203
+ )
1204
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
1205
+
1206
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1207
+
1208
+ # retrieve input_ids and inputs_embeds
1209
+ if input_ids is not None and inputs_embeds is not None:
1210
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
1211
+ elif input_ids is not None:
1212
+ batch_size, seq_length = input_ids.shape[:2]
1213
+ elif inputs_embeds is not None:
1214
+ batch_size, seq_length = inputs_embeds.shape[:2]
1215
+ else:
1216
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
1217
+
1218
+ if self.gradient_checkpointing and self.training:
1219
+ if use_cache:
1220
+ logger.warning_once(
1221
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`transformers."
1222
+ )
1223
+ use_cache = False
1224
+
1225
+ if use_cache and past_key_values is None:
1226
+ past_key_values = DynamicCache()
1227
+
1228
+ if inputs_embeds is None:
1229
+ inputs_embeds = self.word_embeddings(input_ids)
1230
+
1231
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
1232
+
1233
+ if position_ids is None:
1234
+ position_ids = torch.arange(
1235
+ past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
1236
+ )
1237
+ position_ids = position_ids.unsqueeze(0)
1238
+
1239
+ if self._use_flash_attention_2:
1240
+ # 2d mask is passed through the layers
1241
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
1242
+ elif self._use_sdpa and not output_attentions:
1243
+ # output_attentions=True can not be supported when using SDPA, and we fall back on
1244
+ # the manual implementation that requires a 4D causal mask in all cases.
1245
+ attention_mask = _prepare_4d_causal_attention_mask_for_sdpa(
1246
+ attention_mask,
1247
+ (batch_size, seq_length),
1248
+ inputs_embeds,
1249
+ past_seen_tokens,
1250
+ )
1251
+ else:
1252
+ # 4d mask is passed through the layers
1253
+ attention_mask = _prepare_4d_causal_attention_mask(
1254
+ attention_mask, (batch_size, seq_length), inputs_embeds, past_seen_tokens
1255
+ )
1256
+
1257
+ # embed positions
1258
+ hidden_states = inputs_embeds
1259
+
1260
+ # create position embeddings to be shared across the decoder layers
1261
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
1262
+
1263
+ # decoder layers
1264
+ all_hidden_states = () if output_hidden_states else None
1265
+ all_self_attns = () if output_attentions else None
1266
+ all_router_logits = () if output_router_logits else None
1267
+ next_decoder_cache = None
1268
+ layers = self.layers[: -self.num_nextn_predict_layers] if self.num_nextn_predict_layers > 0 else self.layers
1269
+ mtp_layers = self.layers[-self.num_nextn_predict_layers :] if self.num_nextn_predict_layers > 0 else None
1270
+
1271
+ for decoder_layer in layers:
1272
+ if output_hidden_states:
1273
+ all_hidden_states += (hidden_states,)
1274
+
1275
+ if self.gradient_checkpointing and self.training:
1276
+ layer_outputs = self._gradient_checkpointing_func(
1277
+ decoder_layer.__call__,
1278
+ hidden_states,
1279
+ attention_mask,
1280
+ position_ids,
1281
+ past_key_values,
1282
+ output_attentions,
1283
+ output_router_logits,
1284
+ use_cache,
1285
+ position_embeddings,
1286
+ )
1287
+ else:
1288
+ layer_outputs = decoder_layer(
1289
+ hidden_states,
1290
+ attention_mask=attention_mask,
1291
+ position_ids=position_ids,
1292
+ past_key_value=past_key_values,
1293
+ output_attentions=output_attentions,
1294
+ output_router_logits=output_router_logits,
1295
+ use_cache=use_cache,
1296
+ position_embeddings=position_embeddings,
1297
+ )
1298
+ hidden_states = layer_outputs[0]
1299
+
1300
+ if use_cache:
1301
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1302
+
1303
+ if output_attentions:
1304
+ all_self_attns += (layer_outputs[1],)
1305
+
1306
+ if output_router_logits and layer_outputs[-1] is not None:
1307
+ all_router_logits += (layer_outputs[-1],)
1308
+
1309
+ hidden_states = self.norm(hidden_states)
1310
+ main_hidden_states = hidden_states
1311
+
1312
+ # add hidden states from the last decoder layer
1313
+ if output_hidden_states:
1314
+ all_hidden_states += (main_hidden_states,)
1315
+
1316
+ mtp_hidden_states = None
1317
+
1318
+ if mtp_layers:
1319
+ for decoder_layer in mtp_layers:
1320
+ input_ids, _ = roll_tensor(input_ids, shifts=-1, dims=-1)
1321
+ inputs_embeds = self.word_embeddings(input_ids)
1322
+
1323
+ if self.gradient_checkpointing and self.training:
1324
+ layer_outputs = self._gradient_checkpointing_func(
1325
+ decoder_layer.__call__,
1326
+ inputs_embeds,
1327
+ hidden_states,
1328
+ attention_mask,
1329
+ position_ids,
1330
+ past_key_values,
1331
+ output_attentions,
1332
+ output_router_logits,
1333
+ use_cache,
1334
+ position_embeddings,
1335
+ )
1336
+ else:
1337
+ layer_outputs = decoder_layer(
1338
+ inputs_embeds,
1339
+ hidden_states,
1340
+ attention_mask=attention_mask,
1341
+ position_ids=position_ids,
1342
+ past_key_value=past_key_values,
1343
+ output_attentions=output_attentions,
1344
+ output_router_logits=output_router_logits,
1345
+ use_cache=use_cache,
1346
+ position_embeddings=position_embeddings,
1347
+ )
1348
+ if mtp_hidden_states is None:
1349
+ mtp_hidden_states = []
1350
+ hidden_states = layer_outputs[0]
1351
+ mtp_hidden_states.append(hidden_states)
1352
+
1353
+ if output_hidden_states:
1354
+ all_hidden_states += (hidden_states,)
1355
+
1356
+ if use_cache:
1357
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1358
+
1359
+ if output_attentions:
1360
+ all_self_attns += (layer_outputs[1],)
1361
+
1362
+ if output_router_logits and layer_outputs[-1] is not None:
1363
+ all_router_logits += (layer_outputs[-1],)
1364
+
1365
+ next_cache = None
1366
+ if use_cache:
1367
+ next_cache = next_decoder_cache
1368
+ if not return_dict:
1369
+ return tuple(
1370
+ v
1371
+ for v in [main_hidden_states, next_cache, all_hidden_states, all_self_attns, all_router_logits]
1372
+ if v is not None
1373
+ )
1374
+ return MoeV2ModelOutputWithPast(
1375
+ last_hidden_state=main_hidden_states,
1376
+ past_key_values=next_cache,
1377
+ hidden_states=all_hidden_states,
1378
+ mtp_hidden_states=mtp_hidden_states,
1379
+ attentions=all_self_attns,
1380
+ router_logits=all_router_logits,
1381
+ )
1382
+
1383
+
1384
+ class BailingMoeV2ForCausalLM(BailingMoeV2PreTrainedModel, GenerationMixin):
1385
+ _tied_weights_keys = ["lm_head.weight"]
1386
+
1387
+ def __init__(self, config: BailingMoeV2Config):
1388
+ super().__init__(config)
1389
+ self.model = BailingMoeV2Model(config)
1390
+ self.vocab_size = config.vocab_size
1391
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1392
+ self.num_nextn_predict_layers = config.num_nextn_predict_layers
1393
+ self.mtp_loss_scaling_factor = config.mtp_loss_scaling_factor
1394
+
1395
+ # Initialize weights and apply final processing
1396
+ self.post_init()
1397
+
1398
+ def get_input_embeddings(self):
1399
+ return self.model.word_embeddings
1400
+
1401
+ def set_input_embeddings(self, value):
1402
+ self.model.word_embeddings = value
1403
+
1404
+ def get_output_embeddings(self):
1405
+ return self.lm_head
1406
+
1407
+ def set_output_embeddings(self, new_embeddings):
1408
+ self.lm_head = new_embeddings
1409
+
1410
+ def set_decoder(self, decoder):
1411
+ self.model = decoder
1412
+
1413
+ def get_decoder(self):
1414
+ return self.model
1415
+
1416
+ @add_start_docstrings_to_model_forward(BAILINGMOEV2_INPUTS_DOCSTRING)
1417
+ @replace_return_docstrings(output_type=MoEV2CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1418
+ def forward(
1419
+ self,
1420
+ input_ids: torch.LongTensor = None,
1421
+ attention_mask: Optional[torch.Tensor] = None,
1422
+ position_ids: Optional[torch.LongTensor] = None,
1423
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1424
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1425
+ labels: Optional[torch.LongTensor] = None,
1426
+ use_cache: Optional[bool] = None,
1427
+ output_attentions: Optional[bool] = None,
1428
+ output_hidden_states: Optional[bool] = None,
1429
+ output_router_logits: Optional[bool] = None,
1430
+ return_dict: Optional[bool] = None,
1431
+ **kwargs,
1432
+ ) -> Union[Tuple, MoEV2CausalLMOutputWithPast]:
1433
+ r"""
1434
+ Args:
1435
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1436
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1437
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1438
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1439
+
1440
+ Returns:
1441
+
1442
+ Example:
1443
+
1444
+ ```python
1445
+ >>> from transformers import AutoTokenizer
1446
+
1447
+ >>> model = BailingMoeV2ForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
1448
+ >>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
1449
+
1450
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
1451
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1452
+
1453
+ >>> # Generate
1454
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1455
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1456
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
1457
+ ```"""
1458
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1459
+ output_hidden_states = (
1460
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1461
+ )
1462
+ output_router_logits = (
1463
+ output_router_logits if output_router_logits is not None else self.config.output_router_logits
1464
+ )
1465
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1466
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1467
+ outputs = self.model(
1468
+ input_ids=input_ids,
1469
+ attention_mask=attention_mask,
1470
+ position_ids=position_ids,
1471
+ past_key_values=past_key_values,
1472
+ inputs_embeds=inputs_embeds,
1473
+ use_cache=use_cache,
1474
+ output_attentions=output_attentions,
1475
+ output_hidden_states=output_hidden_states,
1476
+ output_router_logits=output_router_logits,
1477
+ return_dict=return_dict,
1478
+ **kwargs,
1479
+ )
1480
+
1481
+ loss = None
1482
+ all_mtp_loss = None
1483
+ aux_loss = None
1484
+ hidden_states = outputs[0]
1485
+ logits = self.lm_head(hidden_states)
1486
+ logits = logits.float()
1487
+
1488
+ if labels is not None:
1489
+ loss = self.loss_function(logits, labels, self.config.vocab_size, **kwargs)
1490
+
1491
+ all_mtp_logits = None
1492
+ if self.num_nextn_predict_layers > 0:
1493
+ mtp_hidden_states = outputs.mtp_hidden_states
1494
+ shift_labels_mtp = None
1495
+ for i in range(self.num_nextn_predict_layers):
1496
+ mtp_hidden_states = mtp_hidden_states[i]
1497
+ mtp_logits = self.lm_head(mtp_hidden_states).float()
1498
+ if all_mtp_logits is None:
1499
+ all_mtp_logits = []
1500
+ all_mtp_logits.append(mtp_logits)
1501
+ if labels is not None:
1502
+ if shift_labels_mtp is None:
1503
+ shift_labels_mtp = labels.clone()
1504
+ shift_labels_mtp, _ = roll_tensor(shift_labels_mtp, shifts=-1, dims=-1, fill_value=-100)
1505
+ mtp_logits_ = mtp_logits.view(-1, self.config.vocab_size)
1506
+ mtp_loss = self.loss_function(mtp_logits_, shift_labels_mtp.to(mtp_logits_.device).view(-1), self.config.vocab_size, **kwargs)
1507
+ if loss is not None:
1508
+ loss += self.mtp_loss_scaling_factor * mtp_loss
1509
+ else:
1510
+ loss = self.mtp_loss_scaling_factor * mtp_loss
1511
+
1512
+ if all_mtp_loss is None:
1513
+ all_mtp_loss = []
1514
+ all_mtp_loss.append(mtp_loss)
1515
+
1516
+ if not return_dict:
1517
+ output = (logits,) + outputs[1:]
1518
+ if output_router_logits:
1519
+ output = (aux_loss,) + output
1520
+ return (loss,) + output if loss is not None else output
1521
+
1522
+ return MoEV2CausalLMOutputWithPast(
1523
+ loss=loss,
1524
+ mtp_loss=all_mtp_loss,
1525
+ aux_loss=aux_loss,
1526
+ logits=logits,
1527
+ mtp_logits=all_mtp_logits,
1528
+ past_key_values=outputs.past_key_values,
1529
+ hidden_states=outputs.hidden_states,
1530
+ attentions=outputs.attentions,
1531
+ router_logits=outputs.router_logits,
1532
+ )
pruning-code/prune_ring_moe.py ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Calibration-based structured pruning for Ring-mini-2.0 (BailingMoeV2 MoE).
4
+
5
+ This script prunes Mixture-of-Experts (MoE) experts per layer based on routing
6
+ statistics gathered from a small calibration dataset, and writes out a new
7
+ checkpoint with fewer experts (e.g., 256 -> 144 per layer) to hit a target
8
+ total parameter budget (e.g., ~10B total params instead of ~16.8B).
9
+
10
+ Key features:
11
+ - Collects per-layer expert importance via router outputs (prob mass or usage).
12
+ - Keeps the same number of experts per group to preserve gating layout.
13
+ - Rebuilds each MoE block with the selected experts and remaps gate weights.
14
+ - Saves a standalone pruned model with updated config.
15
+
16
+ Usage example (experts -> 144 per layer):
17
+
18
+ python prune_ring_moe.py \
19
+ --model . \
20
+ --output_dir ./ring-mini-2.0-pruned-144e \
21
+ --calib_path ./calib_data \
22
+ --samples 200 --seq_len 512 \
23
+ --target_experts 144 \
24
+ --score route_count
25
+
26
+ Alternatively, specify a target total parameter budget (approx.):
27
+
28
+ python prune_ring_moe.py \
29
+ --model . \
30
+ --output_dir ./ring-mini-2.0-pruned-10B \
31
+ --calib_path ./calib_data \
32
+ --samples 200 --seq_len 512 \
33
+ --target_total_params 10000000000
34
+
35
+ Notes:
36
+ - The script expects Ring-mini-2.0 code in the working directory (trust_remote_code=True).
37
+ - Calibration path can be a folder of .txt files or a .jsonl file with {"text": ...} lines.
38
+ - Ensure enough VRAM/system RAM to load the model and run short eval passes.
39
+ """
40
+
41
+ from __future__ import annotations
42
+
43
+ import argparse
44
+ import copy
45
+ import json
46
+ import math
47
+ import os
48
+ import random
49
+ import sys
50
+ from tqdm import tqdm
51
+ from dataclasses import dataclass
52
+ from typing import Dict, Iterable, List, Optional, Sequence, Tuple
53
+
54
+ import torch
55
+ from torch import nn
56
+
57
+ try:
58
+ from transformers import AutoModelForCausalLM, AutoTokenizer
59
+ except Exception as e: # pragma: no cover - CLI convenience
60
+ print("Please install transformers: pip install transformers", file=sys.stderr)
61
+ raise
62
+
63
+
64
+ # ----------------------------
65
+ # Calibration dataset
66
+ # ----------------------------
67
+
68
+ def iter_texts(calib_path: str) -> Iterable[str]:
69
+ """Yield texts from a directory of .txt files or a .jsonl file with {"text": ...} lines."""
70
+ if os.path.isdir(calib_path):
71
+ for root, _, files in os.walk(calib_path):
72
+ for fn in files:
73
+ if fn.lower().endswith(".txt"):
74
+ p = os.path.join(root, fn)
75
+ try:
76
+ with open(p, "r", encoding="utf-8", errors="ignore") as f:
77
+ txt = f.read().strip()
78
+ if txt:
79
+ yield txt
80
+ except Exception:
81
+ continue
82
+ elif os.path.isfile(calib_path) and calib_path.lower().endswith(".jsonl"):
83
+ with open(calib_path, "r", encoding="utf-8", errors="ignore") as f:
84
+ for line in f:
85
+ line = line.strip()
86
+ if not line:
87
+ continue
88
+ try:
89
+ obj = json.loads(line)
90
+ txt = obj.get("text", "").strip()
91
+ if txt:
92
+ yield txt
93
+ except Exception:
94
+ continue
95
+ else:
96
+ raise ValueError(f"Unsupported calib_path: {calib_path}")
97
+
98
+
99
+ @dataclass
100
+ class PruneArgs:
101
+ model: str
102
+ output_dir: str
103
+ calib_path: Optional[str]
104
+ tokenizer: Optional[str]
105
+ device: str
106
+ dtype: str
107
+ device_map: Optional[str]
108
+ seed: int
109
+ samples: int
110
+ seq_len: int
111
+ batch_size: int
112
+ score: str # 'route_count' | 'prob_mass' | 'combined'
113
+ alpha: float # weight for route_count in combined
114
+ target_experts: Optional[int]
115
+ target_total_params: Optional[int]
116
+ dry_run: bool
117
+
118
+
119
+ def set_seed(seed: int) -> None:
120
+ random.seed(seed)
121
+ torch.manual_seed(seed)
122
+ torch.cuda.manual_seed_all(seed)
123
+
124
+
125
+ def infer_dtype(dtype_str: str) -> torch.dtype:
126
+ if dtype_str.lower() in ("auto",):
127
+ return torch.float16 if torch.cuda.is_available() else torch.float32
128
+ m = dtype_str.lower()
129
+ if m in ("fp16", "float16", "half"): return torch.float16
130
+ if m in ("bf16", "bfloat16"): return torch.bfloat16
131
+ if m in ("fp32", "float32", "full"): return torch.float32
132
+ raise ValueError(f"Unsupported dtype: {dtype_str}")
133
+
134
+
135
+ # ----------------------------
136
+ # Param count estimation
137
+ # ----------------------------
138
+
139
+ def estimate_total_params_for_config(
140
+ *,
141
+ vocab_size: int,
142
+ hidden_size: int,
143
+ intermediate_size: int,
144
+ num_hidden_layers: int,
145
+ num_attention_heads: int,
146
+ num_key_value_heads: int,
147
+ head_dim: int,
148
+ use_qkv_bias: bool,
149
+ use_bias: bool,
150
+ n_group: int,
151
+ num_experts: int,
152
+ moe_intermediate_size: int,
153
+ num_shared_experts: int,
154
+ first_k_dense_replace: int,
155
+ ) -> int:
156
+ """Compute an approximate parameter count from config, without instantiating the model.
157
+
158
+ The calculation mirrors the shapes in modeling_bailing_moe_v2.py and is sufficient
159
+ to solve for a target experts-per-layer given a total param budget.
160
+ """
161
+ L = num_hidden_layers
162
+ HS = hidden_size
163
+ NH = num_attention_heads
164
+ NKV = num_key_value_heads
165
+ Dh = head_dim
166
+ V = vocab_size
167
+
168
+ # Embedding + LM head + final RMS norm
169
+ emb = V * HS
170
+ lm_head = HS * V
171
+ final_norm = HS
172
+
173
+ # Per-layer attention params
174
+ qkv_out = (NH + 2 * NKV) * Dh
175
+ qkv = HS * qkv_out + (qkv_out if use_qkv_bias else 0)
176
+ o_proj = (NH * Dh) * HS + (HS if use_bias else 0)
177
+ # QK norms (weights only)
178
+ qk_norm = 2 * Dh
179
+ # Pre/post RMS norms (weights only)
180
+ layer_norms = 2 * HS
181
+ attn_block = qkv + o_proj + qk_norm + layer_norms
182
+
183
+ # Dense MLP (first_k_dense_replace layers)
184
+ dense_mlp_per_layer = 3 * HS * intermediate_size
185
+
186
+ # MoE per layer: gate + experts + shared experts
187
+ gate = num_experts * HS # expert_bias buffer omitted
188
+ expert_mlp_per_expert = 3 * HS * moe_intermediate_size
189
+ shared_experts = 3 * HS * moe_intermediate_size * max(1, num_shared_experts)
190
+ moe_block = gate + num_experts * expert_mlp_per_expert + shared_experts
191
+
192
+ total = 0
193
+ total += emb + lm_head + final_norm
194
+ total += L * attn_block
195
+ total += first_k_dense_replace * dense_mlp_per_layer
196
+ total += (L - first_k_dense_replace) * moe_block
197
+ return int(total)
198
+
199
+
200
+ def solve_target_experts_for_budget(cfg, target_total_params: int) -> int:
201
+ """Given a config and a target total params, solve for experts per layer.
202
+
203
+ Returns a value divisible by cfg.n_group and >= cfg.num_experts_per_tok.
204
+ """
205
+ def total_for_experts(E: int) -> int:
206
+ return estimate_total_params_for_config(
207
+ vocab_size=cfg.vocab_size,
208
+ hidden_size=cfg.hidden_size,
209
+ intermediate_size=cfg.intermediate_size,
210
+ num_hidden_layers=cfg.num_hidden_layers,
211
+ num_attention_heads=cfg.num_attention_heads,
212
+ num_key_value_heads=cfg.num_key_value_heads,
213
+ head_dim=cfg.head_dim,
214
+ use_qkv_bias=cfg.use_qkv_bias,
215
+ use_bias=cfg.use_bias,
216
+ n_group=cfg.n_group,
217
+ num_experts=E,
218
+ moe_intermediate_size=cfg.moe_intermediate_size,
219
+ num_shared_experts=cfg.num_shared_experts or 0,
220
+ first_k_dense_replace=cfg.first_k_dense_replace,
221
+ )
222
+
223
+ # Binary search between [num_experts_per_tok, current_num_experts]
224
+ lo = max(cfg.num_experts_per_tok, cfg.n_group) # at least one per group
225
+ hi = cfg.num_experts
226
+ best = hi
227
+ while lo <= hi:
228
+ mid = (lo + hi) // 2
229
+ # enforce divisibility by n_group
230
+ mid = (mid // cfg.n_group) * cfg.n_group
231
+ mid = max(mid, cfg.n_group)
232
+ mid = max(mid, cfg.num_experts_per_tok)
233
+ if mid == 0:
234
+ mid = cfg.n_group
235
+ t = total_for_experts(mid)
236
+ if t > target_total_params:
237
+ hi = mid - cfg.n_group
238
+ else:
239
+ best = mid
240
+ lo = mid + cfg.n_group
241
+ return max(cfg.num_experts_per_tok, best)
242
+
243
+
244
+ # ----------------------------
245
+ # Scoring and selection
246
+ # ----------------------------
247
+
248
+ @torch.no_grad()
249
+ def collect_moe_stats(
250
+ model, tokenizer, texts: Iterable[str], *,
251
+ max_samples: int, seq_len: int, batch_size: int, device: str
252
+ ) -> Tuple[List[torch.Tensor], List[torch.Tensor]]:
253
+ """Accumulate per-layer stats for MoE experts.
254
+
255
+ Returns (prob_mass_list, route_count_list), each a list of tensors of
256
+ shape [num_experts] for each MoE layer.
257
+ """
258
+ model.eval()
259
+ prob_mass: List[torch.Tensor] = []
260
+ route_cnt: List[torch.Tensor] = []
261
+
262
+ # Determine MoE layers using config
263
+ cfg = model.config
264
+ moe_layer_indices = list(range(cfg.first_k_dense_replace, cfg.num_hidden_layers))
265
+ if not moe_layer_indices:
266
+ return prob_mass, route_cnt
267
+
268
+ # Initialize accumulators lazily after first forward (to know num_experts)
269
+ initialized = False
270
+
271
+ batch_texts: List[str] = []
272
+ n_seen = 0
273
+ for txt in tqdm(texts, desc="Calculating MoE Expert Weights"):
274
+ if n_seen >= max_samples:
275
+ break
276
+ if not txt:
277
+ continue
278
+ batch_texts.append(txt)
279
+ if len(batch_texts) < batch_size and (n_seen + len(batch_texts)) < max_samples:
280
+ continue
281
+
282
+ enc = tokenizer(
283
+ batch_texts,
284
+ padding=True,
285
+ truncation=True,
286
+ max_length=seq_len,
287
+ return_tensors="pt",
288
+ return_token_type_ids=False,
289
+ )
290
+ enc = {k: v.to(device) for k, v in enc.items()}
291
+ out = model(**enc, use_cache=False, output_router_logits=True, return_dict=True)
292
+
293
+ # out.router_logits is a tuple per layer: (router_logits, topk_idx)
294
+ if not initialized:
295
+ # Create accumulators per MoE layer
296
+ for (r_logits, topk_idx) in out.router_logits:
297
+ num_experts_layer = r_logits.shape[-1]
298
+ prob_mass.append(torch.zeros(num_experts_layer, dtype=torch.float64))
299
+ route_cnt.append(torch.zeros(num_experts_layer, dtype=torch.float64))
300
+ initialized = True
301
+
302
+ for layer_i, (r_logits, topk_idx) in enumerate(out.router_logits):
303
+ probs = torch.sigmoid(r_logits).sum(dim=(0, 1)).double().cpu() # sum over batch, seq
304
+ prob_mass[layer_i] += probs
305
+ # Count selections via bincount on flattened topk indices
306
+ flat = topk_idx.reshape(-1).to(torch.int64).cpu()
307
+ bc = torch.bincount(flat, minlength=prob_mass[layer_i].numel()).double()
308
+ route_cnt[layer_i] += bc
309
+
310
+ n_seen += len(batch_texts)
311
+ batch_texts.clear()
312
+
313
+ if not initialized:
314
+ raise RuntimeError("No calibration samples were processed; check calib_path.")
315
+
316
+ return prob_mass, route_cnt
317
+
318
+
319
+ def per_group_topk_indices(
320
+ scores: torch.Tensor,
321
+ *,
322
+ n_group: int,
323
+ keep_per_group: int,
324
+ ) -> List[int]:
325
+ """Select top experts per group based on scores.
326
+
327
+ - scores: tensor [E]
328
+ - n_group: number of groups
329
+ - keep_per_group: how many experts to keep in each group
330
+
331
+ Returns list of kept expert indices in new order grouped contiguously by group.
332
+ """
333
+ E = scores.numel()
334
+ if E % n_group != 0:
335
+ raise ValueError(f"num_experts={E} must be divisible by n_group={n_group}")
336
+ per_group = E // n_group
337
+ keep: List[int] = []
338
+ for g in range(n_group):
339
+ start = g * per_group
340
+ end = start + per_group
341
+ sl = scores[start:end]
342
+ vals, idx = torch.topk(sl, k=keep_per_group, dim=0, largest=True, sorted=True)
343
+ keep.extend((start + idx).tolist())
344
+ return keep
345
+
346
+
347
+ def build_pruned_mlp_block(
348
+ old_block: nn.Module,
349
+ *,
350
+ new_cfg,
351
+ keep_indices: Sequence[int],
352
+ ) -> nn.Module:
353
+ """Create a new BailingMoeV2SparseMoeBlock with selected experts and remapped gate.
354
+
355
+ Assumes old_block is an instance of BailingMoeV2SparseMoeBlock.
356
+ """
357
+ # Lazy import to avoid import-time side effects when running help
358
+ from modeling_bailing_moe_v2 import BailingMoeV2SparseMoeBlock
359
+
360
+ new_block = BailingMoeV2SparseMoeBlock(new_cfg)
361
+
362
+ # Copy shared experts (if present)
363
+ if hasattr(old_block, "shared_experts") and hasattr(new_block, "shared_experts"):
364
+ for name in ("gate_proj", "up_proj", "down_proj"):
365
+ getattr(new_block.shared_experts, name).weight.data.copy_(
366
+ getattr(old_block.shared_experts, name).weight.data
367
+ )
368
+
369
+ # Copy selected experts in the new order
370
+ for new_idx, old_idx in enumerate(keep_indices):
371
+ old_exp = old_block.experts[old_idx]
372
+ new_exp = new_block.experts[new_idx]
373
+ for name in ("gate_proj", "up_proj", "down_proj"):
374
+ getattr(new_exp, name).weight.data.copy_(getattr(old_exp, name).weight.data)
375
+
376
+ # Remap gating weights and biases (if any)
377
+ new_block.gate.weight.data.copy_(old_block.gate.weight.data[keep_indices, :])
378
+ if hasattr(old_block.gate, "expert_bias") and hasattr(new_block.gate, "expert_bias"):
379
+ new_block.gate.expert_bias.data.copy_(old_block.gate.expert_bias.data[keep_indices])
380
+
381
+ return new_block
382
+
383
+
384
+ def prune_model_experts(
385
+ model, *,
386
+ keep_per_group: int,
387
+ scores_prob_mass: List[torch.Tensor],
388
+ scores_route_cnt: List[torch.Tensor],
389
+ score_mode: str,
390
+ alpha: float,
391
+ ) -> Tuple[object, Dict[str, List[int]]]:
392
+ """Prune experts per MoE layer in-place and return selection mapping.
393
+
394
+ - keep_per_group: number of experts kept per group in every MoE layer.
395
+ - score_mode: 'route_count' | 'prob_mass' | 'combined'
396
+ - alpha: weight for route_count in 'combined'
397
+ """
398
+ cfg = model.config
399
+ if keep_per_group * cfg.n_group < cfg.num_experts_per_tok:
400
+ raise ValueError("Keeping fewer experts than `num_experts_per_tok` is invalid.")
401
+
402
+ # Prepare a config clone with new num_experts
403
+ new_cfg = copy.deepcopy(cfg)
404
+ new_cfg.num_experts = keep_per_group * cfg.n_group
405
+
406
+ selection: Dict[str, List[int]] = {}
407
+
408
+ # Iterate MoE layers
409
+ moe_layers = list(range(cfg.first_k_dense_replace, cfg.num_hidden_layers))
410
+ for local_i, layer_idx in tqdm(enumerate(moe_layers), desc="Rebuilding MoE Layers"):
411
+ layer = model.model.layers[layer_idx]
412
+ old_block = layer.mlp
413
+ # Compute score
414
+ if score_mode == "route_count":
415
+ score_vec = scores_route_cnt[local_i]
416
+ elif score_mode == "prob_mass":
417
+ score_vec = scores_prob_mass[local_i]
418
+ elif score_mode == "combined":
419
+ # normalize then combine
420
+ rc = scores_route_cnt[local_i]
421
+ pm = scores_prob_mass[local_i]
422
+ rc = rc / (rc.sum() + 1e-9)
423
+ pm = pm / (pm.sum() + 1e-9)
424
+ score_vec = alpha * rc + (1 - alpha) * pm
425
+ else:
426
+ raise ValueError(f"Unknown score mode: {score_mode}")
427
+
428
+ keep_idx = per_group_topk_indices(
429
+ score_vec,
430
+ n_group=cfg.n_group,
431
+ keep_per_group=keep_per_group,
432
+ )
433
+ selection[f"layer_{layer_idx}"] = keep_idx
434
+
435
+ # Rebuild this MoE block and swap
436
+ new_block = build_pruned_mlp_block(old_block, new_cfg=new_cfg, keep_indices=keep_idx)
437
+ layer.mlp = new_block
438
+
439
+ # Update top-level config
440
+ model.config.num_experts = new_cfg.num_experts
441
+ return model, selection
442
+
443
+
444
+ def main(argv: Optional[Sequence[str]] = None) -> None:
445
+ p = argparse.ArgumentParser(description="Prune Ring-mini-2.0 MoE experts using a calibration set")
446
+ p.add_argument("--model", type=str, required=True, help="Model path or HF repo id (trust_remote_code=True)")
447
+ p.add_argument("--output_dir", type=str, required=True, help="Where to save the pruned model")
448
+ p.add_argument("--calib_path", type=str, default=None, help="Path to calibration data (.txt dir or .jsonl)")
449
+ p.add_argument("--tokenizer", type=str, default=None, help="Optional tokenizer path; defaults to --model")
450
+ p.add_argument("--device", type=str, default="cuda" if torch.cuda.is_available() else "cpu")
451
+ p.add_argument("--dtype", type=str, default="auto", help="auto|fp16|bf16|fp32")
452
+ p.add_argument("--device_map", type=str, default=None, help="Optional accelerate device_map like 'auto'")
453
+ p.add_argument("--seed", type=int, default=42)
454
+ p.add_argument("--samples", type=int, default=200, help="Number of texts to use for calibration")
455
+ p.add_argument("--seq_len", type=int, default=512)
456
+ p.add_argument("--batch_size", type=int, default=4)
457
+ p.add_argument("--score", type=str, default="route_count", choices=["route_count", "prob_mass", "combined"])
458
+ p.add_argument("--alpha", type=float, default=0.7, help="Weight for route_count in combined scoring")
459
+ p.add_argument("--target_experts", type=int, default=None, help="Experts per layer to keep (divisible by n_group)")
460
+ p.add_argument("--target_total_params", type=int, default=None, help="Approximate total params budget, e.g. 10000000000 for ~10B")
461
+ p.add_argument("--dry_run", action="store_true", help="Collect stats and print plan, but do not prune or save")
462
+ args = p.parse_args(argv)
463
+
464
+ set_seed(args.seed)
465
+ dtype = infer_dtype(args.dtype)
466
+
467
+ # Load tokenizer
468
+ tok_name = args.tokenizer or args.model
469
+ tokenizer = AutoTokenizer.from_pretrained(tok_name, trust_remote_code=True)
470
+
471
+ # Load model (weights required to get routing behavior)
472
+ model_kwargs = dict(torch_dtype=dtype, trust_remote_code=True)
473
+ if args.device_map:
474
+ model_kwargs["device_map"] = args.device_map
475
+ model = AutoModelForCausalLM.from_pretrained(args.model, **model_kwargs)
476
+ if args.device_map is None:
477
+ model.to(args.device)
478
+
479
+ cfg = model.config
480
+
481
+ # Determine target experts per layer
482
+ if args.target_experts is not None and args.target_total_params is not None:
483
+ print("Both --target_experts and --target_total_params provided; --target_experts takes precedence.")
484
+
485
+ if args.target_experts is not None:
486
+ target_experts = int(args.target_experts)
487
+ elif args.target_total_params is not None:
488
+ target_experts = solve_target_experts_for_budget(cfg, int(args.target_total_params))
489
+ print(f"Resolved experts/layer for target params ≈ {args.target_total_params}: {target_experts}")
490
+ else:
491
+ # Default to a 144 experts/layer target (≈10B for Ring-mini-2.0 defaults)
492
+ target_experts = 144
493
+ print("No target specified; defaulting to --target_experts 144 (~10B for default config)")
494
+
495
+ if target_experts % cfg.n_group != 0:
496
+ raise ValueError(f"target_experts={target_experts} must be divisible by n_group={cfg.n_group}")
497
+ if target_experts < cfg.num_experts_per_tok:
498
+ raise ValueError(f"target_experts={target_experts} must be >= num_experts_per_tok={cfg.num_experts_per_tok}")
499
+
500
+ keep_per_group = target_experts // cfg.n_group
501
+ print(f"Target experts per layer: {target_experts} ({keep_per_group} per group × {cfg.n_group} groups)")
502
+
503
+ # Collect calibration stats
504
+ if args.calib_path is None:
505
+ raise ValueError("--calib_path is required to compute routing-based scores")
506
+ texts = iter_texts(args.calib_path)
507
+ prob_mass, route_cnt = collect_moe_stats(
508
+ model, tokenizer, texts,
509
+ max_samples=args.samples, seq_len=args.seq_len, batch_size=args.batch_size, device=args.device,
510
+ )
511
+ print("Collected MoE routing statistics.")
512
+
513
+ if args.dry_run:
514
+ print("--dry_run set; skipping pruning and save.")
515
+ return
516
+
517
+ # Prune experts per MoE layer
518
+ model, selection = prune_model_experts(
519
+ model,
520
+ keep_per_group=keep_per_group,
521
+ scores_prob_mass=prob_mass,
522
+ scores_route_cnt=route_cnt,
523
+ score_mode=args.score,
524
+ alpha=args.alpha,
525
+ )
526
+
527
+ os.makedirs(args.output_dir, exist_ok=True)
528
+ # Save selection mapping for transparency
529
+ with open(os.path.join(args.output_dir, "expert_selection.json"), "w", encoding="utf-8") as f:
530
+ json.dump(selection, f, indent=2)
531
+
532
+ # Save model + tokenizer
533
+ # Default to saving weights in BF16 regardless of compute dtype.
534
+ # This keeps runtime/calibration flexible while ensuring compact BF16 checkpoints.
535
+ try:
536
+ model.to(torch.bfloat16)
537
+ except Exception as e:
538
+ print(f"Warning: failed to cast model to BF16 before saving; saving current dtype. Error: {e}")
539
+ model.save_pretrained(args.output_dir, safe_serialization=True)
540
+ tokenizer.save_pretrained(args.output_dir)
541
+ print(f"Saved pruned model to {args.output_dir}")
542
+
543
+ # Print number of parameters of the model
544
+ total_params = sum(p.numel() for p in model.parameters())
545
+ print(f"Total number of parameters in the model: {total_params}")
546
+
547
+
548
+ if __name__ == "__main__":
549
+ main()
pruning-code/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|startoftext|>",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "<|endoftext|>",
5
+ "gmask_token": "[gMASK]",
6
+ "pad_token": "<|endoftext|>"
7
+ }
pruning-code/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
pruning-code/tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "bos_token": "<|startoftext|>",
5
+ "chat_template": "{% for message in messages %}{% set role = message['role'] | lower %}{% if role == 'user' %}{% set role = 'HUMAN' %}{% endif %}{% set role = role | upper %}{{ '<role>' + role + '</role>' + message['content'] }}{% endfor %}{% if add_generation_prompt %}{{ '<role>ASSISTANT</role><think>\n' }}{% endif %}",
6
+ "clean_up_tokenization_spaces": false,
7
+ "cls_token": "[CLS]",
8
+ "eos_token": "<|endoftext|>",
9
+ "fast_tokenizer": true,
10
+ "gmask_token": "[gMASK]",
11
+ "merges_file": null,
12
+ "model_max_length": 1000000000000000019884624838656,
13
+ "pad_token": "<|endoftext|>",
14
+ "tokenizer_class": "PreTrainedTokenizerFast",
15
+ "trust_remote_code": true,
16
+ "vocab_file": null
17
+ }
special_tokens_map.json CHANGED
@@ -1,7 +1,30 @@
1
  {
2
- "bos_token": "<|startoftext|>",
3
- "cls_token": "[CLS]",
4
- "eos_token": "<|endoftext|>",
5
- "gmask_token": "[gMASK]",
6
- "pad_token": "<|endoftext|>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
 
1
  {
2
+ "bos_token": {
3
+ "content": "<|startoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "[CLS]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "pad_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
  }
tokenizer.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
@@ -1,17 +1,2114 @@
1
  {
2
  "add_bos_token": false,
3
  "add_eos_token": false,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  "bos_token": "<|startoftext|>",
5
- "chat_template": "{% for message in messages %}{% set role = message['role'] | lower %}{% if role == 'user' %}{% set role = 'HUMAN' %}{% endif %}{% set role = role | upper %}{{ '<role>' + role + '</role>' + message['content'] }}{% endfor %}{% if add_generation_prompt %}{{ '<role>ASSISTANT</role><think>\n' }}{% endif %}",
6
  "clean_up_tokenization_spaces": false,
7
  "cls_token": "[CLS]",
8
  "eos_token": "<|endoftext|>",
 
9
  "fast_tokenizer": true,
10
  "gmask_token": "[gMASK]",
11
  "merges_file": null,
12
  "model_max_length": 1000000000000000019884624838656,
13
  "pad_token": "<|endoftext|>",
14
  "tokenizer_class": "PreTrainedTokenizerFast",
15
- "trust_remote_code": true,
16
- "vocab_file": null
17
  }
 
1
  {
2
  "add_bos_token": false,
3
  "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "156891": {
6
+ "content": "<|startoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "156892": {
14
+ "content": "<|endoftext|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "156893": {
22
+ "content": "[CLS]",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "156894": {
30
+ "content": "[gMASK]",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "156895": {
38
+ "content": "<|reserved_token_0|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "156896": {
46
+ "content": "<|reserved_token_1|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "156897": {
54
+ "content": "<|reserved_token_2|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "156898": {
62
+ "content": "<|reserved_token_3|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "156899": {
70
+ "content": "<|reserved_token_4|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "156900": {
78
+ "content": "<|reserved_token_5|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "156901": {
86
+ "content": "<|reserved_token_6|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "156902": {
94
+ "content": "<|reserved_token_7|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "156903": {
102
+ "content": "<|reserved_token_8|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "156904": {
110
+ "content": "<|reserved_token_9|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "156905": {
118
+ "content": "<|reserved_token_10|>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": true
124
+ },
125
+ "156906": {
126
+ "content": "<|reserved_token_11|>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": true
132
+ },
133
+ "156907": {
134
+ "content": "<|reserved_token_12|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": true
140
+ },
141
+ "156908": {
142
+ "content": "<|reserved_token_13|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": true
148
+ },
149
+ "156909": {
150
+ "content": "<|reserved_token_14|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": true
156
+ },
157
+ "156910": {
158
+ "content": "<|reserved_token_15|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": true
164
+ },
165
+ "156911": {
166
+ "content": "<|reserved_token_16|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": true
172
+ },
173
+ "156912": {
174
+ "content": "<|reserved_token_17|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": true
180
+ },
181
+ "156913": {
182
+ "content": "<|reserved_token_18|>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": true
188
+ },
189
+ "156914": {
190
+ "content": "<|reserved_token_19|>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": true
196
+ },
197
+ "156915": {
198
+ "content": "<|reserved_token_20|>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": true
204
+ },
205
+ "156916": {
206
+ "content": "<|reserved_token_21|>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": true
212
+ },
213
+ "156917": {
214
+ "content": "<|reserved_token_22|>",
215
+ "lstrip": false,
216
+ "normalized": false,
217
+ "rstrip": false,
218
+ "single_word": false,
219
+ "special": true
220
+ },
221
+ "156918": {
222
+ "content": "<|reserved_token_23|>",
223
+ "lstrip": false,
224
+ "normalized": false,
225
+ "rstrip": false,
226
+ "single_word": false,
227
+ "special": true
228
+ },
229
+ "156919": {
230
+ "content": "<|reserved_token_24|>",
231
+ "lstrip": false,
232
+ "normalized": false,
233
+ "rstrip": false,
234
+ "single_word": false,
235
+ "special": true
236
+ },
237
+ "156920": {
238
+ "content": "<|reserved_token_25|>",
239
+ "lstrip": false,
240
+ "normalized": false,
241
+ "rstrip": false,
242
+ "single_word": false,
243
+ "special": true
244
+ },
245
+ "156921": {
246
+ "content": "<|reserved_token_26|>",
247
+ "lstrip": false,
248
+ "normalized": false,
249
+ "rstrip": false,
250
+ "single_word": false,
251
+ "special": true
252
+ },
253
+ "156922": {
254
+ "content": "<|reserved_token_27|>",
255
+ "lstrip": false,
256
+ "normalized": false,
257
+ "rstrip": false,
258
+ "single_word": false,
259
+ "special": true
260
+ },
261
+ "156923": {
262
+ "content": "<|reserved_token_28|>",
263
+ "lstrip": false,
264
+ "normalized": false,
265
+ "rstrip": false,
266
+ "single_word": false,
267
+ "special": true
268
+ },
269
+ "156924": {
270
+ "content": "<|reserved_token_29|>",
271
+ "lstrip": false,
272
+ "normalized": false,
273
+ "rstrip": false,
274
+ "single_word": false,
275
+ "special": true
276
+ },
277
+ "156925": {
278
+ "content": "<|reserved_token_30|>",
279
+ "lstrip": false,
280
+ "normalized": false,
281
+ "rstrip": false,
282
+ "single_word": false,
283
+ "special": true
284
+ },
285
+ "156926": {
286
+ "content": "<|reserved_token_31|>",
287
+ "lstrip": false,
288
+ "normalized": false,
289
+ "rstrip": false,
290
+ "single_word": false,
291
+ "special": true
292
+ },
293
+ "156927": {
294
+ "content": "<|reserved_token_32|>",
295
+ "lstrip": false,
296
+ "normalized": false,
297
+ "rstrip": false,
298
+ "single_word": false,
299
+ "special": true
300
+ },
301
+ "156928": {
302
+ "content": "<|reserved_token_33|>",
303
+ "lstrip": false,
304
+ "normalized": false,
305
+ "rstrip": false,
306
+ "single_word": false,
307
+ "special": true
308
+ },
309
+ "156929": {
310
+ "content": "<|reserved_token_34|>",
311
+ "lstrip": false,
312
+ "normalized": false,
313
+ "rstrip": false,
314
+ "single_word": false,
315
+ "special": true
316
+ },
317
+ "156930": {
318
+ "content": "<|reserved_token_35|>",
319
+ "lstrip": false,
320
+ "normalized": false,
321
+ "rstrip": false,
322
+ "single_word": false,
323
+ "special": true
324
+ },
325
+ "156931": {
326
+ "content": "<|reserved_token_36|>",
327
+ "lstrip": false,
328
+ "normalized": false,
329
+ "rstrip": false,
330
+ "single_word": false,
331
+ "special": true
332
+ },
333
+ "156932": {
334
+ "content": "<|reserved_token_37|>",
335
+ "lstrip": false,
336
+ "normalized": false,
337
+ "rstrip": false,
338
+ "single_word": false,
339
+ "special": true
340
+ },
341
+ "156933": {
342
+ "content": "<|reserved_token_38|>",
343
+ "lstrip": false,
344
+ "normalized": false,
345
+ "rstrip": false,
346
+ "single_word": false,
347
+ "special": true
348
+ },
349
+ "156934": {
350
+ "content": "<|reserved_token_39|>",
351
+ "lstrip": false,
352
+ "normalized": false,
353
+ "rstrip": false,
354
+ "single_word": false,
355
+ "special": true
356
+ },
357
+ "156935": {
358
+ "content": "<|reserved_token_40|>",
359
+ "lstrip": false,
360
+ "normalized": false,
361
+ "rstrip": false,
362
+ "single_word": false,
363
+ "special": true
364
+ },
365
+ "156936": {
366
+ "content": "<|reserved_token_41|>",
367
+ "lstrip": false,
368
+ "normalized": false,
369
+ "rstrip": false,
370
+ "single_word": false,
371
+ "special": true
372
+ },
373
+ "156937": {
374
+ "content": "<|reserved_token_42|>",
375
+ "lstrip": false,
376
+ "normalized": false,
377
+ "rstrip": false,
378
+ "single_word": false,
379
+ "special": true
380
+ },
381
+ "156938": {
382
+ "content": "<|reserved_token_43|>",
383
+ "lstrip": false,
384
+ "normalized": false,
385
+ "rstrip": false,
386
+ "single_word": false,
387
+ "special": true
388
+ },
389
+ "156939": {
390
+ "content": "<|reserved_token_44|>",
391
+ "lstrip": false,
392
+ "normalized": false,
393
+ "rstrip": false,
394
+ "single_word": false,
395
+ "special": true
396
+ },
397
+ "156940": {
398
+ "content": "<|reserved_token_45|>",
399
+ "lstrip": false,
400
+ "normalized": false,
401
+ "rstrip": false,
402
+ "single_word": false,
403
+ "special": true
404
+ },
405
+ "156941": {
406
+ "content": "<|reserved_token_46|>",
407
+ "lstrip": false,
408
+ "normalized": false,
409
+ "rstrip": false,
410
+ "single_word": false,
411
+ "special": true
412
+ },
413
+ "156942": {
414
+ "content": "<|reserved_token_47|>",
415
+ "lstrip": false,
416
+ "normalized": false,
417
+ "rstrip": false,
418
+ "single_word": false,
419
+ "special": true
420
+ },
421
+ "156943": {
422
+ "content": "<|reserved_token_48|>",
423
+ "lstrip": false,
424
+ "normalized": false,
425
+ "rstrip": false,
426
+ "single_word": false,
427
+ "special": true
428
+ },
429
+ "156944": {
430
+ "content": "<|reserved_token_49|>",
431
+ "lstrip": false,
432
+ "normalized": false,
433
+ "rstrip": false,
434
+ "single_word": false,
435
+ "special": true
436
+ },
437
+ "156945": {
438
+ "content": "<|reserved_token_50|>",
439
+ "lstrip": false,
440
+ "normalized": false,
441
+ "rstrip": false,
442
+ "single_word": false,
443
+ "special": true
444
+ },
445
+ "156946": {
446
+ "content": "<|reserved_token_51|>",
447
+ "lstrip": false,
448
+ "normalized": false,
449
+ "rstrip": false,
450
+ "single_word": false,
451
+ "special": true
452
+ },
453
+ "156947": {
454
+ "content": "<|reserved_token_52|>",
455
+ "lstrip": false,
456
+ "normalized": false,
457
+ "rstrip": false,
458
+ "single_word": false,
459
+ "special": true
460
+ },
461
+ "156948": {
462
+ "content": "<|reserved_token_53|>",
463
+ "lstrip": false,
464
+ "normalized": false,
465
+ "rstrip": false,
466
+ "single_word": false,
467
+ "special": true
468
+ },
469
+ "156949": {
470
+ "content": "<|reserved_token_54|>",
471
+ "lstrip": false,
472
+ "normalized": false,
473
+ "rstrip": false,
474
+ "single_word": false,
475
+ "special": true
476
+ },
477
+ "156950": {
478
+ "content": "<|reserved_token_55|>",
479
+ "lstrip": false,
480
+ "normalized": false,
481
+ "rstrip": false,
482
+ "single_word": false,
483
+ "special": true
484
+ },
485
+ "156951": {
486
+ "content": "<|reserved_token_56|>",
487
+ "lstrip": false,
488
+ "normalized": false,
489
+ "rstrip": false,
490
+ "single_word": false,
491
+ "special": true
492
+ },
493
+ "156952": {
494
+ "content": "<|reserved_token_57|>",
495
+ "lstrip": false,
496
+ "normalized": false,
497
+ "rstrip": false,
498
+ "single_word": false,
499
+ "special": true
500
+ },
501
+ "156953": {
502
+ "content": "<|reserved_token_58|>",
503
+ "lstrip": false,
504
+ "normalized": false,
505
+ "rstrip": false,
506
+ "single_word": false,
507
+ "special": true
508
+ },
509
+ "156954": {
510
+ "content": "<|reserved_token_59|>",
511
+ "lstrip": false,
512
+ "normalized": false,
513
+ "rstrip": false,
514
+ "single_word": false,
515
+ "special": true
516
+ },
517
+ "156955": {
518
+ "content": "<|reserved_token_60|>",
519
+ "lstrip": false,
520
+ "normalized": false,
521
+ "rstrip": false,
522
+ "single_word": false,
523
+ "special": true
524
+ },
525
+ "156956": {
526
+ "content": "<|reserved_token_61|>",
527
+ "lstrip": false,
528
+ "normalized": false,
529
+ "rstrip": false,
530
+ "single_word": false,
531
+ "special": true
532
+ },
533
+ "156957": {
534
+ "content": "<|reserved_token_62|>",
535
+ "lstrip": false,
536
+ "normalized": false,
537
+ "rstrip": false,
538
+ "single_word": false,
539
+ "special": true
540
+ },
541
+ "156958": {
542
+ "content": "<|reserved_token_63|>",
543
+ "lstrip": false,
544
+ "normalized": false,
545
+ "rstrip": false,
546
+ "single_word": false,
547
+ "special": true
548
+ },
549
+ "156959": {
550
+ "content": "<|reserved_token_64|>",
551
+ "lstrip": false,
552
+ "normalized": false,
553
+ "rstrip": false,
554
+ "single_word": false,
555
+ "special": true
556
+ },
557
+ "156960": {
558
+ "content": "<|reserved_token_65|>",
559
+ "lstrip": false,
560
+ "normalized": false,
561
+ "rstrip": false,
562
+ "single_word": false,
563
+ "special": true
564
+ },
565
+ "156961": {
566
+ "content": "<|reserved_token_66|>",
567
+ "lstrip": false,
568
+ "normalized": false,
569
+ "rstrip": false,
570
+ "single_word": false,
571
+ "special": true
572
+ },
573
+ "156962": {
574
+ "content": "<|reserved_token_67|>",
575
+ "lstrip": false,
576
+ "normalized": false,
577
+ "rstrip": false,
578
+ "single_word": false,
579
+ "special": true
580
+ },
581
+ "156963": {
582
+ "content": "<|reserved_token_68|>",
583
+ "lstrip": false,
584
+ "normalized": false,
585
+ "rstrip": false,
586
+ "single_word": false,
587
+ "special": true
588
+ },
589
+ "156964": {
590
+ "content": "<|reserved_token_69|>",
591
+ "lstrip": false,
592
+ "normalized": false,
593
+ "rstrip": false,
594
+ "single_word": false,
595
+ "special": true
596
+ },
597
+ "156965": {
598
+ "content": "<|reserved_token_70|>",
599
+ "lstrip": false,
600
+ "normalized": false,
601
+ "rstrip": false,
602
+ "single_word": false,
603
+ "special": true
604
+ },
605
+ "156966": {
606
+ "content": "<|reserved_token_71|>",
607
+ "lstrip": false,
608
+ "normalized": false,
609
+ "rstrip": false,
610
+ "single_word": false,
611
+ "special": true
612
+ },
613
+ "156967": {
614
+ "content": "<|reserved_token_72|>",
615
+ "lstrip": false,
616
+ "normalized": false,
617
+ "rstrip": false,
618
+ "single_word": false,
619
+ "special": true
620
+ },
621
+ "156968": {
622
+ "content": "<|reserved_token_73|>",
623
+ "lstrip": false,
624
+ "normalized": false,
625
+ "rstrip": false,
626
+ "single_word": false,
627
+ "special": true
628
+ },
629
+ "156969": {
630
+ "content": "<|reserved_token_74|>",
631
+ "lstrip": false,
632
+ "normalized": false,
633
+ "rstrip": false,
634
+ "single_word": false,
635
+ "special": true
636
+ },
637
+ "156970": {
638
+ "content": "<|reserved_token_75|>",
639
+ "lstrip": false,
640
+ "normalized": false,
641
+ "rstrip": false,
642
+ "single_word": false,
643
+ "special": true
644
+ },
645
+ "156971": {
646
+ "content": "<|reserved_token_76|>",
647
+ "lstrip": false,
648
+ "normalized": false,
649
+ "rstrip": false,
650
+ "single_word": false,
651
+ "special": true
652
+ },
653
+ "156972": {
654
+ "content": "<|reserved_token_77|>",
655
+ "lstrip": false,
656
+ "normalized": false,
657
+ "rstrip": false,
658
+ "single_word": false,
659
+ "special": true
660
+ },
661
+ "156973": {
662
+ "content": "<|reserved_token_78|>",
663
+ "lstrip": false,
664
+ "normalized": false,
665
+ "rstrip": false,
666
+ "single_word": false,
667
+ "special": true
668
+ },
669
+ "156974": {
670
+ "content": "<|reserved_token_79|>",
671
+ "lstrip": false,
672
+ "normalized": false,
673
+ "rstrip": false,
674
+ "single_word": false,
675
+ "special": true
676
+ },
677
+ "156975": {
678
+ "content": "<|reserved_token_80|>",
679
+ "lstrip": false,
680
+ "normalized": false,
681
+ "rstrip": false,
682
+ "single_word": false,
683
+ "special": true
684
+ },
685
+ "156976": {
686
+ "content": "<|reserved_token_81|>",
687
+ "lstrip": false,
688
+ "normalized": false,
689
+ "rstrip": false,
690
+ "single_word": false,
691
+ "special": true
692
+ },
693
+ "156977": {
694
+ "content": "<|reserved_token_82|>",
695
+ "lstrip": false,
696
+ "normalized": false,
697
+ "rstrip": false,
698
+ "single_word": false,
699
+ "special": true
700
+ },
701
+ "156978": {
702
+ "content": "<|reserved_token_83|>",
703
+ "lstrip": false,
704
+ "normalized": false,
705
+ "rstrip": false,
706
+ "single_word": false,
707
+ "special": true
708
+ },
709
+ "156979": {
710
+ "content": "<|reserved_token_84|>",
711
+ "lstrip": false,
712
+ "normalized": false,
713
+ "rstrip": false,
714
+ "single_word": false,
715
+ "special": true
716
+ },
717
+ "156980": {
718
+ "content": "<|reserved_token_85|>",
719
+ "lstrip": false,
720
+ "normalized": false,
721
+ "rstrip": false,
722
+ "single_word": false,
723
+ "special": true
724
+ },
725
+ "156981": {
726
+ "content": "<|reserved_token_86|>",
727
+ "lstrip": false,
728
+ "normalized": false,
729
+ "rstrip": false,
730
+ "single_word": false,
731
+ "special": true
732
+ },
733
+ "156982": {
734
+ "content": "<|reserved_token_87|>",
735
+ "lstrip": false,
736
+ "normalized": false,
737
+ "rstrip": false,
738
+ "single_word": false,
739
+ "special": true
740
+ },
741
+ "156983": {
742
+ "content": "<|reserved_token_88|>",
743
+ "lstrip": false,
744
+ "normalized": false,
745
+ "rstrip": false,
746
+ "single_word": false,
747
+ "special": true
748
+ },
749
+ "156984": {
750
+ "content": "<|reserved_token_89|>",
751
+ "lstrip": false,
752
+ "normalized": false,
753
+ "rstrip": false,
754
+ "single_word": false,
755
+ "special": true
756
+ },
757
+ "156985": {
758
+ "content": "<|reserved_token_90|>",
759
+ "lstrip": false,
760
+ "normalized": false,
761
+ "rstrip": false,
762
+ "single_word": false,
763
+ "special": true
764
+ },
765
+ "156986": {
766
+ "content": "<|reserved_token_91|>",
767
+ "lstrip": false,
768
+ "normalized": false,
769
+ "rstrip": false,
770
+ "single_word": false,
771
+ "special": true
772
+ },
773
+ "156987": {
774
+ "content": "<|reserved_token_92|>",
775
+ "lstrip": false,
776
+ "normalized": false,
777
+ "rstrip": false,
778
+ "single_word": false,
779
+ "special": true
780
+ },
781
+ "156988": {
782
+ "content": "<|reserved_token_93|>",
783
+ "lstrip": false,
784
+ "normalized": false,
785
+ "rstrip": false,
786
+ "single_word": false,
787
+ "special": true
788
+ },
789
+ "156989": {
790
+ "content": "<|reserved_token_94|>",
791
+ "lstrip": false,
792
+ "normalized": false,
793
+ "rstrip": false,
794
+ "single_word": false,
795
+ "special": true
796
+ },
797
+ "156990": {
798
+ "content": "<|reserved_token_95|>",
799
+ "lstrip": false,
800
+ "normalized": false,
801
+ "rstrip": false,
802
+ "single_word": false,
803
+ "special": true
804
+ },
805
+ "156991": {
806
+ "content": "<|reserved_token_96|>",
807
+ "lstrip": false,
808
+ "normalized": false,
809
+ "rstrip": false,
810
+ "single_word": false,
811
+ "special": true
812
+ },
813
+ "156992": {
814
+ "content": "<|reserved_token_97|>",
815
+ "lstrip": false,
816
+ "normalized": false,
817
+ "rstrip": false,
818
+ "single_word": false,
819
+ "special": true
820
+ },
821
+ "156993": {
822
+ "content": "<|reserved_token_98|>",
823
+ "lstrip": false,
824
+ "normalized": false,
825
+ "rstrip": false,
826
+ "single_word": false,
827
+ "special": true
828
+ },
829
+ "156994": {
830
+ "content": "<|reserved_token_99|>",
831
+ "lstrip": false,
832
+ "normalized": false,
833
+ "rstrip": false,
834
+ "single_word": false,
835
+ "special": true
836
+ },
837
+ "156995": {
838
+ "content": "<|reserved_token_100|>",
839
+ "lstrip": false,
840
+ "normalized": false,
841
+ "rstrip": false,
842
+ "single_word": false,
843
+ "special": true
844
+ },
845
+ "156996": {
846
+ "content": "<|reserved_token_101|>",
847
+ "lstrip": false,
848
+ "normalized": false,
849
+ "rstrip": false,
850
+ "single_word": false,
851
+ "special": true
852
+ },
853
+ "156997": {
854
+ "content": "<|reserved_token_102|>",
855
+ "lstrip": false,
856
+ "normalized": false,
857
+ "rstrip": false,
858
+ "single_word": false,
859
+ "special": true
860
+ },
861
+ "156998": {
862
+ "content": "<|reserved_token_103|>",
863
+ "lstrip": false,
864
+ "normalized": false,
865
+ "rstrip": false,
866
+ "single_word": false,
867
+ "special": true
868
+ },
869
+ "156999": {
870
+ "content": "<|reserved_token_104|>",
871
+ "lstrip": false,
872
+ "normalized": false,
873
+ "rstrip": false,
874
+ "single_word": false,
875
+ "special": true
876
+ },
877
+ "157000": {
878
+ "content": "<|reserved_token_105|>",
879
+ "lstrip": false,
880
+ "normalized": false,
881
+ "rstrip": false,
882
+ "single_word": false,
883
+ "special": true
884
+ },
885
+ "157001": {
886
+ "content": "<|reserved_token_106|>",
887
+ "lstrip": false,
888
+ "normalized": false,
889
+ "rstrip": false,
890
+ "single_word": false,
891
+ "special": true
892
+ },
893
+ "157002": {
894
+ "content": "<|reserved_token_107|>",
895
+ "lstrip": false,
896
+ "normalized": false,
897
+ "rstrip": false,
898
+ "single_word": false,
899
+ "special": true
900
+ },
901
+ "157003": {
902
+ "content": "<|reserved_token_108|>",
903
+ "lstrip": false,
904
+ "normalized": false,
905
+ "rstrip": false,
906
+ "single_word": false,
907
+ "special": true
908
+ },
909
+ "157004": {
910
+ "content": "<|reserved_token_109|>",
911
+ "lstrip": false,
912
+ "normalized": false,
913
+ "rstrip": false,
914
+ "single_word": false,
915
+ "special": true
916
+ },
917
+ "157005": {
918
+ "content": "<|reserved_token_110|>",
919
+ "lstrip": false,
920
+ "normalized": false,
921
+ "rstrip": false,
922
+ "single_word": false,
923
+ "special": true
924
+ },
925
+ "157006": {
926
+ "content": "<|reserved_token_111|>",
927
+ "lstrip": false,
928
+ "normalized": false,
929
+ "rstrip": false,
930
+ "single_word": false,
931
+ "special": true
932
+ },
933
+ "157007": {
934
+ "content": "<|reserved_token_112|>",
935
+ "lstrip": false,
936
+ "normalized": false,
937
+ "rstrip": false,
938
+ "single_word": false,
939
+ "special": true
940
+ },
941
+ "157008": {
942
+ "content": "<|reserved_token_113|>",
943
+ "lstrip": false,
944
+ "normalized": false,
945
+ "rstrip": false,
946
+ "single_word": false,
947
+ "special": true
948
+ },
949
+ "157009": {
950
+ "content": "<|reserved_token_114|>",
951
+ "lstrip": false,
952
+ "normalized": false,
953
+ "rstrip": false,
954
+ "single_word": false,
955
+ "special": true
956
+ },
957
+ "157010": {
958
+ "content": "<|reserved_token_115|>",
959
+ "lstrip": false,
960
+ "normalized": false,
961
+ "rstrip": false,
962
+ "single_word": false,
963
+ "special": true
964
+ },
965
+ "157011": {
966
+ "content": "<|reserved_token_116|>",
967
+ "lstrip": false,
968
+ "normalized": false,
969
+ "rstrip": false,
970
+ "single_word": false,
971
+ "special": true
972
+ },
973
+ "157012": {
974
+ "content": "<|reserved_token_117|>",
975
+ "lstrip": false,
976
+ "normalized": false,
977
+ "rstrip": false,
978
+ "single_word": false,
979
+ "special": true
980
+ },
981
+ "157013": {
982
+ "content": "<|reserved_token_118|>",
983
+ "lstrip": false,
984
+ "normalized": false,
985
+ "rstrip": false,
986
+ "single_word": false,
987
+ "special": true
988
+ },
989
+ "157014": {
990
+ "content": "<|reserved_token_119|>",
991
+ "lstrip": false,
992
+ "normalized": false,
993
+ "rstrip": false,
994
+ "single_word": false,
995
+ "special": true
996
+ },
997
+ "157015": {
998
+ "content": "<|reserved_token_120|>",
999
+ "lstrip": false,
1000
+ "normalized": false,
1001
+ "rstrip": false,
1002
+ "single_word": false,
1003
+ "special": true
1004
+ },
1005
+ "157016": {
1006
+ "content": "<|reserved_token_121|>",
1007
+ "lstrip": false,
1008
+ "normalized": false,
1009
+ "rstrip": false,
1010
+ "single_word": false,
1011
+ "special": true
1012
+ },
1013
+ "157017": {
1014
+ "content": "<|reserved_token_122|>",
1015
+ "lstrip": false,
1016
+ "normalized": false,
1017
+ "rstrip": false,
1018
+ "single_word": false,
1019
+ "special": true
1020
+ },
1021
+ "157018": {
1022
+ "content": "<|reserved_token_123|>",
1023
+ "lstrip": false,
1024
+ "normalized": false,
1025
+ "rstrip": false,
1026
+ "single_word": false,
1027
+ "special": true
1028
+ },
1029
+ "157019": {
1030
+ "content": "<|reserved_token_124|>",
1031
+ "lstrip": false,
1032
+ "normalized": false,
1033
+ "rstrip": false,
1034
+ "single_word": false,
1035
+ "special": true
1036
+ },
1037
+ "157020": {
1038
+ "content": "<|reserved_token_125|>",
1039
+ "lstrip": false,
1040
+ "normalized": false,
1041
+ "rstrip": false,
1042
+ "single_word": false,
1043
+ "special": true
1044
+ },
1045
+ "157021": {
1046
+ "content": "<|reserved_token_126|>",
1047
+ "lstrip": false,
1048
+ "normalized": false,
1049
+ "rstrip": false,
1050
+ "single_word": false,
1051
+ "special": true
1052
+ },
1053
+ "157022": {
1054
+ "content": "<|reserved_token_127|>",
1055
+ "lstrip": false,
1056
+ "normalized": false,
1057
+ "rstrip": false,
1058
+ "single_word": false,
1059
+ "special": true
1060
+ },
1061
+ "157023": {
1062
+ "content": "<|reserved_token_128|>",
1063
+ "lstrip": false,
1064
+ "normalized": false,
1065
+ "rstrip": false,
1066
+ "single_word": false,
1067
+ "special": true
1068
+ },
1069
+ "157024": {
1070
+ "content": "<|reserved_token_129|>",
1071
+ "lstrip": false,
1072
+ "normalized": false,
1073
+ "rstrip": false,
1074
+ "single_word": false,
1075
+ "special": true
1076
+ },
1077
+ "157025": {
1078
+ "content": "<|reserved_token_130|>",
1079
+ "lstrip": false,
1080
+ "normalized": false,
1081
+ "rstrip": false,
1082
+ "single_word": false,
1083
+ "special": true
1084
+ },
1085
+ "157026": {
1086
+ "content": "<|reserved_token_131|>",
1087
+ "lstrip": false,
1088
+ "normalized": false,
1089
+ "rstrip": false,
1090
+ "single_word": false,
1091
+ "special": true
1092
+ },
1093
+ "157027": {
1094
+ "content": "<|reserved_token_132|>",
1095
+ "lstrip": false,
1096
+ "normalized": false,
1097
+ "rstrip": false,
1098
+ "single_word": false,
1099
+ "special": true
1100
+ },
1101
+ "157028": {
1102
+ "content": "<|reserved_token_133|>",
1103
+ "lstrip": false,
1104
+ "normalized": false,
1105
+ "rstrip": false,
1106
+ "single_word": false,
1107
+ "special": true
1108
+ },
1109
+ "157029": {
1110
+ "content": "<|reserved_token_134|>",
1111
+ "lstrip": false,
1112
+ "normalized": false,
1113
+ "rstrip": false,
1114
+ "single_word": false,
1115
+ "special": true
1116
+ },
1117
+ "157030": {
1118
+ "content": "<|reserved_token_135|>",
1119
+ "lstrip": false,
1120
+ "normalized": false,
1121
+ "rstrip": false,
1122
+ "single_word": false,
1123
+ "special": true
1124
+ },
1125
+ "157031": {
1126
+ "content": "<|reserved_token_136|>",
1127
+ "lstrip": false,
1128
+ "normalized": false,
1129
+ "rstrip": false,
1130
+ "single_word": false,
1131
+ "special": true
1132
+ },
1133
+ "157032": {
1134
+ "content": "<|reserved_token_137|>",
1135
+ "lstrip": false,
1136
+ "normalized": false,
1137
+ "rstrip": false,
1138
+ "single_word": false,
1139
+ "special": true
1140
+ },
1141
+ "157033": {
1142
+ "content": "<|reserved_token_138|>",
1143
+ "lstrip": false,
1144
+ "normalized": false,
1145
+ "rstrip": false,
1146
+ "single_word": false,
1147
+ "special": true
1148
+ },
1149
+ "157034": {
1150
+ "content": "<|reserved_token_139|>",
1151
+ "lstrip": false,
1152
+ "normalized": false,
1153
+ "rstrip": false,
1154
+ "single_word": false,
1155
+ "special": true
1156
+ },
1157
+ "157035": {
1158
+ "content": "<|reserved_token_140|>",
1159
+ "lstrip": false,
1160
+ "normalized": false,
1161
+ "rstrip": false,
1162
+ "single_word": false,
1163
+ "special": true
1164
+ },
1165
+ "157036": {
1166
+ "content": "<|reserved_token_141|>",
1167
+ "lstrip": false,
1168
+ "normalized": false,
1169
+ "rstrip": false,
1170
+ "single_word": false,
1171
+ "special": true
1172
+ },
1173
+ "157037": {
1174
+ "content": "<|reserved_token_142|>",
1175
+ "lstrip": false,
1176
+ "normalized": false,
1177
+ "rstrip": false,
1178
+ "single_word": false,
1179
+ "special": true
1180
+ },
1181
+ "157038": {
1182
+ "content": "<|reserved_token_143|>",
1183
+ "lstrip": false,
1184
+ "normalized": false,
1185
+ "rstrip": false,
1186
+ "single_word": false,
1187
+ "special": true
1188
+ },
1189
+ "157039": {
1190
+ "content": "<|reserved_token_144|>",
1191
+ "lstrip": false,
1192
+ "normalized": false,
1193
+ "rstrip": false,
1194
+ "single_word": false,
1195
+ "special": true
1196
+ },
1197
+ "157040": {
1198
+ "content": "<|reserved_token_145|>",
1199
+ "lstrip": false,
1200
+ "normalized": false,
1201
+ "rstrip": false,
1202
+ "single_word": false,
1203
+ "special": true
1204
+ },
1205
+ "157041": {
1206
+ "content": "<|reserved_token_146|>",
1207
+ "lstrip": false,
1208
+ "normalized": false,
1209
+ "rstrip": false,
1210
+ "single_word": false,
1211
+ "special": true
1212
+ },
1213
+ "157042": {
1214
+ "content": "<|reserved_token_147|>",
1215
+ "lstrip": false,
1216
+ "normalized": false,
1217
+ "rstrip": false,
1218
+ "single_word": false,
1219
+ "special": true
1220
+ },
1221
+ "157043": {
1222
+ "content": "<|reserved_token_148|>",
1223
+ "lstrip": false,
1224
+ "normalized": false,
1225
+ "rstrip": false,
1226
+ "single_word": false,
1227
+ "special": true
1228
+ },
1229
+ "157044": {
1230
+ "content": "<|reserved_token_149|>",
1231
+ "lstrip": false,
1232
+ "normalized": false,
1233
+ "rstrip": false,
1234
+ "single_word": false,
1235
+ "special": true
1236
+ },
1237
+ "157045": {
1238
+ "content": "<|reserved_token_150|>",
1239
+ "lstrip": false,
1240
+ "normalized": false,
1241
+ "rstrip": false,
1242
+ "single_word": false,
1243
+ "special": true
1244
+ },
1245
+ "157046": {
1246
+ "content": "<|reserved_token_151|>",
1247
+ "lstrip": false,
1248
+ "normalized": false,
1249
+ "rstrip": false,
1250
+ "single_word": false,
1251
+ "special": true
1252
+ },
1253
+ "157047": {
1254
+ "content": "<|reserved_token_152|>",
1255
+ "lstrip": false,
1256
+ "normalized": false,
1257
+ "rstrip": false,
1258
+ "single_word": false,
1259
+ "special": true
1260
+ },
1261
+ "157048": {
1262
+ "content": "<|reserved_token_153|>",
1263
+ "lstrip": false,
1264
+ "normalized": false,
1265
+ "rstrip": false,
1266
+ "single_word": false,
1267
+ "special": true
1268
+ },
1269
+ "157049": {
1270
+ "content": "<|reserved_token_154|>",
1271
+ "lstrip": false,
1272
+ "normalized": false,
1273
+ "rstrip": false,
1274
+ "single_word": false,
1275
+ "special": true
1276
+ },
1277
+ "157050": {
1278
+ "content": "<|reserved_token_155|>",
1279
+ "lstrip": false,
1280
+ "normalized": false,
1281
+ "rstrip": false,
1282
+ "single_word": false,
1283
+ "special": true
1284
+ },
1285
+ "157051": {
1286
+ "content": "<|reserved_token_156|>",
1287
+ "lstrip": false,
1288
+ "normalized": false,
1289
+ "rstrip": false,
1290
+ "single_word": false,
1291
+ "special": true
1292
+ },
1293
+ "157052": {
1294
+ "content": "<|reserved_token_157|>",
1295
+ "lstrip": false,
1296
+ "normalized": false,
1297
+ "rstrip": false,
1298
+ "single_word": false,
1299
+ "special": true
1300
+ },
1301
+ "157053": {
1302
+ "content": "<|reserved_token_158|>",
1303
+ "lstrip": false,
1304
+ "normalized": false,
1305
+ "rstrip": false,
1306
+ "single_word": false,
1307
+ "special": true
1308
+ },
1309
+ "157054": {
1310
+ "content": "<|reserved_token_159|>",
1311
+ "lstrip": false,
1312
+ "normalized": false,
1313
+ "rstrip": false,
1314
+ "single_word": false,
1315
+ "special": true
1316
+ },
1317
+ "157055": {
1318
+ "content": "<|reserved_token_160|>",
1319
+ "lstrip": false,
1320
+ "normalized": false,
1321
+ "rstrip": false,
1322
+ "single_word": false,
1323
+ "special": true
1324
+ },
1325
+ "157056": {
1326
+ "content": "<|reserved_token_161|>",
1327
+ "lstrip": false,
1328
+ "normalized": false,
1329
+ "rstrip": false,
1330
+ "single_word": false,
1331
+ "special": true
1332
+ },
1333
+ "157057": {
1334
+ "content": "<|reserved_token_162|>",
1335
+ "lstrip": false,
1336
+ "normalized": false,
1337
+ "rstrip": false,
1338
+ "single_word": false,
1339
+ "special": true
1340
+ },
1341
+ "157058": {
1342
+ "content": "<|reserved_token_163|>",
1343
+ "lstrip": false,
1344
+ "normalized": false,
1345
+ "rstrip": false,
1346
+ "single_word": false,
1347
+ "special": true
1348
+ },
1349
+ "157059": {
1350
+ "content": "<|reserved_token_164|>",
1351
+ "lstrip": false,
1352
+ "normalized": false,
1353
+ "rstrip": false,
1354
+ "single_word": false,
1355
+ "special": true
1356
+ },
1357
+ "157060": {
1358
+ "content": "<|reserved_token_165|>",
1359
+ "lstrip": false,
1360
+ "normalized": false,
1361
+ "rstrip": false,
1362
+ "single_word": false,
1363
+ "special": true
1364
+ },
1365
+ "157061": {
1366
+ "content": "<|reserved_token_166|>",
1367
+ "lstrip": false,
1368
+ "normalized": false,
1369
+ "rstrip": false,
1370
+ "single_word": false,
1371
+ "special": true
1372
+ },
1373
+ "157062": {
1374
+ "content": "<|reserved_token_167|>",
1375
+ "lstrip": false,
1376
+ "normalized": false,
1377
+ "rstrip": false,
1378
+ "single_word": false,
1379
+ "special": true
1380
+ },
1381
+ "157063": {
1382
+ "content": "<|reserved_token_168|>",
1383
+ "lstrip": false,
1384
+ "normalized": false,
1385
+ "rstrip": false,
1386
+ "single_word": false,
1387
+ "special": true
1388
+ },
1389
+ "157064": {
1390
+ "content": "<|reserved_token_169|>",
1391
+ "lstrip": false,
1392
+ "normalized": false,
1393
+ "rstrip": false,
1394
+ "single_word": false,
1395
+ "special": true
1396
+ },
1397
+ "157065": {
1398
+ "content": "<|reserved_token_170|>",
1399
+ "lstrip": false,
1400
+ "normalized": false,
1401
+ "rstrip": false,
1402
+ "single_word": false,
1403
+ "special": true
1404
+ },
1405
+ "157066": {
1406
+ "content": "<|reserved_token_171|>",
1407
+ "lstrip": false,
1408
+ "normalized": false,
1409
+ "rstrip": false,
1410
+ "single_word": false,
1411
+ "special": true
1412
+ },
1413
+ "157067": {
1414
+ "content": "<|reserved_token_172|>",
1415
+ "lstrip": false,
1416
+ "normalized": false,
1417
+ "rstrip": false,
1418
+ "single_word": false,
1419
+ "special": true
1420
+ },
1421
+ "157068": {
1422
+ "content": "<|reserved_token_173|>",
1423
+ "lstrip": false,
1424
+ "normalized": false,
1425
+ "rstrip": false,
1426
+ "single_word": false,
1427
+ "special": true
1428
+ },
1429
+ "157069": {
1430
+ "content": "<|reserved_token_174|>",
1431
+ "lstrip": false,
1432
+ "normalized": false,
1433
+ "rstrip": false,
1434
+ "single_word": false,
1435
+ "special": true
1436
+ },
1437
+ "157070": {
1438
+ "content": "<|reserved_token_175|>",
1439
+ "lstrip": false,
1440
+ "normalized": false,
1441
+ "rstrip": false,
1442
+ "single_word": false,
1443
+ "special": true
1444
+ },
1445
+ "157071": {
1446
+ "content": "<|reserved_token_176|>",
1447
+ "lstrip": false,
1448
+ "normalized": false,
1449
+ "rstrip": false,
1450
+ "single_word": false,
1451
+ "special": true
1452
+ },
1453
+ "157072": {
1454
+ "content": "<|reserved_token_177|>",
1455
+ "lstrip": false,
1456
+ "normalized": false,
1457
+ "rstrip": false,
1458
+ "single_word": false,
1459
+ "special": true
1460
+ },
1461
+ "157073": {
1462
+ "content": "<|reserved_token_178|>",
1463
+ "lstrip": false,
1464
+ "normalized": false,
1465
+ "rstrip": false,
1466
+ "single_word": false,
1467
+ "special": true
1468
+ },
1469
+ "157074": {
1470
+ "content": "<|reserved_token_179|>",
1471
+ "lstrip": false,
1472
+ "normalized": false,
1473
+ "rstrip": false,
1474
+ "single_word": false,
1475
+ "special": true
1476
+ },
1477
+ "157075": {
1478
+ "content": "<|reserved_token_180|>",
1479
+ "lstrip": false,
1480
+ "normalized": false,
1481
+ "rstrip": false,
1482
+ "single_word": false,
1483
+ "special": true
1484
+ },
1485
+ "157076": {
1486
+ "content": "<|reserved_token_181|>",
1487
+ "lstrip": false,
1488
+ "normalized": false,
1489
+ "rstrip": false,
1490
+ "single_word": false,
1491
+ "special": true
1492
+ },
1493
+ "157077": {
1494
+ "content": "<|reserved_token_182|>",
1495
+ "lstrip": false,
1496
+ "normalized": false,
1497
+ "rstrip": false,
1498
+ "single_word": false,
1499
+ "special": true
1500
+ },
1501
+ "157078": {
1502
+ "content": "<|reserved_token_183|>",
1503
+ "lstrip": false,
1504
+ "normalized": false,
1505
+ "rstrip": false,
1506
+ "single_word": false,
1507
+ "special": true
1508
+ },
1509
+ "157079": {
1510
+ "content": "<|reserved_token_184|>",
1511
+ "lstrip": false,
1512
+ "normalized": false,
1513
+ "rstrip": false,
1514
+ "single_word": false,
1515
+ "special": true
1516
+ },
1517
+ "157080": {
1518
+ "content": "<|reserved_token_185|>",
1519
+ "lstrip": false,
1520
+ "normalized": false,
1521
+ "rstrip": false,
1522
+ "single_word": false,
1523
+ "special": true
1524
+ },
1525
+ "157081": {
1526
+ "content": "<|reserved_token_186|>",
1527
+ "lstrip": false,
1528
+ "normalized": false,
1529
+ "rstrip": false,
1530
+ "single_word": false,
1531
+ "special": true
1532
+ },
1533
+ "157082": {
1534
+ "content": "<|reserved_token_187|>",
1535
+ "lstrip": false,
1536
+ "normalized": false,
1537
+ "rstrip": false,
1538
+ "single_word": false,
1539
+ "special": true
1540
+ },
1541
+ "157083": {
1542
+ "content": "<|reserved_token_188|>",
1543
+ "lstrip": false,
1544
+ "normalized": false,
1545
+ "rstrip": false,
1546
+ "single_word": false,
1547
+ "special": true
1548
+ },
1549
+ "157084": {
1550
+ "content": "<|reserved_token_189|>",
1551
+ "lstrip": false,
1552
+ "normalized": false,
1553
+ "rstrip": false,
1554
+ "single_word": false,
1555
+ "special": true
1556
+ },
1557
+ "157085": {
1558
+ "content": "<|reserved_token_190|>",
1559
+ "lstrip": false,
1560
+ "normalized": false,
1561
+ "rstrip": false,
1562
+ "single_word": false,
1563
+ "special": true
1564
+ },
1565
+ "157086": {
1566
+ "content": "<|reserved_token_191|>",
1567
+ "lstrip": false,
1568
+ "normalized": false,
1569
+ "rstrip": false,
1570
+ "single_word": false,
1571
+ "special": true
1572
+ },
1573
+ "157087": {
1574
+ "content": "<|reserved_token_192|>",
1575
+ "lstrip": false,
1576
+ "normalized": false,
1577
+ "rstrip": false,
1578
+ "single_word": false,
1579
+ "special": true
1580
+ },
1581
+ "157088": {
1582
+ "content": "<|reserved_token_193|>",
1583
+ "lstrip": false,
1584
+ "normalized": false,
1585
+ "rstrip": false,
1586
+ "single_word": false,
1587
+ "special": true
1588
+ },
1589
+ "157089": {
1590
+ "content": "<|reserved_token_194|>",
1591
+ "lstrip": false,
1592
+ "normalized": false,
1593
+ "rstrip": false,
1594
+ "single_word": false,
1595
+ "special": true
1596
+ },
1597
+ "157090": {
1598
+ "content": "<|reserved_token_195|>",
1599
+ "lstrip": false,
1600
+ "normalized": false,
1601
+ "rstrip": false,
1602
+ "single_word": false,
1603
+ "special": true
1604
+ },
1605
+ "157091": {
1606
+ "content": "<|reserved_token_196|>",
1607
+ "lstrip": false,
1608
+ "normalized": false,
1609
+ "rstrip": false,
1610
+ "single_word": false,
1611
+ "special": true
1612
+ },
1613
+ "157092": {
1614
+ "content": "<|reserved_token_197|>",
1615
+ "lstrip": false,
1616
+ "normalized": false,
1617
+ "rstrip": false,
1618
+ "single_word": false,
1619
+ "special": true
1620
+ },
1621
+ "157093": {
1622
+ "content": "<|reserved_token_198|>",
1623
+ "lstrip": false,
1624
+ "normalized": false,
1625
+ "rstrip": false,
1626
+ "single_word": false,
1627
+ "special": true
1628
+ },
1629
+ "157094": {
1630
+ "content": "<|reserved_token_199|>",
1631
+ "lstrip": false,
1632
+ "normalized": false,
1633
+ "rstrip": false,
1634
+ "single_word": false,
1635
+ "special": true
1636
+ },
1637
+ "157095": {
1638
+ "content": "<|reserved_token_200|>",
1639
+ "lstrip": false,
1640
+ "normalized": false,
1641
+ "rstrip": false,
1642
+ "single_word": false,
1643
+ "special": true
1644
+ },
1645
+ "157096": {
1646
+ "content": "<|reserved_token_201|>",
1647
+ "lstrip": false,
1648
+ "normalized": false,
1649
+ "rstrip": false,
1650
+ "single_word": false,
1651
+ "special": true
1652
+ },
1653
+ "157097": {
1654
+ "content": "<|reserved_token_202|>",
1655
+ "lstrip": false,
1656
+ "normalized": false,
1657
+ "rstrip": false,
1658
+ "single_word": false,
1659
+ "special": true
1660
+ },
1661
+ "157098": {
1662
+ "content": "<|reserved_token_203|>",
1663
+ "lstrip": false,
1664
+ "normalized": false,
1665
+ "rstrip": false,
1666
+ "single_word": false,
1667
+ "special": true
1668
+ },
1669
+ "157099": {
1670
+ "content": "<|reserved_token_204|>",
1671
+ "lstrip": false,
1672
+ "normalized": false,
1673
+ "rstrip": false,
1674
+ "single_word": false,
1675
+ "special": true
1676
+ },
1677
+ "157100": {
1678
+ "content": "<|reserved_token_205|>",
1679
+ "lstrip": false,
1680
+ "normalized": false,
1681
+ "rstrip": false,
1682
+ "single_word": false,
1683
+ "special": true
1684
+ },
1685
+ "157101": {
1686
+ "content": "<|reserved_token_206|>",
1687
+ "lstrip": false,
1688
+ "normalized": false,
1689
+ "rstrip": false,
1690
+ "single_word": false,
1691
+ "special": true
1692
+ },
1693
+ "157102": {
1694
+ "content": "<|reserved_token_207|>",
1695
+ "lstrip": false,
1696
+ "normalized": false,
1697
+ "rstrip": false,
1698
+ "single_word": false,
1699
+ "special": true
1700
+ },
1701
+ "157103": {
1702
+ "content": "<|reserved_token_208|>",
1703
+ "lstrip": false,
1704
+ "normalized": false,
1705
+ "rstrip": false,
1706
+ "single_word": false,
1707
+ "special": true
1708
+ },
1709
+ "157104": {
1710
+ "content": "<|reserved_token_209|>",
1711
+ "lstrip": false,
1712
+ "normalized": false,
1713
+ "rstrip": false,
1714
+ "single_word": false,
1715
+ "special": true
1716
+ },
1717
+ "157105": {
1718
+ "content": "<|reserved_token_210|>",
1719
+ "lstrip": false,
1720
+ "normalized": false,
1721
+ "rstrip": false,
1722
+ "single_word": false,
1723
+ "special": true
1724
+ },
1725
+ "157106": {
1726
+ "content": "<|reserved_token_211|>",
1727
+ "lstrip": false,
1728
+ "normalized": false,
1729
+ "rstrip": false,
1730
+ "single_word": false,
1731
+ "special": true
1732
+ },
1733
+ "157107": {
1734
+ "content": "<|reserved_token_212|>",
1735
+ "lstrip": false,
1736
+ "normalized": false,
1737
+ "rstrip": false,
1738
+ "single_word": false,
1739
+ "special": true
1740
+ },
1741
+ "157108": {
1742
+ "content": "<|reserved_token_213|>",
1743
+ "lstrip": false,
1744
+ "normalized": false,
1745
+ "rstrip": false,
1746
+ "single_word": false,
1747
+ "special": true
1748
+ },
1749
+ "157109": {
1750
+ "content": "<|reserved_token_214|>",
1751
+ "lstrip": false,
1752
+ "normalized": false,
1753
+ "rstrip": false,
1754
+ "single_word": false,
1755
+ "special": true
1756
+ },
1757
+ "157110": {
1758
+ "content": "<|reserved_token_215|>",
1759
+ "lstrip": false,
1760
+ "normalized": false,
1761
+ "rstrip": false,
1762
+ "single_word": false,
1763
+ "special": true
1764
+ },
1765
+ "157111": {
1766
+ "content": "<|reserved_token_216|>",
1767
+ "lstrip": false,
1768
+ "normalized": false,
1769
+ "rstrip": false,
1770
+ "single_word": false,
1771
+ "special": true
1772
+ },
1773
+ "157112": {
1774
+ "content": "<|reserved_token_217|>",
1775
+ "lstrip": false,
1776
+ "normalized": false,
1777
+ "rstrip": false,
1778
+ "single_word": false,
1779
+ "special": true
1780
+ },
1781
+ "157113": {
1782
+ "content": "<|reserved_token_218|>",
1783
+ "lstrip": false,
1784
+ "normalized": false,
1785
+ "rstrip": false,
1786
+ "single_word": false,
1787
+ "special": true
1788
+ },
1789
+ "157114": {
1790
+ "content": "<|reserved_token_219|>",
1791
+ "lstrip": false,
1792
+ "normalized": false,
1793
+ "rstrip": false,
1794
+ "single_word": false,
1795
+ "special": true
1796
+ },
1797
+ "157115": {
1798
+ "content": "<|reserved_token_220|>",
1799
+ "lstrip": false,
1800
+ "normalized": false,
1801
+ "rstrip": false,
1802
+ "single_word": false,
1803
+ "special": true
1804
+ },
1805
+ "157116": {
1806
+ "content": "<|reserved_token_221|>",
1807
+ "lstrip": false,
1808
+ "normalized": false,
1809
+ "rstrip": false,
1810
+ "single_word": false,
1811
+ "special": true
1812
+ },
1813
+ "157117": {
1814
+ "content": "<|reserved_token_222|>",
1815
+ "lstrip": false,
1816
+ "normalized": false,
1817
+ "rstrip": false,
1818
+ "single_word": false,
1819
+ "special": true
1820
+ },
1821
+ "157118": {
1822
+ "content": "<|reserved_token_223|>",
1823
+ "lstrip": false,
1824
+ "normalized": false,
1825
+ "rstrip": false,
1826
+ "single_word": false,
1827
+ "special": true
1828
+ },
1829
+ "157119": {
1830
+ "content": "<|reserved_token_224|>",
1831
+ "lstrip": false,
1832
+ "normalized": false,
1833
+ "rstrip": false,
1834
+ "single_word": false,
1835
+ "special": true
1836
+ },
1837
+ "157120": {
1838
+ "content": "<|reserved_token_225|>",
1839
+ "lstrip": false,
1840
+ "normalized": false,
1841
+ "rstrip": false,
1842
+ "single_word": false,
1843
+ "special": true
1844
+ },
1845
+ "157121": {
1846
+ "content": "<|reserved_token_226|>",
1847
+ "lstrip": false,
1848
+ "normalized": false,
1849
+ "rstrip": false,
1850
+ "single_word": false,
1851
+ "special": true
1852
+ },
1853
+ "157122": {
1854
+ "content": "<|reserved_token_227|>",
1855
+ "lstrip": false,
1856
+ "normalized": false,
1857
+ "rstrip": false,
1858
+ "single_word": false,
1859
+ "special": true
1860
+ },
1861
+ "157123": {
1862
+ "content": "<|reserved_token_228|>",
1863
+ "lstrip": false,
1864
+ "normalized": false,
1865
+ "rstrip": false,
1866
+ "single_word": false,
1867
+ "special": true
1868
+ },
1869
+ "157124": {
1870
+ "content": "<|reserved_token_229|>",
1871
+ "lstrip": false,
1872
+ "normalized": false,
1873
+ "rstrip": false,
1874
+ "single_word": false,
1875
+ "special": true
1876
+ },
1877
+ "157125": {
1878
+ "content": "<|reserved_token_230|>",
1879
+ "lstrip": false,
1880
+ "normalized": false,
1881
+ "rstrip": false,
1882
+ "single_word": false,
1883
+ "special": true
1884
+ },
1885
+ "157126": {
1886
+ "content": "<|reserved_token_231|>",
1887
+ "lstrip": false,
1888
+ "normalized": false,
1889
+ "rstrip": false,
1890
+ "single_word": false,
1891
+ "special": true
1892
+ },
1893
+ "157127": {
1894
+ "content": "<|reserved_token_232|>",
1895
+ "lstrip": false,
1896
+ "normalized": false,
1897
+ "rstrip": false,
1898
+ "single_word": false,
1899
+ "special": true
1900
+ },
1901
+ "157128": {
1902
+ "content": "<|reserved_token_233|>",
1903
+ "lstrip": false,
1904
+ "normalized": false,
1905
+ "rstrip": false,
1906
+ "single_word": false,
1907
+ "special": true
1908
+ },
1909
+ "157129": {
1910
+ "content": "<|reserved_token_234|>",
1911
+ "lstrip": false,
1912
+ "normalized": false,
1913
+ "rstrip": false,
1914
+ "single_word": false,
1915
+ "special": true
1916
+ },
1917
+ "157130": {
1918
+ "content": "<|reserved_token_235|>",
1919
+ "lstrip": false,
1920
+ "normalized": false,
1921
+ "rstrip": false,
1922
+ "single_word": false,
1923
+ "special": true
1924
+ },
1925
+ "157131": {
1926
+ "content": "<|reserved_token_236|>",
1927
+ "lstrip": false,
1928
+ "normalized": false,
1929
+ "rstrip": false,
1930
+ "single_word": false,
1931
+ "special": true
1932
+ },
1933
+ "157132": {
1934
+ "content": "<|reserved_token_237|>",
1935
+ "lstrip": false,
1936
+ "normalized": false,
1937
+ "rstrip": false,
1938
+ "single_word": false,
1939
+ "special": true
1940
+ },
1941
+ "157133": {
1942
+ "content": "<|reserved_token_238|>",
1943
+ "lstrip": false,
1944
+ "normalized": false,
1945
+ "rstrip": false,
1946
+ "single_word": false,
1947
+ "special": true
1948
+ },
1949
+ "157134": {
1950
+ "content": "<|reserved_token_239|>",
1951
+ "lstrip": false,
1952
+ "normalized": false,
1953
+ "rstrip": false,
1954
+ "single_word": false,
1955
+ "special": true
1956
+ },
1957
+ "157135": {
1958
+ "content": "<|reserved_token_240|>",
1959
+ "lstrip": false,
1960
+ "normalized": false,
1961
+ "rstrip": false,
1962
+ "single_word": false,
1963
+ "special": true
1964
+ },
1965
+ "157136": {
1966
+ "content": "<|reserved_token_241|>",
1967
+ "lstrip": false,
1968
+ "normalized": false,
1969
+ "rstrip": false,
1970
+ "single_word": false,
1971
+ "special": true
1972
+ },
1973
+ "157137": {
1974
+ "content": "<|reserved_token_242|>",
1975
+ "lstrip": false,
1976
+ "normalized": false,
1977
+ "rstrip": false,
1978
+ "single_word": false,
1979
+ "special": true
1980
+ },
1981
+ "157138": {
1982
+ "content": "<|reserved_token_243|>",
1983
+ "lstrip": false,
1984
+ "normalized": false,
1985
+ "rstrip": false,
1986
+ "single_word": false,
1987
+ "special": true
1988
+ },
1989
+ "157139": {
1990
+ "content": "<|reserved_token_244|>",
1991
+ "lstrip": false,
1992
+ "normalized": false,
1993
+ "rstrip": false,
1994
+ "single_word": false,
1995
+ "special": true
1996
+ },
1997
+ "157140": {
1998
+ "content": "<|reserved_token_245|>",
1999
+ "lstrip": false,
2000
+ "normalized": false,
2001
+ "rstrip": false,
2002
+ "single_word": false,
2003
+ "special": true
2004
+ },
2005
+ "157141": {
2006
+ "content": "<|reserved_token_246|>",
2007
+ "lstrip": false,
2008
+ "normalized": false,
2009
+ "rstrip": false,
2010
+ "single_word": false,
2011
+ "special": true
2012
+ },
2013
+ "157142": {
2014
+ "content": "<|reserved_token_247|>",
2015
+ "lstrip": false,
2016
+ "normalized": false,
2017
+ "rstrip": false,
2018
+ "single_word": false,
2019
+ "special": true
2020
+ },
2021
+ "157143": {
2022
+ "content": "<|reserved_token_248|>",
2023
+ "lstrip": false,
2024
+ "normalized": false,
2025
+ "rstrip": false,
2026
+ "single_word": false,
2027
+ "special": true
2028
+ },
2029
+ "157144": {
2030
+ "content": "<|reserved_token_249|>",
2031
+ "lstrip": false,
2032
+ "normalized": false,
2033
+ "rstrip": false,
2034
+ "single_word": false,
2035
+ "special": true
2036
+ },
2037
+ "157145": {
2038
+ "content": "<|reserved_token_250|>",
2039
+ "lstrip": false,
2040
+ "normalized": false,
2041
+ "rstrip": false,
2042
+ "single_word": false,
2043
+ "special": true
2044
+ },
2045
+ "157146": {
2046
+ "content": "<|reserved_token_251|>",
2047
+ "lstrip": false,
2048
+ "normalized": false,
2049
+ "rstrip": false,
2050
+ "single_word": false,
2051
+ "special": true
2052
+ },
2053
+ "157147": {
2054
+ "content": "<|reserved_token_252|>",
2055
+ "lstrip": false,
2056
+ "normalized": false,
2057
+ "rstrip": false,
2058
+ "single_word": false,
2059
+ "special": true
2060
+ },
2061
+ "157148": {
2062
+ "content": "<|reserved_token_253|>",
2063
+ "lstrip": false,
2064
+ "normalized": false,
2065
+ "rstrip": false,
2066
+ "single_word": false,
2067
+ "special": true
2068
+ },
2069
+ "157149": {
2070
+ "content": "<|reserved_token_254|>",
2071
+ "lstrip": false,
2072
+ "normalized": false,
2073
+ "rstrip": false,
2074
+ "single_word": false,
2075
+ "special": true
2076
+ },
2077
+ "157150": {
2078
+ "content": "<|reserved_token_255|>",
2079
+ "lstrip": false,
2080
+ "normalized": false,
2081
+ "rstrip": false,
2082
+ "single_word": false,
2083
+ "special": true
2084
+ },
2085
+ "157151": {
2086
+ "content": "<role>",
2087
+ "lstrip": false,
2088
+ "normalized": false,
2089
+ "rstrip": false,
2090
+ "single_word": false,
2091
+ "special": true
2092
+ },
2093
+ "157152": {
2094
+ "content": "</role>",
2095
+ "lstrip": false,
2096
+ "normalized": false,
2097
+ "rstrip": false,
2098
+ "single_word": false,
2099
+ "special": true
2100
+ }
2101
+ },
2102
  "bos_token": "<|startoftext|>",
 
2103
  "clean_up_tokenization_spaces": false,
2104
  "cls_token": "[CLS]",
2105
  "eos_token": "<|endoftext|>",
2106
+ "extra_special_tokens": {},
2107
  "fast_tokenizer": true,
2108
  "gmask_token": "[gMASK]",
2109
  "merges_file": null,
2110
  "model_max_length": 1000000000000000019884624838656,
2111
  "pad_token": "<|endoftext|>",
2112
  "tokenizer_class": "PreTrainedTokenizerFast",
2113
+ "trust_remote_code": true
 
2114
  }