littlelobberster commited on
Commit
baea5c0
·
verified ·
1 Parent(s): 747c843

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +17 -0
  2. 2/README.md +62 -0
  3. 2/adapter_config.json +39 -0
  4. 2/adapter_model.safetensors +3 -0
  5. 2/added_tokens.json +28 -0
  6. 2/all_results.json +9 -0
  7. 2/checkpoint-100/README.md +202 -0
  8. 2/checkpoint-100/adapter_config.json +39 -0
  9. 2/checkpoint-100/adapter_model.safetensors +3 -0
  10. 2/checkpoint-100/added_tokens.json +28 -0
  11. 2/checkpoint-100/global_step100/mp_rank_00_model_states.pt +3 -0
  12. 2/checkpoint-100/global_step100/zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  13. 2/checkpoint-100/global_step100/zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  14. 2/checkpoint-100/latest +1 -0
  15. 2/checkpoint-100/merges.txt +0 -0
  16. 2/checkpoint-100/rng_state_0.pth +3 -0
  17. 2/checkpoint-100/rng_state_1.pth +3 -0
  18. 2/checkpoint-100/scheduler.pt +3 -0
  19. 2/checkpoint-100/special_tokens_map.json +31 -0
  20. 2/checkpoint-100/tokenizer.json +3 -0
  21. 2/checkpoint-100/tokenizer_config.json +241 -0
  22. 2/checkpoint-100/trainer_state.json +194 -0
  23. 2/checkpoint-100/training_args.bin +3 -0
  24. 2/checkpoint-100/vocab.json +0 -0
  25. 2/checkpoint-100/zero_to_fp32.py +760 -0
  26. 2/checkpoint-1000/README.md +202 -0
  27. 2/checkpoint-1000/adapter_config.json +39 -0
  28. 2/checkpoint-1000/adapter_model.safetensors +3 -0
  29. 2/checkpoint-1000/added_tokens.json +28 -0
  30. 2/checkpoint-1000/global_step1000/mp_rank_00_model_states.pt +3 -0
  31. 2/checkpoint-1000/global_step1000/zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  32. 2/checkpoint-1000/global_step1000/zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  33. 2/checkpoint-1000/latest +1 -0
  34. 2/checkpoint-1000/merges.txt +0 -0
  35. 2/checkpoint-1000/rng_state_0.pth +3 -0
  36. 2/checkpoint-1000/rng_state_1.pth +3 -0
  37. 2/checkpoint-1000/scheduler.pt +3 -0
  38. 2/checkpoint-1000/special_tokens_map.json +31 -0
  39. 2/checkpoint-1000/tokenizer.json +3 -0
  40. 2/checkpoint-1000/tokenizer_config.json +241 -0
  41. 2/checkpoint-1000/trainer_state.json +1634 -0
  42. 2/checkpoint-1000/training_args.bin +3 -0
  43. 2/checkpoint-1000/vocab.json +0 -0
  44. 2/checkpoint-1000/zero_to_fp32.py +760 -0
  45. 2/checkpoint-1100/README.md +202 -0
  46. 2/checkpoint-1100/adapter_config.json +39 -0
  47. 2/checkpoint-1100/adapter_model.safetensors +3 -0
  48. 2/checkpoint-1100/added_tokens.json +28 -0
  49. 2/checkpoint-1100/global_step1100/mp_rank_00_model_states.pt +3 -0
  50. 2/checkpoint-1100/global_step1100/zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
