ekurtic commited on
Commit
d408d20
·
1 Parent(s): 0d195f6
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. README.md +186 -0
  3. config.json +103 -0
  4. configuration_deepseek.py +206 -0
  5. generation_config.json +9 -0
  6. model-00001-of-00048.safetensors +3 -0
  7. model-00002-of-00048.safetensors +3 -0
  8. model-00003-of-00048.safetensors +3 -0
  9. model-00004-of-00048.safetensors +3 -0
  10. model-00005-of-00048.safetensors +3 -0
  11. model-00006-of-00048.safetensors +3 -0
  12. model-00007-of-00048.safetensors +3 -0
  13. model-00008-of-00048.safetensors +3 -0
  14. model-00009-of-00048.safetensors +3 -0
  15. model-00010-of-00048.safetensors +3 -0
  16. model-00011-of-00048.safetensors +3 -0
  17. model-00012-of-00048.safetensors +3 -0
  18. model-00013-of-00048.safetensors +3 -0
  19. model-00014-of-00048.safetensors +3 -0
  20. model-00015-of-00048.safetensors +3 -0
  21. model-00016-of-00048.safetensors +3 -0
  22. model-00017-of-00048.safetensors +3 -0
  23. model-00018-of-00048.safetensors +3 -0
  24. model-00019-of-00048.safetensors +3 -0
  25. model-00020-of-00048.safetensors +3 -0
  26. model-00021-of-00048.safetensors +3 -0
  27. model-00022-of-00048.safetensors +3 -0
  28. model-00023-of-00048.safetensors +3 -0
  29. model-00024-of-00048.safetensors +3 -0
  30. model-00025-of-00048.safetensors +3 -0
  31. model-00026-of-00048.safetensors +3 -0
  32. model-00027-of-00048.safetensors +3 -0
  33. model-00028-of-00048.safetensors +3 -0
  34. model-00029-of-00048.safetensors +3 -0
  35. model-00030-of-00048.safetensors +3 -0
  36. model-00031-of-00048.safetensors +3 -0
  37. model-00032-of-00048.safetensors +3 -0
  38. model-00033-of-00048.safetensors +3 -0
  39. model-00034-of-00048.safetensors +3 -0
  40. model-00035-of-00048.safetensors +3 -0
  41. model-00036-of-00048.safetensors +3 -0
  42. model-00037-of-00048.safetensors +3 -0
  43. model-00038-of-00048.safetensors +3 -0
  44. model-00039-of-00048.safetensors +3 -0
  45. model-00040-of-00048.safetensors +3 -0
  46. model-00041-of-00048.safetensors +3 -0
  47. model-00042-of-00048.safetensors +3 -0
  48. model-00043-of-00048.safetensors +3 -0
  49. model-00044-of-00048.safetensors +3 -0
  50. model-00045-of-00048.safetensors +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - moe
