PEFT
Safetensors
deu05232 commited on
Commit
b51176e
·
verified ·
1 Parent(s): 11024fd

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: meta-llama/Llama-2-7b-hf
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.14.0
adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "meta-llama/Llama-2-7b-hf",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 64,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.1,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 32,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "down_proj",
27
+ "v_proj",
28
+ "o_proj",
29
+ "q_proj",
30
+ "k_proj",
31
+ "up_proj",
32
+ "gate_proj"
33
+ ],
34
+ "task_type": "FEATURE_EXTRACTION",
35
+ "use_dora": false,
36
+ "use_rslora": false
37
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4658821a31b42f54caae8ae01ebb1479a99c60fef9a319cbd8769d5d23104d42
3
+ size 159965640
global_step1655/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:172b7207682725f03087160da0f57975d9487d5d3a80de657adaf7d1d9755856
3
+ size 479727536
global_step1655/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:9c45ba4dcd849e9515f24a57e2b2504b80ca3ee8ef7fe7394164521cbfd98bb8
3
+ size 479727536
global_step1655/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:67ad42b12298f4b30031f3e0a35e3fd9f9759ebebb13337071a5831259258c31
3
+ size 6608028458
global_step1655/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:dcc22d6b81df6a05660bd8fc85f4456c7b6233ab68b68c3b4f40cb12495cee1c
3
+ size 6608028458
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step1655
rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d44e4cb93d62c803bd53846e7c9483dec147759c6015852861ef7a54acad8c2b
3
+ size 14512
rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:962bdb064e165c3976f599dce744351bc065adf4c64e20b0b335dc351196822e
3
+ size 14512
trainer_state.json ADDED
@@ -0,0 +1,1188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 0.9996979764421625,
5
+ "eval_steps": 500,
6
+ "global_step": 1655,
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.006040471156750227,
13
+ "grad_norm": 6.352119345594041,
14
+ "learning_rate": 4.9999999999999996e-05,
15
+ "loss": 5.7625,
16
+ "step": 10
17
+ },
18
+ {
19
+ "epoch": 0.012080942313500454,
20
+ "grad_norm": 3.5107589040708578,
21
+ "learning_rate": 6.505149978319905e-05,
22
+ "loss": 3.1477,
23
+ "step": 20
24
+ },
25
+ {
26
+ "epoch": 0.018121413470250678,
27
+ "grad_norm": 1.7597502982401718,
28
+ "learning_rate": 7.385606273598311e-05,
29
+ "loss": 1.8234,
30
+ "step": 30
31
+ },
32
+ {
33
+ "epoch": 0.024161884627000908,
34
+ "grad_norm": 2.0430582664699704,
35
+ "learning_rate": 8.01029995663981e-05,
36
+ "loss": 1.482,
37
+ "step": 40
38
+ },
39
+ {
40
+ "epoch": 0.030202355783751134,
41
+ "grad_norm": 2.30138022647804,
42
+ "learning_rate": 8.494850021680092e-05,
43
+ "loss": 1.427,
44
+ "step": 50
45
+ },
46
+ {
47
+ "epoch": 0.036242826940501356,
48
+ "grad_norm": 1.961300808555845,
49
+ "learning_rate": 8.890756251918216e-05,
50
+ "loss": 1.3652,
51
+ "step": 60
52
+ },
53
+ {
54
+ "epoch": 0.042283298097251586,
55
+ "grad_norm": 1.5670057056368645,
56
+ "learning_rate": 9.225490200071284e-05,
57
+ "loss": 1.2859,
58
+ "step": 70
59
+ },
60
+ {
61
+ "epoch": 0.048323769254001815,
62
+ "grad_norm": 1.5648604780816326,
63
+ "learning_rate": 9.515449934959716e-05,
64
+ "loss": 1.2166,
65
+ "step": 80
66
+ },
67
+ {
68
+ "epoch": 0.05436424041075204,
69
+ "grad_norm": 1.5594489363452173,
70
+ "learning_rate": 9.771212547196623e-05,
71
+ "loss": 1.2299,
72
+ "step": 90
73
+ },
74
+ {
75
+ "epoch": 0.06040471156750227,
76
+ "grad_norm": 1.478498798125124,
77
+ "learning_rate": 9.999999999999999e-05,
78
+ "loss": 1.1406,
79
+ "step": 100
80
+ },
81
+ {
82
+ "epoch": 0.0664451827242525,
83
+ "grad_norm": 1.3456415286113537,
84
+ "learning_rate": 9.942122186495178e-05,
85
+ "loss": 1.1512,
86
+ "step": 110
87
+ },
88
+ {
89
+ "epoch": 0.07248565388100271,
90
+ "grad_norm": 1.4169868695799486,
91
+ "learning_rate": 9.877813504823152e-05,
92
+ "loss": 1.2473,
93
+ "step": 120
94
+ },
95
+ {
96
+ "epoch": 0.07852612503775294,
97
+ "grad_norm": 1.5442406663559958,
98
+ "learning_rate": 9.813504823151127e-05,
99
+ "loss": 1.1609,
100
+ "step": 130
101
+ },
102
+ {
103
+ "epoch": 0.08456659619450317,
104
+ "grad_norm": 1.3840740480619829,
105
+ "learning_rate": 9.7491961414791e-05,
106
+ "loss": 1.1617,
107
+ "step": 140
108
+ },
109
+ {
110
+ "epoch": 0.0906070673512534,
111
+ "grad_norm": 1.1099163069476086,
112
+ "learning_rate": 9.684887459807074e-05,
113
+ "loss": 1.1746,
114
+ "step": 150
115
+ },
116
+ {
117
+ "epoch": 0.09664753850800363,
118
+ "grad_norm": 1.2420434112131873,
119
+ "learning_rate": 9.620578778135049e-05,
120
+ "loss": 1.1504,
121
+ "step": 160
122
+ },
123
+ {
124
+ "epoch": 0.10268800966475385,
125
+ "grad_norm": 1.081321720135299,
126
+ "learning_rate": 9.556270096463023e-05,
127
+ "loss": 1.1605,
128
+ "step": 170
129
+ },
130
+ {
131
+ "epoch": 0.10872848082150408,
132
+ "grad_norm": 1.0982034537770153,
133
+ "learning_rate": 9.491961414790998e-05,
134
+ "loss": 1.0799,
135
+ "step": 180
136
+ },
137
+ {
138
+ "epoch": 0.1147689519782543,
139
+ "grad_norm": 1.1736811633063773,
140
+ "learning_rate": 9.427652733118972e-05,
141
+ "loss": 1.1242,
142
+ "step": 190
143
+ },
144
+ {
145
+ "epoch": 0.12080942313500453,
146
+ "grad_norm": 1.3595797342301437,
147
+ "learning_rate": 9.363344051446946e-05,
148
+ "loss": 1.1016,
149
+ "step": 200
150
+ },
151
+ {
152
+ "epoch": 0.12684989429175475,
153
+ "grad_norm": 1.2621841618934533,
154
+ "learning_rate": 9.29903536977492e-05,
155
+ "loss": 1.0695,
156
+ "step": 210
157
+ },
158
+ {
159
+ "epoch": 0.132890365448505,
160
+ "grad_norm": 1.2070699106064489,
161
+ "learning_rate": 9.234726688102894e-05,
162
+ "loss": 1.1049,
163
+ "step": 220
164
+ },
165
+ {
166
+ "epoch": 0.1389308366052552,
167
+ "grad_norm": 1.0416383062176056,
168
+ "learning_rate": 9.17041800643087e-05,
169
+ "loss": 1.1467,
170
+ "step": 230
171
+ },
172
+ {
173
+ "epoch": 0.14497130776200542,
174
+ "grad_norm": 1.1856097509180394,
175
+ "learning_rate": 9.106109324758843e-05,
176
+ "loss": 1.0746,
177
+ "step": 240
178
+ },
179
+ {
180
+ "epoch": 0.15101177891875567,
181
+ "grad_norm": 1.144246874115688,
182
+ "learning_rate": 9.041800643086817e-05,
183
+ "loss": 1.2018,
184
+ "step": 250
185
+ },
186
+ {
187
+ "epoch": 0.15705225007550588,
188
+ "grad_norm": 0.9353587652819314,
189
+ "learning_rate": 8.977491961414792e-05,
190
+ "loss": 1.0789,
191
+ "step": 260
192
+ },
193
+ {
194
+ "epoch": 0.16309272123225613,
195
+ "grad_norm": 1.0285527563460544,
196
+ "learning_rate": 8.913183279742766e-05,
197
+ "loss": 1.0555,
198
+ "step": 270
199
+ },
200
+ {
201
+ "epoch": 0.16913319238900634,
202
+ "grad_norm": 0.9852353032151006,
203
+ "learning_rate": 8.848874598070739e-05,
204
+ "loss": 1.1451,
205
+ "step": 280
206
+ },
207
+ {
208
+ "epoch": 0.17517366354575656,
209
+ "grad_norm": 1.175932073617665,
210
+ "learning_rate": 8.784565916398714e-05,
211
+ "loss": 1.0789,
212
+ "step": 290
213
+ },
214
+ {
215
+ "epoch": 0.1812141347025068,
216
+ "grad_norm": 1.213820312892746,
217
+ "learning_rate": 8.720257234726688e-05,
218
+ "loss": 1.0475,
219
+ "step": 300
220
+ },
221
+ {
222
+ "epoch": 0.18725460585925702,
223
+ "grad_norm": 1.1846528600649535,
224
+ "learning_rate": 8.655948553054663e-05,
225
+ "loss": 1.0521,
226
+ "step": 310
227
+ },
228
+ {
229
+ "epoch": 0.19329507701600726,
230
+ "grad_norm": 1.1497197430459096,
231
+ "learning_rate": 8.591639871382637e-05,
232
+ "loss": 1.082,
233
+ "step": 320
234
+ },
235
+ {
236
+ "epoch": 0.19933554817275748,
237
+ "grad_norm": 1.1612797319381625,
238
+ "learning_rate": 8.52733118971061e-05,
239
+ "loss": 1.0793,
240
+ "step": 330
241
+ },
242
+ {
243
+ "epoch": 0.2053760193295077,
244
+ "grad_norm": 1.082739707844854,
245
+ "learning_rate": 8.463022508038586e-05,
246
+ "loss": 1.1061,
247
+ "step": 340
248
+ },
249
+ {
250
+ "epoch": 0.21141649048625794,
251
+ "grad_norm": 1.2757899011878036,
252
+ "learning_rate": 8.398713826366559e-05,
253
+ "loss": 1.073,
254
+ "step": 350
255
+ },
256
+ {
257
+ "epoch": 0.21745696164300815,
258
+ "grad_norm": 0.9540956853203417,
259
+ "learning_rate": 8.334405144694534e-05,
260
+ "loss": 1.0135,
261
+ "step": 360
262
+ },
263
+ {
264
+ "epoch": 0.2234974327997584,
265
+ "grad_norm": 1.0200709241255603,
266
+ "learning_rate": 8.270096463022508e-05,
267
+ "loss": 1.1389,
268
+ "step": 370
269
+ },
270
+ {
271
+ "epoch": 0.2295379039565086,
272
+ "grad_norm": 0.8455317026975807,
273
+ "learning_rate": 8.205787781350482e-05,
274
+ "loss": 1.0598,
275
+ "step": 380
276
+ },
277
+ {
278
+ "epoch": 0.23557837511325883,
279
+ "grad_norm": 1.1381349305391164,
280
+ "learning_rate": 8.141479099678457e-05,
281
+ "loss": 1.0777,
282
+ "step": 390
283
+ },
284
+ {
285
+ "epoch": 0.24161884627000907,
286
+ "grad_norm": 1.103747383663609,
287
+ "learning_rate": 8.07717041800643e-05,
288
+ "loss": 1.0617,
289
+ "step": 400
290
+ },
291
+ {
292
+ "epoch": 0.24765931742675928,
293
+ "grad_norm": 1.138904626814912,
294
+ "learning_rate": 8.012861736334406e-05,
295
+ "loss": 1.0324,
296
+ "step": 410
297
+ },
298
+ {
299
+ "epoch": 0.2536997885835095,
300
+ "grad_norm": 1.0781428262426909,
301
+ "learning_rate": 7.94855305466238e-05,
302
+ "loss": 1.0859,
303
+ "step": 420
304
+ },
305
+ {
306
+ "epoch": 0.2597402597402597,
307
+ "grad_norm": 1.0846995831727089,
308
+ "learning_rate": 7.884244372990353e-05,
309
+ "loss": 1.0553,
310
+ "step": 430
311
+ },
312
+ {
313
+ "epoch": 0.26578073089701,
314
+ "grad_norm": 0.8641072003497396,
315
+ "learning_rate": 7.819935691318328e-05,
316
+ "loss": 1.0068,
317
+ "step": 440
318
+ },
319
+ {
320
+ "epoch": 0.2718212020537602,
321
+ "grad_norm": 1.110226877216393,
322
+ "learning_rate": 7.755627009646302e-05,
323
+ "loss": 1.0115,
324
+ "step": 450
325
+ },
326
+ {
327
+ "epoch": 0.2778616732105104,
328
+ "grad_norm": 1.1418636977442045,
329
+ "learning_rate": 7.691318327974277e-05,
330
+ "loss": 1.0373,
331
+ "step": 460
332
+ },
333
+ {
334
+ "epoch": 0.28390214436726063,
335
+ "grad_norm": 0.9476740742119087,
336
+ "learning_rate": 7.62700964630225e-05,
337
+ "loss": 1.0023,
338
+ "step": 470
339
+ },
340
+ {
341
+ "epoch": 0.28994261552401085,
342
+ "grad_norm": 1.1736350313366837,
343
+ "learning_rate": 7.562700964630224e-05,
344
+ "loss": 1.0338,
345
+ "step": 480
346
+ },
347
+ {
348
+ "epoch": 0.2959830866807611,
349
+ "grad_norm": 1.113923619981689,
350
+ "learning_rate": 7.4983922829582e-05,
351
+ "loss": 0.9855,
352
+ "step": 490
353
+ },
354
+ {
355
+ "epoch": 0.30202355783751134,
356
+ "grad_norm": 1.0389339180007815,
357
+ "learning_rate": 7.434083601286173e-05,
358
+ "loss": 1.0525,
359
+ "step": 500
360
+ },
361
+ {
362
+ "epoch": 0.30806402899426155,
363
+ "grad_norm": 1.161270624803982,
364
+ "learning_rate": 7.369774919614148e-05,
365
+ "loss": 1.0697,
366
+ "step": 510
367
+ },
368
+ {
369
+ "epoch": 0.31410450015101177,
370
+ "grad_norm": 0.8892068789215148,
371
+ "learning_rate": 7.305466237942122e-05,
372
+ "loss": 0.9889,
373
+ "step": 520
374
+ },
375
+ {
376
+ "epoch": 0.320144971307762,
377
+ "grad_norm": 1.0455859065719944,
378
+ "learning_rate": 7.241157556270097e-05,
379
+ "loss": 0.9898,
380
+ "step": 530
381
+ },
382
+ {
383
+ "epoch": 0.32618544246451225,
384
+ "grad_norm": 1.0186894188406512,
385
+ "learning_rate": 7.17684887459807e-05,
386
+ "loss": 0.9904,
387
+ "step": 540
388
+ },
389
+ {
390
+ "epoch": 0.33222591362126247,
391
+ "grad_norm": 1.0072092839183986,
392
+ "learning_rate": 7.112540192926044e-05,
393
+ "loss": 0.9873,
394
+ "step": 550
395
+ },
396
+ {
397
+ "epoch": 0.3382663847780127,
398
+ "grad_norm": 0.9663462582485958,
399
+ "learning_rate": 7.04823151125402e-05,
400
+ "loss": 1.0375,
401
+ "step": 560
402
+ },
403
+ {
404
+ "epoch": 0.3443068559347629,
405
+ "grad_norm": 0.9103712505082897,
406
+ "learning_rate": 6.983922829581993e-05,
407
+ "loss": 1.0383,
408
+ "step": 570
409
+ },
410
+ {
411
+ "epoch": 0.3503473270915131,
412
+ "grad_norm": 1.0485963233672557,
413
+ "learning_rate": 6.919614147909968e-05,
414
+ "loss": 0.9758,
415
+ "step": 580
416
+ },
417
+ {
418
+ "epoch": 0.3563877982482634,
419
+ "grad_norm": 0.9912979171159205,
420
+ "learning_rate": 6.855305466237942e-05,
421
+ "loss": 0.993,
422
+ "step": 590
423
+ },
424
+ {
425
+ "epoch": 0.3624282694050136,
426
+ "grad_norm": 1.1550179596081722,
427
+ "learning_rate": 6.790996784565917e-05,
428
+ "loss": 1.032,
429
+ "step": 600
430
+ },
431
+ {
432
+ "epoch": 0.3684687405617638,
433
+ "grad_norm": 1.0176105219446732,
434
+ "learning_rate": 6.726688102893891e-05,
435
+ "loss": 1.0094,
436
+ "step": 610
437
+ },
438
+ {
439
+ "epoch": 0.37450921171851403,
440
+ "grad_norm": 1.1210756115920897,
441
+ "learning_rate": 6.662379421221864e-05,
442
+ "loss": 0.968,
443
+ "step": 620
444
+ },
445
+ {
446
+ "epoch": 0.38054968287526425,
447
+ "grad_norm": 0.9310657150450071,
448
+ "learning_rate": 6.59807073954984e-05,
449
+ "loss": 1.0102,
450
+ "step": 630
451
+ },
452
+ {
453
+ "epoch": 0.3865901540320145,
454
+ "grad_norm": 1.1633016127800648,
455
+ "learning_rate": 6.533762057877813e-05,
456
+ "loss": 1.0256,
457
+ "step": 640
458
+ },
459
+ {
460
+ "epoch": 0.39263062518876474,
461
+ "grad_norm": 0.8195008101746646,
462
+ "learning_rate": 6.469453376205788e-05,
463
+ "loss": 0.9906,
464
+ "step": 650
465
+ },
466
+ {
467
+ "epoch": 0.39867109634551495,
468
+ "grad_norm": 0.9310761172857367,
469
+ "learning_rate": 6.405144694533762e-05,
470
+ "loss": 0.9754,
471
+ "step": 660
472
+ },
473
+ {
474
+ "epoch": 0.40471156750226517,
475
+ "grad_norm": 1.0516630367824455,
476
+ "learning_rate": 6.340836012861736e-05,
477
+ "loss": 1.0275,
478
+ "step": 670
479
+ },
480
+ {
481
+ "epoch": 0.4107520386590154,
482
+ "grad_norm": 1.0629036969985795,
483
+ "learning_rate": 6.276527331189711e-05,
484
+ "loss": 1.0088,
485
+ "step": 680
486
+ },
487
+ {
488
+ "epoch": 0.41679250981576565,
489
+ "grad_norm": 1.0110994904370134,
490
+ "learning_rate": 6.212218649517684e-05,
491
+ "loss": 1.0416,
492
+ "step": 690
493
+ },
494
+ {
495
+ "epoch": 0.42283298097251587,
496
+ "grad_norm": 0.8895584335650736,
497
+ "learning_rate": 6.14790996784566e-05,
498
+ "loss": 1.0762,
499
+ "step": 700
500
+ },
501
+ {
502
+ "epoch": 0.4288734521292661,
503
+ "grad_norm": 1.0448634604827216,
504
+ "learning_rate": 6.083601286173633e-05,
505
+ "loss": 0.9771,
506
+ "step": 710
507
+ },
508
+ {
509
+ "epoch": 0.4349139232860163,
510
+ "grad_norm": 0.7905625978703504,
511
+ "learning_rate": 6.019292604501608e-05,
512
+ "loss": 1.0104,
513
+ "step": 720
514
+ },
515
+ {
516
+ "epoch": 0.4409543944427665,
517
+ "grad_norm": 1.0522004404580236,
518
+ "learning_rate": 5.954983922829582e-05,
519
+ "loss": 0.9977,
520
+ "step": 730
521
+ },
522
+ {
523
+ "epoch": 0.4469948655995168,
524
+ "grad_norm": 0.989475716298655,
525
+ "learning_rate": 5.8906752411575564e-05,
526
+ "loss": 0.9752,
527
+ "step": 740
528
+ },
529
+ {
530
+ "epoch": 0.453035336756267,
531
+ "grad_norm": 1.1463565668787514,
532
+ "learning_rate": 5.826366559485531e-05,
533
+ "loss": 0.9922,
534
+ "step": 750
535
+ },
536
+ {
537
+ "epoch": 0.4590758079130172,
538
+ "grad_norm": 1.189865689753586,
539
+ "learning_rate": 5.7620578778135045e-05,
540
+ "loss": 1.0211,
541
+ "step": 760
542
+ },
543
+ {
544
+ "epoch": 0.46511627906976744,
545
+ "grad_norm": 1.0920686333427474,
546
+ "learning_rate": 5.6977491961414796e-05,
547
+ "loss": 0.9664,
548
+ "step": 770
549
+ },
550
+ {
551
+ "epoch": 0.47115675022651765,
552
+ "grad_norm": 1.0174913677757231,
553
+ "learning_rate": 5.633440514469453e-05,
554
+ "loss": 0.9992,
555
+ "step": 780
556
+ },
557
+ {
558
+ "epoch": 0.4771972213832679,
559
+ "grad_norm": 1.1913080680366728,
560
+ "learning_rate": 5.5691318327974284e-05,
561
+ "loss": 1.033,
562
+ "step": 790
563
+ },
564
+ {
565
+ "epoch": 0.48323769254001814,
566
+ "grad_norm": 1.0204323369307062,
567
+ "learning_rate": 5.504823151125402e-05,
568
+ "loss": 0.9807,
569
+ "step": 800
570
+ },
571
+ {
572
+ "epoch": 0.48927816369676835,
573
+ "grad_norm": 1.118864062431584,
574
+ "learning_rate": 5.440514469453376e-05,
575
+ "loss": 0.974,
576
+ "step": 810
577
+ },
578
+ {
579
+ "epoch": 0.49531863485351857,
580
+ "grad_norm": 1.0350012597705058,
581
+ "learning_rate": 5.376205787781351e-05,
582
+ "loss": 0.9705,
583
+ "step": 820
584
+ },
585
+ {
586
+ "epoch": 0.5013591060102688,
587
+ "grad_norm": 1.0845595520731828,
588
+ "learning_rate": 5.3118971061093246e-05,
589
+ "loss": 0.9582,
590
+ "step": 830
591
+ },
592
+ {
593
+ "epoch": 0.507399577167019,
594
+ "grad_norm": 0.9453749574005488,
595
+ "learning_rate": 5.2475884244372996e-05,
596
+ "loss": 1.0293,
597
+ "step": 840
598
+ },
599
+ {
600
+ "epoch": 0.5134400483237692,
601
+ "grad_norm": 1.042699724920899,
602
+ "learning_rate": 5.183279742765273e-05,
603
+ "loss": 0.952,
604
+ "step": 850
605
+ },
606
+ {
607
+ "epoch": 0.5194805194805194,
608
+ "grad_norm": 1.024020216858902,
609
+ "learning_rate": 5.118971061093247e-05,
610
+ "loss": 1.018,
611
+ "step": 860
612
+ },
613
+ {
614
+ "epoch": 0.5255209906372698,
615
+ "grad_norm": 1.0360224854752502,
616
+ "learning_rate": 5.054662379421222e-05,
617
+ "loss": 0.9295,
618
+ "step": 870
619
+ },
620
+ {
621
+ "epoch": 0.53156146179402,
622
+ "grad_norm": 1.1683508369643563,
623
+ "learning_rate": 4.9903536977491965e-05,
624
+ "loss": 1.0133,
625
+ "step": 880
626
+ },
627
+ {
628
+ "epoch": 0.5376019329507702,
629
+ "grad_norm": 0.8614966755997071,
630
+ "learning_rate": 4.92604501607717e-05,
631
+ "loss": 0.993,
632
+ "step": 890
633
+ },
634
+ {
635
+ "epoch": 0.5436424041075204,
636
+ "grad_norm": 0.9857361206695465,
637
+ "learning_rate": 4.8617363344051446e-05,
638
+ "loss": 0.951,
639
+ "step": 900
640
+ },
641
+ {
642
+ "epoch": 0.5496828752642706,
643
+ "grad_norm": 0.8956078547131043,
644
+ "learning_rate": 4.797427652733119e-05,
645
+ "loss": 0.9268,
646
+ "step": 910
647
+ },
648
+ {
649
+ "epoch": 0.5557233464210208,
650
+ "grad_norm": 0.8885268581836658,
651
+ "learning_rate": 4.7331189710610934e-05,
652
+ "loss": 0.9688,
653
+ "step": 920
654
+ },
655
+ {
656
+ "epoch": 0.561763817577771,
657
+ "grad_norm": 1.136712299735102,
658
+ "learning_rate": 4.668810289389068e-05,
659
+ "loss": 0.9545,
660
+ "step": 930
661
+ },
662
+ {
663
+ "epoch": 0.5678042887345213,
664
+ "grad_norm": 1.114040839440962,
665
+ "learning_rate": 4.604501607717042e-05,
666
+ "loss": 1.0,
667
+ "step": 940
668
+ },
669
+ {
670
+ "epoch": 0.5738447598912715,
671
+ "grad_norm": 1.2120423884348053,
672
+ "learning_rate": 4.5401929260450165e-05,
673
+ "loss": 0.9525,
674
+ "step": 950
675
+ },
676
+ {
677
+ "epoch": 0.5798852310480217,
678
+ "grad_norm": 0.9841344976466476,
679
+ "learning_rate": 4.47588424437299e-05,
680
+ "loss": 1.0389,
681
+ "step": 960
682
+ },
683
+ {
684
+ "epoch": 0.585925702204772,
685
+ "grad_norm": 1.0459005071658793,
686
+ "learning_rate": 4.4115755627009646e-05,
687
+ "loss": 1.0041,
688
+ "step": 970
689
+ },
690
+ {
691
+ "epoch": 0.5919661733615222,
692
+ "grad_norm": 1.2096290639870764,
693
+ "learning_rate": 4.347266881028939e-05,
694
+ "loss": 0.9939,
695
+ "step": 980
696
+ },
697
+ {
698
+ "epoch": 0.5980066445182725,
699
+ "grad_norm": 1.0171142436328486,
700
+ "learning_rate": 4.2829581993569134e-05,
701
+ "loss": 0.9432,
702
+ "step": 990
703
+ },
704
+ {
705
+ "epoch": 0.6040471156750227,
706
+ "grad_norm": 1.0557726010616861,
707
+ "learning_rate": 4.218649517684888e-05,
708
+ "loss": 1.0041,
709
+ "step": 1000
710
+ },
711
+ {
712
+ "epoch": 0.6100875868317729,
713
+ "grad_norm": 0.9854936325370102,
714
+ "learning_rate": 4.154340836012862e-05,
715
+ "loss": 0.9598,
716
+ "step": 1010
717
+ },
718
+ {
719
+ "epoch": 0.6161280579885231,
720
+ "grad_norm": 1.0002881708013533,
721
+ "learning_rate": 4.090032154340836e-05,
722
+ "loss": 0.9537,
723
+ "step": 1020
724
+ },
725
+ {
726
+ "epoch": 0.6221685291452733,
727
+ "grad_norm": 1.0163254545569222,
728
+ "learning_rate": 4.02572347266881e-05,
729
+ "loss": 0.9781,
730
+ "step": 1030
731
+ },
732
+ {
733
+ "epoch": 0.6282090003020235,
734
+ "grad_norm": 1.0700856083800017,
735
+ "learning_rate": 3.961414790996785e-05,
736
+ "loss": 0.9418,
737
+ "step": 1040
738
+ },
739
+ {
740
+ "epoch": 0.6342494714587738,
741
+ "grad_norm": 0.925802326406659,
742
+ "learning_rate": 3.897106109324759e-05,
743
+ "loss": 0.9355,
744
+ "step": 1050
745
+ },
746
+ {
747
+ "epoch": 0.640289942615524,
748
+ "grad_norm": 1.0173964783122673,
749
+ "learning_rate": 3.8327974276527335e-05,
750
+ "loss": 0.9311,
751
+ "step": 1060
752
+ },
753
+ {
754
+ "epoch": 0.6463304137722743,
755
+ "grad_norm": 1.0886760638416628,
756
+ "learning_rate": 3.768488745980708e-05,
757
+ "loss": 1.0104,
758
+ "step": 1070
759
+ },
760
+ {
761
+ "epoch": 0.6523708849290245,
762
+ "grad_norm": 0.8784480294988184,
763
+ "learning_rate": 3.7041800643086816e-05,
764
+ "loss": 0.9631,
765
+ "step": 1080
766
+ },
767
+ {
768
+ "epoch": 0.6584113560857747,
769
+ "grad_norm": 1.0061477546516637,
770
+ "learning_rate": 3.639871382636656e-05,
771
+ "loss": 0.9209,
772
+ "step": 1090
773
+ },
774
+ {
775
+ "epoch": 0.6644518272425249,
776
+ "grad_norm": 1.0443361002098694,
777
+ "learning_rate": 3.5755627009646303e-05,
778
+ "loss": 0.9494,
779
+ "step": 1100
780
+ },
781
+ {
782
+ "epoch": 0.6704922983992752,
783
+ "grad_norm": 1.064188874483296,
784
+ "learning_rate": 3.511254019292605e-05,
785
+ "loss": 0.9871,
786
+ "step": 1110
787
+ },
788
+ {
789
+ "epoch": 0.6765327695560254,
790
+ "grad_norm": 0.9804777210337282,
791
+ "learning_rate": 3.446945337620579e-05,
792
+ "loss": 0.9357,
793
+ "step": 1120
794
+ },
795
+ {
796
+ "epoch": 0.6825732407127756,
797
+ "grad_norm": 1.0053083581127769,
798
+ "learning_rate": 3.3826366559485535e-05,
799
+ "loss": 0.9637,
800
+ "step": 1130
801
+ },
802
+ {
803
+ "epoch": 0.6886137118695258,
804
+ "grad_norm": 1.0062328413826747,
805
+ "learning_rate": 3.318327974276528e-05,
806
+ "loss": 0.9914,
807
+ "step": 1140
808
+ },
809
+ {
810
+ "epoch": 0.694654183026276,
811
+ "grad_norm": 1.0659942748249296,
812
+ "learning_rate": 3.2540192926045016e-05,
813
+ "loss": 0.9332,
814
+ "step": 1150
815
+ },
816
+ {
817
+ "epoch": 0.7006946541830262,
818
+ "grad_norm": 1.2425227959394274,
819
+ "learning_rate": 3.189710610932476e-05,
820
+ "loss": 0.9951,
821
+ "step": 1160
822
+ },
823
+ {
824
+ "epoch": 0.7067351253397764,
825
+ "grad_norm": 1.0269910163244402,
826
+ "learning_rate": 3.1254019292604504e-05,
827
+ "loss": 0.9805,
828
+ "step": 1170
829
+ },
830
+ {
831
+ "epoch": 0.7127755964965268,
832
+ "grad_norm": 1.067485855484705,
833
+ "learning_rate": 3.061093247588425e-05,
834
+ "loss": 0.975,
835
+ "step": 1180
836
+ },
837
+ {
838
+ "epoch": 0.718816067653277,
839
+ "grad_norm": 0.9819234749980894,
840
+ "learning_rate": 2.996784565916399e-05,
841
+ "loss": 0.9805,
842
+ "step": 1190
843
+ },
844
+ {
845
+ "epoch": 0.7248565388100272,
846
+ "grad_norm": 0.9915476687600292,
847
+ "learning_rate": 2.9324758842443732e-05,
848
+ "loss": 0.9365,
849
+ "step": 1200
850
+ },
851
+ {
852
+ "epoch": 0.7308970099667774,
853
+ "grad_norm": 1.048821106029052,
854
+ "learning_rate": 2.8681672025723473e-05,
855
+ "loss": 0.9861,
856
+ "step": 1210
857
+ },
858
+ {
859
+ "epoch": 0.7369374811235276,
860
+ "grad_norm": 0.9121022219179783,
861
+ "learning_rate": 2.8038585209003217e-05,
862
+ "loss": 0.9854,
863
+ "step": 1220
864
+ },
865
+ {
866
+ "epoch": 0.7429779522802779,
867
+ "grad_norm": 0.9525288844616361,
868
+ "learning_rate": 2.739549839228296e-05,
869
+ "loss": 0.948,
870
+ "step": 1230
871
+ },
872
+ {
873
+ "epoch": 0.7490184234370281,
874
+ "grad_norm": 1.1391100357014714,
875
+ "learning_rate": 2.67524115755627e-05,
876
+ "loss": 0.8887,
877
+ "step": 1240
878
+ },
879
+ {
880
+ "epoch": 0.7550588945937783,
881
+ "grad_norm": 1.1078585866746686,
882
+ "learning_rate": 2.6109324758842445e-05,
883
+ "loss": 0.9715,
884
+ "step": 1250
885
+ },
886
+ {
887
+ "epoch": 0.7610993657505285,
888
+ "grad_norm": 0.9323091046055703,
889
+ "learning_rate": 2.546623794212219e-05,
890
+ "loss": 0.9359,
891
+ "step": 1260
892
+ },
893
+ {
894
+ "epoch": 0.7671398369072787,
895
+ "grad_norm": 1.146046378807531,
896
+ "learning_rate": 2.482315112540193e-05,
897
+ "loss": 0.8967,
898
+ "step": 1270
899
+ },
900
+ {
901
+ "epoch": 0.773180308064029,
902
+ "grad_norm": 1.14163561365635,
903
+ "learning_rate": 2.4180064308681673e-05,
904
+ "loss": 0.9707,
905
+ "step": 1280
906
+ },
907
+ {
908
+ "epoch": 0.7792207792207793,
909
+ "grad_norm": 1.0034307361335086,
910
+ "learning_rate": 2.3536977491961414e-05,
911
+ "loss": 0.9668,
912
+ "step": 1290
913
+ },
914
+ {
915
+ "epoch": 0.7852612503775295,
916
+ "grad_norm": 1.1199578096409222,
917
+ "learning_rate": 2.2893890675241158e-05,
918
+ "loss": 0.968,
919
+ "step": 1300
920
+ },
921
+ {
922
+ "epoch": 0.7913017215342797,
923
+ "grad_norm": 1.0809213063777794,
924
+ "learning_rate": 2.22508038585209e-05,
925
+ "loss": 0.9264,
926
+ "step": 1310
927
+ },
928
+ {
929
+ "epoch": 0.7973421926910299,
930
+ "grad_norm": 1.1266044230874084,
931
+ "learning_rate": 2.1607717041800642e-05,
932
+ "loss": 1.0203,
933
+ "step": 1320
934
+ },
935
+ {
936
+ "epoch": 0.8033826638477801,
937
+ "grad_norm": 0.8540728431635001,
938
+ "learning_rate": 2.0964630225080386e-05,
939
+ "loss": 0.924,
940
+ "step": 1330
941
+ },
942
+ {
943
+ "epoch": 0.8094231350045303,
944
+ "grad_norm": 1.0063045365537524,
945
+ "learning_rate": 2.032154340836013e-05,
946
+ "loss": 0.9656,
947
+ "step": 1340
948
+ },
949
+ {
950
+ "epoch": 0.8154636061612806,
951
+ "grad_norm": 0.9432512605760064,
952
+ "learning_rate": 1.967845659163987e-05,
953
+ "loss": 1.0254,
954
+ "step": 1350
955
+ },
956
+ {
957
+ "epoch": 0.8215040773180308,
958
+ "grad_norm": 1.162199676010242,
959
+ "learning_rate": 1.9035369774919614e-05,
960
+ "loss": 0.9549,
961
+ "step": 1360
962
+ },
963
+ {
964
+ "epoch": 0.827544548474781,
965
+ "grad_norm": 1.0184734737311432,
966
+ "learning_rate": 1.8392282958199358e-05,
967
+ "loss": 0.8937,
968
+ "step": 1370
969
+ },
970
+ {
971
+ "epoch": 0.8335850196315313,
972
+ "grad_norm": 1.0321283898574098,
973
+ "learning_rate": 1.77491961414791e-05,
974
+ "loss": 0.9641,
975
+ "step": 1380
976
+ },
977
+ {
978
+ "epoch": 0.8396254907882815,
979
+ "grad_norm": 0.948342731761788,
980
+ "learning_rate": 1.7106109324758842e-05,
981
+ "loss": 0.907,
982
+ "step": 1390
983
+ },
984
+ {
985
+ "epoch": 0.8456659619450317,
986
+ "grad_norm": 1.016072519476065,
987
+ "learning_rate": 1.6463022508038586e-05,
988
+ "loss": 0.999,
989
+ "step": 1400
990
+ },
991
+ {
992
+ "epoch": 0.851706433101782,
993
+ "grad_norm": 0.8891894724654406,
994
+ "learning_rate": 1.581993569131833e-05,
995
+ "loss": 0.9238,
996
+ "step": 1410
997
+ },
998
+ {
999
+ "epoch": 0.8577469042585322,
1000
+ "grad_norm": 1.0116016221718374,
1001
+ "learning_rate": 1.517684887459807e-05,
1002
+ "loss": 0.9488,
1003
+ "step": 1420
1004
+ },
1005
+ {
1006
+ "epoch": 0.8637873754152824,
1007
+ "grad_norm": 1.092739541532347,
1008
+ "learning_rate": 1.4533762057877815e-05,
1009
+ "loss": 0.9971,
1010
+ "step": 1430
1011
+ },
1012
+ {
1013
+ "epoch": 0.8698278465720326,
1014
+ "grad_norm": 0.8563957174375877,
1015
+ "learning_rate": 1.3890675241157558e-05,
1016
+ "loss": 1.0133,
1017
+ "step": 1440
1018
+ },
1019
+ {
1020
+ "epoch": 0.8758683177287828,
1021
+ "grad_norm": 1.089288756096709,
1022
+ "learning_rate": 1.3247588424437299e-05,
1023
+ "loss": 0.9127,
1024
+ "step": 1450
1025
+ },
1026
+ {
1027
+ "epoch": 0.881908788885533,
1028
+ "grad_norm": 0.9458299067214011,
1029
+ "learning_rate": 1.2604501607717043e-05,
1030
+ "loss": 0.9668,
1031
+ "step": 1460
1032
+ },
1033
+ {
1034
+ "epoch": 0.8879492600422833,
1035
+ "grad_norm": 1.2229020868039389,
1036
+ "learning_rate": 1.1961414790996785e-05,
1037
+ "loss": 0.9506,
1038
+ "step": 1470
1039
+ },
1040
+ {
1041
+ "epoch": 0.8939897311990336,
1042
+ "grad_norm": 1.0615217830735095,
1043
+ "learning_rate": 1.1318327974276529e-05,
1044
+ "loss": 0.9219,
1045
+ "step": 1480
1046
+ },
1047
+ {
1048
+ "epoch": 0.9000302023557838,
1049
+ "grad_norm": 1.1622944573297567,
1050
+ "learning_rate": 1.0675241157556271e-05,
1051
+ "loss": 0.9391,
1052
+ "step": 1490
1053
+ },
1054
+ {
1055
+ "epoch": 0.906070673512534,
1056
+ "grad_norm": 0.9443566657008828,
1057
+ "learning_rate": 1.0032154340836013e-05,
1058
+ "loss": 0.8955,
1059
+ "step": 1500
1060
+ },
1061
+ {
1062
+ "epoch": 0.9121111446692842,
1063
+ "grad_norm": 1.1367332066610845,
1064
+ "learning_rate": 9.389067524115757e-06,
1065
+ "loss": 0.9385,
1066
+ "step": 1510
1067
+ },
1068
+ {
1069
+ "epoch": 0.9181516158260344,
1070
+ "grad_norm": 0.9414922696266849,
1071
+ "learning_rate": 8.7459807073955e-06,
1072
+ "loss": 0.9318,
1073
+ "step": 1520
1074
+ },
1075
+ {
1076
+ "epoch": 0.9241920869827847,
1077
+ "grad_norm": 1.0844935096035118,
1078
+ "learning_rate": 8.102893890675242e-06,
1079
+ "loss": 0.9311,
1080
+ "step": 1530
1081
+ },
1082
+ {
1083
+ "epoch": 0.9302325581395349,
1084
+ "grad_norm": 1.120509038145209,
1085
+ "learning_rate": 7.459807073954985e-06,
1086
+ "loss": 0.9422,
1087
+ "step": 1540
1088
+ },
1089
+ {
1090
+ "epoch": 0.9362730292962851,
1091
+ "grad_norm": 0.9486397409946379,
1092
+ "learning_rate": 6.816720257234727e-06,
1093
+ "loss": 0.9162,
1094
+ "step": 1550
1095
+ },
1096
+ {
1097
+ "epoch": 0.9423135004530353,
1098
+ "grad_norm": 1.1412479158621043,
1099
+ "learning_rate": 6.17363344051447e-06,
1100
+ "loss": 0.9676,
1101
+ "step": 1560
1102
+ },
1103
+ {
1104
+ "epoch": 0.9483539716097855,
1105
+ "grad_norm": 1.050318112867144,
1106
+ "learning_rate": 5.530546623794212e-06,
1107
+ "loss": 0.9754,
1108
+ "step": 1570
1109
+ },
1110
+ {
1111
+ "epoch": 0.9543944427665358,
1112
+ "grad_norm": 1.0466438135565226,
1113
+ "learning_rate": 4.887459807073955e-06,
1114
+ "loss": 0.926,
1115
+ "step": 1580
1116
+ },
1117
+ {
1118
+ "epoch": 0.9604349139232861,
1119
+ "grad_norm": 0.9720115456232871,
1120
+ "learning_rate": 4.244372990353698e-06,
1121
+ "loss": 0.9447,
1122
+ "step": 1590
1123
+ },
1124
+ {
1125
+ "epoch": 0.9664753850800363,
1126
+ "grad_norm": 0.8786923129454015,
1127
+ "learning_rate": 3.6012861736334403e-06,
1128
+ "loss": 0.9443,
1129
+ "step": 1600
1130
+ },
1131
+ {
1132
+ "epoch": 0.9725158562367865,
1133
+ "grad_norm": 1.0733513985052048,
1134
+ "learning_rate": 2.9581993569131834e-06,
1135
+ "loss": 0.9053,
1136
+ "step": 1610
1137
+ },
1138
+ {
1139
+ "epoch": 0.9785563273935367,
1140
+ "grad_norm": 0.8731368575153022,
1141
+ "learning_rate": 2.315112540192926e-06,
1142
+ "loss": 0.9803,
1143
+ "step": 1620
1144
+ },
1145
+ {
1146
+ "epoch": 0.9845967985502869,
1147
+ "grad_norm": 1.0060959243542735,
1148
+ "learning_rate": 1.6720257234726688e-06,
1149
+ "loss": 0.9563,
1150
+ "step": 1630
1151
+ },
1152
+ {
1153
+ "epoch": 0.9906372697070371,
1154
+ "grad_norm": 0.9113226806468382,
1155
+ "learning_rate": 1.0289389067524116e-06,
1156
+ "loss": 0.9191,
1157
+ "step": 1640
1158
+ },
1159
+ {
1160
+ "epoch": 0.9966777408637874,
1161
+ "grad_norm": 0.9160377841463557,
1162
+ "learning_rate": 3.8585209003215437e-07,
1163
+ "loss": 0.9117,
1164
+ "step": 1650
1165
+ }
1166
+ ],
1167
+ "logging_steps": 10,
1168
+ "max_steps": 1655,
1169
+ "num_input_tokens_seen": 0,
1170
+ "num_train_epochs": 1,
1171
+ "save_steps": 100,
1172
+ "stateful_callbacks": {
1173
+ "TrainerControl": {
1174
+ "args": {
1175
+ "should_epoch_stop": false,
1176
+ "should_evaluate": false,
1177
+ "should_log": false,
1178
+ "should_save": true,
1179
+ "should_training_stop": true
1180
+ },
1181
+ "attributes": {}
1182
+ }
1183
+ },
1184
+ "total_flos": 0.0,
1185
+ "train_batch_size": 32,
1186
+ "trial_name": null,
1187
+ "trial_params": null
1188
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:889b418411635b080223cf5b494471bfd7a53dadaa45890f705449cbb042f27f
3
+ size 7480
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)