killawhale2 commited on
Commit
de945d6
·
0 Parent(s):

Upload folder using huggingface_hub

Browse files
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Upstage Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ license_link: https://huggingface.co/upstage/solar-pro-preview-instruct/blob/main/LICENSE
4
+ language:
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - nlp
9
+ ---
10
+
11
+ <p align="left">
12
+ <a href="https://go.upstage.ai/3Xk9J6X">
13
+ <img src="https://huggingface.co/upstage/solar-pro-preview-instruct/resolve/main/solar-pro-banner.png" width="100%"/>
14
+ </a>
15
+ <p>
16
+
17
+ # **Solar Pro Preview: The most intelligent LLM on a single GPU**
18
+
19
+ # **Summary**
20
+
21
+ We introduce **Solar Pro Preview**, an advanced large language model (LLM) with 22 billion parameters designed to [fit into a single GPU](https://www.upstage.ai/products/solar-pro-preview?utm_source=%08platform&utm_medium=huggingface&utm_campaign=solarpro-preview-launch). Solar Pro Preview shows superior performance compared to LLMs with less than 30 billion parameters and delivers performance comparable to models over three times its size, such as Llama 3.1 with 70 billion parameters.
22
+
23
+ Solar Pro Preview is developed using an enhanced version of our previous depth up-scaling method, which scales a Phi-3-medium model with 14 billion parameters to 22 billion parameters, intended to run on a GPU with 80GB of VRAM. Our carefully curated training strategy and dataset have significantly enhanced performance from Phi-3-medium, particularly on the MMLU-Pro and IFEval benchmarks, both respected for evaluating a model’s knowledge and instruction-following abilities.
24
+
25
+ Solar Pro Preview is a pre-release version of the official Solar Pro, with limitations on language coverage and a maximum context length of 4K. However, we believe Solar Pro Preview not only stands out as a highly efficient and capable model, but has the potential to be further extended to cover more languages and capabilities. The official version of Solar Pro will be released this November 2024 with expanded language support beyond English and longer context windows. To stay informed about the latest updates, please sign up for [our mailing list](https://www.upstage.ai/get-upstage-updates). If you have any feedback or questions about the model, please visit our [model discussion board](https://huggingface.co/upstage/solar-pro-preview-instruct/discussions) and connect with us directly.
26
+
27
+ # **Usage**
28
+
29
+ Solar Pro Preview is an instruction-tuned language model. This model is specifically designed to follow instructions and engage in conversational tasks.
30
+
31
+ ### Chat Template
32
+
33
+ As an instruction-tuned model, Solar Pro Preview uses the ChatML template for optimal performance in conversational and instruction-following tasks. This approach aligns with the model's training data and is likely to yield more accurate and relevant responses. For instance, a question formatted in the ChatML template looks like the following, where the model generates the answer after <|im_start|>assistant. Solar Pro Preview does not thoroughly account for system prompts, which may result in the instruction in a system prompt being overlooked.
34
+
35
+ ```
36
+ <|im_start|>user
37
+ Please, introduce yourself.<|im_end|>
38
+ <|im_start|>assistant
39
+ ```
40
+
41
+ ### Text Generation
42
+
43
+ Below is an example inference code that details loading the model, applying the chat template, and generating the model answer.
44
+
45
+ ```python
46
+ # Install requirements
47
+ # !pip install transformers==4.44.2 torch==2.3.1 flash_attn==2.5.8 accelerate==0.31.0
48
+
49
+ # Load model
50
+ import torch
51
+ from transformers import AutoModelForCausalLM, AutoTokenizer
52
+ tokenizer = AutoTokenizer.from_pretrained("upstage/solar-pro-preview-instruct")
53
+ model = AutoModelForCausalLM.from_pretrained(
54
+ "upstage/solar-pro-preview-instruct",
55
+ device_map="cuda",
56
+ torch_dtype="auto",
57
+ trust_remote_code=True,
58
+ )
59
+ # Apply chat template
60
+ messages = [
61
+ {"role": "user", "content": "Please, introduce yourself."},
62
+ ]
63
+ prompt = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
64
+ # Generate text
65
+ outputs = model.generate(prompt, max_new_tokens=512)
66
+ print(tokenizer.decode(outputs[0]))
67
+ ```
68
+
69
+ Solar Pro Preview is also available as an API in [Upstage Console](https://go.upstage.ai/3Xl0Hqv) and we provide other easy-to-use methods as well. If you'd like to explore these options, please visit our [blog page](https://www.upstage.ai/products/solar-pro-preview?utm_source=%08platform&utm_medium=huggingface&utm_campaign=solarpro-preview-launch).
70
+
71
+
72
+ # **Evaluation**
73
+
74
+ Solar Pro Preview is evaluated over a variety of benchmarks.
75
+
76
+ | | Solar-pro-preview | Phi-3-medium-4K-instruct | Phi-3.5-MoE-instruct | Gemma 2 27B IT | Llama-3.1-8B-instruct | Llama-3.1-70B-instruct |
77
+ | ------------- | :---------------: | :----------------------: | :------------------: | :----------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |
78
+ | *Release Date* | 2024.09.08 | 2024.05.02 | 2024.08.20 | 2024.06.25 | 2024.06.18 | 2024.06.16 |
79
+ | *Model size* | 22B | 14B | 41.9B (6.6B) | 27B | 8B | 70B |
80
+ | *License* | MIT | MIT | MIT | [gemma](https://ai.google.dev/gemma/terms) | [llama3.1](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B/blob/main/LICENSE) | [llama3.1](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B/blob/main/LICENSE) |
81
+ | **MMLU** | 79.14 | 78.02 | 78.66 | 76.13 | 68.25 | 82.09 |
82
+ | **MMLU Pro** | 52.11 | 47.51 | 46.99 | 45.68 | 37.88 | 53.01 |
83
+ | **IFEval** | 84.37 | 64.37 | 69.15 | 75.36 | 77.40 | 84.13 |
84
+ | **ARC-C** | 68.86 | 66.55 | 68.34 | 74.06 | 60.24 | 70.39 |
85
+ | **GPQA** | 36.38 | 35.78 | 34.38 | 36.38 | 35.26 | 41.06 |
86
+ | **HellaSwag** | 86.36 | 85.68 | 85.97 | 86.02 | 80.08 | 86.42 |
87
+ | **EQBench** | 77.91 | 76.78 | 77.22 | 80.32 | 65.80 | 82.52 |
88
+ | **BigBench Hard** | 67.31 | 63.09 | 62.58 | 64.88 | 51.06 | 69.54 |
89
+ | **MUSR** | 45.85 | 42.28 | 46.79 | 45.67 | 29.68 | 47.22 |
90
+ | **GSM8K** | 89.69 | 84.76 | 82.26 | 62.85 | 75.97 | 92.12 |
91
+ | **MBPP** | 61.59 | 60.27 | N/A (\*) | 63.08 | 52.20 | 65.51 |
92
+
93
+ (*) Since the model tends to generate a chat template, the score can't be accurately determined.
94
+
95
+ ### Evaluation Protocol
96
+
97
+ For easy reproduction of our evaluation results, we list the evaluation tools and settings used below. All evaluations are conducted with NVIDIA DGX H100.
98
+
99
+ | | Evaluation setting | Metric | Evaluation tool |
100
+ | ------------- | :-------------------- | :------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
101
+ | MMLU | 5-shot | macro_avg / acc | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
102
+ | MMLU Pro | 5-shot | macro_avg / acc | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
103
+ | IFEval | 0-shot, chat_template | mean of prompt_level_strict_acc and instruction_level_strict_acc | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
104
+ | ARC-C | 25-shot | acc_norm | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
105
+ | GPQA | 0-shot | acc_norm | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
106
+ | HellaSwag | 10-shot | acc_norm | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
107
+ | EQBench | 0-shot, chat_template | eqbench score | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
108
+ | BigBench Hard | 3-shot | macro_avg / acc_norm | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
109
+ | MUSR | 0-shot | macro_avg / acc_norm | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
110
+ | GSM8K | 8-shot, CoT | acc, exact_match & strict_extract | [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/928e8bb6f50d1e93ef5d0bcaa81f8c5fd9a6f4d8) #928e8bb |
111
+ | MBPP | 0-shot | pass@1 | [bigcode-evaluation-harness](https://github.com/bigcode-project/bigcode-evaluation-harness/tree/0f3e95f0806e78a4f432056cdb1be93604a51d69) #0f3e95f |
112
+
113
+ The results may vary slightly for different batch sizes and experimental environment such as GPU type.
114
+
115
+ # **Contact us**
116
+
117
+ For any questions and suggestions regarding the model, please visit the [discussion board](https://huggingface.co/upstage/solar-pro-preview-instruct/discussions).
118
+
119
+ Learn more:
120
+
121
+ - [Chat with Solar Pro](https://chat.upstage.ai)
122
+ - [Solar Pro Preview developer documents](https://developers.upstage.ai/docs/apis/chat?utm_campaign=solarpro-preview-launch)
123
+
124
+ Also try out:
125
+
126
+ - [Document Parse](http://developers.upstage.ai/docs/apis/document-parse?utm_campaign=solarpro-preview-launch): An industry-leading model for converting complex document files to LLM-compatible HTML formats.
127
+ - [Solar DocVision Preview](http://developers.upstage.ai/docs/apis/document-qa?utm_campaign=solarpro-preview-launch): A vision LLM specialized on documents.
added_tokens.json ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "<|assistant|>": 32001,
3
+ "<|end|>": 32000,
4
+ "<|im_end|>": 32007,
5
+ "<|im_start|>": 32010,
6
+ "<|placeholder100|>": 32104,
7
+ "<|placeholder101|>": 32105,
8
+ "<|placeholder102|>": 32106,
9
+ "<|placeholder103|>": 32107,
10
+ "<|placeholder104|>": 32108,
11
+ "<|placeholder105|>": 32109,
12
+ "<|placeholder106|>": 32110,
13
+ "<|placeholder107|>": 32111,
14
+ "<|placeholder108|>": 32112,
15
+ "<|placeholder109|>": 32113,
16
+ "<|placeholder10|>": 32014,
17
+ "<|placeholder110|>": 32114,
18
+ "<|placeholder111|>": 32115,
19
+ "<|placeholder112|>": 32116,
20
+ "<|placeholder113|>": 32117,
21
+ "<|placeholder114|>": 32118,
22
+ "<|placeholder115|>": 32119,
23
+ "<|placeholder116|>": 32120,
24
+ "<|placeholder117|>": 32121,
25
+ "<|placeholder118|>": 32122,
26
+ "<|placeholder119|>": 32123,
27
+ "<|placeholder11|>": 32015,
28
+ "<|placeholder120|>": 32124,
29
+ "<|placeholder121|>": 32125,
30
+ "<|placeholder122|>": 32126,
31
+ "<|placeholder123|>": 32127,
32
+ "<|placeholder12|>": 32016,
33
+ "<|placeholder13|>": 32017,
34
+ "<|placeholder14|>": 32018,
35
+ "<|placeholder15|>": 32019,
36
+ "<|placeholder16|>": 32020,
37
+ "<|placeholder17|>": 32021,
38
+ "<|placeholder18|>": 32022,
39
+ "<|placeholder19|>": 32023,
40
+ "<|placeholder1|>": 32002,
41
+ "<|placeholder20|>": 32024,
42
+ "<|placeholder21|>": 32025,
43
+ "<|placeholder22|>": 32026,
44
+ "<|placeholder23|>": 32027,
45
+ "<|placeholder24|>": 32028,
46
+ "<|placeholder25|>": 32029,
47
+ "<|placeholder26|>": 32030,
48
+ "<|placeholder27|>": 32031,
49
+ "<|placeholder28|>": 32032,
50
+ "<|placeholder29|>": 32033,
51
+ "<|placeholder2|>": 32003,
52
+ "<|placeholder30|>": 32034,
53
+ "<|placeholder31|>": 32035,
54
+ "<|placeholder32|>": 32036,
55
+ "<|placeholder33|>": 32037,
56
+ "<|placeholder34|>": 32038,
57
+ "<|placeholder35|>": 32039,
58
+ "<|placeholder36|>": 32040,
59
+ "<|placeholder37|>": 32041,
60
+ "<|placeholder38|>": 32042,
61
+ "<|placeholder39|>": 32043,
62
+ "<|placeholder3|>": 32004,
63
+ "<|placeholder40|>": 32044,
64
+ "<|placeholder41|>": 32045,
65
+ "<|placeholder42|>": 32046,
66
+ "<|placeholder43|>": 32047,
67
+ "<|placeholder44|>": 32048,
68
+ "<|placeholder45|>": 32049,
69
+ "<|placeholder46|>": 32050,
70
+ "<|placeholder47|>": 32051,
71
+ "<|placeholder48|>": 32052,
72
+ "<|placeholder49|>": 32053,
73
+ "<|placeholder4|>": 32005,
74
+ "<|placeholder50|>": 32054,
75
+ "<|placeholder51|>": 32055,
76
+ "<|placeholder52|>": 32056,
77
+ "<|placeholder53|>": 32057,
78
+ "<|placeholder54|>": 32058,
79
+ "<|placeholder55|>": 32059,
80
+ "<|placeholder56|>": 32060,
81
+ "<|placeholder57|>": 32061,
82
+ "<|placeholder58|>": 32062,
83
+ "<|placeholder59|>": 32063,
84
+ "<|placeholder5|>": 32008,
85
+ "<|placeholder60|>": 32064,
86
+ "<|placeholder61|>": 32065,
87
+ "<|placeholder62|>": 32066,
88
+ "<|placeholder63|>": 32067,
89
+ "<|placeholder64|>": 32068,
90
+ "<|placeholder65|>": 32069,
91
+ "<|placeholder66|>": 32070,
92
+ "<|placeholder67|>": 32071,
93
+ "<|placeholder68|>": 32072,
94
+ "<|placeholder69|>": 32073,
95
+ "<|placeholder6|>": 32009,
96
+ "<|placeholder70|>": 32074,
97
+ "<|placeholder71|>": 32075,
98
+ "<|placeholder72|>": 32076,
99
+ "<|placeholder73|>": 32077,
100
+ "<|placeholder74|>": 32078,
101
+ "<|placeholder75|>": 32079,
102
+ "<|placeholder76|>": 32080,
103
+ "<|placeholder77|>": 32081,
104
+ "<|placeholder78|>": 32082,
105
+ "<|placeholder79|>": 32083,
106
+ "<|placeholder7|>": 32011,
107
+ "<|placeholder80|>": 32084,
108
+ "<|placeholder81|>": 32085,
109
+ "<|placeholder82|>": 32086,
110
+ "<|placeholder83|>": 32087,
111
+ "<|placeholder84|>": 32088,
112
+ "<|placeholder85|>": 32089,
113
+ "<|placeholder86|>": 32090,
114
+ "<|placeholder87|>": 32091,
115
+ "<|placeholder88|>": 32092,
116
+ "<|placeholder89|>": 32093,
117
+ "<|placeholder8|>": 32012,
118
+ "<|placeholder90|>": 32094,
119
+ "<|placeholder91|>": 32095,
120
+ "<|placeholder92|>": 32096,
121
+ "<|placeholder93|>": 32097,
122
+ "<|placeholder94|>": 32098,
123
+ "<|placeholder95|>": 32099,
124
+ "<|placeholder96|>": 32100,
125
+ "<|placeholder97|>": 32101,
126
+ "<|placeholder98|>": 32102,
127
+ "<|placeholder99|>": 32103,
128
+ "<|placeholder9|>": 32013,
129
+ "<|system|>": 32006
130
+ }
config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SolarForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_solar.SolarConfig",
9
+ "AutoModelForCausalLM": "modeling_solar.SolarForCausalLM"
10
+ },
11
+ "bos_token_id": 1,
12
+ "bskcn_1": [
13
+ 12,
14
+ 20,
15
+ 32,
16
+ 44
17
+ ],
18
+ "bskcn_2": [
19
+ 20,
20
+ 32
21
+ ],
22
+ "bskcn_3": [
23
+ 16,
24
+ 24,
25
+ 36,
26
+ 48
27
+ ],
28
+ "bskcn_4": [
29
+ 28,
30
+ 40
31
+ ],
32
+ "bskcn_tv": [
33
+ 0.9,
34
+ 0.8
35
+ ],
36
+ "eos_token_id": 32007,
37
+ "hidden_act": "silu",
38
+ "hidden_size": 5120,
39
+ "initializer_range": 0.02,
40
+ "intermediate_size": 17920,
41
+ "max_position_embeddings": 4096,
42
+ "mlp_bias": false,
43
+ "model_type": "solar",
44
+ "num_attention_heads": 40,
45
+ "num_hidden_layers": 64,
46
+ "num_key_value_heads": 10,
47
+ "pretraining_tp": 1,
48
+ "rms_norm_eps": 1e-05,
49
+ "rope_scaling": null,
50
+ "rope_theta": 10000.0,
51
+ "sliding_window": 2047,
52
+ "tie_word_embeddings": false,
53
+ "torch_dtype": "bfloat16",
54
+ "transformers_version": "4.44.2",
55
+ "use_cache": true,
56
+ "vocab_size": 32128
57
+ }
configuration_solar.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Solar model configuration"""
21
+
22
+ from transformers.configuration_utils import PretrainedConfig
23
+ from transformers.utils import logging
24
+
25
+
26
+ logger = logging.get_logger(__name__)
27
+
28
+
29
+ class SolarConfig(PretrainedConfig):
30
+ r"""
31
+ This is the configuration class to store the configuration of a [`SolarModel`]. It is used to instantiate an LLaMA
32
+ model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
33
+ defaults will yield a similar configuration to that of the LLaMA-7B.
34
+
35
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
36
+ documentation from [`PretrainedConfig`] for more information.
37
+
38
+
39
+ Args:
40
+ vocab_size (`int`, *optional*, defaults to 32000):
41
+ Vocabulary size of the LLaMA model. Defines the number of different tokens that can be represented by the
42
+ `inputs_ids` passed when calling [`SolarModel`]
43
+ hidden_size (`int`, *optional*, defaults to 4096):
44
+ Dimension of the hidden representations.
45
+ intermediate_size (`int`, *optional*, defaults to 11008):
46
+ Dimension of the MLP representations.
47
+ num_hidden_layers (`int`, *optional*, defaults to 32):
48
+ Number of hidden layers in the Transformer decoder.
49
+ num_attention_heads (`int`, *optional*, defaults to 32):
50
+ Number of attention heads for each attention layer in the Transformer decoder.
51
+ num_key_value_heads (`int`, *optional*):
52
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
53
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
54
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
55
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
56
+ by meanpooling all the original heads within that group. For more details checkout [this
57
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
58
+ `num_attention_heads`.
59
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
60
+ The non-linear activation function (function or string) in the decoder.
61
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
62
+ The maximum sequence length that this model might ever be used with. Solar 1 supports up to 2048 tokens,
63
+ Solar 2 up to 4096, CodeSolar up to 16384.
64
+ initializer_range (`float`, *optional*, defaults to 0.02):
65
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
66
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
67
+ The epsilon used by the rms normalization layers.
68
+ use_cache (`bool`, *optional*, defaults to `True`):
69
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
70
+ relevant if `config.is_decoder=True`.
71
+ pad_token_id (`int`, *optional*):
72
+ Padding token id.
73
+ bos_token_id (`int`, *optional*, defaults to 1):
74
+ Beginning of stream token id.
75
+ eos_token_id (`int`, *optional*, defaults to 2):
76
+ End of stream token id.
77
+ pretraining_tp (`int`, *optional*, defaults to 1):
78
+ Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
79
+ document](https://huggingface.co/docs/transformers/main/perf_train_gpu_many#tensor-parallelism) to understand more about it. This value is
80
+ necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
81
+ issue](https://github.com/pytorch/pytorch/issues/76232).
82
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
83
+ Whether to tie weight embeddings
84
+ rope_theta (`float`, *optional*, defaults to 10000.0):
85
+ The base period of the RoPE embeddings.
86
+ rope_scaling (`Dict`, *optional*):
87
+ Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
88
+ strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
89
+ `{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
90
+ `max_position_embeddings` to the expected new maximum. See the following thread for more information on how
91
+ these scaling strategies behave:
92
+ https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
93
+ experimental feature, subject to breaking API changes in future versions.
94
+ attention_bias (`bool`, *optional*, defaults to `False`):
95
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
96
+ attention_dropout (`float`, *optional*, defaults to 0.0):
97
+ The dropout ratio for the attention probabilities.
98
+ mlp_bias (`bool`, *optional*, defaults to `False`):
99
+ Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.
100
+ sliding_window (`int`, *optional*, defaults to 2047):
101
+ Sliding window attention window size. If not specified, will default to `2047`.
102
+
103
+ ```python
104
+ >>> from transformers import SolarModel, SolarConfig
105
+
106
+ >>> # Initializing a Solar-pro style configuration
107
+ >>> configuration = SolarConfig()
108
+
109
+ >>> # Initializing a model from the Solar-pro style configuration
110
+ >>> model = SolarModel(configuration)
111
+
112
+ >>> # Accessing the model configuration
113
+ >>> configuration = model.config
114
+ ```"""
115
+
116
+ model_type = "solar"
117
+ keys_to_ignore_at_inference = ["past_key_values"]
118
+
119
+ def __init__(
120
+ self,
121
+ vocab_size=32000,
122
+ hidden_size=4096,
123
+ intermediate_size=11008,
124
+ num_hidden_layers=32,
125
+ num_attention_heads=32,
126
+ num_key_value_heads=None,
127
+ hidden_act="silu",
128
+ max_position_embeddings=2048,
129
+ initializer_range=0.02,
130
+ rms_norm_eps=1e-6,
131
+ use_cache=True,
132
+ pad_token_id=None,
133
+ bos_token_id=1,
134
+ eos_token_id=2,
135
+ pretraining_tp=1,
136
+ tie_word_embeddings=False,
137
+ rope_theta=10000.0,
138
+ rope_scaling=None,
139
+ attention_bias=False,
140
+ attention_dropout=0.0,
141
+ mlp_bias=False,
142
+ sliding_window=2047,
143
+ bskcn_1=[12, 20, 32, 44],
144
+ bskcn_2=[20, 32],
145
+ bskcn_3=[16, 24, 36, 48],
146
+ bskcn_4=[28, 40],
147
+ bskcn_tv=[0.9,0.8],
148
+ **kwargs,
149
+ ):
150
+ self.vocab_size = vocab_size
151
+ self.max_position_embeddings = max_position_embeddings
152
+ self.hidden_size = hidden_size
153
+ self.intermediate_size = intermediate_size
154
+ self.num_hidden_layers = num_hidden_layers
155
+ self.num_attention_heads = num_attention_heads
156
+
157
+ # for backward compatibility
158
+ if num_key_value_heads is None:
159
+ num_key_value_heads = num_attention_heads
160
+
161
+ self.num_key_value_heads = num_key_value_heads
162
+ self.hidden_act = hidden_act
163
+ self.initializer_range = initializer_range
164
+ self.rms_norm_eps = rms_norm_eps
165
+ self.pretraining_tp = pretraining_tp
166
+ self.use_cache = use_cache
167
+ self.rope_theta = rope_theta
168
+ self.rope_scaling = rope_scaling
169
+ self._rope_scaling_validation()
170
+ self.attention_bias = attention_bias
171
+ self.attention_dropout = attention_dropout
172
+ self.mlp_bias = mlp_bias
173
+ self.sliding_window = sliding_window
174
+ self.bskcn_1 = bskcn_1
175
+ self.bskcn_2 = bskcn_2
176
+ self.bskcn_3 = bskcn_3
177
+ self.bskcn_4 = bskcn_4
178
+ self.bskcn_tv = bskcn_tv
179
+
180
+ super().__init__(
181
+ pad_token_id=pad_token_id,
182
+ bos_token_id=bos_token_id,
183
+ eos_token_id=eos_token_id,
184
+ tie_word_embeddings=tie_word_embeddings,
185
+ **kwargs,
186
+ )
187
+
188
+ def _rope_scaling_validation(self):
189
+ """
190
+ Validate the `rope_scaling` configuration.
191
+ """
192
+ if self.rope_scaling is None:
193
+ return
194
+
195
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
196
+ raise ValueError(
197
+ "`rope_scaling` must be a dictionary with two fields, `type` and `factor`, " f"got {self.rope_scaling}"
198
+ )
199
+ rope_scaling_type = self.rope_scaling.get("type", None)
200
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
201
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
202
+ raise ValueError(
203
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"
204
+ )
205
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
206
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": [
5
+ 2,
6
+ 32000,
7
+ 32007
8
+ ],
9
+ "use_cache": true,
10
+ "transformers_version": "4.44.2"
11
+ }
model-00001-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bce5ef2fe88dbf56e12271e674d40408d8884fbcd2878179904be71f8d311bfa
3
+ size 4916640672
model-00002-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8aeb0f191bfa0ff6a5316fcc99e817dfef70c7c7fcf1bf7423c1c0d0c145d7b3
3
+ size 4954693120
model-00003-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3565f2a2f9d6820f9457e6890bc0ed480786022fa023d0b5c69d5bcfc9e2ed7
3
+ size 4902243992
model-00004-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbb538fb3e865651a8243160df5ee1bd0dd7ab9f9e624bac2946a7d63e5b8d8c
3
+ size 4954672440
model-00005-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a93c34d1340d596ca741a2bf037ca3892b30e6166b745dd2f41d99de5309e08
3
+ size 4954672432
model-00006-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:813a5b5c0623d9fe090972c27e535147be0e76ebaaa3f90847dfaa02bded02b1
3
+ size 4954693144
model-00007-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4c5b2f4d811d8e1568b745382b532dc911ce905af109bdabd6357de55466b61
3
+ size 4902243992
model-00008-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3b715fd390c37b43bf91e280e89921ca056c5b28f028868f5790ef55a504943
3
+ size 4954672440
model-00009-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0af544234a1e6f6dcbf25323f848003b639df26e5d9892e87d59a67118f39a2a
3
+ size 4785599296
model.safetensors.index.json ADDED
@@ -0,0 +1,586 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 44280064000
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00009-of-00009.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00009.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00009.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
13
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
14
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
15
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
16
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
17
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00009.safetensors",
18
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
19
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
20
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
21
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
22
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
23
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
24
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
25
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
26
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00009.safetensors",
27
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
28
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
29
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
30
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
31
+ "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
32
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
33
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
34
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
35
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00009.safetensors",
36
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
37
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
38
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
39
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
40
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
41
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
42
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
43
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
44
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00009.safetensors",
45
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
46
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
47
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
48
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
49
+ "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
50
+ "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
51
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
52
+ "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
53
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00009.safetensors",
54
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
55
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
56
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
57
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
58
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
59
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
60
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
61
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
62
+ "model.layers.14.input_layernorm.weight": "model-00003-of-00009.safetensors",
63
+ "model.layers.14.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
64
+ "model.layers.14.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
65
+ "model.layers.14.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
66
+ "model.layers.14.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
67
+ "model.layers.14.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
68
+ "model.layers.14.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
69
+ "model.layers.14.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
70
+ "model.layers.14.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
71
+ "model.layers.15.input_layernorm.weight": "model-00003-of-00009.safetensors",
72
+ "model.layers.15.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
73
+ "model.layers.15.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
74
+ "model.layers.15.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
75
+ "model.layers.15.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
76
+ "model.layers.15.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
77
+ "model.layers.15.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
78
+ "model.layers.15.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
79
+ "model.layers.15.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
80
+ "model.layers.16.input_layernorm.weight": "model-00003-of-00009.safetensors",
81
+ "model.layers.16.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
82
+ "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
83
+ "model.layers.16.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
84
+ "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
85
+ "model.layers.16.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
86
+ "model.layers.16.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
87
+ "model.layers.16.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
88
+ "model.layers.16.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
89
+ "model.layers.17.input_layernorm.weight": "model-00003-of-00009.safetensors",
90
+ "model.layers.17.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
91
+ "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
92
+ "model.layers.17.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
93
+ "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
94
+ "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
95
+ "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
96
+ "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
97
+ "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
98
+ "model.layers.18.input_layernorm.weight": "model-00003-of-00009.safetensors",
99
+ "model.layers.18.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
100
+ "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
101
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
102
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
103
+ "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
104
+ "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
105
+ "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
106
+ "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
107
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00009.safetensors",
108
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
109
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
110
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
111
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
112
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
113
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
114
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
115
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
116
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00009.safetensors",
117
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
118
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
119
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
120
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
121
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
122
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
123
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
124
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
125
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00009.safetensors",
126
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00009.safetensors",
127
+ "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00009.safetensors",
128
+ "model.layers.20.mlp.up_proj.weight": "model-00003-of-00009.safetensors",
129
+ "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00009.safetensors",
130
+ "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
131
+ "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
132
+ "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
133
+ "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
134
+ "model.layers.21.input_layernorm.weight": "model-00004-of-00009.safetensors",
135
+ "model.layers.21.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
136
+ "model.layers.21.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
137
+ "model.layers.21.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
138
+ "model.layers.21.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
139
+ "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00009.safetensors",
140
+ "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00009.safetensors",
141
+ "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00009.safetensors",
142
+ "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00009.safetensors",
143
+ "model.layers.22.input_layernorm.weight": "model-00004-of-00009.safetensors",
144
+ "model.layers.22.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
145
+ "model.layers.22.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
146
+ "model.layers.22.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
147
+ "model.layers.22.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
148
+ "model.layers.22.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
149
+ "model.layers.22.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
150
+ "model.layers.22.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
151
+ "model.layers.22.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
152
+ "model.layers.23.input_layernorm.weight": "model-00004-of-00009.safetensors",
153
+ "model.layers.23.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
154
+ "model.layers.23.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
155
+ "model.layers.23.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
156
+ "model.layers.23.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
157
+ "model.layers.23.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
158
+ "model.layers.23.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
159
+ "model.layers.23.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
160
+ "model.layers.23.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
161
+ "model.layers.24.input_layernorm.weight": "model-00004-of-00009.safetensors",
162
+ "model.layers.24.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
163
+ "model.layers.24.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
164
+ "model.layers.24.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
165
+ "model.layers.24.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
166
+ "model.layers.24.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
167
+ "model.layers.24.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
168
+ "model.layers.24.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
169
+ "model.layers.24.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
170
+ "model.layers.25.input_layernorm.weight": "model-00004-of-00009.safetensors",
171
+ "model.layers.25.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
172
+ "model.layers.25.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
173
+ "model.layers.25.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
174
+ "model.layers.25.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
175
+ "model.layers.25.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
176
+ "model.layers.25.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
177
+ "model.layers.25.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
178
+ "model.layers.25.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
179
+ "model.layers.26.input_layernorm.weight": "model-00004-of-00009.safetensors",
180
+ "model.layers.26.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
181
+ "model.layers.26.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
182
+ "model.layers.26.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
183
+ "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
184
+ "model.layers.26.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
185
+ "model.layers.26.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
186
+ "model.layers.26.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
187
+ "model.layers.26.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
188
+ "model.layers.27.input_layernorm.weight": "model-00004-of-00009.safetensors",
189
+ "model.layers.27.mlp.down_proj.weight": "model-00004-of-00009.safetensors",
190
+ "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
191
+ "model.layers.27.mlp.up_proj.weight": "model-00004-of-00009.safetensors",
192
+ "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00009.safetensors",
193
+ "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
194
+ "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
195
+ "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
196
+ "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
197
+ "model.layers.28.input_layernorm.weight": "model-00005-of-00009.safetensors",
198
+ "model.layers.28.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
199
+ "model.layers.28.mlp.gate_proj.weight": "model-00004-of-00009.safetensors",
200
+ "model.layers.28.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
201
+ "model.layers.28.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
202
+ "model.layers.28.self_attn.k_proj.weight": "model-00004-of-00009.safetensors",
203
+ "model.layers.28.self_attn.o_proj.weight": "model-00004-of-00009.safetensors",
204
+ "model.layers.28.self_attn.q_proj.weight": "model-00004-of-00009.safetensors",
205
+ "model.layers.28.self_attn.v_proj.weight": "model-00004-of-00009.safetensors",
206
+ "model.layers.29.input_layernorm.weight": "model-00005-of-00009.safetensors",
207
+ "model.layers.29.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
208
+ "model.layers.29.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
209
+ "model.layers.29.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
210
+ "model.layers.29.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
211
+ "model.layers.29.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
212
+ "model.layers.29.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
213
+ "model.layers.29.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
214
+ "model.layers.29.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
215
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00009.safetensors",
216
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
217
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
218
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
219
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
220
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
221
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
222
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
223
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
224
+ "model.layers.30.input_layernorm.weight": "model-00005-of-00009.safetensors",
225
+ "model.layers.30.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
226
+ "model.layers.30.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
227
+ "model.layers.30.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
228
+ "model.layers.30.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
229
+ "model.layers.30.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
230
+ "model.layers.30.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
231
+ "model.layers.30.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
232
+ "model.layers.30.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
233
+ "model.layers.31.input_layernorm.weight": "model-00005-of-00009.safetensors",
234
+ "model.layers.31.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
235
+ "model.layers.31.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
236
+ "model.layers.31.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
237
+ "model.layers.31.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
238
+ "model.layers.31.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
239
+ "model.layers.31.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
240
+ "model.layers.31.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
241
+ "model.layers.31.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
242
+ "model.layers.32.input_layernorm.weight": "model-00005-of-00009.safetensors",
243
+ "model.layers.32.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
244
+ "model.layers.32.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
245
+ "model.layers.32.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
246
+ "model.layers.32.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
247
+ "model.layers.32.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
248
+ "model.layers.32.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
249
+ "model.layers.32.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
250
+ "model.layers.32.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
251
+ "model.layers.33.input_layernorm.weight": "model-00005-of-00009.safetensors",
252
+ "model.layers.33.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
253
+ "model.layers.33.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
254
+ "model.layers.33.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
255
+ "model.layers.33.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
256
+ "model.layers.33.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
257
+ "model.layers.33.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
258
+ "model.layers.33.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
259
+ "model.layers.33.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
260
+ "model.layers.34.input_layernorm.weight": "model-00005-of-00009.safetensors",
261
+ "model.layers.34.mlp.down_proj.weight": "model-00005-of-00009.safetensors",
262
+ "model.layers.34.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
263
+ "model.layers.34.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
264
+ "model.layers.34.post_attention_layernorm.weight": "model-00005-of-00009.safetensors",
265
+ "model.layers.34.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
266
+ "model.layers.34.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
267
+ "model.layers.34.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
268
+ "model.layers.34.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
269
+ "model.layers.35.input_layernorm.weight": "model-00006-of-00009.safetensors",
270
+ "model.layers.35.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
271
+ "model.layers.35.mlp.gate_proj.weight": "model-00005-of-00009.safetensors",
272
+ "model.layers.35.mlp.up_proj.weight": "model-00005-of-00009.safetensors",
273
+ "model.layers.35.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
274
+ "model.layers.35.self_attn.k_proj.weight": "model-00005-of-00009.safetensors",
275
+ "model.layers.35.self_attn.o_proj.weight": "model-00005-of-00009.safetensors",
276
+ "model.layers.35.self_attn.q_proj.weight": "model-00005-of-00009.safetensors",
277
+ "model.layers.35.self_attn.v_proj.weight": "model-00005-of-00009.safetensors",
278
+ "model.layers.36.input_layernorm.weight": "model-00006-of-00009.safetensors",
279
+ "model.layers.36.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
280
+ "model.layers.36.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
281
+ "model.layers.36.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
282
+ "model.layers.36.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
283
+ "model.layers.36.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
284
+ "model.layers.36.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
285
+ "model.layers.36.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
286
+ "model.layers.36.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
287
+ "model.layers.37.input_layernorm.weight": "model-00006-of-00009.safetensors",
288
+ "model.layers.37.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
289
+ "model.layers.37.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
290
+ "model.layers.37.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
291
+ "model.layers.37.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
292
+ "model.layers.37.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
293
+ "model.layers.37.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
294
+ "model.layers.37.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
295
+ "model.layers.37.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
296
+ "model.layers.38.input_layernorm.weight": "model-00006-of-00009.safetensors",
297
+ "model.layers.38.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
298
+ "model.layers.38.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
299
+ "model.layers.38.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
300
+ "model.layers.38.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
301
+ "model.layers.38.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
302
+ "model.layers.38.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
303
+ "model.layers.38.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
304
+ "model.layers.38.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
305
+ "model.layers.39.input_layernorm.weight": "model-00006-of-00009.safetensors",
306
+ "model.layers.39.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
307
+ "model.layers.39.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
308
+ "model.layers.39.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
309
+ "model.layers.39.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
310
+ "model.layers.39.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
311
+ "model.layers.39.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
312
+ "model.layers.39.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
313
+ "model.layers.39.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
314
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00009.safetensors",
315
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
316
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
317
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
318
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
319
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
320
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
321
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
322
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
323
+ "model.layers.40.input_layernorm.weight": "model-00006-of-00009.safetensors",
324
+ "model.layers.40.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
325
+ "model.layers.40.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
326
+ "model.layers.40.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
327
+ "model.layers.40.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
328
+ "model.layers.40.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
329
+ "model.layers.40.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
330
+ "model.layers.40.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
331
+ "model.layers.40.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
332
+ "model.layers.41.input_layernorm.weight": "model-00006-of-00009.safetensors",
333
+ "model.layers.41.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
334
+ "model.layers.41.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
335
+ "model.layers.41.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
336
+ "model.layers.41.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
337
+ "model.layers.41.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
338
+ "model.layers.41.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
339
+ "model.layers.41.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
340
+ "model.layers.41.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
341
+ "model.layers.42.input_layernorm.weight": "model-00006-of-00009.safetensors",
342
+ "model.layers.42.mlp.down_proj.weight": "model-00006-of-00009.safetensors",
343
+ "model.layers.42.mlp.gate_proj.weight": "model-00006-of-00009.safetensors",
344
+ "model.layers.42.mlp.up_proj.weight": "model-00006-of-00009.safetensors",
345
+ "model.layers.42.post_attention_layernorm.weight": "model-00006-of-00009.safetensors",
346
+ "model.layers.42.self_attn.k_proj.weight": "model-00006-of-00009.safetensors",
347
+ "model.layers.42.self_attn.o_proj.weight": "model-00006-of-00009.safetensors",
348
+ "model.layers.42.self_attn.q_proj.weight": "model-00006-of-00009.safetensors",
349
+ "model.layers.42.self_attn.v_proj.weight": "model-00006-of-00009.safetensors",
350
+ "model.layers.43.input_layernorm.weight": "model-00007-of-00009.safetensors",
351
+ "model.layers.43.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
352
+ "model.layers.43.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
353
+ "model.layers.43.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
354
+ "model.layers.43.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
355
+ "model.layers.43.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
356
+ "model.layers.43.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
357
+ "model.layers.43.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
358
+ "model.layers.43.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
359
+ "model.layers.44.input_layernorm.weight": "model-00007-of-00009.safetensors",
360
+ "model.layers.44.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
361
+ "model.layers.44.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
362
+ "model.layers.44.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
363
+ "model.layers.44.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
364
+ "model.layers.44.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
365
+ "model.layers.44.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
366
+ "model.layers.44.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
367
+ "model.layers.44.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
368
+ "model.layers.45.input_layernorm.weight": "model-00007-of-00009.safetensors",
369
+ "model.layers.45.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
370
+ "model.layers.45.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
371
+ "model.layers.45.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
372
+ "model.layers.45.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
373
+ "model.layers.45.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
374
+ "model.layers.45.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
375
+ "model.layers.45.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
376
+ "model.layers.45.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
377
+ "model.layers.46.input_layernorm.weight": "model-00007-of-00009.safetensors",
378
+ "model.layers.46.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
379
+ "model.layers.46.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
380
+ "model.layers.46.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
381
+ "model.layers.46.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
382
+ "model.layers.46.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
383
+ "model.layers.46.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
384
+ "model.layers.46.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
385
+ "model.layers.46.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
386
+ "model.layers.47.input_layernorm.weight": "model-00007-of-00009.safetensors",
387
+ "model.layers.47.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
388
+ "model.layers.47.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
389
+ "model.layers.47.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
390
+ "model.layers.47.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
391
+ "model.layers.47.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
392
+ "model.layers.47.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
393
+ "model.layers.47.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
394
+ "model.layers.47.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
395
+ "model.layers.48.input_layernorm.weight": "model-00007-of-00009.safetensors",
396
+ "model.layers.48.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
397
+ "model.layers.48.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
398
+ "model.layers.48.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
399
+ "model.layers.48.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
400
+ "model.layers.48.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
401
+ "model.layers.48.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
402
+ "model.layers.48.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
403
+ "model.layers.48.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
404
+ "model.layers.49.input_layernorm.weight": "model-00007-of-00009.safetensors",
405
+ "model.layers.49.mlp.down_proj.weight": "model-00007-of-00009.safetensors",
406
+ "model.layers.49.mlp.gate_proj.weight": "model-00007-of-00009.safetensors",
407
+ "model.layers.49.mlp.up_proj.weight": "model-00007-of-00009.safetensors",
408
+ "model.layers.49.post_attention_layernorm.weight": "model-00007-of-00009.safetensors",
409
+ "model.layers.49.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
410
+ "model.layers.49.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
411
+ "model.layers.49.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
412
+ "model.layers.49.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
413
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00009.safetensors",
414
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00009.safetensors",
415
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
416
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
417
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00009.safetensors",
418
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
419
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
420
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
421
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
422
+ "model.layers.50.input_layernorm.weight": "model-00008-of-00009.safetensors",
423
+ "model.layers.50.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
424
+ "model.layers.50.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
425
+ "model.layers.50.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
426
+ "model.layers.50.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
427
+ "model.layers.50.self_attn.k_proj.weight": "model-00007-of-00009.safetensors",
428
+ "model.layers.50.self_attn.o_proj.weight": "model-00007-of-00009.safetensors",
429
+ "model.layers.50.self_attn.q_proj.weight": "model-00007-of-00009.safetensors",
430
+ "model.layers.50.self_attn.v_proj.weight": "model-00007-of-00009.safetensors",
431
+ "model.layers.51.input_layernorm.weight": "model-00008-of-00009.safetensors",
432
+ "model.layers.51.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
433
+ "model.layers.51.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
434
+ "model.layers.51.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
435
+ "model.layers.51.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
436
+ "model.layers.51.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
437
+ "model.layers.51.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
438
+ "model.layers.51.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
439
+ "model.layers.51.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
440
+ "model.layers.52.input_layernorm.weight": "model-00008-of-00009.safetensors",
441
+ "model.layers.52.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
442
+ "model.layers.52.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
443
+ "model.layers.52.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
444
+ "model.layers.52.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
445
+ "model.layers.52.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
446
+ "model.layers.52.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
447
+ "model.layers.52.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
448
+ "model.layers.52.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
449
+ "model.layers.53.input_layernorm.weight": "model-00008-of-00009.safetensors",
450
+ "model.layers.53.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
451
+ "model.layers.53.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
452
+ "model.layers.53.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
453
+ "model.layers.53.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
454
+ "model.layers.53.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
455
+ "model.layers.53.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
456
+ "model.layers.53.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
457
+ "model.layers.53.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
458
+ "model.layers.54.input_layernorm.weight": "model-00008-of-00009.safetensors",
459
+ "model.layers.54.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
460
+ "model.layers.54.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
461
+ "model.layers.54.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
462
+ "model.layers.54.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
463
+ "model.layers.54.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
464
+ "model.layers.54.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
465
+ "model.layers.54.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
466
+ "model.layers.54.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
467
+ "model.layers.55.input_layernorm.weight": "model-00008-of-00009.safetensors",
468
+ "model.layers.55.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
469
+ "model.layers.55.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
470
+ "model.layers.55.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
471
+ "model.layers.55.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
472
+ "model.layers.55.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
473
+ "model.layers.55.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
474
+ "model.layers.55.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
475
+ "model.layers.55.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
476
+ "model.layers.56.input_layernorm.weight": "model-00008-of-00009.safetensors",
477
+ "model.layers.56.mlp.down_proj.weight": "model-00008-of-00009.safetensors",
478
+ "model.layers.56.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
479
+ "model.layers.56.mlp.up_proj.weight": "model-00008-of-00009.safetensors",
480
+ "model.layers.56.post_attention_layernorm.weight": "model-00008-of-00009.safetensors",
481
+ "model.layers.56.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
482
+ "model.layers.56.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
483
+ "model.layers.56.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
484
+ "model.layers.56.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
485
+ "model.layers.57.input_layernorm.weight": "model-00009-of-00009.safetensors",
486
+ "model.layers.57.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
487
+ "model.layers.57.mlp.gate_proj.weight": "model-00008-of-00009.safetensors",
488
+ "model.layers.57.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
489
+ "model.layers.57.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
490
+ "model.layers.57.self_attn.k_proj.weight": "model-00008-of-00009.safetensors",
491
+ "model.layers.57.self_attn.o_proj.weight": "model-00008-of-00009.safetensors",
492
+ "model.layers.57.self_attn.q_proj.weight": "model-00008-of-00009.safetensors",
493
+ "model.layers.57.self_attn.v_proj.weight": "model-00008-of-00009.safetensors",
494
+ "model.layers.58.input_layernorm.weight": "model-00009-of-00009.safetensors",
495
+ "model.layers.58.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
496
+ "model.layers.58.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
497
+ "model.layers.58.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
498
+ "model.layers.58.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
499
+ "model.layers.58.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
500
+ "model.layers.58.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
501
+ "model.layers.58.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
502
+ "model.layers.58.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
503
+ "model.layers.59.input_layernorm.weight": "model-00009-of-00009.safetensors",
504
+ "model.layers.59.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
505
+ "model.layers.59.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
506
+ "model.layers.59.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
507
+ "model.layers.59.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
508
+ "model.layers.59.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
509
+ "model.layers.59.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
510
+ "model.layers.59.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
511
+ "model.layers.59.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
512
+ "model.layers.6.input_layernorm.weight": "model-00002-of-00009.safetensors",
513
+ "model.layers.6.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
514
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00009.safetensors",
515
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00009.safetensors",
516
+ "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
517
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00009.safetensors",
518
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00009.safetensors",
519
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00009.safetensors",
520
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00009.safetensors",
521
+ "model.layers.60.input_layernorm.weight": "model-00009-of-00009.safetensors",
522
+ "model.layers.60.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
523
+ "model.layers.60.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
524
+ "model.layers.60.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
525
+ "model.layers.60.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
526
+ "model.layers.60.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
527
+ "model.layers.60.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
528
+ "model.layers.60.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
529
+ "model.layers.60.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
530
+ "model.layers.61.input_layernorm.weight": "model-00009-of-00009.safetensors",
531
+ "model.layers.61.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
532
+ "model.layers.61.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
533
+ "model.layers.61.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
534
+ "model.layers.61.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
535
+ "model.layers.61.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
536
+ "model.layers.61.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
537
+ "model.layers.61.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
538
+ "model.layers.61.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
539
+ "model.layers.62.input_layernorm.weight": "model-00009-of-00009.safetensors",
540
+ "model.layers.62.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
541
+ "model.layers.62.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
542
+ "model.layers.62.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
543
+ "model.layers.62.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
544
+ "model.layers.62.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
545
+ "model.layers.62.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
546
+ "model.layers.62.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
547
+ "model.layers.62.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
548
+ "model.layers.63.input_layernorm.weight": "model-00009-of-00009.safetensors",
549
+ "model.layers.63.mlp.down_proj.weight": "model-00009-of-00009.safetensors",
550
+ "model.layers.63.mlp.gate_proj.weight": "model-00009-of-00009.safetensors",
551
+ "model.layers.63.mlp.up_proj.weight": "model-00009-of-00009.safetensors",
552
+ "model.layers.63.post_attention_layernorm.weight": "model-00009-of-00009.safetensors",
553
+ "model.layers.63.self_attn.k_proj.weight": "model-00009-of-00009.safetensors",
554
+ "model.layers.63.self_attn.o_proj.weight": "model-00009-of-00009.safetensors",
555
+ "model.layers.63.self_attn.q_proj.weight": "model-00009-of-00009.safetensors",
556
+ "model.layers.63.self_attn.v_proj.weight": "model-00009-of-00009.safetensors",
557
+ "model.layers.7.input_layernorm.weight": "model-00002-of-00009.safetensors",
558
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
559
+ "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
560
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
561
+ "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
562
+ "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
563
+ "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
564
+ "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
565
+ "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
566
+ "model.layers.8.input_layernorm.weight": "model-00002-of-00009.safetensors",
567
+ "model.layers.8.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
568
+ "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
569
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
570
+ "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
571
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
572
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
573
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
574
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
575
+ "model.layers.9.input_layernorm.weight": "model-00002-of-00009.safetensors",
576
+ "model.layers.9.mlp.down_proj.weight": "model-00002-of-00009.safetensors",
577
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00009.safetensors",
578
+ "model.layers.9.mlp.up_proj.weight": "model-00002-of-00009.safetensors",
579
+ "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00009.safetensors",
580
+ "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00009.safetensors",
581
+ "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00009.safetensors",
582
+ "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00009.safetensors",
583
+ "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00009.safetensors",
584
+ "model.norm.weight": "model-00009-of-00009.safetensors"
585
+ }
586
+ }
modeling_solar.py ADDED
@@ -0,0 +1,1745 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Solar model."""
21
+ import math
22
+ from typing import List, Optional, Tuple, Union
23
+
24
+ import torch
25
+ import torch.nn.functional as F
26
+ import torch.utils.checkpoint
27
+ from torch import nn
28
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
29
+
30
+ from transformers.activations import ACT2FN
31
+ from transformers.cache_utils import Cache, DynamicCache, SlidingWindowCache, StaticCache
32
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
33
+ from transformers.modeling_outputs import (
34
+ BaseModelOutputWithPast,
35
+ CausalLMOutputWithPast,
36
+ QuestionAnsweringModelOutput,
37
+ SequenceClassifierOutputWithPast,
38
+ TokenClassifierOutput,
39
+ )
40
+ from transformers.modeling_utils import PreTrainedModel
41
+ from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
42
+ from transformers.utils import (
43
+ add_start_docstrings,
44
+ add_start_docstrings_to_model_forward,
45
+ is_flash_attn_2_available,
46
+ is_flash_attn_greater_or_equal_2_10,
47
+ logging,
48
+ replace_return_docstrings,
49
+ )
50
+ from .configuration_solar import SolarConfig
51
+
52
+
53
+ if is_flash_attn_2_available():
54
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
55
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
56
+ import inspect
57
+
58
+ _flash_supports_window_size = "window_size" in list(inspect.signature(flash_attn_func).parameters)
59
+
60
+ logger = logging.get_logger(__name__)
61
+
62
+ _CONFIG_FOR_DOC = "SolarConfig"
63
+
64
+ # Copied from transformers.models.llama.modeling_llama._get_unpad_data
65
+ def _get_unpad_data(attention_mask):
66
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
67
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
68
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
69
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.int32), (1, 0))
70
+ return (
71
+ indices,
72
+ cu_seqlens,
73
+ max_seqlen_in_batch,
74
+ )
75
+
76
+ # Copied from transformers.models.llama.modeling_llama.LlamaRMSNorm
77
+ class SolarRMSNorm(nn.Module):
78
+ def __init__(self, hidden_size, eps=1e-6):
79
+ """
80
+ SolarRMSNorm is equivalent to T5LayerNorm
81
+ """
82
+ super().__init__()
83
+ self.weight = nn.Parameter(torch.ones(hidden_size))
84
+ self.variance_epsilon = eps
85
+
86
+ def forward(self, hidden_states):
87
+ input_dtype = hidden_states.dtype
88
+ hidden_states = hidden_states.to(torch.float32)
89
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
90
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
91
+ return self.weight * hidden_states.to(input_dtype)
92
+
93
+
94
+ ALL_LAYERNORM_LAYERS.append(SolarRMSNorm)
95
+
96
+
97
+ class SolarRotaryEmbedding(nn.Module):
98
+ def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
99
+ super().__init__()
100
+ self.scaling_factor = scaling_factor
101
+ self.dim = dim
102
+ self.max_position_embeddings = max_position_embeddings
103
+ self.base = base
104
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(device) / self.dim))
105
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
106
+ # For BC we register cos and sin cached
107
+ self.max_seq_len_cached = max_position_embeddings
108
+
109
+ @torch.no_grad()
110
+ def forward(self, x, position_ids):
111
+ # x: [bs, num_attention_heads, seq_len, head_size]
112
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
113
+ position_ids_expanded = position_ids[:, None, :].float()
114
+ # Force float32 since bfloat16 loses precision on long contexts
115
+ # See https://github.com/huggingface/transformers/pull/29285
116
+ device_type = x.device.type
117
+ device_type = device_type if isinstance(device_type, str) and device_type != "mps" else "cpu"
118
+ with torch.autocast(device_type=device_type, enabled=False):
119
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
120
+ emb = torch.cat((freqs, freqs), dim=-1)
121
+ cos = emb.cos()
122
+ sin = emb.sin()
123
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
124
+
125
+
126
+ class SolarLinearScalingRotaryEmbedding(SolarRotaryEmbedding):
127
+ """SolarRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
128
+
129
+ def forward(self, x, position_ids):
130
+ # difference to the original RoPE: a scaling factor is aplied to the position ids
131
+ position_ids = position_ids.float() / self.scaling_factor
132
+ cos, sin = super().forward(x, position_ids)
133
+ return cos, sin
134
+
135
+
136
+ class SolarDynamicNTKScalingRotaryEmbedding(SolarRotaryEmbedding):
137
+ """SolarRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
138
+
139
+ def forward(self, x, position_ids):
140
+ # difference to the original RoPE: inv_freq is recomputed when the sequence length > original length
141
+ seq_len = torch.max(position_ids) + 1
142
+ if seq_len > self.max_position_embeddings:
143
+ base = self.base * (
144
+ (self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
145
+ ) ** (self.dim / (self.dim - 2))
146
+ inv_freq = 1.0 / (
147
+ base ** (torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(x.device) / self.dim)
148
+ )
149
+ self.register_buffer("inv_freq", inv_freq, persistent=False) # TODO joao: this may break with compilation
150
+
151
+ cos, sin = super().forward(x, position_ids)
152
+ return cos, sin
153
+
154
+
155
+ def rotate_half(x):
156
+ """Rotates half the hidden dims of the input."""
157
+ x1 = x[..., : x.shape[-1] // 2]
158
+ x2 = x[..., x.shape[-1] // 2 :]
159
+ return torch.cat((-x2, x1), dim=-1)
160
+
161
+
162
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
163
+ """Applies Rotary Position Embedding to the query and key tensors.
164
+
165
+ Args:
166
+ q (`torch.Tensor`): The query tensor.
167
+ k (`torch.Tensor`): The key tensor.
168
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
169
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
170
+ position_ids (`torch.Tensor`, *optional*):
171
+ Deprecated and unused.
172
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
173
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
174
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
175
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
176
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
177
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
178
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
179
+ Returns:
180
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
181
+ """
182
+ cos = cos.unsqueeze(unsqueeze_dim)
183
+ sin = sin.unsqueeze(unsqueeze_dim)
184
+ q_embed = (q * cos) + (rotate_half(q) * sin)
185
+ k_embed = (k * cos) + (rotate_half(k) * sin)
186
+ return q_embed, k_embed
187
+
188
+
189
+ class SolarMLP(nn.Module):
190
+ def __init__(self, config):
191
+ super().__init__()
192
+ self.config = config
193
+ self.hidden_size = config.hidden_size
194
+ self.intermediate_size = config.intermediate_size
195
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
196
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
197
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.mlp_bias)
198
+ self.act_fn = ACT2FN[config.hidden_act]
199
+
200
+ def forward(self, x):
201
+ if self.config.pretraining_tp > 1:
202
+ slice = self.intermediate_size // self.config.pretraining_tp
203
+ gate_proj_slices = self.gate_proj.weight.split(slice, dim=0)
204
+ up_proj_slices = self.up_proj.weight.split(slice, dim=0)
205
+ down_proj_slices = self.down_proj.weight.split(slice, dim=1)
206
+
207
+ gate_proj = torch.cat(
208
+ [F.linear(x, gate_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1
209
+ )
210
+ up_proj = torch.cat([F.linear(x, up_proj_slices[i]) for i in range(self.config.pretraining_tp)], dim=-1)
211
+
212
+ intermediate_states = (self.act_fn(gate_proj) * up_proj).split(slice, dim=2)
213
+ down_proj = [
214
+ F.linear(intermediate_states[i], down_proj_slices[i]) for i in range(self.config.pretraining_tp)
215
+ ]
216
+ down_proj = sum(down_proj)
217
+ else:
218
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
219
+
220
+ return down_proj
221
+
222
+
223
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
224
+ """
225
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
226
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
227
+ """
228
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
229
+ if n_rep == 1:
230
+ return hidden_states
231
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
232
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
233
+
234
+
235
+ class SolarAttention(nn.Module):
236
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
237
+
238
+ def __init__(self, config: SolarConfig, layer_idx: Optional[int] = None):
239
+ super().__init__()
240
+ self.config = config
241
+ self.layer_idx = layer_idx
242
+ if layer_idx is None:
243
+ logger.warning_once(
244
+ f"Instantiating {self.__class__.__name__} without passing a `layer_idx` is not recommended and will "
245
+ "lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` "
246
+ "when creating this class."
247
+ )
248
+
249
+ self.attention_dropout = config.attention_dropout
250
+ self.hidden_size = config.hidden_size
251
+ self.num_heads = config.num_attention_heads
252
+ self.head_dim = self.hidden_size // self.num_heads
253
+ self.num_key_value_heads = config.num_key_value_heads
254
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
255
+ self.max_position_embeddings = config.max_position_embeddings
256
+ self.rope_theta = config.rope_theta
257
+ self.is_causal = True
258
+
259
+ if (self.head_dim * self.num_heads) != self.hidden_size:
260
+ raise ValueError(
261
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
262
+ f" and `num_heads`: {self.num_heads})."
263
+ )
264
+
265
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
266
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
267
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
268
+ self.o_proj = nn.Linear(self.hidden_size, self.hidden_size, bias=config.attention_bias)
269
+ self._init_rope()
270
+
271
+ def _init_rope(self):
272
+ if self.config.rope_scaling is None:
273
+ self.rotary_emb = SolarRotaryEmbedding(
274
+ self.head_dim,
275
+ max_position_embeddings=self.max_position_embeddings,
276
+ base=self.rope_theta,
277
+ )
278
+ else:
279
+ scaling_type = self.config.rope_scaling["type"]
280
+ scaling_factor = self.config.rope_scaling["factor"]
281
+ if scaling_type == "linear":
282
+ self.rotary_emb = SolarLinearScalingRotaryEmbedding(
283
+ self.head_dim,
284
+ max_position_embeddings=self.max_position_embeddings,
285
+ scaling_factor=scaling_factor,
286
+ base=self.rope_theta,
287
+ )
288
+ elif scaling_type == "dynamic":
289
+ self.rotary_emb = SolarDynamicNTKScalingRotaryEmbedding(
290
+ self.head_dim,
291
+ max_position_embeddings=self.max_position_embeddings,
292
+ scaling_factor=scaling_factor,
293
+ base=self.rope_theta,
294
+ )
295
+ else:
296
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
297
+
298
+ def forward(
299
+ self,
300
+ hidden_states: torch.Tensor,
301
+ attention_mask: Optional[torch.Tensor] = None,
302
+ position_ids: Optional[torch.LongTensor] = None,
303
+ past_key_value: Optional[Cache] = None,
304
+ output_attentions: bool = False,
305
+ use_cache: bool = False,
306
+ cache_position: Optional[torch.LongTensor] = None,
307
+ **kwargs,
308
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
309
+ bsz, q_len, _ = hidden_states.size()
310
+
311
+ if self.config.pretraining_tp > 1:
312
+ key_value_slicing = (self.num_key_value_heads * self.head_dim) // self.config.pretraining_tp
313
+ query_slices = self.q_proj.weight.split(
314
+ (self.num_heads * self.head_dim) // self.config.pretraining_tp, dim=0
315
+ )
316
+ key_slices = self.k_proj.weight.split(key_value_slicing, dim=0)
317
+ value_slices = self.v_proj.weight.split(key_value_slicing, dim=0)
318
+
319
+ query_states = [F.linear(hidden_states, query_slices[i]) for i in range(self.config.pretraining_tp)]
320
+ query_states = torch.cat(query_states, dim=-1)
321
+
322
+ key_states = [F.linear(hidden_states, key_slices[i]) for i in range(self.config.pretraining_tp)]
323
+ key_states = torch.cat(key_states, dim=-1)
324
+
325
+ value_states = [F.linear(hidden_states, value_slices[i]) for i in range(self.config.pretraining_tp)]
326
+ value_states = torch.cat(value_states, dim=-1)
327
+
328
+ else:
329
+ query_states = self.q_proj(hidden_states)
330
+ key_states = self.k_proj(hidden_states)
331
+ value_states = self.v_proj(hidden_states)
332
+
333
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
334
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
335
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
336
+
337
+ cos, sin = self.rotary_emb(value_states, position_ids)
338
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
339
+
340
+ if past_key_value is not None:
341
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
342
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
343
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
344
+
345
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
346
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
347
+
348
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
349
+
350
+ if attention_mask is not None: # no matter the length, we just slice it
351
+ causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
352
+ attn_weights = attn_weights + causal_mask
353
+
354
+ # upcast attention to fp32
355
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
356
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
357
+ attn_output = torch.matmul(attn_weights, value_states)
358
+
359
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
360
+ raise ValueError(
361
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
362
+ f" {attn_output.size()}"
363
+ )
364
+
365
+ attn_output = attn_output.transpose(1, 2).contiguous()
366
+
367
+ attn_output = attn_output.reshape(bsz, q_len, -1)
368
+
369
+ if self.config.pretraining_tp > 1:
370
+ attn_output = attn_output.split(self.hidden_size // self.config.pretraining_tp, dim=2)
371
+ o_proj_slices = self.o_proj.weight.split(self.hidden_size // self.config.pretraining_tp, dim=1)
372
+ attn_output = sum([F.linear(attn_output[i], o_proj_slices[i]) for i in range(self.config.pretraining_tp)])
373
+ else:
374
+ attn_output = self.o_proj(attn_output)
375
+
376
+ if not output_attentions:
377
+ attn_weights = None
378
+
379
+ return attn_output, attn_weights, past_key_value
380
+
381
+ # Copied from transformers.models.mistral.modeling_mistal.MistralFlashAttention2
382
+ class SolarFlashAttention2(SolarAttention):
383
+ """
384
+ Solar flash attention module. This module inherits from `SolarAttention` as the weights of the module stays
385
+ untouched. The only required change would be on the forward pass where it needs to correctly call the public API of
386
+ flash attention and deal with padding tokens in case the input contains any of them.
387
+ """
388
+
389
+ # Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
390
+ def __init__(self, *args, **kwargs):
391
+ super().__init__(*args, **kwargs)
392
+
393
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
394
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
395
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
396
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
397
+
398
+ def forward(
399
+ self,
400
+ hidden_states: torch.Tensor,
401
+ attention_mask: Optional[torch.Tensor] = None,
402
+ position_ids: Optional[torch.LongTensor] = None,
403
+ past_key_value: Optional[Cache] = None,
404
+ output_attentions: bool = False,
405
+ use_cache: bool = False,
406
+ cache_position: Optional[torch.LongTensor] = None,
407
+ ):
408
+ if isinstance(past_key_value, StaticCache):
409
+ raise ValueError(
410
+ "`static` cache implementation is not compatible with `attn_implementation==flash_attention_2` "
411
+ "make sure to use `sdpa` in the mean time, and open an issue at https://github.com/huggingface/transformers"
412
+ )
413
+
414
+ output_attentions = False
415
+
416
+ bsz, q_len, _ = hidden_states.size()
417
+
418
+ query_states = self.q_proj(hidden_states)
419
+ key_states = self.k_proj(hidden_states)
420
+ value_states = self.v_proj(hidden_states)
421
+
422
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
423
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
424
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
425
+
426
+ kv_seq_len = key_states.shape[-2]
427
+ if past_key_value is not None:
428
+ kv_seq_len += cache_position[0]
429
+
430
+ cos, sin = self.rotary_emb(value_states, position_ids)
431
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
432
+
433
+ use_sliding_windows = (
434
+ _flash_supports_window_size
435
+ and getattr(self.config, "sliding_window", None) is not None
436
+ and kv_seq_len > self.config.sliding_window
437
+ )
438
+
439
+ if not _flash_supports_window_size:
440
+ logger.warning_once(
441
+ "The current flash attention version does not support sliding window attention, for a more memory efficient implementation"
442
+ " make sure to upgrade flash-attn library."
443
+ )
444
+
445
+ if past_key_value is not None:
446
+ # Activate slicing cache only if the config has a value `sliding_windows` attribute
447
+ cache_has_contents = past_key_value.get_seq_length(self.layer_idx) > 0
448
+ if (
449
+ getattr(self.config, "sliding_window", None) is not None
450
+ and kv_seq_len > self.config.sliding_window
451
+ and cache_has_contents
452
+ ):
453
+ slicing_tokens = 1 - self.config.sliding_window
454
+
455
+ past_key = past_key_value[self.layer_idx][0]
456
+ past_value = past_key_value[self.layer_idx][1]
457
+
458
+ past_key = past_key[:, :, slicing_tokens:, :].contiguous()
459
+ past_value = past_value[:, :, slicing_tokens:, :].contiguous()
460
+
461
+ if past_key.shape[-2] != self.config.sliding_window - 1:
462
+ raise ValueError(
463
+ f"past key must have a shape of (`batch_size, num_heads, self.config.sliding_window-1, head_dim`), got"
464
+ f" {past_key.shape}"
465
+ )
466
+
467
+ if attention_mask is not None:
468
+ attention_mask = attention_mask[:, slicing_tokens:]
469
+ attention_mask = torch.cat([attention_mask, torch.ones_like(attention_mask[:, -1:])], dim=-1)
470
+
471
+ cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
472
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
473
+
474
+ # repeat k/v heads if n_kv_heads < n_heads
475
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
476
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
477
+ dropout_rate = 0.0 if not self.training else self.attention_dropout
478
+
479
+ # In PEFT, usually we cast the layer norms in float32 for training stability reasons
480
+ # therefore the input hidden states gets silently casted in float32. Hence, we need
481
+ # cast them back in float16 just to be sure everything works as expected.
482
+ input_dtype = query_states.dtype
483
+ if input_dtype == torch.float32:
484
+ if torch.is_autocast_enabled():
485
+ target_dtype = torch.get_autocast_gpu_dtype()
486
+ # Handle the case where the model is quantized
487
+ elif hasattr(self.config, "_pre_quantization_dtype"):
488
+ target_dtype = self.config._pre_quantization_dtype
489
+ else:
490
+ target_dtype = self.q_proj.weight.dtype
491
+
492
+ logger.warning_once(
493
+ f"The input hidden states seems to be silently casted in float32, this might be related to"
494
+ f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
495
+ f" {target_dtype}."
496
+ )
497
+
498
+ query_states = query_states.to(target_dtype)
499
+ key_states = key_states.to(target_dtype)
500
+ value_states = value_states.to(target_dtype)
501
+
502
+ # Reashape to the expected shape for Flash Attention
503
+ query_states = query_states.transpose(1, 2)
504
+ key_states = key_states.transpose(1, 2)
505
+ value_states = value_states.transpose(1, 2)
506
+
507
+ attn_output = self._flash_attention_forward(
508
+ query_states,
509
+ key_states,
510
+ value_states,
511
+ attention_mask,
512
+ q_len,
513
+ dropout=dropout_rate,
514
+ use_sliding_windows=use_sliding_windows,
515
+ )
516
+
517
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
518
+ attn_output = self.o_proj(attn_output)
519
+
520
+ if not output_attentions:
521
+ attn_weights = None
522
+
523
+ return attn_output, attn_weights, past_key_value
524
+
525
+ def _flash_attention_forward(
526
+ self,
527
+ query_states,
528
+ key_states,
529
+ value_states,
530
+ attention_mask,
531
+ query_length,
532
+ dropout=0.0,
533
+ softmax_scale=None,
534
+ use_sliding_windows=False,
535
+ ):
536
+ """
537
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
538
+ first unpad the input, then computes the attention scores and pad the final attention scores.
539
+
540
+ Args:
541
+ query_states (`torch.Tensor`):
542
+ Input query states to be passed to Flash Attention API
543
+ key_states (`torch.Tensor`):
544
+ Input key states to be passed to Flash Attention API
545
+ value_states (`torch.Tensor`):
546
+ Input value states to be passed to Flash Attention API
547
+ attention_mask (`torch.Tensor`):
548
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
549
+ position of padding tokens and 1 for the position of non-padding tokens.
550
+ dropout (`float`):
551
+ Attention dropout
552
+ softmax_scale (`float`, *optional*):
553
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
554
+ use_sliding_windows (`bool`, *optional*):
555
+ Whether to activate sliding window attention.
556
+ """
557
+ if not self._flash_attn_uses_top_left_mask:
558
+ causal = self.is_causal
559
+ else:
560
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in LlamaFlashAttention2 __init__.
561
+ causal = self.is_causal and query_length != 1
562
+
563
+ # Contains at least one padding token in the sequence
564
+ if attention_mask is not None:
565
+ batch_size = query_states.shape[0]
566
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
567
+ query_states, key_states, value_states, attention_mask, query_length
568
+ )
569
+
570
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
571
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
572
+
573
+ if not use_sliding_windows:
574
+ attn_output_unpad = flash_attn_varlen_func(
575
+ query_states,
576
+ key_states,
577
+ value_states,
578
+ cu_seqlens_q=cu_seqlens_q,
579
+ cu_seqlens_k=cu_seqlens_k,
580
+ max_seqlen_q=max_seqlen_in_batch_q,
581
+ max_seqlen_k=max_seqlen_in_batch_k,
582
+ dropout_p=dropout,
583
+ softmax_scale=softmax_scale,
584
+ causal=causal,
585
+ )
586
+ else:
587
+ attn_output_unpad = flash_attn_varlen_func(
588
+ query_states,
589
+ key_states,
590
+ value_states,
591
+ cu_seqlens_q=cu_seqlens_q,
592
+ cu_seqlens_k=cu_seqlens_k,
593
+ max_seqlen_q=max_seqlen_in_batch_q,
594
+ max_seqlen_k=max_seqlen_in_batch_k,
595
+ dropout_p=dropout,
596
+ softmax_scale=softmax_scale,
597
+ causal=causal,
598
+ window_size=(self.config.sliding_window, self.config.sliding_window),
599
+ )
600
+
601
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
602
+ else:
603
+ if not use_sliding_windows:
604
+ attn_output = flash_attn_func(
605
+ query_states,
606
+ key_states,
607
+ value_states,
608
+ dropout,
609
+ softmax_scale=softmax_scale,
610
+ causal=causal,
611
+ )
612
+ else:
613
+ attn_output = flash_attn_func(
614
+ query_states,
615
+ key_states,
616
+ value_states,
617
+ dropout,
618
+ softmax_scale=softmax_scale,
619
+ causal=causal,
620
+ window_size=(self.config.sliding_window, self.config.sliding_window),
621
+ )
622
+
623
+ return attn_output
624
+
625
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
626
+ batch_size, kv_seq_len, num_heads, head_dim = key_layer.shape
627
+
628
+ # On the first iteration we need to properly re-create the padding mask
629
+ # by slicing it on the proper place
630
+ if kv_seq_len != attention_mask.shape[-1]:
631
+ attention_mask_num_tokens = attention_mask.shape[-1]
632
+ attention_mask = attention_mask[:, attention_mask_num_tokens - kv_seq_len :]
633
+
634
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
635
+
636
+ key_layer = index_first_axis(key_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
637
+ value_layer = index_first_axis(value_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
638
+
639
+ if query_length == kv_seq_len:
640
+ query_layer = index_first_axis(
641
+ query_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k
642
+ )
643
+ cu_seqlens_q = cu_seqlens_k
644
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
645
+ indices_q = indices_k
646
+ elif query_length == 1:
647
+ max_seqlen_in_batch_q = 1
648
+ cu_seqlens_q = torch.arange(
649
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
650
+ ) # There is a memcpy here, that is very bad.
651
+ indices_q = cu_seqlens_q[:-1]
652
+ query_layer = query_layer.squeeze(1)
653
+ else:
654
+ # The -q_len: slice assumes left padding.
655
+ attention_mask = attention_mask[:, -query_length:]
656
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
657
+
658
+ return (
659
+ query_layer,
660
+ key_layer,
661
+ value_layer,
662
+ indices_q,
663
+ (cu_seqlens_q, cu_seqlens_k),
664
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
665
+ )
666
+
667
+
668
+ class SolarSdpaAttention(SolarAttention):
669
+ """
670
+ Solar attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
671
+ `SolarAttention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
672
+ SDPA API.
673
+ """
674
+
675
+ # Adapted from SolarAttention.forward
676
+ def forward(
677
+ self,
678
+ hidden_states: torch.Tensor,
679
+ attention_mask: Optional[torch.Tensor] = None,
680
+ position_ids: Optional[torch.LongTensor] = None,
681
+ past_key_value: Optional[Cache] = None,
682
+ output_attentions: bool = False,
683
+ use_cache: bool = False,
684
+ cache_position: Optional[torch.LongTensor] = None,
685
+ **kwargs,
686
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
687
+ if output_attentions:
688
+ # TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
689
+ logger.warning_once(
690
+ "SolarModel is using SolarSdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
691
+ 'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
692
+ )
693
+ return super().forward(
694
+ hidden_states=hidden_states,
695
+ attention_mask=attention_mask,
696
+ position_ids=position_ids,
697
+ past_key_value=past_key_value,
698
+ output_attentions=output_attentions,
699
+ use_cache=use_cache,
700
+ cache_position=cache_position,
701
+ )
702
+
703
+ bsz, q_len, _ = hidden_states.size()
704
+
705
+ query_states = self.q_proj(hidden_states)
706
+ key_states = self.k_proj(hidden_states)
707
+ value_states = self.v_proj(hidden_states)
708
+
709
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
710
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
711
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
712
+
713
+ cos, sin = self.rotary_emb(value_states, position_ids)
714
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
715
+
716
+ if past_key_value is not None:
717
+ # sin and cos are specific to RoPE models; cache_position needed for the static cache
718
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
719
+ key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
720
+
721
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
722
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
723
+
724
+ causal_mask = attention_mask
725
+ if attention_mask is not None:
726
+ causal_mask = causal_mask[:, :, :, : key_states.shape[-2]]
727
+
728
+ # SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
729
+ # Reference: https://github.com/pytorch/pytorch/issues/112577.
730
+ if query_states.device.type == "cuda" and causal_mask is not None:
731
+ query_states = query_states.contiguous()
732
+ key_states = key_states.contiguous()
733
+ value_states = value_states.contiguous()
734
+
735
+ # We dispatch to SDPA's Flash Attention or Efficient kernels via this `is_causal` if statement instead of an inline conditional assignment
736
+ # in SDPA to support both torch.compile's dynamic shapes and full graph options. An inline conditional prevents dynamic shapes from compiling.
737
+ is_causal = True if causal_mask is None and q_len > 1 else False
738
+
739
+ attn_output = torch.nn.functional.scaled_dot_product_attention(
740
+ query_states,
741
+ key_states,
742
+ value_states,
743
+ attn_mask=causal_mask,
744
+ dropout_p=self.attention_dropout if self.training else 0.0,
745
+ is_causal=is_causal,
746
+ )
747
+
748
+ attn_output = attn_output.transpose(1, 2).contiguous()
749
+ attn_output = attn_output.view(bsz, q_len, -1)
750
+
751
+ attn_output = self.o_proj(attn_output)
752
+
753
+ return attn_output, None, past_key_value
754
+
755
+
756
+ SOLAR_ATTENTION_CLASSES = {
757
+ "eager": SolarAttention,
758
+ "flash_attention_2": SolarFlashAttention2,
759
+ "sdpa": SolarSdpaAttention,
760
+ }
761
+
762
+
763
+ class SolarDecoderLayer(nn.Module):
764
+ def __init__(self, config: SolarConfig, layer_idx: int):
765
+ super().__init__()
766
+ self.hidden_size = config.hidden_size
767
+
768
+ self.self_attn = SOLAR_ATTENTION_CLASSES[config._attn_implementation](config=config, layer_idx=layer_idx)
769
+
770
+ self.mlp = SolarMLP(config)
771
+ self.input_layernorm = SolarRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
772
+ self.post_attention_layernorm = SolarRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
773
+
774
+ def forward(
775
+ self,
776
+ hidden_states: torch.Tensor,
777
+ attention_mask: Optional[torch.Tensor] = None,
778
+ position_ids: Optional[torch.LongTensor] = None,
779
+ past_key_value: Optional[Cache] = None,
780
+ output_attentions: Optional[bool] = False,
781
+ use_cache: Optional[bool] = False,
782
+ cache_position: Optional[torch.LongTensor] = None,
783
+ **kwargs,
784
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
785
+ """
786
+ Args:
787
+ hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
788
+ attention_mask (`torch.FloatTensor`, *optional*):
789
+ attention mask of size `(batch_size, sequence_length)` if flash attention is used or `(batch_size, 1,
790
+ query_sequence_length, key_sequence_length)` if default attention is used.
791
+ output_attentions (`bool`, *optional*):
792
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under
793
+ returned tensors for more detail.
794
+ use_cache (`bool`, *optional*):
795
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
796
+ (see `past_key_values`).
797
+ past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
798
+ cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
799
+ Indices depicting the position of the input sequence tokens in the sequence
800
+ kwargs (`dict`, *optional*):
801
+ Arbitrary kwargs to be ignored, used for FSDP and other methods that injects code
802
+ into the model
803
+ """
804
+ residual = hidden_states
805
+
806
+ hidden_states = self.input_layernorm(hidden_states)
807
+
808
+ # Self Attention
809
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
810
+ hidden_states=hidden_states,
811
+ attention_mask=attention_mask,
812
+ position_ids=position_ids,
813
+ past_key_value=past_key_value,
814
+ output_attentions=output_attentions,
815
+ use_cache=use_cache,
816
+ cache_position=cache_position,
817
+ )
818
+ hidden_states = residual + hidden_states
819
+
820
+ # Fully Connected
821
+ residual = hidden_states
822
+ hidden_states = self.post_attention_layernorm(hidden_states)
823
+ hidden_states = self.mlp(hidden_states)
824
+ hidden_states = residual + hidden_states
825
+
826
+ outputs = (hidden_states,)
827
+
828
+ if output_attentions:
829
+ outputs += (self_attn_weights,)
830
+
831
+ if use_cache:
832
+ outputs += (present_key_value,)
833
+
834
+ return outputs
835
+
836
+
837
+ SOLAR_START_DOCSTRING = r"""
838
+ This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
839
+ library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
840
+ etc.)
841
+
842
+ This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
843
+ Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
844
+ and behavior.
845
+
846
+ Parameters:
847
+ config ([`SolarConfig`]):
848
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
849
+ load the weights associated with the model, only the configuration. Check out the
850
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
851
+ """
852
+
853
+
854
+ @add_start_docstrings(
855
+ "The bare Solar Model outputting raw hidden-states without any specific head on top.",
856
+ SOLAR_START_DOCSTRING,
857
+ )
858
+ class SolarPreTrainedModel(PreTrainedModel):
859
+ config_class = SolarConfig
860
+ base_model_prefix = "model"
861
+ supports_gradient_checkpointing = True
862
+ _no_split_modules = ["SolarDecoderLayer"]
863
+ _skip_keys_device_placement = ["past_key_values"]
864
+ _supports_flash_attn_2 = True
865
+ _supports_sdpa = True
866
+ _supports_cache_class = True
867
+ _supports_quantized_cache = True
868
+ _supports_static_cache = True
869
+
870
+ def _init_weights(self, module):
871
+ std = self.config.initializer_range
872
+ if isinstance(module, nn.Linear):
873
+ module.weight.data.normal_(mean=0.0, std=std)
874
+ if module.bias is not None:
875
+ module.bias.data.zero_()
876
+ elif isinstance(module, nn.Embedding):
877
+ module.weight.data.normal_(mean=0.0, std=std)
878
+ if module.padding_idx is not None:
879
+ module.weight.data[module.padding_idx].zero_()
880
+
881
+
882
+ SOLAR_INPUTS_DOCSTRING = r"""
883
+ Args:
884
+ input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
885
+ Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
886
+ it.
887
+
888
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
889
+ [`PreTrainedTokenizer.__call__`] for details.
890
+
891
+ [What are input IDs?](../glossary#input-ids)
892
+ attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
893
+ Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
894
+
895
+ - 1 for tokens that are **not masked**,
896
+ - 0 for tokens that are **masked**.
897
+
898
+ [What are attention masks?](../glossary#attention-mask)
899
+
900
+ Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
901
+ [`PreTrainedTokenizer.__call__`] for details.
902
+
903
+ If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
904
+ `past_key_values`).
905
+
906
+ If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
907
+ and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
908
+ information on the default strategy.
909
+
910
+ - 1 indicates the head is **not masked**,
911
+ - 0 indicates the head is **masked**.
912
+ position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
913
+ Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
914
+ config.n_positions - 1]`.
915
+
916
+ [What are position IDs?](../glossary#position-ids)
917
+ past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
918
+ Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
919
+ blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
920
+ returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
921
+
922
+ Two formats are allowed:
923
+ - a [`~cache_utils.Cache`] instance;
924
+ - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
925
+ shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
926
+ cache format.
927
+
928
+ The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
929
+ legacy cache format will be returned.
930
+
931
+ If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
932
+ have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
933
+ of shape `(batch_size, sequence_length)`.
934
+ inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
935
+ Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
936
+ is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
937
+ model's internal embedding lookup matrix.
938
+ use_cache (`bool`, *optional*):
939
+ If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
940
+ `past_key_values`).
941
+ output_attentions (`bool`, *optional*):
942
+ Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
943
+ tensors for more detail.
944
+ output_hidden_states (`bool`, *optional*):
945
+ Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
946
+ more detail.
947
+ return_dict (`bool`, *optional*):
948
+ Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
949
+ cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
950
+ Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
951
+ this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
952
+ the complete sequence length.
953
+ """
954
+
955
+
956
+ @add_start_docstrings(
957
+ "The bare Solar Model outputting raw hidden-states without any specific head on top.",
958
+ SOLAR_START_DOCSTRING,
959
+ )
960
+ class SolarModel(SolarPreTrainedModel):
961
+ """
962
+ Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`SolarDecoderLayer`]
963
+
964
+ Args:
965
+ config: SolarConfig
966
+ """
967
+
968
+ def __init__(self, config: SolarConfig):
969
+ super().__init__(config)
970
+ self.padding_idx = config.pad_token_id
971
+ self.vocab_size = config.vocab_size
972
+
973
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
974
+ self.layers = nn.ModuleList(
975
+ [SolarDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
976
+ )
977
+ self._attn_implementation = config._attn_implementation
978
+ self.norm = SolarRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
979
+
980
+ self.gradient_checkpointing = False
981
+ # Initialize weights and apply final processing
982
+ self.post_init()
983
+
984
+ def get_input_embeddings(self):
985
+ return self.embed_tokens
986
+
987
+ def set_input_embeddings(self, value):
988
+ self.embed_tokens = value
989
+
990
+ @add_start_docstrings_to_model_forward(SOLAR_INPUTS_DOCSTRING)
991
+ def forward(
992
+ self,
993
+ input_ids: torch.LongTensor = None,
994
+ attention_mask: Optional[torch.Tensor] = None,
995
+ position_ids: Optional[torch.LongTensor] = None,
996
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
997
+ inputs_embeds: Optional[torch.FloatTensor] = None,
998
+ use_cache: Optional[bool] = None,
999
+ output_attentions: Optional[bool] = None,
1000
+ output_hidden_states: Optional[bool] = None,
1001
+ return_dict: Optional[bool] = None,
1002
+ cache_position: Optional[torch.LongTensor] = None,
1003
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
1004
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1005
+ output_hidden_states = (
1006
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1007
+ )
1008
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
1009
+
1010
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1011
+
1012
+ # retrieve input_ids and inputs_embeds
1013
+ if (input_ids is None) ^ (inputs_embeds is not None):
1014
+ raise ValueError(
1015
+ "You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
1016
+ )
1017
+
1018
+ if self.gradient_checkpointing and self.training and use_cache:
1019
+ logger.warning_once(
1020
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
1021
+ )
1022
+ use_cache = False
1023
+
1024
+ if inputs_embeds is None:
1025
+ inputs_embeds = self.embed_tokens(input_ids)
1026
+
1027
+ return_legacy_cache = False
1028
+ if use_cache and not isinstance(past_key_values, Cache):
1029
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
1030
+ return_legacy_cache = True
1031
+ logger.warning_once(
1032
+ "We detected that you are passing `past_key_values` as a tuple and this is deprecated and will be removed in v4.43. "
1033
+ "Please use an appropriate `Cache` class (https://huggingface.co/docs/transformers/v4.41.3/en/internal/generation_utils#transformers.Cache)"
1034
+ )
1035
+
1036
+ if cache_position is None:
1037
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
1038
+ cache_position = torch.arange(
1039
+ past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
1040
+ )
1041
+
1042
+ if position_ids is None:
1043
+ position_ids = cache_position.unsqueeze(0)
1044
+
1045
+ causal_mask = self._update_causal_mask(
1046
+ attention_mask, inputs_embeds, cache_position, past_key_values, use_cache, output_attentions
1047
+ )
1048
+
1049
+ hidden_states = inputs_embeds
1050
+
1051
+ # decoder layers
1052
+ all_hidden_states = () if output_hidden_states else None
1053
+ all_self_attns = () if output_attentions else None
1054
+ next_decoder_cache = None
1055
+
1056
+ bskcn_1 = None
1057
+ bskcn_2 = None
1058
+ bskcn_tv = self.config.bskcn_tv[0] if self.training else self.config.bskcn_tv[1]
1059
+ for layer_idx, decoder_layer in enumerate(self.layers):
1060
+ if layer_idx in self.config.bskcn_1:
1061
+ bskcn_1 = hidden_states
1062
+ if layer_idx in self.config.bskcn_2:
1063
+ bskcn_2 = hidden_states
1064
+ if layer_idx in self.config.bskcn_3:
1065
+ hidden_states = (bskcn_1*bskcn_tv).to(hidden_states.device) + hidden_states*(1-bskcn_tv)
1066
+ if layer_idx in self.config.bskcn_4:
1067
+ hidden_states = (bskcn_2*bskcn_tv).to(hidden_states.device) + hidden_states*(1-bskcn_tv)
1068
+
1069
+ if output_hidden_states:
1070
+ all_hidden_states += (hidden_states,)
1071
+
1072
+ if self.gradient_checkpointing and self.training:
1073
+ layer_outputs = self._gradient_checkpointing_func(
1074
+ decoder_layer.__call__,
1075
+ hidden_states,
1076
+ causal_mask,
1077
+ position_ids,
1078
+ past_key_values,
1079
+ output_attentions,
1080
+ use_cache,
1081
+ cache_position,
1082
+ )
1083
+ else:
1084
+ layer_outputs = decoder_layer(
1085
+ hidden_states,
1086
+ attention_mask=causal_mask,
1087
+ position_ids=position_ids,
1088
+ past_key_value=past_key_values,
1089
+ output_attentions=output_attentions,
1090
+ use_cache=use_cache,
1091
+ cache_position=cache_position,
1092
+ )
1093
+
1094
+ hidden_states = layer_outputs[0]
1095
+
1096
+ if use_cache:
1097
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
1098
+
1099
+ if output_attentions:
1100
+ all_self_attns += (layer_outputs[1],)
1101
+
1102
+ hidden_states = self.norm(hidden_states)
1103
+
1104
+ # add hidden states from the last decoder layer
1105
+ if output_hidden_states:
1106
+ all_hidden_states += (hidden_states,)
1107
+
1108
+ next_cache = next_decoder_cache if use_cache else None
1109
+ if return_legacy_cache:
1110
+ next_cache = next_cache.to_legacy_cache()
1111
+
1112
+ if not return_dict:
1113
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
1114
+ return BaseModelOutputWithPast(
1115
+ last_hidden_state=hidden_states,
1116
+ past_key_values=next_cache,
1117
+ hidden_states=all_hidden_states,
1118
+ attentions=all_self_attns,
1119
+ )
1120
+
1121
+ def _update_causal_mask(
1122
+ self,
1123
+ attention_mask: torch.Tensor,
1124
+ input_tensor: torch.Tensor,
1125
+ cache_position: torch.Tensor,
1126
+ past_key_values: Cache,
1127
+ use_cache: bool,
1128
+ output_attentions: bool,
1129
+ ):
1130
+ # TODO: As of torch==2.2.0, the `attention_mask` passed to the model in `generate` is 2D and of dynamic length even when the static
1131
+ # KV cache is used. This is an issue for torch.compile which then recaptures cudagraphs at each decode steps due to the dynamic shapes.
1132
+ # (`recording cudagraph tree for symint key 13`, etc.), which is VERY slow. A workaround is `@torch.compiler.disable`, but this prevents using
1133
+ # `fullgraph=True`. See more context in https://github.com/huggingface/transformers/pull/29114
1134
+
1135
+ if self._attn_implementation == "flash_attention_2":
1136
+ if attention_mask is not None and use_cache:
1137
+ is_padding_right = attention_mask[:, -1].sum().item() != input_tensor.size()[0]
1138
+ if is_padding_right:
1139
+ raise ValueError(
1140
+ "You are attempting to perform batched generation with padding_side='right'"
1141
+ " this may lead to unexpected behaviour for Flash Attention version of Solar. Make sure to "
1142
+ " call `tokenizer.padding_side = 'left'` before tokenizing the input. "
1143
+ )
1144
+ if attention_mask is not None and 0.0 in attention_mask:
1145
+ return attention_mask
1146
+ return None
1147
+
1148
+ # For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
1149
+ # order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
1150
+ # to infer the attention mask.
1151
+
1152
+ # cache_position must be valid here no matter which cache we use
1153
+ past_seen_tokens = cache_position[0] if past_key_values is not None else 0
1154
+ using_static_cache = isinstance(past_key_values, StaticCache)
1155
+ using_sliding_window_cache = isinstance(past_key_values, SlidingWindowCache)
1156
+
1157
+ if (
1158
+ self.config._attn_implementation == "sdpa"
1159
+ and not (using_static_cache or using_sliding_window_cache)
1160
+ and not output_attentions
1161
+ ):
1162
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
1163
+ attention_mask,
1164
+ inputs_embeds=input_tensor,
1165
+ past_key_values_length=past_seen_tokens,
1166
+ sliding_window=self.config.sliding_window,
1167
+ is_training=self.training,
1168
+ ):
1169
+ return None
1170
+
1171
+ dtype, device = input_tensor.dtype, input_tensor.device
1172
+ min_dtype = torch.finfo(dtype).min
1173
+ sequence_length = input_tensor.shape[1]
1174
+ # SlidingWindowCache
1175
+ if using_sliding_window_cache:
1176
+ target_length = max(sequence_length, self.config.sliding_window)
1177
+ # StaticCache
1178
+ elif using_static_cache:
1179
+ target_length = past_key_values.get_max_length()
1180
+ # DynamicCache or no cache
1181
+ else:
1182
+ target_length = (
1183
+ attention_mask.shape[-1]
1184
+ if isinstance(attention_mask, torch.Tensor)
1185
+ else past_seen_tokens + sequence_length + 1
1186
+ )
1187
+
1188
+ if attention_mask is not None and attention_mask.dim() == 4:
1189
+ # in this case we assume that the mask comes already in inverted form and requires no inversion or slicing
1190
+ if attention_mask.max() != 0:
1191
+ raise ValueError("Custom 4D attention mask should be passed in inverted form with max==0`")
1192
+ causal_mask = attention_mask
1193
+ else:
1194
+ causal_mask = torch.full(
1195
+ (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device
1196
+ )
1197
+ exclude_mask = torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
1198
+ if self.config.sliding_window is not None:
1199
+ if not using_sliding_window_cache or sequence_length > self.config.sliding_window:
1200
+ exclude_mask |= torch.arange(target_length, device=device) <= (
1201
+ cache_position.reshape(-1, 1) - self.config.sliding_window
1202
+ )
1203
+ causal_mask *= exclude_mask
1204
+ causal_mask = causal_mask[None, None, :, :].expand(input_tensor.shape[0], 1, -1, -1)
1205
+ if attention_mask is not None:
1206
+ causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit
1207
+ if attention_mask.dim() == 2:
1208
+ mask_length = attention_mask.shape[-1]
1209
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :]
1210
+ padding_mask = padding_mask == 0
1211
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
1212
+ padding_mask, min_dtype
1213
+ )
1214
+
1215
+ if (
1216
+ self.config._attn_implementation == "sdpa"
1217
+ and attention_mask is not None
1218
+ and attention_mask.device.type == "cuda"
1219
+ and not output_attentions
1220
+ ):
1221
+ # Attend to all tokens in fully masked rows in the causal_mask, for example the relevant first rows when
1222
+ # using left padding. This is required by F.scaled_dot_product_attention memory-efficient attention path.
1223
+ # Details: https://github.com/pytorch/pytorch/issues/110213
1224
+ causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
1225
+
1226
+ return causal_mask
1227
+
1228
+ # Copied from transformers.models.mistral.modeling_mistal.SolarCasualLM
1229
+ class SolarForCausalLM(SolarPreTrainedModel):
1230
+ _tied_weights_keys = ["lm_head.weight"]
1231
+
1232
+ def __init__(self, config):
1233
+ super().__init__(config)
1234
+ self.model = SolarModel(config)
1235
+ self.vocab_size = config.vocab_size
1236
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
1237
+
1238
+ # Initialize weights and apply final processing
1239
+ self.post_init()
1240
+
1241
+ def get_input_embeddings(self):
1242
+ return self.model.embed_tokens
1243
+
1244
+ def set_input_embeddings(self, value):
1245
+ self.model.embed_tokens = value
1246
+
1247
+ def get_output_embeddings(self):
1248
+ return self.lm_head
1249
+
1250
+ def set_output_embeddings(self, new_embeddings):
1251
+ self.lm_head = new_embeddings
1252
+
1253
+ def set_decoder(self, decoder):
1254
+ self.model = decoder
1255
+
1256
+ def get_decoder(self):
1257
+ return self.model
1258
+
1259
+ @add_start_docstrings_to_model_forward(SOLAR_INPUTS_DOCSTRING)
1260
+ @replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
1261
+ def forward(
1262
+ self,
1263
+ input_ids: torch.LongTensor = None,
1264
+ attention_mask: Optional[torch.Tensor] = None,
1265
+ position_ids: Optional[torch.LongTensor] = None,
1266
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1267
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1268
+ labels: Optional[torch.LongTensor] = None,
1269
+ use_cache: Optional[bool] = None,
1270
+ output_attentions: Optional[bool] = None,
1271
+ output_hidden_states: Optional[bool] = None,
1272
+ return_dict: Optional[bool] = None,
1273
+ cache_position: Optional[torch.LongTensor] = None,
1274
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
1275
+ r"""
1276
+ Args:
1277
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
1278
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
1279
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
1280
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
1281
+
1282
+ Returns:
1283
+
1284
+ Example:
1285
+
1286
+ ```python
1287
+ >>> from transformers import AutoTokenizer, SolarForCausalLM
1288
+
1289
+ >>> model = SolarForCausalLM.from_pretrained("upstage/Solar-pro-1.0")
1290
+ >>> tokenizer = AutoTokenizer.from_pretrained("upstage/Solar-pro-1.0")
1291
+
1292
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
1293
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
1294
+
1295
+ >>> # Generate
1296
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
1297
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
1298
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
1299
+ ```"""
1300
+
1301
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
1302
+ output_hidden_states = (
1303
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
1304
+ )
1305
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1306
+
1307
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
1308
+ outputs = self.model(
1309
+ input_ids=input_ids,
1310
+ attention_mask=attention_mask,
1311
+ position_ids=position_ids,
1312
+ past_key_values=past_key_values,
1313
+ inputs_embeds=inputs_embeds,
1314
+ use_cache=use_cache,
1315
+ output_attentions=output_attentions,
1316
+ output_hidden_states=output_hidden_states,
1317
+ return_dict=return_dict,
1318
+ cache_position=cache_position,
1319
+ )
1320
+
1321
+ hidden_states = outputs[0]
1322
+ logits = self.lm_head(hidden_states)
1323
+ logits = logits.float()
1324
+
1325
+ loss = None
1326
+ if labels is not None:
1327
+ # Shift so that tokens < n predict n
1328
+ shift_logits = logits[..., :-1, :].contiguous()
1329
+ shift_labels = labels[..., 1:].contiguous()
1330
+ # Flatten the tokens
1331
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
1332
+ shift_labels = shift_labels.view(-1)
1333
+ # Ensure tensors are on the same device
1334
+ shift_labels = shift_labels.to(shift_logits.device)
1335
+ loss_fct = CrossEntropyLoss()
1336
+ loss = loss_fct(shift_logits, shift_labels)
1337
+
1338
+ if not return_dict:
1339
+ output = (logits,) + outputs[1:]
1340
+ return (loss,) + output if loss is not None else output
1341
+
1342
+ return CausalLMOutputWithPast(
1343
+ loss=loss,
1344
+ logits=logits,
1345
+ past_key_values=outputs.past_key_values,
1346
+ hidden_states=outputs.hidden_states,
1347
+ attentions=outputs.attentions,
1348
+ )
1349
+
1350
+ def prepare_inputs_for_generation(
1351
+ self,
1352
+ input_ids,
1353
+ past_key_values=None,
1354
+ attention_mask=None,
1355
+ inputs_embeds=None,
1356
+ cache_position=None,
1357
+ use_cache=True,
1358
+ **kwargs,
1359
+ ):
1360
+ past_length = 0
1361
+ # Omit tokens covered by past_key_values
1362
+ if past_key_values is not None:
1363
+ # Past key values are always initialized with a `Cache` object -> no need for if-else anymore
1364
+ past_length = cache_position[0] if cache_position is not None else past_key_values.get_seq_length()
1365
+ max_cache_length = (
1366
+ torch.tensor(past_key_values.get_max_length(), device=input_ids.device)
1367
+ if past_key_values.get_max_length() is not None
1368
+ else None
1369
+ )
1370
+ cache_length = past_length if max_cache_length is None else torch.min(max_cache_length, past_length)
1371
+
1372
+ # Keep only the unprocessed tokens:
1373
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
1374
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
1375
+ # input)
1376
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
1377
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
1378
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
1379
+ # input_ids based on the past_length.
1380
+ elif past_length < input_ids.shape[1]:
1381
+ input_ids = input_ids[:, past_length:]
1382
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
1383
+
1384
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
1385
+ if (
1386
+ max_cache_length is not None
1387
+ and attention_mask is not None
1388
+ and cache_length + input_ids.shape[1] > max_cache_length
1389
+ ):
1390
+ attention_mask = attention_mask[:, -max_cache_length:]
1391
+
1392
+ position_ids = kwargs.get("position_ids", None)
1393
+ if attention_mask is not None and position_ids is None:
1394
+ # create position_ids on the fly for batch generation
1395
+ position_ids = attention_mask.long().cumsum(-1) - 1
1396
+ position_ids.masked_fill_(attention_mask == 0, 1)
1397
+ if past_key_values:
1398
+ position_ids = position_ids[:, -input_ids.shape[1] :]
1399
+
1400
+ # crop the attention_mask to sliding window size during decode phase if using SlidingWindowCache
1401
+ if (
1402
+ past_length > 0
1403
+ and attention_mask is not None
1404
+ and isinstance(past_key_values, SlidingWindowCache)
1405
+ and attention_mask.shape[1] > past_key_values.max_cache_len
1406
+ ):
1407
+ attention_mask = attention_mask[:, -past_key_values.max_cache_len :]
1408
+
1409
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
1410
+ if inputs_embeds is not None and past_length == 0:
1411
+ model_inputs = {"inputs_embeds": inputs_embeds}
1412
+ else:
1413
+ model_inputs = {"input_ids": input_ids.contiguous()}
1414
+
1415
+ input_length = position_ids.shape[-1] if position_ids is not None else input_ids.shape[-1]
1416
+ if cache_position is None:
1417
+ cache_position = torch.arange(past_length, past_length + input_length, device=input_ids.device)
1418
+ elif use_cache:
1419
+ cache_position = cache_position[-input_length:]
1420
+
1421
+ model_inputs.update(
1422
+ {
1423
+ "position_ids": position_ids,
1424
+ "cache_position": cache_position,
1425
+ "past_key_values": past_key_values,
1426
+ "use_cache": use_cache,
1427
+ "attention_mask": attention_mask,
1428
+ }
1429
+ )
1430
+ return model_inputs
1431
+
1432
+ @staticmethod
1433
+ def _reorder_cache(past_key_values, beam_idx):
1434
+ reordered_past = ()
1435
+ for layer_past in past_key_values:
1436
+ reordered_past += (
1437
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
1438
+ )
1439
+ return reordered_past
1440
+
1441
+
1442
+ @add_start_docstrings(
1443
+ """
1444
+ The Solar Model transformer with a sequence classification head on top (linear layer).
1445
+
1446
+ [`SolarForSequenceClassification`] uses the last token in order to do the classification, as other causal models
1447
+ (e.g. GPT-2) do.
1448
+
1449
+ Since it does classification on the last token, it requires to know the position of the last token. If a
1450
+ `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
1451
+ no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
1452
+ padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
1453
+ each row of the batch).
1454
+ """,
1455
+ SOLAR_START_DOCSTRING,
1456
+ )
1457
+ class SolarForSequenceClassification(SolarPreTrainedModel):
1458
+ def __init__(self, config):
1459
+ super().__init__(config)
1460
+ self.num_labels = config.num_labels
1461
+ self.model = SolarModel(config)
1462
+ self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
1463
+
1464
+ # Initialize weights and apply final processing
1465
+ self.post_init()
1466
+
1467
+ def get_input_embeddings(self):
1468
+ return self.model.embed_tokens
1469
+
1470
+ def set_input_embeddings(self, value):
1471
+ self.model.embed_tokens = value
1472
+
1473
+ @add_start_docstrings_to_model_forward(SOLAR_INPUTS_DOCSTRING)
1474
+ def forward(
1475
+ self,
1476
+ input_ids: torch.LongTensor = None,
1477
+ attention_mask: Optional[torch.Tensor] = None,
1478
+ position_ids: Optional[torch.LongTensor] = None,
1479
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1480
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1481
+ labels: Optional[torch.LongTensor] = None,
1482
+ use_cache: Optional[bool] = None,
1483
+ output_attentions: Optional[bool] = None,
1484
+ output_hidden_states: Optional[bool] = None,
1485
+ return_dict: Optional[bool] = None,
1486
+ ) -> Union[Tuple, SequenceClassifierOutputWithPast]:
1487
+ r"""
1488
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1489
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1490
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1491
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1492
+ """
1493
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1494
+
1495
+ transformer_outputs = self.model(
1496
+ input_ids,
1497
+ attention_mask=attention_mask,
1498
+ position_ids=position_ids,
1499
+ past_key_values=past_key_values,
1500
+ inputs_embeds=inputs_embeds,
1501
+ use_cache=use_cache,
1502
+ output_attentions=output_attentions,
1503
+ output_hidden_states=output_hidden_states,
1504
+ return_dict=return_dict,
1505
+ )
1506
+ hidden_states = transformer_outputs[0]
1507
+ logits = self.score(hidden_states)
1508
+
1509
+ if input_ids is not None:
1510
+ batch_size = input_ids.shape[0]
1511
+ else:
1512
+ batch_size = inputs_embeds.shape[0]
1513
+
1514
+ if self.config.pad_token_id is None and batch_size != 1:
1515
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
1516
+ if self.config.pad_token_id is None:
1517
+ sequence_lengths = -1
1518
+ else:
1519
+ if input_ids is not None:
1520
+ # if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
1521
+ sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
1522
+ sequence_lengths = sequence_lengths % input_ids.shape[-1]
1523
+ sequence_lengths = sequence_lengths.to(logits.device)
1524
+ else:
1525
+ sequence_lengths = -1
1526
+
1527
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
1528
+
1529
+ loss = None
1530
+ if labels is not None:
1531
+ labels = labels.to(logits.device)
1532
+ if self.config.problem_type is None:
1533
+ if self.num_labels == 1:
1534
+ self.config.problem_type = "regression"
1535
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
1536
+ self.config.problem_type = "single_label_classification"
1537
+ else:
1538
+ self.config.problem_type = "multi_label_classification"
1539
+
1540
+ if self.config.problem_type == "regression":
1541
+ loss_fct = MSELoss()
1542
+ if self.num_labels == 1:
1543
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
1544
+ else:
1545
+ loss = loss_fct(pooled_logits, labels)
1546
+ elif self.config.problem_type == "single_label_classification":
1547
+ loss_fct = CrossEntropyLoss()
1548
+ loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
1549
+ elif self.config.problem_type == "multi_label_classification":
1550
+ loss_fct = BCEWithLogitsLoss()
1551
+ loss = loss_fct(pooled_logits, labels)
1552
+ if not return_dict:
1553
+ output = (pooled_logits,) + transformer_outputs[1:]
1554
+ return ((loss,) + output) if loss is not None else output
1555
+
1556
+ return SequenceClassifierOutputWithPast(
1557
+ loss=loss,
1558
+ logits=pooled_logits,
1559
+ past_key_values=transformer_outputs.past_key_values,
1560
+ hidden_states=transformer_outputs.hidden_states,
1561
+ attentions=transformer_outputs.attentions,
1562
+ )
1563
+
1564
+
1565
+ @add_start_docstrings(
1566
+ """
1567
+ The Solar Model transformer with a span classification head on top for extractive question-answering tasks like
1568
+ SQuAD (a linear layer on top of the hidden-states output to compute `span start logits` and `span end logits`).
1569
+ """,
1570
+ SOLAR_START_DOCSTRING,
1571
+ )
1572
+ class SolarForQuestionAnswering(SolarPreTrainedModel):
1573
+ base_model_prefix = "transformer"
1574
+
1575
+ # Copied from transformers.models.bloom.modeling_bloom.BloomForQuestionAnswering.__init__ with Bloom->Solar
1576
+ def __init__(self, config):
1577
+ super().__init__(config)
1578
+ self.transformer = SolarModel(config)
1579
+ self.qa_outputs = nn.Linear(config.hidden_size, 2)
1580
+
1581
+ # Initialize weights and apply final processing
1582
+ self.post_init()
1583
+
1584
+ def get_input_embeddings(self):
1585
+ return self.transformer.embed_tokens
1586
+
1587
+ def set_input_embeddings(self, value):
1588
+ self.transformer.embed_tokens = value
1589
+
1590
+ @add_start_docstrings_to_model_forward(SOLAR_INPUTS_DOCSTRING)
1591
+ def forward(
1592
+ self,
1593
+ input_ids: Optional[torch.LongTensor] = None,
1594
+ attention_mask: Optional[torch.FloatTensor] = None,
1595
+ position_ids: Optional[torch.LongTensor] = None,
1596
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
1597
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1598
+ start_positions: Optional[torch.LongTensor] = None,
1599
+ end_positions: Optional[torch.LongTensor] = None,
1600
+ output_attentions: Optional[bool] = None,
1601
+ output_hidden_states: Optional[bool] = None,
1602
+ return_dict: Optional[bool] = None,
1603
+ ) -> Union[Tuple, QuestionAnsweringModelOutput]:
1604
+ r"""
1605
+ start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1606
+ Labels for position (index) of the start of the labelled span for computing the token classification loss.
1607
+ Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
1608
+ are not taken into account for computing the loss.
1609
+ end_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1610
+ Labels for position (index) of the end of the labelled span for computing the token classification loss.
1611
+ Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
1612
+ are not taken into account for computing the loss.
1613
+ """
1614
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1615
+
1616
+ outputs = self.transformer(
1617
+ input_ids,
1618
+ attention_mask=attention_mask,
1619
+ position_ids=position_ids,
1620
+ past_key_values=past_key_values,
1621
+ inputs_embeds=inputs_embeds,
1622
+ output_attentions=output_attentions,
1623
+ output_hidden_states=output_hidden_states,
1624
+ return_dict=return_dict,
1625
+ )
1626
+
1627
+ sequence_output = outputs[0]
1628
+
1629
+ logits = self.qa_outputs(sequence_output)
1630
+ start_logits, end_logits = logits.split(1, dim=-1)
1631
+ start_logits = start_logits.squeeze(-1).contiguous()
1632
+ end_logits = end_logits.squeeze(-1).contiguous()
1633
+
1634
+ total_loss = None
1635
+ if start_positions is not None and end_positions is not None:
1636
+ # If we are on multi-GPU, split add a dimension
1637
+ if len(start_positions.size()) > 1:
1638
+ start_positions = start_positions.squeeze(-1).to(start_logits.device)
1639
+ if len(end_positions.size()) > 1:
1640
+ end_positions = end_positions.squeeze(-1).to(end_logits.device)
1641
+ # sometimes the start/end positions are outside our model inputs, we ignore these terms
1642
+ ignored_index = start_logits.size(1)
1643
+ start_positions = start_positions.clamp(0, ignored_index)
1644
+ end_positions = end_positions.clamp(0, ignored_index)
1645
+
1646
+ loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
1647
+ start_loss = loss_fct(start_logits, start_positions)
1648
+ end_loss = loss_fct(end_logits, end_positions)
1649
+ total_loss = (start_loss + end_loss) / 2
1650
+
1651
+ if not return_dict:
1652
+ output = (start_logits, end_logits) + outputs[2:]
1653
+ return ((total_loss,) + output) if total_loss is not None else output
1654
+
1655
+ return QuestionAnsweringModelOutput(
1656
+ loss=total_loss,
1657
+ start_logits=start_logits,
1658
+ end_logits=end_logits,
1659
+ hidden_states=outputs.hidden_states,
1660
+ attentions=outputs.attentions,
1661
+ )
1662
+
1663
+
1664
+ @add_start_docstrings(
1665
+ """
1666
+ The Solar Model transformer with a token classification head on top (a linear layer on top of the hidden-states
1667
+ output) e.g. for Named-Entity-Recognition (NER) tasks.
1668
+ """,
1669
+ SOLAR_START_DOCSTRING,
1670
+ )
1671
+ class SolarForTokenClassification(SolarPreTrainedModel):
1672
+ def __init__(self, config):
1673
+ super().__init__(config)
1674
+ self.num_labels = config.num_labels
1675
+ self.model = SolarModel(config)
1676
+ if getattr(config, "classifier_dropout", None) is not None:
1677
+ classifier_dropout = config.classifier_dropout
1678
+ elif getattr(config, "hidden_dropout", None) is not None:
1679
+ classifier_dropout = config.hidden_dropout
1680
+ else:
1681
+ classifier_dropout = 0.1
1682
+ self.dropout = nn.Dropout(classifier_dropout)
1683
+ self.score = nn.Linear(config.hidden_size, config.num_labels)
1684
+
1685
+ # Initialize weights and apply final processing
1686
+ self.post_init()
1687
+
1688
+ def get_input_embeddings(self):
1689
+ return self.model.embed_tokens
1690
+
1691
+ def set_input_embeddings(self, value):
1692
+ self.model.embed_tokens = value
1693
+
1694
+ @add_start_docstrings_to_model_forward(SOLAR_INPUTS_DOCSTRING)
1695
+ def forward(
1696
+ self,
1697
+ input_ids: Optional[torch.LongTensor] = None,
1698
+ attention_mask: Optional[torch.Tensor] = None,
1699
+ position_ids: Optional[torch.LongTensor] = None,
1700
+ past_key_values: Optional[List[torch.FloatTensor]] = None,
1701
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1702
+ labels: Optional[torch.LongTensor] = None,
1703
+ use_cache: Optional[bool] = None,
1704
+ output_attentions: Optional[bool] = None,
1705
+ output_hidden_states: Optional[bool] = None,
1706
+ return_dict: Optional[bool] = None,
1707
+ ) -> Union[Tuple, TokenClassifierOutput]:
1708
+ r"""
1709
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1710
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
1711
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
1712
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
1713
+ """
1714
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1715
+
1716
+ outputs = self.model(
1717
+ input_ids,
1718
+ attention_mask=attention_mask,
1719
+ position_ids=position_ids,
1720
+ past_key_values=past_key_values,
1721
+ inputs_embeds=inputs_embeds,
1722
+ use_cache=use_cache,
1723
+ output_attentions=output_attentions,
1724
+ output_hidden_states=output_hidden_states,
1725
+ return_dict=return_dict,
1726
+ )
1727
+ sequence_output = outputs[0]
1728
+ sequence_output = self.dropout(sequence_output)
1729
+ logits = self.score(sequence_output)
1730
+
1731
+ loss = None
1732
+ if labels is not None:
1733
+ loss_fct = CrossEntropyLoss()
1734
+ loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
1735
+
1736
+ if not return_dict:
1737
+ output = (logits,) + outputs[2:]
1738
+ return ((loss,) + output) if loss is not None else output
1739
+
1740
+ return TokenClassifierOutput(
1741
+ loss=loss,
1742
+ logits=logits,
1743
+ hidden_states=outputs.hidden_states,
1744
+ attentions=outputs.attentions,
1745
+ )
solar-pro-banner.png ADDED
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|startoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|im_end|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|im_end|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c241ca72f5e6b8ea5dba3cc3eeb37fcbee6e41ef1f28debd0251b03a901c1918
3
+ size 131
tokenizer_config.json ADDED
@@ -0,0 +1,1067 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<|startoftext|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "<|endoftext|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "32000": {
31
+ "content": "<|end|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "32001": {
39
+ "content": "<|assistant|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "32002": {
47
+ "content": "<|placeholder1|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": true,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "32003": {
55
+ "content": "<|placeholder2|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": true,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "32004": {
63
+ "content": "<|placeholder3|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": true,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "32005": {
71
+ "content": "<|placeholder4|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": true,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "32006": {
79
+ "content": "<|system|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "32007": {
87
+ "content": "<|im_end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "32008": {
95
+ "content": "<|placeholder5|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": true,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "32009": {
103
+ "content": "<|placeholder6|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": true,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "32010": {
111
+ "content": "<|im_start|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "32011": {
119
+ "content": "<|placeholder7|>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": true,
123
+ "single_word": false,
124
+ "special": true
125
+ },
126
+ "32012": {
127
+ "content": "<|placeholder8|>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": true,
131
+ "single_word": false,
132
+ "special": true
133
+ },
134
+ "32013": {
135
+ "content": "<|placeholder9|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": true,
139
+ "single_word": false,
140
+ "special": true
141
+ },
142
+ "32014": {
143
+ "content": "<|placeholder10|>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": true,
147
+ "single_word": false,
148
+ "special": true
149
+ },
150
+ "32015": {
151
+ "content": "<|placeholder11|>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": true,
155
+ "single_word": false,
156
+ "special": true
157
+ },
158
+ "32016": {
159
+ "content": "<|placeholder12|>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": true,
163
+ "single_word": false,
164
+ "special": true
165
+ },
166
+ "32017": {
167
+ "content": "<|placeholder13|>",
168
+ "lstrip": false,
169
+ "normalized": false,
170
+ "rstrip": true,
171
+ "single_word": false,
172
+ "special": true
173
+ },
174
+ "32018": {
175
+ "content": "<|placeholder14|>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": true,
179
+ "single_word": false,
180
+ "special": true
181
+ },
182
+ "32019": {
183
+ "content": "<|placeholder15|>",
184
+ "lstrip": false,
185
+ "normalized": false,
186
+ "rstrip": true,
187
+ "single_word": false,
188
+ "special": true
189
+ },
190
+ "32020": {
191
+ "content": "<|placeholder16|>",
192
+ "lstrip": false,
193
+ "normalized": false,
194
+ "rstrip": true,
195
+ "single_word": false,
196
+ "special": true
197
+ },
198
+ "32021": {
199
+ "content": "<|placeholder17|>",
200
+ "lstrip": false,
201
+ "normalized": false,
202
+ "rstrip": true,
203
+ "single_word": false,
204
+ "special": true
205
+ },
206
+ "32022": {
207
+ "content": "<|placeholder18|>",
208
+ "lstrip": false,
209
+ "normalized": false,
210
+ "rstrip": true,
211
+ "single_word": false,
212
+ "special": true
213
+ },
214
+ "32023": {
215
+ "content": "<|placeholder19|>",
216
+ "lstrip": false,
217
+ "normalized": false,
218
+ "rstrip": true,
219
+ "single_word": false,
220
+ "special": true
221
+ },
222
+ "32024": {
223
+ "content": "<|placeholder20|>",
224
+ "lstrip": false,
225
+ "normalized": false,
226
+ "rstrip": true,
227
+ "single_word": false,
228
+ "special": true
229
+ },
230
+ "32025": {
231
+ "content": "<|placeholder21|>",
232
+ "lstrip": false,
233
+ "normalized": false,
234
+ "rstrip": true,
235
+ "single_word": false,
236
+ "special": true
237
+ },
238
+ "32026": {
239
+ "content": "<|placeholder22|>",
240
+ "lstrip": false,
241
+ "normalized": false,
242
+ "rstrip": true,
243
+ "single_word": false,
244
+ "special": true
245
+ },
246
+ "32027": {
247
+ "content": "<|placeholder23|>",
248
+ "lstrip": false,
249
+ "normalized": false,
250
+ "rstrip": true,
251
+ "single_word": false,
252
+ "special": true
253
+ },
254
+ "32028": {
255
+ "content": "<|placeholder24|>",
256
+ "lstrip": false,
257
+ "normalized": false,
258
+ "rstrip": true,
259
+ "single_word": false,
260
+ "special": true
261
+ },
262
+ "32029": {
263
+ "content": "<|placeholder25|>",
264
+ "lstrip": false,
265
+ "normalized": false,
266
+ "rstrip": true,
267
+ "single_word": false,
268
+ "special": true
269
+ },
270
+ "32030": {
271
+ "content": "<|placeholder26|>",
272
+ "lstrip": false,
273
+ "normalized": false,
274
+ "rstrip": true,
275
+ "single_word": false,
276
+ "special": true
277
+ },
278
+ "32031": {
279
+ "content": "<|placeholder27|>",
280
+ "lstrip": false,
281
+ "normalized": false,
282
+ "rstrip": true,
283
+ "single_word": false,
284
+ "special": true
285
+ },
286
+ "32032": {
287
+ "content": "<|placeholder28|>",
288
+ "lstrip": false,
289
+ "normalized": false,
290
+ "rstrip": true,
291
+ "single_word": false,
292
+ "special": true
293
+ },
294
+ "32033": {
295
+ "content": "<|placeholder29|>",
296
+ "lstrip": false,
297
+ "normalized": false,
298
+ "rstrip": true,
299
+ "single_word": false,
300
+ "special": true
301
+ },
302
+ "32034": {
303
+ "content": "<|placeholder30|>",
304
+ "lstrip": false,
305
+ "normalized": false,
306
+ "rstrip": true,
307
+ "single_word": false,
308
+ "special": true
309
+ },
310
+ "32035": {
311
+ "content": "<|placeholder31|>",
312
+ "lstrip": false,
313
+ "normalized": false,
314
+ "rstrip": true,
315
+ "single_word": false,
316
+ "special": true
317
+ },
318
+ "32036": {
319
+ "content": "<|placeholder32|>",
320
+ "lstrip": false,
321
+ "normalized": false,
322
+ "rstrip": true,
323
+ "single_word": false,
324
+ "special": true
325
+ },
326
+ "32037": {
327
+ "content": "<|placeholder33|>",
328
+ "lstrip": false,
329
+ "normalized": false,
330
+ "rstrip": true,
331
+ "single_word": false,
332
+ "special": true
333
+ },
334
+ "32038": {
335
+ "content": "<|placeholder34|>",
336
+ "lstrip": false,
337
+ "normalized": false,
338
+ "rstrip": true,
339
+ "single_word": false,
340
+ "special": true
341
+ },
342
+ "32039": {
343
+ "content": "<|placeholder35|>",
344
+ "lstrip": false,
345
+ "normalized": false,
346
+ "rstrip": true,
347
+ "single_word": false,
348
+ "special": true
349
+ },
350
+ "32040": {
351
+ "content": "<|placeholder36|>",
352
+ "lstrip": false,
353
+ "normalized": false,
354
+ "rstrip": true,
355
+ "single_word": false,
356
+ "special": true
357
+ },
358
+ "32041": {
359
+ "content": "<|placeholder37|>",
360
+ "lstrip": false,
361
+ "normalized": false,
362
+ "rstrip": true,
363
+ "single_word": false,
364
+ "special": true
365
+ },
366
+ "32042": {
367
+ "content": "<|placeholder38|>",
368
+ "lstrip": false,
369
+ "normalized": false,
370
+ "rstrip": true,
371
+ "single_word": false,
372
+ "special": true
373
+ },
374
+ "32043": {
375
+ "content": "<|placeholder39|>",
376
+ "lstrip": false,
377
+ "normalized": false,
378
+ "rstrip": true,
379
+ "single_word": false,
380
+ "special": true
381
+ },
382
+ "32044": {
383
+ "content": "<|placeholder40|>",
384
+ "lstrip": false,
385
+ "normalized": false,
386
+ "rstrip": true,
387
+ "single_word": false,
388
+ "special": true
389
+ },
390
+ "32045": {
391
+ "content": "<|placeholder41|>",
392
+ "lstrip": false,
393
+ "normalized": false,
394
+ "rstrip": true,
395
+ "single_word": false,
396
+ "special": true
397
+ },
398
+ "32046": {
399
+ "content": "<|placeholder42|>",
400
+ "lstrip": false,
401
+ "normalized": false,
402
+ "rstrip": true,
403
+ "single_word": false,
404
+ "special": true
405
+ },
406
+ "32047": {
407
+ "content": "<|placeholder43|>",
408
+ "lstrip": false,
409
+ "normalized": false,
410
+ "rstrip": true,
411
+ "single_word": false,
412
+ "special": true
413
+ },
414
+ "32048": {
415
+ "content": "<|placeholder44|>",
416
+ "lstrip": false,
417
+ "normalized": false,
418
+ "rstrip": true,
419
+ "single_word": false,
420
+ "special": true
421
+ },
422
+ "32049": {
423
+ "content": "<|placeholder45|>",
424
+ "lstrip": false,
425
+ "normalized": false,
426
+ "rstrip": true,
427
+ "single_word": false,
428
+ "special": true
429
+ },
430
+ "32050": {
431
+ "content": "<|placeholder46|>",
432
+ "lstrip": false,
433
+ "normalized": false,
434
+ "rstrip": true,
435
+ "single_word": false,
436
+ "special": true
437
+ },
438
+ "32051": {
439
+ "content": "<|placeholder47|>",
440
+ "lstrip": false,
441
+ "normalized": false,
442
+ "rstrip": true,
443
+ "single_word": false,
444
+ "special": true
445
+ },
446
+ "32052": {
447
+ "content": "<|placeholder48|>",
448
+ "lstrip": false,
449
+ "normalized": false,
450
+ "rstrip": true,
451
+ "single_word": false,
452
+ "special": true
453
+ },
454
+ "32053": {
455
+ "content": "<|placeholder49|>",
456
+ "lstrip": false,
457
+ "normalized": false,
458
+ "rstrip": true,
459
+ "single_word": false,
460
+ "special": true
461
+ },
462
+ "32054": {
463
+ "content": "<|placeholder50|>",
464
+ "lstrip": false,
465
+ "normalized": false,
466
+ "rstrip": true,
467
+ "single_word": false,
468
+ "special": true
469
+ },
470
+ "32055": {
471
+ "content": "<|placeholder51|>",
472
+ "lstrip": false,
473
+ "normalized": false,
474
+ "rstrip": true,
475
+ "single_word": false,
476
+ "special": true
477
+ },
478
+ "32056": {
479
+ "content": "<|placeholder52|>",
480
+ "lstrip": false,
481
+ "normalized": false,
482
+ "rstrip": true,
483
+ "single_word": false,
484
+ "special": true
485
+ },
486
+ "32057": {
487
+ "content": "<|placeholder53|>",
488
+ "lstrip": false,
489
+ "normalized": false,
490
+ "rstrip": true,
491
+ "single_word": false,
492
+ "special": true
493
+ },
494
+ "32058": {
495
+ "content": "<|placeholder54|>",
496
+ "lstrip": false,
497
+ "normalized": false,
498
+ "rstrip": true,
499
+ "single_word": false,
500
+ "special": true
501
+ },
502
+ "32059": {
503
+ "content": "<|placeholder55|>",
504
+ "lstrip": false,
505
+ "normalized": false,
506
+ "rstrip": true,
507
+ "single_word": false,
508
+ "special": true
509
+ },
510
+ "32060": {
511
+ "content": "<|placeholder56|>",
512
+ "lstrip": false,
513
+ "normalized": false,
514
+ "rstrip": true,
515
+ "single_word": false,
516
+ "special": true
517
+ },
518
+ "32061": {
519
+ "content": "<|placeholder57|>",
520
+ "lstrip": false,
521
+ "normalized": false,
522
+ "rstrip": true,
523
+ "single_word": false,
524
+ "special": true
525
+ },
526
+ "32062": {
527
+ "content": "<|placeholder58|>",
528
+ "lstrip": false,
529
+ "normalized": false,
530
+ "rstrip": true,
531
+ "single_word": false,
532
+ "special": true
533
+ },
534
+ "32063": {
535
+ "content": "<|placeholder59|>",
536
+ "lstrip": false,
537
+ "normalized": false,
538
+ "rstrip": true,
539
+ "single_word": false,
540
+ "special": true
541
+ },
542
+ "32064": {
543
+ "content": "<|placeholder60|>",
544
+ "lstrip": false,
545
+ "normalized": false,
546
+ "rstrip": true,
547
+ "single_word": false,
548
+ "special": true
549
+ },
550
+ "32065": {
551
+ "content": "<|placeholder61|>",
552
+ "lstrip": false,
553
+ "normalized": false,
554
+ "rstrip": true,
555
+ "single_word": false,
556
+ "special": true
557
+ },
558
+ "32066": {
559
+ "content": "<|placeholder62|>",
560
+ "lstrip": false,
561
+ "normalized": false,
562
+ "rstrip": true,
563
+ "single_word": false,
564
+ "special": true
565
+ },
566
+ "32067": {
567
+ "content": "<|placeholder63|>",
568
+ "lstrip": false,
569
+ "normalized": false,
570
+ "rstrip": true,
571
+ "single_word": false,
572
+ "special": true
573
+ },
574
+ "32068": {
575
+ "content": "<|placeholder64|>",
576
+ "lstrip": false,
577
+ "normalized": false,
578
+ "rstrip": true,
579
+ "single_word": false,
580
+ "special": true
581
+ },
582
+ "32069": {
583
+ "content": "<|placeholder65|>",
584
+ "lstrip": false,
585
+ "normalized": false,
586
+ "rstrip": true,
587
+ "single_word": false,
588
+ "special": true
589
+ },
590
+ "32070": {
591
+ "content": "<|placeholder66|>",
592
+ "lstrip": false,
593
+ "normalized": false,
594
+ "rstrip": true,
595
+ "single_word": false,
596
+ "special": true
597
+ },
598
+ "32071": {
599
+ "content": "<|placeholder67|>",
600
+ "lstrip": false,
601
+ "normalized": false,
602
+ "rstrip": true,
603
+ "single_word": false,
604
+ "special": true
605
+ },
606
+ "32072": {
607
+ "content": "<|placeholder68|>",
608
+ "lstrip": false,
609
+ "normalized": false,
610
+ "rstrip": true,
611
+ "single_word": false,
612
+ "special": true
613
+ },
614
+ "32073": {
615
+ "content": "<|placeholder69|>",
616
+ "lstrip": false,
617
+ "normalized": false,
618
+ "rstrip": true,
619
+ "single_word": false,
620
+ "special": true
621
+ },
622
+ "32074": {
623
+ "content": "<|placeholder70|>",
624
+ "lstrip": false,
625
+ "normalized": false,
626
+ "rstrip": true,
627
+ "single_word": false,
628
+ "special": true
629
+ },
630
+ "32075": {
631
+ "content": "<|placeholder71|>",
632
+ "lstrip": false,
633
+ "normalized": false,
634
+ "rstrip": true,
635
+ "single_word": false,
636
+ "special": true
637
+ },
638
+ "32076": {
639
+ "content": "<|placeholder72|>",
640
+ "lstrip": false,
641
+ "normalized": false,
642
+ "rstrip": true,
643
+ "single_word": false,
644
+ "special": true
645
+ },
646
+ "32077": {
647
+ "content": "<|placeholder73|>",
648
+ "lstrip": false,
649
+ "normalized": false,
650
+ "rstrip": true,
651
+ "single_word": false,
652
+ "special": true
653
+ },
654
+ "32078": {
655
+ "content": "<|placeholder74|>",
656
+ "lstrip": false,
657
+ "normalized": false,
658
+ "rstrip": true,
659
+ "single_word": false,
660
+ "special": true
661
+ },
662
+ "32079": {
663
+ "content": "<|placeholder75|>",
664
+ "lstrip": false,
665
+ "normalized": false,
666
+ "rstrip": true,
667
+ "single_word": false,
668
+ "special": true
669
+ },
670
+ "32080": {
671
+ "content": "<|placeholder76|>",
672
+ "lstrip": false,
673
+ "normalized": false,
674
+ "rstrip": true,
675
+ "single_word": false,
676
+ "special": true
677
+ },
678
+ "32081": {
679
+ "content": "<|placeholder77|>",
680
+ "lstrip": false,
681
+ "normalized": false,
682
+ "rstrip": true,
683
+ "single_word": false,
684
+ "special": true
685
+ },
686
+ "32082": {
687
+ "content": "<|placeholder78|>",
688
+ "lstrip": false,
689
+ "normalized": false,
690
+ "rstrip": true,
691
+ "single_word": false,
692
+ "special": true
693
+ },
694
+ "32083": {
695
+ "content": "<|placeholder79|>",
696
+ "lstrip": false,
697
+ "normalized": false,
698
+ "rstrip": true,
699
+ "single_word": false,
700
+ "special": true
701
+ },
702
+ "32084": {
703
+ "content": "<|placeholder80|>",
704
+ "lstrip": false,
705
+ "normalized": false,
706
+ "rstrip": true,
707
+ "single_word": false,
708
+ "special": true
709
+ },
710
+ "32085": {
711
+ "content": "<|placeholder81|>",
712
+ "lstrip": false,
713
+ "normalized": false,
714
+ "rstrip": true,
715
+ "single_word": false,
716
+ "special": true
717
+ },
718
+ "32086": {
719
+ "content": "<|placeholder82|>",
720
+ "lstrip": false,
721
+ "normalized": false,
722
+ "rstrip": true,
723
+ "single_word": false,
724
+ "special": true
725
+ },
726
+ "32087": {
727
+ "content": "<|placeholder83|>",
728
+ "lstrip": false,
729
+ "normalized": false,
730
+ "rstrip": true,
731
+ "single_word": false,
732
+ "special": true
733
+ },
734
+ "32088": {
735
+ "content": "<|placeholder84|>",
736
+ "lstrip": false,
737
+ "normalized": false,
738
+ "rstrip": true,
739
+ "single_word": false,
740
+ "special": true
741
+ },
742
+ "32089": {
743
+ "content": "<|placeholder85|>",
744
+ "lstrip": false,
745
+ "normalized": false,
746
+ "rstrip": true,
747
+ "single_word": false,
748
+ "special": true
749
+ },
750
+ "32090": {
751
+ "content": "<|placeholder86|>",
752
+ "lstrip": false,
753
+ "normalized": false,
754
+ "rstrip": true,
755
+ "single_word": false,
756
+ "special": true
757
+ },
758
+ "32091": {
759
+ "content": "<|placeholder87|>",
760
+ "lstrip": false,
761
+ "normalized": false,
762
+ "rstrip": true,
763
+ "single_word": false,
764
+ "special": true
765
+ },
766
+ "32092": {
767
+ "content": "<|placeholder88|>",
768
+ "lstrip": false,
769
+ "normalized": false,
770
+ "rstrip": true,
771
+ "single_word": false,
772
+ "special": true
773
+ },
774
+ "32093": {
775
+ "content": "<|placeholder89|>",
776
+ "lstrip": false,
777
+ "normalized": false,
778
+ "rstrip": true,
779
+ "single_word": false,
780
+ "special": true
781
+ },
782
+ "32094": {
783
+ "content": "<|placeholder90|>",
784
+ "lstrip": false,
785
+ "normalized": false,
786
+ "rstrip": true,
787
+ "single_word": false,
788
+ "special": true
789
+ },
790
+ "32095": {
791
+ "content": "<|placeholder91|>",
792
+ "lstrip": false,
793
+ "normalized": false,
794
+ "rstrip": true,
795
+ "single_word": false,
796
+ "special": true
797
+ },
798
+ "32096": {
799
+ "content": "<|placeholder92|>",
800
+ "lstrip": false,
801
+ "normalized": false,
802
+ "rstrip": true,
803
+ "single_word": false,
804
+ "special": true
805
+ },
806
+ "32097": {
807
+ "content": "<|placeholder93|>",
808
+ "lstrip": false,
809
+ "normalized": false,
810
+ "rstrip": true,
811
+ "single_word": false,
812
+ "special": true
813
+ },
814
+ "32098": {
815
+ "content": "<|placeholder94|>",
816
+ "lstrip": false,
817
+ "normalized": false,
818
+ "rstrip": true,
819
+ "single_word": false,
820
+ "special": true
821
+ },
822
+ "32099": {
823
+ "content": "<|placeholder95|>",
824
+ "lstrip": false,
825
+ "normalized": false,
826
+ "rstrip": true,
827
+ "single_word": false,
828
+ "special": true
829
+ },
830
+ "32100": {
831
+ "content": "<|placeholder96|>",
832
+ "lstrip": false,
833
+ "normalized": false,
834
+ "rstrip": true,
835
+ "single_word": false,
836
+ "special": true
837
+ },
838
+ "32101": {
839
+ "content": "<|placeholder97|>",
840
+ "lstrip": false,
841
+ "normalized": false,
842
+ "rstrip": true,
843
+ "single_word": false,
844
+ "special": true
845
+ },
846
+ "32102": {
847
+ "content": "<|placeholder98|>",
848
+ "lstrip": false,
849
+ "normalized": false,
850
+ "rstrip": true,
851
+ "single_word": false,
852
+ "special": true
853
+ },
854
+ "32103": {
855
+ "content": "<|placeholder99|>",
856
+ "lstrip": false,
857
+ "normalized": false,
858
+ "rstrip": true,
859
+ "single_word": false,
860
+ "special": true
861
+ },
862
+ "32104": {
863
+ "content": "<|placeholder100|>",
864
+ "lstrip": false,
865
+ "normalized": false,
866
+ "rstrip": true,
867
+ "single_word": false,
868
+ "special": true
869
+ },
870
+ "32105": {
871
+ "content": "<|placeholder101|>",
872
+ "lstrip": false,
873
+ "normalized": false,
874
+ "rstrip": true,
875
+ "single_word": false,
876
+ "special": true
877
+ },
878
+ "32106": {
879
+ "content": "<|placeholder102|>",
880
+ "lstrip": false,
881
+ "normalized": false,
882
+ "rstrip": true,
883
+ "single_word": false,
884
+ "special": true
885
+ },
886
+ "32107": {
887
+ "content": "<|placeholder103|>",
888
+ "lstrip": false,
889
+ "normalized": false,
890
+ "rstrip": true,
891
+ "single_word": false,
892
+ "special": true
893
+ },
894
+ "32108": {
895
+ "content": "<|placeholder104|>",
896
+ "lstrip": false,
897
+ "normalized": false,
898
+ "rstrip": true,
899
+ "single_word": false,
900
+ "special": true
901
+ },
902
+ "32109": {
903
+ "content": "<|placeholder105|>",
904
+ "lstrip": false,
905
+ "normalized": false,
906
+ "rstrip": true,
907
+ "single_word": false,
908
+ "special": true
909
+ },
910
+ "32110": {
911
+ "content": "<|placeholder106|>",
912
+ "lstrip": false,
913
+ "normalized": false,
914
+ "rstrip": true,
915
+ "single_word": false,
916
+ "special": true
917
+ },
918
+ "32111": {
919
+ "content": "<|placeholder107|>",
920
+ "lstrip": false,
921
+ "normalized": false,
922
+ "rstrip": true,
923
+ "single_word": false,
924
+ "special": true
925
+ },
926
+ "32112": {
927
+ "content": "<|placeholder108|>",
928
+ "lstrip": false,
929
+ "normalized": false,
930
+ "rstrip": true,
931
+ "single_word": false,
932
+ "special": true
933
+ },
934
+ "32113": {
935
+ "content": "<|placeholder109|>",
936
+ "lstrip": false,
937
+ "normalized": false,
938
+ "rstrip": true,
939
+ "single_word": false,
940
+ "special": true
941
+ },
942
+ "32114": {
943
+ "content": "<|placeholder110|>",
944
+ "lstrip": false,
945
+ "normalized": false,
946
+ "rstrip": true,
947
+ "single_word": false,
948
+ "special": true
949
+ },
950
+ "32115": {
951
+ "content": "<|placeholder111|>",
952
+ "lstrip": false,
953
+ "normalized": false,
954
+ "rstrip": true,
955
+ "single_word": false,
956
+ "special": true
957
+ },
958
+ "32116": {
959
+ "content": "<|placeholder112|>",
960
+ "lstrip": false,
961
+ "normalized": false,
962
+ "rstrip": true,
963
+ "single_word": false,
964
+ "special": true
965
+ },
966
+ "32117": {
967
+ "content": "<|placeholder113|>",
968
+ "lstrip": false,
969
+ "normalized": false,
970
+ "rstrip": true,
971
+ "single_word": false,
972
+ "special": true
973
+ },
974
+ "32118": {
975
+ "content": "<|placeholder114|>",
976
+ "lstrip": false,
977
+ "normalized": false,
978
+ "rstrip": true,
979
+ "single_word": false,
980
+ "special": true
981
+ },
982
+ "32119": {
983
+ "content": "<|placeholder115|>",
984
+ "lstrip": false,
985
+ "normalized": false,
986
+ "rstrip": true,
987
+ "single_word": false,
988
+ "special": true
989
+ },
990
+ "32120": {
991
+ "content": "<|placeholder116|>",
992
+ "lstrip": false,
993
+ "normalized": false,
994
+ "rstrip": true,
995
+ "single_word": false,
996
+ "special": true
997
+ },
998
+ "32121": {
999
+ "content": "<|placeholder117|>",
1000
+ "lstrip": false,
1001
+ "normalized": false,
1002
+ "rstrip": true,
1003
+ "single_word": false,
1004
+ "special": true
1005
+ },
1006
+ "32122": {
1007
+ "content": "<|placeholder118|>",
1008
+ "lstrip": false,
1009
+ "normalized": false,
1010
+ "rstrip": true,
1011
+ "single_word": false,
1012
+ "special": true
1013
+ },
1014
+ "32123": {
1015
+ "content": "<|placeholder119|>",
1016
+ "lstrip": false,
1017
+ "normalized": false,
1018
+ "rstrip": true,
1019
+ "single_word": false,
1020
+ "special": true
1021
+ },
1022
+ "32124": {
1023
+ "content": "<|placeholder120|>",
1024
+ "lstrip": false,
1025
+ "normalized": false,
1026
+ "rstrip": true,
1027
+ "single_word": false,
1028
+ "special": true
1029
+ },
1030
+ "32125": {
1031
+ "content": "<|placeholder121|>",
1032
+ "lstrip": false,
1033
+ "normalized": false,
1034
+ "rstrip": true,
1035
+ "single_word": false,
1036
+ "special": true
1037
+ },
1038
+ "32126": {
1039
+ "content": "<|placeholder122|>",
1040
+ "lstrip": false,
1041
+ "normalized": false,
1042
+ "rstrip": true,
1043
+ "single_word": false,
1044
+ "special": true
1045
+ },
1046
+ "32127": {
1047
+ "content": "<|placeholder123|>",
1048
+ "lstrip": false,
1049
+ "normalized": false,
1050
+ "rstrip": true,
1051
+ "single_word": false,
1052
+ "special": true
1053
+ }
1054
+ },
1055
+ "bos_token": "<|startoftext|>",
1056
+ "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
1057
+ "clean_up_tokenization_spaces": false,
1058
+ "eos_token": "<|im_end|>",
1059
+ "legacy": true,
1060
+ "model_max_length": 4096,
1061
+ "pad_token": "<|im_end|>",
1062
+ "padding_side": "left",
1063
+ "sp_model_kwargs": {},
1064
+ "tokenizer_class": "LlamaTokenizer",
1065
+ "unk_token": "<unk>",
1066
+ "use_default_system_prompt": false
1067
+ }
vllm_solar.py ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Adapted from
3
+ # https://github.com/huggingface/transformers/blob/v4.28.0/src/transformers/models/llama/modeling_llama.py
4
+ # Copyright 2023 The vLLM team.
5
+ # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
6
+ #
7
+ # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
8
+ # and OPT implementations in this library. It has been modified from its
9
+ # original forms to accommodate minor architectural differences compared
10
+ # to GPT-NeoX and OPT used by the Meta AI team that trained the model.
11
+ #
12
+ # Licensed under the Apache License, Version 2.0 (the "License");
13
+ # you may not use this file except in compliance with the License.
14
+ # You may obtain a copy of the License at
15
+ #
16
+ # http://www.apache.org/licenses/LICENSE-2.0
17
+ #
18
+ # Unless required by applicable law or agreed to in writing, software
19
+ # distributed under the License is distributed on an "AS IS" BASIS,
20
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ # See the License for the specific language governing permissions and
22
+ # limitations under the License.
23
+ """Inference-only Solar model compatible with HuggingFace weights."""
24
+ from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
25
+
26
+ import torch
27
+ from torch import nn
28
+
29
+ from vllm.attention import Attention, AttentionMetadata
30
+ from vllm.config import CacheConfig, LoRAConfig
31
+ from vllm.distributed import (get_pp_group, get_tensor_model_parallel_rank,
32
+ get_tensor_model_parallel_world_size)
33
+ from vllm.model_executor.layers.activation import SiluAndMul
34
+ from vllm.model_executor.layers.layernorm import RMSNorm
35
+ from vllm.model_executor.layers.linear import (MergedColumnParallelLinear,
36
+ QKVParallelLinear,
37
+ RowParallelLinear)
38
+ from vllm.model_executor.layers.logits_processor import LogitsProcessor
39
+ from vllm.model_executor.layers.quantization.base_config import (
40
+ QuantizationConfig)
41
+ from vllm.model_executor.layers.quantization.compressed_tensors.utils import (
42
+ get_compressed_tensors_cache_scale)
43
+ from vllm.model_executor.layers.rotary_embedding import get_rope
44
+ from vllm.model_executor.layers.sampler import Sampler
45
+ from vllm.model_executor.layers.vocab_parallel_embedding import (
46
+ DEFAULT_VOCAB_PADDING_SIZE, ParallelLMHead, VocabParallelEmbedding)
47
+ from vllm.model_executor.model_loader.weight_utils import (
48
+ default_weight_loader, kv_cache_scales_loader, maybe_remap_kv_scale_name)
49
+ from vllm.model_executor.sampling_metadata import SamplingMetadata
50
+ from vllm.sequence import IntermediateTensors, SamplerOutput
51
+ from vllm.utils import is_hip
52
+
53
+ from vllm.model_executor.models.interfaces import SupportsLoRA
54
+ from vllm.model_executor.models.utils import PPMissingLayer, is_pp_missing_parameter, make_layers
55
+
56
+ class SolarMLP(nn.Module):
57
+
58
+ def __init__(
59
+ self,
60
+ hidden_size: int,
61
+ intermediate_size: int,
62
+ hidden_act: str,
63
+ quant_config: Optional[QuantizationConfig] = None,
64
+ bias: bool = False,
65
+ prefix: str = "",
66
+ ) -> None:
67
+ super().__init__()
68
+ self.gate_up_proj = MergedColumnParallelLinear(
69
+ input_size=hidden_size,
70
+ output_sizes=[intermediate_size] * 2,
71
+ bias=bias,
72
+ quant_config=quant_config,
73
+ prefix=f"{prefix}.gate_up_proj")
74
+ self.down_proj = RowParallelLinear(input_size=intermediate_size,
75
+ output_size=hidden_size,
76
+ bias=bias,
77
+ quant_config=quant_config,
78
+ prefix=f"{prefix}.down_proj")
79
+ if hidden_act != "silu":
80
+ raise ValueError(f"Unsupported activation: {hidden_act}. "
81
+ "Only silu is supported for now.")
82
+ self.act_fn = SiluAndMul()
83
+
84
+ def forward(self, x):
85
+ gate_up, _ = self.gate_up_proj(x)
86
+ x = self.act_fn(gate_up)
87
+ x, _ = self.down_proj(x)
88
+ return x
89
+
90
+
91
+ class SolarAttention(nn.Module):
92
+
93
+ def __init__(
94
+ self,
95
+ config,
96
+ hidden_size: int,
97
+ num_heads: int,
98
+ num_kv_heads: int,
99
+ rope_theta: float = 10000,
100
+ rope_scaling: Optional[Dict[str, Any]] = None,
101
+ max_position_embeddings: int = 8192,
102
+ quant_config: Optional[QuantizationConfig] = None,
103
+ bias: bool = False,
104
+ cache_config: Optional[CacheConfig] = None,
105
+ prefix: str = "",
106
+ ) -> None:
107
+ super().__init__()
108
+ self.hidden_size = hidden_size
109
+ tp_size = get_tensor_model_parallel_world_size()
110
+ self.total_num_heads = num_heads
111
+ assert self.total_num_heads % tp_size == 0
112
+ self.num_heads = self.total_num_heads // tp_size
113
+ self.total_num_kv_heads = num_kv_heads
114
+ if self.total_num_kv_heads >= tp_size:
115
+ # Number of KV heads is greater than TP size, so we partition
116
+ # the KV heads across multiple tensor parallel GPUs.
117
+ assert self.total_num_kv_heads % tp_size == 0
118
+ else:
119
+ # Number of KV heads is less than TP size, so we replicate
120
+ # the KV heads across multiple tensor parallel GPUs.
121
+ assert tp_size % self.total_num_kv_heads == 0
122
+ self.num_kv_heads = max(1, self.total_num_kv_heads // tp_size)
123
+ # MistralConfig has an optional head_dim introduced by Mistral-Nemo
124
+ self.head_dim = getattr(config, "head_dim",
125
+ self.hidden_size // self.total_num_heads)
126
+ self.q_size = self.num_heads * self.head_dim
127
+ self.kv_size = self.num_kv_heads * self.head_dim
128
+ self.scaling = self.head_dim**-0.5
129
+ self.rope_theta = rope_theta
130
+ self.max_position_embeddings = max_position_embeddings
131
+
132
+ self.qkv_proj = QKVParallelLinear(
133
+ hidden_size=hidden_size,
134
+ head_size=self.head_dim,
135
+ total_num_heads=self.total_num_heads,
136
+ total_num_kv_heads=self.total_num_kv_heads,
137
+ bias=bias,
138
+ quant_config=quant_config,
139
+ prefix=f"{prefix}.qkv_proj",
140
+ )
141
+ self.o_proj = RowParallelLinear(
142
+ input_size=self.total_num_heads * self.head_dim,
143
+ output_size=hidden_size,
144
+ bias=bias,
145
+ quant_config=quant_config,
146
+ prefix=f"{prefix}.o_proj",
147
+ )
148
+
149
+ self.rotary_emb = get_rope(
150
+ self.head_dim,
151
+ rotary_dim=self.head_dim,
152
+ max_position=max_position_embeddings,
153
+ base=rope_theta,
154
+ rope_scaling=rope_scaling,
155
+ )
156
+ self.attn = Attention(self.num_heads,
157
+ self.head_dim,
158
+ self.scaling,
159
+ num_kv_heads=self.num_kv_heads,
160
+ cache_config=cache_config,
161
+ quant_config=quant_config)
162
+
163
+ def forward(
164
+ self,
165
+ positions: torch.Tensor,
166
+ hidden_states: torch.Tensor,
167
+ kv_cache: torch.Tensor,
168
+ attn_metadata: AttentionMetadata,
169
+ ) -> torch.Tensor:
170
+ qkv, _ = self.qkv_proj(hidden_states)
171
+ q, k, v = qkv.split([self.q_size, self.kv_size, self.kv_size], dim=-1)
172
+ q, k = self.rotary_emb(positions, q, k)
173
+ attn_output = self.attn(q, k, v, kv_cache, attn_metadata)
174
+ output, _ = self.o_proj(attn_output)
175
+ return output
176
+
177
+
178
+ class SolarDecoderLayer(nn.Module):
179
+
180
+ def __init__(
181
+ self,
182
+ config,
183
+ cache_config: Optional[CacheConfig] = None,
184
+ quant_config: Optional[QuantizationConfig] = None,
185
+ prefix: str = "",
186
+ ) -> None:
187
+ super().__init__()
188
+ self.hidden_size = config.hidden_size
189
+ rope_theta = getattr(config, "rope_theta", 10000)
190
+ rope_scaling = getattr(config, "rope_scaling", None)
191
+ if rope_scaling is not None and getattr(
192
+ config, "original_max_position_embeddings", None):
193
+ rope_scaling["original_max_position_embeddings"] = (
194
+ config.original_max_position_embeddings)
195
+ max_position_embeddings = getattr(config, "max_position_embeddings",
196
+ 8192)
197
+ # Support abacusai/Smaug-72B-v0.1 with attention_bias
198
+ # Support internlm/internlm-7b with bias
199
+ attention_bias = getattr(config, "attention_bias", False) or getattr(
200
+ config, "bias", False)
201
+ self.self_attn = SolarAttention(
202
+ config=config,
203
+ hidden_size=self.hidden_size,
204
+ num_heads=config.num_attention_heads,
205
+ num_kv_heads=getattr(config, "num_key_value_heads",
206
+ config.num_attention_heads),
207
+ rope_theta=rope_theta,
208
+ rope_scaling=rope_scaling,
209
+ max_position_embeddings=max_position_embeddings,
210
+ quant_config=quant_config,
211
+ bias=attention_bias,
212
+ cache_config=cache_config,
213
+ prefix=f"{prefix}.self_attn",
214
+ )
215
+ self.mlp = SolarMLP(
216
+ hidden_size=self.hidden_size,
217
+ intermediate_size=config.intermediate_size,
218
+ hidden_act=config.hidden_act,
219
+ quant_config=quant_config,
220
+ bias=getattr(config, "mlp_bias", False),
221
+ prefix=f"{prefix}.mlp",
222
+ )
223
+ self.input_layernorm = RMSNorm(config.hidden_size,
224
+ eps=config.rms_norm_eps)
225
+ self.post_attention_layernorm = RMSNorm(config.hidden_size,
226
+ eps=config.rms_norm_eps)
227
+
228
+ def forward(
229
+ self,
230
+ positions: torch.Tensor,
231
+ hidden_states: torch.Tensor,
232
+ kv_cache: torch.Tensor,
233
+ attn_metadata: AttentionMetadata,
234
+ residual: Optional[torch.Tensor],
235
+ ) -> Tuple[torch.Tensor, torch.Tensor]:
236
+ # Self Attention
237
+ if residual is None:
238
+ residual = hidden_states
239
+ hidden_states = self.input_layernorm(hidden_states)
240
+ else:
241
+ hidden_states, residual = self.input_layernorm(
242
+ hidden_states, residual)
243
+ hidden_states = self.self_attn(
244
+ positions=positions,
245
+ hidden_states=hidden_states,
246
+ kv_cache=kv_cache,
247
+ attn_metadata=attn_metadata,
248
+ )
249
+
250
+ # Fully Connected
251
+ hidden_states, residual = self.post_attention_layernorm(
252
+ hidden_states, residual)
253
+ hidden_states = self.mlp(hidden_states)
254
+ return hidden_states, residual
255
+
256
+
257
+ class SolarModel(nn.Module):
258
+
259
+ def __init__(
260
+ self,
261
+ config,
262
+ cache_config: Optional[CacheConfig] = None,
263
+ quant_config: Optional[QuantizationConfig] = None,
264
+ lora_config: Optional[LoRAConfig] = None,
265
+ prefix: str = "",
266
+ ) -> None:
267
+ super().__init__()
268
+ self.config = config
269
+ self.padding_idx = config.pad_token_id
270
+ lora_vocab = (lora_config.lora_extra_vocab_size *
271
+ (lora_config.max_loras or 1)) if lora_config else 0
272
+ self.vocab_size = config.vocab_size + lora_vocab
273
+ self.org_vocab_size = config.vocab_size
274
+ if get_pp_group().is_first_rank or (config.tie_word_embeddings
275
+ and get_pp_group().is_last_rank):
276
+ self.embed_tokens = VocabParallelEmbedding(
277
+ self.vocab_size,
278
+ config.hidden_size,
279
+ org_num_embeddings=config.vocab_size,
280
+ )
281
+ else:
282
+ self.embed_tokens = PPMissingLayer()
283
+ self.start_layer, self.end_layer, self.layers = make_layers(
284
+ config.num_hidden_layers,
285
+ lambda prefix: SolarDecoderLayer(config=config,
286
+ cache_config=cache_config,
287
+ quant_config=quant_config,
288
+ prefix=prefix),
289
+ prefix=f"{prefix}.layers")
290
+ if get_pp_group().is_last_rank:
291
+ self.norm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
292
+ else:
293
+ self.norm = PPMissingLayer()
294
+
295
+ def get_input_embeddings(self, input_ids: torch.Tensor) -> torch.Tensor:
296
+ return self.embed_tokens(input_ids)
297
+
298
+ def forward(
299
+ self,
300
+ input_ids: Optional[torch.Tensor],
301
+ positions: torch.Tensor,
302
+ kv_caches: List[torch.Tensor],
303
+ attn_metadata: AttentionMetadata,
304
+ intermediate_tensors: Optional[IntermediateTensors],
305
+ inputs_embeds: Optional[torch.Tensor] = None,
306
+ ) -> Union[torch.Tensor, IntermediateTensors]:
307
+ if get_pp_group().is_first_rank:
308
+ if inputs_embeds is not None:
309
+ hidden_states = inputs_embeds
310
+ else:
311
+ hidden_states = self.get_input_embeddings(input_ids)
312
+ residual = None
313
+ else:
314
+ assert intermediate_tensors is not None
315
+ hidden_states = intermediate_tensors["hidden_states"]
316
+ residual = intermediate_tensors["residual"]
317
+
318
+ bskcn_h_1 = None
319
+ bskcn_h_2 = None
320
+ bskcn_r_1 = None
321
+ bskcn_r_2 = None
322
+ bskcn_tv = self.config.bskcn_tv[0] if self.training else self.config.bskcn_tv[1]
323
+
324
+ for i in range(self.start_layer, self.end_layer):
325
+ if i in self.config.bskcn_1:
326
+ bskcn_h_1 = hidden_states.clone()
327
+ bskcn_r_1 = residual.clone()
328
+ if i in self.config.bskcn_2:
329
+ bskcn_h_2 = hidden_states.clone()
330
+ bskcn_r_2 = residual.clone()
331
+ if i in self.config.bskcn_3:
332
+ hidden_states = bskcn_h_1*bskcn_tv + hidden_states*(1-bskcn_tv)
333
+ residual = bskcn_r_1*bskcn_tv + residual*(1-bskcn_tv)
334
+ if i in self.config.bskcn_4:
335
+ hidden_states = bskcn_h_2*bskcn_tv + hidden_states*(1-bskcn_tv)
336
+ residual = bskcn_r_2*bskcn_tv + residual*(1-bskcn_tv)
337
+ layer = self.layers[i]
338
+ hidden_states, residual = layer(
339
+ positions,
340
+ hidden_states,
341
+ kv_caches[i - self.start_layer],
342
+ attn_metadata,
343
+ residual,
344
+ )
345
+
346
+ if not get_pp_group().is_last_rank:
347
+ return IntermediateTensors({
348
+ "hidden_states": hidden_states,
349
+ "residual": residual
350
+ })
351
+
352
+ hidden_states, _ = self.norm(hidden_states, residual)
353
+ return hidden_states
354
+
355
+
356
+ class SolarForCausalLM(nn.Module, SupportsLoRA):
357
+ packed_modules_mapping = {
358
+ "qkv_proj": [
359
+ "q_proj",
360
+ "k_proj",
361
+ "v_proj",
362
+ ],
363
+ "gate_up_proj": [
364
+ "gate_proj",
365
+ "up_proj",
366
+ ],
367
+ }
368
+
369
+ # LoRA specific attributes
370
+ supported_lora_modules = [
371
+ "qkv_proj", "o_proj", "gate_up_proj", "down_proj", "embed_tokens",
372
+ "lm_head"
373
+ ]
374
+ embedding_modules = {
375
+ "embed_tokens": "input_embeddings",
376
+ "lm_head": "output_embeddings",
377
+ }
378
+ embedding_padding_modules = ["lm_head"]
379
+ bitsandbytes_stacked_params_mapping = {
380
+ # shard_name, weight_name, index
381
+ "q_proj": ("qkv_proj", 0),
382
+ "k_proj": ("qkv_proj", 1),
383
+ "v_proj": ("qkv_proj", 2),
384
+ "gate_proj": ("gate_up_proj", 0),
385
+ "up_proj": ("gate_up_proj", 1),
386
+ }
387
+
388
+ def __init__(
389
+ self,
390
+ config,
391
+ cache_config: Optional[CacheConfig] = None,
392
+ quant_config: Optional[QuantizationConfig] = None,
393
+ lora_config: Optional[LoRAConfig] = None,
394
+ ) -> None:
395
+ super().__init__()
396
+
397
+ self.config = config
398
+ self.lora_config = lora_config
399
+
400
+ self.model = SolarModel(config,
401
+ cache_config,
402
+ quant_config,
403
+ lora_config=lora_config,
404
+ prefix="model")
405
+ if get_pp_group().is_last_rank:
406
+ self.unpadded_vocab_size = config.vocab_size
407
+ if lora_config:
408
+ self.unpadded_vocab_size += lora_config.lora_extra_vocab_size
409
+ self.lm_head = ParallelLMHead(
410
+ self.unpadded_vocab_size,
411
+ config.hidden_size,
412
+ org_num_embeddings=config.vocab_size,
413
+ padding_size=DEFAULT_VOCAB_PADDING_SIZE
414
+ # We need bigger padding if using lora for kernel
415
+ # compatibility
416
+ if not lora_config else lora_config.lora_vocab_padding_size,
417
+ quant_config=quant_config,
418
+ )
419
+ if config.tie_word_embeddings:
420
+ self.lm_head.weight = self.model.embed_tokens.weight
421
+
422
+ logit_scale = getattr(config, "logit_scale", 1.0)
423
+ self.logits_processor = LogitsProcessor(self.unpadded_vocab_size,
424
+ config.vocab_size,
425
+ logit_scale)
426
+ self.sampler = Sampler()
427
+ else:
428
+ self.lm_head = PPMissingLayer()
429
+
430
+ def forward(
431
+ self,
432
+ input_ids: torch.Tensor,
433
+ positions: torch.Tensor,
434
+ kv_caches: List[torch.Tensor],
435
+ attn_metadata: AttentionMetadata,
436
+ intermediate_tensors: Optional[IntermediateTensors] = None,
437
+ ) -> Union[torch.Tensor, IntermediateTensors]:
438
+ model_output = self.model(input_ids, positions, kv_caches,
439
+ attn_metadata, intermediate_tensors)
440
+ return model_output
441
+
442
+ def compute_logits(self, hidden_states: torch.Tensor,
443
+ sampling_metadata: SamplingMetadata) -> torch.Tensor:
444
+ logits = self.logits_processor(self.lm_head, hidden_states,
445
+ sampling_metadata)
446
+ return logits
447
+
448
+ def sample(
449
+ self,
450
+ logits: torch.Tensor,
451
+ sampling_metadata: SamplingMetadata,
452
+ ) -> Optional[SamplerOutput]:
453
+ next_tokens = self.sampler(logits, sampling_metadata)
454
+ return next_tokens
455
+
456
+ def make_empty_intermediate_tensors(
457
+ self, batch_size: int, dtype: torch.dtype,
458
+ device: torch.device) -> IntermediateTensors:
459
+ return IntermediateTensors({
460
+ "hidden_states":
461
+ torch.zeros((batch_size, self.config.hidden_size),
462
+ dtype=dtype,
463
+ device=device),
464
+ "residual":
465
+ torch.zeros((batch_size, self.config.hidden_size),
466
+ dtype=dtype,
467
+ device=device),
468
+ })
469
+
470
+ def load_weights(self, weights: Iterable[Tuple[str, torch.Tensor]]):
471
+ stacked_params_mapping = [
472
+ # (param_name, shard_name, shard_id)
473
+ (".qkv_proj", ".q_proj", "q"),
474
+ (".qkv_proj", ".k_proj", "k"),
475
+ (".qkv_proj", ".v_proj", "v"),
476
+ (".gate_up_proj", ".gate_proj", 0),
477
+ (".gate_up_proj", ".up_proj", 1),
478
+ ]
479
+ params_dict = dict(self.named_parameters())
480
+ for name, loaded_weight in weights:
481
+ if "rotary_emb.inv_freq" in name:
482
+ continue
483
+ if ("rotary_emb.cos_cached" in name
484
+ or "rotary_emb.sin_cached" in name):
485
+ # Models trained using ColossalAI may include these tensors in
486
+ # the checkpoint. Skip them.
487
+ continue
488
+ if scale_name := get_compressed_tensors_cache_scale(name):
489
+ # Loading kv cache scales for compressed-tensors quantization
490
+ param = params_dict[scale_name]
491
+ weight_loader = getattr(param, "weight_loader",
492
+ default_weight_loader)
493
+ loaded_weight = loaded_weight[0]
494
+ weight_loader(param, loaded_weight)
495
+ continue
496
+ for (param_name, weight_name, shard_id) in stacked_params_mapping:
497
+ if weight_name not in name:
498
+ continue
499
+ name = name.replace(weight_name, param_name)
500
+ # Skip loading extra bias for GPTQ models.
501
+ if name.endswith(".bias") and name not in params_dict:
502
+ continue
503
+
504
+ if is_pp_missing_parameter(name, self):
505
+ continue
506
+
507
+ param = params_dict[name]
508
+ weight_loader = param.weight_loader
509
+ weight_loader(param, loaded_weight, shard_id)
510
+
511
+ break
512
+ else:
513
+ # Skip loading extra bias for GPTQ models.
514
+ if name.endswith(".bias") and name not in params_dict:
515
+ continue
516
+ # Remapping the name of FP8 kv-scale.
517
+ name = maybe_remap_kv_scale_name(name, params_dict)
518
+ if name is None:
519
+ continue
520
+
521
+ if is_pp_missing_parameter(name, self):
522
+ continue
523
+
524
+ param = params_dict[name]
525
+ weight_loader = getattr(param, "weight_loader",
526
+ default_weight_loader)
527
+ weight_loader(param, loaded_weight)
528
+
529
+ # If this function is called, it should always initialize KV cache scale
530
+ # factors (or else raise an exception). Thus, handled exceptions should
531
+ # make sure to leave KV cache scale factors in a known good (dummy) state
532
+ def load_kv_cache_scales(self, quantization_param_path: str) -> None:
533
+ tp_size = get_tensor_model_parallel_world_size()
534
+ tp_rank = get_tensor_model_parallel_rank()
535
+ for layer_idx, scaling_factor in kv_cache_scales_loader(
536
+ quantization_param_path, tp_rank, tp_size,
537
+ self.config.num_hidden_layers,
538
+ self.config.__class__.model_type):
539
+ if not isinstance(self.model.layers[layer_idx], nn.Identity):
540
+ layer_self_attn = self.model.layers[layer_idx].self_attn
541
+
542
+ if is_hip():
543
+ # The scaling factor convention we are assuming is
544
+ # quantized_value * scaling_factor ~= true_value
545
+ # which is consistent with the practice of setting
546
+ # scaling_factor = tensor_amax / FPtype_max
547
+ scaling_factor *= 2
548
+ if hasattr(layer_self_attn, "kv_scale"):
549
+ layer_self_attn.attn._kv_scale = scaling_factor
550
+ else:
551
+ raise RuntimeError("Self attention has no KV cache scaling "
552
+ "factor attribute!")