init
Browse files- config.json +58 -0
- configuration_hf_openmoe.py +53 -0
- generation_config.json +7 -0
- model-00001-of-00010.safetensors +3 -0
- model-00002-of-00010.safetensors +3 -0
- model-00003-of-00010.safetensors +3 -0
- model-00004-of-00010.safetensors +3 -0
- model-00005-of-00010.safetensors +3 -0
- model-00006-of-00010.safetensors +3 -0
- model-00007-of-00010.safetensors +3 -0
- model-00008-of-00010.safetensors +3 -0
- model-00009-of-00010.safetensors +3 -0
- model-00010-of-00010.safetensors +3 -0
- model.safetensors.index.json +618 -0
- modeling_hf_openmoe.py +1121 -0
- tokenization_hf_openmoe.py +24 -0
config.json
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"HFOpenMoeForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoModel": "modeling_hf_openmoe.HFOpenMoeModel",
|
9 |
+
"AutoConfig": "configuration_hf_openmoe.HFOpenMoeConfig",
|
10 |
+
"AutoModelForCausalLM": "modeling_hf_openmoe.HFOpenMoeForCausalLM"
|
11 |
+
},
|
12 |
+
"bos_token_id": 0,
|
13 |
+
"dropout_rate": 0.0,
|
14 |
+
"enable_comm_overlap": false,
|
15 |
+
"enable_hierarchical_alltoall": false,
|
16 |
+
"enable_kernel": false,
|
17 |
+
"enable_load_balance": false,
|
18 |
+
"eos_token_id": 1,
|
19 |
+
"expert_parallel": null,
|
20 |
+
"head_dim": 128,
|
21 |
+
"hidden_act": "swiglu",
|
22 |
+
"hidden_size": 2048,
|
23 |
+
"initializer_range": 0.02,
|
24 |
+
"intermediate_size": 8192,
|
25 |
+
"label_smoothing": 0.001,
|
26 |
+
"layer_norm_epsilon": 1e-06,
|
27 |
+
"load_balance_beam_width": 8,
|
28 |
+
"load_balance_group_swap_factor": 0.4,
|
29 |
+
"load_balance_tolerance": 0.1,
|
30 |
+
"max_position_embeddings": 2048,
|
31 |
+
"mlp_bias": false,
|
32 |
+
"mlp_gated": true,
|
33 |
+
"model_type": "openmoe",
|
34 |
+
"moe_layer_interval": 6,
|
35 |
+
"num_attention_heads": 24,
|
36 |
+
"num_experts": 32,
|
37 |
+
"num_hidden_layers": 24,
|
38 |
+
"num_key_value_heads": 24,
|
39 |
+
"pad_token_id": 0,
|
40 |
+
"pretraining_tp": 1,
|
41 |
+
"rms_norm_eps": 1e-06,
|
42 |
+
"rope_scaling": null,
|
43 |
+
"rope_theta": 10000.0,
|
44 |
+
"router_aux_loss_factor": 0.01,
|
45 |
+
"router_capacity_factor_eval": 2.0,
|
46 |
+
"router_capacity_factor_train": 1.25,
|
47 |
+
"router_drop_tks": true,
|
48 |
+
"router_min_capacity": 4,
|
49 |
+
"router_noisy_policy": null,
|
50 |
+
"router_topk": 2,
|
51 |
+
"router_z_loss_factor": 0.0001,
|
52 |
+
"tie_word_embeddings": false,
|
53 |
+
"torch_dtype": "float32",
|
54 |
+
"transformers_version": "4.43.3",
|
55 |
+
"use_cache": true,
|
56 |
+
"vocab_size": 256384,
|
57 |
+
"z_loss_factor": 0.01
|
58 |
+
}
|
configuration_hf_openmoe.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import LlamaConfig
|
2 |
+
|
3 |
+
__all__ = ["HFOpenMoeConfig"]
|
4 |
+
|
5 |
+
|
6 |
+
class HFOpenMoeConfig(LlamaConfig):
|
7 |
+
model_type = "openmoe"
|
8 |
+
def __init__(
|
9 |
+
self,
|
10 |
+
num_experts: int = 32,
|
11 |
+
moe_layer_interval: int = 6,
|
12 |
+
router_topk: int = 2,
|
13 |
+
router_capacity_factor_train: float = 1.25,
|
14 |
+
router_capacity_factor_eval: float = 2.0,
|
15 |
+
router_min_capacity: int = 4,
|
16 |
+
router_noisy_policy: str = None,
|
17 |
+
router_drop_tks: bool = True,
|
18 |
+
router_aux_loss_factor: float = 0.01,
|
19 |
+
router_z_loss_factor: float = 0.0001,
|
20 |
+
mlp_gated: bool = True,
|
21 |
+
label_smoothing: float = 0.001,
|
22 |
+
z_loss_factor: float = 0.01,
|
23 |
+
enable_load_balance: bool = False,
|
24 |
+
load_balance_tolerance: float = 0.1,
|
25 |
+
load_balance_beam_width: int = 8,
|
26 |
+
load_balance_group_swap_factor: float = 0.4,
|
27 |
+
enable_kernel: bool = False,
|
28 |
+
enable_comm_overlap: bool = False,
|
29 |
+
enable_hierarchical_alltoall: bool = False,
|
30 |
+
**kwargs
|
31 |
+
):
|
32 |
+
self.num_experts = num_experts
|
33 |
+
self.moe_layer_interval = moe_layer_interval
|
34 |
+
self.router_topk = router_topk
|
35 |
+
self.router_capacity_factor_train = router_capacity_factor_train
|
36 |
+
self.router_capacity_factor_eval = router_capacity_factor_eval
|
37 |
+
self.router_min_capacity = router_min_capacity
|
38 |
+
self.router_noisy_policy = router_noisy_policy
|
39 |
+
self.router_drop_tks = router_drop_tks
|
40 |
+
self.router_aux_loss_factor = router_aux_loss_factor
|
41 |
+
self.router_z_loss_factor = router_z_loss_factor
|
42 |
+
self.mlp_gated = mlp_gated
|
43 |
+
self.label_smoothing = label_smoothing
|
44 |
+
self.z_loss_factor = z_loss_factor
|
45 |
+
self.enable_load_balance = enable_load_balance
|
46 |
+
self.load_balance_tolerance = load_balance_tolerance
|
47 |
+
self.load_balance_beam_width = load_balance_beam_width
|
48 |
+
self.load_balance_group_swap_factor = load_balance_group_swap_factor
|
49 |
+
self.enable_kernel = enable_kernel
|
50 |
+
self.enable_comm_overlap = enable_comm_overlap
|
51 |
+
self.enable_hierarchical_alltoall = enable_hierarchical_alltoall
|
52 |
+
|
53 |
+
super().__init__(**kwargs)
|
generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 0,
|
4 |
+
"eos_token_id": 1,
|
5 |
+
"pad_token_id": 0,
|
6 |
+
"transformers_version": "4.43.3"
|
7 |
+
}
|
model-00001-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ec229bf56b0726cbaba3e67994d6c96629d5d7f79bf4ba94bab28e87b41ac3dc
|
3 |
+
size 4986346648
|
model-00002-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eb5f12a244b2e8c751852f7a844cd980f7733dca6d0de96c35b115a6d1bc07c9
|
3 |
+
size 4966062856
|
model-00003-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:67cddbb2160baa44e38bbfae81eecc27c080a424fcffa0e4f06bcd26dc2c2ac4
|
3 |
+
size 4899325848
|
model-00004-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf85eb0992701ecdb8feb5fffea136955ba2c896bfd07241995bb2fb2977bd7a
|
3 |
+
size 4966062776
|
model-00005-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9c58b7a5cb906ad76623f2b5eff4ef912d928a69109954bf5d836c7632247279
|
3 |
+
size 4999676432
|
model-00006-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:106916f17274c0b557de3f4e3976af5085fb21c9e5d2413ecc3d281d0b06f40f
|
3 |
+
size 4999930240
|
model-00007-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:76a36e031c80311276ad0c4135be8f49a8603790e5b9ac64f8ffb944051335d8
|
3 |
+
size 4999642592
|
model-00008-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:156af9a8472948caa702719c7454f61eeea897ead29c1a6a74540749bc2afb56
|
3 |
+
size 4999964088
|
model-00009-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:da28ce83a95c60d0cfd4da82921f2b3249e49c02af147aad8874e9365a0d0ad9
|
3 |
+
size 4966062928
|
model-00010-of-00010.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ab30a6648ad25187f2a104526c316f0e49d010b5647812eb9c929c357cb73b01
|
3 |
+
size 2637186096
|
model.safetensors.index.json
ADDED
@@ -0,0 +1,618 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 47420186624
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"lm_head.weight": "model-00010-of-00010.safetensors",
|
7 |
+
"model.embed_tokens.weight": "model-00001-of-00010.safetensors",
|
8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00010.safetensors",
|
9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00010.safetensors",
|
10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00010.safetensors",
|
11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00010.safetensors",
|
12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00010.safetensors",
|
13 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00010.safetensors",
|
14 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00010.safetensors",
|
15 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00010.safetensors",
|
16 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00010.safetensors",
|
17 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00010.safetensors",
|
18 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00010.safetensors",
|
19 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00010.safetensors",
|
20 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00010.safetensors",
|
21 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00010.safetensors",
|
22 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00010.safetensors",
|
23 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00010.safetensors",
|
24 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00010.safetensors",
|
25 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00010.safetensors",
|
26 |
+
"model.layers.10.input_layernorm.weight": "model-00003-of-00010.safetensors",
|
27 |
+
"model.layers.10.mlp.down_proj.weight": "model-00003-of-00010.safetensors",
|
28 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00003-of-00010.safetensors",
|
29 |
+
"model.layers.10.mlp.up_proj.weight": "model-00003-of-00010.safetensors",
|
30 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00003-of-00010.safetensors",
|
31 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00003-of-00010.safetensors",
|
32 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00003-of-00010.safetensors",
|
33 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00003-of-00010.safetensors",
|
34 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00003-of-00010.safetensors",
|
35 |
+
"model.layers.11.extra_mlp.down_proj.weight": "model-00005-of-00010.safetensors",
|
36 |
+
"model.layers.11.extra_mlp.gate_proj.weight": "model-00005-of-00010.safetensors",
|
37 |
+
"model.layers.11.extra_mlp.up_proj.weight": "model-00005-of-00010.safetensors",
|
38 |
+
"model.layers.11.input_layernorm.weight": "model-00003-of-00010.safetensors",
|
39 |
+
"model.layers.11.mlp.experts.0.down_proj.weight": "model-00004-of-00010.safetensors",
|
40 |
+
"model.layers.11.mlp.experts.0.gate_proj.weight": "model-00004-of-00010.safetensors",
|
41 |
+
"model.layers.11.mlp.experts.0.up_proj.weight": "model-00004-of-00010.safetensors",
|
42 |
+
"model.layers.11.mlp.experts.1.down_proj.weight": "model-00004-of-00010.safetensors",
|
43 |
+
"model.layers.11.mlp.experts.1.gate_proj.weight": "model-00004-of-00010.safetensors",
|
44 |
+
"model.layers.11.mlp.experts.1.up_proj.weight": "model-00004-of-00010.safetensors",
|
45 |
+
"model.layers.11.mlp.experts.10.down_proj.weight": "model-00004-of-00010.safetensors",
|
46 |
+
"model.layers.11.mlp.experts.10.gate_proj.weight": "model-00004-of-00010.safetensors",
|
47 |
+
"model.layers.11.mlp.experts.10.up_proj.weight": "model-00004-of-00010.safetensors",
|
48 |
+
"model.layers.11.mlp.experts.11.down_proj.weight": "model-00004-of-00010.safetensors",
|
49 |
+
"model.layers.11.mlp.experts.11.gate_proj.weight": "model-00004-of-00010.safetensors",
|
50 |
+
"model.layers.11.mlp.experts.11.up_proj.weight": "model-00004-of-00010.safetensors",
|
51 |
+
"model.layers.11.mlp.experts.12.down_proj.weight": "model-00004-of-00010.safetensors",
|
52 |
+
"model.layers.11.mlp.experts.12.gate_proj.weight": "model-00004-of-00010.safetensors",
|
53 |
+
"model.layers.11.mlp.experts.12.up_proj.weight": "model-00004-of-00010.safetensors",
|
54 |
+
"model.layers.11.mlp.experts.13.down_proj.weight": "model-00004-of-00010.safetensors",
|
55 |
+
"model.layers.11.mlp.experts.13.gate_proj.weight": "model-00004-of-00010.safetensors",
|
56 |
+
"model.layers.11.mlp.experts.13.up_proj.weight": "model-00004-of-00010.safetensors",
|
57 |
+
"model.layers.11.mlp.experts.14.down_proj.weight": "model-00004-of-00010.safetensors",
|
58 |
+
"model.layers.11.mlp.experts.14.gate_proj.weight": "model-00004-of-00010.safetensors",
|
59 |
+
"model.layers.11.mlp.experts.14.up_proj.weight": "model-00004-of-00010.safetensors",
|
60 |
+
"model.layers.11.mlp.experts.15.down_proj.weight": "model-00004-of-00010.safetensors",
|
61 |
+
"model.layers.11.mlp.experts.15.gate_proj.weight": "model-00004-of-00010.safetensors",
|
62 |
+
"model.layers.11.mlp.experts.15.up_proj.weight": "model-00004-of-00010.safetensors",
|
63 |
+
"model.layers.11.mlp.experts.16.down_proj.weight": "model-00004-of-00010.safetensors",
|
64 |
+
"model.layers.11.mlp.experts.16.gate_proj.weight": "model-00004-of-00010.safetensors",
|
65 |
+
"model.layers.11.mlp.experts.16.up_proj.weight": "model-00004-of-00010.safetensors",
|
66 |
+
"model.layers.11.mlp.experts.17.down_proj.weight": "model-00004-of-00010.safetensors",
|
67 |
+
"model.layers.11.mlp.experts.17.gate_proj.weight": "model-00004-of-00010.safetensors",
|
68 |
+
"model.layers.11.mlp.experts.17.up_proj.weight": "model-00004-of-00010.safetensors",
|
69 |
+
"model.layers.11.mlp.experts.18.down_proj.weight": "model-00005-of-00010.safetensors",
|
70 |
+
"model.layers.11.mlp.experts.18.gate_proj.weight": "model-00004-of-00010.safetensors",
|
71 |
+
"model.layers.11.mlp.experts.18.up_proj.weight": "model-00005-of-00010.safetensors",
|
72 |
+
"model.layers.11.mlp.experts.19.down_proj.weight": "model-00005-of-00010.safetensors",
|
73 |
+
"model.layers.11.mlp.experts.19.gate_proj.weight": "model-00005-of-00010.safetensors",
|
74 |
+
"model.layers.11.mlp.experts.19.up_proj.weight": "model-00005-of-00010.safetensors",
|
75 |
+
"model.layers.11.mlp.experts.2.down_proj.weight": "model-00004-of-00010.safetensors",
|
76 |
+
"model.layers.11.mlp.experts.2.gate_proj.weight": "model-00004-of-00010.safetensors",
|
77 |
+
"model.layers.11.mlp.experts.2.up_proj.weight": "model-00004-of-00010.safetensors",
|
78 |
+
"model.layers.11.mlp.experts.20.down_proj.weight": "model-00005-of-00010.safetensors",
|
79 |
+
"model.layers.11.mlp.experts.20.gate_proj.weight": "model-00005-of-00010.safetensors",
|
80 |
+
"model.layers.11.mlp.experts.20.up_proj.weight": "model-00005-of-00010.safetensors",
|
81 |
+
"model.layers.11.mlp.experts.21.down_proj.weight": "model-00005-of-00010.safetensors",
|
82 |
+
"model.layers.11.mlp.experts.21.gate_proj.weight": "model-00005-of-00010.safetensors",
|
83 |
+
"model.layers.11.mlp.experts.21.up_proj.weight": "model-00005-of-00010.safetensors",
|
84 |
+
"model.layers.11.mlp.experts.22.down_proj.weight": "model-00005-of-00010.safetensors",
|
85 |
+
"model.layers.11.mlp.experts.22.gate_proj.weight": "model-00005-of-00010.safetensors",
|
86 |
+
"model.layers.11.mlp.experts.22.up_proj.weight": "model-00005-of-00010.safetensors",
|
87 |
+
"model.layers.11.mlp.experts.23.down_proj.weight": "model-00005-of-00010.safetensors",
|
88 |
+
"model.layers.11.mlp.experts.23.gate_proj.weight": "model-00005-of-00010.safetensors",
|
89 |
+
"model.layers.11.mlp.experts.23.up_proj.weight": "model-00005-of-00010.safetensors",
|
90 |
+
"model.layers.11.mlp.experts.24.down_proj.weight": "model-00005-of-00010.safetensors",
|
91 |
+
"model.layers.11.mlp.experts.24.gate_proj.weight": "model-00005-of-00010.safetensors",
|
92 |
+
"model.layers.11.mlp.experts.24.up_proj.weight": "model-00005-of-00010.safetensors",
|
93 |
+
"model.layers.11.mlp.experts.25.down_proj.weight": "model-00005-of-00010.safetensors",
|
94 |
+
"model.layers.11.mlp.experts.25.gate_proj.weight": "model-00005-of-00010.safetensors",
|
95 |
+
"model.layers.11.mlp.experts.25.up_proj.weight": "model-00005-of-00010.safetensors",
|
96 |
+
"model.layers.11.mlp.experts.26.down_proj.weight": "model-00005-of-00010.safetensors",
|
97 |
+
"model.layers.11.mlp.experts.26.gate_proj.weight": "model-00005-of-00010.safetensors",
|
98 |
+
"model.layers.11.mlp.experts.26.up_proj.weight": "model-00005-of-00010.safetensors",
|
99 |
+
"model.layers.11.mlp.experts.27.down_proj.weight": "model-00005-of-00010.safetensors",
|
100 |
+
"model.layers.11.mlp.experts.27.gate_proj.weight": "model-00005-of-00010.safetensors",
|
101 |
+
"model.layers.11.mlp.experts.27.up_proj.weight": "model-00005-of-00010.safetensors",
|
102 |
+
"model.layers.11.mlp.experts.28.down_proj.weight": "model-00005-of-00010.safetensors",
|
103 |
+
"model.layers.11.mlp.experts.28.gate_proj.weight": "model-00005-of-00010.safetensors",
|
104 |
+
"model.layers.11.mlp.experts.28.up_proj.weight": "model-00005-of-00010.safetensors",
|
105 |
+
"model.layers.11.mlp.experts.29.down_proj.weight": "model-00005-of-00010.safetensors",
|
106 |
+
"model.layers.11.mlp.experts.29.gate_proj.weight": "model-00005-of-00010.safetensors",
|
107 |
+
"model.layers.11.mlp.experts.29.up_proj.weight": "model-00005-of-00010.safetensors",
|
108 |
+
"model.layers.11.mlp.experts.3.down_proj.weight": "model-00004-of-00010.safetensors",
|
109 |
+
"model.layers.11.mlp.experts.3.gate_proj.weight": "model-00004-of-00010.safetensors",
|
110 |
+
"model.layers.11.mlp.experts.3.up_proj.weight": "model-00004-of-00010.safetensors",
|
111 |
+
"model.layers.11.mlp.experts.30.down_proj.weight": "model-00005-of-00010.safetensors",
|
112 |
+
"model.layers.11.mlp.experts.30.gate_proj.weight": "model-00005-of-00010.safetensors",
|
113 |
+
"model.layers.11.mlp.experts.30.up_proj.weight": "model-00005-of-00010.safetensors",
|
114 |
+
"model.layers.11.mlp.experts.31.down_proj.weight": "model-00005-of-00010.safetensors",
|
115 |
+
"model.layers.11.mlp.experts.31.gate_proj.weight": "model-00005-of-00010.safetensors",
|
116 |
+
"model.layers.11.mlp.experts.31.up_proj.weight": "model-00005-of-00010.safetensors",
|
117 |
+
"model.layers.11.mlp.experts.4.down_proj.weight": "model-00004-of-00010.safetensors",
|
118 |
+
"model.layers.11.mlp.experts.4.gate_proj.weight": "model-00004-of-00010.safetensors",
|
119 |
+
"model.layers.11.mlp.experts.4.up_proj.weight": "model-00004-of-00010.safetensors",
|
120 |
+
"model.layers.11.mlp.experts.5.down_proj.weight": "model-00004-of-00010.safetensors",
|
121 |
+
"model.layers.11.mlp.experts.5.gate_proj.weight": "model-00004-of-00010.safetensors",
|
122 |
+
"model.layers.11.mlp.experts.5.up_proj.weight": "model-00004-of-00010.safetensors",
|
123 |
+
"model.layers.11.mlp.experts.6.down_proj.weight": "model-00004-of-00010.safetensors",
|
124 |
+
"model.layers.11.mlp.experts.6.gate_proj.weight": "model-00004-of-00010.safetensors",
|
125 |
+
"model.layers.11.mlp.experts.6.up_proj.weight": "model-00004-of-00010.safetensors",
|
126 |
+
"model.layers.11.mlp.experts.7.down_proj.weight": "model-00004-of-00010.safetensors",
|
127 |
+
"model.layers.11.mlp.experts.7.gate_proj.weight": "model-00004-of-00010.safetensors",
|
128 |
+
"model.layers.11.mlp.experts.7.up_proj.weight": "model-00004-of-00010.safetensors",
|
129 |
+
"model.layers.11.mlp.experts.8.down_proj.weight": "model-00004-of-00010.safetensors",
|
130 |
+
"model.layers.11.mlp.experts.8.gate_proj.weight": "model-00004-of-00010.safetensors",
|
131 |
+
"model.layers.11.mlp.experts.8.up_proj.weight": "model-00004-of-00010.safetensors",
|
132 |
+
"model.layers.11.mlp.experts.9.down_proj.weight": "model-00004-of-00010.safetensors",
|
133 |
+
"model.layers.11.mlp.experts.9.gate_proj.weight": "model-00004-of-00010.safetensors",
|
134 |
+
"model.layers.11.mlp.experts.9.up_proj.weight": "model-00004-of-00010.safetensors",
|
135 |
+
"model.layers.11.mlp.gate.weight": "model-00003-of-00010.safetensors",
|
136 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00003-of-00010.safetensors",
|
137 |
+
"model.layers.11.pre_extra_mlp_layernorm.weight": "model-00005-of-00010.safetensors",
|
138 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00003-of-00010.safetensors",
|
139 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00003-of-00010.safetensors",
|
140 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00003-of-00010.safetensors",
|
141 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00003-of-00010.safetensors",
|
142 |
+
"model.layers.12.input_layernorm.weight": "model-00005-of-00010.safetensors",
|
143 |
+
"model.layers.12.mlp.down_proj.weight": "model-00005-of-00010.safetensors",
|
144 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00005-of-00010.safetensors",
|
145 |
+
"model.layers.12.mlp.up_proj.weight": "model-00005-of-00010.safetensors",
|
146 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00005-of-00010.safetensors",
|
147 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00005-of-00010.safetensors",
|
148 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00005-of-00010.safetensors",
|
149 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00005-of-00010.safetensors",
|
150 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00005-of-00010.safetensors",
|
151 |
+
"model.layers.13.input_layernorm.weight": "model-00005-of-00010.safetensors",
|
152 |
+
"model.layers.13.mlp.down_proj.weight": "model-00005-of-00010.safetensors",
|
153 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00005-of-00010.safetensors",
|
154 |
+
"model.layers.13.mlp.up_proj.weight": "model-00005-of-00010.safetensors",
|
155 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00005-of-00010.safetensors",
|
156 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00005-of-00010.safetensors",
|
157 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00005-of-00010.safetensors",
|
158 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00005-of-00010.safetensors",
|
159 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00005-of-00010.safetensors",
|
160 |
+
"model.layers.14.input_layernorm.weight": "model-00005-of-00010.safetensors",
|
161 |
+
"model.layers.14.mlp.down_proj.weight": "model-00005-of-00010.safetensors",
|
162 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00005-of-00010.safetensors",
|
163 |
+
"model.layers.14.mlp.up_proj.weight": "model-00005-of-00010.safetensors",
|
164 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00005-of-00010.safetensors",
|
165 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00005-of-00010.safetensors",
|
166 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00005-of-00010.safetensors",
|
167 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00005-of-00010.safetensors",
|
168 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00005-of-00010.safetensors",
|
169 |
+
"model.layers.15.input_layernorm.weight": "model-00006-of-00010.safetensors",
|
170 |
+
"model.layers.15.mlp.down_proj.weight": "model-00006-of-00010.safetensors",
|
171 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00006-of-00010.safetensors",
|
172 |
+
"model.layers.15.mlp.up_proj.weight": "model-00006-of-00010.safetensors",
|
173 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00006-of-00010.safetensors",
|
174 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00006-of-00010.safetensors",
|
175 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00006-of-00010.safetensors",
|
176 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00006-of-00010.safetensors",
|
177 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00006-of-00010.safetensors",
|
178 |
+
"model.layers.16.input_layernorm.weight": "model-00006-of-00010.safetensors",
|
179 |
+
"model.layers.16.mlp.down_proj.weight": "model-00006-of-00010.safetensors",
|
180 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00006-of-00010.safetensors",
|
181 |
+
"model.layers.16.mlp.up_proj.weight": "model-00006-of-00010.safetensors",
|
182 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00006-of-00010.safetensors",
|
183 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00006-of-00010.safetensors",
|
184 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00006-of-00010.safetensors",
|
185 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00006-of-00010.safetensors",
|
186 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00006-of-00010.safetensors",
|
187 |
+
"model.layers.17.extra_mlp.down_proj.weight": "model-00007-of-00010.safetensors",
|
188 |
+
"model.layers.17.extra_mlp.gate_proj.weight": "model-00007-of-00010.safetensors",
|
189 |
+
"model.layers.17.extra_mlp.up_proj.weight": "model-00007-of-00010.safetensors",
|
190 |
+
"model.layers.17.input_layernorm.weight": "model-00006-of-00010.safetensors",
|
191 |
+
"model.layers.17.mlp.experts.0.down_proj.weight": "model-00006-of-00010.safetensors",
|
192 |
+
"model.layers.17.mlp.experts.0.gate_proj.weight": "model-00006-of-00010.safetensors",
|
193 |
+
"model.layers.17.mlp.experts.0.up_proj.weight": "model-00006-of-00010.safetensors",
|
194 |
+
"model.layers.17.mlp.experts.1.down_proj.weight": "model-00006-of-00010.safetensors",
|
195 |
+
"model.layers.17.mlp.experts.1.gate_proj.weight": "model-00006-of-00010.safetensors",
|
196 |
+
"model.layers.17.mlp.experts.1.up_proj.weight": "model-00006-of-00010.safetensors",
|
197 |
+
"model.layers.17.mlp.experts.10.down_proj.weight": "model-00006-of-00010.safetensors",
|
198 |
+
"model.layers.17.mlp.experts.10.gate_proj.weight": "model-00006-of-00010.safetensors",
|
199 |
+
"model.layers.17.mlp.experts.10.up_proj.weight": "model-00006-of-00010.safetensors",
|
200 |
+
"model.layers.17.mlp.experts.11.down_proj.weight": "model-00006-of-00010.safetensors",
|
201 |
+
"model.layers.17.mlp.experts.11.gate_proj.weight": "model-00006-of-00010.safetensors",
|
202 |
+
"model.layers.17.mlp.experts.11.up_proj.weight": "model-00006-of-00010.safetensors",
|
203 |
+
"model.layers.17.mlp.experts.12.down_proj.weight": "model-00006-of-00010.safetensors",
|
204 |
+
"model.layers.17.mlp.experts.12.gate_proj.weight": "model-00006-of-00010.safetensors",
|
205 |
+
"model.layers.17.mlp.experts.12.up_proj.weight": "model-00006-of-00010.safetensors",
|
206 |
+
"model.layers.17.mlp.experts.13.down_proj.weight": "model-00006-of-00010.safetensors",
|
207 |
+
"model.layers.17.mlp.experts.13.gate_proj.weight": "model-00006-of-00010.safetensors",
|
208 |
+
"model.layers.17.mlp.experts.13.up_proj.weight": "model-00006-of-00010.safetensors",
|
209 |
+
"model.layers.17.mlp.experts.14.down_proj.weight": "model-00006-of-00010.safetensors",
|
210 |
+
"model.layers.17.mlp.experts.14.gate_proj.weight": "model-00006-of-00010.safetensors",
|
211 |
+
"model.layers.17.mlp.experts.14.up_proj.weight": "model-00006-of-00010.safetensors",
|
212 |
+
"model.layers.17.mlp.experts.15.down_proj.weight": "model-00007-of-00010.safetensors",
|
213 |
+
"model.layers.17.mlp.experts.15.gate_proj.weight": "model-00006-of-00010.safetensors",
|
214 |
+
"model.layers.17.mlp.experts.15.up_proj.weight": "model-00007-of-00010.safetensors",
|
215 |
+
"model.layers.17.mlp.experts.16.down_proj.weight": "model-00007-of-00010.safetensors",
|
216 |
+
"model.layers.17.mlp.experts.16.gate_proj.weight": "model-00007-of-00010.safetensors",
|
217 |
+
"model.layers.17.mlp.experts.16.up_proj.weight": "model-00007-of-00010.safetensors",
|
218 |
+
"model.layers.17.mlp.experts.17.down_proj.weight": "model-00007-of-00010.safetensors",
|
219 |
+
"model.layers.17.mlp.experts.17.gate_proj.weight": "model-00007-of-00010.safetensors",
|
220 |
+
"model.layers.17.mlp.experts.17.up_proj.weight": "model-00007-of-00010.safetensors",
|
221 |
+
"model.layers.17.mlp.experts.18.down_proj.weight": "model-00007-of-00010.safetensors",
|
222 |
+
"model.layers.17.mlp.experts.18.gate_proj.weight": "model-00007-of-00010.safetensors",
|
223 |
+
"model.layers.17.mlp.experts.18.up_proj.weight": "model-00007-of-00010.safetensors",
|
224 |
+
"model.layers.17.mlp.experts.19.down_proj.weight": "model-00007-of-00010.safetensors",
|
225 |
+
"model.layers.17.mlp.experts.19.gate_proj.weight": "model-00007-of-00010.safetensors",
|
226 |
+
"model.layers.17.mlp.experts.19.up_proj.weight": "model-00007-of-00010.safetensors",
|
227 |
+
"model.layers.17.mlp.experts.2.down_proj.weight": "model-00006-of-00010.safetensors",
|
228 |
+
"model.layers.17.mlp.experts.2.gate_proj.weight": "model-00006-of-00010.safetensors",
|
229 |
+
"model.layers.17.mlp.experts.2.up_proj.weight": "model-00006-of-00010.safetensors",
|
230 |
+
"model.layers.17.mlp.experts.20.down_proj.weight": "model-00007-of-00010.safetensors",
|
231 |
+
"model.layers.17.mlp.experts.20.gate_proj.weight": "model-00007-of-00010.safetensors",
|
232 |
+
"model.layers.17.mlp.experts.20.up_proj.weight": "model-00007-of-00010.safetensors",
|
233 |
+
"model.layers.17.mlp.experts.21.down_proj.weight": "model-00007-of-00010.safetensors",
|
234 |
+
"model.layers.17.mlp.experts.21.gate_proj.weight": "model-00007-of-00010.safetensors",
|
235 |
+
"model.layers.17.mlp.experts.21.up_proj.weight": "model-00007-of-00010.safetensors",
|
236 |
+
"model.layers.17.mlp.experts.22.down_proj.weight": "model-00007-of-00010.safetensors",
|
237 |
+
"model.layers.17.mlp.experts.22.gate_proj.weight": "model-00007-of-00010.safetensors",
|
238 |
+
"model.layers.17.mlp.experts.22.up_proj.weight": "model-00007-of-00010.safetensors",
|
239 |
+
"model.layers.17.mlp.experts.23.down_proj.weight": "model-00007-of-00010.safetensors",
|
240 |
+
"model.layers.17.mlp.experts.23.gate_proj.weight": "model-00007-of-00010.safetensors",
|
241 |
+
"model.layers.17.mlp.experts.23.up_proj.weight": "model-00007-of-00010.safetensors",
|
242 |
+
"model.layers.17.mlp.experts.24.down_proj.weight": "model-00007-of-00010.safetensors",
|
243 |
+
"model.layers.17.mlp.experts.24.gate_proj.weight": "model-00007-of-00010.safetensors",
|
244 |
+
"model.layers.17.mlp.experts.24.up_proj.weight": "model-00007-of-00010.safetensors",
|
245 |
+
"model.layers.17.mlp.experts.25.down_proj.weight": "model-00007-of-00010.safetensors",
|
246 |
+
"model.layers.17.mlp.experts.25.gate_proj.weight": "model-00007-of-00010.safetensors",
|
247 |
+
"model.layers.17.mlp.experts.25.up_proj.weight": "model-00007-of-00010.safetensors",
|
248 |
+
"model.layers.17.mlp.experts.26.down_proj.weight": "model-00007-of-00010.safetensors",
|
249 |
+
"model.layers.17.mlp.experts.26.gate_proj.weight": "model-00007-of-00010.safetensors",
|
250 |
+
"model.layers.17.mlp.experts.26.up_proj.weight": "model-00007-of-00010.safetensors",
|
251 |
+
"model.layers.17.mlp.experts.27.down_proj.weight": "model-00007-of-00010.safetensors",
|
252 |
+
"model.layers.17.mlp.experts.27.gate_proj.weight": "model-00007-of-00010.safetensors",
|
253 |
+
"model.layers.17.mlp.experts.27.up_proj.weight": "model-00007-of-00010.safetensors",
|
254 |
+
"model.layers.17.mlp.experts.28.down_proj.weight": "model-00007-of-00010.safetensors",
|
255 |
+
"model.layers.17.mlp.experts.28.gate_proj.weight": "model-00007-of-00010.safetensors",
|
256 |
+
"model.layers.17.mlp.experts.28.up_proj.weight": "model-00007-of-00010.safetensors",
|
257 |
+
"model.layers.17.mlp.experts.29.down_proj.weight": "model-00007-of-00010.safetensors",
|
258 |
+
"model.layers.17.mlp.experts.29.gate_proj.weight": "model-00007-of-00010.safetensors",
|
259 |
+
"model.layers.17.mlp.experts.29.up_proj.weight": "model-00007-of-00010.safetensors",
|
260 |
+
"model.layers.17.mlp.experts.3.down_proj.weight": "model-00006-of-00010.safetensors",
|
261 |
+
"model.layers.17.mlp.experts.3.gate_proj.weight": "model-00006-of-00010.safetensors",
|
262 |
+
"model.layers.17.mlp.experts.3.up_proj.weight": "model-00006-of-00010.safetensors",
|
263 |
+
"model.layers.17.mlp.experts.30.down_proj.weight": "model-00007-of-00010.safetensors",
|
264 |
+
"model.layers.17.mlp.experts.30.gate_proj.weight": "model-00007-of-00010.safetensors",
|
265 |
+
"model.layers.17.mlp.experts.30.up_proj.weight": "model-00007-of-00010.safetensors",
|
266 |
+
"model.layers.17.mlp.experts.31.down_proj.weight": "model-00007-of-00010.safetensors",
|
267 |
+
"model.layers.17.mlp.experts.31.gate_proj.weight": "model-00007-of-00010.safetensors",
|
268 |
+
"model.layers.17.mlp.experts.31.up_proj.weight": "model-00007-of-00010.safetensors",
|
269 |
+
"model.layers.17.mlp.experts.4.down_proj.weight": "model-00006-of-00010.safetensors",
|
270 |
+
"model.layers.17.mlp.experts.4.gate_proj.weight": "model-00006-of-00010.safetensors",
|
271 |
+
"model.layers.17.mlp.experts.4.up_proj.weight": "model-00006-of-00010.safetensors",
|
272 |
+
"model.layers.17.mlp.experts.5.down_proj.weight": "model-00006-of-00010.safetensors",
|
273 |
+
"model.layers.17.mlp.experts.5.gate_proj.weight": "model-00006-of-00010.safetensors",
|
274 |
+
"model.layers.17.mlp.experts.5.up_proj.weight": "model-00006-of-00010.safetensors",
|
275 |
+
"model.layers.17.mlp.experts.6.down_proj.weight": "model-00006-of-00010.safetensors",
|
276 |
+
"model.layers.17.mlp.experts.6.gate_proj.weight": "model-00006-of-00010.safetensors",
|
277 |
+
"model.layers.17.mlp.experts.6.up_proj.weight": "model-00006-of-00010.safetensors",
|
278 |
+
"model.layers.17.mlp.experts.7.down_proj.weight": "model-00006-of-00010.safetensors",
|
279 |
+
"model.layers.17.mlp.experts.7.gate_proj.weight": "model-00006-of-00010.safetensors",
|
280 |
+
"model.layers.17.mlp.experts.7.up_proj.weight": "model-00006-of-00010.safetensors",
|
281 |
+
"model.layers.17.mlp.experts.8.down_proj.weight": "model-00006-of-00010.safetensors",
|
282 |
+
"model.layers.17.mlp.experts.8.gate_proj.weight": "model-00006-of-00010.safetensors",
|
283 |
+
"model.layers.17.mlp.experts.8.up_proj.weight": "model-00006-of-00010.safetensors",
|
284 |
+
"model.layers.17.mlp.experts.9.down_proj.weight": "model-00006-of-00010.safetensors",
|
285 |
+
"model.layers.17.mlp.experts.9.gate_proj.weight": "model-00006-of-00010.safetensors",
|
286 |
+
"model.layers.17.mlp.experts.9.up_proj.weight": "model-00006-of-00010.safetensors",
|
287 |
+
"model.layers.17.mlp.gate.weight": "model-00006-of-00010.safetensors",
|
288 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00006-of-00010.safetensors",
|
289 |
+
"model.layers.17.pre_extra_mlp_layernorm.weight": "model-00007-of-00010.safetensors",
|
290 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00006-of-00010.safetensors",
|
291 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00006-of-00010.safetensors",
|
292 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00006-of-00010.safetensors",
|
293 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00006-of-00010.safetensors",
|
294 |
+
"model.layers.18.input_layernorm.weight": "model-00007-of-00010.safetensors",
|
295 |
+
"model.layers.18.mlp.down_proj.weight": "model-00008-of-00010.safetensors",
|
296 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00007-of-00010.safetensors",
|
297 |
+
"model.layers.18.mlp.up_proj.weight": "model-00007-of-00010.safetensors",
|
298 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00007-of-00010.safetensors",
|
299 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00007-of-00010.safetensors",
|
300 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00007-of-00010.safetensors",
|
301 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00007-of-00010.safetensors",
|
302 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00007-of-00010.safetensors",
|
303 |
+
"model.layers.19.input_layernorm.weight": "model-00008-of-00010.safetensors",
|
304 |
+
"model.layers.19.mlp.down_proj.weight": "model-00008-of-00010.safetensors",
|
305 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00008-of-00010.safetensors",
|
306 |
+
"model.layers.19.mlp.up_proj.weight": "model-00008-of-00010.safetensors",
|
307 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00008-of-00010.safetensors",
|
308 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00008-of-00010.safetensors",
|
309 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00008-of-00010.safetensors",
|
310 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00008-of-00010.safetensors",
|
311 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00008-of-00010.safetensors",
|
312 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00010.safetensors",
|
313 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00010.safetensors",
|
314 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00010.safetensors",
|
315 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00010.safetensors",
|
316 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00010.safetensors",
|
317 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00010.safetensors",
|
318 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00010.safetensors",
|
319 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00010.safetensors",
|
320 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00010.safetensors",
|
321 |
+
"model.layers.20.input_layernorm.weight": "model-00008-of-00010.safetensors",
|
322 |
+
"model.layers.20.mlp.down_proj.weight": "model-00008-of-00010.safetensors",
|
323 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00008-of-00010.safetensors",
|
324 |
+
"model.layers.20.mlp.up_proj.weight": "model-00008-of-00010.safetensors",
|
325 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00008-of-00010.safetensors",
|
326 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00008-of-00010.safetensors",
|
327 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00008-of-00010.safetensors",
|
328 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00008-of-00010.safetensors",
|
329 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00008-of-00010.safetensors",
|
330 |
+
"model.layers.21.input_layernorm.weight": "model-00008-of-00010.safetensors",
|
331 |
+
"model.layers.21.mlp.down_proj.weight": "model-00008-of-00010.safetensors",
|
332 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00008-of-00010.safetensors",
|
333 |
+
"model.layers.21.mlp.up_proj.weight": "model-00008-of-00010.safetensors",
|
334 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00008-of-00010.safetensors",
|
335 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00008-of-00010.safetensors",
|
336 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00008-of-00010.safetensors",
|
337 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00008-of-00010.safetensors",
|
338 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00008-of-00010.safetensors",
|
339 |
+
"model.layers.22.input_layernorm.weight": "model-00008-of-00010.safetensors",
|
340 |
+
"model.layers.22.mlp.down_proj.weight": "model-00008-of-00010.safetensors",
|
341 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00008-of-00010.safetensors",
|
342 |
+
"model.layers.22.mlp.up_proj.weight": "model-00008-of-00010.safetensors",
|
343 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00008-of-00010.safetensors",
|
344 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00008-of-00010.safetensors",
|
345 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00008-of-00010.safetensors",
|
346 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00008-of-00010.safetensors",
|
347 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00008-of-00010.safetensors",
|
348 |
+
"model.layers.23.extra_mlp.down_proj.weight": "model-00010-of-00010.safetensors",
|
349 |
+
"model.layers.23.extra_mlp.gate_proj.weight": "model-00010-of-00010.safetensors",
|
350 |
+
"model.layers.23.extra_mlp.up_proj.weight": "model-00010-of-00010.safetensors",
|
351 |
+
"model.layers.23.input_layernorm.weight": "model-00008-of-00010.safetensors",
|
352 |
+
"model.layers.23.mlp.experts.0.down_proj.weight": "model-00008-of-00010.safetensors",
|
353 |
+
"model.layers.23.mlp.experts.0.gate_proj.weight": "model-00008-of-00010.safetensors",
|
354 |
+
"model.layers.23.mlp.experts.0.up_proj.weight": "model-00008-of-00010.safetensors",
|
355 |
+
"model.layers.23.mlp.experts.1.down_proj.weight": "model-00008-of-00010.safetensors",
|
356 |
+
"model.layers.23.mlp.experts.1.gate_proj.weight": "model-00008-of-00010.safetensors",
|
357 |
+
"model.layers.23.mlp.experts.1.up_proj.weight": "model-00008-of-00010.safetensors",
|
358 |
+
"model.layers.23.mlp.experts.10.down_proj.weight": "model-00008-of-00010.safetensors",
|
359 |
+
"model.layers.23.mlp.experts.10.gate_proj.weight": "model-00008-of-00010.safetensors",
|
360 |
+
"model.layers.23.mlp.experts.10.up_proj.weight": "model-00008-of-00010.safetensors",
|
361 |
+
"model.layers.23.mlp.experts.11.down_proj.weight": "model-00008-of-00010.safetensors",
|
362 |
+
"model.layers.23.mlp.experts.11.gate_proj.weight": "model-00008-of-00010.safetensors",
|
363 |
+
"model.layers.23.mlp.experts.11.up_proj.weight": "model-00008-of-00010.safetensors",
|
364 |
+
"model.layers.23.mlp.experts.12.down_proj.weight": "model-00009-of-00010.safetensors",
|
365 |
+
"model.layers.23.mlp.experts.12.gate_proj.weight": "model-00008-of-00010.safetensors",
|
366 |
+
"model.layers.23.mlp.experts.12.up_proj.weight": "model-00009-of-00010.safetensors",
|
367 |
+
"model.layers.23.mlp.experts.13.down_proj.weight": "model-00009-of-00010.safetensors",
|
368 |
+
"model.layers.23.mlp.experts.13.gate_proj.weight": "model-00009-of-00010.safetensors",
|
369 |
+
"model.layers.23.mlp.experts.13.up_proj.weight": "model-00009-of-00010.safetensors",
|
370 |
+
"model.layers.23.mlp.experts.14.down_proj.weight": "model-00009-of-00010.safetensors",
|
371 |
+
"model.layers.23.mlp.experts.14.gate_proj.weight": "model-00009-of-00010.safetensors",
|
372 |
+
"model.layers.23.mlp.experts.14.up_proj.weight": "model-00009-of-00010.safetensors",
|
373 |
+
"model.layers.23.mlp.experts.15.down_proj.weight": "model-00009-of-00010.safetensors",
|
374 |
+
"model.layers.23.mlp.experts.15.gate_proj.weight": "model-00009-of-00010.safetensors",
|
375 |
+
"model.layers.23.mlp.experts.15.up_proj.weight": "model-00009-of-00010.safetensors",
|
376 |
+
"model.layers.23.mlp.experts.16.down_proj.weight": "model-00009-of-00010.safetensors",
|
377 |
+
"model.layers.23.mlp.experts.16.gate_proj.weight": "model-00009-of-00010.safetensors",
|
378 |
+
"model.layers.23.mlp.experts.16.up_proj.weight": "model-00009-of-00010.safetensors",
|
379 |
+
"model.layers.23.mlp.experts.17.down_proj.weight": "model-00009-of-00010.safetensors",
|
380 |
+
"model.layers.23.mlp.experts.17.gate_proj.weight": "model-00009-of-00010.safetensors",
|
381 |
+
"model.layers.23.mlp.experts.17.up_proj.weight": "model-00009-of-00010.safetensors",
|
382 |
+
"model.layers.23.mlp.experts.18.down_proj.weight": "model-00009-of-00010.safetensors",
|
383 |
+
"model.layers.23.mlp.experts.18.gate_proj.weight": "model-00009-of-00010.safetensors",
|
384 |
+
"model.layers.23.mlp.experts.18.up_proj.weight": "model-00009-of-00010.safetensors",
|
385 |
+
"model.layers.23.mlp.experts.19.down_proj.weight": "model-00009-of-00010.safetensors",
|
386 |
+
"model.layers.23.mlp.experts.19.gate_proj.weight": "model-00009-of-00010.safetensors",
|
387 |
+
"model.layers.23.mlp.experts.19.up_proj.weight": "model-00009-of-00010.safetensors",
|
388 |
+
"model.layers.23.mlp.experts.2.down_proj.weight": "model-00008-of-00010.safetensors",
|
389 |
+
"model.layers.23.mlp.experts.2.gate_proj.weight": "model-00008-of-00010.safetensors",
|
390 |
+
"model.layers.23.mlp.experts.2.up_proj.weight": "model-00008-of-00010.safetensors",
|
391 |
+
"model.layers.23.mlp.experts.20.down_proj.weight": "model-00009-of-00010.safetensors",
|
392 |
+
"model.layers.23.mlp.experts.20.gate_proj.weight": "model-00009-of-00010.safetensors",
|
393 |
+
"model.layers.23.mlp.experts.20.up_proj.weight": "model-00009-of-00010.safetensors",
|
394 |
+
"model.layers.23.mlp.experts.21.down_proj.weight": "model-00009-of-00010.safetensors",
|
395 |
+
"model.layers.23.mlp.experts.21.gate_proj.weight": "model-00009-of-00010.safetensors",
|
396 |
+
"model.layers.23.mlp.experts.21.up_proj.weight": "model-00009-of-00010.safetensors",
|
397 |
+
"model.layers.23.mlp.experts.22.down_proj.weight": "model-00009-of-00010.safetensors",
|
398 |
+
"model.layers.23.mlp.experts.22.gate_proj.weight": "model-00009-of-00010.safetensors",
|
399 |
+
"model.layers.23.mlp.experts.22.up_proj.weight": "model-00009-of-00010.safetensors",
|
400 |
+
"model.layers.23.mlp.experts.23.down_proj.weight": "model-00009-of-00010.safetensors",
|
401 |
+
"model.layers.23.mlp.experts.23.gate_proj.weight": "model-00009-of-00010.safetensors",
|
402 |
+
"model.layers.23.mlp.experts.23.up_proj.weight": "model-00009-of-00010.safetensors",
|
403 |
+
"model.layers.23.mlp.experts.24.down_proj.weight": "model-00009-of-00010.safetensors",
|
404 |
+
"model.layers.23.mlp.experts.24.gate_proj.weight": "model-00009-of-00010.safetensors",
|
405 |
+
"model.layers.23.mlp.experts.24.up_proj.weight": "model-00009-of-00010.safetensors",
|
406 |
+
"model.layers.23.mlp.experts.25.down_proj.weight": "model-00009-of-00010.safetensors",
|
407 |
+
"model.layers.23.mlp.experts.25.gate_proj.weight": "model-00009-of-00010.safetensors",
|
408 |
+
"model.layers.23.mlp.experts.25.up_proj.weight": "model-00009-of-00010.safetensors",
|
409 |
+
"model.layers.23.mlp.experts.26.down_proj.weight": "model-00009-of-00010.safetensors",
|
410 |
+
"model.layers.23.mlp.experts.26.gate_proj.weight": "model-00009-of-00010.safetensors",
|
411 |
+
"model.layers.23.mlp.experts.26.up_proj.weight": "model-00009-of-00010.safetensors",
|
412 |
+
"model.layers.23.mlp.experts.27.down_proj.weight": "model-00009-of-00010.safetensors",
|
413 |
+
"model.layers.23.mlp.experts.27.gate_proj.weight": "model-00009-of-00010.safetensors",
|
414 |
+
"model.layers.23.mlp.experts.27.up_proj.weight": "model-00009-of-00010.safetensors",
|
415 |
+
"model.layers.23.mlp.experts.28.down_proj.weight": "model-00009-of-00010.safetensors",
|
416 |
+
"model.layers.23.mlp.experts.28.gate_proj.weight": "model-00009-of-00010.safetensors",
|
417 |
+
"model.layers.23.mlp.experts.28.up_proj.weight": "model-00009-of-00010.safetensors",
|
418 |
+
"model.layers.23.mlp.experts.29.down_proj.weight": "model-00009-of-00010.safetensors",
|
419 |
+
"model.layers.23.mlp.experts.29.gate_proj.weight": "model-00009-of-00010.safetensors",
|
420 |
+
"model.layers.23.mlp.experts.29.up_proj.weight": "model-00009-of-00010.safetensors",
|
421 |
+
"model.layers.23.mlp.experts.3.down_proj.weight": "model-00008-of-00010.safetensors",
|
422 |
+
"model.layers.23.mlp.experts.3.gate_proj.weight": "model-00008-of-00010.safetensors",
|
423 |
+
"model.layers.23.mlp.experts.3.up_proj.weight": "model-00008-of-00010.safetensors",
|
424 |
+
"model.layers.23.mlp.experts.30.down_proj.weight": "model-00009-of-00010.safetensors",
|
425 |
+
"model.layers.23.mlp.experts.30.gate_proj.weight": "model-00009-of-00010.safetensors",
|
426 |
+
"model.layers.23.mlp.experts.30.up_proj.weight": "model-00009-of-00010.safetensors",
|
427 |
+
"model.layers.23.mlp.experts.31.down_proj.weight": "model-00010-of-00010.safetensors",
|
428 |
+
"model.layers.23.mlp.experts.31.gate_proj.weight": "model-00010-of-00010.safetensors",
|
429 |
+
"model.layers.23.mlp.experts.31.up_proj.weight": "model-00010-of-00010.safetensors",
|
430 |
+
"model.layers.23.mlp.experts.4.down_proj.weight": "model-00008-of-00010.safetensors",
|
431 |
+
"model.layers.23.mlp.experts.4.gate_proj.weight": "model-00008-of-00010.safetensors",
|
432 |
+
"model.layers.23.mlp.experts.4.up_proj.weight": "model-00008-of-00010.safetensors",
|
433 |
+
"model.layers.23.mlp.experts.5.down_proj.weight": "model-00008-of-00010.safetensors",
|
434 |
+
"model.layers.23.mlp.experts.5.gate_proj.weight": "model-00008-of-00010.safetensors",
|
435 |
+
"model.layers.23.mlp.experts.5.up_proj.weight": "model-00008-of-00010.safetensors",
|
436 |
+
"model.layers.23.mlp.experts.6.down_proj.weight": "model-00008-of-00010.safetensors",
|
437 |
+
"model.layers.23.mlp.experts.6.gate_proj.weight": "model-00008-of-00010.safetensors",
|
438 |
+
"model.layers.23.mlp.experts.6.up_proj.weight": "model-00008-of-00010.safetensors",
|
439 |
+
"model.layers.23.mlp.experts.7.down_proj.weight": "model-00008-of-00010.safetensors",
|
440 |
+
"model.layers.23.mlp.experts.7.gate_proj.weight": "model-00008-of-00010.safetensors",
|
441 |
+
"model.layers.23.mlp.experts.7.up_proj.weight": "model-00008-of-00010.safetensors",
|
442 |
+
"model.layers.23.mlp.experts.8.down_proj.weight": "model-00008-of-00010.safetensors",
|
443 |
+
"model.layers.23.mlp.experts.8.gate_proj.weight": "model-00008-of-00010.safetensors",
|
444 |
+
"model.layers.23.mlp.experts.8.up_proj.weight": "model-00008-of-00010.safetensors",
|
445 |
+
"model.layers.23.mlp.experts.9.down_proj.weight": "model-00008-of-00010.safetensors",
|
446 |
+
"model.layers.23.mlp.experts.9.gate_proj.weight": "model-00008-of-00010.safetensors",
|
447 |
+
"model.layers.23.mlp.experts.9.up_proj.weight": "model-00008-of-00010.safetensors",
|
448 |
+
"model.layers.23.mlp.gate.weight": "model-00008-of-00010.safetensors",
|
449 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00008-of-00010.safetensors",
|
450 |
+
"model.layers.23.pre_extra_mlp_layernorm.weight": "model-00010-of-00010.safetensors",
|
451 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00008-of-00010.safetensors",
|
452 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00008-of-00010.safetensors",
|
453 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00008-of-00010.safetensors",
|
454 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00008-of-00010.safetensors",
|
455 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00010.safetensors",
|
456 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00010.safetensors",
|
457 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00010.safetensors",
|
458 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00010.safetensors",
|
459 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00010.safetensors",
|
460 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00010.safetensors",
|
461 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00010.safetensors",
|
462 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00010.safetensors",
|
463 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00010.safetensors",
|
464 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00010.safetensors",
|
465 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00010.safetensors",
|
466 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00010.safetensors",
|
467 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00010.safetensors",
|
468 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00010.safetensors",
|
469 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00010.safetensors",
|
470 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00010.safetensors",
|
471 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00010.safetensors",
|
472 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00010.safetensors",
|
473 |
+
"model.layers.5.extra_mlp.down_proj.weight": "model-00003-of-00010.safetensors",
|
474 |
+
"model.layers.5.extra_mlp.gate_proj.weight": "model-00003-of-00010.safetensors",
|
475 |
+
"model.layers.5.extra_mlp.up_proj.weight": "model-00003-of-00010.safetensors",
|
476 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00010.safetensors",
|
477 |
+
"model.layers.5.mlp.experts.0.down_proj.weight": "model-00001-of-00010.safetensors",
|
478 |
+
"model.layers.5.mlp.experts.0.gate_proj.weight": "model-00001-of-00010.safetensors",
|
479 |
+
"model.layers.5.mlp.experts.0.up_proj.weight": "model-00001-of-00010.safetensors",
|
480 |
+
"model.layers.5.mlp.experts.1.down_proj.weight": "model-00001-of-00010.safetensors",
|
481 |
+
"model.layers.5.mlp.experts.1.gate_proj.weight": "model-00001-of-00010.safetensors",
|
482 |
+
"model.layers.5.mlp.experts.1.up_proj.weight": "model-00001-of-00010.safetensors",
|
483 |
+
"model.layers.5.mlp.experts.10.down_proj.weight": "model-00002-of-00010.safetensors",
|
484 |
+
"model.layers.5.mlp.experts.10.gate_proj.weight": "model-00002-of-00010.safetensors",
|
485 |
+
"model.layers.5.mlp.experts.10.up_proj.weight": "model-00002-of-00010.safetensors",
|
486 |
+
"model.layers.5.mlp.experts.11.down_proj.weight": "model-00002-of-00010.safetensors",
|
487 |
+
"model.layers.5.mlp.experts.11.gate_proj.weight": "model-00002-of-00010.safetensors",
|
488 |
+
"model.layers.5.mlp.experts.11.up_proj.weight": "model-00002-of-00010.safetensors",
|
489 |
+
"model.layers.5.mlp.experts.12.down_proj.weight": "model-00002-of-00010.safetensors",
|
490 |
+
"model.layers.5.mlp.experts.12.gate_proj.weight": "model-00002-of-00010.safetensors",
|
491 |
+
"model.layers.5.mlp.experts.12.up_proj.weight": "model-00002-of-00010.safetensors",
|
492 |
+
"model.layers.5.mlp.experts.13.down_proj.weight": "model-00002-of-00010.safetensors",
|
493 |
+
"model.layers.5.mlp.experts.13.gate_proj.weight": "model-00002-of-00010.safetensors",
|
494 |
+
"model.layers.5.mlp.experts.13.up_proj.weight": "model-00002-of-00010.safetensors",
|
495 |
+
"model.layers.5.mlp.experts.14.down_proj.weight": "model-00002-of-00010.safetensors",
|
496 |
+
"model.layers.5.mlp.experts.14.gate_proj.weight": "model-00002-of-00010.safetensors",
|
497 |
+
"model.layers.5.mlp.experts.14.up_proj.weight": "model-00002-of-00010.safetensors",
|
498 |
+
"model.layers.5.mlp.experts.15.down_proj.weight": "model-00002-of-00010.safetensors",
|
499 |
+
"model.layers.5.mlp.experts.15.gate_proj.weight": "model-00002-of-00010.safetensors",
|
500 |
+
"model.layers.5.mlp.experts.15.up_proj.weight": "model-00002-of-00010.safetensors",
|
501 |
+
"model.layers.5.mlp.experts.16.down_proj.weight": "model-00002-of-00010.safetensors",
|
502 |
+
"model.layers.5.mlp.experts.16.gate_proj.weight": "model-00002-of-00010.safetensors",
|
503 |
+
"model.layers.5.mlp.experts.16.up_proj.weight": "model-00002-of-00010.safetensors",
|
504 |
+
"model.layers.5.mlp.experts.17.down_proj.weight": "model-00002-of-00010.safetensors",
|
505 |
+
"model.layers.5.mlp.experts.17.gate_proj.weight": "model-00002-of-00010.safetensors",
|
506 |
+
"model.layers.5.mlp.experts.17.up_proj.weight": "model-00002-of-00010.safetensors",
|
507 |
+
"model.layers.5.mlp.experts.18.down_proj.weight": "model-00002-of-00010.safetensors",
|
508 |
+
"model.layers.5.mlp.experts.18.gate_proj.weight": "model-00002-of-00010.safetensors",
|
509 |
+
"model.layers.5.mlp.experts.18.up_proj.weight": "model-00002-of-00010.safetensors",
|
510 |
+
"model.layers.5.mlp.experts.19.down_proj.weight": "model-00002-of-00010.safetensors",
|
511 |
+
"model.layers.5.mlp.experts.19.gate_proj.weight": "model-00002-of-00010.safetensors",
|
512 |
+
"model.layers.5.mlp.experts.19.up_proj.weight": "model-00002-of-00010.safetensors",
|
513 |
+
"model.layers.5.mlp.experts.2.down_proj.weight": "model-00001-of-00010.safetensors",
|
514 |
+
"model.layers.5.mlp.experts.2.gate_proj.weight": "model-00001-of-00010.safetensors",
|
515 |
+
"model.layers.5.mlp.experts.2.up_proj.weight": "model-00001-of-00010.safetensors",
|
516 |
+
"model.layers.5.mlp.experts.20.down_proj.weight": "model-00002-of-00010.safetensors",
|
517 |
+
"model.layers.5.mlp.experts.20.gate_proj.weight": "model-00002-of-00010.safetensors",
|
518 |
+
"model.layers.5.mlp.experts.20.up_proj.weight": "model-00002-of-00010.safetensors",
|
519 |
+
"model.layers.5.mlp.experts.21.down_proj.weight": "model-00002-of-00010.safetensors",
|
520 |
+
"model.layers.5.mlp.experts.21.gate_proj.weight": "model-00002-of-00010.safetensors",
|
521 |
+
"model.layers.5.mlp.experts.21.up_proj.weight": "model-00002-of-00010.safetensors",
|
522 |
+
"model.layers.5.mlp.experts.22.down_proj.weight": "model-00003-of-00010.safetensors",
|
523 |
+
"model.layers.5.mlp.experts.22.gate_proj.weight": "model-00003-of-00010.safetensors",
|
524 |
+
"model.layers.5.mlp.experts.22.up_proj.weight": "model-00003-of-00010.safetensors",
|
525 |
+
"model.layers.5.mlp.experts.23.down_proj.weight": "model-00003-of-00010.safetensors",
|
526 |
+
"model.layers.5.mlp.experts.23.gate_proj.weight": "model-00003-of-00010.safetensors",
|
527 |
+
"model.layers.5.mlp.experts.23.up_proj.weight": "model-00003-of-00010.safetensors",
|
528 |
+
"model.layers.5.mlp.experts.24.down_proj.weight": "model-00003-of-00010.safetensors",
|
529 |
+
"model.layers.5.mlp.experts.24.gate_proj.weight": "model-00003-of-00010.safetensors",
|
530 |
+
"model.layers.5.mlp.experts.24.up_proj.weight": "model-00003-of-00010.safetensors",
|
531 |
+
"model.layers.5.mlp.experts.25.down_proj.weight": "model-00003-of-00010.safetensors",
|
532 |
+
"model.layers.5.mlp.experts.25.gate_proj.weight": "model-00003-of-00010.safetensors",
|
533 |
+
"model.layers.5.mlp.experts.25.up_proj.weight": "model-00003-of-00010.safetensors",
|
534 |
+
"model.layers.5.mlp.experts.26.down_proj.weight": "model-00003-of-00010.safetensors",
|
535 |
+
"model.layers.5.mlp.experts.26.gate_proj.weight": "model-00003-of-00010.safetensors",
|
536 |
+
"model.layers.5.mlp.experts.26.up_proj.weight": "model-00003-of-00010.safetensors",
|
537 |
+
"model.layers.5.mlp.experts.27.down_proj.weight": "model-00003-of-00010.safetensors",
|
538 |
+
"model.layers.5.mlp.experts.27.gate_proj.weight": "model-00003-of-00010.safetensors",
|
539 |
+
"model.layers.5.mlp.experts.27.up_proj.weight": "model-00003-of-00010.safetensors",
|
540 |
+
"model.layers.5.mlp.experts.28.down_proj.weight": "model-00003-of-00010.safetensors",
|
541 |
+
"model.layers.5.mlp.experts.28.gate_proj.weight": "model-00003-of-00010.safetensors",
|
542 |
+
"model.layers.5.mlp.experts.28.up_proj.weight": "model-00003-of-00010.safetensors",
|
543 |
+
"model.layers.5.mlp.experts.29.down_proj.weight": "model-00003-of-00010.safetensors",
|
544 |
+
"model.layers.5.mlp.experts.29.gate_proj.weight": "model-00003-of-00010.safetensors",
|
545 |
+
"model.layers.5.mlp.experts.29.up_proj.weight": "model-00003-of-00010.safetensors",
|
546 |
+
"model.layers.5.mlp.experts.3.down_proj.weight": "model-00002-of-00010.safetensors",
|
547 |
+
"model.layers.5.mlp.experts.3.gate_proj.weight": "model-00001-of-00010.safetensors",
|
548 |
+
"model.layers.5.mlp.experts.3.up_proj.weight": "model-00002-of-00010.safetensors",
|
549 |
+
"model.layers.5.mlp.experts.30.down_proj.weight": "model-00003-of-00010.safetensors",
|
550 |
+
"model.layers.5.mlp.experts.30.gate_proj.weight": "model-00003-of-00010.safetensors",
|
551 |
+
"model.layers.5.mlp.experts.30.up_proj.weight": "model-00003-of-00010.safetensors",
|
552 |
+
"model.layers.5.mlp.experts.31.down_proj.weight": "model-00003-of-00010.safetensors",
|
553 |
+
"model.layers.5.mlp.experts.31.gate_proj.weight": "model-00003-of-00010.safetensors",
|
554 |
+
"model.layers.5.mlp.experts.31.up_proj.weight": "model-00003-of-00010.safetensors",
|
555 |
+
"model.layers.5.mlp.experts.4.down_proj.weight": "model-00002-of-00010.safetensors",
|
556 |
+
"model.layers.5.mlp.experts.4.gate_proj.weight": "model-00002-of-00010.safetensors",
|
557 |
+
"model.layers.5.mlp.experts.4.up_proj.weight": "model-00002-of-00010.safetensors",
|
558 |
+
"model.layers.5.mlp.experts.5.down_proj.weight": "model-00002-of-00010.safetensors",
|
559 |
+
"model.layers.5.mlp.experts.5.gate_proj.weight": "model-00002-of-00010.safetensors",
|
560 |
+
"model.layers.5.mlp.experts.5.up_proj.weight": "model-00002-of-00010.safetensors",
|
561 |
+
"model.layers.5.mlp.experts.6.down_proj.weight": "model-00002-of-00010.safetensors",
|
562 |
+
"model.layers.5.mlp.experts.6.gate_proj.weight": "model-00002-of-00010.safetensors",
|
563 |
+
"model.layers.5.mlp.experts.6.up_proj.weight": "model-00002-of-00010.safetensors",
|
564 |
+
"model.layers.5.mlp.experts.7.down_proj.weight": "model-00002-of-00010.safetensors",
|
565 |
+
"model.layers.5.mlp.experts.7.gate_proj.weight": "model-00002-of-00010.safetensors",
|
566 |
+
"model.layers.5.mlp.experts.7.up_proj.weight": "model-00002-of-00010.safetensors",
|
567 |
+
"model.layers.5.mlp.experts.8.down_proj.weight": "model-00002-of-00010.safetensors",
|
568 |
+
"model.layers.5.mlp.experts.8.gate_proj.weight": "model-00002-of-00010.safetensors",
|
569 |
+
"model.layers.5.mlp.experts.8.up_proj.weight": "model-00002-of-00010.safetensors",
|
570 |
+
"model.layers.5.mlp.experts.9.down_proj.weight": "model-00002-of-00010.safetensors",
|
571 |
+
"model.layers.5.mlp.experts.9.gate_proj.weight": "model-00002-of-00010.safetensors",
|
572 |
+
"model.layers.5.mlp.experts.9.up_proj.weight": "model-00002-of-00010.safetensors",
|
573 |
+
"model.layers.5.mlp.gate.weight": "model-00001-of-00010.safetensors",
|
574 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00010.safetensors",
|
575 |
+
"model.layers.5.pre_extra_mlp_layernorm.weight": "model-00003-of-00010.safetensors",
|
576 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00010.safetensors",
|
577 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00010.safetensors",
|
578 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00010.safetensors",
|
579 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00010.safetensors",
|
580 |
+
"model.layers.6.input_layernorm.weight": "model-00003-of-00010.safetensors",
|
581 |
+
"model.layers.6.mlp.down_proj.weight": "model-00003-of-00010.safetensors",
|
582 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00003-of-00010.safetensors",
|
583 |
+
"model.layers.6.mlp.up_proj.weight": "model-00003-of-00010.safetensors",
|
584 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00003-of-00010.safetensors",
|
585 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00003-of-00010.safetensors",
|
586 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00003-of-00010.safetensors",
|
587 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00003-of-00010.safetensors",
|
588 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00003-of-00010.safetensors",
|
589 |
+
"model.layers.7.input_layernorm.weight": "model-00003-of-00010.safetensors",
|
590 |
+
"model.layers.7.mlp.down_proj.weight": "model-00003-of-00010.safetensors",
|
591 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00003-of-00010.safetensors",
|
592 |
+
"model.layers.7.mlp.up_proj.weight": "model-00003-of-00010.safetensors",
|
593 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00003-of-00010.safetensors",
|
594 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00003-of-00010.safetensors",
|
595 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00003-of-00010.safetensors",
|
596 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00003-of-00010.safetensors",
|
597 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00003-of-00010.safetensors",
|
598 |
+
"model.layers.8.input_layernorm.weight": "model-00003-of-00010.safetensors",
|
599 |
+
"model.layers.8.mlp.down_proj.weight": "model-00003-of-00010.safetensors",
|
600 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00003-of-00010.safetensors",
|
601 |
+
"model.layers.8.mlp.up_proj.weight": "model-00003-of-00010.safetensors",
|
602 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00003-of-00010.safetensors",
|
603 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00003-of-00010.safetensors",
|
604 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00003-of-00010.safetensors",
|
605 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00003-of-00010.safetensors",
|
606 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00003-of-00010.safetensors",
|
607 |
+
"model.layers.9.input_layernorm.weight": "model-00003-of-00010.safetensors",
|
608 |
+
"model.layers.9.mlp.down_proj.weight": "model-00003-of-00010.safetensors",
|
609 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00003-of-00010.safetensors",
|
610 |
+
"model.layers.9.mlp.up_proj.weight": "model-00003-of-00010.safetensors",
|
611 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00003-of-00010.safetensors",
|
612 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00003-of-00010.safetensors",
|
613 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00003-of-00010.safetensors",
|
614 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00003-of-00010.safetensors",
|
615 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00003-of-00010.safetensors",
|
616 |
+
"model.norm.weight": "model-00010-of-00010.safetensors"
|
617 |
+
}
|
618 |
+
}
|
modeling_hf_openmoe.py
ADDED
@@ -0,0 +1,1121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 EleutherAI 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 OpenMoE model."""
|
21 |
+
import math
|
22 |
+
from typing import List, Union
|
23 |
+
from typing import Optional, Tuple
|
24 |
+
|
25 |
+
import torch
|
26 |
+
import torch.utils.checkpoint
|
27 |
+
from torch import nn
|
28 |
+
from torch.nn import functional as F
|
29 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
30 |
+
from transformers.modeling_utils import PreTrainedModel
|
31 |
+
from transformers.utils import (
|
32 |
+
add_start_docstrings,
|
33 |
+
add_start_docstrings_to_model_forward,
|
34 |
+
logging,
|
35 |
+
replace_return_docstrings,
|
36 |
+
)
|
37 |
+
|
38 |
+
# from .llama_attn import LlamaAttention
|
39 |
+
from .configuration_hf_openmoe import HFOpenMoeConfig
|
40 |
+
|
41 |
+
logger = logging.get_logger(__name__)
|
42 |
+
|
43 |
+
_CONFIG_FOR_DOC = "HFOpenMoeConfig"
|
44 |
+
|
45 |
+
|
46 |
+
# Copied from transformers.models.bart.modeling_bart._make_causal_mask
|
47 |
+
def _make_causal_mask(
|
48 |
+
input_ids_shape: torch.Size, dtype: torch.dtype, device: torch.device, past_key_values_length: int = 0
|
49 |
+
):
|
50 |
+
"""
|
51 |
+
Make causal mask used for bi-directional self-attention.
|
52 |
+
"""
|
53 |
+
bsz, tgt_len = input_ids_shape
|
54 |
+
mask = torch.full((tgt_len, tgt_len), torch.finfo(dtype).min, device=device)
|
55 |
+
mask_cond = torch.arange(mask.size(-1), device=device)
|
56 |
+
mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
|
57 |
+
mask = mask.to(dtype)
|
58 |
+
|
59 |
+
if past_key_values_length > 0:
|
60 |
+
mask = torch.cat([torch.zeros(tgt_len, past_key_values_length, dtype=dtype, device=device), mask], dim=-1)
|
61 |
+
return mask[None, None, :, :].expand(bsz, 1, tgt_len, tgt_len + past_key_values_length)
|
62 |
+
|
63 |
+
|
64 |
+
# Copied from transformers.models.bart.modeling_bart._expand_mask
|
65 |
+
def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
|
66 |
+
"""
|
67 |
+
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
68 |
+
"""
|
69 |
+
bsz, src_len = mask.size()
|
70 |
+
tgt_len = tgt_len if tgt_len is not None else src_len
|
71 |
+
|
72 |
+
expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len, src_len).to(dtype)
|
73 |
+
|
74 |
+
inverted_mask = 1.0 - expanded_mask
|
75 |
+
|
76 |
+
return inverted_mask.masked_fill(inverted_mask.to(torch.bool), torch.finfo(dtype).min)
|
77 |
+
|
78 |
+
|
79 |
+
def apply_rotary_embedding(q, k, cos, sin, decode=False, rotary_index=None):
|
80 |
+
# q: (bs, q_len, num_heads, head_dim)
|
81 |
+
# k: (bs, q_len [+past_kv_len], num_heads, head_dim)
|
82 |
+
# cos: (max_seq_len, head_dim)
|
83 |
+
# sin: (max_seq_len, head_dim)
|
84 |
+
# rotary_index: (bs, 1) # only used during decoding, when one query token is input at a time
|
85 |
+
"""Helper function to apply Rotary Embeddings."""
|
86 |
+
cos = cos.to(q.dtype)
|
87 |
+
sin = sin.to(q.dtype)
|
88 |
+
|
89 |
+
if len(k.shape) == 3: # for multi query attention
|
90 |
+
k = k.unsqueeze(2)
|
91 |
+
multiquery = True
|
92 |
+
else:
|
93 |
+
multiquery = False
|
94 |
+
|
95 |
+
batch, qlen, qheads, d = q.shape
|
96 |
+
kbatch, klen, kheads, kd = k.shape
|
97 |
+
assert batch == kbatch, f"{batch} != {kbatch}"
|
98 |
+
assert d == kd, f"{d} != {kd}"
|
99 |
+
if decode and qlen == 1 and rotary_index is not None:
|
100 |
+
qcos = cos[rotary_index, :] # (bs, 1, head_dim)
|
101 |
+
qsin = sin[rotary_index, :] # (bs, 1, head_dim)
|
102 |
+
qcos = qcos.unsqueeze(2) # (bs, q_len=1, 1, head_dim) # broadcast to all heads
|
103 |
+
qsin = qsin.unsqueeze(2) # (bs, q_len=1, 1, head_dim)
|
104 |
+
else:
|
105 |
+
qcos, qsin = cos[:qlen, :], sin[:qlen, :] # (q_len, head_dim)
|
106 |
+
qcos = qcos.unsqueeze(0).unsqueeze(2) # (1, q_len, 1, head_dim)
|
107 |
+
qsin = qsin.unsqueeze(0).unsqueeze(2)
|
108 |
+
|
109 |
+
kcos, ksin = cos[:klen, :], sin[:klen, :] # (k_len, head_dim)
|
110 |
+
kcos = kcos.unsqueeze(0).unsqueeze(
|
111 |
+
2) # (1, k_len, 1, head_dim) # broadcast to the whole batch, broadcast to all heads
|
112 |
+
ksin = ksin.unsqueeze(0).unsqueeze(2) # (1, k_len, 1, head_dim)
|
113 |
+
out_q = (q * qcos) + (rotate_half(q) * qsin)
|
114 |
+
out_k = (k * kcos) + (rotate_half(k) * ksin)
|
115 |
+
|
116 |
+
if multiquery:
|
117 |
+
out_k = out_k.squeeze(2)
|
118 |
+
|
119 |
+
return out_q, out_k
|
120 |
+
|
121 |
+
|
122 |
+
def rotate_half(x):
|
123 |
+
"""Rotates half the hidden dims of the input."""
|
124 |
+
x1 = x[..., : x.shape[-1] // 2]
|
125 |
+
x2 = x[..., x.shape[-1] // 2:]
|
126 |
+
return torch.cat((-x2, x1), dim=-1)
|
127 |
+
|
128 |
+
|
129 |
+
class LlamaRMSNorm(nn.Module):
|
130 |
+
def __init__(self, hidden_size, eps=1e-6):
|
131 |
+
"""
|
132 |
+
LlamaRMSNorm is equivalent to T5LayerNorm
|
133 |
+
"""
|
134 |
+
super().__init__()
|
135 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
136 |
+
self.variance_epsilon = eps
|
137 |
+
|
138 |
+
def forward(self, hidden_states):
|
139 |
+
input_dtype = hidden_states.dtype
|
140 |
+
hidden_states = hidden_states.to(torch.float32)
|
141 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
142 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
143 |
+
return self.weight * hidden_states.to(input_dtype)
|
144 |
+
|
145 |
+
|
146 |
+
def swiglu_act_fn(x):
|
147 |
+
"""Gated linear unit activation function.
|
148 |
+
Args:
|
149 |
+
x : input array
|
150 |
+
axis: the axis along which the split should be computed (default: -1)
|
151 |
+
"""
|
152 |
+
size = x.shape[-1]
|
153 |
+
assert size % 2 == 0, "axis size must be divisible by 2"
|
154 |
+
x1, x2 = torch.split(x, size // 2, -1)
|
155 |
+
return x1 * (x2 * torch.sigmoid(x2))
|
156 |
+
|
157 |
+
|
158 |
+
class HFOpenMoeMLP(torch.nn.Module):
|
159 |
+
def __init__(self, config: HFOpenMoeConfig):
|
160 |
+
super().__init__()
|
161 |
+
assert config.hidden_act == "swiglu"
|
162 |
+
self.ffn_dim = config.intermediate_size
|
163 |
+
self.hidden_dim = config.hidden_size
|
164 |
+
|
165 |
+
self.gate_proj = nn.Linear(self.hidden_dim, self.ffn_dim * 2, bias=False)
|
166 |
+
self.up_proj = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False)
|
167 |
+
self.down_proj = nn.Linear(self.ffn_dim, self.hidden_dim, bias=False)
|
168 |
+
|
169 |
+
def forward(self, hidden_states):
|
170 |
+
return self.down_proj(swiglu_act_fn(self.gate_proj(hidden_states)) * self.up_proj(hidden_states))
|
171 |
+
|
172 |
+
|
173 |
+
def moe_cumsum(inputs: torch.Tensor):
|
174 |
+
return torch.cumsum(inputs, dim=0) - 1
|
175 |
+
|
176 |
+
|
177 |
+
class HFOpenMoeTop2Router(torch.nn.Module):
|
178 |
+
def __init__(self, config: HFOpenMoeConfig):
|
179 |
+
super().__init__()
|
180 |
+
assert config.router_topk == 2
|
181 |
+
self.k_value = 2
|
182 |
+
self.capacity_factor_train = config.router_capacity_factor_train
|
183 |
+
self.capacity_factor_eval = config.router_capacity_factor_eval
|
184 |
+
self.min_capacity = config.router_min_capacity
|
185 |
+
self.drop_tks = config.router_drop_tks
|
186 |
+
|
187 |
+
def get_capacity(self, logits_shape):
|
188 |
+
capacity_factor = self.capacity_factor_train if self.training else self.capacity_factor_eval
|
189 |
+
capacity = math.floor(self.k_value * capacity_factor * logits_shape[-2] / logits_shape[-1])
|
190 |
+
capacity += capacity % 2
|
191 |
+
capacity = max(capacity, self.min_capacity)
|
192 |
+
assert capacity > 0
|
193 |
+
return int(capacity)
|
194 |
+
|
195 |
+
def forward(self, inputs: torch.Tensor) -> Tuple:
|
196 |
+
assert inputs.dtype == torch.float, "Router input should be FP32"
|
197 |
+
|
198 |
+
probs = F.softmax(inputs, dim=-1)
|
199 |
+
num_experts = probs.size(-1)
|
200 |
+
capacity = self.get_capacity(inputs.shape)
|
201 |
+
|
202 |
+
top1_idx = torch.argmax(probs, dim=-1)
|
203 |
+
mask1 = F.one_hot(top1_idx, num_classes=num_experts).to(torch.int32)
|
204 |
+
logits_except1 = probs.masked_fill(mask1.bool(), float("-inf"))
|
205 |
+
top2_idx = torch.argmax(logits_except1, dim=-1)
|
206 |
+
mask2 = F.one_hot(top2_idx, num_classes=num_experts).to(torch.int32)
|
207 |
+
|
208 |
+
rank1 = moe_cumsum(mask1) # rank1: [s, e]
|
209 |
+
rank2 = moe_cumsum(mask2)
|
210 |
+
rank2 += torch.sum(mask1, dim=-2, keepdim=True)
|
211 |
+
|
212 |
+
mask1 *= torch.lt(rank1, capacity)
|
213 |
+
mask2 *= torch.lt(rank2, capacity)
|
214 |
+
used_capacity = mask1.sum(dim=0) + mask2.sum(dim=0)
|
215 |
+
|
216 |
+
rank1 = torch.sum(mask1 * rank1, dim=-1)
|
217 |
+
rank2 = torch.sum(mask2 * rank2, dim=-1)
|
218 |
+
|
219 |
+
weight1 = mask1 * probs.type_as(inputs)
|
220 |
+
weight2 = mask2 * probs.type_as(inputs)
|
221 |
+
|
222 |
+
cb_weight = torch.zeros(inputs.shape + (capacity,), device=inputs.device)
|
223 |
+
sec_mask = torch.zeros_like(cb_weight, dtype=torch.bool)
|
224 |
+
indices = torch.arange(0, inputs.shape[0], device=inputs.device)
|
225 |
+
cb_weight[indices, top1_idx[indices], rank1[indices]] += weight1[indices, top1_idx[indices]]
|
226 |
+
cb_weight[indices, top2_idx[indices], rank2[indices]] += weight2[indices, top2_idx[indices]]
|
227 |
+
sec_mask[indices, top1_idx[indices], rank1[indices]] |= mask1.bool()[indices, top1_idx[indices]]
|
228 |
+
sec_mask[indices, top2_idx[indices], rank2[indices]] |= mask2.bool()[indices, top2_idx[indices]]
|
229 |
+
|
230 |
+
return used_capacity, cb_weight, sec_mask
|
231 |
+
|
232 |
+
|
233 |
+
class HFOpenMoeSparseMLP(torch.nn.Module):
|
234 |
+
def __init__(self, config: HFOpenMoeConfig):
|
235 |
+
super().__init__()
|
236 |
+
self.hidden_size = config.hidden_size
|
237 |
+
self.intermediate_size = config.intermediate_size
|
238 |
+
self.num_experts = config.num_experts
|
239 |
+
|
240 |
+
self.gate = torch.nn.Linear(self.hidden_size, config.num_experts, bias=False)
|
241 |
+
|
242 |
+
self.experts = nn.ModuleList([HFOpenMoeMLP(config) for _ in range(self.num_experts)])
|
243 |
+
self.router = HFOpenMoeTop2Router(config)
|
244 |
+
|
245 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
246 |
+
# reshape the input tokens
|
247 |
+
tokens = hidden_states.reshape(-1, self.hidden_size)
|
248 |
+
inputs = hidden_states
|
249 |
+
|
250 |
+
# the data type of the inputs in the gating should be fp32
|
251 |
+
fp32_input = tokens.to(torch.float)
|
252 |
+
self.gate = self.gate.to(torch.float)
|
253 |
+
gate_output = self.gate(fp32_input)
|
254 |
+
|
255 |
+
used_capacity, *route_result_list = self.router(inputs=gate_output)
|
256 |
+
|
257 |
+
sec_mask_f = route_result_list[1].type_as(inputs)
|
258 |
+
dispatch_data = torch.matmul(sec_mask_f.permute(1, 2, 0), tokens)
|
259 |
+
|
260 |
+
expert_output = self._local_process(dispatch_data)
|
261 |
+
|
262 |
+
combine_weights = route_result_list[0].type_as(inputs)
|
263 |
+
combine_weights = combine_weights.view(combine_weights.shape[0], -1)
|
264 |
+
expert_output = expert_output.view(-1, expert_output.shape[-1])
|
265 |
+
ans = torch.matmul(combine_weights, expert_output)
|
266 |
+
|
267 |
+
ans = ans.reshape(inputs.shape)
|
268 |
+
return ans
|
269 |
+
|
270 |
+
def _local_process(self, expert_in: torch.Tensor) -> torch.Tensor:
|
271 |
+
expert_in = expert_in.unsqueeze(0)
|
272 |
+
x = expert_in
|
273 |
+
|
274 |
+
# Copied from colossalai MLPExperts class
|
275 |
+
e = x.size(1)
|
276 |
+
h = x.size(-1)
|
277 |
+
|
278 |
+
x = x.transpose(0, 1)
|
279 |
+
inshape = x.shape
|
280 |
+
x = x.reshape(e, -1, h)
|
281 |
+
|
282 |
+
x = [self.experts[i](x[i]) for i in range(e)]
|
283 |
+
|
284 |
+
x = torch.cat([x[i].unsqueeze(0) for i in range(e)], dim=0)
|
285 |
+
x = x.reshape(inshape)
|
286 |
+
x = x.transpose(0, 1).contiguous()
|
287 |
+
|
288 |
+
expert_out = x
|
289 |
+
return expert_out
|
290 |
+
|
291 |
+
|
292 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
293 |
+
"""
|
294 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
295 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
296 |
+
"""
|
297 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
298 |
+
if n_rep == 1:
|
299 |
+
return hidden_states
|
300 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
301 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
302 |
+
|
303 |
+
|
304 |
+
class HFOpenMoeAttention(nn.Module):
|
305 |
+
"""Multi-headed attention from 'Attention Is All You Need' paper"""
|
306 |
+
|
307 |
+
def __init__(self, config: HFOpenMoeConfig):
|
308 |
+
super().__init__()
|
309 |
+
self.config = config
|
310 |
+
self.hidden_size = config.hidden_size
|
311 |
+
self.num_heads = config.num_attention_heads
|
312 |
+
self.head_dim = config.head_dim
|
313 |
+
self.num_key_value_heads = config.num_key_value_heads
|
314 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
315 |
+
self.pretraining_tp = config.pretraining_tp
|
316 |
+
self.max_position_embeddings = config.max_position_embeddings
|
317 |
+
|
318 |
+
self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=False)
|
319 |
+
self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=False)
|
320 |
+
self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=False)
|
321 |
+
self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
|
322 |
+
self.generate_fixed_pos_embedding(self.head_dim, self.max_position_embeddings, 1.0, 1e4)
|
323 |
+
self.use_kernel = config.enable_kernel
|
324 |
+
|
325 |
+
def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
|
326 |
+
return tensor.view(bsz, seq_len, self.num_heads, self.head_dim).transpose(1, 2).contiguous()
|
327 |
+
|
328 |
+
def generate_fixed_pos_embedding(self, features, length, min_timescale=1.0, max_timescale=10000.0):
|
329 |
+
"""Generate Sin/Cos for Rotary Embeddings.
|
330 |
+
|
331 |
+
Args:
|
332 |
+
features: an integer
|
333 |
+
length: an integer
|
334 |
+
min_timescale: an optional float
|
335 |
+
max_timescale: an optional float
|
336 |
+
|
337 |
+
Returns:
|
338 |
+
output_sin: a float32 Tensor with shape [length, features]
|
339 |
+
output_cos: a float32 Tensor with shape [length, features]
|
340 |
+
"""
|
341 |
+
fraction = torch.arange(0, features, 2, dtype=torch.float32) / features
|
342 |
+
timescale = min_timescale * (max_timescale / min_timescale) ** fraction
|
343 |
+
rotational_frequency = 1.0 / timescale
|
344 |
+
|
345 |
+
sinusoid_inp = torch.einsum("i,j->ij", torch.arange(length, dtype=torch.float32), rotational_frequency)
|
346 |
+
|
347 |
+
sinusoid_inp = torch.cat([sinusoid_inp, sinusoid_inp], dim=-1)
|
348 |
+
|
349 |
+
self.register_buffer('sin', torch.sin(sinusoid_inp),
|
350 |
+
persistent=False) # persistent=False --> buffer won't appear in the state_dict
|
351 |
+
self.register_buffer('cos', torch.cos(sinusoid_inp), persistent=False)
|
352 |
+
|
353 |
+
def forward(
|
354 |
+
self,
|
355 |
+
hidden_states: torch.Tensor,
|
356 |
+
attention_mask: Optional[torch.Tensor] = None,
|
357 |
+
position_ids: Optional[torch.LongTensor] = None,
|
358 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
359 |
+
output_attentions: bool = False,
|
360 |
+
use_cache: bool = False,
|
361 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
362 |
+
bsz, q_len, _ = hidden_states.size()
|
363 |
+
|
364 |
+
if self.pretraining_tp > 1:
|
365 |
+
key_value_slicing = (self.num_key_value_heads * self.head_dim) // self.pretraining_tp
|
366 |
+
query_slices = self.q_proj.weight.split((self.num_heads * self.head_dim) // self.pretraining_tp, dim=0)
|
367 |
+
key_slices = self.k_proj.weight.split(key_value_slicing, dim=0)
|
368 |
+
value_slices = self.v_proj.weight.split(key_value_slicing, dim=0)
|
369 |
+
|
370 |
+
query_states = [F.linear(hidden_states, query_slices[i]) for i in range(self.pretraining_tp)]
|
371 |
+
query_states = torch.cat(query_states, dim=-1)
|
372 |
+
|
373 |
+
key_states = [F.linear(hidden_states, key_slices[i]) for i in range(self.pretraining_tp)]
|
374 |
+
key_states = torch.cat(key_states, dim=-1)
|
375 |
+
|
376 |
+
value_states = [F.linear(hidden_states, value_slices[i]) for i in range(self.pretraining_tp)]
|
377 |
+
value_states = torch.cat(value_states, dim=-1)
|
378 |
+
|
379 |
+
else:
|
380 |
+
query_states = self.q_proj(hidden_states)
|
381 |
+
key_states = self.k_proj(hidden_states)
|
382 |
+
value_states = self.v_proj(hidden_states)
|
383 |
+
|
384 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
385 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
386 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
387 |
+
|
388 |
+
kv_seq_len = key_states.shape[-2]
|
389 |
+
if past_key_value is not None:
|
390 |
+
kv_seq_len += past_key_value[0].shape[-2]
|
391 |
+
# cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
392 |
+
# query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
393 |
+
if past_key_value is not None:
|
394 |
+
# reuse k, v, self_attention
|
395 |
+
key_states = torch.cat([past_key_value[0], key_states], dim=2)
|
396 |
+
value_states = torch.cat([past_key_value[1], value_states], dim=2)
|
397 |
+
|
398 |
+
past_key_value = (key_states, value_states) if use_cache else None
|
399 |
+
|
400 |
+
query_states = query_states.transpose(1, 2)
|
401 |
+
key_states = key_states.transpose(1, 2)
|
402 |
+
max_length = max(query_states.shape[1], key_states.shape[1])
|
403 |
+
assert max_length <= self.sin.shape[0]
|
404 |
+
sin, cos = self.sin[:max_length], self.cos[:max_length]
|
405 |
+
# TODO: for inference, we can add emb kv into cache to avoid computation
|
406 |
+
query_states, key_states = apply_rotary_embedding(
|
407 |
+
query_states, key_states, cos, sin, decode=True if q_len == 1 else False, rotary_index=position_ids
|
408 |
+
)
|
409 |
+
query_states = query_states.transpose(1, 2)
|
410 |
+
key_states = key_states.transpose(1, 2)
|
411 |
+
|
412 |
+
# repeat k/v heads if n_kv_heads < n_heads
|
413 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
414 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
415 |
+
|
416 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(2, 3))
|
417 |
+
|
418 |
+
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
|
419 |
+
raise ValueError(
|
420 |
+
f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
|
421 |
+
f" {attn_weights.size()}"
|
422 |
+
)
|
423 |
+
|
424 |
+
if attention_mask is not None:
|
425 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
426 |
+
raise ValueError(
|
427 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
428 |
+
)
|
429 |
+
if self.training:
|
430 |
+
attention_mask = attention_mask.clone().detach()
|
431 |
+
attention_mask[:, :, :, 0] = 0
|
432 |
+
attn_weights = attn_weights + attention_mask
|
433 |
+
|
434 |
+
# upcast attention to fp32
|
435 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
436 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
437 |
+
|
438 |
+
if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
|
439 |
+
raise ValueError(
|
440 |
+
f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
|
441 |
+
f" {attn_output.size()}"
|
442 |
+
)
|
443 |
+
|
444 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
445 |
+
attn_output = attn_output.reshape(bsz, q_len, self.num_heads * self.head_dim)
|
446 |
+
|
447 |
+
if self.pretraining_tp > 1:
|
448 |
+
attn_output = attn_output.split(self.hidden_size // self.pretraining_tp, dim=2)
|
449 |
+
o_proj_slices = self.o_proj.weight.split(self.hidden_size // self.pretraining_tp, dim=1)
|
450 |
+
attn_output = sum([F.linear(attn_output[i], o_proj_slices[i]) for i in range(self.pretraining_tp)])
|
451 |
+
else:
|
452 |
+
attn_output = self.o_proj(attn_output)
|
453 |
+
|
454 |
+
if not output_attentions:
|
455 |
+
attn_weights = None
|
456 |
+
|
457 |
+
return attn_output, attn_weights, past_key_value
|
458 |
+
|
459 |
+
|
460 |
+
class HFOpenMoeDecoderLayer(nn.Module):
|
461 |
+
def __init__(self, config: HFOpenMoeConfig, moe: bool):
|
462 |
+
super().__init__()
|
463 |
+
self.hidden_size = config.hidden_size
|
464 |
+
self.moe = moe
|
465 |
+
self.self_attn = HFOpenMoeAttention(config=config)
|
466 |
+
# self.self_attn = LlamaAttention(config=config) # TODO: introduce LLaMA Positional Encoding
|
467 |
+
self.input_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
468 |
+
self.post_attention_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
469 |
+
if self.moe:
|
470 |
+
self.mlp = HFOpenMoeSparseMLP(config)
|
471 |
+
self.pre_extra_mlp_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
472 |
+
self.extra_mlp = HFOpenMoeMLP(config)
|
473 |
+
else:
|
474 |
+
self.mlp = HFOpenMoeMLP(config)
|
475 |
+
|
476 |
+
def forward(
|
477 |
+
self,
|
478 |
+
hidden_states: torch.Tensor,
|
479 |
+
attention_mask: Optional[torch.Tensor] = None,
|
480 |
+
position_ids: Optional[torch.LongTensor] = None,
|
481 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
482 |
+
output_attentions: Optional[bool] = False,
|
483 |
+
use_cache: Optional[bool] = False,
|
484 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
485 |
+
"""
|
486 |
+
Args:
|
487 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
488 |
+
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
|
489 |
+
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
|
490 |
+
output_attentions (`bool`, *optional*):
|
491 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under
|
492 |
+
returned tensors for more detail.
|
493 |
+
use_cache (`bool`, *optional*):
|
494 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
495 |
+
(see `past_key_values`).
|
496 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
|
497 |
+
"""
|
498 |
+
|
499 |
+
residual = hidden_states
|
500 |
+
|
501 |
+
hidden_states = self.input_layernorm(hidden_states)
|
502 |
+
|
503 |
+
# Self Attention
|
504 |
+
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
505 |
+
hidden_states=hidden_states,
|
506 |
+
attention_mask=attention_mask,
|
507 |
+
position_ids=position_ids,
|
508 |
+
past_key_value=past_key_value,
|
509 |
+
output_attentions=output_attentions,
|
510 |
+
use_cache=use_cache,
|
511 |
+
)
|
512 |
+
hidden_states = residual + hidden_states
|
513 |
+
|
514 |
+
# Fully Connected
|
515 |
+
residual = hidden_states
|
516 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
517 |
+
hidden_states = self.mlp(hidden_states)
|
518 |
+
hidden_states = residual + hidden_states
|
519 |
+
|
520 |
+
if self.moe:
|
521 |
+
residual = hidden_states
|
522 |
+
hidden_states = self.pre_extra_mlp_layernorm(hidden_states)
|
523 |
+
hidden_states = self.extra_mlp(hidden_states)
|
524 |
+
hidden_states = residual + hidden_states
|
525 |
+
|
526 |
+
outputs = (hidden_states,)
|
527 |
+
|
528 |
+
if output_attentions:
|
529 |
+
outputs += (self_attn_weights,)
|
530 |
+
|
531 |
+
if use_cache:
|
532 |
+
outputs += (present_key_value,)
|
533 |
+
|
534 |
+
return outputs
|
535 |
+
|
536 |
+
|
537 |
+
LLAMA_START_DOCSTRING = r"""
|
538 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
539 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
540 |
+
etc.)
|
541 |
+
|
542 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
543 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
544 |
+
and behavior.
|
545 |
+
|
546 |
+
Parameters:
|
547 |
+
config ([`HFOpenMoeConfig`]):
|
548 |
+
Model configuration class with all the parameters of the model. Initializing with a config file does not
|
549 |
+
load the weights associated with the model, only the configuration. Check out the
|
550 |
+
[`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
551 |
+
"""
|
552 |
+
|
553 |
+
|
554 |
+
@add_start_docstrings(
|
555 |
+
"The bare LLaMA Model outputting raw hidden-states without any specific head on top.",
|
556 |
+
LLAMA_START_DOCSTRING,
|
557 |
+
)
|
558 |
+
class HFOpenMoePreTrainedModel(PreTrainedModel):
|
559 |
+
config_class = HFOpenMoeConfig
|
560 |
+
base_model_prefix = "model"
|
561 |
+
supports_gradient_checkpointing = True
|
562 |
+
_no_split_modules = ["HFOpenMoeDecoderLayer"]
|
563 |
+
_skip_keys_device_placement = "past_key_values"
|
564 |
+
|
565 |
+
def _init_weights(self, module):
|
566 |
+
std = self.config.initializer_range
|
567 |
+
if isinstance(module, nn.Linear):
|
568 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
569 |
+
if module.bias is not None:
|
570 |
+
module.bias.data.zero_()
|
571 |
+
elif isinstance(module, nn.Embedding):
|
572 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
573 |
+
if module.padding_idx is not None:
|
574 |
+
module.weight.data[module.padding_idx].zero_()
|
575 |
+
|
576 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
577 |
+
if isinstance(module, HFOpenMoeModel):
|
578 |
+
module.gradient_checkpointing = value
|
579 |
+
|
580 |
+
|
581 |
+
LLAMA_INPUTS_DOCSTRING = r"""
|
582 |
+
Args:
|
583 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
584 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
585 |
+
it.
|
586 |
+
|
587 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
588 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
589 |
+
|
590 |
+
[What are input IDs?](../glossary#input-ids)
|
591 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
592 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
593 |
+
|
594 |
+
- 1 for tokens that are **not masked**,
|
595 |
+
- 0 for tokens that are **masked**.
|
596 |
+
|
597 |
+
[What are attention masks?](../glossary#attention-mask)
|
598 |
+
|
599 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
600 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
601 |
+
|
602 |
+
If `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
|
603 |
+
`past_key_values`).
|
604 |
+
|
605 |
+
If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
|
606 |
+
and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
|
607 |
+
information on the default strategy.
|
608 |
+
|
609 |
+
- 1 indicates the head is **not masked**,
|
610 |
+
- 0 indicates the head is **masked**.
|
611 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
612 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
613 |
+
config.n_positions - 1]`.
|
614 |
+
|
615 |
+
[What are position IDs?](../glossary#position-ids)
|
616 |
+
past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
617 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
618 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
|
619 |
+
`(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`.
|
620 |
+
|
621 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
|
622 |
+
blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.
|
623 |
+
|
624 |
+
If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
|
625 |
+
don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
|
626 |
+
`decoder_input_ids` of shape `(batch_size, sequence_length)`.
|
627 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
628 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
629 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
630 |
+
model's internal embedding lookup matrix.
|
631 |
+
use_cache (`bool`, *optional*):
|
632 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
633 |
+
`past_key_values`).
|
634 |
+
output_attentions (`bool`, *optional*):
|
635 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
636 |
+
tensors for more detail.
|
637 |
+
output_hidden_states (`bool`, *optional*):
|
638 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
639 |
+
more detail.
|
640 |
+
return_dict (`bool`, *optional*):
|
641 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
642 |
+
"""
|
643 |
+
|
644 |
+
|
645 |
+
@add_start_docstrings(
|
646 |
+
"The bare LLaMA Model outputting raw hidden-states without any specific head on top.",
|
647 |
+
LLAMA_START_DOCSTRING,
|
648 |
+
)
|
649 |
+
class HFOpenMoeModel(HFOpenMoePreTrainedModel):
|
650 |
+
"""
|
651 |
+
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`LlamaDecoderLayer`]
|
652 |
+
|
653 |
+
Args:
|
654 |
+
config: HFOpenMoeConfig
|
655 |
+
"""
|
656 |
+
|
657 |
+
def __init__(self, config: HFOpenMoeConfig):
|
658 |
+
super().__init__(config)
|
659 |
+
self.padding_idx = config.pad_token_id
|
660 |
+
self.vocab_size = config.vocab_size
|
661 |
+
|
662 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
663 |
+
self.layers = nn.ModuleList(
|
664 |
+
[
|
665 |
+
HFOpenMoeDecoderLayer(config, moe=True if (i + 1) % config.moe_layer_interval == 0 else False)
|
666 |
+
for i in range(config.num_hidden_layers)
|
667 |
+
]
|
668 |
+
)
|
669 |
+
self.norm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
670 |
+
|
671 |
+
self.gradient_checkpointing = False
|
672 |
+
# Initialize weights and apply final processing
|
673 |
+
self.post_init()
|
674 |
+
|
675 |
+
def get_input_embeddings(self):
|
676 |
+
return self.embed_tokens
|
677 |
+
|
678 |
+
def set_input_embeddings(self, value):
|
679 |
+
self.embed_tokens = value
|
680 |
+
|
681 |
+
# Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
|
682 |
+
def _prepare_decoder_attention_mask(self, attention_mask, input_shape, inputs_embeds, past_key_values_length):
|
683 |
+
# create causal mask
|
684 |
+
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
|
685 |
+
combined_attention_mask = None
|
686 |
+
if input_shape[-1] > 1:
|
687 |
+
combined_attention_mask = _make_causal_mask(
|
688 |
+
input_shape,
|
689 |
+
inputs_embeds.dtype,
|
690 |
+
device=inputs_embeds.device,
|
691 |
+
past_key_values_length=past_key_values_length,
|
692 |
+
)
|
693 |
+
|
694 |
+
if attention_mask is not None:
|
695 |
+
# [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
|
696 |
+
expanded_attn_mask = _expand_mask(attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]).to(
|
697 |
+
inputs_embeds.device
|
698 |
+
)
|
699 |
+
combined_attention_mask = (
|
700 |
+
expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask + combined_attention_mask
|
701 |
+
)
|
702 |
+
|
703 |
+
return combined_attention_mask
|
704 |
+
|
705 |
+
@add_start_docstrings_to_model_forward(LLAMA_INPUTS_DOCSTRING)
|
706 |
+
def forward(
|
707 |
+
self,
|
708 |
+
input_ids: torch.LongTensor = None,
|
709 |
+
attention_mask: Optional[torch.Tensor] = None,
|
710 |
+
position_ids: Optional[torch.LongTensor] = None,
|
711 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
712 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
713 |
+
use_cache: Optional[bool] = None,
|
714 |
+
output_attentions: Optional[bool] = None,
|
715 |
+
output_hidden_states: Optional[bool] = None,
|
716 |
+
return_dict: Optional[bool] = None,
|
717 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
718 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
719 |
+
output_hidden_states = (
|
720 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
721 |
+
)
|
722 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
723 |
+
|
724 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
725 |
+
|
726 |
+
# retrieve input_ids and inputs_embeds
|
727 |
+
if input_ids is not None and inputs_embeds is not None:
|
728 |
+
raise ValueError("You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time")
|
729 |
+
elif input_ids is not None:
|
730 |
+
batch_size, seq_length = input_ids.shape
|
731 |
+
elif inputs_embeds is not None:
|
732 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
733 |
+
else:
|
734 |
+
raise ValueError("You have to specify either decoder_input_ids or decoder_inputs_embeds")
|
735 |
+
|
736 |
+
seq_length_with_past = seq_length
|
737 |
+
past_key_values_length = 0
|
738 |
+
|
739 |
+
if past_key_values is not None:
|
740 |
+
past_key_values_length = past_key_values[0][0].shape[2]
|
741 |
+
seq_length_with_past = seq_length_with_past + past_key_values_length
|
742 |
+
|
743 |
+
if position_ids is None:
|
744 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
745 |
+
position_ids = torch.arange(
|
746 |
+
past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
|
747 |
+
)
|
748 |
+
position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
|
749 |
+
else:
|
750 |
+
position_ids = position_ids.view(-1, seq_length).long()
|
751 |
+
|
752 |
+
if inputs_embeds is None:
|
753 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
754 |
+
# embed positions
|
755 |
+
if attention_mask is None:
|
756 |
+
attention_mask = torch.ones(
|
757 |
+
(batch_size, seq_length_with_past), dtype=torch.bool, device=inputs_embeds.device
|
758 |
+
)
|
759 |
+
attention_mask = self._prepare_decoder_attention_mask(
|
760 |
+
attention_mask, (batch_size, seq_length), inputs_embeds, past_key_values_length
|
761 |
+
)
|
762 |
+
|
763 |
+
hidden_states = inputs_embeds
|
764 |
+
|
765 |
+
if self.gradient_checkpointing and self.training:
|
766 |
+
if use_cache:
|
767 |
+
logger.warning_once(
|
768 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
769 |
+
)
|
770 |
+
use_cache = False
|
771 |
+
|
772 |
+
# decoder layers
|
773 |
+
all_hidden_states = () if output_hidden_states else None
|
774 |
+
all_self_attns = () if output_attentions else None
|
775 |
+
next_decoder_cache = () if use_cache else None
|
776 |
+
|
777 |
+
for idx, decoder_layer in enumerate(self.layers):
|
778 |
+
if output_hidden_states:
|
779 |
+
all_hidden_states += (hidden_states,)
|
780 |
+
|
781 |
+
past_key_value = past_key_values[idx] if past_key_values is not None else None
|
782 |
+
|
783 |
+
if self.gradient_checkpointing and self.training:
|
784 |
+
|
785 |
+
def create_custom_forward(module):
|
786 |
+
def custom_forward(*inputs):
|
787 |
+
# None for past_key_value
|
788 |
+
return module(*inputs, output_attentions, None)
|
789 |
+
|
790 |
+
return custom_forward
|
791 |
+
|
792 |
+
layer_outputs = torch.utils.checkpoint.checkpoint(
|
793 |
+
create_custom_forward(decoder_layer),
|
794 |
+
hidden_states,
|
795 |
+
attention_mask,
|
796 |
+
position_ids,
|
797 |
+
None,
|
798 |
+
)
|
799 |
+
else:
|
800 |
+
layer_outputs = decoder_layer(
|
801 |
+
hidden_states,
|
802 |
+
attention_mask=attention_mask,
|
803 |
+
position_ids=position_ids,
|
804 |
+
past_key_value=past_key_value,
|
805 |
+
output_attentions=output_attentions,
|
806 |
+
use_cache=use_cache,
|
807 |
+
)
|
808 |
+
|
809 |
+
hidden_states = layer_outputs[0]
|
810 |
+
|
811 |
+
if use_cache:
|
812 |
+
next_decoder_cache += (layer_outputs[2 if output_attentions else 1],)
|
813 |
+
|
814 |
+
if output_attentions:
|
815 |
+
all_self_attns += (layer_outputs[1],)
|
816 |
+
|
817 |
+
hidden_states = self.norm(hidden_states)
|
818 |
+
|
819 |
+
# add hidden states from the last decoder layer
|
820 |
+
if output_hidden_states:
|
821 |
+
all_hidden_states += (hidden_states,)
|
822 |
+
|
823 |
+
next_cache = next_decoder_cache if use_cache else None
|
824 |
+
if not return_dict:
|
825 |
+
return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
|
826 |
+
return BaseModelOutputWithPast(
|
827 |
+
last_hidden_state=hidden_states,
|
828 |
+
past_key_values=next_cache,
|
829 |
+
hidden_states=all_hidden_states,
|
830 |
+
attentions=all_self_attns,
|
831 |
+
)
|
832 |
+
|
833 |
+
|
834 |
+
class HFOpenMoeForCausalLM(HFOpenMoePreTrainedModel):
|
835 |
+
# _tied_weights_keys = ["lm_head.weight"]
|
836 |
+
|
837 |
+
def __init__(self, config):
|
838 |
+
super().__init__(config)
|
839 |
+
self.model = HFOpenMoeModel(config)
|
840 |
+
self.pretraining_tp = config.pretraining_tp
|
841 |
+
self.vocab_size = config.vocab_size
|
842 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
843 |
+
|
844 |
+
# Initialize weights and apply final processing
|
845 |
+
self.post_init()
|
846 |
+
|
847 |
+
def get_input_embeddings(self):
|
848 |
+
return self.model.embed_tokens
|
849 |
+
|
850 |
+
def set_input_embeddings(self, value):
|
851 |
+
self.model.embed_tokens = value
|
852 |
+
|
853 |
+
def get_output_embeddings(self):
|
854 |
+
return self.lm_head
|
855 |
+
|
856 |
+
def set_output_embeddings(self, new_embeddings):
|
857 |
+
self.lm_head = new_embeddings
|
858 |
+
|
859 |
+
def set_decoder(self, decoder):
|
860 |
+
self.model = decoder
|
861 |
+
|
862 |
+
def get_decoder(self):
|
863 |
+
return self.model
|
864 |
+
|
865 |
+
@add_start_docstrings_to_model_forward(LLAMA_INPUTS_DOCSTRING)
|
866 |
+
@replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
|
867 |
+
def forward(
|
868 |
+
self,
|
869 |
+
input_ids: torch.LongTensor = None,
|
870 |
+
attention_mask: Optional[torch.Tensor] = None,
|
871 |
+
position_ids: Optional[torch.LongTensor] = None,
|
872 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
873 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
874 |
+
labels: Optional[torch.LongTensor] = None,
|
875 |
+
use_cache: Optional[bool] = None,
|
876 |
+
output_attentions: Optional[bool] = None,
|
877 |
+
output_hidden_states: Optional[bool] = None,
|
878 |
+
return_dict: Optional[bool] = None,
|
879 |
+
chunk_head: Optional[bool] = True,
|
880 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
881 |
+
r"""
|
882 |
+
Args:
|
883 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
884 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
885 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
886 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
887 |
+
|
888 |
+
Returns:
|
889 |
+
|
890 |
+
Example:
|
891 |
+
|
892 |
+
```python
|
893 |
+
>>> from transformers import AutoTokenizer, LlamaForCausalLM
|
894 |
+
|
895 |
+
>>> model = LlamaForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
|
896 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
|
897 |
+
|
898 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
899 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
900 |
+
|
901 |
+
>>> # Generate
|
902 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
903 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
904 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
905 |
+
```"""
|
906 |
+
# reset moe loss
|
907 |
+
|
908 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
909 |
+
output_hidden_states = (
|
910 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
911 |
+
)
|
912 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
913 |
+
|
914 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
915 |
+
outputs = self.model(
|
916 |
+
input_ids=input_ids,
|
917 |
+
attention_mask=attention_mask,
|
918 |
+
position_ids=position_ids,
|
919 |
+
past_key_values=past_key_values,
|
920 |
+
inputs_embeds=inputs_embeds,
|
921 |
+
use_cache=use_cache,
|
922 |
+
output_attentions=output_attentions,
|
923 |
+
output_hidden_states=output_hidden_states,
|
924 |
+
return_dict=return_dict,
|
925 |
+
)
|
926 |
+
|
927 |
+
hidden_states = outputs[0]
|
928 |
+
if self.pretraining_tp > 1:
|
929 |
+
lm_head_slices = self.lm_head.weight.split(self.vocab_size // self.pretraining_tp, dim=0)
|
930 |
+
logits = [F.linear(hidden_states, lm_head_slices[i]) for i in range(self.pretraining_tp)]
|
931 |
+
logits = torch.cat(logits, dim=-1)
|
932 |
+
|
933 |
+
loss = None
|
934 |
+
# if no training, just do forward
|
935 |
+
if labels is None:
|
936 |
+
logits = self.lm_head(hidden_states)
|
937 |
+
logits = logits.float()
|
938 |
+
# the vocab size for openmoe is 30w+
|
939 |
+
# which causes great activation memory in training, up to 20G for one sequence
|
940 |
+
# so we use chunk and checkpoint to reduce memory
|
941 |
+
else:
|
942 |
+
if chunk_head == True:
|
943 |
+
|
944 |
+
def create_custom_forward(module):
|
945 |
+
def custom_forward(*inputs):
|
946 |
+
logits = module(inputs[0])
|
947 |
+
logits = logits.float()
|
948 |
+
# Shift so that tokens < n predict n
|
949 |
+
shift_logits = logits[..., :-1, :].contiguous().float()
|
950 |
+
shift_labels = inputs[1][..., 1:].contiguous()
|
951 |
+
# Flatten the tokens
|
952 |
+
loss = self._calculate_loss(shift_logits, shift_labels)
|
953 |
+
return loss
|
954 |
+
|
955 |
+
return custom_forward
|
956 |
+
|
957 |
+
for batch_idx in range(hidden_states.shape[0]):
|
958 |
+
loss = loss + torch.utils.checkpoint.checkpoint(
|
959 |
+
create_custom_forward(self.lm_head),
|
960 |
+
hidden_states[batch_idx: batch_idx + 1, :],
|
961 |
+
labels[batch_idx: batch_idx + 1, :],
|
962 |
+
) if loss is not None else torch.utils.checkpoint.checkpoint(
|
963 |
+
create_custom_forward(self.lm_head),
|
964 |
+
hidden_states[batch_idx: batch_idx + 1, :],
|
965 |
+
labels[batch_idx: batch_idx + 1, :],
|
966 |
+
)
|
967 |
+
logits = None
|
968 |
+
else:
|
969 |
+
logits = self.lm_head(hidden_states)
|
970 |
+
logits = logits.float()
|
971 |
+
# Shift so that tokens < n predict n
|
972 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
973 |
+
shift_labels = labels[..., 1:].contiguous()
|
974 |
+
# Flatten the tokens
|
975 |
+
loss = self._calculate_loss(shift_logits, shift_labels)
|
976 |
+
|
977 |
+
if not return_dict:
|
978 |
+
output = (logits,) + outputs[1:]
|
979 |
+
return (loss,) + output if loss is not None else output
|
980 |
+
|
981 |
+
return CausalLMOutputWithPast(
|
982 |
+
loss=loss,
|
983 |
+
logits=logits,
|
984 |
+
past_key_values=outputs.past_key_values,
|
985 |
+
hidden_states=outputs.hidden_states,
|
986 |
+
attentions=outputs.attentions,
|
987 |
+
)
|
988 |
+
|
989 |
+
def prepare_inputs_for_generation(
|
990 |
+
self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
|
991 |
+
):
|
992 |
+
if past_key_values:
|
993 |
+
input_ids = input_ids[:, -1:]
|
994 |
+
|
995 |
+
position_ids = kwargs.get("position_ids", None)
|
996 |
+
if attention_mask is not None and position_ids is None:
|
997 |
+
# create position_ids on the fly for batch generation
|
998 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
999 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
1000 |
+
if past_key_values:
|
1001 |
+
position_ids = position_ids[:, -1].unsqueeze(-1)
|
1002 |
+
|
1003 |
+
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
|
1004 |
+
if inputs_embeds is not None and past_key_values is None:
|
1005 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
1006 |
+
else:
|
1007 |
+
model_inputs = {"input_ids": input_ids}
|
1008 |
+
|
1009 |
+
model_inputs.update(
|
1010 |
+
{
|
1011 |
+
"position_ids": position_ids,
|
1012 |
+
"past_key_values": past_key_values,
|
1013 |
+
"use_cache": kwargs.get("use_cache"),
|
1014 |
+
"attention_mask": attention_mask,
|
1015 |
+
}
|
1016 |
+
)
|
1017 |
+
return model_inputs
|
1018 |
+
|
1019 |
+
@staticmethod
|
1020 |
+
def _reorder_cache(past_key_values, beam_idx):
|
1021 |
+
reordered_past = ()
|
1022 |
+
for layer_past in past_key_values:
|
1023 |
+
reordered_past += (
|
1024 |
+
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
1025 |
+
)
|
1026 |
+
return reordered_past
|
1027 |
+
|
1028 |
+
def _calculate_loss(self, logits: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:
|
1029 |
+
"""Compute cross entropy and entropy for log probs and targets.
|
1030 |
+
|
1031 |
+
Args:
|
1032 |
+
logits: [batch, length, num_classes] float array.
|
1033 |
+
targets: categorical targets [batch, length] int array.
|
1034 |
+
|
1035 |
+
Returns:
|
1036 |
+
Tuple of scalar loss.
|
1037 |
+
"""
|
1038 |
+
if len(logits.shape) != len(targets.shape) + 1:
|
1039 |
+
raise ValueError(
|
1040 |
+
"Incorrect shapes. Got shape %s logits and %s targets" % (str(logits.shape), str(targets.shape))
|
1041 |
+
)
|
1042 |
+
vocab_size = logits.shape[-1]
|
1043 |
+
confidence = 1.0 - self.config.label_smoothing
|
1044 |
+
low_confidence = (1.0 - confidence) / (vocab_size - 1)
|
1045 |
+
normalizing_constant = -(
|
1046 |
+
confidence * math.log(confidence) + (vocab_size - 1) * low_confidence * math.log(low_confidence + 1e-20)
|
1047 |
+
)
|
1048 |
+
|
1049 |
+
# one hot
|
1050 |
+
soft_targets = targets[..., None] == torch.arange(vocab_size, device=targets.device).reshape(
|
1051 |
+
(1,) * len(targets.shape) + (-1,)
|
1052 |
+
)
|
1053 |
+
soft_targets = torch.where(
|
1054 |
+
soft_targets, torch.full_like(soft_targets, confidence), torch.full_like(soft_targets, low_confidence)
|
1055 |
+
)
|
1056 |
+
soft_targets = soft_targets.to(torch.float32)
|
1057 |
+
|
1058 |
+
# cross entropy
|
1059 |
+
total_loss = ZLossCrossEntropy.apply(logits, soft_targets, self.config.z_loss_factor)
|
1060 |
+
total_loss = total_loss - normalizing_constant
|
1061 |
+
total_loss = torch.mean(torch.sum(total_loss, dim=-1), dim=0)
|
1062 |
+
return total_loss
|
1063 |
+
|
1064 |
+
|
1065 |
+
class ZLossCrossEntropy(torch.autograd.Function):
|
1066 |
+
"""Computes cross entropy loss with stable custom gradient.
|
1067 |
+
|
1068 |
+
Computes a stabilized-gradient version of:
|
1069 |
+
-jnp.sum(targets * nn.log_softmax(logits), axis=-1)
|
1070 |
+
|
1071 |
+
If z_loss > 0, then an auxiliary loss equal to z_loss*log(z)^2
|
1072 |
+
will be added to the cross entropy loss (z = softmax normalization constant).
|
1073 |
+
The two uses of z_loss are:
|
1074 |
+
1. To keep the logits from drifting too far from zero, which can cause
|
1075 |
+
unacceptable roundoff errors in bfloat16.
|
1076 |
+
2. To encourage the logits to be normalized log-probabilities.
|
1077 |
+
|
1078 |
+
Args:
|
1079 |
+
logits: [batch, length, num_classes] float array.
|
1080 |
+
targets: categorical one-hot targets [batch, length, num_classes] float
|
1081 |
+
array.
|
1082 |
+
z_loss: coefficient for auxilliary z-loss loss term.
|
1083 |
+
|
1084 |
+
Returns:
|
1085 |
+
tuple with the total loss and the z_loss, both
|
1086 |
+
float arrays with shape [batch, length].
|
1087 |
+
"""
|
1088 |
+
|
1089 |
+
@staticmethod
|
1090 |
+
def forward(ctx, logits, targets, z_loss):
|
1091 |
+
max_logit = torch.max(logits, dim=-1, keepdim=True)[0]
|
1092 |
+
shifted = logits - max_logit
|
1093 |
+
exp_shifted = torch.exp(shifted)
|
1094 |
+
sum_exp = torch.sum(exp_shifted, axis=-1, keepdims=True)
|
1095 |
+
sum_exp_log = torch.log(sum_exp)
|
1096 |
+
log_softmax = shifted - sum_exp_log
|
1097 |
+
loss = -torch.sum(targets * log_softmax, axis=-1)
|
1098 |
+
# Add auxilliary z-loss term.
|
1099 |
+
log_z = torch.squeeze(sum_exp_log + max_logit, axis=-1)
|
1100 |
+
total_z_loss = z_loss * torch.square(log_z)
|
1101 |
+
loss += total_z_loss
|
1102 |
+
ctx.z_loss = z_loss
|
1103 |
+
ctx.save_for_backward(logits, targets, exp_shifted, sum_exp, log_softmax, log_z)
|
1104 |
+
return loss
|
1105 |
+
|
1106 |
+
@staticmethod
|
1107 |
+
def backward(ctx, *grad_outputs):
|
1108 |
+
assert len(grad_outputs) == 1
|
1109 |
+
g = grad_outputs[0]
|
1110 |
+
z_loss = ctx.z_loss
|
1111 |
+
logits, targets, exp_shifted, sum_exp, log_softmax, log_z = ctx.saved_tensors
|
1112 |
+
# z-loss term adds the (2 * z_loss * log_z) factor.
|
1113 |
+
deriv = (1 + 2 * z_loss * log_z).unsqueeze(-1) * exp_shifted / sum_exp - targets
|
1114 |
+
g_logits = g.unsqueeze(-1) * deriv
|
1115 |
+
g_targets = -g.unsqueeze(-1) * log_softmax
|
1116 |
+
|
1117 |
+
return (
|
1118 |
+
g_logits.to(logits.dtype),
|
1119 |
+
g_targets.to(targets.dtype),
|
1120 |
+
None,
|
1121 |
+
)
|
tokenization_hf_openmoe.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Optional
|
2 |
+
|
3 |
+
from transformers import T5Tokenizer
|
4 |
+
|
5 |
+
|
6 |
+
class HFOpenMoeTokenizer(T5Tokenizer):
|
7 |
+
def __init__(self, *args, **kwargs):
|
8 |
+
super().__init__(*args, **kwargs)
|
9 |
+
self.padding_side = 'left'
|
10 |
+
self.add_bos_token = True
|
11 |
+
self.add_eos_token = False
|
12 |
+
|
13 |
+
def build_inputs_with_special_tokens(
|
14 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
|
15 |
+
) -> List[int]:
|
16 |
+
if self.add_eos_token:
|
17 |
+
token_ids_0 = self._add_eos_if_not_present(token_ids_0)
|
18 |
+
if self.add_bos_token:
|
19 |
+
token_ids_0 = [self.pad_token_id] + token_ids_0
|
20 |
+
if token_ids_1 is None:
|
21 |
+
return token_ids_0
|
22 |
+
else:
|
23 |
+
token_ids_1 = self._add_eos_if_not_present(token_ids_1)
|
24 |
+
return token_ids_0 + token_ids_1
|