DylanJHJ commited on
Commit
91ae547
·
verified ·
1 Parent(s): 8614716

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: meta-llama/Llama-3.1-8B-Instruct
3
+ library_name: peft
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.15.2
adapter_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "meta-llama/Llama-3.1-8B-Instruct",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 64,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0.1,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "r": 32,
24
+ "rank_pattern": {},
25
+ "revision": null,
26
+ "target_modules": [
27
+ "gate_proj",
28
+ "up_proj",
29
+ "k_proj",
30
+ "v_proj",
31
+ "down_proj",
32
+ "o_proj",
33
+ "q_proj"
34
+ ],
35
+ "task_type": "FEATURE_EXTRACTION",
36
+ "trainable_token_indices": null,
37
+ "use_dora": false,
38
+ "use_rslora": false
39
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d834a8946d199e927c8a90a6618f5f2ca8d22e2dcf561e28eb61a014c56c2d58
3
+ size 167830000
global_step2000/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21dd4b0a9f05b89675664a0cda1b742341e5bc6a61ae8436a9e93ff3fb7bd23f
3
+ size 503321221
global_step2000/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e34c4ef234d151fb65ce06cd131d88e7409114f0f88b469a17903ec9033f6917
3
+ size 503321221
global_step2000/zero_pp_rank_0_mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb48c3fc9c0a085913a812cd0f0e0937020d2aac30e06696ac5e5a0f00ae91ca
3
+ size 7505607949
global_step2000/zero_pp_rank_1_mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6b16f374d498e5cdd2f7871c3711d95acdbfccdffdd96a4469c78c9a8b7806b
3
+ size 7505607949
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step2000
rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3187582f93346ac731063660f77d204a6388aa62af543ba14bb46eb3557256cf
3
+ size 14917
rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fa719667cb4203b1bf435939440361a7640d442b6d4371fc26ee5d2f66c10f0
3
+ size 14917
trainer_state.json ADDED
@@ -0,0 +1,1434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.5213764337851929,
6
+ "eval_steps": 500,
7
+ "global_step": 2000,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.0026068821689259644,
14
+ "grad_norm": 49.331476986681444,
15
+ "learning_rate": 3.2668258512966296e-05,
16
+ "loss": 12.2547,
17
+ "step": 10
18
+ },
19
+ {
20
+ "epoch": 0.005213764337851929,
21
+ "grad_norm": 8.763915233449037,
22
+ "learning_rate": 4.2502384231474356e-05,
23
+ "loss": 4.8812,
24
+ "step": 20
25
+ },
26
+ {
27
+ "epoch": 0.007820646506777894,
28
+ "grad_norm": 3.334694167190291,
29
+ "learning_rate": 4.825497900417907e-05,
30
+ "loss": 1.6309,
31
+ "step": 30
32
+ },
33
+ {
34
+ "epoch": 0.010427528675703858,
35
+ "grad_norm": 2.624343181311664,
36
+ "learning_rate": 5.2336509949982417e-05,
37
+ "loss": 1.3866,
38
+ "step": 40
39
+ },
40
+ {
41
+ "epoch": 0.013034410844629822,
42
+ "grad_norm": 2.6057816533089366,
43
+ "learning_rate": 5.550239130742453e-05,
44
+ "loss": 1.2347,
45
+ "step": 50
46
+ },
47
+ {
48
+ "epoch": 0.01564129301355579,
49
+ "grad_norm": 3.3478789899750456,
50
+ "learning_rate": 5.8089104722687125e-05,
51
+ "loss": 1.1339,
52
+ "step": 60
53
+ },
54
+ {
55
+ "epoch": 0.01824817518248175,
56
+ "grad_norm": 2.233945689028257,
57
+ "learning_rate": 6.027613975295318e-05,
58
+ "loss": 1.1551,
59
+ "step": 70
60
+ },
61
+ {
62
+ "epoch": 0.020855057351407715,
63
+ "grad_norm": 2.5906299607793,
64
+ "learning_rate": 6.217063566849047e-05,
65
+ "loss": 1.0871,
66
+ "step": 80
67
+ },
68
+ {
69
+ "epoch": 0.02346193952033368,
70
+ "grad_norm": 2.1892355695478547,
71
+ "learning_rate": 6.384169949539185e-05,
72
+ "loss": 1.0,
73
+ "step": 90
74
+ },
75
+ {
76
+ "epoch": 0.026068821689259645,
77
+ "grad_norm": 2.0124093217815813,
78
+ "learning_rate": 6.533651702593259e-05,
79
+ "loss": 1.0452,
80
+ "step": 100
81
+ },
82
+ {
83
+ "epoch": 0.02867570385818561,
84
+ "grad_norm": 2.079141219384628,
85
+ "learning_rate": 6.668874396522732e-05,
86
+ "loss": 1.0112,
87
+ "step": 110
88
+ },
89
+ {
90
+ "epoch": 0.03128258602711158,
91
+ "grad_norm": 1.9554916426797533,
92
+ "learning_rate": 6.79232304411952e-05,
93
+ "loss": 1.0344,
94
+ "step": 120
95
+ },
96
+ {
97
+ "epoch": 0.03388946819603754,
98
+ "grad_norm": 1.9875868563850505,
99
+ "learning_rate": 6.905884791492633e-05,
100
+ "loss": 1.0269,
101
+ "step": 130
102
+ },
103
+ {
104
+ "epoch": 0.0364963503649635,
105
+ "grad_norm": 2.1941623350784516,
106
+ "learning_rate": 7.011026547146124e-05,
107
+ "loss": 1.039,
108
+ "step": 140
109
+ },
110
+ {
111
+ "epoch": 0.03910323253388947,
112
+ "grad_norm": 1.8155718741045461,
113
+ "learning_rate": 7.10891117986373e-05,
114
+ "loss": 1.0616,
115
+ "step": 150
116
+ },
117
+ {
118
+ "epoch": 0.04171011470281543,
119
+ "grad_norm": 1.7586342549475686,
120
+ "learning_rate": 7.200476138699854e-05,
121
+ "loss": 1.0547,
122
+ "step": 160
123
+ },
124
+ {
125
+ "epoch": 0.0443169968717414,
126
+ "grad_norm": 2.100292158595079,
127
+ "learning_rate": 7.28648819635523e-05,
128
+ "loss": 1.0031,
129
+ "step": 170
130
+ },
131
+ {
132
+ "epoch": 0.04692387904066736,
133
+ "grad_norm": 2.0513256959729227,
134
+ "learning_rate": 7.36758252138999e-05,
135
+ "loss": 1.0158,
136
+ "step": 180
137
+ },
138
+ {
139
+ "epoch": 0.04953076120959333,
140
+ "grad_norm": 2.1426958006504897,
141
+ "learning_rate": 7.444291172327986e-05,
142
+ "loss": 1.0174,
143
+ "step": 190
144
+ },
145
+ {
146
+ "epoch": 0.05213764337851929,
147
+ "grad_norm": 1.8318521527764522,
148
+ "learning_rate": 7.517064274444065e-05,
149
+ "loss": 1.0546,
150
+ "step": 200
151
+ },
152
+ {
153
+ "epoch": 0.05474452554744526,
154
+ "grad_norm": 1.886155228760021,
155
+ "learning_rate": 7.586286024416594e-05,
156
+ "loss": 1.0019,
157
+ "step": 210
158
+ },
159
+ {
160
+ "epoch": 0.05735140771637122,
161
+ "grad_norm": 2.739142325850314,
162
+ "learning_rate": 7.652286968373537e-05,
163
+ "loss": 0.9374,
164
+ "step": 220
165
+ },
166
+ {
167
+ "epoch": 0.05995828988529719,
168
+ "grad_norm": 1.7629924772556742,
169
+ "learning_rate": 7.715353548429121e-05,
170
+ "loss": 1.0266,
171
+ "step": 230
172
+ },
173
+ {
174
+ "epoch": 0.06256517205422316,
175
+ "grad_norm": 2.165683236469649,
176
+ "learning_rate": 7.775735615970326e-05,
177
+ "loss": 1.0178,
178
+ "step": 240
179
+ },
180
+ {
181
+ "epoch": 0.06517205422314912,
182
+ "grad_norm": 1.733337560836944,
183
+ "learning_rate": 7.833652410188277e-05,
184
+ "loss": 0.9352,
185
+ "step": 250
186
+ },
187
+ {
188
+ "epoch": 0.06777893639207508,
189
+ "grad_norm": 1.4644627780270372,
190
+ "learning_rate": 7.88929736334344e-05,
191
+ "loss": 0.9917,
192
+ "step": 260
193
+ },
194
+ {
195
+ "epoch": 0.07038581856100104,
196
+ "grad_norm": 1.8822940709742961,
197
+ "learning_rate": 7.942841998660462e-05,
198
+ "loss": 1.01,
199
+ "step": 270
200
+ },
201
+ {
202
+ "epoch": 0.072992700729927,
203
+ "grad_norm": 1.796235628150547,
204
+ "learning_rate": 7.99443911899693e-05,
205
+ "loss": 0.9574,
206
+ "step": 280
207
+ },
208
+ {
209
+ "epoch": 0.07559958289885298,
210
+ "grad_norm": 1.7794624205157685,
211
+ "learning_rate": 8.044225435717374e-05,
212
+ "loss": 0.9455,
213
+ "step": 290
214
+ },
215
+ {
216
+ "epoch": 0.07820646506777894,
217
+ "grad_norm": 1.845721579155461,
218
+ "learning_rate": 8.092323751714537e-05,
219
+ "loss": 0.9842,
220
+ "step": 300
221
+ },
222
+ {
223
+ "epoch": 0.0808133472367049,
224
+ "grad_norm": 1.5340232922646442,
225
+ "learning_rate": 8.13884478634796e-05,
226
+ "loss": 1.0016,
227
+ "step": 310
228
+ },
229
+ {
230
+ "epoch": 0.08342022940563086,
231
+ "grad_norm": 1.7408053834467931,
232
+ "learning_rate": 8.18388871055066e-05,
233
+ "loss": 0.9408,
234
+ "step": 320
235
+ },
236
+ {
237
+ "epoch": 0.08602711157455684,
238
+ "grad_norm": 2.002334563523922,
239
+ "learning_rate": 8.227546445644009e-05,
240
+ "loss": 1.011,
241
+ "step": 330
242
+ },
243
+ {
244
+ "epoch": 0.0886339937434828,
245
+ "grad_norm": 1.5325036507169985,
246
+ "learning_rate": 8.269900768206035e-05,
247
+ "loss": 0.9431,
248
+ "step": 340
249
+ },
250
+ {
251
+ "epoch": 0.09124087591240876,
252
+ "grad_norm": 1.656179096323659,
253
+ "learning_rate": 8.31102725474114e-05,
254
+ "loss": 0.948,
255
+ "step": 350
256
+ },
257
+ {
258
+ "epoch": 0.09384775808133472,
259
+ "grad_norm": 1.579268561671285,
260
+ "learning_rate": 8.350995093240796e-05,
261
+ "loss": 0.9828,
262
+ "step": 360
263
+ },
264
+ {
265
+ "epoch": 0.09645464025026068,
266
+ "grad_norm": 1.430642284312776,
267
+ "learning_rate": 8.389867783526633e-05,
268
+ "loss": 0.9933,
269
+ "step": 370
270
+ },
271
+ {
272
+ "epoch": 0.09906152241918666,
273
+ "grad_norm": 1.834119895542427,
274
+ "learning_rate": 8.427703744178792e-05,
275
+ "loss": 0.9299,
276
+ "step": 380
277
+ },
278
+ {
279
+ "epoch": 0.10166840458811262,
280
+ "grad_norm": 1.615728296022092,
281
+ "learning_rate": 8.46455684061391e-05,
282
+ "loss": 0.933,
283
+ "step": 390
284
+ },
285
+ {
286
+ "epoch": 0.10427528675703858,
287
+ "grad_norm": 1.5075395597879127,
288
+ "learning_rate": 8.500476846294871e-05,
289
+ "loss": 0.9402,
290
+ "step": 400
291
+ },
292
+ {
293
+ "epoch": 0.10688216892596454,
294
+ "grad_norm": 2.318206330951205,
295
+ "learning_rate": 8.535509846982542e-05,
296
+ "loss": 0.9586,
297
+ "step": 410
298
+ },
299
+ {
300
+ "epoch": 0.10948905109489052,
301
+ "grad_norm": 1.7156459393153987,
302
+ "learning_rate": 8.5696985962674e-05,
303
+ "loss": 0.9669,
304
+ "step": 420
305
+ },
306
+ {
307
+ "epoch": 0.11209593326381648,
308
+ "grad_norm": 1.661507066068275,
309
+ "learning_rate": 8.603082829261603e-05,
310
+ "loss": 0.9069,
311
+ "step": 430
312
+ },
313
+ {
314
+ "epoch": 0.11470281543274244,
315
+ "grad_norm": 1.4599548493342727,
316
+ "learning_rate": 8.635699540224343e-05,
317
+ "loss": 0.9652,
318
+ "step": 440
319
+ },
320
+ {
321
+ "epoch": 0.1173096976016684,
322
+ "grad_norm": 1.7927399177658685,
323
+ "learning_rate": 8.667583228985008e-05,
324
+ "loss": 0.9607,
325
+ "step": 450
326
+ },
327
+ {
328
+ "epoch": 0.11991657977059438,
329
+ "grad_norm": 1.4930927495338642,
330
+ "learning_rate": 8.698766120279926e-05,
331
+ "loss": 0.9299,
332
+ "step": 460
333
+ },
334
+ {
335
+ "epoch": 0.12252346193952034,
336
+ "grad_norm": 1.6044841258937315,
337
+ "learning_rate": 8.729278359498751e-05,
338
+ "loss": 0.9433,
339
+ "step": 470
340
+ },
341
+ {
342
+ "epoch": 0.1251303441084463,
343
+ "grad_norm": 1.9302309005632683,
344
+ "learning_rate": 8.75914818782113e-05,
345
+ "loss": 0.9274,
346
+ "step": 480
347
+ },
348
+ {
349
+ "epoch": 0.12773722627737227,
350
+ "grad_norm": 1.728242732565303,
351
+ "learning_rate": 8.788402099294005e-05,
352
+ "loss": 0.9181,
353
+ "step": 490
354
+ },
355
+ {
356
+ "epoch": 0.13034410844629823,
357
+ "grad_norm": 1.4910517402601842,
358
+ "learning_rate": 8.817064982039083e-05,
359
+ "loss": 0.9234,
360
+ "step": 500
361
+ },
362
+ {
363
+ "epoch": 0.1329509906152242,
364
+ "grad_norm": 1.5741224965672913,
365
+ "learning_rate": 8.845160245476505e-05,
366
+ "loss": 0.8945,
367
+ "step": 510
368
+ },
369
+ {
370
+ "epoch": 0.13555787278415016,
371
+ "grad_norm": 1.3822257084676812,
372
+ "learning_rate": 8.872709935194245e-05,
373
+ "loss": 0.982,
374
+ "step": 520
375
+ },
376
+ {
377
+ "epoch": 0.13816475495307612,
378
+ "grad_norm": 1.4357135301136048,
379
+ "learning_rate": 8.899734836875464e-05,
380
+ "loss": 0.9525,
381
+ "step": 530
382
+ },
383
+ {
384
+ "epoch": 0.14077163712200208,
385
+ "grad_norm": 1.4310342833260414,
386
+ "learning_rate": 8.926254570511269e-05,
387
+ "loss": 0.9697,
388
+ "step": 540
389
+ },
390
+ {
391
+ "epoch": 0.14337851929092804,
392
+ "grad_norm": 1.3185832595803366,
393
+ "learning_rate": 8.952287675968555e-05,
394
+ "loss": 0.9374,
395
+ "step": 550
396
+ },
397
+ {
398
+ "epoch": 0.145985401459854,
399
+ "grad_norm": 1.194013911012122,
400
+ "learning_rate": 8.977851690847735e-05,
401
+ "loss": 0.9299,
402
+ "step": 560
403
+ },
404
+ {
405
+ "epoch": 0.14859228362878,
406
+ "grad_norm": 1.6923709597781003,
407
+ "learning_rate": 9.002963221449265e-05,
408
+ "loss": 0.9219,
409
+ "step": 570
410
+ },
411
+ {
412
+ "epoch": 0.15119916579770595,
413
+ "grad_norm": 1.526862442225114,
414
+ "learning_rate": 9.02763800756818e-05,
415
+ "loss": 0.9628,
416
+ "step": 580
417
+ },
418
+ {
419
+ "epoch": 0.15380604796663191,
420
+ "grad_norm": 1.5075661508716671,
421
+ "learning_rate": 9.051890981749827e-05,
422
+ "loss": 0.9135,
423
+ "step": 590
424
+ },
425
+ {
426
+ "epoch": 0.15641293013555788,
427
+ "grad_norm": 1.4428334009023258,
428
+ "learning_rate": 9.075736323565343e-05,
429
+ "loss": 0.909,
430
+ "step": 600
431
+ },
432
+ {
433
+ "epoch": 0.15901981230448384,
434
+ "grad_norm": 1.741611639128364,
435
+ "learning_rate": 9.09918750940095e-05,
436
+ "loss": 0.897,
437
+ "step": 610
438
+ },
439
+ {
440
+ "epoch": 0.1616266944734098,
441
+ "grad_norm": 1.187339694623765,
442
+ "learning_rate": 9.122257358198768e-05,
443
+ "loss": 0.9161,
444
+ "step": 620
445
+ },
446
+ {
447
+ "epoch": 0.16423357664233576,
448
+ "grad_norm": 1.7239405643085177,
449
+ "learning_rate": 9.144958073537873e-05,
450
+ "loss": 0.9275,
451
+ "step": 630
452
+ },
453
+ {
454
+ "epoch": 0.16684045881126172,
455
+ "grad_norm": 1.4934424469320755,
456
+ "learning_rate": 9.167301282401467e-05,
457
+ "loss": 0.9181,
458
+ "step": 640
459
+ },
460
+ {
461
+ "epoch": 0.16944734098018768,
462
+ "grad_norm": 1.5887533903293958,
463
+ "learning_rate": 9.189298070938457e-05,
464
+ "loss": 0.8614,
465
+ "step": 650
466
+ },
467
+ {
468
+ "epoch": 0.17205422314911367,
469
+ "grad_norm": 1.3073452168799204,
470
+ "learning_rate": 9.210959017494815e-05,
471
+ "loss": 0.9295,
472
+ "step": 660
473
+ },
474
+ {
475
+ "epoch": 0.17466110531803963,
476
+ "grad_norm": 1.6241911957261628,
477
+ "learning_rate": 9.232294223161082e-05,
478
+ "loss": 0.9024,
479
+ "step": 670
480
+ },
481
+ {
482
+ "epoch": 0.1772679874869656,
483
+ "grad_norm": 1.353634519365756,
484
+ "learning_rate": 9.25331334005684e-05,
485
+ "loss": 1.002,
486
+ "step": 680
487
+ },
488
+ {
489
+ "epoch": 0.17987486965589156,
490
+ "grad_norm": 1.3805701443193243,
491
+ "learning_rate": 9.274025597550396e-05,
492
+ "loss": 0.9504,
493
+ "step": 690
494
+ },
495
+ {
496
+ "epoch": 0.18248175182481752,
497
+ "grad_norm": 1.349628444790834,
498
+ "learning_rate": 9.294439826591947e-05,
499
+ "loss": 0.8845,
500
+ "step": 700
501
+ },
502
+ {
503
+ "epoch": 0.18508863399374348,
504
+ "grad_norm": 1.6959737374830173,
505
+ "learning_rate": 9.314564482320817e-05,
506
+ "loss": 0.8913,
507
+ "step": 710
508
+ },
509
+ {
510
+ "epoch": 0.18769551616266944,
511
+ "grad_norm": 1.214625729911582,
512
+ "learning_rate": 9.334407665091604e-05,
513
+ "loss": 0.9063,
514
+ "step": 720
515
+ },
516
+ {
517
+ "epoch": 0.1903023983315954,
518
+ "grad_norm": 1.8898319277908309,
519
+ "learning_rate": 9.353977140050108e-05,
520
+ "loss": 0.9611,
521
+ "step": 730
522
+ },
523
+ {
524
+ "epoch": 0.19290928050052136,
525
+ "grad_norm": 1.3636119152062076,
526
+ "learning_rate": 9.373280355377439e-05,
527
+ "loss": 0.9486,
528
+ "step": 740
529
+ },
530
+ {
531
+ "epoch": 0.19551616266944735,
532
+ "grad_norm": 1.5038687436039977,
533
+ "learning_rate": 9.392324459309554e-05,
534
+ "loss": 0.8918,
535
+ "step": 750
536
+ },
537
+ {
538
+ "epoch": 0.1981230448383733,
539
+ "grad_norm": 1.437881387105274,
540
+ "learning_rate": 9.411116316029599e-05,
541
+ "loss": 0.9538,
542
+ "step": 760
543
+ },
544
+ {
545
+ "epoch": 0.20072992700729927,
546
+ "grad_norm": 1.4684627474926828,
547
+ "learning_rate": 9.429662520521419e-05,
548
+ "loss": 0.9875,
549
+ "step": 770
550
+ },
551
+ {
552
+ "epoch": 0.20333680917622524,
553
+ "grad_norm": 1.2498034963556186,
554
+ "learning_rate": 9.447969412464717e-05,
555
+ "loss": 0.8688,
556
+ "step": 780
557
+ },
558
+ {
559
+ "epoch": 0.2059436913451512,
560
+ "grad_norm": 1.6662177047291735,
561
+ "learning_rate": 9.466043089245074e-05,
562
+ "loss": 0.9125,
563
+ "step": 790
564
+ },
565
+ {
566
+ "epoch": 0.20855057351407716,
567
+ "grad_norm": 1.866989275221486,
568
+ "learning_rate": 9.483889418145677e-05,
569
+ "loss": 0.9201,
570
+ "step": 800
571
+ },
572
+ {
573
+ "epoch": 0.21115745568300312,
574
+ "grad_norm": 1.3968953751850115,
575
+ "learning_rate": 9.501514047781739e-05,
576
+ "loss": 0.8627,
577
+ "step": 810
578
+ },
579
+ {
580
+ "epoch": 0.21376433785192908,
581
+ "grad_norm": 1.471933908900232,
582
+ "learning_rate": 9.518922418833347e-05,
583
+ "loss": 0.8386,
584
+ "step": 820
585
+ },
586
+ {
587
+ "epoch": 0.21637122002085507,
588
+ "grad_norm": 1.5563986530773524,
589
+ "learning_rate": 9.536119774127809e-05,
590
+ "loss": 0.9067,
591
+ "step": 830
592
+ },
593
+ {
594
+ "epoch": 0.21897810218978103,
595
+ "grad_norm": 1.3658584392037696,
596
+ "learning_rate": 9.553111168118207e-05,
597
+ "loss": 0.8931,
598
+ "step": 840
599
+ },
600
+ {
601
+ "epoch": 0.221584984358707,
602
+ "grad_norm": 1.3728098970120093,
603
+ "learning_rate": 9.569901475801053e-05,
604
+ "loss": 0.8876,
605
+ "step": 850
606
+ },
607
+ {
608
+ "epoch": 0.22419186652763295,
609
+ "grad_norm": 1.3264474456198803,
610
+ "learning_rate": 9.58649540111241e-05,
611
+ "loss": 0.908,
612
+ "step": 860
613
+ },
614
+ {
615
+ "epoch": 0.22679874869655892,
616
+ "grad_norm": 1.4306688515313286,
617
+ "learning_rate": 9.602897484838651e-05,
618
+ "loss": 0.8527,
619
+ "step": 870
620
+ },
621
+ {
622
+ "epoch": 0.22940563086548488,
623
+ "grad_norm": 1.359364809712028,
624
+ "learning_rate": 9.619112112075149e-05,
625
+ "loss": 0.8834,
626
+ "step": 880
627
+ },
628
+ {
629
+ "epoch": 0.23201251303441084,
630
+ "grad_norm": 1.6419437685113607,
631
+ "learning_rate": 9.63514351926354e-05,
632
+ "loss": 0.9578,
633
+ "step": 890
634
+ },
635
+ {
636
+ "epoch": 0.2346193952033368,
637
+ "grad_norm": 1.4939985595932985,
638
+ "learning_rate": 9.650995800835814e-05,
639
+ "loss": 0.9139,
640
+ "step": 900
641
+ },
642
+ {
643
+ "epoch": 0.23722627737226276,
644
+ "grad_norm": 1.7581353118072822,
645
+ "learning_rate": 9.66667291549132e-05,
646
+ "loss": 0.8936,
647
+ "step": 910
648
+ },
649
+ {
650
+ "epoch": 0.23983315954118875,
651
+ "grad_norm": 1.4500851564730863,
652
+ "learning_rate": 9.682178692130732e-05,
653
+ "loss": 0.8767,
654
+ "step": 920
655
+ },
656
+ {
657
+ "epoch": 0.2424400417101147,
658
+ "grad_norm": 1.7403153499682062,
659
+ "learning_rate": 9.697516835469238e-05,
660
+ "loss": 0.8915,
661
+ "step": 930
662
+ },
663
+ {
664
+ "epoch": 0.24504692387904067,
665
+ "grad_norm": 1.7325737919906712,
666
+ "learning_rate": 9.712690931349557e-05,
667
+ "loss": 0.8679,
668
+ "step": 940
669
+ },
670
+ {
671
+ "epoch": 0.24765380604796663,
672
+ "grad_norm": 1.2607566606772898,
673
+ "learning_rate": 9.72770445177381e-05,
674
+ "loss": 0.9302,
675
+ "step": 950
676
+ },
677
+ {
678
+ "epoch": 0.2502606882168926,
679
+ "grad_norm": 1.3948857503153305,
680
+ "learning_rate": 9.742560759671938e-05,
681
+ "loss": 0.9622,
682
+ "step": 960
683
+ },
684
+ {
685
+ "epoch": 0.2528675703858186,
686
+ "grad_norm": 1.4990971836866378,
687
+ "learning_rate": 9.757263113423036e-05,
688
+ "loss": 0.8862,
689
+ "step": 970
690
+ },
691
+ {
692
+ "epoch": 0.25547445255474455,
693
+ "grad_norm": 1.26002568302247,
694
+ "learning_rate": 9.771814671144811e-05,
695
+ "loss": 0.902,
696
+ "step": 980
697
+ },
698
+ {
699
+ "epoch": 0.2580813347236705,
700
+ "grad_norm": 1.6328643018778433,
701
+ "learning_rate": 9.786218494765286e-05,
702
+ "loss": 0.9177,
703
+ "step": 990
704
+ },
705
+ {
706
+ "epoch": 0.26068821689259647,
707
+ "grad_norm": 1.5208345584967045,
708
+ "learning_rate": 9.800477553889888e-05,
709
+ "loss": 0.9209,
710
+ "step": 1000
711
+ },
712
+ {
713
+ "epoch": 0.26329509906152243,
714
+ "grad_norm": 1.7155524494692724,
715
+ "learning_rate": 9.814594729476141e-05,
716
+ "loss": 0.9237,
717
+ "step": 1010
718
+ },
719
+ {
720
+ "epoch": 0.2659019812304484,
721
+ "grad_norm": 1.2913660127117599,
722
+ "learning_rate": 9.828572817327313e-05,
723
+ "loss": 0.9243,
724
+ "step": 1020
725
+ },
726
+ {
727
+ "epoch": 0.26850886339937435,
728
+ "grad_norm": 1.7535505034210201,
729
+ "learning_rate": 9.84241453141565e-05,
730
+ "loss": 0.8931,
731
+ "step": 1030
732
+ },
733
+ {
734
+ "epoch": 0.2711157455683003,
735
+ "grad_norm": 1.2898088323947252,
736
+ "learning_rate": 9.856122507045051e-05,
737
+ "loss": 0.8526,
738
+ "step": 1040
739
+ },
740
+ {
741
+ "epoch": 0.2737226277372263,
742
+ "grad_norm": 1.463455335110262,
743
+ "learning_rate": 9.869699303862418e-05,
744
+ "loss": 0.8793,
745
+ "step": 1050
746
+ },
747
+ {
748
+ "epoch": 0.27632950990615224,
749
+ "grad_norm": 1.3899833101623003,
750
+ "learning_rate": 9.88314740872627e-05,
751
+ "loss": 0.9302,
752
+ "step": 1060
753
+ },
754
+ {
755
+ "epoch": 0.2789363920750782,
756
+ "grad_norm": 1.5658975524017984,
757
+ "learning_rate": 9.896469238440684e-05,
758
+ "loss": 0.9169,
759
+ "step": 1070
760
+ },
761
+ {
762
+ "epoch": 0.28154327424400416,
763
+ "grad_norm": 1.3907147804328621,
764
+ "learning_rate": 9.909667142362075e-05,
765
+ "loss": 0.9001,
766
+ "step": 1080
767
+ },
768
+ {
769
+ "epoch": 0.2841501564129301,
770
+ "grad_norm": 1.6141986396288779,
771
+ "learning_rate": 9.922743404885818e-05,
772
+ "loss": 0.8768,
773
+ "step": 1090
774
+ },
775
+ {
776
+ "epoch": 0.2867570385818561,
777
+ "grad_norm": 1.3427468296126188,
778
+ "learning_rate": 9.935700247819361e-05,
779
+ "loss": 0.8774,
780
+ "step": 1100
781
+ },
782
+ {
783
+ "epoch": 0.28936392075078204,
784
+ "grad_norm": 1.466877011233847,
785
+ "learning_rate": 9.94853983264791e-05,
786
+ "loss": 0.8975,
787
+ "step": 1110
788
+ },
789
+ {
790
+ "epoch": 0.291970802919708,
791
+ "grad_norm": 1.5146408692829303,
792
+ "learning_rate": 9.961264262698542e-05,
793
+ "loss": 0.9306,
794
+ "step": 1120
795
+ },
796
+ {
797
+ "epoch": 0.29457768508863397,
798
+ "grad_norm": 1.267673391297586,
799
+ "learning_rate": 9.97387558520811e-05,
800
+ "loss": 0.9058,
801
+ "step": 1130
802
+ },
803
+ {
804
+ "epoch": 0.29718456725756,
805
+ "grad_norm": 1.4730762854067057,
806
+ "learning_rate": 9.98637579330007e-05,
807
+ "loss": 0.9042,
808
+ "step": 1140
809
+ },
810
+ {
811
+ "epoch": 0.29979144942648595,
812
+ "grad_norm": 1.3202056072894564,
813
+ "learning_rate": 9.998766827874944e-05,
814
+ "loss": 0.9109,
815
+ "step": 1150
816
+ },
817
+ {
818
+ "epoch": 0.3023983315954119,
819
+ "grad_norm": 1.7165734727653075,
820
+ "learning_rate": 9.992275755527663e-05,
821
+ "loss": 0.9557,
822
+ "step": 1160
823
+ },
824
+ {
825
+ "epoch": 0.30500521376433787,
826
+ "grad_norm": 1.4663092625643357,
827
+ "learning_rate": 9.982620449937241e-05,
828
+ "loss": 0.9291,
829
+ "step": 1170
830
+ },
831
+ {
832
+ "epoch": 0.30761209593326383,
833
+ "grad_norm": 1.4879041927617032,
834
+ "learning_rate": 9.972965144346819e-05,
835
+ "loss": 0.9282,
836
+ "step": 1180
837
+ },
838
+ {
839
+ "epoch": 0.3102189781021898,
840
+ "grad_norm": 1.246157859500466,
841
+ "learning_rate": 9.963309838756398e-05,
842
+ "loss": 0.8993,
843
+ "step": 1190
844
+ },
845
+ {
846
+ "epoch": 0.31282586027111575,
847
+ "grad_norm": 1.5069087106646166,
848
+ "learning_rate": 9.953654533165974e-05,
849
+ "loss": 0.8619,
850
+ "step": 1200
851
+ },
852
+ {
853
+ "epoch": 0.3154327424400417,
854
+ "grad_norm": 1.6313981760455594,
855
+ "learning_rate": 9.943999227575553e-05,
856
+ "loss": 0.9107,
857
+ "step": 1210
858
+ },
859
+ {
860
+ "epoch": 0.3180396246089677,
861
+ "grad_norm": 1.7942805182458694,
862
+ "learning_rate": 9.934343921985131e-05,
863
+ "loss": 0.8675,
864
+ "step": 1220
865
+ },
866
+ {
867
+ "epoch": 0.32064650677789364,
868
+ "grad_norm": 1.8369591575858806,
869
+ "learning_rate": 9.924688616394709e-05,
870
+ "loss": 0.9358,
871
+ "step": 1230
872
+ },
873
+ {
874
+ "epoch": 0.3232533889468196,
875
+ "grad_norm": 1.7610189048584648,
876
+ "learning_rate": 9.915033310804287e-05,
877
+ "loss": 0.8879,
878
+ "step": 1240
879
+ },
880
+ {
881
+ "epoch": 0.32586027111574556,
882
+ "grad_norm": 1.1839900127231098,
883
+ "learning_rate": 9.905378005213866e-05,
884
+ "loss": 0.8603,
885
+ "step": 1250
886
+ },
887
+ {
888
+ "epoch": 0.3284671532846715,
889
+ "grad_norm": 1.3882705515733773,
890
+ "learning_rate": 9.895722699623443e-05,
891
+ "loss": 0.892,
892
+ "step": 1260
893
+ },
894
+ {
895
+ "epoch": 0.3310740354535975,
896
+ "grad_norm": 1.327576256659297,
897
+ "learning_rate": 9.886067394033022e-05,
898
+ "loss": 0.9003,
899
+ "step": 1270
900
+ },
901
+ {
902
+ "epoch": 0.33368091762252344,
903
+ "grad_norm": 1.8987128563646904,
904
+ "learning_rate": 9.8764120884426e-05,
905
+ "loss": 0.8824,
906
+ "step": 1280
907
+ },
908
+ {
909
+ "epoch": 0.3362877997914494,
910
+ "grad_norm": 1.3623197435419394,
911
+ "learning_rate": 9.866756782852177e-05,
912
+ "loss": 0.8985,
913
+ "step": 1290
914
+ },
915
+ {
916
+ "epoch": 0.33889468196037537,
917
+ "grad_norm": 1.5687193453586346,
918
+ "learning_rate": 9.857101477261755e-05,
919
+ "loss": 0.9256,
920
+ "step": 1300
921
+ },
922
+ {
923
+ "epoch": 0.3415015641293014,
924
+ "grad_norm": 1.7026203127602761,
925
+ "learning_rate": 9.847446171671334e-05,
926
+ "loss": 0.892,
927
+ "step": 1310
928
+ },
929
+ {
930
+ "epoch": 0.34410844629822734,
931
+ "grad_norm": 1.452492802061833,
932
+ "learning_rate": 9.837790866080911e-05,
933
+ "loss": 0.9324,
934
+ "step": 1320
935
+ },
936
+ {
937
+ "epoch": 0.3467153284671533,
938
+ "grad_norm": 1.3446352406962594,
939
+ "learning_rate": 9.82813556049049e-05,
940
+ "loss": 0.9037,
941
+ "step": 1330
942
+ },
943
+ {
944
+ "epoch": 0.34932221063607927,
945
+ "grad_norm": 1.5312444025461112,
946
+ "learning_rate": 9.818480254900068e-05,
947
+ "loss": 0.8823,
948
+ "step": 1340
949
+ },
950
+ {
951
+ "epoch": 0.35192909280500523,
952
+ "grad_norm": 1.2547101152696145,
953
+ "learning_rate": 9.808824949309646e-05,
954
+ "loss": 0.8986,
955
+ "step": 1350
956
+ },
957
+ {
958
+ "epoch": 0.3545359749739312,
959
+ "grad_norm": 1.7576893497240795,
960
+ "learning_rate": 9.799169643719224e-05,
961
+ "loss": 0.8729,
962
+ "step": 1360
963
+ },
964
+ {
965
+ "epoch": 0.35714285714285715,
966
+ "grad_norm": 1.2979110987807732,
967
+ "learning_rate": 9.789514338128803e-05,
968
+ "loss": 0.8368,
969
+ "step": 1370
970
+ },
971
+ {
972
+ "epoch": 0.3597497393117831,
973
+ "grad_norm": 1.3445976041661503,
974
+ "learning_rate": 9.77985903253838e-05,
975
+ "loss": 0.9255,
976
+ "step": 1380
977
+ },
978
+ {
979
+ "epoch": 0.3623566214807091,
980
+ "grad_norm": 1.5914212414708893,
981
+ "learning_rate": 9.770203726947958e-05,
982
+ "loss": 0.868,
983
+ "step": 1390
984
+ },
985
+ {
986
+ "epoch": 0.36496350364963503,
987
+ "grad_norm": 1.6920255872918506,
988
+ "learning_rate": 9.760548421357536e-05,
989
+ "loss": 0.9099,
990
+ "step": 1400
991
+ },
992
+ {
993
+ "epoch": 0.367570385818561,
994
+ "grad_norm": 1.5488187265112325,
995
+ "learning_rate": 9.750893115767114e-05,
996
+ "loss": 0.8716,
997
+ "step": 1410
998
+ },
999
+ {
1000
+ "epoch": 0.37017726798748696,
1001
+ "grad_norm": 1.451972780765123,
1002
+ "learning_rate": 9.741237810176692e-05,
1003
+ "loss": 0.8561,
1004
+ "step": 1420
1005
+ },
1006
+ {
1007
+ "epoch": 0.3727841501564129,
1008
+ "grad_norm": 1.295850263704956,
1009
+ "learning_rate": 9.731582504586271e-05,
1010
+ "loss": 0.9015,
1011
+ "step": 1430
1012
+ },
1013
+ {
1014
+ "epoch": 0.3753910323253389,
1015
+ "grad_norm": 1.5842277075718598,
1016
+ "learning_rate": 9.721927198995849e-05,
1017
+ "loss": 0.9298,
1018
+ "step": 1440
1019
+ },
1020
+ {
1021
+ "epoch": 0.37799791449426484,
1022
+ "grad_norm": 1.3596224626112259,
1023
+ "learning_rate": 9.712271893405427e-05,
1024
+ "loss": 0.8806,
1025
+ "step": 1450
1026
+ },
1027
+ {
1028
+ "epoch": 0.3806047966631908,
1029
+ "grad_norm": 1.615036427471816,
1030
+ "learning_rate": 9.702616587815004e-05,
1031
+ "loss": 0.8381,
1032
+ "step": 1460
1033
+ },
1034
+ {
1035
+ "epoch": 0.38321167883211676,
1036
+ "grad_norm": 1.3877699271760322,
1037
+ "learning_rate": 9.692961282224584e-05,
1038
+ "loss": 0.8688,
1039
+ "step": 1470
1040
+ },
1041
+ {
1042
+ "epoch": 0.3858185610010427,
1043
+ "grad_norm": 1.4359747663434173,
1044
+ "learning_rate": 9.68330597663416e-05,
1045
+ "loss": 0.8943,
1046
+ "step": 1480
1047
+ },
1048
+ {
1049
+ "epoch": 0.38842544316996874,
1050
+ "grad_norm": 1.4881531927353704,
1051
+ "learning_rate": 9.673650671043739e-05,
1052
+ "loss": 0.906,
1053
+ "step": 1490
1054
+ },
1055
+ {
1056
+ "epoch": 0.3910323253388947,
1057
+ "grad_norm": 1.4488364078976648,
1058
+ "learning_rate": 9.663995365453317e-05,
1059
+ "loss": 0.8626,
1060
+ "step": 1500
1061
+ },
1062
+ {
1063
+ "epoch": 0.39363920750782067,
1064
+ "grad_norm": 1.4207762959482324,
1065
+ "learning_rate": 9.654340059862895e-05,
1066
+ "loss": 0.8339,
1067
+ "step": 1510
1068
+ },
1069
+ {
1070
+ "epoch": 0.3962460896767466,
1071
+ "grad_norm": 1.2660341079423447,
1072
+ "learning_rate": 9.644684754272473e-05,
1073
+ "loss": 0.9113,
1074
+ "step": 1520
1075
+ },
1076
+ {
1077
+ "epoch": 0.3988529718456726,
1078
+ "grad_norm": 1.277561759581565,
1079
+ "learning_rate": 9.635029448682052e-05,
1080
+ "loss": 0.9101,
1081
+ "step": 1530
1082
+ },
1083
+ {
1084
+ "epoch": 0.40145985401459855,
1085
+ "grad_norm": 1.3307684337403334,
1086
+ "learning_rate": 9.625374143091628e-05,
1087
+ "loss": 0.9213,
1088
+ "step": 1540
1089
+ },
1090
+ {
1091
+ "epoch": 0.4040667361835245,
1092
+ "grad_norm": 1.415345659530655,
1093
+ "learning_rate": 9.615718837501208e-05,
1094
+ "loss": 0.858,
1095
+ "step": 1550
1096
+ },
1097
+ {
1098
+ "epoch": 0.40667361835245047,
1099
+ "grad_norm": 1.7317695266528055,
1100
+ "learning_rate": 9.606063531910785e-05,
1101
+ "loss": 0.8247,
1102
+ "step": 1560
1103
+ },
1104
+ {
1105
+ "epoch": 0.40928050052137643,
1106
+ "grad_norm": 1.3841397564289928,
1107
+ "learning_rate": 9.596408226320363e-05,
1108
+ "loss": 0.9004,
1109
+ "step": 1570
1110
+ },
1111
+ {
1112
+ "epoch": 0.4118873826903024,
1113
+ "grad_norm": 1.6542817351437331,
1114
+ "learning_rate": 9.586752920729941e-05,
1115
+ "loss": 0.8688,
1116
+ "step": 1580
1117
+ },
1118
+ {
1119
+ "epoch": 0.41449426485922836,
1120
+ "grad_norm": 1.1741335364390655,
1121
+ "learning_rate": 9.57709761513952e-05,
1122
+ "loss": 0.8711,
1123
+ "step": 1590
1124
+ },
1125
+ {
1126
+ "epoch": 0.4171011470281543,
1127
+ "grad_norm": 1.6436036502277707,
1128
+ "learning_rate": 9.567442309549097e-05,
1129
+ "loss": 0.843,
1130
+ "step": 1600
1131
+ },
1132
+ {
1133
+ "epoch": 0.4197080291970803,
1134
+ "grad_norm": 1.5352723465358284,
1135
+ "learning_rate": 9.557787003958676e-05,
1136
+ "loss": 0.908,
1137
+ "step": 1610
1138
+ },
1139
+ {
1140
+ "epoch": 0.42231491136600624,
1141
+ "grad_norm": 1.5272500363549157,
1142
+ "learning_rate": 9.548131698368254e-05,
1143
+ "loss": 0.8234,
1144
+ "step": 1620
1145
+ },
1146
+ {
1147
+ "epoch": 0.4249217935349322,
1148
+ "grad_norm": 1.2675860878774323,
1149
+ "learning_rate": 9.538476392777832e-05,
1150
+ "loss": 0.8992,
1151
+ "step": 1630
1152
+ },
1153
+ {
1154
+ "epoch": 0.42752867570385816,
1155
+ "grad_norm": 1.2425270593669835,
1156
+ "learning_rate": 9.52882108718741e-05,
1157
+ "loss": 0.8693,
1158
+ "step": 1640
1159
+ },
1160
+ {
1161
+ "epoch": 0.4301355578727841,
1162
+ "grad_norm": 1.570064901663505,
1163
+ "learning_rate": 9.519165781596989e-05,
1164
+ "loss": 0.8652,
1165
+ "step": 1650
1166
+ },
1167
+ {
1168
+ "epoch": 0.43274244004171014,
1169
+ "grad_norm": 1.3621769054786714,
1170
+ "learning_rate": 9.509510476006565e-05,
1171
+ "loss": 0.8596,
1172
+ "step": 1660
1173
+ },
1174
+ {
1175
+ "epoch": 0.4353493222106361,
1176
+ "grad_norm": 1.4560708789685335,
1177
+ "learning_rate": 9.499855170416144e-05,
1178
+ "loss": 0.8062,
1179
+ "step": 1670
1180
+ },
1181
+ {
1182
+ "epoch": 0.43795620437956206,
1183
+ "grad_norm": 1.315052892176818,
1184
+ "learning_rate": 9.490199864825722e-05,
1185
+ "loss": 0.8548,
1186
+ "step": 1680
1187
+ },
1188
+ {
1189
+ "epoch": 0.440563086548488,
1190
+ "grad_norm": 1.3293319921282323,
1191
+ "learning_rate": 9.4805445592353e-05,
1192
+ "loss": 0.9029,
1193
+ "step": 1690
1194
+ },
1195
+ {
1196
+ "epoch": 0.443169968717414,
1197
+ "grad_norm": 1.6758016698805198,
1198
+ "learning_rate": 9.470889253644878e-05,
1199
+ "loss": 0.8288,
1200
+ "step": 1700
1201
+ },
1202
+ {
1203
+ "epoch": 0.44577685088633995,
1204
+ "grad_norm": 1.4994197671525644,
1205
+ "learning_rate": 9.461233948054457e-05,
1206
+ "loss": 0.8813,
1207
+ "step": 1710
1208
+ },
1209
+ {
1210
+ "epoch": 0.4483837330552659,
1211
+ "grad_norm": 1.4043994377616684,
1212
+ "learning_rate": 9.451578642464035e-05,
1213
+ "loss": 0.8745,
1214
+ "step": 1720
1215
+ },
1216
+ {
1217
+ "epoch": 0.45099061522419187,
1218
+ "grad_norm": 1.3750450980048579,
1219
+ "learning_rate": 9.441923336873612e-05,
1220
+ "loss": 0.9459,
1221
+ "step": 1730
1222
+ },
1223
+ {
1224
+ "epoch": 0.45359749739311783,
1225
+ "grad_norm": 1.7045501519636879,
1226
+ "learning_rate": 9.43226803128319e-05,
1227
+ "loss": 0.8674,
1228
+ "step": 1740
1229
+ },
1230
+ {
1231
+ "epoch": 0.4562043795620438,
1232
+ "grad_norm": 1.6497345479066228,
1233
+ "learning_rate": 9.422612725692768e-05,
1234
+ "loss": 0.8646,
1235
+ "step": 1750
1236
+ },
1237
+ {
1238
+ "epoch": 0.45881126173096975,
1239
+ "grad_norm": 1.5931163752198003,
1240
+ "learning_rate": 9.412957420102346e-05,
1241
+ "loss": 0.8455,
1242
+ "step": 1760
1243
+ },
1244
+ {
1245
+ "epoch": 0.4614181438998957,
1246
+ "grad_norm": 1.7230724221709457,
1247
+ "learning_rate": 9.403302114511925e-05,
1248
+ "loss": 0.9131,
1249
+ "step": 1770
1250
+ },
1251
+ {
1252
+ "epoch": 0.4640250260688217,
1253
+ "grad_norm": 1.46180495132515,
1254
+ "learning_rate": 9.393646808921503e-05,
1255
+ "loss": 0.8871,
1256
+ "step": 1780
1257
+ },
1258
+ {
1259
+ "epoch": 0.46663190823774764,
1260
+ "grad_norm": 1.5935162065821926,
1261
+ "learning_rate": 9.383991503331081e-05,
1262
+ "loss": 0.8675,
1263
+ "step": 1790
1264
+ },
1265
+ {
1266
+ "epoch": 0.4692387904066736,
1267
+ "grad_norm": 1.1992013716756416,
1268
+ "learning_rate": 9.374336197740659e-05,
1269
+ "loss": 0.8699,
1270
+ "step": 1800
1271
+ },
1272
+ {
1273
+ "epoch": 0.47184567257559956,
1274
+ "grad_norm": 1.2641218432215904,
1275
+ "learning_rate": 9.364680892150238e-05,
1276
+ "loss": 0.8158,
1277
+ "step": 1810
1278
+ },
1279
+ {
1280
+ "epoch": 0.4744525547445255,
1281
+ "grad_norm": 1.2473362593090205,
1282
+ "learning_rate": 9.355025586559814e-05,
1283
+ "loss": 0.888,
1284
+ "step": 1820
1285
+ },
1286
+ {
1287
+ "epoch": 0.4770594369134515,
1288
+ "grad_norm": 1.464832534464096,
1289
+ "learning_rate": 9.345370280969393e-05,
1290
+ "loss": 0.86,
1291
+ "step": 1830
1292
+ },
1293
+ {
1294
+ "epoch": 0.4796663190823775,
1295
+ "grad_norm": 1.4843223334337357,
1296
+ "learning_rate": 9.335714975378971e-05,
1297
+ "loss": 0.8826,
1298
+ "step": 1840
1299
+ },
1300
+ {
1301
+ "epoch": 0.48227320125130346,
1302
+ "grad_norm": 1.4314799678240455,
1303
+ "learning_rate": 9.326059669788549e-05,
1304
+ "loss": 0.9123,
1305
+ "step": 1850
1306
+ },
1307
+ {
1308
+ "epoch": 0.4848800834202294,
1309
+ "grad_norm": 1.5671717582839904,
1310
+ "learning_rate": 9.316404364198127e-05,
1311
+ "loss": 0.8619,
1312
+ "step": 1860
1313
+ },
1314
+ {
1315
+ "epoch": 0.4874869655891554,
1316
+ "grad_norm": 1.5285351609841458,
1317
+ "learning_rate": 9.306749058607706e-05,
1318
+ "loss": 0.8608,
1319
+ "step": 1870
1320
+ },
1321
+ {
1322
+ "epoch": 0.49009384775808135,
1323
+ "grad_norm": 1.4572720749431034,
1324
+ "learning_rate": 9.297093753017283e-05,
1325
+ "loss": 0.8562,
1326
+ "step": 1880
1327
+ },
1328
+ {
1329
+ "epoch": 0.4927007299270073,
1330
+ "grad_norm": 1.3144129556287165,
1331
+ "learning_rate": 9.287438447426862e-05,
1332
+ "loss": 0.8674,
1333
+ "step": 1890
1334
+ },
1335
+ {
1336
+ "epoch": 0.49530761209593327,
1337
+ "grad_norm": 1.765323561126351,
1338
+ "learning_rate": 9.27778314183644e-05,
1339
+ "loss": 0.8338,
1340
+ "step": 1900
1341
+ },
1342
+ {
1343
+ "epoch": 0.49791449426485923,
1344
+ "grad_norm": 1.440502764478305,
1345
+ "learning_rate": 9.268127836246017e-05,
1346
+ "loss": 0.8791,
1347
+ "step": 1910
1348
+ },
1349
+ {
1350
+ "epoch": 0.5005213764337852,
1351
+ "grad_norm": 1.5684279942469967,
1352
+ "learning_rate": 9.258472530655595e-05,
1353
+ "loss": 0.8177,
1354
+ "step": 1920
1355
+ },
1356
+ {
1357
+ "epoch": 0.5031282586027112,
1358
+ "grad_norm": 1.310102072350701,
1359
+ "learning_rate": 9.248817225065174e-05,
1360
+ "loss": 0.8493,
1361
+ "step": 1930
1362
+ },
1363
+ {
1364
+ "epoch": 0.5057351407716372,
1365
+ "grad_norm": 1.5214634407076848,
1366
+ "learning_rate": 9.239161919474751e-05,
1367
+ "loss": 0.8537,
1368
+ "step": 1940
1369
+ },
1370
+ {
1371
+ "epoch": 0.5083420229405631,
1372
+ "grad_norm": 1.5587847023414687,
1373
+ "learning_rate": 9.22950661388433e-05,
1374
+ "loss": 0.9156,
1375
+ "step": 1950
1376
+ },
1377
+ {
1378
+ "epoch": 0.5109489051094891,
1379
+ "grad_norm": 1.388133145041633,
1380
+ "learning_rate": 9.219851308293908e-05,
1381
+ "loss": 0.8231,
1382
+ "step": 1960
1383
+ },
1384
+ {
1385
+ "epoch": 0.513555787278415,
1386
+ "grad_norm": 1.5926213586780094,
1387
+ "learning_rate": 9.210196002703486e-05,
1388
+ "loss": 0.8427,
1389
+ "step": 1970
1390
+ },
1391
+ {
1392
+ "epoch": 0.516162669447341,
1393
+ "grad_norm": 1.3201354229543043,
1394
+ "learning_rate": 9.200540697113063e-05,
1395
+ "loss": 0.8208,
1396
+ "step": 1980
1397
+ },
1398
+ {
1399
+ "epoch": 0.5187695516162669,
1400
+ "grad_norm": 1.393366393240565,
1401
+ "learning_rate": 9.190885391522643e-05,
1402
+ "loss": 0.8929,
1403
+ "step": 1990
1404
+ },
1405
+ {
1406
+ "epoch": 0.5213764337851929,
1407
+ "grad_norm": 1.362764482222623,
1408
+ "learning_rate": 9.18123008593222e-05,
1409
+ "loss": 0.8929,
1410
+ "step": 2000
1411
+ }
1412
+ ],
1413
+ "logging_steps": 10,
1414
+ "max_steps": 11508,
1415
+ "num_input_tokens_seen": 0,
1416
+ "num_train_epochs": 3,
1417
+ "save_steps": 1000,
1418
+ "stateful_callbacks": {
1419
+ "TrainerControl": {
1420
+ "args": {
1421
+ "should_epoch_stop": false,
1422
+ "should_evaluate": false,
1423
+ "should_log": false,
1424
+ "should_save": true,
1425
+ "should_training_stop": false
1426
+ },
1427
+ "attributes": {}
1428
+ }
1429
+ },
1430
+ "total_flos": 0.0,
1431
+ "train_batch_size": 16,
1432
+ "trial_name": null,
1433
+ "trial_params": null
1434
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a226f6c1a516d7f4d2c2f86a40c3dfb06f1dfbfa39d092d3b825fb40fe7fa84f
3
+ size 8401
zero_to_fp32.py ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import json
25
+ from tqdm import tqdm
26
+ from collections import OrderedDict
27
+ from dataclasses import dataclass
28
+
29
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
30
+ # DeepSpeed data structures it has to be available in the current python environment.
31
+ from deepspeed.utils import logger
32
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
33
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
34
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
35
+
36
+
37
+ @dataclass
38
+ class zero_model_state:
39
+ buffers: dict()
40
+ param_shapes: dict()
41
+ shared_params: list
42
+ ds_version: int
43
+ frozen_param_shapes: dict()
44
+ frozen_param_fragments: dict()
45
+
46
+
47
+ debug = 0
48
+
49
+ # load to cpu
50
+ device = torch.device('cpu')
51
+
52
+
53
+ def atoi(text):
54
+ return int(text) if text.isdigit() else text
55
+
56
+
57
+ def natural_keys(text):
58
+ '''
59
+ alist.sort(key=natural_keys) sorts in human order
60
+ http://nedbatchelder.com/blog/200712/human_sorting.html
61
+ (See Toothy's implementation in the comments)
62
+ '''
63
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
64
+
65
+
66
+ def get_model_state_file(checkpoint_dir, zero_stage):
67
+ if not os.path.isdir(checkpoint_dir):
68
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
69
+
70
+ # there should be only one file
71
+ if zero_stage <= 2:
72
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
73
+ elif zero_stage == 3:
74
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
75
+
76
+ if not os.path.exists(file):
77
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
78
+
79
+ return file
80
+
81
+
82
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
83
+ # XXX: need to test that this simple glob rule works for multi-node setup too
84
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
85
+
86
+ if len(ckpt_files) == 0:
87
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
88
+
89
+ return ckpt_files
90
+
91
+
92
+ def get_optim_files(checkpoint_dir):
93
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
94
+
95
+
96
+ def get_model_state_files(checkpoint_dir):
97
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
98
+
99
+
100
+ def parse_model_states(files):
101
+ zero_model_states = []
102
+ for file in files:
103
+ state_dict = torch.load(file, map_location=device)
104
+
105
+ if BUFFER_NAMES not in state_dict:
106
+ raise ValueError(f"{file} is not a model state checkpoint")
107
+ buffer_names = state_dict[BUFFER_NAMES]
108
+ if debug:
109
+ print("Found buffers:", buffer_names)
110
+
111
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
112
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
113
+ param_shapes = state_dict[PARAM_SHAPES]
114
+
115
+ # collect parameters that are included in param_shapes
116
+ param_names = []
117
+ for s in param_shapes:
118
+ for name in s.keys():
119
+ param_names.append(name)
120
+
121
+ # update with frozen parameters
122
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
123
+ if frozen_param_shapes is not None:
124
+ if debug:
125
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
126
+ param_names += list(frozen_param_shapes.keys())
127
+
128
+ # handle shared params
129
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
130
+
131
+ ds_version = state_dict.get(DS_VERSION, None)
132
+
133
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
134
+
135
+ z_model_state = zero_model_state(buffers=buffers,
136
+ param_shapes=param_shapes,
137
+ shared_params=shared_params,
138
+ ds_version=ds_version,
139
+ frozen_param_shapes=frozen_param_shapes,
140
+ frozen_param_fragments=frozen_param_fragments)
141
+ zero_model_states.append(z_model_state)
142
+
143
+ return zero_model_states
144
+
145
+
146
+ def parse_optim_states(files, ds_checkpoint_dir):
147
+ total_files = len(files)
148
+ state_dicts = []
149
+ for f in files:
150
+ state_dict = torch.load(f, map_location=device)
151
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
152
+ # and also handle the case where it was already removed by another helper script
153
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
154
+ state_dicts.append(state_dict)
155
+
156
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
157
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
158
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
159
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
160
+
161
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
162
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
163
+ # use the max of the partition_count to get the dp world_size.
164
+
165
+ if type(world_size) is list:
166
+ world_size = max(world_size)
167
+
168
+ if world_size != total_files:
169
+ raise ValueError(
170
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
171
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
172
+ )
173
+
174
+ # the groups are named differently in each stage
175
+ if zero_stage <= 2:
176
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
177
+ elif zero_stage == 3:
178
+ fp32_groups_key = FP32_FLAT_GROUPS
179
+ else:
180
+ raise ValueError(f"unknown zero stage {zero_stage}")
181
+
182
+ if zero_stage <= 2:
183
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
184
+ elif zero_stage == 3:
185
+ # if there is more than one param group, there will be multiple flattened tensors - one
186
+ # flattened tensor per group - for simplicity merge them into a single tensor
187
+ #
188
+ # XXX: could make the script more memory efficient for when there are multiple groups - it
189
+ # will require matching the sub-lists of param_shapes for each param group flattened tensor
190
+
191
+ fp32_flat_groups = [
192
+ torch.cat(state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key], 0) for i in range(len(state_dicts))
193
+ ]
194
+
195
+ return zero_stage, world_size, fp32_flat_groups
196
+
197
+
198
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
199
+ """
200
+ Returns fp32 state_dict reconstructed from ds checkpoint
201
+
202
+ Args:
203
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
204
+
205
+ """
206
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
207
+
208
+ optim_files = get_optim_files(ds_checkpoint_dir)
209
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
210
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
211
+
212
+ model_files = get_model_state_files(ds_checkpoint_dir)
213
+
214
+ zero_model_states = parse_model_states(model_files)
215
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
216
+
217
+ if zero_stage <= 2:
218
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
219
+ exclude_frozen_parameters)
220
+ elif zero_stage == 3:
221
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
222
+ exclude_frozen_parameters)
223
+
224
+
225
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
226
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
227
+ return
228
+
229
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
230
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
231
+
232
+ if debug:
233
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
234
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
235
+
236
+ wanted_params = len(frozen_param_shapes)
237
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
238
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
239
+ print(f'Frozen params: Have {avail_numel} numels to process.')
240
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
241
+
242
+ total_params = 0
243
+ total_numel = 0
244
+ for name, shape in frozen_param_shapes.items():
245
+ total_params += 1
246
+ unpartitioned_numel = shape.numel()
247
+ total_numel += unpartitioned_numel
248
+
249
+ state_dict[name] = frozen_param_fragments[name]
250
+
251
+ if debug:
252
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
253
+
254
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
255
+
256
+
257
+ def _has_callable(obj, fn):
258
+ attr = getattr(obj, fn, None)
259
+ return callable(attr)
260
+
261
+
262
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
263
+ param_shapes = zero_model_states[0].param_shapes
264
+
265
+ # Reconstruction protocol:
266
+ #
267
+ # XXX: document this
268
+
269
+ if debug:
270
+ for i in range(world_size):
271
+ for j in range(len(fp32_flat_groups[0])):
272
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
273
+
274
+ # XXX: memory usage doubles here (zero2)
275
+ num_param_groups = len(fp32_flat_groups[0])
276
+ merged_single_partition_of_fp32_groups = []
277
+ for i in range(num_param_groups):
278
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
279
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
280
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
281
+ avail_numel = sum(
282
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
283
+
284
+ if debug:
285
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
286
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
287
+ # not asserting if there is a mismatch due to possible padding
288
+ print(f"Have {avail_numel} numels to process.")
289
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
290
+
291
+ # params
292
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
293
+ # out-of-core computing solution
294
+ total_numel = 0
295
+ total_params = 0
296
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
297
+ offset = 0
298
+ avail_numel = full_single_fp32_vector.numel()
299
+ for name, shape in shapes.items():
300
+
301
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
302
+ total_numel += unpartitioned_numel
303
+ total_params += 1
304
+
305
+ if debug:
306
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
307
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
308
+ offset += unpartitioned_numel
309
+
310
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
311
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
312
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
313
+ # live optimizer object, so we are checking that the numbers are within the right range
314
+ align_to = 2 * world_size
315
+
316
+ def zero2_align(x):
317
+ return align_to * math.ceil(x / align_to)
318
+
319
+ if debug:
320
+ print(f"original offset={offset}, avail_numel={avail_numel}")
321
+
322
+ offset = zero2_align(offset)
323
+ avail_numel = zero2_align(avail_numel)
324
+
325
+ if debug:
326
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
327
+
328
+ # Sanity check
329
+ if offset != avail_numel:
330
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
331
+
332
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
333
+
334
+
335
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
336
+ exclude_frozen_parameters):
337
+ state_dict = OrderedDict()
338
+
339
+ # buffers
340
+ buffers = zero_model_states[0].buffers
341
+ state_dict.update(buffers)
342
+ if debug:
343
+ print(f"added {len(buffers)} buffers")
344
+
345
+ if not exclude_frozen_parameters:
346
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
347
+
348
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
349
+
350
+ # recover shared parameters
351
+ for pair in zero_model_states[0].shared_params:
352
+ if pair[1] in state_dict:
353
+ state_dict[pair[0]] = state_dict[pair[1]]
354
+
355
+ return state_dict
356
+
357
+
358
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
359
+ remainder = unpartitioned_numel % world_size
360
+ padding_numel = (world_size - remainder) if remainder else 0
361
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
362
+ return partitioned_numel, padding_numel
363
+
364
+
365
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
366
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
367
+ return
368
+
369
+ if debug:
370
+ for i in range(world_size):
371
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
372
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
373
+
374
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
375
+ wanted_params = len(frozen_param_shapes)
376
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
377
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
378
+ print(f'Frozen params: Have {avail_numel} numels to process.')
379
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
380
+
381
+ total_params = 0
382
+ total_numel = 0
383
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
384
+ total_params += 1
385
+ unpartitioned_numel = shape.numel()
386
+ total_numel += unpartitioned_numel
387
+
388
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
389
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
390
+
391
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
392
+
393
+ if debug:
394
+ print(
395
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
396
+ )
397
+
398
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
399
+
400
+
401
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
402
+ param_shapes = zero_model_states[0].param_shapes
403
+ avail_numel = fp32_flat_groups[0].numel() * world_size
404
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
405
+ # param, re-consolidating each param, while dealing with padding if any
406
+
407
+ # merge list of dicts, preserving order
408
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
409
+
410
+ if debug:
411
+ for i in range(world_size):
412
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
413
+
414
+ wanted_params = len(param_shapes)
415
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
416
+ # not asserting if there is a mismatch due to possible padding
417
+ avail_numel = fp32_flat_groups[0].numel() * world_size
418
+ print(f"Trainable params: Have {avail_numel} numels to process.")
419
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
420
+
421
+ # params
422
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
423
+ # out-of-core computing solution
424
+ offset = 0
425
+ total_numel = 0
426
+ total_params = 0
427
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering Sharded Weights'):
428
+ unpartitioned_numel = shape.numel()
429
+ total_numel += unpartitioned_numel
430
+ total_params += 1
431
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
432
+
433
+ if debug:
434
+ print(
435
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
436
+ )
437
+
438
+ # XXX: memory usage doubles here
439
+ state_dict[name] = torch.cat(
440
+ tuple(fp32_flat_groups[i].narrow(0, offset, partitioned_numel) for i in range(world_size)),
441
+ 0).narrow(0, 0, unpartitioned_numel).view(shape)
442
+ offset += partitioned_numel
443
+
444
+ offset *= world_size
445
+
446
+ # Sanity check
447
+ if offset != avail_numel:
448
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
449
+
450
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
451
+
452
+
453
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
454
+ exclude_frozen_parameters):
455
+ state_dict = OrderedDict()
456
+
457
+ # buffers
458
+ buffers = zero_model_states[0].buffers
459
+ state_dict.update(buffers)
460
+ if debug:
461
+ print(f"added {len(buffers)} buffers")
462
+
463
+ if not exclude_frozen_parameters:
464
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
465
+
466
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
467
+
468
+ # recover shared parameters
469
+ for pair in zero_model_states[0].shared_params:
470
+ if pair[1] in state_dict:
471
+ state_dict[pair[0]] = state_dict[pair[1]]
472
+
473
+ return state_dict
474
+
475
+
476
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag=None, exclude_frozen_parameters=False):
477
+ """
478
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
479
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
480
+ via a model hub.
481
+
482
+ Args:
483
+ - ``checkpoint_dir``: path to the desired checkpoint folder
484
+ - ``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``
485
+ - ``exclude_frozen_parameters``: exclude frozen parameters
486
+
487
+ Returns:
488
+ - pytorch ``state_dict``
489
+
490
+ Note: this approach may not work if your application doesn't have sufficient free CPU memory and
491
+ you may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
492
+ the checkpoint.
493
+
494
+ A typical usage might be ::
495
+
496
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
497
+ # do the training and checkpoint saving
498
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
499
+ model = model.cpu() # move to cpu
500
+ model.load_state_dict(state_dict)
501
+ # submit to model hub or save the model to share with others
502
+
503
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
504
+ application. i.e. you will need to re-initialize the deepspeed engine, since
505
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
506
+
507
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
508
+
509
+ """
510
+ if tag is None:
511
+ latest_path = os.path.join(checkpoint_dir, 'latest')
512
+ if os.path.isfile(latest_path):
513
+ with open(latest_path, 'r') as fd:
514
+ tag = fd.read().strip()
515
+ else:
516
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
517
+
518
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
519
+
520
+ if not os.path.isdir(ds_checkpoint_dir):
521
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
522
+
523
+ return _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
524
+
525
+
526
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
527
+ output_dir,
528
+ max_shard_size="5GB",
529
+ safe_serialization=False,
530
+ tag=None,
531
+ exclude_frozen_parameters=False):
532
+ """
533
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
534
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
535
+
536
+ Args:
537
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
538
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
539
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
540
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
541
+ - ``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``
542
+ - ``exclude_frozen_parameters``: exclude frozen parameters
543
+ """
544
+ # Dependency pre-check
545
+ if safe_serialization:
546
+ try:
547
+ from safetensors.torch import save_file
548
+ except ImportError:
549
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
550
+ raise
551
+ if max_shard_size is not None:
552
+ try:
553
+ from huggingface_hub import split_torch_state_dict_into_shards
554
+ except ImportError:
555
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
556
+ raise
557
+
558
+ # Convert zero checkpoint to state_dict
559
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag, exclude_frozen_parameters)
560
+
561
+ # Shard the model if it is too big.
562
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
563
+ if max_shard_size is not None:
564
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
565
+ state_dict_split = split_torch_state_dict_into_shards(state_dict,
566
+ filename_pattern=filename_pattern,
567
+ max_shard_size=max_shard_size)
568
+ else:
569
+ from collections import namedtuple
570
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
571
+ state_dict_split = StateDictSplit(is_sharded=False,
572
+ filename_to_tensors={weights_name: list(state_dict.keys())})
573
+
574
+ # Save the model
575
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
576
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
577
+ shard = {tensor: state_dict[tensor].contiguous() for tensor in tensors}
578
+ output_path = os.path.join(output_dir, shard_file)
579
+ if safe_serialization:
580
+ save_file(shard, output_path, metadata={"format": "pt"})
581
+ else:
582
+ torch.save(shard, output_path)
583
+
584
+ # Save index if sharded
585
+ if state_dict_split.is_sharded:
586
+ index = {
587
+ "metadata": state_dict_split.metadata,
588
+ "weight_map": state_dict_split.tensor_to_filename,
589
+ }
590
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
591
+ save_index_file = os.path.join(output_dir, save_index_file)
592
+ with open(save_index_file, "w", encoding="utf-8") as f:
593
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
594
+ f.write(content)
595
+
596
+
597
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
598
+ """
599
+ 1. Put the provided model to cpu
600
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
601
+ 3. Load it into the provided model
602
+
603
+ Args:
604
+ - ``model``: the model object to update
605
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
606
+ - ``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``
607
+
608
+ Returns:
609
+ - ``model`: modified model
610
+
611
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
612
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
613
+ conveniently placed for you in the checkpoint folder.
614
+
615
+ A typical usage might be ::
616
+
617
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
618
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
619
+ # submit to model hub or save the model to share with others
620
+
621
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
622
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
623
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
624
+
625
+ """
626
+ logger.info(f"Extracting fp32 weights")
627
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
628
+
629
+ logger.info(f"Overwriting model with fp32 weights")
630
+ model = model.cpu()
631
+ model.load_state_dict(state_dict, strict=False)
632
+
633
+ return model
634
+
635
+
636
+ if __name__ == "__main__":
637
+ parser = argparse.ArgumentParser()
638
+ parser.add_argument("checkpoint_dir",
639
+ type=str,
640
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
641
+ parser.add_argument("output_dir",
642
+ type=str,
643
+ help="directory to the pytorch fp32 state_dict output files"
644
+ "(e.g. path/checkpoint-12-output/)")
645
+ parser.add_argument(
646
+ "--max_shard_size",
647
+ type=str,
648
+ default="5GB",
649
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
650
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
651
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
652
+ "without CPU OOM issues.")
653
+ parser.add_argument(
654
+ "--safe_serialization",
655
+ default=False,
656
+ action='store_true',
657
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
658
+ parser.add_argument("-t",
659
+ "--tag",
660
+ type=str,
661
+ default=None,
662
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
663
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
664
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
665
+ args = parser.parse_args()
666
+
667
+ debug = args.debug
668
+
669
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
670
+ args.output_dir,
671
+ max_shard_size=args.max_shard_size,
672
+ safe_serialization=args.safe_serialization,
673
+ tag=args.tag,
674
+ exclude_frozen_parameters=args.exclude_frozen_parameters)