6
+ - fp8
7
+ - vllm
8
+ license: other
9
+ license_name: deepseek
10
+ license_link: https://github.com/deepseek-ai/DeepSeek-V2/blob/main/LICENSE-MODEL
11
+ library_name: transformers
12
+ ---
13
+
14
+ # DeepSeek-V2.5-1210-FP8
15
+
16
+ ## Model Overview
17
+ - **Model Architecture:** DeepSeek-V2.5-1210
18
+ - **Input:** Text
19
+ - **Output:** Text
20
+ - **Model Optimizations:**
21
+ - **Weight quantization:** FP8
22
+ - **Activation quantization:** FP8
23
+ - **Release Date:** 3/1/2025
24
+ - **Version:** 1.0
25
+ - **Model Developers:** Neural Magic
26
+
27
+ Quantized version of [DeepSeek-V2.5-1210](https://huggingface.co/deepseek-ai/DeepSeek-V2.5-1210).
28
+ It achieves an average score of 77.8 on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) benchmark (version 1), whereas the unquantized model achieves 77.82.
29
+
30
+ ### Model Optimizations
31
+
32
+ This model was obtained by quantizing the weights and activations to FP8 data type, ready for inference with vLLM >= 0.5.2.
33
+ This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%. The weights and activations of the linear operators within transformers blocks are quantized, except the MLP routers.
34
+
35
+ ## Deployment
36
+
37
+ ### Use with vLLM
38
+
39
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer
43
+ from vllm import LLM, SamplingParams
44
+
45
+ max_model_len, tp_size = 4096, 4
46
+ model_name = "neuralmagic-ent/DeepSeek-V2.5-1210-FP8"
47
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
48
+ llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True)
49
+ sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])
50
+
51
+ messages_list = [
52
+ [{"role": "user", "content": "Who are you? Please respond in pirate speak!"}],
53
+ ]
54
+
55
+ prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]
56
+
57
+ outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)
58
+
59
+ generated_text = [output.outputs[0].text for output in outputs]
60
+ print(generated_text)
61
+ ```
62
+
63
+ vLLM also supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
64
+
65
+ ## Creation
66
+
67
+ This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below with the following command:
68
+
69
+ ```bash
70
+ python quantize.py --model_path deepseek-ai/DeepSeek-V2.5-1210 --quant_path "output_dir" --calib_size 128
71
+ ```
72
+
73
+
74
+ ```python
75
+ import argparse
76
+ from datasets import load_dataset
77
+ from transformers import AutoModelForCausalLM, AutoTokenizer
78
+ from llmcompressor.modifiers.quantization import QuantizationModifier
79
+ from llmcompressor.transformers import oneshot
80
+ from llmcompressor.transformers.compression.helpers import calculate_offload_device_map
81
+ import torch
82
+ import os
83
+
84
+
85
+ def main():
86
+ # Set up command line argument parsing
87
+ parser = argparse.ArgumentParser(description='Quantize a transformer model to FP8')
88
+ parser.add_argument('--model_id', type=str, required=True,
89
+ help='The model ID from HuggingFace (e.g., "meta-llama/Meta-Llama-3-8B-Instruct")')
90
+ parser.add_argument('--save_path', type=str, default='.',
91
+ help='Custom path to save the quantized model. If not provided, will use model_name-FP8')
92
+ parser.add_argument('--calib_size', type=int, default=256)
93
+ args = parser.parse_args()
94
+
95
+ device_map = calculate_offload_device_map(
96
+ args.model_id,
97
+ reserve_for_hessians=False,
98
+ num_gpus=torch.cuda.device_count(),
99
+ trust_remote_code=True,
100
+ torch_dtype=torch.bfloat16,
101
+ )
102
+
103
+ model = AutoModelForCausalLM.from_pretrained(
104
+ args.model_id, device_map=device_map, torch_dtype=torch.bfloat16, trust_remote_code=True,
105
+ )
106
+ tokenizer = AutoTokenizer.from_pretrained(args.model_id)
107
+
108
+ NUM_CALIBRATION_SAMPLES = args.calib_size
109
+ DATASET_ID = "garage-bAInd/Open-Platypus"
110
+ DATASET_SPLIT = "train"
111
+ ds = load_dataset(DATASET_ID, split=DATASET_SPLIT)
112
+ ds = ds.shuffle(seed=42).select(range(NUM_CALIBRATION_SAMPLES))
113
+
114
+ def preprocess(example):
115
+ concat_txt = example["instruction"] + "\n" + example["output"]
116
+ return {"text": concat_txt}
117
+
118
+ ds = ds.map(preprocess)
119
+
120
+ def tokenize(sample):
121
+ return tokenizer(
122
+ sample["text"],
123
+ padding=False,
124
+ truncation=False,
125
+ add_special_tokens=True,
126
+ )
127
+
128
+ ds = ds.map(tokenize, remove_columns=ds.column_names)
129
+
130
+ # Configure the quantization algorithm and scheme
131
+ recipe = QuantizationModifier(
132
+ targets="Linear", scheme="FP8", ignore=["lm_head", "re:.*\.mlp\.gate$"]
133
+ )
134
+
135
+ # Apply quantization
136
+ oneshot(
137
+ model=model,
138
+ dataset=ds,
139
+ recipe=recipe,
140
+ num_calibration_samples=args.calib_size
141
+ )
142
+
143
+ save_path = os.path.join(args.save_path, args.model_id.split("/")[1] + "-FP8")
144
+ os.makedirs(save_path, exist_ok=True)
145
+
146
+ # Save to disk in compressed-tensors format
147
+ model.save_pretrained(save_path, save_compressed=True, skip_compression_stats=True)
148
+ tokenizer.save_pretrained(save_path)
149
+ print(f"Model and tokenizer saved to: {save_path}")
150
+
151
+ if __name__ == "__main__":
152
+ main()
153
+ ```
154
+
155
+ ## Evaluation
156
+
157
+ The model was evaluated on OpenLLM Leaderboard [V1](https://huggingface.co/spaces/open-llm-leaderboard-old/open_llm_leaderboard) using the following command:
158
+
159
+ OpenLLM Leaderboard V1:
160
+ ```
161
+ lm_eval \
162
+ --model vllm \
163
+ --model_args pretrained="neuralmagic-ent/DeepSeek-V2.5-1210-FP8",dtype=auto,add_bos_token=True,max_model_len=4096,tensor_parallel_size=4,gpu_memory_utilization=0.8,enable_chunked_prefill=True,trust_remote_code=True \
164
+ --tasks openllm \
165
+ --write_out \
166
+ --batch_size auto \
167
+ --output_path output_dir \
168
+ --show_config
169
+ ```
170
+
171
+
172
+ ### Accuracy
173
+
174
+ #### OpenLLM Leaderboard V1 evaluation scores
175
+
176
+ | Metric | deepseek-ai/DeepSeek-V2.5-1210 | neuralmagic-ent/DeepSeek-V2.5-1210-FP8 |
177
+ |-----------------------------------------|:---------------------------------:|:-------------------------------------------:|
178
+ | ARC-Challenge (Acc-Norm, 25-shot) | 72.61 | 72.44 |
179
+ | GSM8K (Strict-Match, 5-shot) | 88.25 | 88.02 |
180
+ | HellaSwag (Acc-Norm, 10-shot) | 85.01 | 84.75 |
181
+ | MMLU (Acc, 5-shot) | 79.60 | 79.44 |
182
+ | TruthfulQA (MC2, 0-shot) | 57.18 | 57.53 |
183
+ | Winogrande (Acc, 5-shot) | 84.29 | 84.61 |
184
+ | **Average Score** | **77.82** | **77.80** |
185
+ | **Recovery** | **100.00** | **99.97** |
186
+
config.json ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "deepseek-ai/DeepSeek-V2.5-1210",
3
+ "architectures": [
4
+ "DeepseekV2ForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "auto_map": {
9
+ "AutoConfig": "deepseek-ai/DeepSeek-V2.5-1210--configuration_deepseek.DeepseekV2Config",
10
+ "AutoModel": "deepseek-ai/DeepSeek-V2.5-1210--modeling_deepseek.DeepseekV2Model",
11
+ "AutoModelForCausalLM": "deepseek-ai/DeepSeek-V2.5-1210--modeling_deepseek.DeepseekV2ForCausalLM"
12
+ },
13
+ "aux_loss_alpha": 0.001,
14
+ "bos_token_id": 100000,
15
+ "eos_token_id": 100001,
16
+ "ep_size": 1,
17
+ "first_k_dense_replace": 1,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 5120,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 12288,
22
+ "kv_lora_rank": 512,
23
+ "max_position_embeddings": 163840,
24
+ "model_type": "deepseek_v2",
25
+ "moe_intermediate_size": 1536,
26
+ "moe_layer_freq": 1,
27
+ "n_group": 8,
28
+ "n_routed_experts": 160,
29
+ "n_shared_experts": 2,
30
+ "norm_topk_prob": false,
31
+ "num_attention_heads": 128,
32
+ "num_experts_per_tok": 6,
33
+ "num_hidden_layers": 60,
34
+ "num_key_value_heads": 128,
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
+ "config_groups": {
41
+ "group_0": {
42
+ "input_activations": {
43
+ "actorder": null,
44
+ "block_structure": null,
45
+ "dynamic": false,
46
+ "group_size": null,
47
+ "num_bits": 8,
48
+ "observer": "minmax",
49
+ "observer_kwargs": {},
50
+ "strategy": "tensor",
51
+ "symmetric": true,
52
+ "type": "float"
53
+ },
54
+ "output_activations": null,
55
+ "targets": [
56
+ "Linear"
57
+ ],
58
+ "weights": {
59
+ "actorder": null,
60
+ "block_structure": null,
61
+ "dynamic": false,
62
+ "group_size": null,
63
+ "num_bits": 8,
64
+ "observer": "minmax",
65
+ "observer_kwargs": {},
66
+ "strategy": "tensor",
67
+ "symmetric": true,
68
+ "type": "float"
69
+ }
70
+ }
71
+ },
72
+ "format": "float-quantized",
73
+ "global_compression_ratio": 1.5935207871800965,
74
+ "ignore": [
75
+ "lm_head"
76
+ ],
77
+ "kv_cache_scheme": null,
78
+ "quant_method": "compressed-tensors",
79
+ "quantization_status": "compressed"
80
+ },
81
+ "rms_norm_eps": 1e-06,
82
+ "rope_scaling": {
83
+ "beta_fast": 32,
84
+ "beta_slow": 1,
85
+ "factor": 40,
86
+ "mscale": 1.0,
87
+ "mscale_all_dim": 1.0,
88
+ "original_max_position_embeddings": 4096,
89
+ "type": "yarn"
90
+ },
91
+ "rope_theta": 10000,
92
+ "routed_scaling_factor": 16.0,
93
+ "scoring_func": "softmax",
94
+ "seq_aux": true,
95
+ "tie_word_embeddings": false,
96
+ "topk_group": 3,
97
+ "topk_method": "group_limited_greedy",
98
+ "torch_dtype": "bfloat16",
99
+ "transformers_version": "4.46.2",
100
+ "use_cache": true,
101
+ "v_head_dim": 128,
102
+ "vocab_size": 102400
103
+ }
configuration_deepseek.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 DeepseekV2Config(PretrainedConfig):
8
+ r"""
9
+ This is the configuration class to store the configuration of a [`DeepseekV2Model`]. 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-V2.
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 102400):
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 [`DeepseekV2Model`]
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_attention_heads (`int`, *optional*, defaults to 32):
30
+ Number of attention heads for each attention layer in the Transformer decoder.
31
+ n_shared_experts (`int`, *optional*, defaults to None):
32
+ Number of shared experts, None means dense model.
33
+ n_routed_experts (`int`, *optional*, defaults to None):
34
+ Number of routed experts, None means dense model.
35
+ routed_scaling_factor (`float`, *optional*, defaults to 1.0):
36
+ Scaling factor or routed experts.
37
+ topk_method (`str`, *optional*, defaults to `gready`):
38
+ Topk method used in routed gate.
39
+ n_group (`int`, *optional*, defaults to None):
40
+ Number of groups for routed experts.
41
+ topk_group (`int`, *optional*, defaults to None):
42
+ Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
43
+ num_experts_per_tok (`int`, *optional*, defaults to None):
44
+ Number of selected experts, None means dense model.
45
+ moe_layer_freq (`int`, *optional*, defaults to 1):
46
+ The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
47
+ first_k_dense_replace (`int`, *optional*, defaults to 0):
48
+ Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
49
+ \--k dense layers--/
50
+ norm_topk_prob (`bool`, *optional*, defaults to False):
51
+ Whether to normalize the weights of the routed experts.
52
+ scoring_func (`str`, *optional*, defaults to 'softmax'):
53
+ Method of computing expert weights.
54
+ aux_loss_alpha (`float`, *optional*, defaults to 0.001):
55
+ Auxiliary loss weight coefficient.
56
+ seq_aux = (`bool`, *optional*, defaults to True):
57
+ Whether to compute the auxiliary loss for each individual sample.
58
+ num_key_value_heads (`int`, *optional*):
59
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
60
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
61
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
62
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
63
+ by meanpooling all the original heads within that group. For more details checkout [this
64
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
65
+ `num_attention_heads`.
66
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
67
+ The non-linear activation function (function or string) in the decoder.
68
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
69
+ The maximum sequence length that this model might ever be used with.
70
+ initializer_range (`float`, *optional*, defaults to 0.02):
71
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
72
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
73
+ The epsilon used by the rms normalization layers.
74
+ use_cache (`bool`, *optional*, defaults to `True`):
75
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
76
+ relevant if `config.is_decoder=True`.
77
+ pad_token_id (`int`, *optional*):
78
+ Padding token id.
79
+ bos_token_id (`int`, *optional*, defaults to 1):
80
+ Beginning of stream token id.
81
+ eos_token_id (`int`, *optional*, defaults to 2):
82
+ End of stream token id.
83
+ pretraining_tp (`int`, *optional*, defaults to 1):
84
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
85
+ document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
86
+ necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
87
+ issue](https://github.com/pytorch/pytorch/issues/76232).
88
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
89
+ Whether to tie weight embeddings
90
+ rope_theta (`float`, *optional*, defaults to 10000.0):
91
+ The base period of the RoPE embeddings.
92
+ rope_scaling (`Dict`, *optional*):
93
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
94
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
95
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
96
+ `max_position_embeddings` to the expected new maximum.
97
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
98
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
99
+ attention_dropout (`float`, *optional*, defaults to 0.0):
100
+ The dropout ratio for the attention probabilities.
101
+
102
+ ```python
103
+ >>> from transformers import DeepseekV2Model, DeepseekV2Config
104
+
105
+ >>> # Initializing a Deepseek-V2 style configuration
106
+ >>> configuration = DeepseekV2Config()
107
+
108
+ >>> # Accessing the model configuration
109
+ >>> configuration = model.config
110
+ ```"""
111
+
112
+ model_type = "deepseek_v2"
113
+ keys_to_ignore_at_inference = ["past_key_values"]
114
+
115
+ def __init__(
116
+ self,
117
+ vocab_size=102400,
118
+ hidden_size=4096,
119
+ intermediate_size=11008,
120
+ moe_intermediate_size = 1407,
121
+ num_hidden_layers=30,
122
+ num_attention_heads=32,
123
+ num_key_value_heads=32,
124
+ n_shared_experts = None,
125
+ n_routed_experts = None,
126
+ ep_size = 1,
127
+ routed_scaling_factor = 1.0,
128
+ kv_lora_rank = 512,
129
+ q_lora_rank = 1536,
130
+ qk_rope_head_dim = 64,
131
+ v_head_dim = 128,
132
+ qk_nope_head_dim = 128,
133
+ topk_method = 'gready',
134
+ n_group = None,
135
+ topk_group = None,
136
+ num_experts_per_tok = None,
137
+ moe_layer_freq = 1,
138
+ first_k_dense_replace = 0,
139
+ norm_topk_prob = False,
140
+ scoring_func = 'softmax',
141
+ aux_loss_alpha = 0.001,
142
+ seq_aux = True,
143
+ hidden_act="silu",
144
+ max_position_embeddings=2048,
145
+ initializer_range=0.02,
146
+ rms_norm_eps=1e-6,
147
+ use_cache=True,
148
+ pad_token_id=None,
149
+ bos_token_id=100000,
150
+ eos_token_id=100001,
151
+ pretraining_tp=1,
152
+ tie_word_embeddings=False,
153
+ rope_theta=10000.0,
154
+ rope_scaling=None,
155
+ attention_bias=False,
156
+ attention_dropout=0.0,
157
+ **kwargs,
158
+ ):
159
+ self.vocab_size = vocab_size
160
+ self.max_position_embeddings = max_position_embeddings
161
+ self.hidden_size = hidden_size
162
+ self.intermediate_size = intermediate_size
163
+ self.moe_intermediate_size = moe_intermediate_size
164
+ self.num_hidden_layers = num_hidden_layers
165
+ self.num_attention_heads = num_attention_heads
166
+ self.n_shared_experts = n_shared_experts
167
+ self.n_routed_experts = n_routed_experts
168
+ self.ep_size = ep_size
169
+ self.routed_scaling_factor = routed_scaling_factor
170
+ self.kv_lora_rank = kv_lora_rank
171
+ self.q_lora_rank = q_lora_rank
172
+ self.qk_rope_head_dim = qk_rope_head_dim
173
+ self.v_head_dim = v_head_dim
174
+ self.qk_nope_head_dim = qk_nope_head_dim
175
+ self.topk_method = topk_method
176
+ self.n_group = n_group
177
+ self.topk_group = topk_group
178
+ self.num_experts_per_tok = num_experts_per_tok
179
+ self.moe_layer_freq = moe_layer_freq
180
+ self.first_k_dense_replace = first_k_dense_replace
181
+ self.norm_topk_prob = norm_topk_prob
182
+ self.scoring_func = scoring_func
183
+ self.aux_loss_alpha = aux_loss_alpha
184
+ self.seq_aux = seq_aux
185
+ # for backward compatibility
186
+ if num_key_value_heads is None:
187
+ num_key_value_heads = num_attention_heads
188
+
189
+ self.num_key_value_heads = num_key_value_heads
190
+ self.hidden_act = hidden_act
191
+ self.initializer_range = initializer_range
192
+ self.rms_norm_eps = rms_norm_eps
193
+ self.pretraining_tp = pretraining_tp
194
+ self.use_cache = use_cache
195
+ self.rope_theta = rope_theta
196
+ self.rope_scaling = rope_scaling
197
+ self.attention_bias = attention_bias
198
+ self.attention_dropout = attention_dropout
199
+
200
+ super().__init__(
201
+ pad_token_id=pad_token_id,
202
+ bos_token_id=bos_token_id,
203
+ eos_token_id=eos_token_id,
204
+ tie_word_embeddings=tie_word_embeddings,
205
+ **kwargs,
206
+ )
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 100000,
4
+ "do_sample": true,
5
+ "eos_token_id": 100001,
6
+ "temperature": 0.3,
7
+ "top_p": 0.95,
8
+ "transformers_version": "4.46.2"
9
+ }
model-00001-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:471efd450dbaf240a96e7b629ed7fca399289842401d191fd8235aad4c56f9bc
3
+ size 4996270948
model-00002-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:febb24c8eeedcfbdd81de8f21a5fcdbab6a3e33f5d55b5902f1e968b00afe71e
3
+ size 4996995084
model-00003-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ceba9e82bcec6925a69301d0ebfc973e5223c024525dcb5ef3edbb1a535a32f4
3
+ size 4995531320
model-00004-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f92a71fb4c5b2d96e754ab0c946c851c69eaed494c887a49198fde06123f2da1
3
+ size 4995532432
model-00005-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83b3f4e4ee3ba09cbf8a6c4a5388a2fcc86558d5cf073187b535de2c722e1ca6
3
+ size 4995533784
model-00006-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:060507abc07620bd5fd073310e8ebd7aba6a06ce74576993f5b9a0201b58cfea
3
+ size 4996995156
model-00007-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3dc932ae56b3105bd8a43a33b68e2f999540bf5628932d6dd18768f152e8c936
3
+ size 4995531440
model-00008-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:32d895ff67b4fdb1374f7c50ce9285719e9211ed8deb4876716bed625cee4d6b
3
+ size 4995528376
model-00009-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd8b17a934b36e829a556634b468012e11039c36d4c265377deb37d2a1c70950
3
+ size 4995535760
model-00010-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ffb44a4397272bf232f452bb53e11a30e85c32f27825279fbe3bc64cfa4eb68b
3
+ size 4996997044
model-00011-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d9defe3ba8c87a6d26e97ad2f142ccd6dfd8d120dcfca027869eed98f1664a0
3
+ size 4995533416
model-00012-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18d58c3d5759bd5b2470183cd806cd29f061d1a060830ffa11ed1b7dd2b3dcd2
3
+ size 4995534624
model-00013-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be59946250c98d251b013440a9ca308675dfd263f000bc95bc81d9b4a6bacd6e
3
+ size 4989308980
model-00014-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e3033b15f660d78a88bc4654bb014870f40994a9c34280a93ca065adcdda24c
3
+ size 4995355444
model-00015-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:925610d291086e7c8d84902b471168c0818b64cf331cac1eaac0cb196e75cae8
3
+ size 4995533520
model-00016-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bff10dfd512f9ecd74b59d6d91594217458a33add32186f206b5cb4880d94a66
3
+ size 4995534776
model-00017-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40e81829b480b83b1cdb1261483707a6938ffd6241579fe825be45a35a1cd897
3
+ size 4960298320
model-00018-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c1afdd44953d34e57ccda71378f046e74eb8f17dd941fad994997cb5e6012ff1
3
+ size 4992907440
model-00019-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5079a7e235c7869da6923f473bd700629420593cd09f44d169d8f4e8cde73a79
3
+ size 4995533608
model-00020-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5748a36dbbbe35b962ac0c996c5227a2f379318230663a6c88eebdea38cf16b
3
+ size 4995534888
model-00021-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11e8127385d3f4d6fd9b315724bdf1d8be9c5e1a071f7a8b7fe74e16b1631af4
3
+ size 4996996668
model-00022-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb818c042d28bef33048a8b9d7a1eb5ab396da5023fc2f09691d7cc07096bc37
3
+ size 4995532608
model-00023-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec6202affe540725174ab2a56a0e58f775dc1241b8878a0555881a4afd88c1af
3
+ size 4995533728
model-00024-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19f61dc9d140b85898fd2a97ce5295e13694cc347b226a0bcdf496b6d5295293
3
+ size 4995535048
model-00025-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40c3d8be0bae69f051cf18242fa99e2d75c3a9029a4b0cf4316debc8d38597f2
3
+ size 4996996700
model-00026-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b69f67d0ed8be010d917cdd1eb182d183d9a92b41dc8cda914de2a7c15312f8
3
+ size 4995532768
model-00027-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7da5107606089e3dcbc99131d4538a57e7346887614ff00b2993f4cba0481269
3
+ size 4995533848
model-00028-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6311c9f449de8b3d8a51a589d9a618c990ddd8b478684cc2c9a959e87d7cfe81
3
+ size 4995535216
model-00029-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfdd18f1cb5a2c6ca21d5673b4e1670fd75403125f99267afa33615f4260e1d4
3
+ size 4996996740
model-00030-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d15cdb6444dfdcc91dd4c03f4ffb4b4338231f053655694ce097c1dcc722e0e
3
+ size 4995532920
model-00031-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97b1642e38d1b1d92b32d6e9e74485293006afa3bc693e48dbdaaf355fa6653c
3
+ size 4995533968
model-00032-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf6ff131bfcdb3a94b6ae9b6f6152062ba7bd827e66165fc96a662f5723fe67a
3
+ size 4995535384
model-00033-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:687be01abac467ecd8885fd89948b6db1db696ae49161242bc4056a0518d658a
3
+ size 4996996812
model-00034-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bdea5fe86b274b57dd8454ab336fd19ee472b3188d427266383bf7d40dab9a2
3
+ size 4995533040
model-00035-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa214be2566f4312368665b2905ac3dc7c9e36d2a7c012c214dd08a2bd5e61c9
3
+ size 4995534112
model-00036-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b512d4d93ee8dc486f7fb6bbb915dd161996e61d74910a236ac95ef4f3b2d4ae
3
+ size 4995535520
model-00037-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb9acfb4d5f521b8622c3409f398df6058ba2a1366e476d2de3899be8ece3cc5
3
+ size 4996996892
model-00038-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7870dcdf7213a0452758e2cc6d19c0b044f5b21f85e03fa6ccd74b889e1d2994
3
+ size 4995533160
model-00039-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6aef01efe0ece26a9f580f23558fec148e074d13947474504ff4ddfdfad182d1
3
+ size 4995534280
model-00040-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a3adaf1f40f88e16e4fb32addd394a5baabdc79c9504931cdd008c86a6ad814
3
+ size 4995535640
model-00041-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52eb4b203192e492f818df1c0f8799738dd9f111c807422c21507e7585d00ba1
3
+ size 4996996964
model-00042-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4c2b0593bfde92f235cd055fc0dd4feeda1461daab4bbbdf124e8ccfe6b5688
3
+ size 4995533280
model-00043-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b079797af051a2c71df213edf1e0007d35566351b4218a72c11a2d74728c800
3
+ size 4995534448
model-00044-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be5ffa4df53bc17884ce8ac6382395f114db2023ed2346b07b35b5487a97f708
3
+ size 4995535760
model-00045-of-00048.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8577db7dc2a002c3ac0c90c64d3d68b091a0ab395dd01d976e8ad93325a5d315
3
+ size 4996997044