Version1 (#1)
Browse files- upload mxfp4 deepseek-v3 (0c7c716272255bca2a02e7952d747819ad980317)
This view is limited to 50 files because it contains too many changes.
See raw diff
- chat_template.jinja +14 -0
- config.json +452 -0
- configuration_deepseek.py +210 -0
- generation_config.json +6 -0
- model-00001-of-00076.safetensors +3 -0
- model-00002-of-00076.safetensors +3 -0
- model-00003-of-00076.safetensors +3 -0
- model-00004-of-00076.safetensors +3 -0
- model-00005-of-00076.safetensors +3 -0
- model-00006-of-00076.safetensors +3 -0
- model-00007-of-00076.safetensors +3 -0
- model-00008-of-00076.safetensors +3 -0
- model-00009-of-00076.safetensors +3 -0
- model-00010-of-00076.safetensors +3 -0
- model-00011-of-00076.safetensors +3 -0
- model-00012-of-00076.safetensors +3 -0
- model-00013-of-00076.safetensors +3 -0
- model-00014-of-00076.safetensors +3 -0
- model-00015-of-00076.safetensors +3 -0
- model-00016-of-00076.safetensors +3 -0
- model-00017-of-00076.safetensors +3 -0
- model-00018-of-00076.safetensors +3 -0
- model-00019-of-00076.safetensors +3 -0
- model-00020-of-00076.safetensors +3 -0
- model-00021-of-00076.safetensors +3 -0
- model-00022-of-00076.safetensors +3 -0
- model-00023-of-00076.safetensors +3 -0
- model-00024-of-00076.safetensors +3 -0
- model-00025-of-00076.safetensors +3 -0
- model-00026-of-00076.safetensors +3 -0
- model-00027-of-00076.safetensors +3 -0
- model-00028-of-00076.safetensors +3 -0
- model-00029-of-00076.safetensors +3 -0
- model-00030-of-00076.safetensors +3 -0
- model-00031-of-00076.safetensors +3 -0
- model-00032-of-00076.safetensors +3 -0
- model-00033-of-00076.safetensors +3 -0
- model-00034-of-00076.safetensors +3 -0
- model-00035-of-00076.safetensors +3 -0
- model-00036-of-00076.safetensors +3 -0
- model-00037-of-00076.safetensors +3 -0
- model-00038-of-00076.safetensors +3 -0
- model-00039-of-00076.safetensors +3 -0
- model-00040-of-00076.safetensors +3 -0
- model-00041-of-00076.safetensors +3 -0
- model-00042-of-00076.safetensors +3 -0
- model-00043-of-00076.safetensors +3 -0
- model-00044-of-00076.safetensors +3 -0
- model-00045-of-00076.safetensors +3 -0
- model-00046-of-00076.safetensors +3 -0
chat_template.jinja
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_last_user=false) %}{%- for message in messages %}{%- if message['role'] == 'system' %}{%- if ns.is_first_sp %}{% set ns.system_prompt = ns.system_prompt + message['content'] %}{% set ns.is_first_sp = false %}{%- else %}{% set ns.system_prompt = ns.system_prompt + '
|
2 |
+
|
3 |
+
' + message['content'] %}{%- endif %}{%- endif %}{%- endfor %}{{ bos_token }}{{ ns.system_prompt }}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{%- set ns.is_first = false -%}{%- set ns.is_last_user = true -%}{{'<|User|>' + message['content'] + '<|Assistant|>'}}{%- endif %}{%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}{%- set ns.is_last_user = false -%}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{%- endif %}{%- set ns.is_first = false %}{%- set ns.is_tool = false -%}{%- set ns.is_output_first = true %}{%- for tool in message['tool_calls'] %}{%- if not ns.is_first %}{%- if message['content'] is none %}{{'<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '
|
4 |
+
' + '```json' + '
|
5 |
+
' + tool['function']['arguments'] + '
|
6 |
+
' + '```' + '<|tool▁call▁end|>'}}{%- else %}{{message['content'] + '<|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '
|
7 |
+
' + '```json' + '
|
8 |
+
' + tool['function']['arguments'] + '
|
9 |
+
' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- set ns.is_first = true -%}{%- else %}{{'
|
10 |
+
' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '
|
11 |
+
' + '```json' + '
|
12 |
+
' + tool['function']['arguments'] + '
|
13 |
+
' + '```' + '<|tool▁call▁end|>'}}{%- endif %}{%- endfor %}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none)%}{%- set ns.is_last_user = false -%}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{{content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_last_user = false -%}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'
|
14 |
+
<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_last_user and not ns.is_tool %}{{'<|Assistant|>'}}{% endif %}
|
config.json
ADDED
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"DeepseekV3ForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoConfig": "configuration_deepseek.DeepseekV3Config",
|
9 |
+
"AutoModel": "modeling_deepseek.DeepseekV3Model",
|
10 |
+
"AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"
|
11 |
+
},
|
12 |
+
"aux_loss_alpha": 0.001,
|
13 |
+
"bos_token_id": 0,
|
14 |
+
"eos_token_id": 1,
|
15 |
+
"ep_size": 1,
|
16 |
+
"first_k_dense_replace": 3,
|
17 |
+
"hidden_act": "silu",
|
18 |
+
"hidden_size": 7168,
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"intermediate_size": 18432,
|
21 |
+
"kv_lora_rank": 512,
|
22 |
+
"max_position_embeddings": 163840,
|
23 |
+
"model_type": "deepseek_v3",
|
24 |
+
"moe_intermediate_size": 2048,
|
25 |
+
"moe_layer_freq": 1,
|
26 |
+
"n_group": 8,
|
27 |
+
"n_routed_experts": 256,
|
28 |
+
"n_shared_experts": 1,
|
29 |
+
"norm_topk_prob": true,
|
30 |
+
"num_attention_heads": 128,
|
31 |
+
"num_experts_per_tok": 8,
|
32 |
+
"num_hidden_layers": 61,
|
33 |
+
"num_key_value_heads": 128,
|
34 |
+
"num_nextn_predict_layers": 1,
|
35 |
+
"pretraining_tp": 1,
|
36 |
+
"q_lora_rank": 1536,
|
37 |
+
"qk_nope_head_dim": 128,
|
38 |
+
"qk_rope_head_dim": 64,
|
39 |
+
"quantization_config": {
|
40 |
+
"algo_config": [
|
41 |
+
{
|
42 |
+
"compute_scale_loss": "MAE",
|
43 |
+
"model_decoder_layers": "model.layers",
|
44 |
+
"name": "autosmoothquant",
|
45 |
+
"scaling_layers": [
|
46 |
+
{
|
47 |
+
"inp": "mlp.gate_proj",
|
48 |
+
"layers": [
|
49 |
+
"mlp.gate_proj",
|
50 |
+
"mlp.up_proj"
|
51 |
+
],
|
52 |
+
"module2inspect": "mlp",
|
53 |
+
"prev_op": "post_attention_layernorm"
|
54 |
+
},
|
55 |
+
{
|
56 |
+
"inp": "mlp.down_proj",
|
57 |
+
"layers": [
|
58 |
+
"mlp.down_proj"
|
59 |
+
],
|
60 |
+
"prev_op": "mlp.up_proj"
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"inp": "down_proj",
|
64 |
+
"layers": [
|
65 |
+
"down_proj"
|
66 |
+
],
|
67 |
+
"prev_op": "up_proj"
|
68 |
+
}
|
69 |
+
]
|
70 |
+
}
|
71 |
+
],
|
72 |
+
"exclude": [
|
73 |
+
"model.layers.0.self_attn.q_a_proj",
|
74 |
+
"model.layers.0.self_attn.q_b_proj",
|
75 |
+
"model.layers.0.self_attn.kv_a_proj_with_mqa",
|
76 |
+
"model.layers.0.self_attn.kv_b_proj",
|
77 |
+
"model.layers.0.self_attn.o_proj",
|
78 |
+
"model.layers.1.self_attn.q_a_proj",
|
79 |
+
"model.layers.1.self_attn.q_b_proj",
|
80 |
+
"model.layers.1.self_attn.kv_a_proj_with_mqa",
|
81 |
+
"model.layers.1.self_attn.kv_b_proj",
|
82 |
+
"model.layers.1.self_attn.o_proj",
|
83 |
+
"model.layers.2.self_attn.q_a_proj",
|
84 |
+
"model.layers.2.self_attn.q_b_proj",
|
85 |
+
"model.layers.2.self_attn.kv_a_proj_with_mqa",
|
86 |
+
"model.layers.2.self_attn.kv_b_proj",
|
87 |
+
"model.layers.2.self_attn.o_proj",
|
88 |
+
"model.layers.3.self_attn.q_a_proj",
|
89 |
+
"model.layers.3.self_attn.q_b_proj",
|
90 |
+
"model.layers.3.self_attn.kv_a_proj_with_mqa",
|
91 |
+
"model.layers.3.self_attn.kv_b_proj",
|
92 |
+
"model.layers.3.self_attn.o_proj",
|
93 |
+
"model.layers.4.self_attn.q_a_proj",
|
94 |
+
"model.layers.4.self_attn.q_b_proj",
|
95 |
+
"model.layers.4.self_attn.kv_a_proj_with_mqa",
|
96 |
+
"model.layers.4.self_attn.kv_b_proj",
|
97 |
+
"model.layers.4.self_attn.o_proj",
|
98 |
+
"model.layers.5.self_attn.q_a_proj",
|
99 |
+
"model.layers.5.self_attn.q_b_proj",
|
100 |
+
"model.layers.5.self_attn.kv_a_proj_with_mqa",
|
101 |
+
"model.layers.5.self_attn.kv_b_proj",
|
102 |
+
"model.layers.5.self_attn.o_proj",
|
103 |
+
"model.layers.6.self_attn.q_a_proj",
|
104 |
+
"model.layers.6.self_attn.q_b_proj",
|
105 |
+
"model.layers.6.self_attn.kv_a_proj_with_mqa",
|
106 |
+
"model.layers.6.self_attn.kv_b_proj",
|
107 |
+
"model.layers.6.self_attn.o_proj",
|
108 |
+
"model.layers.7.self_attn.q_a_proj",
|
109 |
+
"model.layers.7.self_attn.q_b_proj",
|
110 |
+
"model.layers.7.self_attn.kv_a_proj_with_mqa",
|
111 |
+
"model.layers.7.self_attn.kv_b_proj",
|
112 |
+
"model.layers.7.self_attn.o_proj",
|
113 |
+
"model.layers.8.self_attn.q_a_proj",
|
114 |
+
"model.layers.8.self_attn.q_b_proj",
|
115 |
+
"model.layers.8.self_attn.kv_a_proj_with_mqa",
|
116 |
+
"model.layers.8.self_attn.kv_b_proj",
|
117 |
+
"model.layers.8.self_attn.o_proj",
|
118 |
+
"model.layers.9.self_attn.q_a_proj",
|
119 |
+
"model.layers.9.self_attn.q_b_proj",
|
120 |
+
"model.layers.9.self_attn.kv_a_proj_with_mqa",
|
121 |
+
"model.layers.9.self_attn.kv_b_proj",
|
122 |
+
"model.layers.9.self_attn.o_proj",
|
123 |
+
"model.layers.10.self_attn.q_a_proj",
|
124 |
+
"model.layers.10.self_attn.q_b_proj",
|
125 |
+
"model.layers.10.self_attn.kv_a_proj_with_mqa",
|
126 |
+
"model.layers.10.self_attn.kv_b_proj",
|
127 |
+
"model.layers.10.self_attn.o_proj",
|
128 |
+
"model.layers.11.self_attn.q_a_proj",
|
129 |
+
"model.layers.11.self_attn.q_b_proj",
|
130 |
+
"model.layers.11.self_attn.kv_a_proj_with_mqa",
|
131 |
+
"model.layers.11.self_attn.kv_b_proj",
|
132 |
+
"model.layers.11.self_attn.o_proj",
|
133 |
+
"model.layers.12.self_attn.q_a_proj",
|
134 |
+
"model.layers.12.self_attn.q_b_proj",
|
135 |
+
"model.layers.12.self_attn.kv_a_proj_with_mqa",
|
136 |
+
"model.layers.12.self_attn.kv_b_proj",
|
137 |
+
"model.layers.12.self_attn.o_proj",
|
138 |
+
"model.layers.13.self_attn.q_a_proj",
|
139 |
+
"model.layers.13.self_attn.q_b_proj",
|
140 |
+
"model.layers.13.self_attn.kv_a_proj_with_mqa",
|
141 |
+
"model.layers.13.self_attn.kv_b_proj",
|
142 |
+
"model.layers.13.self_attn.o_proj",
|
143 |
+
"model.layers.14.self_attn.q_a_proj",
|
144 |
+
"model.layers.14.self_attn.q_b_proj",
|
145 |
+
"model.layers.14.self_attn.kv_a_proj_with_mqa",
|
146 |
+
"model.layers.14.self_attn.kv_b_proj",
|
147 |
+
"model.layers.14.self_attn.o_proj",
|
148 |
+
"model.layers.15.self_attn.q_a_proj",
|
149 |
+
"model.layers.15.self_attn.q_b_proj",
|
150 |
+
"model.layers.15.self_attn.kv_a_proj_with_mqa",
|
151 |
+
"model.layers.15.self_attn.kv_b_proj",
|
152 |
+
"model.layers.15.self_attn.o_proj",
|
153 |
+
"model.layers.16.self_attn.q_a_proj",
|
154 |
+
"model.layers.16.self_attn.q_b_proj",
|
155 |
+
"model.layers.16.self_attn.kv_a_proj_with_mqa",
|
156 |
+
"model.layers.16.self_attn.kv_b_proj",
|
157 |
+
"model.layers.16.self_attn.o_proj",
|
158 |
+
"model.layers.17.self_attn.q_a_proj",
|
159 |
+
"model.layers.17.self_attn.q_b_proj",
|
160 |
+
"model.layers.17.self_attn.kv_a_proj_with_mqa",
|
161 |
+
"model.layers.17.self_attn.kv_b_proj",
|
162 |
+
"model.layers.17.self_attn.o_proj",
|
163 |
+
"model.layers.18.self_attn.q_a_proj",
|
164 |
+
"model.layers.18.self_attn.q_b_proj",
|
165 |
+
"model.layers.18.self_attn.kv_a_proj_with_mqa",
|
166 |
+
"model.layers.18.self_attn.kv_b_proj",
|
167 |
+
"model.layers.18.self_attn.o_proj",
|
168 |
+
"model.layers.19.self_attn.q_a_proj",
|
169 |
+
"model.layers.19.self_attn.q_b_proj",
|
170 |
+
"model.layers.19.self_attn.kv_a_proj_with_mqa",
|
171 |
+
"model.layers.19.self_attn.kv_b_proj",
|
172 |
+
"model.layers.19.self_attn.o_proj",
|
173 |
+
"model.layers.20.self_attn.q_a_proj",
|
174 |
+
"model.layers.20.self_attn.q_b_proj",
|
175 |
+
"model.layers.20.self_attn.kv_a_proj_with_mqa",
|
176 |
+
"model.layers.20.self_attn.kv_b_proj",
|
177 |
+
"model.layers.20.self_attn.o_proj",
|
178 |
+
"model.layers.21.self_attn.q_a_proj",
|
179 |
+
"model.layers.21.self_attn.q_b_proj",
|
180 |
+
"model.layers.21.self_attn.kv_a_proj_with_mqa",
|
181 |
+
"model.layers.21.self_attn.kv_b_proj",
|
182 |
+
"model.layers.21.self_attn.o_proj",
|
183 |
+
"model.layers.22.self_attn.q_a_proj",
|
184 |
+
"model.layers.22.self_attn.q_b_proj",
|
185 |
+
"model.layers.22.self_attn.kv_a_proj_with_mqa",
|
186 |
+
"model.layers.22.self_attn.kv_b_proj",
|
187 |
+
"model.layers.22.self_attn.o_proj",
|
188 |
+
"model.layers.23.self_attn.q_a_proj",
|
189 |
+
"model.layers.23.self_attn.q_b_proj",
|
190 |
+
"model.layers.23.self_attn.kv_a_proj_with_mqa",
|
191 |
+
"model.layers.23.self_attn.kv_b_proj",
|
192 |
+
"model.layers.23.self_attn.o_proj",
|
193 |
+
"model.layers.24.self_attn.q_a_proj",
|
194 |
+
"model.layers.24.self_attn.q_b_proj",
|
195 |
+
"model.layers.24.self_attn.kv_a_proj_with_mqa",
|
196 |
+
"model.layers.24.self_attn.kv_b_proj",
|
197 |
+
"model.layers.24.self_attn.o_proj",
|
198 |
+
"model.layers.25.self_attn.q_a_proj",
|
199 |
+
"model.layers.25.self_attn.q_b_proj",
|
200 |
+
"model.layers.25.self_attn.kv_a_proj_with_mqa",
|
201 |
+
"model.layers.25.self_attn.kv_b_proj",
|
202 |
+
"model.layers.25.self_attn.o_proj",
|
203 |
+
"model.layers.26.self_attn.q_a_proj",
|
204 |
+
"model.layers.26.self_attn.q_b_proj",
|
205 |
+
"model.layers.26.self_attn.kv_a_proj_with_mqa",
|
206 |
+
"model.layers.26.self_attn.kv_b_proj",
|
207 |
+
"model.layers.26.self_attn.o_proj",
|
208 |
+
"model.layers.27.self_attn.q_a_proj",
|
209 |
+
"model.layers.27.self_attn.q_b_proj",
|
210 |
+
"model.layers.27.self_attn.kv_a_proj_with_mqa",
|
211 |
+
"model.layers.27.self_attn.kv_b_proj",
|
212 |
+
"model.layers.27.self_attn.o_proj",
|
213 |
+
"model.layers.28.self_attn.q_a_proj",
|
214 |
+
"model.layers.28.self_attn.q_b_proj",
|
215 |
+
"model.layers.28.self_attn.kv_a_proj_with_mqa",
|
216 |
+
"model.layers.28.self_attn.kv_b_proj",
|
217 |
+
"model.layers.28.self_attn.o_proj",
|
218 |
+
"model.layers.29.self_attn.q_a_proj",
|
219 |
+
"model.layers.29.self_attn.q_b_proj",
|
220 |
+
"model.layers.29.self_attn.kv_a_proj_with_mqa",
|
221 |
+
"model.layers.29.self_attn.kv_b_proj",
|
222 |
+
"model.layers.29.self_attn.o_proj",
|
223 |
+
"model.layers.30.self_attn.q_a_proj",
|
224 |
+
"model.layers.30.self_attn.q_b_proj",
|
225 |
+
"model.layers.30.self_attn.kv_a_proj_with_mqa",
|
226 |
+
"model.layers.30.self_attn.kv_b_proj",
|
227 |
+
"model.layers.30.self_attn.o_proj",
|
228 |
+
"model.layers.31.self_attn.q_a_proj",
|
229 |
+
"model.layers.31.self_attn.q_b_proj",
|
230 |
+
"model.layers.31.self_attn.kv_a_proj_with_mqa",
|
231 |
+
"model.layers.31.self_attn.kv_b_proj",
|
232 |
+
"model.layers.31.self_attn.o_proj",
|
233 |
+
"model.layers.32.self_attn.q_a_proj",
|
234 |
+
"model.layers.32.self_attn.q_b_proj",
|
235 |
+
"model.layers.32.self_attn.kv_a_proj_with_mqa",
|
236 |
+
"model.layers.32.self_attn.kv_b_proj",
|
237 |
+
"model.layers.32.self_attn.o_proj",
|
238 |
+
"model.layers.33.self_attn.q_a_proj",
|
239 |
+
"model.layers.33.self_attn.q_b_proj",
|
240 |
+
"model.layers.33.self_attn.kv_a_proj_with_mqa",
|
241 |
+
"model.layers.33.self_attn.kv_b_proj",
|
242 |
+
"model.layers.33.self_attn.o_proj",
|
243 |
+
"model.layers.34.self_attn.q_a_proj",
|
244 |
+
"model.layers.34.self_attn.q_b_proj",
|
245 |
+
"model.layers.34.self_attn.kv_a_proj_with_mqa",
|
246 |
+
"model.layers.34.self_attn.kv_b_proj",
|
247 |
+
"model.layers.34.self_attn.o_proj",
|
248 |
+
"model.layers.35.self_attn.q_a_proj",
|
249 |
+
"model.layers.35.self_attn.q_b_proj",
|
250 |
+
"model.layers.35.self_attn.kv_a_proj_with_mqa",
|
251 |
+
"model.layers.35.self_attn.kv_b_proj",
|
252 |
+
"model.layers.35.self_attn.o_proj",
|
253 |
+
"model.layers.36.self_attn.q_a_proj",
|
254 |
+
"model.layers.36.self_attn.q_b_proj",
|
255 |
+
"model.layers.36.self_attn.kv_a_proj_with_mqa",
|
256 |
+
"model.layers.36.self_attn.kv_b_proj",
|
257 |
+
"model.layers.36.self_attn.o_proj",
|
258 |
+
"model.layers.37.self_attn.q_a_proj",
|
259 |
+
"model.layers.37.self_attn.q_b_proj",
|
260 |
+
"model.layers.37.self_attn.kv_a_proj_with_mqa",
|
261 |
+
"model.layers.37.self_attn.kv_b_proj",
|
262 |
+
"model.layers.37.self_attn.o_proj",
|
263 |
+
"model.layers.38.self_attn.q_a_proj",
|
264 |
+
"model.layers.38.self_attn.q_b_proj",
|
265 |
+
"model.layers.38.self_attn.kv_a_proj_with_mqa",
|
266 |
+
"model.layers.38.self_attn.kv_b_proj",
|
267 |
+
"model.layers.38.self_attn.o_proj",
|
268 |
+
"model.layers.39.self_attn.q_a_proj",
|
269 |
+
"model.layers.39.self_attn.q_b_proj",
|
270 |
+
"model.layers.39.self_attn.kv_a_proj_with_mqa",
|
271 |
+
"model.layers.39.self_attn.kv_b_proj",
|
272 |
+
"model.layers.39.self_attn.o_proj",
|
273 |
+
"model.layers.40.self_attn.q_a_proj",
|
274 |
+
"model.layers.40.self_attn.q_b_proj",
|
275 |
+
"model.layers.40.self_attn.kv_a_proj_with_mqa",
|
276 |
+
"model.layers.40.self_attn.kv_b_proj",
|
277 |
+
"model.layers.40.self_attn.o_proj",
|
278 |
+
"model.layers.41.self_attn.q_a_proj",
|
279 |
+
"model.layers.41.self_attn.q_b_proj",
|
280 |
+
"model.layers.41.self_attn.kv_a_proj_with_mqa",
|
281 |
+
"model.layers.41.self_attn.kv_b_proj",
|
282 |
+
"model.layers.41.self_attn.o_proj",
|
283 |
+
"model.layers.42.self_attn.q_a_proj",
|
284 |
+
"model.layers.42.self_attn.q_b_proj",
|
285 |
+
"model.layers.42.self_attn.kv_a_proj_with_mqa",
|
286 |
+
"model.layers.42.self_attn.kv_b_proj",
|
287 |
+
"model.layers.42.self_attn.o_proj",
|
288 |
+
"model.layers.43.self_attn.q_a_proj",
|
289 |
+
"model.layers.43.self_attn.q_b_proj",
|
290 |
+
"model.layers.43.self_attn.kv_a_proj_with_mqa",
|
291 |
+
"model.layers.43.self_attn.kv_b_proj",
|
292 |
+
"model.layers.43.self_attn.o_proj",
|
293 |
+
"model.layers.44.self_attn.q_a_proj",
|
294 |
+
"model.layers.44.self_attn.q_b_proj",
|
295 |
+
"model.layers.44.self_attn.kv_a_proj_with_mqa",
|
296 |
+
"model.layers.44.self_attn.kv_b_proj",
|
297 |
+
"model.layers.44.self_attn.o_proj",
|
298 |
+
"model.layers.45.self_attn.q_a_proj",
|
299 |
+
"model.layers.45.self_attn.q_b_proj",
|
300 |
+
"model.layers.45.self_attn.kv_a_proj_with_mqa",
|
301 |
+
"model.layers.45.self_attn.kv_b_proj",
|
302 |
+
"model.layers.45.self_attn.o_proj",
|
303 |
+
"model.layers.46.self_attn.q_a_proj",
|
304 |
+
"model.layers.46.self_attn.q_b_proj",
|
305 |
+
"model.layers.46.self_attn.kv_a_proj_with_mqa",
|
306 |
+
"model.layers.46.self_attn.kv_b_proj",
|
307 |
+
"model.layers.46.self_attn.o_proj",
|
308 |
+
"model.layers.47.self_attn.q_a_proj",
|
309 |
+
"model.layers.47.self_attn.q_b_proj",
|
310 |
+
"model.layers.47.self_attn.kv_a_proj_with_mqa",
|
311 |
+
"model.layers.47.self_attn.kv_b_proj",
|
312 |
+
"model.layers.47.self_attn.o_proj",
|
313 |
+
"model.layers.48.self_attn.q_a_proj",
|
314 |
+
"model.layers.48.self_attn.q_b_proj",
|
315 |
+
"model.layers.48.self_attn.kv_a_proj_with_mqa",
|
316 |
+
"model.layers.48.self_attn.kv_b_proj",
|
317 |
+
"model.layers.48.self_attn.o_proj",
|
318 |
+
"model.layers.49.self_attn.q_a_proj",
|
319 |
+
"model.layers.49.self_attn.q_b_proj",
|
320 |
+
"model.layers.49.self_attn.kv_a_proj_with_mqa",
|
321 |
+
"model.layers.49.self_attn.kv_b_proj",
|
322 |
+
"model.layers.49.self_attn.o_proj",
|
323 |
+
"model.layers.50.self_attn.q_a_proj",
|
324 |
+
"model.layers.50.self_attn.q_b_proj",
|
325 |
+
"model.layers.50.self_attn.kv_a_proj_with_mqa",
|
326 |
+
"model.layers.50.self_attn.kv_b_proj",
|
327 |
+
"model.layers.50.self_attn.o_proj",
|
328 |
+
"model.layers.51.self_attn.q_a_proj",
|
329 |
+
"model.layers.51.self_attn.q_b_proj",
|
330 |
+
"model.layers.51.self_attn.kv_a_proj_with_mqa",
|
331 |
+
"model.layers.51.self_attn.kv_b_proj",
|
332 |
+
"model.layers.51.self_attn.o_proj",
|
333 |
+
"model.layers.52.self_attn.q_a_proj",
|
334 |
+
"model.layers.52.self_attn.q_b_proj",
|
335 |
+
"model.layers.52.self_attn.kv_a_proj_with_mqa",
|
336 |
+
"model.layers.52.self_attn.kv_b_proj",
|
337 |
+
"model.layers.52.self_attn.o_proj",
|
338 |
+
"model.layers.53.self_attn.q_a_proj",
|
339 |
+
"model.layers.53.self_attn.q_b_proj",
|
340 |
+
"model.layers.53.self_attn.kv_a_proj_with_mqa",
|
341 |
+
"model.layers.53.self_attn.kv_b_proj",
|
342 |
+
"model.layers.53.self_attn.o_proj",
|
343 |
+
"model.layers.54.self_attn.q_a_proj",
|
344 |
+
"model.layers.54.self_attn.q_b_proj",
|
345 |
+
"model.layers.54.self_attn.kv_a_proj_with_mqa",
|
346 |
+
"model.layers.54.self_attn.kv_b_proj",
|
347 |
+
"model.layers.54.self_attn.o_proj",
|
348 |
+
"model.layers.55.self_attn.q_a_proj",
|
349 |
+
"model.layers.55.self_attn.q_b_proj",
|
350 |
+
"model.layers.55.self_attn.kv_a_proj_with_mqa",
|
351 |
+
"model.layers.55.self_attn.kv_b_proj",
|
352 |
+
"model.layers.55.self_attn.o_proj",
|
353 |
+
"model.layers.56.self_attn.q_a_proj",
|
354 |
+
"model.layers.56.self_attn.q_b_proj",
|
355 |
+
"model.layers.56.self_attn.kv_a_proj_with_mqa",
|
356 |
+
"model.layers.56.self_attn.kv_b_proj",
|
357 |
+
"model.layers.56.self_attn.o_proj",
|
358 |
+
"model.layers.57.self_attn.q_a_proj",
|
359 |
+
"model.layers.57.self_attn.q_b_proj",
|
360 |
+
"model.layers.57.self_attn.kv_a_proj_with_mqa",
|
361 |
+
"model.layers.57.self_attn.kv_b_proj",
|
362 |
+
"model.layers.57.self_attn.o_proj",
|
363 |
+
"model.layers.58.self_attn.q_a_proj",
|
364 |
+
"model.layers.58.self_attn.q_b_proj",
|
365 |
+
"model.layers.58.self_attn.kv_a_proj_with_mqa",
|
366 |
+
"model.layers.58.self_attn.kv_b_proj",
|
367 |
+
"model.layers.58.self_attn.o_proj",
|
368 |
+
"model.layers.59.self_attn.q_a_proj",
|
369 |
+
"model.layers.59.self_attn.q_b_proj",
|
370 |
+
"model.layers.59.self_attn.kv_a_proj_with_mqa",
|
371 |
+
"model.layers.59.self_attn.kv_b_proj",
|
372 |
+
"model.layers.59.self_attn.o_proj",
|
373 |
+
"model.layers.60.self_attn.q_a_proj",
|
374 |
+
"model.layers.60.self_attn.q_b_proj",
|
375 |
+
"model.layers.60.self_attn.kv_a_proj_with_mqa",
|
376 |
+
"model.layers.60.self_attn.kv_b_proj",
|
377 |
+
"model.layers.60.self_attn.o_proj",
|
378 |
+
"lm_head"
|
379 |
+
],
|
380 |
+
"export": {
|
381 |
+
"kv_cache_group": [],
|
382 |
+
"min_kv_scale": 0.0,
|
383 |
+
"pack_method": "reorder",
|
384 |
+
"weight_format": "real_quantized",
|
385 |
+
"weight_merge_groups": null
|
386 |
+
},
|
387 |
+
"global_quant_config": {
|
388 |
+
"bias": null,
|
389 |
+
"input_tensors": {
|
390 |
+
"ch_axis": -1,
|
391 |
+
"dtype": "fp4",
|
392 |
+
"group_size": 32,
|
393 |
+
"is_dynamic": true,
|
394 |
+
"is_scale_quant": false,
|
395 |
+
"mx_element_dtype": null,
|
396 |
+
"observer_cls": "PerBlockMXObserver",
|
397 |
+
"qscheme": "per_group",
|
398 |
+
"round_method": "half_even",
|
399 |
+
"scale_calculation_mode": "even",
|
400 |
+
"scale_format": "e8m0",
|
401 |
+
"scale_type": "float",
|
402 |
+
"symmetric": null
|
403 |
+
},
|
404 |
+
"output_tensors": null,
|
405 |
+
"target_device": null,
|
406 |
+
"weight": {
|
407 |
+
"ch_axis": -1,
|
408 |
+
"dtype": "fp4",
|
409 |
+
"group_size": 32,
|
410 |
+
"is_dynamic": false,
|
411 |
+
"is_scale_quant": false,
|
412 |
+
"mx_element_dtype": null,
|
413 |
+
"observer_cls": "PerBlockMXObserver",
|
414 |
+
"qscheme": "per_group",
|
415 |
+
"round_method": "half_even",
|
416 |
+
"scale_calculation_mode": "even",
|
417 |
+
"scale_format": "e8m0",
|
418 |
+
"scale_type": "float",
|
419 |
+
"symmetric": null
|
420 |
+
}
|
421 |
+
},
|
422 |
+
"kv_cache_quant_config": {},
|
423 |
+
"layer_quant_config": {},
|
424 |
+
"layer_type_quant_config": {},
|
425 |
+
"quant_method": "quark",
|
426 |
+
"quant_mode": "eager_mode",
|
427 |
+
"softmax_quant_spec": null,
|
428 |
+
"version": "0.10+d757f3f3e0"
|
429 |
+
},
|
430 |
+
"rms_norm_eps": 1e-06,
|
431 |
+
"rope_scaling": {
|
432 |
+
"beta_fast": 32,
|
433 |
+
"beta_slow": 1,
|
434 |
+
"factor": 40,
|
435 |
+
"mscale": 1.0,
|
436 |
+
"mscale_all_dim": 1.0,
|
437 |
+
"original_max_position_embeddings": 4096,
|
438 |
+
"type": "yarn"
|
439 |
+
},
|
440 |
+
"rope_theta": 10000,
|
441 |
+
"routed_scaling_factor": 2.5,
|
442 |
+
"scoring_func": "sigmoid",
|
443 |
+
"seq_aux": true,
|
444 |
+
"tie_word_embeddings": false,
|
445 |
+
"topk_group": 4,
|
446 |
+
"topk_method": "noaux_tc",
|
447 |
+
"torch_dtype": "bfloat16",
|
448 |
+
"transformers_version": "4.53.2",
|
449 |
+
"use_cache": true,
|
450 |
+
"v_head_dim": 128,
|
451 |
+
"vocab_size": 129280
|
452 |
+
}
|
configuration_deepseek.py
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.configuration_utils import PretrainedConfig
|
2 |
+
from transformers.utils import logging
|
3 |
+
|
4 |
+
logger = logging.get_logger(__name__)
|
5 |
+
|
6 |
+
DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
7 |
+
class DeepseekV3Config(PretrainedConfig):
|
8 |
+
r"""
|
9 |
+
This is the configuration class to store the configuration of a [`DeepseekV3Model`]. It is used to instantiate an DeepSeek
|
10 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
11 |
+
defaults will yield a similar configuration to that of the DeepSeek-V3.
|
12 |
+
|
13 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
14 |
+
documentation from [`PretrainedConfig`] for more information.
|
15 |
+
|
16 |
+
|
17 |
+
Args:
|
18 |
+
vocab_size (`int`, *optional*, defaults to 129280):
|
19 |
+
Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
|
20 |
+
`inputs_ids` passed when calling [`DeepseekV3Model`]
|
21 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
22 |
+
Dimension of the hidden representations.
|
23 |
+
intermediate_size (`int`, *optional*, defaults to 11008):
|
24 |
+
Dimension of the MLP representations.
|
25 |
+
moe_intermediate_size (`int`, *optional*, defaults to 1407):
|
26 |
+
Dimension of the MoE representations.
|
27 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
28 |
+
Number of hidden layers in the Transformer decoder.
|
29 |
+
num_nextn_predict_layers (`int`, *optional*, defaults to 1):
|
30 |
+
Number of nextn predict layers in the DeepSeekV3 Model.
|
31 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
32 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
33 |
+
n_shared_experts (`int`, *optional*, defaults to None):
|
34 |
+
Number of shared experts, None means dense model.
|
35 |
+
n_routed_experts (`int`, *optional*, defaults to None):
|
36 |
+
Number of routed experts, None means dense model.
|
37 |
+
routed_scaling_factor (`float`, *optional*, defaults to 1.0):
|
38 |
+
Scaling factor or routed experts.
|
39 |
+
topk_method (`str`, *optional*, defaults to `gready`):
|
40 |
+
Topk method used in routed gate.
|
41 |
+
n_group (`int`, *optional*, defaults to None):
|
42 |
+
Number of groups for routed experts.
|
43 |
+
topk_group (`int`, *optional*, defaults to None):
|
44 |
+
Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
|
45 |
+
num_experts_per_tok (`int`, *optional*, defaults to None):
|
46 |
+
Number of selected experts, None means dense model.
|
47 |
+
moe_layer_freq (`int`, *optional*, defaults to 1):
|
48 |
+
The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
|
49 |
+
first_k_dense_replace (`int`, *optional*, defaults to 0):
|
50 |
+
Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
|
51 |
+
\--k dense layers--/
|
52 |
+
norm_topk_prob (`bool`, *optional*, defaults to False):
|
53 |
+
Whether to normalize the weights of the routed experts.
|
54 |
+
scoring_func (`str`, *optional*, defaults to 'softmax'):
|
55 |
+
Method of computing expert weights.
|
56 |
+
aux_loss_alpha (`float`, *optional*, defaults to 0.001):
|
57 |
+
Auxiliary loss weight coefficient.
|
58 |
+
seq_aux = (`bool`, *optional*, defaults to True):
|
59 |
+
Whether to compute the auxiliary loss for each individual sample.
|
60 |
+
num_key_value_heads (`int`, *optional*):
|
61 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
62 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
63 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
64 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
65 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
66 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
67 |
+
`num_attention_heads`.
|
68 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
69 |
+
The non-linear activation function (function or string) in the decoder.
|
70 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
71 |
+
The maximum sequence length that this model might ever be used with.
|
72 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
73 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
74 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
75 |
+
The epsilon used by the rms normalization layers.
|
76 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
77 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
78 |
+
relevant if `config.is_decoder=True`.
|
79 |
+
pad_token_id (`int`, *optional*):
|
80 |
+
Padding token id.
|
81 |
+
bos_token_id (`int`, *optional*, defaults to 1):
|
82 |
+
Beginning of stream token id.
|
83 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
84 |
+
End of stream token id.
|
85 |
+
pretraining_tp (`int`, *optional*, defaults to 1):
|
86 |
+
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
|
87 |
+
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
88 |
+
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
89 |
+
issue](https://github.com/pytorch/pytorch/issues/76232).
|
90 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
91 |
+
Whether to tie weight embeddings
|
92 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
93 |
+
The base period of the RoPE embeddings.
|
94 |
+
rope_scaling (`Dict`, *optional*):
|
95 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
|
96 |
+
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
|
97 |
+
`{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
98 |
+
`max_position_embeddings` to the expected new maximum.
|
99 |
+
attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
|
100 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
101 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
102 |
+
The dropout ratio for the attention probabilities.
|
103 |
+
|
104 |
+
```python
|
105 |
+
>>> from transformers import DeepseekV3Model, DeepseekV3Config
|
106 |
+
|
107 |
+
>>> # Initializing a Deepseek-V3 style configuration
|
108 |
+
>>> configuration = DeepseekV3Config()
|
109 |
+
|
110 |
+
>>> # Accessing the model configuration
|
111 |
+
>>> configuration = model.config
|
112 |
+
```"""
|
113 |
+
|
114 |
+
model_type = "deepseek_v3"
|
115 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
116 |
+
|
117 |
+
def __init__(
|
118 |
+
self,
|
119 |
+
vocab_size=129280,
|
120 |
+
hidden_size=7168,
|
121 |
+
intermediate_size=18432,
|
122 |
+
moe_intermediate_size = 2048,
|
123 |
+
num_hidden_layers=61,
|
124 |
+
num_nextn_predict_layers=1,
|
125 |
+
num_attention_heads=128,
|
126 |
+
num_key_value_heads=128,
|
127 |
+
n_shared_experts = 1,
|
128 |
+
n_routed_experts = 256,
|
129 |
+
ep_size = 1,
|
130 |
+
routed_scaling_factor = 2.5,
|
131 |
+
kv_lora_rank = 512,
|
132 |
+
q_lora_rank = 1536,
|
133 |
+
qk_rope_head_dim = 64,
|
134 |
+
v_head_dim = 128,
|
135 |
+
qk_nope_head_dim = 128,
|
136 |
+
topk_method = 'noaux_tc',
|
137 |
+
n_group = 8,
|
138 |
+
topk_group = 4,
|
139 |
+
num_experts_per_tok = 8,
|
140 |
+
moe_layer_freq = 1,
|
141 |
+
first_k_dense_replace = 3,
|
142 |
+
norm_topk_prob = True,
|
143 |
+
scoring_func = 'sigmoid',
|
144 |
+
aux_loss_alpha = 0.001,
|
145 |
+
seq_aux = True,
|
146 |
+
hidden_act="silu",
|
147 |
+
max_position_embeddings=4096,
|
148 |
+
initializer_range=0.02,
|
149 |
+
rms_norm_eps=1e-6,
|
150 |
+
use_cache=True,
|
151 |
+
pad_token_id=None,
|
152 |
+
bos_token_id=0,
|
153 |
+
eos_token_id=1,
|
154 |
+
pretraining_tp=1,
|
155 |
+
tie_word_embeddings=False,
|
156 |
+
rope_theta=10000.0,
|
157 |
+
rope_scaling=None,
|
158 |
+
attention_bias=False,
|
159 |
+
attention_dropout=0.0,
|
160 |
+
**kwargs,
|
161 |
+
):
|
162 |
+
self.vocab_size = vocab_size
|
163 |
+
self.max_position_embeddings = max_position_embeddings
|
164 |
+
self.hidden_size = hidden_size
|
165 |
+
self.intermediate_size = intermediate_size
|
166 |
+
self.moe_intermediate_size = moe_intermediate_size
|
167 |
+
self.num_hidden_layers = num_hidden_layers
|
168 |
+
self.num_nextn_predict_layers = num_nextn_predict_layers
|
169 |
+
self.num_attention_heads = num_attention_heads
|
170 |
+
self.n_shared_experts = n_shared_experts
|
171 |
+
self.n_routed_experts = n_routed_experts
|
172 |
+
self.ep_size = ep_size
|
173 |
+
self.routed_scaling_factor = routed_scaling_factor
|
174 |
+
self.kv_lora_rank = kv_lora_rank
|
175 |
+
self.q_lora_rank = q_lora_rank
|
176 |
+
self.qk_rope_head_dim = qk_rope_head_dim
|
177 |
+
self.v_head_dim = v_head_dim
|
178 |
+
self.qk_nope_head_dim = qk_nope_head_dim
|
179 |
+
self.topk_method = topk_method
|
180 |
+
self.n_group = n_group
|
181 |
+
self.topk_group = topk_group
|
182 |
+
self.num_experts_per_tok = num_experts_per_tok
|
183 |
+
self.moe_layer_freq = moe_layer_freq
|
184 |
+
self.first_k_dense_replace = first_k_dense_replace
|
185 |
+
self.norm_topk_prob = norm_topk_prob
|
186 |
+
self.scoring_func = scoring_func
|
187 |
+
self.aux_loss_alpha = aux_loss_alpha
|
188 |
+
self.seq_aux = seq_aux
|
189 |
+
# for backward compatibility
|
190 |
+
if num_key_value_heads is None:
|
191 |
+
num_key_value_heads = num_attention_heads
|
192 |
+
|
193 |
+
self.num_key_value_heads = num_key_value_heads
|
194 |
+
self.hidden_act = hidden_act
|
195 |
+
self.initializer_range = initializer_range
|
196 |
+
self.rms_norm_eps = rms_norm_eps
|
197 |
+
self.pretraining_tp = pretraining_tp
|
198 |
+
self.use_cache = use_cache
|
199 |
+
self.rope_theta = rope_theta
|
200 |
+
self.rope_scaling = rope_scaling
|
201 |
+
self.attention_bias = attention_bias
|
202 |
+
self.attention_dropout = attention_dropout
|
203 |
+
|
204 |
+
super().__init__(
|
205 |
+
pad_token_id=pad_token_id,
|
206 |
+
bos_token_id=bos_token_id,
|
207 |
+
eos_token_id=eos_token_id,
|
208 |
+
tie_word_embeddings=tie_word_embeddings,
|
209 |
+
**kwargs,
|
210 |
+
)
|
generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 0,
|
4 |
+
"eos_token_id": 1,
|
5 |
+
"transformers_version": "4.53.2"
|
6 |
+
}
|
model-00001-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6f778638be1f70d723f39f8d06416fc0277a556def7f4290c31a579bbd215927
|
3 |
+
size 4995884768
|
model-00002-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf90557853cc8f54889dc60cad1c2b8bda4c059481a299825dc4fbf4e3c7fd77
|
3 |
+
size 4995052496
|
model-00003-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f2dbfb5bd3a393b94cc02e61147d15c9a6ec296592a1240ecd2eb54704149a7e
|
3 |
+
size 4999071368
|
model-00004-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d5e786f3f08201620f0ad6c447e98719965fbec4991c3fe873ca9f7117c94fc
|
3 |
+
size 4994943096
|
model-00005-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:899d0dcd20f37432d03f2307e38a9d2c4b7021ed59cb34ad72c1c4a442746ccf
|
3 |
+
size 4994943232
|
model-00006-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fa9ee4ab184279c388525635cdefdabccf486d34cfdd924f06376f648647f329
|
3 |
+
size 4994943456
|
model-00007-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d9b5c77354958773fabb9ce15c86aa26dbd30350c385daa61466fbc0e20dbdd
|
3 |
+
size 4999180624
|
model-00008-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a341f6029020f9d561f95350dfd37b2894f239ddf7cd2b67e14ccff839ac74ad
|
3 |
+
size 4994943096
|
model-00009-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fd57dce52649b06964a27e795df8fbe4b11f9cd3f26811a94a730d3f6c95a6b3
|
3 |
+
size 4994943096
|
model-00010-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44ee08146393c389692df3fe717e3baf0d3fa5ca8dbde21ae184486f7a818542
|
3 |
+
size 4994943720
|
model-00011-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9937f7d352e4cf22793923cc7952f049eb0c0480ba936946fac33ea7120cf9cc
|
3 |
+
size 4916044152
|
model-00012-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:57fef23f2ae5b6e10e6502d016ef26790472d7414ae8def07342aa98687757f9
|
3 |
+
size 5000091936
|
model-00013-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d923b18f6667b62ebdb4f54afc1d8bd9bec365378617855cfb2048bfbb8243b7
|
3 |
+
size 4994944296
|
model-00014-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cb531c293e31f51ae520e51481ede8a04fb5a73fc433e17ef07268b83f4b0b0a
|
3 |
+
size 4994944392
|
model-00015-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:91ba4f56d3a71deef0b16b48794a754ea6c0398caa00603c4cbfa3b0ba7e4cff
|
3 |
+
size 4994944648
|
model-00016-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1847dfb119d6ce1803d715b4eb1c95f916af1a657fb2be799a89e3ebfccb9698
|
3 |
+
size 4999181952
|
model-00017-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:48671bf382c2ed1d952cb15526e35c1ed04fa4554483c3db36dc44c5f8fc996b
|
3 |
+
size 4994944288
|
model-00018-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:474fa2a5eb81e632a9dcd1d9e3071e85ad5fb51bb203e90c1502463301b89380
|
3 |
+
size 4994944296
|
model-00019-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dde9bc93227e80d1210ce126977f86c3f1b48bc99b35a6485a4139c1eb862056
|
3 |
+
size 4994944536
|
model-00020-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4249fc283d60f7c5727781aa77cce363a0f8ebacbb0b83125d366ae50c952ead
|
3 |
+
size 4767862480
|
model-00021-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:62c0c1a130eb729eab491e8bc4c46ca7c796e9e0fb155f7ecf5e3e084b1c8783
|
3 |
+
size 5000091936
|
model-00022-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fb3e028c10344770cfcb020c1b7c2d3053743ad15f9f297718fc9176a1a22f14
|
3 |
+
size 4994944296
|
model-00023-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1a20bd7b41f3238c46a9d9d872883c0a3180b9f79b2fd9c85e8f858300565ade
|
3 |
+
size 4994944392
|
model-00024-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e2261c65a19665332be3dcb8e8f322fa62d6198e6c6a41d77fea41ea2ada3b2
|
3 |
+
size 4994944648
|
model-00025-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d421f67ac55b85a7e8d02679a654d1676e1aa26a09465489642df63419537870
|
3 |
+
size 4999181952
|
model-00026-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:185403d53bfc61c8806efc65d35bf7f88b9ab9eebf11fde869b2d1a10726a043
|
3 |
+
size 4994944288
|
model-00027-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:375af68c1da3733821f38049cf39f602b753cb41f777aaca07309468e5caeac0
|
3 |
+
size 4994944296
|
model-00028-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65210438552cb36f2c954c5812987b7545a5a9f88930d3d569bf6c9f864e5629
|
3 |
+
size 4994944536
|
model-00029-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e654e9ae8c58efb0089ab1b9c49de607b24644365dd520da016f991f320a1203
|
3 |
+
size 4767862480
|
model-00030-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:45b8db2d004cb1806bd9a6b5d4dec4c82133b035999a01ff907c0ae4f14a4b2b
|
3 |
+
size 5000091936
|
model-00031-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dc348bd54630faacd6f7e4f32a36e99d66640b9d84ddd59d99ba14c0d734d9a9
|
3 |
+
size 4994944296
|
model-00032-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ffdc7abe493ab218d163d498aa6f2332826470cba5ced44ec7206f7f4eb1a18f
|
3 |
+
size 4994944392
|
model-00033-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5072926a14a9210a3dbbff4824012ee7f72e45ea8f2029434a6558333dbeeb66
|
3 |
+
size 4994944648
|
model-00034-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b4aaba166a2355a804c565a77f1f0384b82e1566d05c0910a928db93f2d32adf
|
3 |
+
size 4999181952
|
model-00035-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2184d9b1ef4e82ae82609a1cbd7b92c7d83c69fc42c9749e93ca51464f329b2c
|
3 |
+
size 4994944288
|
model-00036-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c74b3b49cc4637777115b3d3bd9aedf91102e2413ab375a5265a5543f078ae98
|
3 |
+
size 4994944296
|
model-00037-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e9992c51438f70befaf876ff7c5b29ae8ebd413758b8c9dc5ac3d8130726f01
|
3 |
+
size 4994944536
|
model-00038-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a7dc244be1b918a896be399e86c1738d8c62f18c9fd04010be2531643c2b1571
|
3 |
+
size 4767862480
|
model-00039-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:30daa8ec577fb405af3d481ff4479764f024c495a82598b6740eaebc44b6aaea
|
3 |
+
size 5000091936
|
model-00040-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:21da904f8f8682bdafaf3efc9197648368e02a73f77e8315c1f819ce37382016
|
3 |
+
size 4994944296
|
model-00041-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6590565c74235c757ba7ac9c0f9d98eda5ee647d8968eeb096a30de47a53bf71
|
3 |
+
size 4994944392
|
model-00042-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27620f4c97f92604ed10dd766afaecd4cb4d81082bb4f7bd46c5a6d903dbd650
|
3 |
+
size 4994944648
|
model-00043-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ed07ef726be49e982a748a7c6d798f017f0678c2b421eda59fd0ba70e44b58f
|
3 |
+
size 4999181952
|
model-00044-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:de12ec03f4f1c74f1258e2a060e941e1a2b5d918aa49ed9124a7ef79f985f254
|
3 |
+
size 4994944288
|
model-00045-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d1bea77e71a772046628590c8599bde92e7b5b84278dc3d9604264ab8243b215
|
3 |
+
size 4994944296
|
model-00046-of-00076.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:992ecd8324e44ac79d35207d27b6c2324e15a9b30ccf8292af836e6d03b65e5d
|
3 |
+
size 4994944536
|