chitb commited on
Commit
7124db5
·
verified ·
1 Parent(s): 07c76f6

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,3 +1,202 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: peft
3
+ base_model: Viet-Mistral/Vistral-7B-Chat
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.9.0
adapter_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "Viet-Mistral/Vistral-7B-Chat",
5
+ "bias": "none",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layers_pattern": null,
10
+ "layers_to_transform": null,
11
+ "loftq_config": {},
12
+ "lora_alpha": 256,
13
+ "lora_dropout": 0.05,
14
+ "megatron_config": null,
15
+ "megatron_core": "megatron.core",
16
+ "modules_to_save": null,
17
+ "peft_type": "LORA",
18
+ "r": 128,
19
+ "rank_pattern": {},
20
+ "revision": null,
21
+ "target_modules": [
22
+ "gate_proj",
23
+ "o_proj",
24
+ "down_proj",
25
+ "up_proj",
26
+ "q_proj",
27
+ "k_proj",
28
+ "v_proj"
29
+ ],
30
+ "task_type": "CAUSAL_LM",
31
+ "use_dora": false,
32
+ "use_rslora": false
33
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9cc759aabc4ad48b6147508f9dc71f69f3a47d23e06769d7ce9134cf494cdc8f
3
+ size 671150064
added_tokens.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "<</SYS>>": 38366,
3
+ "<<SYS>>": 38365,
4
+ "[/INST]": 38368,
5
+ "[INST]": 38367
6
+ }
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Viet-Mistral/Vistral-7B-Chat",
3
+ "architectures": [
4
+ "MistralForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "freeze_mm_mlp_adapter": false,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 4096,
12
+ "image_aspect_ratio": "pad",
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 14336,
15
+ "max_position_embeddings": 32768,
16
+ "mm_hidden_size": 1024,
17
+ "mm_patch_merge_type": "flat",
18
+ "mm_projector_lr": 2e-05,
19
+ "mm_projector_type": "mlp2x_gelu",
20
+ "mm_use_im_patch_token": false,
21
+ "mm_use_im_start_end": false,
22
+ "mm_vision_select_feature": "patch",
23
+ "mm_vision_select_layer": -2,
24
+ "mm_vision_tower": "openai/clip-vit-large-patch14-336",
25
+ "model_type": "llava_mistral",
26
+ "num_attention_heads": 32,
27
+ "num_hidden_layers": 32,
28
+ "num_key_value_heads": 8,
29
+ "rms_norm_eps": 1e-05,
30
+ "rope_theta": 10000.0,
31
+ "sliding_window": 4096,
32
+ "tie_word_embeddings": false,
33
+ "tokenizer_model_max_length": 2048,
34
+ "tokenizer_padding_side": "right",
35
+ "torch_dtype": "bfloat16",
36
+ "transformers_version": "4.37.2",
37
+ "tune_mm_mlp_adapter": false,
38
+ "use_cache": true,
39
+ "use_mm_proj": true,
40
+ "vocab_size": 38369
41
+ }
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step728
non_lora_trainables.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5dd53ae020db19f5500f390b8c67e9abf73516cce4f9b7a1a953a2f6a05b9e82
3
+ size 41961648
rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69988968d8d5a12db71ef63a90cd57a93d72db7d8e71339dca2ba33b818726e1
3
+ size 15984
rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:819889969baf1f3e358df118f7ad14a747265a088892f67796e19cb3f7dcca7b
3
+ size 15984
rng_state_2.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c7497ebcd580bdeffdafbe7b595d7a48a070045672d6d51b50a350e9550172f
3
+ size 15984
rng_state_3.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f59dada543b7e4e3b0360181c41ca1f7efa525be268e26ff9589995e1c92a097
3
+ size 15984
rng_state_4.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e113c3f62a3c772780f19cffb4b3ddcff1b11c4fb1ec454620a5dc85daae0e8a
3
+ size 15984
rng_state_5.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69393d0b8187bbc613fbb46a570986eaa4465b9e38d93157e80b89ea42fc6575
3
+ size 15984
rng_state_6.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d66e118e69864543fbe9a5664a456902dbdddcc359771cd4ed80d254c8294b12
3
+ size 15984
rng_state_7.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:faf8236fd4ce6a5aedd45ef71ee41022ec4b1be6f9f2582fa4c459f4592b4b8b
3
+ size 15984
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92c701ceec84f359a0e0880888aead6bdb12fb5bee91ba73be6ba08e36bf3858
3
+ size 1064
special_tokens_map.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<unk>",
4
+ "<s>",
5
+ "</s>"
6
+ ],
7
+ "bos_token": {
8
+ "content": "<s>",
9
+ "lstrip": false,
10
+ "normalized": false,
11
+ "rstrip": false,
12
+ "single_word": false
13
+ },
14
+ "eos_token": {
15
+ "content": "</s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "pad_token": "<unk>",
22
+ "unk_token": {
23
+ "content": "<unk>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false
28
+ }
29
+ }
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e792a804bbfc19a96b61b87109b8f2b0b7c92830025f285b402ba27c0c309c6f
3
+ size 596883
tokenizer_config.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "38365": {
30
+ "content": "<<SYS>>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": false
36
+ },
37
+ "38366": {
38
+ "content": "<</SYS>>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": false
44
+ },
45
+ "38367": {
46
+ "content": "[INST]",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": false
52
+ },
53
+ "38368": {
54
+ "content": "[/INST]",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": false
60
+ }
61
+ },
62
+ "additional_special_tokens": [
63
+ "<unk>",
64
+ "<s>",
65
+ "</s>"
66
+ ],
67
+ "bos_token": "<s>",
68
+ "chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>\\n' + system_message + '\\n<</SYS>>\\n\\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}",
69
+ "clean_up_tokenization_spaces": false,
70
+ "eos_token": "</s>",
71
+ "legacy": true,
72
+ "model_max_length": 2048,
73
+ "pad_token": "<unk>",
74
+ "padding_side": "right",
75
+ "sp_model_kwargs": {},
76
+ "spaces_between_special_tokens": false,
77
+ "tokenizer_class": "LlamaTokenizer",
78
+ "unk_token": "<unk>",
79
+ "use_default_system_prompt": false,
80
+ "use_fast": true
81
+ }
trainer_state.json ADDED
@@ -0,0 +1,1473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 0.9989708404802744,
5
+ "eval_steps": 500,
6
+ "global_step": 728,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.0,
13
+ "learning_rate": 9.090909090909091e-07,
14
+ "loss": 1.4022,
15
+ "step": 3
16
+ },
17
+ {
18
+ "epoch": 0.01,
19
+ "learning_rate": 1.8181818181818183e-06,
20
+ "loss": 1.4239,
21
+ "step": 6
22
+ },
23
+ {
24
+ "epoch": 0.01,
25
+ "learning_rate": 2.7272727272727272e-06,
26
+ "loss": 1.3843,
27
+ "step": 9
28
+ },
29
+ {
30
+ "epoch": 0.02,
31
+ "learning_rate": 3.6363636363636366e-06,
32
+ "loss": 1.3722,
33
+ "step": 12
34
+ },
35
+ {
36
+ "epoch": 0.02,
37
+ "learning_rate": 4.5454545454545455e-06,
38
+ "loss": 1.3411,
39
+ "step": 15
40
+ },
41
+ {
42
+ "epoch": 0.02,
43
+ "learning_rate": 5.4545454545454545e-06,
44
+ "loss": 1.3187,
45
+ "step": 18
46
+ },
47
+ {
48
+ "epoch": 0.03,
49
+ "learning_rate": 6.363636363636364e-06,
50
+ "loss": 1.284,
51
+ "step": 21
52
+ },
53
+ {
54
+ "epoch": 0.03,
55
+ "learning_rate": 7.272727272727273e-06,
56
+ "loss": 1.2492,
57
+ "step": 24
58
+ },
59
+ {
60
+ "epoch": 0.04,
61
+ "learning_rate": 8.181818181818183e-06,
62
+ "loss": 1.2658,
63
+ "step": 27
64
+ },
65
+ {
66
+ "epoch": 0.04,
67
+ "learning_rate": 9.090909090909091e-06,
68
+ "loss": 1.2173,
69
+ "step": 30
70
+ },
71
+ {
72
+ "epoch": 0.05,
73
+ "learning_rate": 1e-05,
74
+ "loss": 1.2302,
75
+ "step": 33
76
+ },
77
+ {
78
+ "epoch": 0.05,
79
+ "learning_rate": 1.0909090909090909e-05,
80
+ "loss": 1.2301,
81
+ "step": 36
82
+ },
83
+ {
84
+ "epoch": 0.05,
85
+ "learning_rate": 1.181818181818182e-05,
86
+ "loss": 1.1855,
87
+ "step": 39
88
+ },
89
+ {
90
+ "epoch": 0.06,
91
+ "learning_rate": 1.2727272727272728e-05,
92
+ "loss": 1.2094,
93
+ "step": 42
94
+ },
95
+ {
96
+ "epoch": 0.06,
97
+ "learning_rate": 1.3636363636363637e-05,
98
+ "loss": 1.1788,
99
+ "step": 45
100
+ },
101
+ {
102
+ "epoch": 0.07,
103
+ "learning_rate": 1.4545454545454546e-05,
104
+ "loss": 1.1804,
105
+ "step": 48
106
+ },
107
+ {
108
+ "epoch": 0.07,
109
+ "learning_rate": 1.5454545454545454e-05,
110
+ "loss": 1.166,
111
+ "step": 51
112
+ },
113
+ {
114
+ "epoch": 0.07,
115
+ "learning_rate": 1.6363636363636366e-05,
116
+ "loss": 1.1256,
117
+ "step": 54
118
+ },
119
+ {
120
+ "epoch": 0.08,
121
+ "learning_rate": 1.7272727272727274e-05,
122
+ "loss": 1.1289,
123
+ "step": 57
124
+ },
125
+ {
126
+ "epoch": 0.08,
127
+ "learning_rate": 1.8181818181818182e-05,
128
+ "loss": 1.1392,
129
+ "step": 60
130
+ },
131
+ {
132
+ "epoch": 0.09,
133
+ "learning_rate": 1.9090909090909094e-05,
134
+ "loss": 1.131,
135
+ "step": 63
136
+ },
137
+ {
138
+ "epoch": 0.09,
139
+ "learning_rate": 2e-05,
140
+ "loss": 1.1288,
141
+ "step": 66
142
+ },
143
+ {
144
+ "epoch": 0.09,
145
+ "learning_rate": 1.9999900994429424e-05,
146
+ "loss": 1.1198,
147
+ "step": 69
148
+ },
149
+ {
150
+ "epoch": 0.1,
151
+ "learning_rate": 1.999960397967811e-05,
152
+ "loss": 1.1281,
153
+ "step": 72
154
+ },
155
+ {
156
+ "epoch": 0.1,
157
+ "learning_rate": 1.9999108961627284e-05,
158
+ "loss": 1.134,
159
+ "step": 75
160
+ },
161
+ {
162
+ "epoch": 0.11,
163
+ "learning_rate": 1.9998415950078858e-05,
164
+ "loss": 1.1148,
165
+ "step": 78
166
+ },
167
+ {
168
+ "epoch": 0.11,
169
+ "learning_rate": 1.9997524958755226e-05,
170
+ "loss": 1.1162,
171
+ "step": 81
172
+ },
173
+ {
174
+ "epoch": 0.12,
175
+ "learning_rate": 1.9996436005299013e-05,
176
+ "loss": 1.12,
177
+ "step": 84
178
+ },
179
+ {
180
+ "epoch": 0.12,
181
+ "learning_rate": 1.999514911127271e-05,
182
+ "loss": 1.12,
183
+ "step": 87
184
+ },
185
+ {
186
+ "epoch": 0.12,
187
+ "learning_rate": 1.9993664302158255e-05,
188
+ "loss": 1.0938,
189
+ "step": 90
190
+ },
191
+ {
192
+ "epoch": 0.13,
193
+ "learning_rate": 1.9991981607356517e-05,
194
+ "loss": 1.0838,
195
+ "step": 93
196
+ },
197
+ {
198
+ "epoch": 0.13,
199
+ "learning_rate": 1.9990101060186732e-05,
200
+ "loss": 1.1078,
201
+ "step": 96
202
+ },
203
+ {
204
+ "epoch": 0.14,
205
+ "learning_rate": 1.998802269788583e-05,
206
+ "loss": 1.1037,
207
+ "step": 99
208
+ },
209
+ {
210
+ "epoch": 0.14,
211
+ "learning_rate": 1.9985746561607696e-05,
212
+ "loss": 1.0804,
213
+ "step": 102
214
+ },
215
+ {
216
+ "epoch": 0.14,
217
+ "learning_rate": 1.998327269642237e-05,
218
+ "loss": 1.0977,
219
+ "step": 105
220
+ },
221
+ {
222
+ "epoch": 0.15,
223
+ "learning_rate": 1.998060115131513e-05,
224
+ "loss": 1.1036,
225
+ "step": 108
226
+ },
227
+ {
228
+ "epoch": 0.15,
229
+ "learning_rate": 1.9977731979185556e-05,
230
+ "loss": 1.1109,
231
+ "step": 111
232
+ },
233
+ {
234
+ "epoch": 0.16,
235
+ "learning_rate": 1.9974665236846443e-05,
236
+ "loss": 1.0937,
237
+ "step": 114
238
+ },
239
+ {
240
+ "epoch": 0.16,
241
+ "learning_rate": 1.9971400985022712e-05,
242
+ "loss": 1.0834,
243
+ "step": 117
244
+ },
245
+ {
246
+ "epoch": 0.16,
247
+ "learning_rate": 1.9967939288350184e-05,
248
+ "loss": 1.1002,
249
+ "step": 120
250
+ },
251
+ {
252
+ "epoch": 0.17,
253
+ "learning_rate": 1.9964280215374312e-05,
254
+ "loss": 1.0847,
255
+ "step": 123
256
+ },
257
+ {
258
+ "epoch": 0.17,
259
+ "learning_rate": 1.9960423838548814e-05,
260
+ "loss": 1.0845,
261
+ "step": 126
262
+ },
263
+ {
264
+ "epoch": 0.18,
265
+ "learning_rate": 1.995637023423425e-05,
266
+ "loss": 1.0984,
267
+ "step": 129
268
+ },
269
+ {
270
+ "epoch": 0.18,
271
+ "learning_rate": 1.9952119482696504e-05,
272
+ "loss": 1.0836,
273
+ "step": 132
274
+ },
275
+ {
276
+ "epoch": 0.19,
277
+ "learning_rate": 1.9947671668105185e-05,
278
+ "loss": 1.082,
279
+ "step": 135
280
+ },
281
+ {
282
+ "epoch": 0.19,
283
+ "learning_rate": 1.9943026878531985e-05,
284
+ "loss": 1.0707,
285
+ "step": 138
286
+ },
287
+ {
288
+ "epoch": 0.19,
289
+ "learning_rate": 1.9938185205948906e-05,
290
+ "loss": 1.0545,
291
+ "step": 141
292
+ },
293
+ {
294
+ "epoch": 0.2,
295
+ "learning_rate": 1.993314674622646e-05,
296
+ "loss": 1.0618,
297
+ "step": 144
298
+ },
299
+ {
300
+ "epoch": 0.2,
301
+ "learning_rate": 1.992791159913177e-05,
302
+ "loss": 1.0514,
303
+ "step": 147
304
+ },
305
+ {
306
+ "epoch": 0.21,
307
+ "learning_rate": 1.992247986832658e-05,
308
+ "loss": 1.0733,
309
+ "step": 150
310
+ },
311
+ {
312
+ "epoch": 0.21,
313
+ "learning_rate": 1.99168516613652e-05,
314
+ "loss": 1.0712,
315
+ "step": 153
316
+ },
317
+ {
318
+ "epoch": 0.21,
319
+ "learning_rate": 1.991102708969241e-05,
320
+ "loss": 1.0788,
321
+ "step": 156
322
+ },
323
+ {
324
+ "epoch": 0.22,
325
+ "learning_rate": 1.9905006268641212e-05,
326
+ "loss": 1.0744,
327
+ "step": 159
328
+ },
329
+ {
330
+ "epoch": 0.22,
331
+ "learning_rate": 1.9898789317430577e-05,
332
+ "loss": 1.0621,
333
+ "step": 162
334
+ },
335
+ {
336
+ "epoch": 0.23,
337
+ "learning_rate": 1.9892376359163058e-05,
338
+ "loss": 1.0598,
339
+ "step": 165
340
+ },
341
+ {
342
+ "epoch": 0.23,
343
+ "learning_rate": 1.9885767520822377e-05,
344
+ "loss": 1.095,
345
+ "step": 168
346
+ },
347
+ {
348
+ "epoch": 0.23,
349
+ "learning_rate": 1.9878962933270896e-05,
350
+ "loss": 1.0666,
351
+ "step": 171
352
+ },
353
+ {
354
+ "epoch": 0.24,
355
+ "learning_rate": 1.987196273124703e-05,
356
+ "loss": 1.0657,
357
+ "step": 174
358
+ },
359
+ {
360
+ "epoch": 0.24,
361
+ "learning_rate": 1.986476705336258e-05,
362
+ "loss": 1.0691,
363
+ "step": 177
364
+ },
365
+ {
366
+ "epoch": 0.25,
367
+ "learning_rate": 1.9857376042099982e-05,
368
+ "loss": 1.0663,
369
+ "step": 180
370
+ },
371
+ {
372
+ "epoch": 0.25,
373
+ "learning_rate": 1.9849789843809496e-05,
374
+ "loss": 1.0476,
375
+ "step": 183
376
+ },
377
+ {
378
+ "epoch": 0.26,
379
+ "learning_rate": 1.9842008608706295e-05,
380
+ "loss": 1.0509,
381
+ "step": 186
382
+ },
383
+ {
384
+ "epoch": 0.26,
385
+ "learning_rate": 1.983403249086751e-05,
386
+ "loss": 1.0622,
387
+ "step": 189
388
+ },
389
+ {
390
+ "epoch": 0.26,
391
+ "learning_rate": 1.9825861648229154e-05,
392
+ "loss": 1.0708,
393
+ "step": 192
394
+ },
395
+ {
396
+ "epoch": 0.27,
397
+ "learning_rate": 1.981749624258302e-05,
398
+ "loss": 1.0672,
399
+ "step": 195
400
+ },
401
+ {
402
+ "epoch": 0.27,
403
+ "learning_rate": 1.9808936439573455e-05,
404
+ "loss": 1.0627,
405
+ "step": 198
406
+ },
407
+ {
408
+ "epoch": 0.28,
409
+ "learning_rate": 1.9800182408694096e-05,
410
+ "loss": 1.0726,
411
+ "step": 201
412
+ },
413
+ {
414
+ "epoch": 0.28,
415
+ "learning_rate": 1.9791234323284515e-05,
416
+ "loss": 1.0558,
417
+ "step": 204
418
+ },
419
+ {
420
+ "epoch": 0.28,
421
+ "learning_rate": 1.9782092360526763e-05,
422
+ "loss": 1.0677,
423
+ "step": 207
424
+ },
425
+ {
426
+ "epoch": 0.29,
427
+ "learning_rate": 1.977275670144189e-05,
428
+ "loss": 1.0422,
429
+ "step": 210
430
+ },
431
+ {
432
+ "epoch": 0.29,
433
+ "learning_rate": 1.9763227530886348e-05,
434
+ "loss": 1.0364,
435
+ "step": 213
436
+ },
437
+ {
438
+ "epoch": 0.3,
439
+ "learning_rate": 1.9753505037548334e-05,
440
+ "loss": 1.0475,
441
+ "step": 216
442
+ },
443
+ {
444
+ "epoch": 0.3,
445
+ "learning_rate": 1.974358941394404e-05,
446
+ "loss": 1.0508,
447
+ "step": 219
448
+ },
449
+ {
450
+ "epoch": 0.3,
451
+ "learning_rate": 1.973348085641387e-05,
452
+ "loss": 1.0595,
453
+ "step": 222
454
+ },
455
+ {
456
+ "epoch": 0.31,
457
+ "learning_rate": 1.972317956511852e-05,
458
+ "loss": 1.0528,
459
+ "step": 225
460
+ },
461
+ {
462
+ "epoch": 0.31,
463
+ "learning_rate": 1.971268574403503e-05,
464
+ "loss": 1.0562,
465
+ "step": 228
466
+ },
467
+ {
468
+ "epoch": 0.32,
469
+ "learning_rate": 1.970199960095276e-05,
470
+ "loss": 1.0329,
471
+ "step": 231
472
+ },
473
+ {
474
+ "epoch": 0.32,
475
+ "learning_rate": 1.9691121347469235e-05,
476
+ "loss": 1.045,
477
+ "step": 234
478
+ },
479
+ {
480
+ "epoch": 0.33,
481
+ "learning_rate": 1.9680051198986004e-05,
482
+ "loss": 1.0561,
483
+ "step": 237
484
+ },
485
+ {
486
+ "epoch": 0.33,
487
+ "learning_rate": 1.9668789374704337e-05,
488
+ "loss": 1.0449,
489
+ "step": 240
490
+ },
491
+ {
492
+ "epoch": 0.33,
493
+ "learning_rate": 1.9657336097620904e-05,
494
+ "loss": 1.0359,
495
+ "step": 243
496
+ },
497
+ {
498
+ "epoch": 0.34,
499
+ "learning_rate": 1.964569159452335e-05,
500
+ "loss": 1.0359,
501
+ "step": 246
502
+ },
503
+ {
504
+ "epoch": 0.34,
505
+ "learning_rate": 1.963385609598581e-05,
506
+ "loss": 1.0271,
507
+ "step": 249
508
+ },
509
+ {
510
+ "epoch": 0.35,
511
+ "learning_rate": 1.9621829836364335e-05,
512
+ "loss": 1.0563,
513
+ "step": 252
514
+ },
515
+ {
516
+ "epoch": 0.35,
517
+ "learning_rate": 1.9609613053792276e-05,
518
+ "loss": 1.0416,
519
+ "step": 255
520
+ },
521
+ {
522
+ "epoch": 0.35,
523
+ "learning_rate": 1.9597205990175528e-05,
524
+ "loss": 1.0578,
525
+ "step": 258
526
+ },
527
+ {
528
+ "epoch": 0.36,
529
+ "learning_rate": 1.958460889118778e-05,
530
+ "loss": 1.0461,
531
+ "step": 261
532
+ },
533
+ {
534
+ "epoch": 0.36,
535
+ "learning_rate": 1.9571822006265623e-05,
536
+ "loss": 1.0262,
537
+ "step": 264
538
+ },
539
+ {
540
+ "epoch": 0.37,
541
+ "learning_rate": 1.9558845588603625e-05,
542
+ "loss": 1.0254,
543
+ "step": 267
544
+ },
545
+ {
546
+ "epoch": 0.37,
547
+ "learning_rate": 1.9545679895149315e-05,
548
+ "loss": 1.0642,
549
+ "step": 270
550
+ },
551
+ {
552
+ "epoch": 0.37,
553
+ "learning_rate": 1.9532325186598093e-05,
554
+ "loss": 1.0456,
555
+ "step": 273
556
+ },
557
+ {
558
+ "epoch": 0.38,
559
+ "learning_rate": 1.951878172738806e-05,
560
+ "loss": 1.0358,
561
+ "step": 276
562
+ },
563
+ {
564
+ "epoch": 0.38,
565
+ "learning_rate": 1.9505049785694803e-05,
566
+ "loss": 1.0409,
567
+ "step": 279
568
+ },
569
+ {
570
+ "epoch": 0.39,
571
+ "learning_rate": 1.9491129633426068e-05,
572
+ "loss": 1.0382,
573
+ "step": 282
574
+ },
575
+ {
576
+ "epoch": 0.39,
577
+ "learning_rate": 1.9477021546216376e-05,
578
+ "loss": 1.0415,
579
+ "step": 285
580
+ },
581
+ {
582
+ "epoch": 0.4,
583
+ "learning_rate": 1.9462725803421566e-05,
584
+ "loss": 1.0308,
585
+ "step": 288
586
+ },
587
+ {
588
+ "epoch": 0.4,
589
+ "learning_rate": 1.9448242688113286e-05,
590
+ "loss": 1.0376,
591
+ "step": 291
592
+ },
593
+ {
594
+ "epoch": 0.4,
595
+ "learning_rate": 1.9433572487073343e-05,
596
+ "loss": 1.0259,
597
+ "step": 294
598
+ },
599
+ {
600
+ "epoch": 0.41,
601
+ "learning_rate": 1.9418715490788066e-05,
602
+ "loss": 1.0496,
603
+ "step": 297
604
+ },
605
+ {
606
+ "epoch": 0.41,
607
+ "learning_rate": 1.9403671993442534e-05,
608
+ "loss": 1.0519,
609
+ "step": 300
610
+ },
611
+ {
612
+ "epoch": 0.42,
613
+ "learning_rate": 1.9388442292914754e-05,
614
+ "loss": 1.0418,
615
+ "step": 303
616
+ },
617
+ {
618
+ "epoch": 0.42,
619
+ "learning_rate": 1.937302669076976e-05,
620
+ "loss": 1.0372,
621
+ "step": 306
622
+ },
623
+ {
624
+ "epoch": 0.42,
625
+ "learning_rate": 1.9357425492253662e-05,
626
+ "loss": 1.0347,
627
+ "step": 309
628
+ },
629
+ {
630
+ "epoch": 0.43,
631
+ "learning_rate": 1.934163900628756e-05,
632
+ "loss": 1.0253,
633
+ "step": 312
634
+ },
635
+ {
636
+ "epoch": 0.43,
637
+ "learning_rate": 1.9325667545461466e-05,
638
+ "loss": 1.0401,
639
+ "step": 315
640
+ },
641
+ {
642
+ "epoch": 0.44,
643
+ "learning_rate": 1.9309511426028105e-05,
644
+ "loss": 1.0282,
645
+ "step": 318
646
+ },
647
+ {
648
+ "epoch": 0.44,
649
+ "learning_rate": 1.9293170967896632e-05,
650
+ "loss": 1.0306,
651
+ "step": 321
652
+ },
653
+ {
654
+ "epoch": 0.44,
655
+ "learning_rate": 1.9276646494626333e-05,
656
+ "loss": 1.0313,
657
+ "step": 324
658
+ },
659
+ {
660
+ "epoch": 0.45,
661
+ "learning_rate": 1.9259938333420183e-05,
662
+ "loss": 1.0433,
663
+ "step": 327
664
+ },
665
+ {
666
+ "epoch": 0.45,
667
+ "learning_rate": 1.9243046815118387e-05,
668
+ "loss": 1.0232,
669
+ "step": 330
670
+ },
671
+ {
672
+ "epoch": 0.46,
673
+ "learning_rate": 1.922597227419183e-05,
674
+ "loss": 1.0222,
675
+ "step": 333
676
+ },
677
+ {
678
+ "epoch": 0.46,
679
+ "learning_rate": 1.9208715048735446e-05,
680
+ "loss": 1.0186,
681
+ "step": 336
682
+ },
683
+ {
684
+ "epoch": 0.47,
685
+ "learning_rate": 1.9191275480461525e-05,
686
+ "loss": 1.033,
687
+ "step": 339
688
+ },
689
+ {
690
+ "epoch": 0.47,
691
+ "learning_rate": 1.9173653914692947e-05,
692
+ "loss": 1.0342,
693
+ "step": 342
694
+ },
695
+ {
696
+ "epoch": 0.47,
697
+ "learning_rate": 1.9155850700356345e-05,
698
+ "loss": 1.035,
699
+ "step": 345
700
+ },
701
+ {
702
+ "epoch": 0.48,
703
+ "learning_rate": 1.91378661899752e-05,
704
+ "loss": 1.0206,
705
+ "step": 348
706
+ },
707
+ {
708
+ "epoch": 0.48,
709
+ "learning_rate": 1.9119700739662857e-05,
710
+ "loss": 1.0435,
711
+ "step": 351
712
+ },
713
+ {
714
+ "epoch": 0.49,
715
+ "learning_rate": 1.910135470911547e-05,
716
+ "loss": 1.0181,
717
+ "step": 354
718
+ },
719
+ {
720
+ "epoch": 0.49,
721
+ "learning_rate": 1.908282846160488e-05,
722
+ "loss": 1.0267,
723
+ "step": 357
724
+ },
725
+ {
726
+ "epoch": 0.49,
727
+ "learning_rate": 1.9064122363971426e-05,
728
+ "loss": 1.0365,
729
+ "step": 360
730
+ },
731
+ {
732
+ "epoch": 0.5,
733
+ "learning_rate": 1.904523678661669e-05,
734
+ "loss": 1.0381,
735
+ "step": 363
736
+ },
737
+ {
738
+ "epoch": 0.5,
739
+ "learning_rate": 1.9026172103496138e-05,
740
+ "loss": 1.0048,
741
+ "step": 366
742
+ },
743
+ {
744
+ "epoch": 0.51,
745
+ "learning_rate": 1.900692869211174e-05,
746
+ "loss": 1.0392,
747
+ "step": 369
748
+ },
749
+ {
750
+ "epoch": 0.51,
751
+ "learning_rate": 1.898750693350447e-05,
752
+ "loss": 1.0278,
753
+ "step": 372
754
+ },
755
+ {
756
+ "epoch": 0.51,
757
+ "learning_rate": 1.8967907212246803e-05,
758
+ "loss": 1.013,
759
+ "step": 375
760
+ },
761
+ {
762
+ "epoch": 0.52,
763
+ "learning_rate": 1.8948129916435048e-05,
764
+ "loss": 1.0385,
765
+ "step": 378
766
+ },
767
+ {
768
+ "epoch": 0.52,
769
+ "learning_rate": 1.8928175437681698e-05,
770
+ "loss": 1.0168,
771
+ "step": 381
772
+ },
773
+ {
774
+ "epoch": 0.53,
775
+ "learning_rate": 1.8908044171107658e-05,
776
+ "loss": 1.0123,
777
+ "step": 384
778
+ },
779
+ {
780
+ "epoch": 0.53,
781
+ "learning_rate": 1.8887736515334443e-05,
782
+ "loss": 1.015,
783
+ "step": 387
784
+ },
785
+ {
786
+ "epoch": 0.54,
787
+ "learning_rate": 1.8867252872476255e-05,
788
+ "loss": 1.0265,
789
+ "step": 390
790
+ },
791
+ {
792
+ "epoch": 0.54,
793
+ "learning_rate": 1.884659364813205e-05,
794
+ "loss": 0.9997,
795
+ "step": 393
796
+ },
797
+ {
798
+ "epoch": 0.54,
799
+ "learning_rate": 1.8825759251377484e-05,
800
+ "loss": 1.0109,
801
+ "step": 396
802
+ },
803
+ {
804
+ "epoch": 0.55,
805
+ "learning_rate": 1.8804750094756827e-05,
806
+ "loss": 1.0199,
807
+ "step": 399
808
+ },
809
+ {
810
+ "epoch": 0.55,
811
+ "learning_rate": 1.8783566594274783e-05,
812
+ "loss": 0.9998,
813
+ "step": 402
814
+ },
815
+ {
816
+ "epoch": 0.56,
817
+ "learning_rate": 1.8762209169388262e-05,
818
+ "loss": 1.0088,
819
+ "step": 405
820
+ },
821
+ {
822
+ "epoch": 0.56,
823
+ "learning_rate": 1.8740678242998077e-05,
824
+ "loss": 1.0022,
825
+ "step": 408
826
+ },
827
+ {
828
+ "epoch": 0.56,
829
+ "learning_rate": 1.8718974241440552e-05,
830
+ "loss": 1.0216,
831
+ "step": 411
832
+ },
833
+ {
834
+ "epoch": 0.57,
835
+ "learning_rate": 1.8697097594479103e-05,
836
+ "loss": 1.0248,
837
+ "step": 414
838
+ },
839
+ {
840
+ "epoch": 0.57,
841
+ "learning_rate": 1.867504873529571e-05,
842
+ "loss": 0.9974,
843
+ "step": 417
844
+ },
845
+ {
846
+ "epoch": 0.58,
847
+ "learning_rate": 1.865282810048235e-05,
848
+ "loss": 1.0138,
849
+ "step": 420
850
+ },
851
+ {
852
+ "epoch": 0.58,
853
+ "learning_rate": 1.8630436130032353e-05,
854
+ "loss": 1.0004,
855
+ "step": 423
856
+ },
857
+ {
858
+ "epoch": 0.58,
859
+ "learning_rate": 1.860787326733168e-05,
860
+ "loss": 1.0081,
861
+ "step": 426
862
+ },
863
+ {
864
+ "epoch": 0.59,
865
+ "learning_rate": 1.8585139959150144e-05,
866
+ "loss": 1.0238,
867
+ "step": 429
868
+ },
869
+ {
870
+ "epoch": 0.59,
871
+ "learning_rate": 1.856223665563258e-05,
872
+ "loss": 1.0328,
873
+ "step": 432
874
+ },
875
+ {
876
+ "epoch": 0.6,
877
+ "learning_rate": 1.8539163810289914e-05,
878
+ "loss": 1.0071,
879
+ "step": 435
880
+ },
881
+ {
882
+ "epoch": 0.6,
883
+ "learning_rate": 1.8515921879990187e-05,
884
+ "loss": 1.0134,
885
+ "step": 438
886
+ },
887
+ {
888
+ "epoch": 0.61,
889
+ "learning_rate": 1.8492511324949516e-05,
890
+ "loss": 1.0181,
891
+ "step": 441
892
+ },
893
+ {
894
+ "epoch": 0.61,
895
+ "learning_rate": 1.8468932608722975e-05,
896
+ "loss": 1.0363,
897
+ "step": 444
898
+ },
899
+ {
900
+ "epoch": 0.61,
901
+ "learning_rate": 1.8445186198195406e-05,
902
+ "loss": 1.0011,
903
+ "step": 447
904
+ },
905
+ {
906
+ "epoch": 0.62,
907
+ "learning_rate": 1.8421272563572202e-05,
908
+ "loss": 0.9993,
909
+ "step": 450
910
+ },
911
+ {
912
+ "epoch": 0.62,
913
+ "learning_rate": 1.8397192178369965e-05,
914
+ "loss": 1.0201,
915
+ "step": 453
916
+ },
917
+ {
918
+ "epoch": 0.63,
919
+ "learning_rate": 1.837294551940716e-05,
920
+ "loss": 0.987,
921
+ "step": 456
922
+ },
923
+ {
924
+ "epoch": 0.63,
925
+ "learning_rate": 1.834853306679464e-05,
926
+ "loss": 1.0106,
927
+ "step": 459
928
+ },
929
+ {
930
+ "epoch": 0.63,
931
+ "learning_rate": 1.8323955303926165e-05,
932
+ "loss": 1.0034,
933
+ "step": 462
934
+ },
935
+ {
936
+ "epoch": 0.64,
937
+ "learning_rate": 1.8299212717468825e-05,
938
+ "loss": 1.0095,
939
+ "step": 465
940
+ },
941
+ {
942
+ "epoch": 0.64,
943
+ "learning_rate": 1.8274305797353397e-05,
944
+ "loss": 0.9921,
945
+ "step": 468
946
+ },
947
+ {
948
+ "epoch": 0.65,
949
+ "learning_rate": 1.824923503676465e-05,
950
+ "loss": 0.9859,
951
+ "step": 471
952
+ },
953
+ {
954
+ "epoch": 0.65,
955
+ "learning_rate": 1.822400093213157e-05,
956
+ "loss": 1.017,
957
+ "step": 474
958
+ },
959
+ {
960
+ "epoch": 0.65,
961
+ "learning_rate": 1.8198603983117546e-05,
962
+ "loss": 1.0118,
963
+ "step": 477
964
+ },
965
+ {
966
+ "epoch": 0.66,
967
+ "learning_rate": 1.8173044692610466e-05,
968
+ "loss": 0.9912,
969
+ "step": 480
970
+ },
971
+ {
972
+ "epoch": 0.66,
973
+ "learning_rate": 1.8147323566712755e-05,
974
+ "loss": 1.0162,
975
+ "step": 483
976
+ },
977
+ {
978
+ "epoch": 0.67,
979
+ "learning_rate": 1.8121441114731366e-05,
980
+ "loss": 1.0089,
981
+ "step": 486
982
+ },
983
+ {
984
+ "epoch": 0.67,
985
+ "learning_rate": 1.809539784916768e-05,
986
+ "loss": 0.9752,
987
+ "step": 489
988
+ },
989
+ {
990
+ "epoch": 0.68,
991
+ "learning_rate": 1.806919428570737e-05,
992
+ "loss": 1.007,
993
+ "step": 492
994
+ },
995
+ {
996
+ "epoch": 0.68,
997
+ "learning_rate": 1.804283094321019e-05,
998
+ "loss": 1.0145,
999
+ "step": 495
1000
+ },
1001
+ {
1002
+ "epoch": 0.68,
1003
+ "learning_rate": 1.8016308343699686e-05,
1004
+ "loss": 1.0008,
1005
+ "step": 498
1006
+ },
1007
+ {
1008
+ "epoch": 0.69,
1009
+ "learning_rate": 1.798962701235289e-05,
1010
+ "loss": 1.0067,
1011
+ "step": 501
1012
+ },
1013
+ {
1014
+ "epoch": 0.69,
1015
+ "learning_rate": 1.796278747748988e-05,
1016
+ "loss": 1.0017,
1017
+ "step": 504
1018
+ },
1019
+ {
1020
+ "epoch": 0.7,
1021
+ "learning_rate": 1.7935790270563345e-05,
1022
+ "loss": 1.0086,
1023
+ "step": 507
1024
+ },
1025
+ {
1026
+ "epoch": 0.7,
1027
+ "learning_rate": 1.790863592614807e-05,
1028
+ "loss": 0.9884,
1029
+ "step": 510
1030
+ },
1031
+ {
1032
+ "epoch": 0.7,
1033
+ "learning_rate": 1.788132498193032e-05,
1034
+ "loss": 1.0028,
1035
+ "step": 513
1036
+ },
1037
+ {
1038
+ "epoch": 0.71,
1039
+ "learning_rate": 1.7853857978697223e-05,
1040
+ "loss": 1.0055,
1041
+ "step": 516
1042
+ },
1043
+ {
1044
+ "epoch": 0.71,
1045
+ "learning_rate": 1.7826235460326043e-05,
1046
+ "loss": 1.005,
1047
+ "step": 519
1048
+ },
1049
+ {
1050
+ "epoch": 0.72,
1051
+ "learning_rate": 1.7798457973773418e-05,
1052
+ "loss": 1.002,
1053
+ "step": 522
1054
+ },
1055
+ {
1056
+ "epoch": 0.72,
1057
+ "learning_rate": 1.7770526069064525e-05,
1058
+ "loss": 0.9838,
1059
+ "step": 525
1060
+ },
1061
+ {
1062
+ "epoch": 0.72,
1063
+ "learning_rate": 1.7742440299282203e-05,
1064
+ "loss": 1.001,
1065
+ "step": 528
1066
+ },
1067
+ {
1068
+ "epoch": 0.73,
1069
+ "learning_rate": 1.7714201220555982e-05,
1070
+ "loss": 0.9984,
1071
+ "step": 531
1072
+ },
1073
+ {
1074
+ "epoch": 0.73,
1075
+ "learning_rate": 1.7685809392051084e-05,
1076
+ "loss": 1.0035,
1077
+ "step": 534
1078
+ },
1079
+ {
1080
+ "epoch": 0.74,
1081
+ "learning_rate": 1.765726537595734e-05,
1082
+ "loss": 1.0076,
1083
+ "step": 537
1084
+ },
1085
+ {
1086
+ "epoch": 0.74,
1087
+ "learning_rate": 1.7628569737478076e-05,
1088
+ "loss": 0.9936,
1089
+ "step": 540
1090
+ },
1091
+ {
1092
+ "epoch": 0.75,
1093
+ "learning_rate": 1.7599723044818898e-05,
1094
+ "loss": 1.0053,
1095
+ "step": 543
1096
+ },
1097
+ {
1098
+ "epoch": 0.75,
1099
+ "learning_rate": 1.7570725869176468e-05,
1100
+ "loss": 0.9968,
1101
+ "step": 546
1102
+ },
1103
+ {
1104
+ "epoch": 0.75,
1105
+ "learning_rate": 1.7541578784727163e-05,
1106
+ "loss": 1.0059,
1107
+ "step": 549
1108
+ },
1109
+ {
1110
+ "epoch": 0.76,
1111
+ "learning_rate": 1.751228236861573e-05,
1112
+ "loss": 1.0059,
1113
+ "step": 552
1114
+ },
1115
+ {
1116
+ "epoch": 0.76,
1117
+ "learning_rate": 1.7482837200943845e-05,
1118
+ "loss": 1.0081,
1119
+ "step": 555
1120
+ },
1121
+ {
1122
+ "epoch": 0.77,
1123
+ "learning_rate": 1.7453243864758638e-05,
1124
+ "loss": 1.0215,
1125
+ "step": 558
1126
+ },
1127
+ {
1128
+ "epoch": 0.77,
1129
+ "learning_rate": 1.7423502946041133e-05,
1130
+ "loss": 0.9935,
1131
+ "step": 561
1132
+ },
1133
+ {
1134
+ "epoch": 0.77,
1135
+ "learning_rate": 1.739361503369466e-05,
1136
+ "loss": 0.9945,
1137
+ "step": 564
1138
+ },
1139
+ {
1140
+ "epoch": 0.78,
1141
+ "learning_rate": 1.7363580719533173e-05,
1142
+ "loss": 0.9926,
1143
+ "step": 567
1144
+ },
1145
+ {
1146
+ "epoch": 0.78,
1147
+ "learning_rate": 1.733340059826956e-05,
1148
+ "loss": 0.9946,
1149
+ "step": 570
1150
+ },
1151
+ {
1152
+ "epoch": 0.79,
1153
+ "learning_rate": 1.7303075267503845e-05,
1154
+ "loss": 1.0079,
1155
+ "step": 573
1156
+ },
1157
+ {
1158
+ "epoch": 0.79,
1159
+ "learning_rate": 1.7272605327711364e-05,
1160
+ "loss": 1.0212,
1161
+ "step": 576
1162
+ },
1163
+ {
1164
+ "epoch": 0.79,
1165
+ "learning_rate": 1.7241991382230872e-05,
1166
+ "loss": 0.993,
1167
+ "step": 579
1168
+ },
1169
+ {
1170
+ "epoch": 0.8,
1171
+ "learning_rate": 1.72112340372526e-05,
1172
+ "loss": 0.9843,
1173
+ "step": 582
1174
+ },
1175
+ {
1176
+ "epoch": 0.8,
1177
+ "learning_rate": 1.718033390180624e-05,
1178
+ "loss": 0.9837,
1179
+ "step": 585
1180
+ },
1181
+ {
1182
+ "epoch": 0.81,
1183
+ "learning_rate": 1.71492915877489e-05,
1184
+ "loss": 0.959,
1185
+ "step": 588
1186
+ },
1187
+ {
1188
+ "epoch": 0.81,
1189
+ "learning_rate": 1.7118107709752986e-05,
1190
+ "loss": 0.9895,
1191
+ "step": 591
1192
+ },
1193
+ {
1194
+ "epoch": 0.82,
1195
+ "learning_rate": 1.7086782885294026e-05,
1196
+ "loss": 0.99,
1197
+ "step": 594
1198
+ },
1199
+ {
1200
+ "epoch": 0.82,
1201
+ "learning_rate": 1.7055317734638444e-05,
1202
+ "loss": 1.006,
1203
+ "step": 597
1204
+ },
1205
+ {
1206
+ "epoch": 0.82,
1207
+ "learning_rate": 1.702371288083127e-05,
1208
+ "loss": 1.0009,
1209
+ "step": 600
1210
+ },
1211
+ {
1212
+ "epoch": 0.83,
1213
+ "learning_rate": 1.6991968949683835e-05,
1214
+ "loss": 0.9758,
1215
+ "step": 603
1216
+ },
1217
+ {
1218
+ "epoch": 0.83,
1219
+ "learning_rate": 1.6960086569761332e-05,
1220
+ "loss": 0.9801,
1221
+ "step": 606
1222
+ },
1223
+ {
1224
+ "epoch": 0.84,
1225
+ "learning_rate": 1.6928066372370407e-05,
1226
+ "loss": 0.9833,
1227
+ "step": 609
1228
+ },
1229
+ {
1230
+ "epoch": 0.84,
1231
+ "learning_rate": 1.689590899154664e-05,
1232
+ "loss": 0.9846,
1233
+ "step": 612
1234
+ },
1235
+ {
1236
+ "epoch": 0.84,
1237
+ "learning_rate": 1.6863615064042003e-05,
1238
+ "loss": 0.9752,
1239
+ "step": 615
1240
+ },
1241
+ {
1242
+ "epoch": 0.85,
1243
+ "learning_rate": 1.6831185229312237e-05,
1244
+ "loss": 0.9869,
1245
+ "step": 618
1246
+ },
1247
+ {
1248
+ "epoch": 0.85,
1249
+ "learning_rate": 1.67986201295042e-05,
1250
+ "loss": 0.9869,
1251
+ "step": 621
1252
+ },
1253
+ {
1254
+ "epoch": 0.86,
1255
+ "learning_rate": 1.676592040944315e-05,
1256
+ "loss": 0.9878,
1257
+ "step": 624
1258
+ },
1259
+ {
1260
+ "epoch": 0.86,
1261
+ "learning_rate": 1.6733086716619976e-05,
1262
+ "loss": 0.9938,
1263
+ "step": 627
1264
+ },
1265
+ {
1266
+ "epoch": 0.86,
1267
+ "learning_rate": 1.6700119701178378e-05,
1268
+ "loss": 1.0045,
1269
+ "step": 630
1270
+ },
1271
+ {
1272
+ "epoch": 0.87,
1273
+ "learning_rate": 1.666702001590199e-05,
1274
+ "loss": 1.0088,
1275
+ "step": 633
1276
+ },
1277
+ {
1278
+ "epoch": 0.87,
1279
+ "learning_rate": 1.6633788316201455e-05,
1280
+ "loss": 0.998,
1281
+ "step": 636
1282
+ },
1283
+ {
1284
+ "epoch": 0.88,
1285
+ "learning_rate": 1.6600425260101453e-05,
1286
+ "loss": 1.0017,
1287
+ "step": 639
1288
+ },
1289
+ {
1290
+ "epoch": 0.88,
1291
+ "learning_rate": 1.6566931508227663e-05,
1292
+ "loss": 0.9995,
1293
+ "step": 642
1294
+ },
1295
+ {
1296
+ "epoch": 0.89,
1297
+ "learning_rate": 1.6533307723793688e-05,
1298
+ "loss": 1.0012,
1299
+ "step": 645
1300
+ },
1301
+ {
1302
+ "epoch": 0.89,
1303
+ "learning_rate": 1.649955457258792e-05,
1304
+ "loss": 0.9807,
1305
+ "step": 648
1306
+ },
1307
+ {
1308
+ "epoch": 0.89,
1309
+ "learning_rate": 1.6465672722960365e-05,
1310
+ "loss": 0.9664,
1311
+ "step": 651
1312
+ },
1313
+ {
1314
+ "epoch": 0.9,
1315
+ "learning_rate": 1.6431662845809388e-05,
1316
+ "loss": 0.9707,
1317
+ "step": 654
1318
+ },
1319
+ {
1320
+ "epoch": 0.9,
1321
+ "learning_rate": 1.6397525614568446e-05,
1322
+ "loss": 0.983,
1323
+ "step": 657
1324
+ },
1325
+ {
1326
+ "epoch": 0.91,
1327
+ "learning_rate": 1.6363261705192757e-05,
1328
+ "loss": 1.0061,
1329
+ "step": 660
1330
+ },
1331
+ {
1332
+ "epoch": 0.91,
1333
+ "learning_rate": 1.6328871796145894e-05,
1334
+ "loss": 0.9899,
1335
+ "step": 663
1336
+ },
1337
+ {
1338
+ "epoch": 0.91,
1339
+ "learning_rate": 1.629435656838637e-05,
1340
+ "loss": 0.9795,
1341
+ "step": 666
1342
+ },
1343
+ {
1344
+ "epoch": 0.92,
1345
+ "learning_rate": 1.6259716705354154e-05,
1346
+ "loss": 1.0002,
1347
+ "step": 669
1348
+ },
1349
+ {
1350
+ "epoch": 0.92,
1351
+ "learning_rate": 1.6224952892957122e-05,
1352
+ "loss": 0.9837,
1353
+ "step": 672
1354
+ },
1355
+ {
1356
+ "epoch": 0.93,
1357
+ "learning_rate": 1.6190065819557496e-05,
1358
+ "loss": 0.9872,
1359
+ "step": 675
1360
+ },
1361
+ {
1362
+ "epoch": 0.93,
1363
+ "learning_rate": 1.615505617595819e-05,
1364
+ "loss": 0.9797,
1365
+ "step": 678
1366
+ },
1367
+ {
1368
+ "epoch": 0.93,
1369
+ "learning_rate": 1.6119924655389158e-05,
1370
+ "loss": 0.9926,
1371
+ "step": 681
1372
+ },
1373
+ {
1374
+ "epoch": 0.94,
1375
+ "learning_rate": 1.6084671953493645e-05,
1376
+ "loss": 0.9884,
1377
+ "step": 684
1378
+ },
1379
+ {
1380
+ "epoch": 0.94,
1381
+ "learning_rate": 1.6049298768314425e-05,
1382
+ "loss": 0.9918,
1383
+ "step": 687
1384
+ },
1385
+ {
1386
+ "epoch": 0.95,
1387
+ "learning_rate": 1.6013805800279977e-05,
1388
+ "loss": 0.9829,
1389
+ "step": 690
1390
+ },
1391
+ {
1392
+ "epoch": 0.95,
1393
+ "learning_rate": 1.5978193752190607e-05,
1394
+ "loss": 0.9854,
1395
+ "step": 693
1396
+ },
1397
+ {
1398
+ "epoch": 0.96,
1399
+ "learning_rate": 1.5942463329204546e-05,
1400
+ "loss": 0.9751,
1401
+ "step": 696
1402
+ },
1403
+ {
1404
+ "epoch": 0.96,
1405
+ "learning_rate": 1.5906615238823974e-05,
1406
+ "loss": 0.9945,
1407
+ "step": 699
1408
+ },
1409
+ {
1410
+ "epoch": 0.96,
1411
+ "learning_rate": 1.5870650190881023e-05,
1412
+ "loss": 0.9957,
1413
+ "step": 702
1414
+ },
1415
+ {
1416
+ "epoch": 0.97,
1417
+ "learning_rate": 1.583456889752371e-05,
1418
+ "loss": 1.0047,
1419
+ "step": 705
1420
+ },
1421
+ {
1422
+ "epoch": 0.97,
1423
+ "learning_rate": 1.579837207320184e-05,
1424
+ "loss": 0.9921,
1425
+ "step": 708
1426
+ },
1427
+ {
1428
+ "epoch": 0.98,
1429
+ "learning_rate": 1.5762060434652863e-05,
1430
+ "loss": 0.9839,
1431
+ "step": 711
1432
+ },
1433
+ {
1434
+ "epoch": 0.98,
1435
+ "learning_rate": 1.572563470088768e-05,
1436
+ "loss": 0.9922,
1437
+ "step": 714
1438
+ },
1439
+ {
1440
+ "epoch": 0.98,
1441
+ "learning_rate": 1.56890955931764e-05,
1442
+ "loss": 0.9752,
1443
+ "step": 717
1444
+ },
1445
+ {
1446
+ "epoch": 0.99,
1447
+ "learning_rate": 1.565244383503407e-05,
1448
+ "loss": 0.9778,
1449
+ "step": 720
1450
+ },
1451
+ {
1452
+ "epoch": 0.99,
1453
+ "learning_rate": 1.5615680152206324e-05,
1454
+ "loss": 0.9795,
1455
+ "step": 723
1456
+ },
1457
+ {
1458
+ "epoch": 1.0,
1459
+ "learning_rate": 1.557880527265505e-05,
1460
+ "loss": 0.9774,
1461
+ "step": 726
1462
+ }
1463
+ ],
1464
+ "logging_steps": 3,
1465
+ "max_steps": 2184,
1466
+ "num_input_tokens_seen": 0,
1467
+ "num_train_epochs": 3,
1468
+ "save_steps": 500.0,
1469
+ "total_flos": 4.694048596218085e+18,
1470
+ "train_batch_size": 8,
1471
+ "trial_name": null,
1472
+ "trial_params": null
1473
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d50359a332e42ea966d472131e23398b23d29c578499d527e2012fe207eae898
3
+ size 6264
zero_to_fp32.py ADDED
@@ -0,0 +1,604 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example: python zero_to_fp32.py . pytorch_model.bin
14
+
15
+ import argparse
16
+ import torch
17
+ import glob
18
+ import math
19
+ import os
20
+ import re
21
+ from collections import OrderedDict
22
+ from dataclasses import dataclass
23
+
24
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
25
+ # DeepSpeed data structures it has to be available in the current python environment.
26
+ from deepspeed.utils import logger
27
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
28
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
29
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
30
+
31
+
32
+ @dataclass
33
+ class zero_model_state:
34
+ buffers: dict()
35
+ param_shapes: dict()
36
+ shared_params: list
37
+ ds_version: int
38
+ frozen_param_shapes: dict()
39
+ frozen_param_fragments: dict()
40
+
41
+
42
+ debug = 0
43
+
44
+ # load to cpu
45
+ device = torch.device('cpu')
46
+
47
+
48
+ def atoi(text):
49
+ return int(text) if text.isdigit() else text
50
+
51
+
52
+ def natural_keys(text):
53
+ '''
54
+ alist.sort(key=natural_keys) sorts in human order
55
+ http://nedbatchelder.com/blog/200712/human_sorting.html
56
+ (See Toothy's implementation in the comments)
57
+ '''
58
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
59
+
60
+
61
+ def get_model_state_file(checkpoint_dir, zero_stage):
62
+ if not os.path.isdir(checkpoint_dir):
63
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
64
+
65
+ # there should be only one file
66
+ if zero_stage <= 2:
67
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
68
+ elif zero_stage == 3:
69
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
70
+
71
+ if not os.path.exists(file):
72
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
73
+
74
+ return file
75
+
76
+
77
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
78
+ # XXX: need to test that this simple glob rule works for multi-node setup too
79
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
80
+
81
+ if len(ckpt_files) == 0:
82
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
83
+
84
+ return ckpt_files
85
+
86
+
87
+ def get_optim_files(checkpoint_dir):
88
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
89
+
90
+
91
+ def get_model_state_files(checkpoint_dir):
92
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
93
+
94
+
95
+ def parse_model_states(files):
96
+ zero_model_states = []
97
+ for file in files:
98
+ state_dict = torch.load(file, map_location=device)
99
+
100
+ if BUFFER_NAMES not in state_dict:
101
+ raise ValueError(f"{file} is not a model state checkpoint")
102
+ buffer_names = state_dict[BUFFER_NAMES]
103
+ if debug:
104
+ print("Found buffers:", buffer_names)
105
+
106
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
107
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
108
+ param_shapes = state_dict[PARAM_SHAPES]
109
+
110
+ # collect parameters that are included in param_shapes
111
+ param_names = []
112
+ for s in param_shapes:
113
+ for name in s.keys():
114
+ param_names.append(name)
115
+
116
+ # update with frozen parameters
117
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
118
+ if frozen_param_shapes is not None:
119
+ if debug:
120
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
121
+ param_names += list(frozen_param_shapes.keys())
122
+
123
+ # handle shared params
124
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
125
+
126
+ ds_version = state_dict.get(DS_VERSION, None)
127
+
128
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
129
+
130
+ z_model_state = zero_model_state(buffers=buffers,
131
+ param_shapes=param_shapes,
132
+ shared_params=shared_params,
133
+ ds_version=ds_version,
134
+ frozen_param_shapes=frozen_param_shapes,
135
+ frozen_param_fragments=frozen_param_fragments)
136
+ zero_model_states.append(z_model_state)
137
+
138
+ return zero_model_states
139
+
140
+
141
+ def parse_optim_states(files, ds_checkpoint_dir):
142
+
143
+ total_files = len(files)
144
+ state_dicts = []
145
+ for f in files:
146
+ state_dict = torch.load(f, map_location=device)
147
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
148
+ # and also handle the case where it was already removed by another helper script
149
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
150
+ state_dicts.append(state_dict)
151
+
152
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
153
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
154
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
155
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
156
+
157
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
158
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
159
+ # use the max of the partition_count to get the dp world_size.
160
+
161
+ if type(world_size) is list:
162
+ world_size = max(world_size)
163
+
164
+ if world_size != total_files:
165
+ raise ValueError(
166
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
167
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
168
+ )
169
+
170
+ # the groups are named differently in each stage
171
+ if zero_stage <= 2:
172
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
173
+ elif zero_stage == 3:
174
+ fp32_groups_key = FP32_FLAT_GROUPS
175
+ else:
176
+ raise ValueError(f"unknown zero stage {zero_stage}")
177
+
178
+ if zero_stage <= 2:
179
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
180
+ elif zero_stage == 3:
181
+ # if there is more than one param group, there will be multiple flattened tensors - one
182
+ # flattened tensor per group - for simplicity merge them into a single tensor
183
+ #
184
+ # XXX: could make the script more memory efficient for when there are multiple groups - it
185
+ # will require matching the sub-lists of param_shapes for each param group flattened tensor
186
+
187
+ fp32_flat_groups = [
188
+ torch.cat(state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key], 0) for i in range(len(state_dicts))
189
+ ]
190
+
191
+ return zero_stage, world_size, fp32_flat_groups
192
+
193
+
194
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
195
+ """
196
+ Returns fp32 state_dict reconstructed from ds checkpoint
197
+
198
+ Args:
199
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
200
+
201
+ """
202
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
203
+
204
+ optim_files = get_optim_files(ds_checkpoint_dir)
205
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
206
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
207
+
208
+ model_files = get_model_state_files(ds_checkpoint_dir)
209
+
210
+ zero_model_states = parse_model_states(model_files)
211
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
212
+
213
+ if zero_stage <= 2:
214
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
215
+ exclude_frozen_parameters)
216
+ elif zero_stage == 3:
217
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
218
+ exclude_frozen_parameters)
219
+
220
+
221
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
222
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
223
+ return
224
+
225
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
226
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
227
+
228
+ if debug:
229
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
230
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
231
+
232
+ wanted_params = len(frozen_param_shapes)
233
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
234
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
235
+ print(f'Frozen params: Have {avail_numel} numels to process.')
236
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
237
+
238
+ total_params = 0
239
+ total_numel = 0
240
+ for name, shape in frozen_param_shapes.items():
241
+ total_params += 1
242
+ unpartitioned_numel = shape.numel()
243
+ total_numel += unpartitioned_numel
244
+
245
+ state_dict[name] = frozen_param_fragments[name]
246
+
247
+ if debug:
248
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
249
+
250
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
251
+
252
+
253
+ def _has_callable(obj, fn):
254
+ attr = getattr(obj, fn, None)
255
+ return callable(attr)
256
+
257
+
258
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
259
+ param_shapes = zero_model_states[0].param_shapes
260
+
261
+ # Reconstruction protocol:
262
+ #
263
+ # XXX: document this
264
+
265
+ if debug:
266
+ for i in range(world_size):
267
+ for j in range(len(fp32_flat_groups[0])):
268
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
269
+
270
+ # XXX: memory usage doubles here (zero2)
271
+ num_param_groups = len(fp32_flat_groups[0])
272
+ merged_single_partition_of_fp32_groups = []
273
+ for i in range(num_param_groups):
274
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
275
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
276
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
277
+ avail_numel = sum(
278
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
279
+
280
+ if debug:
281
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
282
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
283
+ # not asserting if there is a mismatch due to possible padding
284
+ print(f"Have {avail_numel} numels to process.")
285
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
286
+
287
+ # params
288
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
289
+ # out-of-core computing solution
290
+ total_numel = 0
291
+ total_params = 0
292
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
293
+ offset = 0
294
+ avail_numel = full_single_fp32_vector.numel()
295
+ for name, shape in shapes.items():
296
+
297
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
298
+ total_numel += unpartitioned_numel
299
+ total_params += 1
300
+
301
+ if debug:
302
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
303
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
304
+ offset += unpartitioned_numel
305
+
306
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
307
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
308
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
309
+ # live optimizer object, so we are checking that the numbers are within the right range
310
+ align_to = 2 * world_size
311
+
312
+ def zero2_align(x):
313
+ return align_to * math.ceil(x / align_to)
314
+
315
+ if debug:
316
+ print(f"original offset={offset}, avail_numel={avail_numel}")
317
+
318
+ offset = zero2_align(offset)
319
+ avail_numel = zero2_align(avail_numel)
320
+
321
+ if debug:
322
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
323
+
324
+ # Sanity check
325
+ if offset != avail_numel:
326
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
327
+
328
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
329
+
330
+
331
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
332
+ exclude_frozen_parameters):
333
+ state_dict = OrderedDict()
334
+
335
+ # buffers
336
+ buffers = zero_model_states[0].buffers
337
+ state_dict.update(buffers)
338
+ if debug:
339
+ print(f"added {len(buffers)} buffers")
340
+
341
+ if not exclude_frozen_parameters:
342
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
343
+
344
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
345
+
346
+ # recover shared parameters
347
+ for pair in zero_model_states[0].shared_params:
348
+ if pair[1] in state_dict:
349
+ state_dict[pair[0]] = state_dict[pair[1]]
350
+
351
+ return state_dict
352
+
353
+
354
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
355
+ remainder = unpartitioned_numel % world_size
356
+ padding_numel = (world_size - remainder) if remainder else 0
357
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
358
+ return partitioned_numel, padding_numel
359
+
360
+
361
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
362
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
363
+ return
364
+
365
+ if debug:
366
+ for i in range(world_size):
367
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
368
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
369
+
370
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
371
+ wanted_params = len(frozen_param_shapes)
372
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
373
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
374
+ print(f'Frozen params: Have {avail_numel} numels to process.')
375
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
376
+
377
+ total_params = 0
378
+ total_numel = 0
379
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
380
+ total_params += 1
381
+ unpartitioned_numel = shape.numel()
382
+ total_numel += unpartitioned_numel
383
+
384
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
385
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
386
+
387
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
388
+
389
+ if debug:
390
+ print(
391
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
392
+ )
393
+
394
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
395
+
396
+
397
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
398
+ param_shapes = zero_model_states[0].param_shapes
399
+ avail_numel = fp32_flat_groups[0].numel() * world_size
400
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
401
+ # param, re-consolidating each param, while dealing with padding if any
402
+
403
+ # merge list of dicts, preserving order
404
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
405
+
406
+ if debug:
407
+ for i in range(world_size):
408
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
409
+
410
+ wanted_params = len(param_shapes)
411
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
412
+ # not asserting if there is a mismatch due to possible padding
413
+ avail_numel = fp32_flat_groups[0].numel() * world_size
414
+ print(f"Trainable params: Have {avail_numel} numels to process.")
415
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
416
+
417
+ # params
418
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
419
+ # out-of-core computing solution
420
+ offset = 0
421
+ total_numel = 0
422
+ total_params = 0
423
+ for name, shape in param_shapes.items():
424
+
425
+ unpartitioned_numel = shape.numel()
426
+ total_numel += unpartitioned_numel
427
+ total_params += 1
428
+
429
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
430
+
431
+ if debug:
432
+ print(
433
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
434
+ )
435
+
436
+ # XXX: memory usage doubles here
437
+ state_dict[name] = torch.cat(
438
+ tuple(fp32_flat_groups[i].narrow(0, offset, partitioned_numel) for i in range(world_size)),
439
+ 0).narrow(0, 0, unpartitioned_numel).view(shape)
440
+ offset += partitioned_numel
441
+
442
+ offset *= world_size
443
+
444
+ # Sanity check
445
+ if offset != avail_numel:
446
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
447
+
448
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
449
+
450
+
451
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
452
+ exclude_frozen_parameters):
453
+ state_dict = OrderedDict()
454
+
455
+ # buffers
456
+ buffers = zero_model_states[0].buffers
457
+ state_dict.update(buffers)
458
+ if debug:
459
+ print(f"added {len(buffers)} buffers")
460
+
461
+ if not exclude_frozen_parameters:
462
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
463
+
464
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
465
+
466
+ # recover shared parameters
467
+ for pair in zero_model_states[0].shared_params:
468
+ if pair[1] in state_dict:
469
+ state_dict[pair[0]] = state_dict[pair[1]]
470
+
471
+ return state_dict
472
+
473
+
474
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag=None, exclude_frozen_parameters=False):
475
+ """
476
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
477
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
478
+ via a model hub.
479
+
480
+ Args:
481
+ - ``checkpoint_dir``: path to the desired checkpoint folder
482
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
483
+ - ``exclude_frozen_parameters``: exclude frozen parameters
484
+
485
+ Returns:
486
+ - pytorch ``state_dict``
487
+
488
+ Note: this approach may not work if your application doesn't have sufficient free CPU memory and
489
+ you may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
490
+ the checkpoint.
491
+
492
+ A typical usage might be ::
493
+
494
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
495
+ # do the training and checkpoint saving
496
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
497
+ model = model.cpu() # move to cpu
498
+ model.load_state_dict(state_dict)
499
+ # submit to model hub or save the model to share with others
500
+
501
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
502
+ application. i.e. you will need to re-initialize the deepspeed engine, since
503
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
504
+
505
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
506
+
507
+ """
508
+ if tag is None:
509
+ latest_path = os.path.join(checkpoint_dir, 'latest')
510
+ if os.path.isfile(latest_path):
511
+ with open(latest_path, 'r') as fd:
512
+ tag = fd.read().strip()
513
+ else:
514
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
515
+
516
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
517
+
518
+ if not os.path.isdir(ds_checkpoint_dir):
519
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
520
+
521
+ return _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
522
+
523
+
524
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir, output_file, tag=None, exclude_frozen_parameters=False):
525
+ """
526
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
527
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
528
+
529
+ Args:
530
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
531
+ - ``output_file``: path to the pytorch fp32 state_dict output file (e.g. path/pytorch_model.bin)
532
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
533
+ - ``exclude_frozen_parameters``: exclude frozen parameters
534
+ """
535
+
536
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag, exclude_frozen_parameters)
537
+ print(f"Saving fp32 state dict to {output_file}")
538
+ torch.save(state_dict, output_file)
539
+
540
+
541
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
542
+ """
543
+ 1. Put the provided model to cpu
544
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
545
+ 3. Load it into the provided model
546
+
547
+ Args:
548
+ - ``model``: the model object to update
549
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
550
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
551
+
552
+ Returns:
553
+ - ``model`: modified model
554
+
555
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
556
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
557
+ conveniently placed for you in the checkpoint folder.
558
+
559
+ A typical usage might be ::
560
+
561
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
562
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
563
+ # submit to model hub or save the model to share with others
564
+
565
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
566
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
567
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
568
+
569
+ """
570
+ logger.info(f"Extracting fp32 weights")
571
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
572
+
573
+ logger.info(f"Overwriting model with fp32 weights")
574
+ model = model.cpu()
575
+ model.load_state_dict(state_dict, strict=False)
576
+
577
+ return model
578
+
579
+
580
+ if __name__ == "__main__":
581
+
582
+ parser = argparse.ArgumentParser()
583
+ parser.add_argument("checkpoint_dir",
584
+ type=str,
585
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
586
+ parser.add_argument(
587
+ "output_file",
588
+ type=str,
589
+ help="path to the pytorch fp32 state_dict output file (e.g. path/checkpoint-12/pytorch_model.bin)")
590
+ parser.add_argument("-t",
591
+ "--tag",
592
+ type=str,
593
+ default=None,
594
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
595
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
596
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
597
+ args = parser.parse_args()
598
+
599
+ debug = args.debug
600
+
601
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
602
+ args.output_file,
603
+ tag=args.tag,
604
+ exclude_frozen_parameters=args.exclude_frozen_parameters)