.gitattributes CHANGED
@@ -33,3 +33,20 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ 2/checkpoint-100/tokenizer.json filter=lfs diff=lfs merge=lfs -text
38
+ 2/checkpoint-1000/tokenizer.json filter=lfs diff=lfs merge=lfs -text
39
+ 2/checkpoint-1100/tokenizer.json filter=lfs diff=lfs merge=lfs -text
40
+ 2/checkpoint-1200/tokenizer.json filter=lfs diff=lfs merge=lfs -text
41
+ 2/checkpoint-1300/tokenizer.json filter=lfs diff=lfs merge=lfs -text
42
+ 2/checkpoint-1400/tokenizer.json filter=lfs diff=lfs merge=lfs -text
43
+ 2/checkpoint-1404/tokenizer.json filter=lfs diff=lfs merge=lfs -text
44
+ 2/checkpoint-200/tokenizer.json filter=lfs diff=lfs merge=lfs -text
45
+ 2/checkpoint-300/tokenizer.json filter=lfs diff=lfs merge=lfs -text
46
+ 2/checkpoint-400/tokenizer.json filter=lfs diff=lfs merge=lfs -text
47
+ 2/checkpoint-500/tokenizer.json filter=lfs diff=lfs merge=lfs -text
48
+ 2/checkpoint-600/tokenizer.json filter=lfs diff=lfs merge=lfs -text
49
+ 2/checkpoint-700/tokenizer.json filter=lfs diff=lfs merge=lfs -text
50
+ 2/checkpoint-800/tokenizer.json filter=lfs diff=lfs merge=lfs -text
51
+ 2/checkpoint-900/tokenizer.json filter=lfs diff=lfs merge=lfs -text
52
+ 2/tokenizer.json filter=lfs diff=lfs merge=lfs -text
2/README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: peft
3
+ license: other
4
+ base_model: /root/autodl-tmp/Qwen3-8B
5
+ tags:
6
+ - llama-factory
7
+ - lora
8
+ - generated_from_trainer
9
+ model-index:
10
+ - name: '2'
11
+ results: []
12
+ ---
13
+
14
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
15
+ should probably proofread and complete it, then remove this comment. -->
16
+
17
+ # 2
18
+
19
+ This model is a fine-tuned version of [/root/autodl-tmp/Qwen3-8B](https://huggingface.co//root/autodl-tmp/Qwen3-8B) on the LAW and the LAWlegal datasets.
20
+
21
+ ## Model description
22
+
23
+ More information needed
24
+
25
+ ## Intended uses & limitations
26
+
27
+ More information needed
28
+
29
+ ## Training and evaluation data
30
+
31
+ More information needed
32
+
33
+ ## Training procedure
34
+
35
+ ### Training hyperparameters
36
+
37
+ The following hyperparameters were used during training:
38
+ - learning_rate: 0.0001
39
+ - train_batch_size: 1
40
+ - eval_batch_size: 8
41
+ - seed: 42
42
+ - distributed_type: multi-GPU
43
+ - num_devices: 2
44
+ - gradient_accumulation_steps: 8
45
+ - total_train_batch_size: 16
46
+ - total_eval_batch_size: 16
47
+ - optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
48
+ - lr_scheduler_type: cosine
49
+ - num_epochs: 1.0
50
+ - mixed_precision_training: Native AMP
51
+
52
+ ### Training results
53
+
54
+
55
+
56
+ ### Framework versions
57
+
58
+ - PEFT 0.15.1
59
+ - Transformers 4.51.3
60
+ - Pytorch 2.3.0+cu121
61
+ - Datasets 3.5.0
62
+ - Tokenizers 0.21.0
2/adapter_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/root/autodl-tmp/Qwen3-8B",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 8,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "r": 4,
24
+ "rank_pattern": {},
25
+ "revision": null,
26
+ "target_modules": [
27
+ "q_proj",
28
+ "k_proj",
29
+ "v_proj",
30
+ "up_proj",
31
+ "down_proj",
32
+ "gate_proj",
33
+ "o_proj"
34
+ ],
35
+ "task_type": "CAUSAL_LM",
36
+ "trainable_token_indices": null,
37
+ "use_dora": false,
38
+ "use_rslora": true
39
+ }
2/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a8b269cca579b1edb239928e0d508ce1b9a87a02089570c091b785832df8bcd
3
+ size 21889736
2/added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|object_ref_end|>": 151647,
20
+ "<|object_ref_start|>": 151646,
21
+ "<|quad_end|>": 151651,
22
+ "<|quad_start|>": 151650,
23
+ "<|repo_name|>": 151663,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
2/all_results.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 0.9995550413811516,
3
+ "num_input_tokens_seen": 29121176,
4
+ "total_flos": 1.3243117909594604e+18,
5
+ "train_loss": 0.19406711987280778,
6
+ "train_runtime": 19252.8015,
7
+ "train_samples_per_second": 1.167,
8
+ "train_steps_per_second": 0.073
9
+ }
2/checkpoint-100/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /root/autodl-tmp/Qwen3-8B
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.15.1
2/checkpoint-100/adapter_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/root/autodl-tmp/Qwen3-8B",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 8,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "r": 4,
24
+ "rank_pattern": {},
25
+ "revision": null,
26
+ "target_modules": [
27
+ "q_proj",
28
+ "k_proj",
29
+ "v_proj",
30
+ "up_proj",
31
+ "down_proj",
32
+ "gate_proj",
33
+ "o_proj"
34
+ ],
35
+ "task_type": "CAUSAL_LM",
36
+ "trainable_token_indices": null,
37
+ "use_dora": false,
38
+ "use_rslora": true
39
+ }
2/checkpoint-100/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fe6ad31d909f41448594ba6946f7e00f439e6275f85fd4aee80fdd273d4e5c3
3
+ size 21889736
2/checkpoint-100/added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|object_ref_end|>": 151647,
20
+ "<|object_ref_start|>": 151646,
21
+ "<|quad_end|>": 151651,
22
+ "<|quad_start|>": 151650,
23
+ "<|repo_name|>": 151663,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
2/checkpoint-100/global_step100/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d40b8c4949d723df5ed2c9ea72d6290c4f8464a72c50f66a9caa526b3e3051b9
3
+ size 133228077
2/checkpoint-100/global_step100/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:7037c0521ea824ca44d0543c3100740c3b3aaf4190b5e3df1524b69b9b1d90cb
3
+ size 65501576
2/checkpoint-100/global_step100/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:2ce27b3ccfdf5ca6a8cd2398eca54fc0e59b06459f6c4970ff4d8137dd6c22d3
3
+ size 65501704
2/checkpoint-100/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step100
2/checkpoint-100/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
2/checkpoint-100/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8d6a959372d5e0c2ea025dd26c9d0ad2046fce19352056cae8074dcbd0a6fd4
3
+ size 14512
2/checkpoint-100/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f68a37892a1b445d21bb35cc10bf7a058a6f9ec8c363f5ed156ff4f49d90fb6
3
+ size 14512
2/checkpoint-100/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b89769ae34d6c4b2010219db05cd08bd2e022e9ebb9d70a0d02c0d5adec44d84
3
+ size 1064
2/checkpoint-100/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
2/checkpoint-100/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4
3
+ size 11422654
2/checkpoint-100/tokenizer_config.json ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ },
181
+ "151665": {
182
+ "content": "<tool_response>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": false
188
+ },
189
+ "151666": {
190
+ "content": "</tool_response>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": false
196
+ },
197
+ "151667": {
198
+ "content": "<think>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": false
204
+ },
205
+ "151668": {
206
+ "content": "</think>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": false
212
+ }
213
+ },
214
+ "additional_special_tokens": [
215
+ "<|im_start|>",
216
+ "<|im_end|>",
217
+ "<|object_ref_start|>",
218
+ "<|object_ref_end|>",
219
+ "<|box_start|>",
220
+ "<|box_end|>",
221
+ "<|quad_start|>",
222
+ "<|quad_end|>",
223
+ "<|vision_start|>",
224
+ "<|vision_end|>",
225
+ "<|vision_pad|>",
226
+ "<|image_pad|>",
227
+ "<|video_pad|>"
228
+ ],
229
+ "bos_token": null,
230
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in message.content %}\n {%- set content = message.content.split('</think>')[-1].lstrip('\\n') %}\n {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- if loop.index0 > ns.last_query_index %}\n {%- if loop.last or (not loop.last and reasoning_content) %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content.strip('\\n') + '\\n</think>\\n\\n' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- endif %}\n{%- endif %}",
231
+ "clean_up_tokenization_spaces": false,
232
+ "eos_token": "<|im_end|>",
233
+ "errors": "replace",
234
+ "extra_special_tokens": {},
235
+ "model_max_length": 131072,
236
+ "pad_token": "<|endoftext|>",
237
+ "padding_side": "right",
238
+ "split_special_tokens": false,
239
+ "tokenizer_class": "Qwen2Tokenizer",
240
+ "unk_token": null
241
+ }
2/checkpoint-100/trainer_state.json ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.07119337901575154,
6
+ "eval_steps": 500,
7
+ "global_step": 100,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.003559668950787577,
14
+ "grad_norm": 1.069462776184082,
15
+ "learning_rate": 9.999799726899262e-05,
16
+ "loss": 1.4623,
17
+ "num_input_tokens_seen": 97000,
18
+ "step": 5
19
+ },
20
+ {
21
+ "epoch": 0.007119337901575154,
22
+ "grad_norm": 0.6442700624465942,
23
+ "learning_rate": 9.998986144924251e-05,
24
+ "loss": 1.0085,
25
+ "num_input_tokens_seen": 185728,
26
+ "step": 10
27
+ },
28
+ {
29
+ "epoch": 0.01067900685236273,
30
+ "grad_norm": 0.7749446630477905,
31
+ "learning_rate": 9.997546838764065e-05,
32
+ "loss": 0.8166,
33
+ "num_input_tokens_seen": 274048,
34
+ "step": 15
35
+ },
36
+ {
37
+ "epoch": 0.014238675803150308,
38
+ "grad_norm": 0.6821078658103943,
39
+ "learning_rate": 9.995481988576968e-05,
40
+ "loss": 0.6584,
41
+ "num_input_tokens_seen": 395024,
42
+ "step": 20
43
+ },
44
+ {
45
+ "epoch": 0.017798344753937885,
46
+ "grad_norm": 0.6945608258247375,
47
+ "learning_rate": 9.992791852820709e-05,
48
+ "loss": 0.4809,
49
+ "num_input_tokens_seen": 484056,
50
+ "step": 25
51
+ },
52
+ {
53
+ "epoch": 0.02135801370472546,
54
+ "grad_norm": 0.30774927139282227,
55
+ "learning_rate": 9.989476768220168e-05,
56
+ "loss": 0.3719,
57
+ "num_input_tokens_seen": 588744,
58
+ "step": 30
59
+ },
60
+ {
61
+ "epoch": 0.024917682655513036,
62
+ "grad_norm": 0.3996995985507965,
63
+ "learning_rate": 9.985537149725205e-05,
64
+ "loss": 0.3598,
65
+ "num_input_tokens_seen": 687824,
66
+ "step": 35
67
+ },
68
+ {
69
+ "epoch": 0.028477351606300615,
70
+ "grad_norm": 0.26959237456321716,
71
+ "learning_rate": 9.980973490458728e-05,
72
+ "loss": 0.3405,
73
+ "num_input_tokens_seen": 810104,
74
+ "step": 40
75
+ },
76
+ {
77
+ "epoch": 0.03203702055708819,
78
+ "grad_norm": 0.26429229974746704,
79
+ "learning_rate": 9.97578636165496e-05,
80
+ "loss": 0.3165,
81
+ "num_input_tokens_seen": 910048,
82
+ "step": 45
83
+ },
84
+ {
85
+ "epoch": 0.03559668950787577,
86
+ "grad_norm": 0.32172468304634094,
87
+ "learning_rate": 9.969976412587944e-05,
88
+ "loss": 0.292,
89
+ "num_input_tokens_seen": 1022144,
90
+ "step": 50
91
+ },
92
+ {
93
+ "epoch": 0.039156358458663346,
94
+ "grad_norm": 0.28077825903892517,
95
+ "learning_rate": 9.96354437049027e-05,
96
+ "loss": 0.2923,
97
+ "num_input_tokens_seen": 1126152,
98
+ "step": 55
99
+ },
100
+ {
101
+ "epoch": 0.04271602740945092,
102
+ "grad_norm": 0.2883082926273346,
103
+ "learning_rate": 9.956491040462052e-05,
104
+ "loss": 0.2807,
105
+ "num_input_tokens_seen": 1252376,
106
+ "step": 60
107
+ },
108
+ {
109
+ "epoch": 0.0462756963602385,
110
+ "grad_norm": 0.314687043428421,
111
+ "learning_rate": 9.948817305370143e-05,
112
+ "loss": 0.2779,
113
+ "num_input_tokens_seen": 1353176,
114
+ "step": 65
115
+ },
116
+ {
117
+ "epoch": 0.04983536531102607,
118
+ "grad_norm": 0.38759657740592957,
119
+ "learning_rate": 9.94052412573764e-05,
120
+ "loss": 0.2632,
121
+ "num_input_tokens_seen": 1458928,
122
+ "step": 70
123
+ },
124
+ {
125
+ "epoch": 0.05339503426181365,
126
+ "grad_norm": 0.3042629063129425,
127
+ "learning_rate": 9.931612539623643e-05,
128
+ "loss": 0.28,
129
+ "num_input_tokens_seen": 1550808,
130
+ "step": 75
131
+ },
132
+ {
133
+ "epoch": 0.05695470321260123,
134
+ "grad_norm": 0.2713088393211365,
135
+ "learning_rate": 9.922083662493329e-05,
136
+ "loss": 0.2927,
137
+ "num_input_tokens_seen": 1658104,
138
+ "step": 80
139
+ },
140
+ {
141
+ "epoch": 0.060514372163388806,
142
+ "grad_norm": 0.2769795060157776,
143
+ "learning_rate": 9.911938687078324e-05,
144
+ "loss": 0.2728,
145
+ "num_input_tokens_seen": 1763840,
146
+ "step": 85
147
+ },
148
+ {
149
+ "epoch": 0.06407404111417637,
150
+ "grad_norm": 0.3135468363761902,
151
+ "learning_rate": 9.901178883227414e-05,
152
+ "loss": 0.2562,
153
+ "num_input_tokens_seen": 1885016,
154
+ "step": 90
155
+ },
156
+ {
157
+ "epoch": 0.06763371006496396,
158
+ "grad_norm": 0.3024243116378784,
159
+ "learning_rate": 9.889805597747588e-05,
160
+ "loss": 0.2564,
161
+ "num_input_tokens_seen": 2001056,
162
+ "step": 95
163
+ },
164
+ {
165
+ "epoch": 0.07119337901575154,
166
+ "grad_norm": 0.29715123772621155,
167
+ "learning_rate": 9.877820254235471e-05,
168
+ "loss": 0.2392,
169
+ "num_input_tokens_seen": 2076528,
170
+ "step": 100
171
+ }
172
+ ],
173
+ "logging_steps": 5,
174
+ "max_steps": 1404,
175
+ "num_input_tokens_seen": 2076528,
176
+ "num_train_epochs": 1,
177
+ "save_steps": 100,
178
+ "stateful_callbacks": {
179
+ "TrainerControl": {
180
+ "args": {
181
+ "should_epoch_stop": false,
182
+ "should_evaluate": false,
183
+ "should_log": false,
184
+ "should_save": true,
185
+ "should_training_stop": false
186
+ },
187
+ "attributes": {}
188
+ }
189
+ },
190
+ "total_flos": 9.443198752731955e+16,
191
+ "train_batch_size": 1,
192
+ "trial_name": null,
193
+ "trial_params": null
194
+ }
2/checkpoint-100/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53d6f2b6ddc39413c7f5106d4dfc20a60221e892597125a4051acc98e75cf41e
3
+ size 7352
2/checkpoint-100/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
2/checkpoint-100/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)
2/checkpoint-1000/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /root/autodl-tmp/Qwen3-8B
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.15.1
2/checkpoint-1000/adapter_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/root/autodl-tmp/Qwen3-8B",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 8,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "r": 4,
24
+ "rank_pattern": {},
25
+ "revision": null,
26
+ "target_modules": [
27
+ "q_proj",
28
+ "k_proj",
29
+ "v_proj",
30
+ "up_proj",
31
+ "down_proj",
32
+ "gate_proj",
33
+ "o_proj"
34
+ ],
35
+ "task_type": "CAUSAL_LM",
36
+ "trainable_token_indices": null,
37
+ "use_dora": false,
38
+ "use_rslora": true
39
+ }
2/checkpoint-1000/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ea33f60b95b36233813970b1cad9aebe8d9f0bf1379369bdac3623d2f62af7f
3
+ size 21889736
2/checkpoint-1000/added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|object_ref_end|>": 151647,
20
+ "<|object_ref_start|>": 151646,
21
+ "<|quad_end|>": 151651,
22
+ "<|quad_start|>": 151650,
23
+ "<|repo_name|>": 151663,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
2/checkpoint-1000/global_step1000/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e82d63a880cfb762ee5a1095a9b9c8394f33ab337ec8d6e8ca21d5c4e95d4be
3
+ size 133228077
2/checkpoint-1000/global_step1000/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:9ca6ecd594b87e44bb2fe093cb7a59f8eab0f8bd785157765d6e294cb1c95159
3
+ size 65501576
2/checkpoint-1000/global_step1000/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:39cae1e945fe56433b3281f0469ce50930c8a438658f65ebde8e8e499ccbc08c
3
+ size 65501704
2/checkpoint-1000/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step1000
2/checkpoint-1000/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
2/checkpoint-1000/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8d6a959372d5e0c2ea025dd26c9d0ad2046fce19352056cae8074dcbd0a6fd4
3
+ size 14512
2/checkpoint-1000/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f68a37892a1b445d21bb35cc10bf7a058a6f9ec8c363f5ed156ff4f49d90fb6
3
+ size 14512
2/checkpoint-1000/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ea813e47c515744a6308c8143c3b1d70b704d9e8500020af4d6e28d64e8ebe0
3
+ size 1064
2/checkpoint-1000/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
2/checkpoint-1000/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4
3
+ size 11422654
2/checkpoint-1000/tokenizer_config.json ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ },
181
+ "151665": {
182
+ "content": "<tool_response>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": false
188
+ },
189
+ "151666": {
190
+ "content": "</tool_response>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": false
196
+ },
197
+ "151667": {
198
+ "content": "<think>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": false
204
+ },
205
+ "151668": {
206
+ "content": "</think>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": false
212
+ }
213
+ },
214
+ "additional_special_tokens": [
215
+ "<|im_start|>",
216
+ "<|im_end|>",
217
+ "<|object_ref_start|>",
218
+ "<|object_ref_end|>",
219
+ "<|box_start|>",
220
+ "<|box_end|>",
221
+ "<|quad_start|>",
222
+ "<|quad_end|>",
223
+ "<|vision_start|>",
224
+ "<|vision_end|>",
225
+ "<|vision_pad|>",
226
+ "<|image_pad|>",
227
+ "<|video_pad|>"
228
+ ],
229
+ "bos_token": null,
230
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in message.content %}\n {%- set content = message.content.split('</think>')[-1].lstrip('\\n') %}\n {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- if loop.index0 > ns.last_query_index %}\n {%- if loop.last or (not loop.last and reasoning_content) %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content.strip('\\n') + '\\n</think>\\n\\n' + content.lstrip('\\n') }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- endif %}\n{%- endif %}",
231
+ "clean_up_tokenization_spaces": false,
232
+ "eos_token": "<|im_end|>",
233
+ "errors": "replace",
234
+ "extra_special_tokens": {},
235
+ "model_max_length": 131072,
236
+ "pad_token": "<|endoftext|>",
237
+ "padding_side": "right",
238
+ "split_special_tokens": false,
239
+ "tokenizer_class": "Qwen2Tokenizer",
240
+ "unk_token": null
241
+ }
2/checkpoint-1000/trainer_state.json ADDED
@@ -0,0 +1,1634 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.7119337901575153,
6
+ "eval_steps": 500,
7
+ "global_step": 1000,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.003559668950787577,
14
+ "grad_norm": 1.069462776184082,
15
+ "learning_rate": 9.999799726899262e-05,
16
+ "loss": 1.4623,
17
+ "num_input_tokens_seen": 97000,
18
+ "step": 5
19
+ },
20
+ {
21
+ "epoch": 0.007119337901575154,
22
+ "grad_norm": 0.6442700624465942,
23
+ "learning_rate": 9.998986144924251e-05,
24
+ "loss": 1.0085,
25
+ "num_input_tokens_seen": 185728,
26
+ "step": 10
27
+ },
28
+ {
29
+ "epoch": 0.01067900685236273,
30
+ "grad_norm": 0.7749446630477905,
31
+ "learning_rate": 9.997546838764065e-05,
32
+ "loss": 0.8166,
33
+ "num_input_tokens_seen": 274048,
34
+ "step": 15
35
+ },
36
+ {
37
+ "epoch": 0.014238675803150308,
38
+ "grad_norm": 0.6821078658103943,
39
+ "learning_rate": 9.995481988576968e-05,
40
+ "loss": 0.6584,
41
+ "num_input_tokens_seen": 395024,
42
+ "step": 20
43
+ },
44
+ {
45
+ "epoch": 0.017798344753937885,
46
+ "grad_norm": 0.6945608258247375,
47
+ "learning_rate": 9.992791852820709e-05,
48
+ "loss": 0.4809,
49
+ "num_input_tokens_seen": 484056,
50
+ "step": 25
51
+ },
52
+ {
53
+ "epoch": 0.02135801370472546,
54
+ "grad_norm": 0.30774927139282227,
55
+ "learning_rate": 9.989476768220168e-05,
56
+ "loss": 0.3719,
57
+ "num_input_tokens_seen": 588744,
58
+ "step": 30
59
+ },
60
+ {
61
+ "epoch": 0.024917682655513036,
62
+ "grad_norm": 0.3996995985507965,
63
+ "learning_rate": 9.985537149725205e-05,
64
+ "loss": 0.3598,
65
+ "num_input_tokens_seen": 687824,
66
+ "step": 35
67
+ },
68
+ {
69
+ "epoch": 0.028477351606300615,
70
+ "grad_norm": 0.26959237456321716,
71
+ "learning_rate": 9.980973490458728e-05,
72
+ "loss": 0.3405,
73
+ "num_input_tokens_seen": 810104,
74
+ "step": 40
75
+ },
76
+ {
77
+ "epoch": 0.03203702055708819,
78
+ "grad_norm": 0.26429229974746704,
79
+ "learning_rate": 9.97578636165496e-05,
80
+ "loss": 0.3165,
81
+ "num_input_tokens_seen": 910048,
82
+ "step": 45
83
+ },
84
+ {
85
+ "epoch": 0.03559668950787577,
86
+ "grad_norm": 0.32172468304634094,
87
+ "learning_rate": 9.969976412587944e-05,
88
+ "loss": 0.292,
89
+ "num_input_tokens_seen": 1022144,
90
+ "step": 50
91
+ },
92
+ {
93
+ "epoch": 0.039156358458663346,
94
+ "grad_norm": 0.28077825903892517,
95
+ "learning_rate": 9.96354437049027e-05,
96
+ "loss": 0.2923,
97
+ "num_input_tokens_seen": 1126152,
98
+ "step": 55
99
+ },
100
+ {
101
+ "epoch": 0.04271602740945092,
102
+ "grad_norm": 0.2883082926273346,
103
+ "learning_rate": 9.956491040462052e-05,
104
+ "loss": 0.2807,
105
+ "num_input_tokens_seen": 1252376,
106
+ "step": 60
107
+ },
108
+ {
109
+ "epoch": 0.0462756963602385,
110
+ "grad_norm": 0.314687043428421,
111
+ "learning_rate": 9.948817305370143e-05,
112
+ "loss": 0.2779,
113
+ "num_input_tokens_seen": 1353176,
114
+ "step": 65
115
+ },
116
+ {
117
+ "epoch": 0.04983536531102607,
118
+ "grad_norm": 0.38759657740592957,
119
+ "learning_rate": 9.94052412573764e-05,
120
+ "loss": 0.2632,
121
+ "num_input_tokens_seen": 1458928,
122
+ "step": 70
123
+ },
124
+ {
125
+ "epoch": 0.05339503426181365,
126
+ "grad_norm": 0.3042629063129425,
127
+ "learning_rate": 9.931612539623643e-05,
128
+ "loss": 0.28,
129
+ "num_input_tokens_seen": 1550808,
130
+ "step": 75
131
+ },
132
+ {
133
+ "epoch": 0.05695470321260123,
134
+ "grad_norm": 0.2713088393211365,
135
+ "learning_rate": 9.922083662493329e-05,
136
+ "loss": 0.2927,
137
+ "num_input_tokens_seen": 1658104,
138
+ "step": 80
139
+ },
140
+ {
141
+ "epoch": 0.060514372163388806,
142
+ "grad_norm": 0.2769795060157776,
143
+ "learning_rate": 9.911938687078324e-05,
144
+ "loss": 0.2728,
145
+ "num_input_tokens_seen": 1763840,
146
+ "step": 85
147
+ },
148
+ {
149
+ "epoch": 0.06407404111417637,
150
+ "grad_norm": 0.3135468363761902,
151
+ "learning_rate": 9.901178883227414e-05,
152
+ "loss": 0.2562,
153
+ "num_input_tokens_seen": 1885016,
154
+ "step": 90
155
+ },
156
+ {
157
+ "epoch": 0.06763371006496396,
158
+ "grad_norm": 0.3024243116378784,
159
+ "learning_rate": 9.889805597747588e-05,
160
+ "loss": 0.2564,
161
+ "num_input_tokens_seen": 2001056,
162
+ "step": 95
163
+ },
164
+ {
165
+ "epoch": 0.07119337901575154,
166
+ "grad_norm": 0.29715123772621155,
167
+ "learning_rate": 9.877820254235471e-05,
168
+ "loss": 0.2392,
169
+ "num_input_tokens_seen": 2076528,
170
+ "step": 100
171
+ },
172
+ {
173
+ "epoch": 0.07475304796653912,
174
+ "grad_norm": 0.3076399564743042,
175
+ "learning_rate": 9.865224352899119e-05,
176
+ "loss": 0.264,
177
+ "num_input_tokens_seen": 2210064,
178
+ "step": 105
179
+ },
180
+ {
181
+ "epoch": 0.07831271691732669,
182
+ "grad_norm": 0.2700069546699524,
183
+ "learning_rate": 9.852019470370253e-05,
184
+ "loss": 0.2483,
185
+ "num_input_tokens_seen": 2306936,
186
+ "step": 110
187
+ },
188
+ {
189
+ "epoch": 0.08187238586811427,
190
+ "grad_norm": 0.34573429822921753,
191
+ "learning_rate": 9.838207259506891e-05,
192
+ "loss": 0.2462,
193
+ "num_input_tokens_seen": 2413016,
194
+ "step": 115
195
+ },
196
+ {
197
+ "epoch": 0.08543205481890184,
198
+ "grad_norm": 0.29131779074668884,
199
+ "learning_rate": 9.82378944918648e-05,
200
+ "loss": 0.2403,
201
+ "num_input_tokens_seen": 2543504,
202
+ "step": 120
203
+ },
204
+ {
205
+ "epoch": 0.08899172376968942,
206
+ "grad_norm": 0.341266930103302,
207
+ "learning_rate": 9.80876784408948e-05,
208
+ "loss": 0.2276,
209
+ "num_input_tokens_seen": 2640240,
210
+ "step": 125
211
+ },
212
+ {
213
+ "epoch": 0.092551392720477,
214
+ "grad_norm": 0.31063246726989746,
215
+ "learning_rate": 9.793144324473473e-05,
216
+ "loss": 0.221,
217
+ "num_input_tokens_seen": 2743912,
218
+ "step": 130
219
+ },
220
+ {
221
+ "epoch": 0.09611106167126457,
222
+ "grad_norm": 0.3486584722995758,
223
+ "learning_rate": 9.776920845937816e-05,
224
+ "loss": 0.2547,
225
+ "num_input_tokens_seen": 2840632,
226
+ "step": 135
227
+ },
228
+ {
229
+ "epoch": 0.09967073062205214,
230
+ "grad_norm": 0.3306490182876587,
231
+ "learning_rate": 9.760099439178852e-05,
232
+ "loss": 0.2314,
233
+ "num_input_tokens_seen": 2928208,
234
+ "step": 140
235
+ },
236
+ {
237
+ "epoch": 0.10323039957283972,
238
+ "grad_norm": 0.37140771746635437,
239
+ "learning_rate": 9.742682209735727e-05,
240
+ "loss": 0.221,
241
+ "num_input_tokens_seen": 3033456,
242
+ "step": 145
243
+ },
244
+ {
245
+ "epoch": 0.1067900685236273,
246
+ "grad_norm": 0.31432077288627625,
247
+ "learning_rate": 9.724671337726854e-05,
248
+ "loss": 0.2158,
249
+ "num_input_tokens_seen": 3139640,
250
+ "step": 150
251
+ },
252
+ {
253
+ "epoch": 0.11034973747441489,
254
+ "grad_norm": 0.3638117015361786,
255
+ "learning_rate": 9.706069077577001e-05,
256
+ "loss": 0.2277,
257
+ "num_input_tokens_seen": 3240696,
258
+ "step": 155
259
+ },
260
+ {
261
+ "epoch": 0.11390940642520246,
262
+ "grad_norm": 0.2973380982875824,
263
+ "learning_rate": 9.686877757735127e-05,
264
+ "loss": 0.2287,
265
+ "num_input_tokens_seen": 3341736,
266
+ "step": 160
267
+ },
268
+ {
269
+ "epoch": 0.11746907537599004,
270
+ "grad_norm": 0.318136066198349,
271
+ "learning_rate": 9.66709978038292e-05,
272
+ "loss": 0.2201,
273
+ "num_input_tokens_seen": 3424968,
274
+ "step": 165
275
+ },
276
+ {
277
+ "epoch": 0.12102874432677761,
278
+ "grad_norm": 0.397605299949646,
279
+ "learning_rate": 9.646737621134112e-05,
280
+ "loss": 0.2175,
281
+ "num_input_tokens_seen": 3534184,
282
+ "step": 170
283
+ },
284
+ {
285
+ "epoch": 0.12458841327756519,
286
+ "grad_norm": 0.37626489996910095,
287
+ "learning_rate": 9.625793828724618e-05,
288
+ "loss": 0.2359,
289
+ "num_input_tokens_seen": 3631120,
290
+ "step": 175
291
+ },
292
+ {
293
+ "epoch": 0.12814808222835275,
294
+ "grad_norm": 0.441562294960022,
295
+ "learning_rate": 9.604271024693495e-05,
296
+ "loss": 0.2284,
297
+ "num_input_tokens_seen": 3736360,
298
+ "step": 180
299
+ },
300
+ {
301
+ "epoch": 0.13170775117914035,
302
+ "grad_norm": 0.3418191969394684,
303
+ "learning_rate": 9.582171903054816e-05,
304
+ "loss": 0.2125,
305
+ "num_input_tokens_seen": 3830560,
306
+ "step": 185
307
+ },
308
+ {
309
+ "epoch": 0.13526742012992793,
310
+ "grad_norm": 0.40202295780181885,
311
+ "learning_rate": 9.559499229960451e-05,
312
+ "loss": 0.2133,
313
+ "num_input_tokens_seen": 3920536,
314
+ "step": 190
315
+ },
316
+ {
317
+ "epoch": 0.1388270890807155,
318
+ "grad_norm": 0.29538485407829285,
319
+ "learning_rate": 9.536255843353832e-05,
320
+ "loss": 0.1935,
321
+ "num_input_tokens_seen": 4021840,
322
+ "step": 195
323
+ },
324
+ {
325
+ "epoch": 0.14238675803150308,
326
+ "grad_norm": 0.3438551425933838,
327
+ "learning_rate": 9.512444652614728e-05,
328
+ "loss": 0.2249,
329
+ "num_input_tokens_seen": 4123792,
330
+ "step": 200
331
+ },
332
+ {
333
+ "epoch": 0.14594642698229066,
334
+ "grad_norm": 0.31994742155075073,
335
+ "learning_rate": 9.48806863819507e-05,
336
+ "loss": 0.2117,
337
+ "num_input_tokens_seen": 4227968,
338
+ "step": 205
339
+ },
340
+ {
341
+ "epoch": 0.14950609593307823,
342
+ "grad_norm": 0.2823421359062195,
343
+ "learning_rate": 9.463130851245898e-05,
344
+ "loss": 0.2326,
345
+ "num_input_tokens_seen": 4337096,
346
+ "step": 210
347
+ },
348
+ {
349
+ "epoch": 0.1530657648838658,
350
+ "grad_norm": 0.36814814805984497,
351
+ "learning_rate": 9.437634413235436e-05,
352
+ "loss": 0.2211,
353
+ "num_input_tokens_seen": 4442592,
354
+ "step": 215
355
+ },
356
+ {
357
+ "epoch": 0.15662543383465338,
358
+ "grad_norm": 0.31317004561424255,
359
+ "learning_rate": 9.41158251555839e-05,
360
+ "loss": 0.1706,
361
+ "num_input_tokens_seen": 4540672,
362
+ "step": 220
363
+ },
364
+ {
365
+ "epoch": 0.16018510278544096,
366
+ "grad_norm": 0.34285885095596313,
367
+ "learning_rate": 9.384978419136468e-05,
368
+ "loss": 0.2111,
369
+ "num_input_tokens_seen": 4646952,
370
+ "step": 225
371
+ },
372
+ {
373
+ "epoch": 0.16374477173622853,
374
+ "grad_norm": 0.30709314346313477,
375
+ "learning_rate": 9.357825454010213e-05,
376
+ "loss": 0.2043,
377
+ "num_input_tokens_seen": 4748104,
378
+ "step": 230
379
+ },
380
+ {
381
+ "epoch": 0.1673044406870161,
382
+ "grad_norm": 0.331566721200943,
383
+ "learning_rate": 9.330127018922194e-05,
384
+ "loss": 0.2049,
385
+ "num_input_tokens_seen": 4857120,
386
+ "step": 235
387
+ },
388
+ {
389
+ "epoch": 0.17086410963780368,
390
+ "grad_norm": 0.34622254967689514,
391
+ "learning_rate": 9.301886580891562e-05,
392
+ "loss": 0.2129,
393
+ "num_input_tokens_seen": 4967288,
394
+ "step": 240
395
+ },
396
+ {
397
+ "epoch": 0.17442377858859126,
398
+ "grad_norm": 0.3246297240257263,
399
+ "learning_rate": 9.273107674780102e-05,
400
+ "loss": 0.1882,
401
+ "num_input_tokens_seen": 5077952,
402
+ "step": 245
403
+ },
404
+ {
405
+ "epoch": 0.17798344753937884,
406
+ "grad_norm": 0.3121411204338074,
407
+ "learning_rate": 9.243793902849763e-05,
408
+ "loss": 0.1998,
409
+ "num_input_tokens_seen": 5170960,
410
+ "step": 250
411
+ },
412
+ {
413
+ "epoch": 0.1815431164901664,
414
+ "grad_norm": 0.39862558245658875,
415
+ "learning_rate": 9.213948934311767e-05,
416
+ "loss": 0.1945,
417
+ "num_input_tokens_seen": 5281608,
418
+ "step": 255
419
+ },
420
+ {
421
+ "epoch": 0.185102785440954,
422
+ "grad_norm": 0.30746859312057495,
423
+ "learning_rate": 9.183576504867327e-05,
424
+ "loss": 0.1983,
425
+ "num_input_tokens_seen": 5398464,
426
+ "step": 260
427
+ },
428
+ {
429
+ "epoch": 0.18866245439174156,
430
+ "grad_norm": 0.3460409343242645,
431
+ "learning_rate": 9.152680416240059e-05,
432
+ "loss": 0.211,
433
+ "num_input_tokens_seen": 5503696,
434
+ "step": 265
435
+ },
436
+ {
437
+ "epoch": 0.19222212334252914,
438
+ "grad_norm": 0.42770832777023315,
439
+ "learning_rate": 9.121264535700107e-05,
440
+ "loss": 0.1943,
441
+ "num_input_tokens_seen": 5619400,
442
+ "step": 270
443
+ },
444
+ {
445
+ "epoch": 0.19578179229331671,
446
+ "grad_norm": 0.30582112073898315,
447
+ "learning_rate": 9.089332795580086e-05,
448
+ "loss": 0.186,
449
+ "num_input_tokens_seen": 5719208,
450
+ "step": 275
451
+ },
452
+ {
453
+ "epoch": 0.1993414612441043,
454
+ "grad_norm": 0.38887447118759155,
455
+ "learning_rate": 9.056889192782866e-05,
456
+ "loss": 0.2011,
457
+ "num_input_tokens_seen": 5814880,
458
+ "step": 280
459
+ },
460
+ {
461
+ "epoch": 0.20290113019489187,
462
+ "grad_norm": 0.4006999731063843,
463
+ "learning_rate": 9.023937788281278e-05,
464
+ "loss": 0.1941,
465
+ "num_input_tokens_seen": 5910072,
466
+ "step": 285
467
+ },
468
+ {
469
+ "epoch": 0.20646079914567944,
470
+ "grad_norm": 0.373165100812912,
471
+ "learning_rate": 8.990482706609805e-05,
472
+ "loss": 0.1893,
473
+ "num_input_tokens_seen": 6022608,
474
+ "step": 290
475
+ },
476
+ {
477
+ "epoch": 0.21002046809646702,
478
+ "grad_norm": 0.3396100699901581,
479
+ "learning_rate": 8.95652813534831e-05,
480
+ "loss": 0.1945,
481
+ "num_input_tokens_seen": 6135608,
482
+ "step": 295
483
+ },
484
+ {
485
+ "epoch": 0.2135801370472546,
486
+ "grad_norm": 0.4196370542049408,
487
+ "learning_rate": 8.922078324597879e-05,
488
+ "loss": 0.2082,
489
+ "num_input_tokens_seen": 6241088,
490
+ "step": 300
491
+ },
492
+ {
493
+ "epoch": 0.2171398059980422,
494
+ "grad_norm": 0.39760822057724,
495
+ "learning_rate": 8.88713758644883e-05,
496
+ "loss": 0.1875,
497
+ "num_input_tokens_seen": 6353520,
498
+ "step": 305
499
+ },
500
+ {
501
+ "epoch": 0.22069947494882977,
502
+ "grad_norm": 0.30599263310432434,
503
+ "learning_rate": 8.851710294440973e-05,
504
+ "loss": 0.1876,
505
+ "num_input_tokens_seen": 6454480,
506
+ "step": 310
507
+ },
508
+ {
509
+ "epoch": 0.22425914389961735,
510
+ "grad_norm": 0.4323524832725525,
511
+ "learning_rate": 8.815800883016168e-05,
512
+ "loss": 0.2053,
513
+ "num_input_tokens_seen": 6563816,
514
+ "step": 315
515
+ },
516
+ {
517
+ "epoch": 0.22781881285040492,
518
+ "grad_norm": 0.3267993927001953,
519
+ "learning_rate": 8.779413846963267e-05,
520
+ "loss": 0.1994,
521
+ "num_input_tokens_seen": 6658448,
522
+ "step": 320
523
+ },
524
+ {
525
+ "epoch": 0.2313784818011925,
526
+ "grad_norm": 0.372569739818573,
527
+ "learning_rate": 8.742553740855506e-05,
528
+ "loss": 0.1768,
529
+ "num_input_tokens_seen": 6772528,
530
+ "step": 325
531
+ },
532
+ {
533
+ "epoch": 0.23493815075198007,
534
+ "grad_norm": 0.3330164849758148,
535
+ "learning_rate": 8.705225178480398e-05,
536
+ "loss": 0.1916,
537
+ "num_input_tokens_seen": 6875864,
538
+ "step": 330
539
+ },
540
+ {
541
+ "epoch": 0.23849781970276765,
542
+ "grad_norm": 0.4003218710422516,
543
+ "learning_rate": 8.66743283226223e-05,
544
+ "loss": 0.2065,
545
+ "num_input_tokens_seen": 6972880,
546
+ "step": 335
547
+ },
548
+ {
549
+ "epoch": 0.24205748865355523,
550
+ "grad_norm": 0.3475089371204376,
551
+ "learning_rate": 8.629181432677213e-05,
552
+ "loss": 0.2037,
553
+ "num_input_tokens_seen": 7091480,
554
+ "step": 340
555
+ },
556
+ {
557
+ "epoch": 0.2456171576043428,
558
+ "grad_norm": 0.29793596267700195,
559
+ "learning_rate": 8.59047576766137e-05,
560
+ "loss": 0.1915,
561
+ "num_input_tokens_seen": 7198744,
562
+ "step": 345
563
+ },
564
+ {
565
+ "epoch": 0.24917682655513038,
566
+ "grad_norm": 0.39443179965019226,
567
+ "learning_rate": 8.551320682011228e-05,
568
+ "loss": 0.1884,
569
+ "num_input_tokens_seen": 7306808,
570
+ "step": 350
571
+ },
572
+ {
573
+ "epoch": 0.2527364955059179,
574
+ "grad_norm": 0.37115100026130676,
575
+ "learning_rate": 8.511721076777389e-05,
576
+ "loss": 0.1932,
577
+ "num_input_tokens_seen": 7414544,
578
+ "step": 355
579
+ },
580
+ {
581
+ "epoch": 0.2562961644567055,
582
+ "grad_norm": 0.3560400903224945,
583
+ "learning_rate": 8.471681908651067e-05,
584
+ "loss": 0.1879,
585
+ "num_input_tokens_seen": 7526376,
586
+ "step": 360
587
+ },
588
+ {
589
+ "epoch": 0.25985583340749313,
590
+ "grad_norm": 0.36505258083343506,
591
+ "learning_rate": 8.43120818934367e-05,
592
+ "loss": 0.1882,
593
+ "num_input_tokens_seen": 7622440,
594
+ "step": 365
595
+ },
596
+ {
597
+ "epoch": 0.2634155023582807,
598
+ "grad_norm": 0.3832385241985321,
599
+ "learning_rate": 8.390304984959454e-05,
600
+ "loss": 0.1955,
601
+ "num_input_tokens_seen": 7729176,
602
+ "step": 370
603
+ },
604
+ {
605
+ "epoch": 0.2669751713090683,
606
+ "grad_norm": 0.32355767488479614,
607
+ "learning_rate": 8.348977415361434e-05,
608
+ "loss": 0.1977,
609
+ "num_input_tokens_seen": 7846344,
610
+ "step": 375
611
+ },
612
+ {
613
+ "epoch": 0.27053484025985586,
614
+ "grad_norm": 0.31665217876434326,
615
+ "learning_rate": 8.3072306535305e-05,
616
+ "loss": 0.1944,
617
+ "num_input_tokens_seen": 7945632,
618
+ "step": 380
619
+ },
620
+ {
621
+ "epoch": 0.27409450921064343,
622
+ "grad_norm": 0.3798852562904358,
623
+ "learning_rate": 8.265069924917925e-05,
624
+ "loss": 0.1926,
625
+ "num_input_tokens_seen": 8048344,
626
+ "step": 385
627
+ },
628
+ {
629
+ "epoch": 0.277654178161431,
630
+ "grad_norm": 0.3776335120201111,
631
+ "learning_rate": 8.222500506791304e-05,
632
+ "loss": 0.2007,
633
+ "num_input_tokens_seen": 8154184,
634
+ "step": 390
635
+ },
636
+ {
637
+ "epoch": 0.2812138471122186,
638
+ "grad_norm": 0.3042481243610382,
639
+ "learning_rate": 8.179527727573975e-05,
640
+ "loss": 0.1763,
641
+ "num_input_tokens_seen": 8268128,
642
+ "step": 395
643
+ },
644
+ {
645
+ "epoch": 0.28477351606300616,
646
+ "grad_norm": 0.3481425940990448,
647
+ "learning_rate": 8.136156966178081e-05,
648
+ "loss": 0.1897,
649
+ "num_input_tokens_seen": 8366648,
650
+ "step": 400
651
+ },
652
+ {
653
+ "epoch": 0.28833318501379374,
654
+ "grad_norm": 0.345595121383667,
655
+ "learning_rate": 8.092393651331275e-05,
656
+ "loss": 0.1998,
657
+ "num_input_tokens_seen": 8473872,
658
+ "step": 405
659
+ },
660
+ {
661
+ "epoch": 0.2918928539645813,
662
+ "grad_norm": 0.30839142203330994,
663
+ "learning_rate": 8.048243260897217e-05,
664
+ "loss": 0.1844,
665
+ "num_input_tokens_seen": 8575560,
666
+ "step": 410
667
+ },
668
+ {
669
+ "epoch": 0.2954525229153689,
670
+ "grad_norm": 0.3298119008541107,
671
+ "learning_rate": 8.003711321189895e-05,
672
+ "loss": 0.1816,
673
+ "num_input_tokens_seen": 8692528,
674
+ "step": 415
675
+ },
676
+ {
677
+ "epoch": 0.29901219186615646,
678
+ "grad_norm": 0.3186253607273102,
679
+ "learning_rate": 7.95880340628191e-05,
680
+ "loss": 0.1894,
681
+ "num_input_tokens_seen": 8792544,
682
+ "step": 420
683
+ },
684
+ {
685
+ "epoch": 0.30257186081694404,
686
+ "grad_norm": 0.3161162734031677,
687
+ "learning_rate": 7.913525137306756e-05,
688
+ "loss": 0.1859,
689
+ "num_input_tokens_seen": 8911488,
690
+ "step": 425
691
+ },
692
+ {
693
+ "epoch": 0.3061315297677316,
694
+ "grad_norm": 0.36929574608802795,
695
+ "learning_rate": 7.86788218175523e-05,
696
+ "loss": 0.1867,
697
+ "num_input_tokens_seen": 9015008,
698
+ "step": 430
699
+ },
700
+ {
701
+ "epoch": 0.3096911987185192,
702
+ "grad_norm": 0.5688495635986328,
703
+ "learning_rate": 7.821880252766025e-05,
704
+ "loss": 0.2022,
705
+ "num_input_tokens_seen": 9115512,
706
+ "step": 435
707
+ },
708
+ {
709
+ "epoch": 0.31325086766930677,
710
+ "grad_norm": 0.3410090506076813,
711
+ "learning_rate": 7.775525108410615e-05,
712
+ "loss": 0.1674,
713
+ "num_input_tokens_seen": 9216312,
714
+ "step": 440
715
+ },
716
+ {
717
+ "epoch": 0.31681053662009434,
718
+ "grad_norm": 0.41320088505744934,
719
+ "learning_rate": 7.728822550972523e-05,
720
+ "loss": 0.1834,
721
+ "num_input_tokens_seen": 9319432,
722
+ "step": 445
723
+ },
724
+ {
725
+ "epoch": 0.3203702055708819,
726
+ "grad_norm": 0.3464307487010956,
727
+ "learning_rate": 7.681778426221042e-05,
728
+ "loss": 0.1671,
729
+ "num_input_tokens_seen": 9426264,
730
+ "step": 450
731
+ },
732
+ {
733
+ "epoch": 0.3239298745216695,
734
+ "grad_norm": 0.42251551151275635,
735
+ "learning_rate": 7.634398622679517e-05,
736
+ "loss": 0.1873,
737
+ "num_input_tokens_seen": 9536096,
738
+ "step": 455
739
+ },
740
+ {
741
+ "epoch": 0.32748954347245707,
742
+ "grad_norm": 0.41400083899497986,
743
+ "learning_rate": 7.586689070888284e-05,
744
+ "loss": 0.1915,
745
+ "num_input_tokens_seen": 9648984,
746
+ "step": 460
747
+ },
748
+ {
749
+ "epoch": 0.33104921242324464,
750
+ "grad_norm": 0.35248515009880066,
751
+ "learning_rate": 7.53865574266234e-05,
752
+ "loss": 0.1822,
753
+ "num_input_tokens_seen": 9772136,
754
+ "step": 465
755
+ },
756
+ {
757
+ "epoch": 0.3346088813740322,
758
+ "grad_norm": 0.43567249178886414,
759
+ "learning_rate": 7.490304650343841e-05,
760
+ "loss": 0.185,
761
+ "num_input_tokens_seen": 9873504,
762
+ "step": 470
763
+ },
764
+ {
765
+ "epoch": 0.3381685503248198,
766
+ "grad_norm": 0.4128562808036804,
767
+ "learning_rate": 7.441641846049556e-05,
768
+ "loss": 0.1794,
769
+ "num_input_tokens_seen": 9994952,
770
+ "step": 475
771
+ },
772
+ {
773
+ "epoch": 0.34172821927560737,
774
+ "grad_norm": 0.45978060364723206,
775
+ "learning_rate": 7.3926734209133e-05,
776
+ "loss": 0.1694,
777
+ "num_input_tokens_seen": 10096568,
778
+ "step": 480
779
+ },
780
+ {
781
+ "epoch": 0.34528788822639495,
782
+ "grad_norm": 0.42638832330703735,
783
+ "learning_rate": 7.343405504323519e-05,
784
+ "loss": 0.172,
785
+ "num_input_tokens_seen": 10193976,
786
+ "step": 485
787
+ },
788
+ {
789
+ "epoch": 0.3488475571771825,
790
+ "grad_norm": 0.31733188033103943,
791
+ "learning_rate": 7.293844263156072e-05,
792
+ "loss": 0.1722,
793
+ "num_input_tokens_seen": 10314512,
794
+ "step": 490
795
+ },
796
+ {
797
+ "epoch": 0.3524072261279701,
798
+ "grad_norm": 0.4016326665878296,
799
+ "learning_rate": 7.243995901002312e-05,
800
+ "loss": 0.1932,
801
+ "num_input_tokens_seen": 10420280,
802
+ "step": 495
803
+ },
804
+ {
805
+ "epoch": 0.3559668950787577,
806
+ "grad_norm": 0.30861759185791016,
807
+ "learning_rate": 7.193866657392597e-05,
808
+ "loss": 0.1778,
809
+ "num_input_tokens_seen": 10512840,
810
+ "step": 500
811
+ },
812
+ {
813
+ "epoch": 0.35952656402954525,
814
+ "grad_norm": 0.358877032995224,
815
+ "learning_rate": 7.143462807015271e-05,
816
+ "loss": 0.1595,
817
+ "num_input_tokens_seen": 10601008,
818
+ "step": 505
819
+ },
820
+ {
821
+ "epoch": 0.3630862329803328,
822
+ "grad_norm": 0.34301072359085083,
823
+ "learning_rate": 7.092790658931273e-05,
824
+ "loss": 0.163,
825
+ "num_input_tokens_seen": 10686288,
826
+ "step": 510
827
+ },
828
+ {
829
+ "epoch": 0.3666459019311204,
830
+ "grad_norm": 0.32205110788345337,
831
+ "learning_rate": 7.041856555784421e-05,
832
+ "loss": 0.181,
833
+ "num_input_tokens_seen": 10792520,
834
+ "step": 515
835
+ },
836
+ {
837
+ "epoch": 0.370205570881908,
838
+ "grad_norm": 0.44235751032829285,
839
+ "learning_rate": 6.990666873007505e-05,
840
+ "loss": 0.1762,
841
+ "num_input_tokens_seen": 10885304,
842
+ "step": 520
843
+ },
844
+ {
845
+ "epoch": 0.37376523983269555,
846
+ "grad_norm": 0.36452656984329224,
847
+ "learning_rate": 6.939228018024275e-05,
848
+ "loss": 0.1647,
849
+ "num_input_tokens_seen": 10993776,
850
+ "step": 525
851
+ },
852
+ {
853
+ "epoch": 0.3773249087834831,
854
+ "grad_norm": 0.5452892184257507,
855
+ "learning_rate": 6.887546429447419e-05,
856
+ "loss": 0.1669,
857
+ "num_input_tokens_seen": 11110832,
858
+ "step": 530
859
+ },
860
+ {
861
+ "epoch": 0.3808845777342707,
862
+ "grad_norm": 0.517644464969635,
863
+ "learning_rate": 6.835628576272638e-05,
864
+ "loss": 0.1873,
865
+ "num_input_tokens_seen": 11201704,
866
+ "step": 535
867
+ },
868
+ {
869
+ "epoch": 0.3844442466850583,
870
+ "grad_norm": 0.3548191785812378,
871
+ "learning_rate": 6.783480957068934e-05,
872
+ "loss": 0.1711,
873
+ "num_input_tokens_seen": 11293424,
874
+ "step": 540
875
+ },
876
+ {
877
+ "epoch": 0.38800391563584585,
878
+ "grad_norm": 0.3615559935569763,
879
+ "learning_rate": 6.731110099165164e-05,
880
+ "loss": 0.1764,
881
+ "num_input_tokens_seen": 11394280,
882
+ "step": 545
883
+ },
884
+ {
885
+ "epoch": 0.39156358458663343,
886
+ "grad_norm": 0.4043658375740051,
887
+ "learning_rate": 6.678522557833024e-05,
888
+ "loss": 0.184,
889
+ "num_input_tokens_seen": 11477712,
890
+ "step": 550
891
+ },
892
+ {
893
+ "epoch": 0.395123253537421,
894
+ "grad_norm": 0.3802790343761444,
895
+ "learning_rate": 6.625724915466526e-05,
896
+ "loss": 0.1681,
897
+ "num_input_tokens_seen": 11593608,
898
+ "step": 555
899
+ },
900
+ {
901
+ "epoch": 0.3986829224882086,
902
+ "grad_norm": 0.5214163661003113,
903
+ "learning_rate": 6.572723780758069e-05,
904
+ "loss": 0.1764,
905
+ "num_input_tokens_seen": 11706168,
906
+ "step": 560
907
+ },
908
+ {
909
+ "epoch": 0.40224259143899616,
910
+ "grad_norm": 0.4910968840122223,
911
+ "learning_rate": 6.519525787871235e-05,
912
+ "loss": 0.1841,
913
+ "num_input_tokens_seen": 11836904,
914
+ "step": 565
915
+ },
916
+ {
917
+ "epoch": 0.40580226038978373,
918
+ "grad_norm": 0.508994996547699,
919
+ "learning_rate": 6.466137595610388e-05,
920
+ "loss": 0.1755,
921
+ "num_input_tokens_seen": 11952440,
922
+ "step": 570
923
+ },
924
+ {
925
+ "epoch": 0.4093619293405713,
926
+ "grad_norm": 0.3509501516819,
927
+ "learning_rate": 6.412565886587185e-05,
928
+ "loss": 0.1661,
929
+ "num_input_tokens_seen": 12050640,
930
+ "step": 575
931
+ },
932
+ {
933
+ "epoch": 0.4129215982913589,
934
+ "grad_norm": 0.43870943784713745,
935
+ "learning_rate": 6.358817366384122e-05,
936
+ "loss": 0.1835,
937
+ "num_input_tokens_seen": 12159120,
938
+ "step": 580
939
+ },
940
+ {
941
+ "epoch": 0.41648126724214646,
942
+ "grad_norm": 0.45170462131500244,
943
+ "learning_rate": 6.304898762715186e-05,
944
+ "loss": 0.1668,
945
+ "num_input_tokens_seen": 12264824,
946
+ "step": 585
947
+ },
948
+ {
949
+ "epoch": 0.42004093619293403,
950
+ "grad_norm": 0.3374248445034027,
951
+ "learning_rate": 6.250816824583747e-05,
952
+ "loss": 0.1731,
953
+ "num_input_tokens_seen": 12382032,
954
+ "step": 590
955
+ },
956
+ {
957
+ "epoch": 0.4236006051437216,
958
+ "grad_norm": 0.3665522336959839,
959
+ "learning_rate": 6.19657832143779e-05,
960
+ "loss": 0.1558,
961
+ "num_input_tokens_seen": 12494104,
962
+ "step": 595
963
+ },
964
+ {
965
+ "epoch": 0.4271602740945092,
966
+ "grad_norm": 0.32165008783340454,
967
+ "learning_rate": 6.142190042322569e-05,
968
+ "loss": 0.1763,
969
+ "num_input_tokens_seen": 12609472,
970
+ "step": 600
971
+ },
972
+ {
973
+ "epoch": 0.43071994304529676,
974
+ "grad_norm": 0.47890809178352356,
975
+ "learning_rate": 6.087658795030837e-05,
976
+ "loss": 0.1795,
977
+ "num_input_tokens_seen": 12723800,
978
+ "step": 605
979
+ },
980
+ {
981
+ "epoch": 0.4342796119960844,
982
+ "grad_norm": 0.3581695556640625,
983
+ "learning_rate": 6.032991405250702e-05,
984
+ "loss": 0.1658,
985
+ "num_input_tokens_seen": 12812152,
986
+ "step": 610
987
+ },
988
+ {
989
+ "epoch": 0.43783928094687197,
990
+ "grad_norm": 0.3896292746067047,
991
+ "learning_rate": 5.9781947157112536e-05,
992
+ "loss": 0.1781,
993
+ "num_input_tokens_seen": 12913336,
994
+ "step": 615
995
+ },
996
+ {
997
+ "epoch": 0.44139894989765954,
998
+ "grad_norm": 0.3902624845504761,
999
+ "learning_rate": 5.9232755853260635e-05,
1000
+ "loss": 0.1712,
1001
+ "num_input_tokens_seen": 13000856,
1002
+ "step": 620
1003
+ },
1004
+ {
1005
+ "epoch": 0.4449586188484471,
1006
+ "grad_norm": 0.5472461581230164,
1007
+ "learning_rate": 5.868240888334653e-05,
1008
+ "loss": 0.1803,
1009
+ "num_input_tokens_seen": 13110056,
1010
+ "step": 625
1011
+ },
1012
+ {
1013
+ "epoch": 0.4485182877992347,
1014
+ "grad_norm": 0.364450067281723,
1015
+ "learning_rate": 5.813097513442035e-05,
1016
+ "loss": 0.1697,
1017
+ "num_input_tokens_seen": 13199584,
1018
+ "step": 630
1019
+ },
1020
+ {
1021
+ "epoch": 0.45207795675002227,
1022
+ "grad_norm": 0.4172821342945099,
1023
+ "learning_rate": 5.757852362956463e-05,
1024
+ "loss": 0.1652,
1025
+ "num_input_tokens_seen": 13300400,
1026
+ "step": 635
1027
+ },
1028
+ {
1029
+ "epoch": 0.45563762570080985,
1030
+ "grad_norm": 0.5252318382263184,
1031
+ "learning_rate": 5.702512351925464e-05,
1032
+ "loss": 0.1757,
1033
+ "num_input_tokens_seen": 13414232,
1034
+ "step": 640
1035
+ },
1036
+ {
1037
+ "epoch": 0.4591972946515974,
1038
+ "grad_norm": 0.3265618681907654,
1039
+ "learning_rate": 5.6470844072702764e-05,
1040
+ "loss": 0.1671,
1041
+ "num_input_tokens_seen": 13508520,
1042
+ "step": 645
1043
+ },
1044
+ {
1045
+ "epoch": 0.462756963602385,
1046
+ "grad_norm": 0.3361479938030243,
1047
+ "learning_rate": 5.591575466918816e-05,
1048
+ "loss": 0.1757,
1049
+ "num_input_tokens_seen": 13630000,
1050
+ "step": 650
1051
+ },
1052
+ {
1053
+ "epoch": 0.46631663255317257,
1054
+ "grad_norm": 0.39177238941192627,
1055
+ "learning_rate": 5.5359924789372396e-05,
1056
+ "loss": 0.1772,
1057
+ "num_input_tokens_seen": 13746784,
1058
+ "step": 655
1059
+ },
1060
+ {
1061
+ "epoch": 0.46987630150396015,
1062
+ "grad_norm": 0.3369304835796356,
1063
+ "learning_rate": 5.480342400660268e-05,
1064
+ "loss": 0.1642,
1065
+ "num_input_tokens_seen": 13847368,
1066
+ "step": 660
1067
+ },
1068
+ {
1069
+ "epoch": 0.4734359704547477,
1070
+ "grad_norm": 0.3846571445465088,
1071
+ "learning_rate": 5.424632197820324e-05,
1072
+ "loss": 0.1684,
1073
+ "num_input_tokens_seen": 13947616,
1074
+ "step": 665
1075
+ },
1076
+ {
1077
+ "epoch": 0.4769956394055353,
1078
+ "grad_norm": 0.4429912269115448,
1079
+ "learning_rate": 5.368868843675642e-05,
1080
+ "loss": 0.188,
1081
+ "num_input_tokens_seen": 14033504,
1082
+ "step": 670
1083
+ },
1084
+ {
1085
+ "epoch": 0.4805553083563229,
1086
+ "grad_norm": 0.4972701370716095,
1087
+ "learning_rate": 5.31305931813741e-05,
1088
+ "loss": 0.164,
1089
+ "num_input_tokens_seen": 14128176,
1090
+ "step": 675
1091
+ },
1092
+ {
1093
+ "epoch": 0.48411497730711045,
1094
+ "grad_norm": 0.38014113903045654,
1095
+ "learning_rate": 5.2572106068961026e-05,
1096
+ "loss": 0.1778,
1097
+ "num_input_tokens_seen": 14226296,
1098
+ "step": 680
1099
+ },
1100
+ {
1101
+ "epoch": 0.487674646257898,
1102
+ "grad_norm": 0.4327758550643921,
1103
+ "learning_rate": 5.201329700547076e-05,
1104
+ "loss": 0.1822,
1105
+ "num_input_tokens_seen": 14341248,
1106
+ "step": 685
1107
+ },
1108
+ {
1109
+ "epoch": 0.4912343152086856,
1110
+ "grad_norm": 0.3764859735965729,
1111
+ "learning_rate": 5.145423593715557e-05,
1112
+ "loss": 0.1544,
1113
+ "num_input_tokens_seen": 14454128,
1114
+ "step": 690
1115
+ },
1116
+ {
1117
+ "epoch": 0.4947939841594732,
1118
+ "grad_norm": 0.4072837829589844,
1119
+ "learning_rate": 5.089499284181122e-05,
1120
+ "loss": 0.1521,
1121
+ "num_input_tokens_seen": 14558352,
1122
+ "step": 695
1123
+ },
1124
+ {
1125
+ "epoch": 0.49835365311026075,
1126
+ "grad_norm": 0.45584630966186523,
1127
+ "learning_rate": 5.0335637720017817e-05,
1128
+ "loss": 0.1549,
1129
+ "num_input_tokens_seen": 14632632,
1130
+ "step": 700
1131
+ },
1132
+ {
1133
+ "epoch": 0.5019133220610483,
1134
+ "grad_norm": 0.4504990577697754,
1135
+ "learning_rate": 4.977624058637783e-05,
1136
+ "loss": 0.1645,
1137
+ "num_input_tokens_seen": 14733712,
1138
+ "step": 705
1139
+ },
1140
+ {
1141
+ "epoch": 0.5054729910118358,
1142
+ "grad_norm": 0.3279663026332855,
1143
+ "learning_rate": 4.921687146075244e-05,
1144
+ "loss": 0.1786,
1145
+ "num_input_tokens_seen": 14856480,
1146
+ "step": 710
1147
+ },
1148
+ {
1149
+ "epoch": 0.5090326599626235,
1150
+ "grad_norm": 0.43772807717323303,
1151
+ "learning_rate": 4.865760035949695e-05,
1152
+ "loss": 0.1683,
1153
+ "num_input_tokens_seen": 14963032,
1154
+ "step": 715
1155
+ },
1156
+ {
1157
+ "epoch": 0.512592328913411,
1158
+ "grad_norm": 0.41034719347953796,
1159
+ "learning_rate": 4.809849728669702e-05,
1160
+ "loss": 0.1737,
1161
+ "num_input_tokens_seen": 15056864,
1162
+ "step": 720
1163
+ },
1164
+ {
1165
+ "epoch": 0.5161519978641986,
1166
+ "grad_norm": 0.35806897282600403,
1167
+ "learning_rate": 4.7539632225406095e-05,
1168
+ "loss": 0.1635,
1169
+ "num_input_tokens_seen": 15169176,
1170
+ "step": 725
1171
+ },
1172
+ {
1173
+ "epoch": 0.5197116668149863,
1174
+ "grad_norm": 0.410163015127182,
1175
+ "learning_rate": 4.6981075128885693e-05,
1176
+ "loss": 0.1682,
1177
+ "num_input_tokens_seen": 15264616,
1178
+ "step": 730
1179
+ },
1180
+ {
1181
+ "epoch": 0.5232713357657738,
1182
+ "grad_norm": 0.4012819826602936,
1183
+ "learning_rate": 4.642289591184934e-05,
1184
+ "loss": 0.1834,
1185
+ "num_input_tokens_seen": 15375512,
1186
+ "step": 735
1187
+ },
1188
+ {
1189
+ "epoch": 0.5268310047165614,
1190
+ "grad_norm": 0.35860753059387207,
1191
+ "learning_rate": 4.586516444171122e-05,
1192
+ "loss": 0.1708,
1193
+ "num_input_tokens_seen": 15468760,
1194
+ "step": 740
1195
+ },
1196
+ {
1197
+ "epoch": 0.5303906736673489,
1198
+ "grad_norm": 0.4758777916431427,
1199
+ "learning_rate": 4.530795052984104e-05,
1200
+ "loss": 0.1738,
1201
+ "num_input_tokens_seen": 15570704,
1202
+ "step": 745
1203
+ },
1204
+ {
1205
+ "epoch": 0.5339503426181366,
1206
+ "grad_norm": 0.37693336606025696,
1207
+ "learning_rate": 4.475132392282556e-05,
1208
+ "loss": 0.1647,
1209
+ "num_input_tokens_seen": 15668584,
1210
+ "step": 750
1211
+ },
1212
+ {
1213
+ "epoch": 0.5375100115689241,
1214
+ "grad_norm": 0.34583452343940735,
1215
+ "learning_rate": 4.4195354293738484e-05,
1216
+ "loss": 0.1557,
1217
+ "num_input_tokens_seen": 15746296,
1218
+ "step": 755
1219
+ },
1220
+ {
1221
+ "epoch": 0.5410696805197117,
1222
+ "grad_norm": 0.36316967010498047,
1223
+ "learning_rate": 4.364011123341947e-05,
1224
+ "loss": 0.1651,
1225
+ "num_input_tokens_seen": 15868760,
1226
+ "step": 760
1227
+ },
1228
+ {
1229
+ "epoch": 0.5446293494704992,
1230
+ "grad_norm": 0.46182507276535034,
1231
+ "learning_rate": 4.308566424176336e-05,
1232
+ "loss": 0.1691,
1233
+ "num_input_tokens_seen": 15961016,
1234
+ "step": 765
1235
+ },
1236
+ {
1237
+ "epoch": 0.5481890184212869,
1238
+ "grad_norm": 0.4366365075111389,
1239
+ "learning_rate": 4.253208271902091e-05,
1240
+ "loss": 0.1762,
1241
+ "num_input_tokens_seen": 16068296,
1242
+ "step": 770
1243
+ },
1244
+ {
1245
+ "epoch": 0.5517486873720744,
1246
+ "grad_norm": 0.3218953311443329,
1247
+ "learning_rate": 4.197943595711198e-05,
1248
+ "loss": 0.1603,
1249
+ "num_input_tokens_seen": 16189096,
1250
+ "step": 775
1251
+ },
1252
+ {
1253
+ "epoch": 0.555308356322862,
1254
+ "grad_norm": 0.48252201080322266,
1255
+ "learning_rate": 4.142779313095223e-05,
1256
+ "loss": 0.1627,
1257
+ "num_input_tokens_seen": 16303344,
1258
+ "step": 780
1259
+ },
1260
+ {
1261
+ "epoch": 0.5588680252736495,
1262
+ "grad_norm": 0.5327666401863098,
1263
+ "learning_rate": 4.087722328979438e-05,
1264
+ "loss": 0.1752,
1265
+ "num_input_tokens_seen": 16413888,
1266
+ "step": 785
1267
+ },
1268
+ {
1269
+ "epoch": 0.5624276942244372,
1270
+ "grad_norm": 0.4146188795566559,
1271
+ "learning_rate": 4.032779534858544e-05,
1272
+ "loss": 0.156,
1273
+ "num_input_tokens_seen": 16520296,
1274
+ "step": 790
1275
+ },
1276
+ {
1277
+ "epoch": 0.5659873631752247,
1278
+ "grad_norm": 0.4379608631134033,
1279
+ "learning_rate": 3.9779578079340554e-05,
1280
+ "loss": 0.176,
1281
+ "num_input_tokens_seen": 16622024,
1282
+ "step": 795
1283
+ },
1284
+ {
1285
+ "epoch": 0.5695470321260123,
1286
+ "grad_norm": 0.6401222944259644,
1287
+ "learning_rate": 3.9232640102534786e-05,
1288
+ "loss": 0.1524,
1289
+ "num_input_tokens_seen": 16734184,
1290
+ "step": 800
1291
+ },
1292
+ {
1293
+ "epoch": 0.5731067010767998,
1294
+ "grad_norm": 0.48411625623703003,
1295
+ "learning_rate": 3.86870498785139e-05,
1296
+ "loss": 0.171,
1297
+ "num_input_tokens_seen": 16828056,
1298
+ "step": 805
1299
+ },
1300
+ {
1301
+ "epoch": 0.5766663700275875,
1302
+ "grad_norm": 0.3455513119697571,
1303
+ "learning_rate": 3.814287569892512e-05,
1304
+ "loss": 0.1599,
1305
+ "num_input_tokens_seen": 16937648,
1306
+ "step": 810
1307
+ },
1308
+ {
1309
+ "epoch": 0.580226038978375,
1310
+ "grad_norm": 0.35831761360168457,
1311
+ "learning_rate": 3.760018567816908e-05,
1312
+ "loss": 0.1694,
1313
+ "num_input_tokens_seen": 17043496,
1314
+ "step": 815
1315
+ },
1316
+ {
1317
+ "epoch": 0.5837857079291626,
1318
+ "grad_norm": 0.4048117399215698,
1319
+ "learning_rate": 3.705904774487396e-05,
1320
+ "loss": 0.157,
1321
+ "num_input_tokens_seen": 17141592,
1322
+ "step": 820
1323
+ },
1324
+ {
1325
+ "epoch": 0.5873453768799501,
1326
+ "grad_norm": 0.4098561704158783,
1327
+ "learning_rate": 3.651952963339282e-05,
1328
+ "loss": 0.1624,
1329
+ "num_input_tokens_seen": 17260592,
1330
+ "step": 825
1331
+ },
1332
+ {
1333
+ "epoch": 0.5909050458307378,
1334
+ "grad_norm": 0.5280525088310242,
1335
+ "learning_rate": 3.598169887532521e-05,
1336
+ "loss": 0.1637,
1337
+ "num_input_tokens_seen": 17352008,
1338
+ "step": 830
1339
+ },
1340
+ {
1341
+ "epoch": 0.5944647147815253,
1342
+ "grad_norm": 0.3961341083049774,
1343
+ "learning_rate": 3.5445622791064356e-05,
1344
+ "loss": 0.1622,
1345
+ "num_input_tokens_seen": 17484016,
1346
+ "step": 835
1347
+ },
1348
+ {
1349
+ "epoch": 0.5980243837323129,
1350
+ "grad_norm": 0.3392258584499359,
1351
+ "learning_rate": 3.491136848137053e-05,
1352
+ "loss": 0.1614,
1353
+ "num_input_tokens_seen": 17569392,
1354
+ "step": 840
1355
+ },
1356
+ {
1357
+ "epoch": 0.6015840526831004,
1358
+ "grad_norm": 0.41437968611717224,
1359
+ "learning_rate": 3.4379002818972124e-05,
1360
+ "loss": 0.1607,
1361
+ "num_input_tokens_seen": 17660056,
1362
+ "step": 845
1363
+ },
1364
+ {
1365
+ "epoch": 0.6051437216338881,
1366
+ "grad_norm": 0.3347319960594177,
1367
+ "learning_rate": 3.384859244019511e-05,
1368
+ "loss": 0.1549,
1369
+ "num_input_tokens_seen": 17753416,
1370
+ "step": 850
1371
+ },
1372
+ {
1373
+ "epoch": 0.6087033905846756,
1374
+ "grad_norm": 0.41625234484672546,
1375
+ "learning_rate": 3.3320203736622184e-05,
1376
+ "loss": 0.1621,
1377
+ "num_input_tokens_seen": 17850256,
1378
+ "step": 855
1379
+ },
1380
+ {
1381
+ "epoch": 0.6122630595354632,
1382
+ "grad_norm": 0.3651588261127472,
1383
+ "learning_rate": 3.2793902846782534e-05,
1384
+ "loss": 0.1651,
1385
+ "num_input_tokens_seen": 17947344,
1386
+ "step": 860
1387
+ },
1388
+ {
1389
+ "epoch": 0.6158227284862507,
1390
+ "grad_norm": 0.4354760944843292,
1391
+ "learning_rate": 3.226975564787322e-05,
1392
+ "loss": 0.1718,
1393
+ "num_input_tokens_seen": 18052208,
1394
+ "step": 865
1395
+ },
1396
+ {
1397
+ "epoch": 0.6193823974370384,
1398
+ "grad_norm": 0.41476985812187195,
1399
+ "learning_rate": 3.174782774751338e-05,
1400
+ "loss": 0.1567,
1401
+ "num_input_tokens_seen": 18180416,
1402
+ "step": 870
1403
+ },
1404
+ {
1405
+ "epoch": 0.6229420663878259,
1406
+ "grad_norm": 0.42029616236686707,
1407
+ "learning_rate": 3.122818447553201e-05,
1408
+ "loss": 0.1649,
1409
+ "num_input_tokens_seen": 18285576,
1410
+ "step": 875
1411
+ },
1412
+ {
1413
+ "epoch": 0.6265017353386135,
1414
+ "grad_norm": 0.3612583577632904,
1415
+ "learning_rate": 3.071089087579074e-05,
1416
+ "loss": 0.1486,
1417
+ "num_input_tokens_seen": 18382008,
1418
+ "step": 880
1419
+ },
1420
+ {
1421
+ "epoch": 0.630061404289401,
1422
+ "grad_norm": 0.3782946467399597,
1423
+ "learning_rate": 3.019601169804216e-05,
1424
+ "loss": 0.1498,
1425
+ "num_input_tokens_seen": 18463520,
1426
+ "step": 885
1427
+ },
1428
+ {
1429
+ "epoch": 0.6336210732401887,
1430
+ "grad_norm": 0.5428029894828796,
1431
+ "learning_rate": 2.9683611389825167e-05,
1432
+ "loss": 0.1605,
1433
+ "num_input_tokens_seen": 18573728,
1434
+ "step": 890
1435
+ },
1436
+ {
1437
+ "epoch": 0.6371807421909762,
1438
+ "grad_norm": 0.3950955271720886,
1439
+ "learning_rate": 2.917375408839803e-05,
1440
+ "loss": 0.1647,
1441
+ "num_input_tokens_seen": 18670936,
1442
+ "step": 895
1443
+ },
1444
+ {
1445
+ "epoch": 0.6407404111417638,
1446
+ "grad_norm": 0.515082597732544,
1447
+ "learning_rate": 2.8666503612710226e-05,
1448
+ "loss": 0.1499,
1449
+ "num_input_tokens_seen": 18762568,
1450
+ "step": 900
1451
+ },
1452
+ {
1453
+ "epoch": 0.6443000800925514,
1454
+ "grad_norm": 0.40842828154563904,
1455
+ "learning_rate": 2.8161923455414367e-05,
1456
+ "loss": 0.1505,
1457
+ "num_input_tokens_seen": 18865968,
1458
+ "step": 905
1459
+ },
1460
+ {
1461
+ "epoch": 0.647859749043339,
1462
+ "grad_norm": 0.3697022795677185,
1463
+ "learning_rate": 2.7660076774918708e-05,
1464
+ "loss": 0.1681,
1465
+ "num_input_tokens_seen": 18981472,
1466
+ "step": 910
1467
+ },
1468
+ {
1469
+ "epoch": 0.6514194179941265,
1470
+ "grad_norm": 0.5153518319129944,
1471
+ "learning_rate": 2.7161026387481636e-05,
1472
+ "loss": 0.1698,
1473
+ "num_input_tokens_seen": 19079608,
1474
+ "step": 915
1475
+ },
1476
+ {
1477
+ "epoch": 0.6549790869449141,
1478
+ "grad_norm": 0.6159951686859131,
1479
+ "learning_rate": 2.666483475934885e-05,
1480
+ "loss": 0.1589,
1481
+ "num_input_tokens_seen": 19168792,
1482
+ "step": 920
1483
+ },
1484
+ {
1485
+ "epoch": 0.6585387558957017,
1486
+ "grad_norm": 0.4294576644897461,
1487
+ "learning_rate": 2.6171563998934605e-05,
1488
+ "loss": 0.1779,
1489
+ "num_input_tokens_seen": 19292088,
1490
+ "step": 925
1491
+ },
1492
+ {
1493
+ "epoch": 0.6620984248464893,
1494
+ "grad_norm": 0.4489574730396271,
1495
+ "learning_rate": 2.5681275849047482e-05,
1496
+ "loss": 0.1797,
1497
+ "num_input_tokens_seen": 19393184,
1498
+ "step": 930
1499
+ },
1500
+ {
1501
+ "epoch": 0.6656580937972768,
1502
+ "grad_norm": 0.38424602150917053,
1503
+ "learning_rate": 2.5194031679162067e-05,
1504
+ "loss": 0.1585,
1505
+ "num_input_tokens_seen": 19486688,
1506
+ "step": 935
1507
+ },
1508
+ {
1509
+ "epoch": 0.6692177627480644,
1510
+ "grad_norm": 0.3428622782230377,
1511
+ "learning_rate": 2.4709892477737262e-05,
1512
+ "loss": 0.1527,
1513
+ "num_input_tokens_seen": 19583928,
1514
+ "step": 940
1515
+ },
1516
+ {
1517
+ "epoch": 0.672777431698852,
1518
+ "grad_norm": 0.3572031855583191,
1519
+ "learning_rate": 2.422891884458241e-05,
1520
+ "loss": 0.163,
1521
+ "num_input_tokens_seen": 19682760,
1522
+ "step": 945
1523
+ },
1524
+ {
1525
+ "epoch": 0.6763371006496396,
1526
+ "grad_norm": 0.4243921637535095,
1527
+ "learning_rate": 2.3751170983272e-05,
1528
+ "loss": 0.1659,
1529
+ "num_input_tokens_seen": 19784712,
1530
+ "step": 950
1531
+ },
1532
+ {
1533
+ "epoch": 0.6798967696004271,
1534
+ "grad_norm": 0.4836697578430176,
1535
+ "learning_rate": 2.3276708693609943e-05,
1536
+ "loss": 0.1662,
1537
+ "num_input_tokens_seen": 19890408,
1538
+ "step": 955
1539
+ },
1540
+ {
1541
+ "epoch": 0.6834564385512147,
1542
+ "grad_norm": 0.3940310478210449,
1543
+ "learning_rate": 2.2805591364144447e-05,
1544
+ "loss": 0.1689,
1545
+ "num_input_tokens_seen": 19988040,
1546
+ "step": 960
1547
+ },
1548
+ {
1549
+ "epoch": 0.6870161075020023,
1550
+ "grad_norm": 0.41803377866744995,
1551
+ "learning_rate": 2.233787796473432e-05,
1552
+ "loss": 0.1497,
1553
+ "num_input_tokens_seen": 20074552,
1554
+ "step": 965
1555
+ },
1556
+ {
1557
+ "epoch": 0.6905757764527899,
1558
+ "grad_norm": 0.37162527441978455,
1559
+ "learning_rate": 2.187362703916766e-05,
1560
+ "loss": 0.1631,
1561
+ "num_input_tokens_seen": 20181064,
1562
+ "step": 970
1563
+ },
1564
+ {
1565
+ "epoch": 0.6941354454035775,
1566
+ "grad_norm": 0.37610870599746704,
1567
+ "learning_rate": 2.141289669783401e-05,
1568
+ "loss": 0.1752,
1569
+ "num_input_tokens_seen": 20293072,
1570
+ "step": 975
1571
+ },
1572
+ {
1573
+ "epoch": 0.697695114354365,
1574
+ "grad_norm": 0.39441388845443726,
1575
+ "learning_rate": 2.0955744610450618e-05,
1576
+ "loss": 0.1575,
1577
+ "num_input_tokens_seen": 20394384,
1578
+ "step": 980
1579
+ },
1580
+ {
1581
+ "epoch": 0.7012547833051527,
1582
+ "grad_norm": 0.33397364616394043,
1583
+ "learning_rate": 2.050222799884387e-05,
1584
+ "loss": 0.1389,
1585
+ "num_input_tokens_seen": 20497680,
1586
+ "step": 985
1587
+ },
1588
+ {
1589
+ "epoch": 0.7048144522559402,
1590
+ "grad_norm": 0.39059650897979736,
1591
+ "learning_rate": 2.0052403629786858e-05,
1592
+ "loss": 0.1625,
1593
+ "num_input_tokens_seen": 20597280,
1594
+ "step": 990
1595
+ },
1596
+ {
1597
+ "epoch": 0.7083741212067278,
1598
+ "grad_norm": 0.4324747323989868,
1599
+ "learning_rate": 1.9606327807893902e-05,
1600
+ "loss": 0.1546,
1601
+ "num_input_tokens_seen": 20715592,
1602
+ "step": 995
1603
+ },
1604
+ {
1605
+ "epoch": 0.7119337901575153,
1606
+ "grad_norm": 0.4057559072971344,
1607
+ "learning_rate": 1.9164056368572846e-05,
1608
+ "loss": 0.1759,
1609
+ "num_input_tokens_seen": 20830456,
1610
+ "step": 1000
1611
+ }
1612
+ ],
1613
+ "logging_steps": 5,
1614
+ "max_steps": 1404,
1615
+ "num_input_tokens_seen": 20830456,
1616
+ "num_train_epochs": 1,
1617
+ "save_steps": 100,
1618
+ "stateful_callbacks": {
1619
+ "TrainerControl": {
1620
+ "args": {
1621
+ "should_epoch_stop": false,
1622
+ "should_evaluate": false,
1623
+ "should_log": false,
1624
+ "should_save": true,
1625
+ "should_training_stop": false
1626
+ },
1627
+ "attributes": {}
1628
+ }
1629
+ },
1630
+ "total_flos": 9.472838083134095e+17,
1631
+ "train_batch_size": 1,
1632
+ "trial_name": null,
1633
+ "trial_params": null
1634
+ }
2/checkpoint-1000/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53d6f2b6ddc39413c7f5106d4dfc20a60221e892597125a4051acc98e75cf41e
3
+ size 7352
2/checkpoint-1000/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
2/checkpoint-1000/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)
2/checkpoint-1100/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /root/autodl-tmp/Qwen3-8B
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.15.1
2/checkpoint-1100/adapter_config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/root/autodl-tmp/Qwen3-8B",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 8,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "r": 4,
24
+ "rank_pattern": {},
25
+ "revision": null,
26
+ "target_modules": [
27
+ "q_proj",
28
+ "k_proj",
29
+ "v_proj",
30
+ "up_proj",
31
+ "down_proj",
32
+ "gate_proj",
33
+ "o_proj"
34
+ ],
35
+ "task_type": "CAUSAL_LM",
36
+ "trainable_token_indices": null,
37
+ "use_dora": false,
38
+ "use_rslora": true
39
+ }
2/checkpoint-1100/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc980566540beab038e36e4b044f63f9bb8b9ea3480ead65503fde29989ae98a
3
+ size 21889736
2/checkpoint-1100/added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|object_ref_end|>": 151647,
20
+ "<|object_ref_start|>": 151646,
21
+ "<|quad_end|>": 151651,
22
+ "<|quad_start|>": 151650,
23
+ "<|repo_name|>": 151663,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
2/checkpoint-1100/global_step1100/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:031470bac929ee8b41ace3e23b641c253aba531aeaaf043b805f5dd87fd6b04c
3
+ size 133228077
2/checkpoint-1100/global_step1100/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:4587341834363525c009e1d93ddc604d47814005495ace04a593afa44560f06b
3
+ size 65501576