LLucass commited on
Commit
fd34839
·
verified ·
1 Parent(s): ed71bc3

Training in progress, step 50, checkpoint

Browse files
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ checkpoint-50/tokenizer.json filter=lfs diff=lfs merge=lfs -text
checkpoint-50/config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151643,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 1536,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 8960,
12
+ "max_position_embeddings": 131072,
13
+ "max_window_layers": 21,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 28,
17
+ "num_key_value_heads": 2,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_scaling": null,
20
+ "rope_theta": 10000,
21
+ "sliding_window": 4096,
22
+ "tie_word_embeddings": false,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.51.3",
25
+ "use_cache": false,
26
+ "use_mrope": false,
27
+ "use_sliding_window": false,
28
+ "vocab_size": 151936
29
+ }
checkpoint-50/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 151646,
4
+ "do_sample": true,
5
+ "eos_token_id": 151643,
6
+ "temperature": 0.6,
7
+ "top_p": 0.95,
8
+ "transformers_version": "4.51.3"
9
+ }
checkpoint-50/global_step50/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:91d7c570818e17eb9ab3d9ae7da2250dd3386b9963c16dcd7c5565ace1d8a93e
3
+ size 5331274140
checkpoint-50/global_step50/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:44355a401f12fe6307ce7dcf46f858069d68aa77f8a352af856c85d4f7da3b13
3
+ size 5331276572
checkpoint-50/global_step50/bf16_zero_pp_rank_2_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5892e1e0f390290083273b8ecb8c4d7b8d319d1bdf1bba8691422a20a3ab5238
3
+ size 5331276892
checkpoint-50/global_step50/bf16_zero_pp_rank_3_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:033640c9cfff1ef111212298b54e1c71bcf5a8d771aef23fb159f63321449e90
3
+ size 5331273884
checkpoint-50/global_step50/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40d1ced7859b138c6413c062b7b58e13408329bb2aa51798612db6c433fe21cc
3
+ size 3554267640
checkpoint-50/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step50
checkpoint-50/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:043f5828ba1c5fdc0d6334b95cff05d103ac73a819210704d61baeba4d74f7f1
3
+ size 3554214752
checkpoint-50/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a04e0b9305701446f23b9582b13a3fe09b979b2a0a46755e9563668f6bcd9f98
3
+ size 14960
checkpoint-50/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75e617a81f157ddf6265fa6f6b15772fb2fe43b32574e5d292761d35a09c935e
3
+ size 14960
checkpoint-50/rng_state_2.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba62a9b51f7be56e70b89f9674e52a48962a8ef0024092930fdc60a98451602e
3
+ size 14960
checkpoint-50/rng_state_3.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:471f502e874ddb3cb44bf26cb93d72265dbce7e4618ff6175d009e941c7295ed
3
+ size 14960
checkpoint-50/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b1eb06383f9abe538d3bacb9e95a3d1b19c21cae1dfb62d8567723fcc11b74a
3
+ size 1064
checkpoint-50/special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|begin▁of▁sentence|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|end▁of▁sentence|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|end▁of▁sentence|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
checkpoint-50/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4256422650d141f228fe954acee98679da412984c29a569877eefd3af69315a
3
+ size 11422959
checkpoint-50/tokenizer_config.json ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "151643": {
7
+ "content": "<|end▁of▁sentence|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "151644": {
15
+ "content": "<|User|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": false
21
+ },
22
+ "151645": {
23
+ "content": "<|Assistant|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": false
29
+ },
30
+ "151646": {
31
+ "content": "<|begin▁of▁sentence|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "151647": {
39
+ "content": "<|EOT|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "151648": {
47
+ "content": "<think>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "151649": {
55
+ "content": "</think>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "151650": {
63
+ "content": "<|quad_start|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "151651": {
71
+ "content": "<|quad_end|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "151652": {
79
+ "content": "<|vision_start|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "151653": {
87
+ "content": "<|vision_end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "151654": {
95
+ "content": "<|vision_pad|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "151655": {
103
+ "content": "<|image_pad|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "151656": {
111
+ "content": "<|video_pad|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "151657": {
119
+ "content": "<tool_call>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "151658": {
127
+ "content": "</tool_call>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "151659": {
135
+ "content": "<|fim_prefix|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "151660": {
143
+ "content": "<|fim_middle|>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "151661": {
151
+ "content": "<|fim_suffix|>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "151662": {
159
+ "content": "<|fim_pad|>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "151663": {
167
+ "content": "<|repo_name|>",
168
+ "lstrip": false,
169
+ "normalized": false,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "151664": {
175
+ "content": "<|file_sep|>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ }
182
+ },
183
+ "bos_token": "<|begin▁of▁sentence|>",
184
+ "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='') %}{%- for message in messages %}{%- if message['role'] == 'system' %}{% set ns.system_prompt = message['content'] %}{%- endif %}{%- endfor %}{{bos_token}}{{ns.system_prompt}}{%- for message in messages %}{%- if message['role'] == 'user' %}{%- set ns.is_tool = false -%}{{'<|User|>' + message['content']}}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is none %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls']%}{%- if not ns.is_first %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin��>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{%- set ns.is_first = true -%}{%- else %}{{'\\n' + '<|tool▁call▁begin|>' + tool['type'] + '<|tool▁sep|>' + tool['function']['name'] + '\\n' + '```json' + '\\n' + tool['function']['arguments'] + '\\n' + '```' + '<|tool▁call▁end|>'}}{{'<|tool▁calls▁end|><|end▁of▁sentence|>'}}{%- endif %}{%- endfor %}{%- endif %}{%- if message['role'] == 'assistant' and message['content'] is not none %}{%- if ns.is_tool %}{{'<|tool▁outputs▁end|>' + message['content'] + '<|end▁of▁sentence|>'}}{%- set ns.is_tool = false -%}{%- else %}{% set content = message['content'] %}{% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %}{{'<|Assistant|>' + content + '<|end▁of▁sentence|>'}}{%- endif %}{%- endif %}{%- if message['role'] == 'tool' %}{%- set ns.is_tool = true -%}{%- if ns.is_output_first %}{{'<|tool▁outputs▁begin|><|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- set ns.is_output_first = false %}{%- else %}{{'\\n<|tool▁output▁begin|>' + message['content'] + '<|tool▁output▁end|>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|><think>\\n'}}{% endif %}",
185
+ "clean_up_tokenization_spaces": false,
186
+ "eos_token": "<|end▁of▁sentence|>",
187
+ "extra_special_tokens": {},
188
+ "legacy": true,
189
+ "model_max_length": 16384,
190
+ "pad_token": "<|end▁of▁sentence|>",
191
+ "sp_model_kwargs": {},
192
+ "tokenizer_class": "LlamaTokenizerFast",
193
+ "unk_token": null,
194
+ "use_default_system_prompt": false
195
+ }
checkpoint-50/trainer_state.json ADDED
@@ -0,0 +1,1284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.05714285714285714,
6
+ "eval_steps": 500,
7
+ "global_step": 50,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "clip_ratio/high_max": 0.0,
14
+ "clip_ratio/high_mean": 0.0,
15
+ "clip_ratio/low_mean": 0.0,
16
+ "clip_ratio/low_min": 0.0,
17
+ "clip_ratio/region_mean": 0.0,
18
+ "completions/clipped_ratio": 0.671875,
19
+ "completions/max_length": 2048.0,
20
+ "completions/max_terminated_length": 1734.0,
21
+ "completions/mean_length": 1702.03125,
22
+ "completions/mean_terminated_length": 993.6190795898438,
23
+ "completions/min_length": 483.0,
24
+ "completions/min_terminated_length": 483.0,
25
+ "epoch": 0.001142857142857143,
26
+ "frac_reward_zero_std": 0.0,
27
+ "grad_norm": 0.2837146520614624,
28
+ "learning_rate": 0.0,
29
+ "loss": -0.0,
30
+ "num_tokens": 118418.0,
31
+ "reward": -0.09800112247467041,
32
+ "reward_std": 0.3028089702129364,
33
+ "rewards/cosine_scaled_reward/mean": -0.09800112992525101,
34
+ "rewards/cosine_scaled_reward/std": 0.37953105568885803,
35
+ "step": 1
36
+ },
37
+ {
38
+ "clip_ratio/high_max": 0.0,
39
+ "clip_ratio/high_mean": 0.0,
40
+ "clip_ratio/low_mean": 0.0,
41
+ "clip_ratio/low_min": 0.0,
42
+ "clip_ratio/region_mean": 0.0,
43
+ "completions/clipped_ratio": 0.71875,
44
+ "completions/max_length": 2048.0,
45
+ "completions/max_terminated_length": 1894.0,
46
+ "completions/mean_length": 1738.90625,
47
+ "completions/mean_terminated_length": 949.0,
48
+ "completions/min_length": 435.0,
49
+ "completions/min_terminated_length": 435.0,
50
+ "epoch": 0.002285714285714286,
51
+ "frac_reward_zero_std": 0.0,
52
+ "grad_norm": 0.24220912158489227,
53
+ "learning_rate": 2e-08,
54
+ "loss": -0.0,
55
+ "num_tokens": 239748.0,
56
+ "reward": 0.020556632429361343,
57
+ "reward_std": 0.3545936942100525,
58
+ "rewards/cosine_scaled_reward/mean": 0.020556632429361343,
59
+ "rewards/cosine_scaled_reward/std": 0.4492928683757782,
60
+ "step": 2
61
+ },
62
+ {
63
+ "clip_ratio/high_max": 0.0,
64
+ "clip_ratio/high_mean": 0.0,
65
+ "clip_ratio/low_mean": 0.0,
66
+ "clip_ratio/low_min": 0.0,
67
+ "clip_ratio/region_mean": 0.0,
68
+ "completions/clipped_ratio": 0.921875,
69
+ "completions/max_length": 2048.0,
70
+ "completions/max_terminated_length": 869.0,
71
+ "completions/mean_length": 1946.515625,
72
+ "completions/mean_terminated_length": 749.0,
73
+ "completions/min_length": 609.0,
74
+ "completions/min_terminated_length": 609.0,
75
+ "epoch": 0.0034285714285714284,
76
+ "frac_reward_zero_std": 0.0,
77
+ "grad_norm": 0.24765528738498688,
78
+ "learning_rate": 4e-08,
79
+ "loss": -0.0,
80
+ "num_tokens": 374797.0,
81
+ "reward": -0.20057085156440735,
82
+ "reward_std": 0.13691216707229614,
83
+ "rewards/cosine_scaled_reward/mean": -0.20057085156440735,
84
+ "rewards/cosine_scaled_reward/std": 0.16282624006271362,
85
+ "step": 3
86
+ },
87
+ {
88
+ "clip_ratio/high_max": 0.0,
89
+ "clip_ratio/high_mean": 0.0,
90
+ "clip_ratio/low_mean": 0.0,
91
+ "clip_ratio/low_min": 0.0,
92
+ "clip_ratio/region_mean": 0.0,
93
+ "completions/clipped_ratio": 0.578125,
94
+ "completions/max_length": 2048.0,
95
+ "completions/max_terminated_length": 1983.0,
96
+ "completions/mean_length": 1592.0,
97
+ "completions/mean_terminated_length": 967.1111450195312,
98
+ "completions/min_length": 516.0,
99
+ "completions/min_terminated_length": 516.0,
100
+ "epoch": 0.004571428571428572,
101
+ "frac_reward_zero_std": 0.0,
102
+ "grad_norm": 0.28862521052360535,
103
+ "learning_rate": 6e-08,
104
+ "loss": 0.0,
105
+ "num_tokens": 486493.0,
106
+ "reward": -0.19111667573451996,
107
+ "reward_std": 0.19739457964897156,
108
+ "rewards/cosine_scaled_reward/mean": -0.19111669063568115,
109
+ "rewards/cosine_scaled_reward/std": 0.22545036673545837,
110
+ "step": 4
111
+ },
112
+ {
113
+ "clip_ratio/high_max": 0.0,
114
+ "clip_ratio/high_mean": 0.0,
115
+ "clip_ratio/low_mean": 0.0,
116
+ "clip_ratio/low_min": 0.0,
117
+ "clip_ratio/region_mean": 0.0,
118
+ "completions/clipped_ratio": 0.890625,
119
+ "completions/max_length": 2048.0,
120
+ "completions/max_terminated_length": 1939.0,
121
+ "completions/mean_length": 1976.578125,
122
+ "completions/mean_terminated_length": 1395.0001220703125,
123
+ "completions/min_length": 610.0,
124
+ "completions/min_terminated_length": 610.0,
125
+ "epoch": 0.005714285714285714,
126
+ "frac_reward_zero_std": 0.0,
127
+ "grad_norm": 0.23521216213703156,
128
+ "learning_rate": 8e-08,
129
+ "loss": 0.0,
130
+ "num_tokens": 623810.0,
131
+ "reward": -0.2342512309551239,
132
+ "reward_std": 0.16005605459213257,
133
+ "rewards/cosine_scaled_reward/mean": -0.2342512309551239,
134
+ "rewards/cosine_scaled_reward/std": 0.20709452033042908,
135
+ "step": 5
136
+ },
137
+ {
138
+ "clip_ratio/high_max": 0.0,
139
+ "clip_ratio/high_mean": 0.0,
140
+ "clip_ratio/low_mean": 0.0,
141
+ "clip_ratio/low_min": 0.0,
142
+ "clip_ratio/region_mean": 0.0,
143
+ "completions/clipped_ratio": 0.8125,
144
+ "completions/max_length": 2048.0,
145
+ "completions/max_terminated_length": 1987.0,
146
+ "completions/mean_length": 1840.125,
147
+ "completions/mean_terminated_length": 939.3333740234375,
148
+ "completions/min_length": 552.0,
149
+ "completions/min_terminated_length": 552.0,
150
+ "epoch": 0.006857142857142857,
151
+ "frac_reward_zero_std": 0.0,
152
+ "grad_norm": 0.2831529676914215,
153
+ "learning_rate": 1e-07,
154
+ "loss": 0.0,
155
+ "num_tokens": 753226.0,
156
+ "reward": -0.1443408578634262,
157
+ "reward_std": 0.25838011503219604,
158
+ "rewards/cosine_scaled_reward/mean": -0.1443408727645874,
159
+ "rewards/cosine_scaled_reward/std": 0.3164331316947937,
160
+ "step": 6
161
+ },
162
+ {
163
+ "clip_ratio/high_max": 0.0,
164
+ "clip_ratio/high_mean": 0.0,
165
+ "clip_ratio/low_mean": 0.0,
166
+ "clip_ratio/low_min": 0.0,
167
+ "clip_ratio/region_mean": 0.0,
168
+ "completions/clipped_ratio": 0.875,
169
+ "completions/max_length": 2048.0,
170
+ "completions/max_terminated_length": 2002.0,
171
+ "completions/mean_length": 1974.265625,
172
+ "completions/mean_terminated_length": 1458.125,
173
+ "completions/min_length": 1153.0,
174
+ "completions/min_terminated_length": 1153.0,
175
+ "epoch": 0.008,
176
+ "frac_reward_zero_std": 0.0,
177
+ "grad_norm": 0.22311581671237946,
178
+ "learning_rate": 1.2e-07,
179
+ "loss": 0.0,
180
+ "num_tokens": 889987.0,
181
+ "reward": -0.15585696697235107,
182
+ "reward_std": 0.21075330674648285,
183
+ "rewards/cosine_scaled_reward/mean": -0.15585698187351227,
184
+ "rewards/cosine_scaled_reward/std": 0.3327982723712921,
185
+ "step": 7
186
+ },
187
+ {
188
+ "clip_ratio/high_max": 0.0,
189
+ "clip_ratio/high_mean": 0.0,
190
+ "clip_ratio/low_mean": 0.0,
191
+ "clip_ratio/low_min": 0.0,
192
+ "clip_ratio/region_mean": 0.0,
193
+ "completions/clipped_ratio": 0.71875,
194
+ "completions/max_length": 2048.0,
195
+ "completions/max_terminated_length": 1411.0,
196
+ "completions/mean_length": 1701.46875,
197
+ "completions/mean_terminated_length": 815.888916015625,
198
+ "completions/min_length": 346.0,
199
+ "completions/min_terminated_length": 346.0,
200
+ "epoch": 0.009142857142857144,
201
+ "frac_reward_zero_std": 0.0,
202
+ "grad_norm": 0.23218390345573425,
203
+ "learning_rate": 1.4e-07,
204
+ "loss": -0.0,
205
+ "num_tokens": 1009297.0,
206
+ "reward": -0.019736051559448242,
207
+ "reward_std": 0.22464922070503235,
208
+ "rewards/cosine_scaled_reward/mean": -0.01973605342209339,
209
+ "rewards/cosine_scaled_reward/std": 0.46309077739715576,
210
+ "step": 8
211
+ },
212
+ {
213
+ "clip_ratio/high_max": 0.0,
214
+ "clip_ratio/high_mean": 0.0,
215
+ "clip_ratio/low_mean": 0.0,
216
+ "clip_ratio/low_min": 0.0,
217
+ "clip_ratio/region_mean": 0.0,
218
+ "completions/clipped_ratio": 0.859375,
219
+ "completions/max_length": 2048.0,
220
+ "completions/max_terminated_length": 1836.0,
221
+ "completions/mean_length": 1936.96875,
222
+ "completions/mean_terminated_length": 1258.4444580078125,
223
+ "completions/min_length": 839.0,
224
+ "completions/min_terminated_length": 839.0,
225
+ "epoch": 0.010285714285714285,
226
+ "frac_reward_zero_std": 0.0,
227
+ "grad_norm": 0.2455250322818756,
228
+ "learning_rate": 1.6e-07,
229
+ "loss": -0.0,
230
+ "num_tokens": 1144719.0,
231
+ "reward": -0.22108668088912964,
232
+ "reward_std": 0.20550987124443054,
233
+ "rewards/cosine_scaled_reward/mean": -0.22108666598796844,
234
+ "rewards/cosine_scaled_reward/std": 0.27375248074531555,
235
+ "step": 9
236
+ },
237
+ {
238
+ "clip_ratio/high_max": 0.0,
239
+ "clip_ratio/high_mean": 0.0,
240
+ "clip_ratio/low_mean": 0.0,
241
+ "clip_ratio/low_min": 0.0,
242
+ "clip_ratio/region_mean": 0.0,
243
+ "completions/clipped_ratio": 0.6875,
244
+ "completions/max_length": 2048.0,
245
+ "completions/max_terminated_length": 1579.0,
246
+ "completions/mean_length": 1662.0625,
247
+ "completions/mean_terminated_length": 813.0,
248
+ "completions/min_length": 389.0,
249
+ "completions/min_terminated_length": 389.0,
250
+ "epoch": 0.011428571428571429,
251
+ "frac_reward_zero_std": 0.0,
252
+ "grad_norm": 0.26574036478996277,
253
+ "learning_rate": 1.8e-07,
254
+ "loss": -0.0,
255
+ "num_tokens": 1261923.0,
256
+ "reward": -0.140568345785141,
257
+ "reward_std": 0.2796468734741211,
258
+ "rewards/cosine_scaled_reward/mean": -0.140568345785141,
259
+ "rewards/cosine_scaled_reward/std": 0.35179150104522705,
260
+ "step": 10
261
+ },
262
+ {
263
+ "clip_ratio/high_max": 0.0,
264
+ "clip_ratio/high_mean": 0.0,
265
+ "clip_ratio/low_mean": 0.0,
266
+ "clip_ratio/low_min": 0.0,
267
+ "clip_ratio/region_mean": 0.0,
268
+ "completions/clipped_ratio": 0.921875,
269
+ "completions/max_length": 2048.0,
270
+ "completions/max_terminated_length": 1335.0,
271
+ "completions/mean_length": 1970.859375,
272
+ "completions/mean_terminated_length": 1060.5999755859375,
273
+ "completions/min_length": 906.0,
274
+ "completions/min_terminated_length": 906.0,
275
+ "epoch": 0.012571428571428572,
276
+ "frac_reward_zero_std": 0.0,
277
+ "grad_norm": 0.24890610575675964,
278
+ "learning_rate": 2e-07,
279
+ "loss": -0.0,
280
+ "num_tokens": 1399730.0,
281
+ "reward": -0.2551690638065338,
282
+ "reward_std": 0.16209062933921814,
283
+ "rewards/cosine_scaled_reward/mean": -0.2551690638065338,
284
+ "rewards/cosine_scaled_reward/std": 0.2319207787513733,
285
+ "step": 11
286
+ },
287
+ {
288
+ "clip_ratio/high_max": 0.0,
289
+ "clip_ratio/high_mean": 0.0,
290
+ "clip_ratio/low_mean": 0.0,
291
+ "clip_ratio/low_min": 0.0,
292
+ "clip_ratio/region_mean": 0.0,
293
+ "completions/clipped_ratio": 0.65625,
294
+ "completions/max_length": 2048.0,
295
+ "completions/max_terminated_length": 2031.0,
296
+ "completions/mean_length": 1798.71875,
297
+ "completions/mean_terminated_length": 1322.8182373046875,
298
+ "completions/min_length": 724.0,
299
+ "completions/min_terminated_length": 724.0,
300
+ "epoch": 0.013714285714285714,
301
+ "frac_reward_zero_std": 0.0,
302
+ "grad_norm": 0.2804766595363617,
303
+ "learning_rate": 2.1999999999999998e-07,
304
+ "loss": 0.0,
305
+ "num_tokens": 1525792.0,
306
+ "reward": -0.19796784222126007,
307
+ "reward_std": 0.30078738927841187,
308
+ "rewards/cosine_scaled_reward/mean": -0.19796785712242126,
309
+ "rewards/cosine_scaled_reward/std": 0.3346545696258545,
310
+ "step": 12
311
+ },
312
+ {
313
+ "clip_ratio/high_max": 0.0,
314
+ "clip_ratio/high_mean": 0.0,
315
+ "clip_ratio/low_mean": 0.0,
316
+ "clip_ratio/low_min": 0.0,
317
+ "clip_ratio/region_mean": 0.0,
318
+ "completions/clipped_ratio": 0.75,
319
+ "completions/max_length": 2048.0,
320
+ "completions/max_terminated_length": 1800.0,
321
+ "completions/mean_length": 1816.890625,
322
+ "completions/mean_terminated_length": 1123.5625,
323
+ "completions/min_length": 583.0,
324
+ "completions/min_terminated_length": 583.0,
325
+ "epoch": 0.014857142857142857,
326
+ "frac_reward_zero_std": 0.0,
327
+ "grad_norm": 0.2471778392791748,
328
+ "learning_rate": 2.4e-07,
329
+ "loss": -0.0,
330
+ "num_tokens": 1653113.0,
331
+ "reward": -0.17365078628063202,
332
+ "reward_std": 0.23729698359966278,
333
+ "rewards/cosine_scaled_reward/mean": -0.17365078628063202,
334
+ "rewards/cosine_scaled_reward/std": 0.2726025879383087,
335
+ "step": 13
336
+ },
337
+ {
338
+ "clip_ratio/high_max": 0.0,
339
+ "clip_ratio/high_mean": 0.0,
340
+ "clip_ratio/low_mean": 0.0,
341
+ "clip_ratio/low_min": 0.0,
342
+ "clip_ratio/region_mean": 0.0,
343
+ "completions/clipped_ratio": 0.734375,
344
+ "completions/max_length": 2048.0,
345
+ "completions/max_terminated_length": 1529.0,
346
+ "completions/mean_length": 1815.046875,
347
+ "completions/mean_terminated_length": 1171.0,
348
+ "completions/min_length": 639.0,
349
+ "completions/min_terminated_length": 639.0,
350
+ "epoch": 0.016,
351
+ "frac_reward_zero_std": 0.0,
352
+ "grad_norm": 0.22734108567237854,
353
+ "learning_rate": 2.6e-07,
354
+ "loss": 0.0,
355
+ "num_tokens": 1779884.0,
356
+ "reward": -0.086978480219841,
357
+ "reward_std": 0.2551291584968567,
358
+ "rewards/cosine_scaled_reward/mean": -0.0869784876704216,
359
+ "rewards/cosine_scaled_reward/std": 0.4508184790611267,
360
+ "step": 14
361
+ },
362
+ {
363
+ "clip_ratio/high_max": 0.0,
364
+ "clip_ratio/high_mean": 0.0,
365
+ "clip_ratio/low_mean": 0.0,
366
+ "clip_ratio/low_min": 0.0,
367
+ "clip_ratio/region_mean": 0.0,
368
+ "completions/clipped_ratio": 0.734375,
369
+ "completions/max_length": 2048.0,
370
+ "completions/max_terminated_length": 1354.0,
371
+ "completions/mean_length": 1705.421875,
372
+ "completions/mean_terminated_length": 758.2941284179688,
373
+ "completions/min_length": 429.0,
374
+ "completions/min_terminated_length": 429.0,
375
+ "epoch": 0.017142857142857144,
376
+ "frac_reward_zero_std": 0.0,
377
+ "grad_norm": 0.25105422735214233,
378
+ "learning_rate": 2.8e-07,
379
+ "loss": -0.0,
380
+ "num_tokens": 1899951.0,
381
+ "reward": 0.025415867567062378,
382
+ "reward_std": 0.13560885190963745,
383
+ "rewards/cosine_scaled_reward/mean": 0.025415875017642975,
384
+ "rewards/cosine_scaled_reward/std": 0.4663754105567932,
385
+ "step": 15
386
+ },
387
+ {
388
+ "clip_ratio/high_max": 0.0,
389
+ "clip_ratio/high_mean": 0.0,
390
+ "clip_ratio/low_mean": 0.0,
391
+ "clip_ratio/low_min": 0.0,
392
+ "clip_ratio/region_mean": 0.0,
393
+ "completions/clipped_ratio": 1.0,
394
+ "completions/max_length": 2048.0,
395
+ "completions/max_terminated_length": 0.0,
396
+ "completions/mean_length": 2048.0,
397
+ "completions/mean_terminated_length": 0.0,
398
+ "completions/min_length": 2048.0,
399
+ "completions/min_terminated_length": 0.0,
400
+ "epoch": 0.018285714285714287,
401
+ "frac_reward_zero_std": 0.0,
402
+ "grad_norm": 0.23334357142448425,
403
+ "learning_rate": 3e-07,
404
+ "loss": -0.0,
405
+ "num_tokens": 2041463.0,
406
+ "reward": -0.2220873385667801,
407
+ "reward_std": 0.17581966519355774,
408
+ "rewards/cosine_scaled_reward/mean": -0.2220873236656189,
409
+ "rewards/cosine_scaled_reward/std": 0.1694367378950119,
410
+ "step": 16
411
+ },
412
+ {
413
+ "clip_ratio/high_max": 0.0,
414
+ "clip_ratio/high_mean": 0.0,
415
+ "clip_ratio/low_mean": 0.0,
416
+ "clip_ratio/low_min": 0.0,
417
+ "clip_ratio/region_mean": 0.0,
418
+ "completions/clipped_ratio": 0.546875,
419
+ "completions/max_length": 2048.0,
420
+ "completions/max_terminated_length": 1898.0,
421
+ "completions/mean_length": 1524.9375,
422
+ "completions/mean_terminated_length": 893.6551513671875,
423
+ "completions/min_length": 343.0,
424
+ "completions/min_terminated_length": 343.0,
425
+ "epoch": 0.019428571428571427,
426
+ "frac_reward_zero_std": 0.0,
427
+ "grad_norm": 0.33780622482299805,
428
+ "learning_rate": 3.2e-07,
429
+ "loss": -0.0,
430
+ "num_tokens": 2149579.0,
431
+ "reward": -0.026115939021110535,
432
+ "reward_std": 0.3175298571586609,
433
+ "rewards/cosine_scaled_reward/mean": -0.026115931570529938,
434
+ "rewards/cosine_scaled_reward/std": 0.4766712486743927,
435
+ "step": 17
436
+ },
437
+ {
438
+ "clip_ratio/high_max": 0.0,
439
+ "clip_ratio/high_mean": 0.0,
440
+ "clip_ratio/low_mean": 0.0,
441
+ "clip_ratio/low_min": 0.0,
442
+ "clip_ratio/region_mean": 0.0,
443
+ "completions/clipped_ratio": 0.703125,
444
+ "completions/max_length": 2048.0,
445
+ "completions/max_terminated_length": 1635.0,
446
+ "completions/mean_length": 1771.34375,
447
+ "completions/mean_terminated_length": 1116.105224609375,
448
+ "completions/min_length": 538.0,
449
+ "completions/min_terminated_length": 538.0,
450
+ "epoch": 0.02057142857142857,
451
+ "frac_reward_zero_std": 0.0,
452
+ "grad_norm": 0.23123449087142944,
453
+ "learning_rate": 3.4000000000000003e-07,
454
+ "loss": -0.0,
455
+ "num_tokens": 2273321.0,
456
+ "reward": -0.15853706002235413,
457
+ "reward_std": 0.27896177768707275,
458
+ "rewards/cosine_scaled_reward/mean": -0.15853706002235413,
459
+ "rewards/cosine_scaled_reward/std": 0.3426607847213745,
460
+ "step": 18
461
+ },
462
+ {
463
+ "clip_ratio/high_max": 0.0,
464
+ "clip_ratio/high_mean": 0.0,
465
+ "clip_ratio/low_mean": 0.0,
466
+ "clip_ratio/low_min": 0.0,
467
+ "clip_ratio/region_mean": 0.0,
468
+ "completions/clipped_ratio": 0.734375,
469
+ "completions/max_length": 2048.0,
470
+ "completions/max_terminated_length": 2013.0,
471
+ "completions/mean_length": 1811.953125,
472
+ "completions/mean_terminated_length": 1159.3529052734375,
473
+ "completions/min_length": 484.0,
474
+ "completions/min_terminated_length": 484.0,
475
+ "epoch": 0.021714285714285714,
476
+ "frac_reward_zero_std": 0.0,
477
+ "grad_norm": 0.25707289576530457,
478
+ "learning_rate": 3.6e-07,
479
+ "loss": -0.0,
480
+ "num_tokens": 2400542.0,
481
+ "reward": -0.052606794983148575,
482
+ "reward_std": 0.31571486592292786,
483
+ "rewards/cosine_scaled_reward/mean": -0.052606794983148575,
484
+ "rewards/cosine_scaled_reward/std": 0.44901713728904724,
485
+ "step": 19
486
+ },
487
+ {
488
+ "clip_ratio/high_max": 0.0,
489
+ "clip_ratio/high_mean": 0.0,
490
+ "clip_ratio/low_mean": 0.0,
491
+ "clip_ratio/low_min": 0.0,
492
+ "clip_ratio/region_mean": 0.0,
493
+ "completions/clipped_ratio": 0.65625,
494
+ "completions/max_length": 2048.0,
495
+ "completions/max_terminated_length": 1807.0,
496
+ "completions/mean_length": 1632.953125,
497
+ "completions/mean_terminated_length": 840.5909423828125,
498
+ "completions/min_length": 379.0,
499
+ "completions/min_terminated_length": 379.0,
500
+ "epoch": 0.022857142857142857,
501
+ "frac_reward_zero_std": 0.0,
502
+ "grad_norm": 0.25764355063438416,
503
+ "learning_rate": 3.7999999999999996e-07,
504
+ "loss": 0.0,
505
+ "num_tokens": 2516403.0,
506
+ "reward": -0.07391424477100372,
507
+ "reward_std": 0.2678168714046478,
508
+ "rewards/cosine_scaled_reward/mean": -0.07391423732042313,
509
+ "rewards/cosine_scaled_reward/std": 0.3888758718967438,
510
+ "step": 20
511
+ },
512
+ {
513
+ "clip_ratio/high_max": 0.0,
514
+ "clip_ratio/high_mean": 0.0,
515
+ "clip_ratio/low_mean": 0.0,
516
+ "clip_ratio/low_min": 0.0,
517
+ "clip_ratio/region_mean": 0.0,
518
+ "completions/clipped_ratio": 0.75,
519
+ "completions/max_length": 2048.0,
520
+ "completions/max_terminated_length": 1854.0,
521
+ "completions/mean_length": 1820.125,
522
+ "completions/mean_terminated_length": 1136.5,
523
+ "completions/min_length": 344.0,
524
+ "completions/min_terminated_length": 344.0,
525
+ "epoch": 0.024,
526
+ "frac_reward_zero_std": 0.0,
527
+ "grad_norm": 0.27439141273498535,
528
+ "learning_rate": 4e-07,
529
+ "loss": 0.0,
530
+ "num_tokens": 2643699.0,
531
+ "reward": -0.16270118951797485,
532
+ "reward_std": 0.22588439285755157,
533
+ "rewards/cosine_scaled_reward/mean": -0.16270118951797485,
534
+ "rewards/cosine_scaled_reward/std": 0.39143073558807373,
535
+ "step": 21
536
+ },
537
+ {
538
+ "clip_ratio/high_max": 0.0,
539
+ "clip_ratio/high_mean": 0.0,
540
+ "clip_ratio/low_mean": 0.0,
541
+ "clip_ratio/low_min": 0.0,
542
+ "clip_ratio/region_mean": 0.0,
543
+ "completions/clipped_ratio": 0.40625,
544
+ "completions/max_length": 2048.0,
545
+ "completions/max_terminated_length": 1741.0,
546
+ "completions/mean_length": 1271.359375,
547
+ "completions/mean_terminated_length": 739.9736938476562,
548
+ "completions/min_length": 282.0,
549
+ "completions/min_terminated_length": 282.0,
550
+ "epoch": 0.025142857142857144,
551
+ "frac_reward_zero_std": 0.0,
552
+ "grad_norm": 0.37971845269203186,
553
+ "learning_rate": 4.1999999999999995e-07,
554
+ "loss": -0.0,
555
+ "num_tokens": 2734082.0,
556
+ "reward": -0.00552794337272644,
557
+ "reward_std": 0.23386958241462708,
558
+ "rewards/cosine_scaled_reward/mean": -0.005527939647436142,
559
+ "rewards/cosine_scaled_reward/std": 0.4625597596168518,
560
+ "step": 22
561
+ },
562
+ {
563
+ "clip_ratio/high_max": 0.0,
564
+ "clip_ratio/high_mean": 0.0,
565
+ "clip_ratio/low_mean": 0.0,
566
+ "clip_ratio/low_min": 0.0,
567
+ "clip_ratio/region_mean": 0.0,
568
+ "completions/clipped_ratio": 0.609375,
569
+ "completions/max_length": 2048.0,
570
+ "completions/max_terminated_length": 1935.0,
571
+ "completions/mean_length": 1670.296875,
572
+ "completions/mean_terminated_length": 1081.0799560546875,
573
+ "completions/min_length": 472.0,
574
+ "completions/min_terminated_length": 472.0,
575
+ "epoch": 0.026285714285714287,
576
+ "frac_reward_zero_std": 0.0,
577
+ "grad_norm": 0.28573453426361084,
578
+ "learning_rate": 4.3999999999999997e-07,
579
+ "loss": 0.0,
580
+ "num_tokens": 2851773.0,
581
+ "reward": -0.18269123136997223,
582
+ "reward_std": 0.2168647199869156,
583
+ "rewards/cosine_scaled_reward/mean": -0.18269124627113342,
584
+ "rewards/cosine_scaled_reward/std": 0.2703794836997986,
585
+ "step": 23
586
+ },
587
+ {
588
+ "clip_ratio/high_max": 0.0,
589
+ "clip_ratio/high_mean": 0.0,
590
+ "clip_ratio/low_mean": 0.0,
591
+ "clip_ratio/low_min": 0.0,
592
+ "clip_ratio/region_mean": 0.0,
593
+ "completions/clipped_ratio": 0.703125,
594
+ "completions/max_length": 2048.0,
595
+ "completions/max_terminated_length": 1802.0,
596
+ "completions/mean_length": 1757.296875,
597
+ "completions/mean_terminated_length": 1068.7894287109375,
598
+ "completions/min_length": 327.0,
599
+ "completions/min_terminated_length": 327.0,
600
+ "epoch": 0.027428571428571427,
601
+ "frac_reward_zero_std": 0.0,
602
+ "grad_norm": 0.2553797662258148,
603
+ "learning_rate": 4.6e-07,
604
+ "loss": 0.0,
605
+ "num_tokens": 2975168.0,
606
+ "reward": -0.23130035400390625,
607
+ "reward_std": 0.35076260566711426,
608
+ "rewards/cosine_scaled_reward/mean": -0.23130035400390625,
609
+ "rewards/cosine_scaled_reward/std": 0.3866168260574341,
610
+ "step": 24
611
+ },
612
+ {
613
+ "clip_ratio/high_max": 0.0,
614
+ "clip_ratio/high_mean": 0.0,
615
+ "clip_ratio/low_mean": 0.0,
616
+ "clip_ratio/low_min": 0.0,
617
+ "clip_ratio/region_mean": 0.0,
618
+ "completions/clipped_ratio": 0.75,
619
+ "completions/max_length": 2048.0,
620
+ "completions/max_terminated_length": 1584.0,
621
+ "completions/mean_length": 1744.28125,
622
+ "completions/mean_terminated_length": 833.125,
623
+ "completions/min_length": 504.0,
624
+ "completions/min_terminated_length": 504.0,
625
+ "epoch": 0.02857142857142857,
626
+ "frac_reward_zero_std": 0.0,
627
+ "grad_norm": 0.2636294960975647,
628
+ "learning_rate": 4.8e-07,
629
+ "loss": -0.0,
630
+ "num_tokens": 3097098.0,
631
+ "reward": -0.19239474833011627,
632
+ "reward_std": 0.2867633104324341,
633
+ "rewards/cosine_scaled_reward/mean": -0.19239474833011627,
634
+ "rewards/cosine_scaled_reward/std": 0.347222238779068,
635
+ "step": 25
636
+ },
637
+ {
638
+ "clip_ratio/high_max": 0.0,
639
+ "clip_ratio/high_mean": 0.0,
640
+ "clip_ratio/low_mean": 0.0,
641
+ "clip_ratio/low_min": 0.0,
642
+ "clip_ratio/region_mean": 0.0,
643
+ "completions/clipped_ratio": 0.796875,
644
+ "completions/max_length": 2048.0,
645
+ "completions/max_terminated_length": 2033.0,
646
+ "completions/mean_length": 1932.09375,
647
+ "completions/mean_terminated_length": 1477.3846435546875,
648
+ "completions/min_length": 895.0,
649
+ "completions/min_terminated_length": 895.0,
650
+ "epoch": 0.029714285714285714,
651
+ "frac_reward_zero_std": 0.0,
652
+ "grad_norm": 0.22351376712322235,
653
+ "learning_rate": 5e-07,
654
+ "loss": -0.0,
655
+ "num_tokens": 3231384.0,
656
+ "reward": -0.006307817995548248,
657
+ "reward_std": 0.2015555500984192,
658
+ "rewards/cosine_scaled_reward/mean": -0.006307825446128845,
659
+ "rewards/cosine_scaled_reward/std": 0.4079793393611908,
660
+ "step": 26
661
+ },
662
+ {
663
+ "clip_ratio/high_max": 0.0,
664
+ "clip_ratio/high_mean": 0.0,
665
+ "clip_ratio/low_mean": 0.0,
666
+ "clip_ratio/low_min": 0.0,
667
+ "clip_ratio/region_mean": 0.0,
668
+ "completions/clipped_ratio": 0.8125,
669
+ "completions/max_length": 2048.0,
670
+ "completions/max_terminated_length": 1974.0,
671
+ "completions/mean_length": 1899.25,
672
+ "completions/mean_terminated_length": 1254.666748046875,
673
+ "completions/min_length": 545.0,
674
+ "completions/min_terminated_length": 545.0,
675
+ "epoch": 0.030857142857142857,
676
+ "frac_reward_zero_std": 0.0,
677
+ "grad_norm": 0.2670150697231293,
678
+ "learning_rate": 5.2e-07,
679
+ "loss": -0.0,
680
+ "num_tokens": 3363224.0,
681
+ "reward": -0.22071197628974915,
682
+ "reward_std": 0.2118011713027954,
683
+ "rewards/cosine_scaled_reward/mean": -0.22071197628974915,
684
+ "rewards/cosine_scaled_reward/std": 0.2716290354728699,
685
+ "step": 27
686
+ },
687
+ {
688
+ "clip_ratio/high_max": 0.0,
689
+ "clip_ratio/high_mean": 0.0,
690
+ "clip_ratio/low_mean": 0.0,
691
+ "clip_ratio/low_min": 0.0,
692
+ "clip_ratio/region_mean": 0.0,
693
+ "completions/clipped_ratio": 0.75,
694
+ "completions/max_length": 2048.0,
695
+ "completions/max_terminated_length": 1947.0,
696
+ "completions/mean_length": 1767.609375,
697
+ "completions/mean_terminated_length": 926.4375,
698
+ "completions/min_length": 438.0,
699
+ "completions/min_terminated_length": 438.0,
700
+ "epoch": 0.032,
701
+ "frac_reward_zero_std": 0.0,
702
+ "grad_norm": 0.25918784737586975,
703
+ "learning_rate": 5.4e-07,
704
+ "loss": -0.0,
705
+ "num_tokens": 3486687.0,
706
+ "reward": -0.10919298231601715,
707
+ "reward_std": 0.2716072201728821,
708
+ "rewards/cosine_scaled_reward/mean": -0.10919298231601715,
709
+ "rewards/cosine_scaled_reward/std": 0.44544270634651184,
710
+ "step": 28
711
+ },
712
+ {
713
+ "clip_ratio/high_max": 0.0,
714
+ "clip_ratio/high_mean": 0.0,
715
+ "clip_ratio/low_mean": 0.0,
716
+ "clip_ratio/low_min": 0.0,
717
+ "clip_ratio/region_mean": 0.0,
718
+ "completions/clipped_ratio": 0.890625,
719
+ "completions/max_length": 2048.0,
720
+ "completions/max_terminated_length": 1951.0,
721
+ "completions/mean_length": 1932.203125,
722
+ "completions/mean_terminated_length": 989.2857666015625,
723
+ "completions/min_length": 603.0,
724
+ "completions/min_terminated_length": 603.0,
725
+ "epoch": 0.03314285714285714,
726
+ "frac_reward_zero_std": 0.0,
727
+ "grad_norm": 0.24401192367076874,
728
+ "learning_rate": 5.6e-07,
729
+ "loss": 0.0,
730
+ "num_tokens": 3620820.0,
731
+ "reward": -0.19096782803535461,
732
+ "reward_std": 0.15806984901428223,
733
+ "rewards/cosine_scaled_reward/mean": -0.19096782803535461,
734
+ "rewards/cosine_scaled_reward/std": 0.181764155626297,
735
+ "step": 29
736
+ },
737
+ {
738
+ "clip_ratio/high_max": 0.0,
739
+ "clip_ratio/high_mean": 0.0,
740
+ "clip_ratio/low_mean": 0.0,
741
+ "clip_ratio/low_min": 0.0,
742
+ "clip_ratio/region_mean": 0.0,
743
+ "completions/clipped_ratio": 0.765625,
744
+ "completions/max_length": 2048.0,
745
+ "completions/max_terminated_length": 1928.0,
746
+ "completions/mean_length": 1880.71875,
747
+ "completions/mean_terminated_length": 1334.2667236328125,
748
+ "completions/min_length": 604.0,
749
+ "completions/min_terminated_length": 604.0,
750
+ "epoch": 0.03428571428571429,
751
+ "frac_reward_zero_std": 0.0,
752
+ "grad_norm": 0.22094956040382385,
753
+ "learning_rate": 5.8e-07,
754
+ "loss": -0.0,
755
+ "num_tokens": 3751722.0,
756
+ "reward": -0.21267297863960266,
757
+ "reward_std": 0.24843861162662506,
758
+ "rewards/cosine_scaled_reward/mean": -0.21267297863960266,
759
+ "rewards/cosine_scaled_reward/std": 0.29802343249320984,
760
+ "step": 30
761
+ },
762
+ {
763
+ "clip_ratio/high_max": 0.0,
764
+ "clip_ratio/high_mean": 0.0,
765
+ "clip_ratio/low_mean": 0.0,
766
+ "clip_ratio/low_min": 0.0,
767
+ "clip_ratio/region_mean": 0.0,
768
+ "completions/clipped_ratio": 0.78125,
769
+ "completions/max_length": 2048.0,
770
+ "completions/max_terminated_length": 1348.0,
771
+ "completions/mean_length": 1786.234375,
772
+ "completions/mean_terminated_length": 851.357177734375,
773
+ "completions/min_length": 355.0,
774
+ "completions/min_terminated_length": 355.0,
775
+ "epoch": 0.03542857142857143,
776
+ "frac_reward_zero_std": 0.0,
777
+ "grad_norm": 0.2912121117115021,
778
+ "learning_rate": 6e-07,
779
+ "loss": -0.0,
780
+ "num_tokens": 3876537.0,
781
+ "reward": -0.2621557414531708,
782
+ "reward_std": 0.18612943589687347,
783
+ "rewards/cosine_scaled_reward/mean": -0.2621557414531708,
784
+ "rewards/cosine_scaled_reward/std": 0.22891530394554138,
785
+ "step": 31
786
+ },
787
+ {
788
+ "clip_ratio/high_max": 0.0,
789
+ "clip_ratio/high_mean": 0.0,
790
+ "clip_ratio/low_mean": 0.0,
791
+ "clip_ratio/low_min": 0.0,
792
+ "clip_ratio/region_mean": 0.0,
793
+ "completions/clipped_ratio": 0.859375,
794
+ "completions/max_length": 2048.0,
795
+ "completions/max_terminated_length": 1841.0,
796
+ "completions/mean_length": 1948.765625,
797
+ "completions/mean_terminated_length": 1342.3333740234375,
798
+ "completions/min_length": 536.0,
799
+ "completions/min_terminated_length": 536.0,
800
+ "epoch": 0.036571428571428574,
801
+ "frac_reward_zero_std": 0.0,
802
+ "grad_norm": 0.2303810715675354,
803
+ "learning_rate": 6.2e-07,
804
+ "loss": 0.0,
805
+ "num_tokens": 4011610.0,
806
+ "reward": -0.1655973494052887,
807
+ "reward_std": 0.2392224669456482,
808
+ "rewards/cosine_scaled_reward/mean": -0.1655973345041275,
809
+ "rewards/cosine_scaled_reward/std": 0.3260692358016968,
810
+ "step": 32
811
+ },
812
+ {
813
+ "clip_ratio/high_max": 0.0,
814
+ "clip_ratio/high_mean": 0.0,
815
+ "clip_ratio/low_mean": 0.0,
816
+ "clip_ratio/low_min": 0.0,
817
+ "clip_ratio/region_mean": 0.0,
818
+ "completions/clipped_ratio": 0.90625,
819
+ "completions/max_length": 2048.0,
820
+ "completions/max_terminated_length": 1972.0,
821
+ "completions/mean_length": 1984.0,
822
+ "completions/mean_terminated_length": 1365.3333740234375,
823
+ "completions/min_length": 965.0,
824
+ "completions/min_terminated_length": 965.0,
825
+ "epoch": 0.037714285714285714,
826
+ "frac_reward_zero_std": 0.0,
827
+ "grad_norm": 0.23169051110744476,
828
+ "learning_rate": 6.4e-07,
829
+ "loss": 0.0,
830
+ "num_tokens": 4149802.0,
831
+ "reward": -0.22799505293369293,
832
+ "reward_std": 0.24000275135040283,
833
+ "rewards/cosine_scaled_reward/mean": -0.22799506783485413,
834
+ "rewards/cosine_scaled_reward/std": 0.30748653411865234,
835
+ "step": 33
836
+ },
837
+ {
838
+ "clip_ratio/high_max": 0.0,
839
+ "clip_ratio/high_mean": 0.0,
840
+ "clip_ratio/low_mean": 0.0,
841
+ "clip_ratio/low_min": 0.0,
842
+ "clip_ratio/region_mean": 0.0,
843
+ "completions/clipped_ratio": 0.609375,
844
+ "completions/max_length": 2048.0,
845
+ "completions/max_terminated_length": 1977.0,
846
+ "completions/mean_length": 1700.859375,
847
+ "completions/mean_terminated_length": 1159.3199462890625,
848
+ "completions/min_length": 433.0,
849
+ "completions/min_terminated_length": 433.0,
850
+ "epoch": 0.038857142857142854,
851
+ "frac_reward_zero_std": 0.0,
852
+ "grad_norm": 0.2647433578968048,
853
+ "learning_rate": 6.6e-07,
854
+ "loss": 0.0,
855
+ "num_tokens": 4268209.0,
856
+ "reward": -0.07232969254255295,
857
+ "reward_std": 0.3570185899734497,
858
+ "rewards/cosine_scaled_reward/mean": -0.07232969999313354,
859
+ "rewards/cosine_scaled_reward/std": 0.4520716369152069,
860
+ "step": 34
861
+ },
862
+ {
863
+ "clip_ratio/high_max": 0.0,
864
+ "clip_ratio/high_mean": 0.0,
865
+ "clip_ratio/low_mean": 0.0,
866
+ "clip_ratio/low_min": 0.0,
867
+ "clip_ratio/region_mean": 0.0,
868
+ "completions/clipped_ratio": 0.875,
869
+ "completions/max_length": 2048.0,
870
+ "completions/max_terminated_length": 1458.0,
871
+ "completions/mean_length": 1884.625,
872
+ "completions/mean_terminated_length": 741.0,
873
+ "completions/min_length": 358.0,
874
+ "completions/min_terminated_length": 358.0,
875
+ "epoch": 0.04,
876
+ "frac_reward_zero_std": 0.0,
877
+ "grad_norm": 0.2681647539138794,
878
+ "learning_rate": 6.800000000000001e-07,
879
+ "loss": 0.0,
880
+ "num_tokens": 4400321.0,
881
+ "reward": -0.21119418740272522,
882
+ "reward_std": 0.2156996876001358,
883
+ "rewards/cosine_scaled_reward/mean": -0.21119415760040283,
884
+ "rewards/cosine_scaled_reward/std": 0.304564893245697,
885
+ "step": 35
886
+ },
887
+ {
888
+ "clip_ratio/high_max": 0.0,
889
+ "clip_ratio/high_mean": 0.0,
890
+ "clip_ratio/low_mean": 0.0,
891
+ "clip_ratio/low_min": 0.0,
892
+ "clip_ratio/region_mean": 0.0,
893
+ "completions/clipped_ratio": 0.96875,
894
+ "completions/max_length": 2048.0,
895
+ "completions/max_terminated_length": 2002.0,
896
+ "completions/mean_length": 2032.765625,
897
+ "completions/mean_terminated_length": 1560.5,
898
+ "completions/min_length": 1119.0,
899
+ "completions/min_terminated_length": 1119.0,
900
+ "epoch": 0.04114285714285714,
901
+ "frac_reward_zero_std": 0.0,
902
+ "grad_norm": 0.25201615691185,
903
+ "learning_rate": 7e-07,
904
+ "loss": -0.0,
905
+ "num_tokens": 4541530.0,
906
+ "reward": -0.2148258090019226,
907
+ "reward_std": 0.1970210075378418,
908
+ "rewards/cosine_scaled_reward/mean": -0.2148257941007614,
909
+ "rewards/cosine_scaled_reward/std": 0.21921320259571075,
910
+ "step": 36
911
+ },
912
+ {
913
+ "clip_ratio/high_max": 0.0,
914
+ "clip_ratio/high_mean": 0.0,
915
+ "clip_ratio/low_mean": 0.0,
916
+ "clip_ratio/low_min": 0.0,
917
+ "clip_ratio/region_mean": 0.0,
918
+ "completions/clipped_ratio": 0.859375,
919
+ "completions/max_length": 2048.0,
920
+ "completions/max_terminated_length": 2005.0,
921
+ "completions/mean_length": 1954.5,
922
+ "completions/mean_terminated_length": 1383.111083984375,
923
+ "completions/min_length": 901.0,
924
+ "completions/min_terminated_length": 901.0,
925
+ "epoch": 0.04228571428571429,
926
+ "frac_reward_zero_std": 0.0,
927
+ "grad_norm": 0.29214274883270264,
928
+ "learning_rate": 7.2e-07,
929
+ "loss": 0.0,
930
+ "num_tokens": 4677642.0,
931
+ "reward": -0.23519155383110046,
932
+ "reward_std": 0.14085054397583008,
933
+ "rewards/cosine_scaled_reward/mean": -0.23519155383110046,
934
+ "rewards/cosine_scaled_reward/std": 0.17065586149692535,
935
+ "step": 37
936
+ },
937
+ {
938
+ "clip_ratio/high_max": 0.0,
939
+ "clip_ratio/high_mean": 0.0,
940
+ "clip_ratio/low_mean": 0.0,
941
+ "clip_ratio/low_min": 0.0,
942
+ "clip_ratio/region_mean": 0.0,
943
+ "completions/clipped_ratio": 0.875,
944
+ "completions/max_length": 2048.0,
945
+ "completions/max_terminated_length": 2016.0,
946
+ "completions/mean_length": 1949.1875,
947
+ "completions/mean_terminated_length": 1257.5,
948
+ "completions/min_length": 1042.0,
949
+ "completions/min_terminated_length": 1042.0,
950
+ "epoch": 0.04342857142857143,
951
+ "frac_reward_zero_std": 0.0,
952
+ "grad_norm": 0.2337840050458908,
953
+ "learning_rate": 7.4e-07,
954
+ "loss": -0.0,
955
+ "num_tokens": 4814102.0,
956
+ "reward": -0.16185586154460907,
957
+ "reward_std": 0.19152981042861938,
958
+ "rewards/cosine_scaled_reward/mean": -0.16185584664344788,
959
+ "rewards/cosine_scaled_reward/std": 0.3005273640155792,
960
+ "step": 38
961
+ },
962
+ {
963
+ "clip_ratio/high_max": 0.0,
964
+ "clip_ratio/high_mean": 0.0,
965
+ "clip_ratio/low_mean": 0.0,
966
+ "clip_ratio/low_min": 0.0,
967
+ "clip_ratio/region_mean": 0.0,
968
+ "completions/clipped_ratio": 0.828125,
969
+ "completions/max_length": 2048.0,
970
+ "completions/max_terminated_length": 1953.0,
971
+ "completions/mean_length": 1810.515625,
972
+ "completions/mean_terminated_length": 666.2727661132812,
973
+ "completions/min_length": 246.0,
974
+ "completions/min_terminated_length": 246.0,
975
+ "epoch": 0.044571428571428574,
976
+ "frac_reward_zero_std": 0.0,
977
+ "grad_norm": 0.246645987033844,
978
+ "learning_rate": 7.599999999999999e-07,
979
+ "loss": 0.0,
980
+ "num_tokens": 4940759.0,
981
+ "reward": -0.10980962216854095,
982
+ "reward_std": 0.18094567954540253,
983
+ "rewards/cosine_scaled_reward/mean": -0.10980962216854095,
984
+ "rewards/cosine_scaled_reward/std": 0.3624936640262604,
985
+ "step": 39
986
+ },
987
+ {
988
+ "clip_ratio/high_max": 0.0,
989
+ "clip_ratio/high_mean": 0.0,
990
+ "clip_ratio/low_mean": 0.0,
991
+ "clip_ratio/low_min": 0.0,
992
+ "clip_ratio/region_mean": 0.0,
993
+ "completions/clipped_ratio": 0.65625,
994
+ "completions/max_length": 2048.0,
995
+ "completions/max_terminated_length": 1754.0,
996
+ "completions/mean_length": 1700.796875,
997
+ "completions/mean_terminated_length": 1037.95458984375,
998
+ "completions/min_length": 524.0,
999
+ "completions/min_terminated_length": 524.0,
1000
+ "epoch": 0.045714285714285714,
1001
+ "frac_reward_zero_std": 0.0,
1002
+ "grad_norm": 0.26321786642074585,
1003
+ "learning_rate": 7.799999999999999e-07,
1004
+ "loss": -0.0,
1005
+ "num_tokens": 5059682.0,
1006
+ "reward": -0.14547404646873474,
1007
+ "reward_std": 0.22270715236663818,
1008
+ "rewards/cosine_scaled_reward/mean": -0.14547404646873474,
1009
+ "rewards/cosine_scaled_reward/std": 0.4000875651836395,
1010
+ "step": 40
1011
+ },
1012
+ {
1013
+ "clip_ratio/high_max": 0.0,
1014
+ "clip_ratio/high_mean": 0.0,
1015
+ "clip_ratio/low_mean": 0.0,
1016
+ "clip_ratio/low_min": 0.0,
1017
+ "clip_ratio/region_mean": 0.0,
1018
+ "completions/clipped_ratio": 0.703125,
1019
+ "completions/max_length": 2048.0,
1020
+ "completions/max_terminated_length": 1939.0,
1021
+ "completions/mean_length": 1860.328125,
1022
+ "completions/mean_terminated_length": 1415.8421630859375,
1023
+ "completions/min_length": 982.0,
1024
+ "completions/min_terminated_length": 982.0,
1025
+ "epoch": 0.046857142857142854,
1026
+ "frac_reward_zero_std": 0.0,
1027
+ "grad_norm": 0.21273446083068848,
1028
+ "learning_rate": 8e-07,
1029
+ "loss": -0.0,
1030
+ "num_tokens": 5189895.0,
1031
+ "reward": -0.24220962822437286,
1032
+ "reward_std": 0.27360057830810547,
1033
+ "rewards/cosine_scaled_reward/mean": -0.24220961332321167,
1034
+ "rewards/cosine_scaled_reward/std": 0.33429500460624695,
1035
+ "step": 41
1036
+ },
1037
+ {
1038
+ "clip_ratio/high_max": 0.0,
1039
+ "clip_ratio/high_mean": 0.0,
1040
+ "clip_ratio/low_mean": 0.0,
1041
+ "clip_ratio/low_min": 0.0,
1042
+ "clip_ratio/region_mean": 0.0,
1043
+ "completions/clipped_ratio": 0.765625,
1044
+ "completions/max_length": 2048.0,
1045
+ "completions/max_terminated_length": 1547.0,
1046
+ "completions/mean_length": 1694.375,
1047
+ "completions/mean_terminated_length": 539.2000122070312,
1048
+ "completions/min_length": 131.0,
1049
+ "completions/min_terminated_length": 131.0,
1050
+ "epoch": 0.048,
1051
+ "frac_reward_zero_std": 0.0,
1052
+ "grad_norm": 0.3549652099609375,
1053
+ "learning_rate": 8.199999999999999e-07,
1054
+ "loss": -0.0,
1055
+ "num_tokens": 5308695.0,
1056
+ "reward": -0.22589105367660522,
1057
+ "reward_std": 0.16009008884429932,
1058
+ "rewards/cosine_scaled_reward/mean": -0.22589105367660522,
1059
+ "rewards/cosine_scaled_reward/std": 0.17985297739505768,
1060
+ "step": 42
1061
+ },
1062
+ {
1063
+ "clip_ratio/high_max": 0.0,
1064
+ "clip_ratio/high_mean": 0.0,
1065
+ "clip_ratio/low_mean": 0.0,
1066
+ "clip_ratio/low_min": 0.0,
1067
+ "clip_ratio/region_mean": 0.0,
1068
+ "completions/clipped_ratio": 0.796875,
1069
+ "completions/max_length": 2048.0,
1070
+ "completions/max_terminated_length": 2006.0,
1071
+ "completions/mean_length": 1824.75,
1072
+ "completions/mean_terminated_length": 948.923095703125,
1073
+ "completions/min_length": 473.0,
1074
+ "completions/min_terminated_length": 473.0,
1075
+ "epoch": 0.04914285714285714,
1076
+ "frac_reward_zero_std": 0.0,
1077
+ "grad_norm": 0.25625720620155334,
1078
+ "learning_rate": 8.399999999999999e-07,
1079
+ "loss": -0.0,
1080
+ "num_tokens": 5437095.0,
1081
+ "reward": -0.10874830186367035,
1082
+ "reward_std": 0.2326180636882782,
1083
+ "rewards/cosine_scaled_reward/mean": -0.10874830186367035,
1084
+ "rewards/cosine_scaled_reward/std": 0.3275902569293976,
1085
+ "step": 43
1086
+ },
1087
+ {
1088
+ "clip_ratio/high_max": 0.0,
1089
+ "clip_ratio/high_mean": 0.0,
1090
+ "clip_ratio/low_mean": 0.0,
1091
+ "clip_ratio/low_min": 0.0,
1092
+ "clip_ratio/region_mean": 0.0,
1093
+ "completions/clipped_ratio": 0.703125,
1094
+ "completions/max_length": 2048.0,
1095
+ "completions/max_terminated_length": 1751.0,
1096
+ "completions/mean_length": 1673.734375,
1097
+ "completions/mean_terminated_length": 787.3157958984375,
1098
+ "completions/min_length": 484.0,
1099
+ "completions/min_terminated_length": 484.0,
1100
+ "epoch": 0.05028571428571429,
1101
+ "frac_reward_zero_std": 0.0,
1102
+ "grad_norm": 0.3032245934009552,
1103
+ "learning_rate": 8.599999999999999e-07,
1104
+ "loss": 0.0,
1105
+ "num_tokens": 5554910.0,
1106
+ "reward": -0.1157154068350792,
1107
+ "reward_std": 0.2323075234889984,
1108
+ "rewards/cosine_scaled_reward/mean": -0.1157153993844986,
1109
+ "rewards/cosine_scaled_reward/std": 0.4071435034275055,
1110
+ "step": 44
1111
+ },
1112
+ {
1113
+ "clip_ratio/high_max": 0.0,
1114
+ "clip_ratio/high_mean": 0.0,
1115
+ "clip_ratio/low_mean": 0.0,
1116
+ "clip_ratio/low_min": 0.0,
1117
+ "clip_ratio/region_mean": 0.0,
1118
+ "completions/clipped_ratio": 0.9375,
1119
+ "completions/max_length": 2048.0,
1120
+ "completions/max_terminated_length": 1931.0,
1121
+ "completions/mean_length": 2031.03125,
1122
+ "completions/mean_terminated_length": 1776.5,
1123
+ "completions/min_length": 1421.0,
1124
+ "completions/min_terminated_length": 1421.0,
1125
+ "epoch": 0.05142857142857143,
1126
+ "frac_reward_zero_std": 0.0,
1127
+ "grad_norm": 0.2320922464132309,
1128
+ "learning_rate": 8.799999999999999e-07,
1129
+ "loss": 0.0,
1130
+ "num_tokens": 5696552.0,
1131
+ "reward": -0.22731460630893707,
1132
+ "reward_std": 0.19835877418518066,
1133
+ "rewards/cosine_scaled_reward/mean": -0.22731460630893707,
1134
+ "rewards/cosine_scaled_reward/std": 0.28479474782943726,
1135
+ "step": 45
1136
+ },
1137
+ {
1138
+ "clip_ratio/high_max": 0.0,
1139
+ "clip_ratio/high_mean": 0.0,
1140
+ "clip_ratio/low_mean": 0.0,
1141
+ "clip_ratio/low_min": 0.0,
1142
+ "clip_ratio/region_mean": 0.0,
1143
+ "completions/clipped_ratio": 0.875,
1144
+ "completions/max_length": 2048.0,
1145
+ "completions/max_terminated_length": 981.0,
1146
+ "completions/mean_length": 1890.3125,
1147
+ "completions/mean_terminated_length": 786.5,
1148
+ "completions/min_length": 490.0,
1149
+ "completions/min_terminated_length": 490.0,
1150
+ "epoch": 0.052571428571428575,
1151
+ "frac_reward_zero_std": 0.0,
1152
+ "grad_norm": 0.2494276612997055,
1153
+ "learning_rate": 9e-07,
1154
+ "loss": 0.0,
1155
+ "num_tokens": 5828700.0,
1156
+ "reward": -0.23243775963783264,
1157
+ "reward_std": 0.18319474160671234,
1158
+ "rewards/cosine_scaled_reward/mean": -0.23243777453899384,
1159
+ "rewards/cosine_scaled_reward/std": 0.20973731577396393,
1160
+ "step": 46
1161
+ },
1162
+ {
1163
+ "clip_ratio/high_max": 0.0,
1164
+ "clip_ratio/high_mean": 0.0,
1165
+ "clip_ratio/low_mean": 0.0,
1166
+ "clip_ratio/low_min": 0.0,
1167
+ "clip_ratio/region_mean": 0.0,
1168
+ "completions/clipped_ratio": 0.71875,
1169
+ "completions/max_length": 2048.0,
1170
+ "completions/max_terminated_length": 1398.0,
1171
+ "completions/mean_length": 1672.09375,
1172
+ "completions/mean_terminated_length": 711.4444580078125,
1173
+ "completions/min_length": 303.0,
1174
+ "completions/min_terminated_length": 303.0,
1175
+ "epoch": 0.053714285714285714,
1176
+ "frac_reward_zero_std": 0.0,
1177
+ "grad_norm": 0.3419908881187439,
1178
+ "learning_rate": 9.2e-07,
1179
+ "loss": 0.0,
1180
+ "num_tokens": 5946114.0,
1181
+ "reward": -0.16157878935337067,
1182
+ "reward_std": 0.24494563043117523,
1183
+ "rewards/cosine_scaled_reward/mean": -0.16157880425453186,
1184
+ "rewards/cosine_scaled_reward/std": 0.39992472529411316,
1185
+ "step": 47
1186
+ },
1187
+ {
1188
+ "clip_ratio/high_max": 0.0,
1189
+ "clip_ratio/high_mean": 0.0,
1190
+ "clip_ratio/low_mean": 0.0,
1191
+ "clip_ratio/low_min": 0.0,
1192
+ "clip_ratio/region_mean": 0.0,
1193
+ "completions/clipped_ratio": 0.765625,
1194
+ "completions/max_length": 2048.0,
1195
+ "completions/max_terminated_length": 1501.0,
1196
+ "completions/mean_length": 1787.171875,
1197
+ "completions/mean_terminated_length": 935.1333618164062,
1198
+ "completions/min_length": 687.0,
1199
+ "completions/min_terminated_length": 687.0,
1200
+ "epoch": 0.054857142857142854,
1201
+ "frac_reward_zero_std": 0.0,
1202
+ "grad_norm": 0.25991642475128174,
1203
+ "learning_rate": 9.399999999999999e-07,
1204
+ "loss": 0.0,
1205
+ "num_tokens": 6071037.0,
1206
+ "reward": -0.1829870045185089,
1207
+ "reward_std": 0.2542135417461395,
1208
+ "rewards/cosine_scaled_reward/mean": -0.1829870045185089,
1209
+ "rewards/cosine_scaled_reward/std": 0.30597779154777527,
1210
+ "step": 48
1211
+ },
1212
+ {
1213
+ "clip_ratio/high_max": 0.0,
1214
+ "clip_ratio/high_mean": 0.0,
1215
+ "clip_ratio/low_mean": 0.0,
1216
+ "clip_ratio/low_min": 0.0,
1217
+ "clip_ratio/region_mean": 0.0,
1218
+ "completions/clipped_ratio": 0.5625,
1219
+ "completions/max_length": 2048.0,
1220
+ "completions/max_terminated_length": 1981.0,
1221
+ "completions/mean_length": 1565.34375,
1222
+ "completions/mean_terminated_length": 944.7857666015625,
1223
+ "completions/min_length": 322.0,
1224
+ "completions/min_terminated_length": 322.0,
1225
+ "epoch": 0.056,
1226
+ "frac_reward_zero_std": 0.0,
1227
+ "grad_norm": 0.27452352643013,
1228
+ "learning_rate": 9.6e-07,
1229
+ "loss": 0.0,
1230
+ "num_tokens": 6181283.0,
1231
+ "reward": -0.22301900386810303,
1232
+ "reward_std": 0.25131016969680786,
1233
+ "rewards/cosine_scaled_reward/mean": -0.22301900386810303,
1234
+ "rewards/cosine_scaled_reward/std": 0.2918049991130829,
1235
+ "step": 49
1236
+ },
1237
+ {
1238
+ "clip_ratio/high_max": 0.0,
1239
+ "clip_ratio/high_mean": 0.0,
1240
+ "clip_ratio/low_mean": 0.0,
1241
+ "clip_ratio/low_min": 0.0,
1242
+ "clip_ratio/region_mean": 0.0,
1243
+ "completions/clipped_ratio": 0.765625,
1244
+ "completions/max_length": 2048.0,
1245
+ "completions/max_terminated_length": 1947.0,
1246
+ "completions/mean_length": 1775.515625,
1247
+ "completions/mean_terminated_length": 885.4000244140625,
1248
+ "completions/min_length": 280.0,
1249
+ "completions/min_terminated_length": 280.0,
1250
+ "epoch": 0.05714285714285714,
1251
+ "frac_reward_zero_std": 0.0,
1252
+ "grad_norm": 0.22758428752422333,
1253
+ "learning_rate": 9.8e-07,
1254
+ "loss": 0.0,
1255
+ "num_tokens": 6305732.0,
1256
+ "reward": -0.10754476487636566,
1257
+ "reward_std": 0.18711507320404053,
1258
+ "rewards/cosine_scaled_reward/mean": -0.10754477977752686,
1259
+ "rewards/cosine_scaled_reward/std": 0.39105597138404846,
1260
+ "step": 50
1261
+ }
1262
+ ],
1263
+ "logging_steps": 1,
1264
+ "max_steps": 500,
1265
+ "num_input_tokens_seen": 6305732,
1266
+ "num_train_epochs": 1,
1267
+ "save_steps": 50,
1268
+ "stateful_callbacks": {
1269
+ "TrainerControl": {
1270
+ "args": {
1271
+ "should_epoch_stop": false,
1272
+ "should_evaluate": false,
1273
+ "should_log": false,
1274
+ "should_save": true,
1275
+ "should_training_stop": false
1276
+ },
1277
+ "attributes": {}
1278
+ }
1279
+ },
1280
+ "total_flos": 0.0,
1281
+ "train_batch_size": 4,
1282
+ "trial_name": null,
1283
+ "trial_params": null
1284
+ }
checkpoint-50/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b847efd20062b0cb1aebb8c261e138e047198d5f1277135c040d30f434a732d
3
+ size 8824
checkpoint-50/zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``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``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``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``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``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``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)