fisherman611 commited on
Commit
6225191
·
verified ·
1 Parent(s): 57a5ccc

Upload all Qwen3 training checkpoints (part 3)

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. qwen3/fdd_srkl/checkpoint-1570/README.md +208 -0
  3. qwen3/fdd_srkl/checkpoint-1570/adapter_config.json +46 -0
  4. qwen3/fdd_srkl/checkpoint-1570/adapter_model.safetensors +3 -0
  5. qwen3/fdd_srkl/checkpoint-1570/chat_template.jinja +89 -0
  6. qwen3/fdd_srkl/checkpoint-1570/global_step1570/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  7. qwen3/fdd_srkl/checkpoint-1570/global_step1570/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  8. qwen3/fdd_srkl/checkpoint-1570/global_step1570/mp_rank_00_model_states.pt +3 -0
  9. qwen3/fdd_srkl/checkpoint-1570/latest +1 -0
  10. qwen3/fdd_srkl/checkpoint-1570/rng_state_0.pth +3 -0
  11. qwen3/fdd_srkl/checkpoint-1570/rng_state_1.pth +3 -0
  12. qwen3/fdd_srkl/checkpoint-1570/scheduler.pt +3 -0
  13. qwen3/fdd_srkl/checkpoint-1570/tokenizer.json +3 -0
  14. qwen3/fdd_srkl/checkpoint-1570/tokenizer_config.json +31 -0
  15. qwen3/fdd_srkl/checkpoint-1570/trainer_state.json +655 -0
  16. qwen3/fdd_srkl/checkpoint-1570/training_args.bin +3 -0
  17. qwen3/fdd_srkl/checkpoint-1570/zero_to_fp32.py +790 -0
  18. qwen3/fdd_srkl/checkpoint-314/README.md +208 -0
  19. qwen3/fdd_srkl/checkpoint-314/adapter_config.json +46 -0
  20. qwen3/fdd_srkl/checkpoint-314/adapter_model.safetensors +3 -0
  21. qwen3/fdd_srkl/checkpoint-314/chat_template.jinja +89 -0
  22. qwen3/fdd_srkl/checkpoint-314/global_step314/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  23. qwen3/fdd_srkl/checkpoint-314/global_step314/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  24. qwen3/fdd_srkl/checkpoint-314/global_step314/mp_rank_00_model_states.pt +3 -0
  25. qwen3/fdd_srkl/checkpoint-314/latest +1 -0
  26. qwen3/fdd_srkl/checkpoint-314/rng_state_0.pth +3 -0
  27. qwen3/fdd_srkl/checkpoint-314/rng_state_1.pth +3 -0
  28. qwen3/fdd_srkl/checkpoint-314/scheduler.pt +3 -0
  29. qwen3/fdd_srkl/checkpoint-314/tokenizer.json +3 -0
  30. qwen3/fdd_srkl/checkpoint-314/tokenizer_config.json +31 -0
  31. qwen3/fdd_srkl/checkpoint-314/trainer_state.json +154 -0
  32. qwen3/fdd_srkl/checkpoint-314/training_args.bin +3 -0
  33. qwen3/fdd_srkl/checkpoint-314/zero_to_fp32.py +790 -0
  34. qwen3/fdd_srkl/checkpoint-628/README.md +208 -0
  35. qwen3/fdd_srkl/checkpoint-628/adapter_config.json +46 -0
  36. qwen3/fdd_srkl/checkpoint-628/adapter_model.safetensors +3 -0
  37. qwen3/fdd_srkl/checkpoint-628/chat_template.jinja +89 -0
  38. qwen3/fdd_srkl/checkpoint-628/global_step628/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  39. qwen3/fdd_srkl/checkpoint-628/global_step628/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  40. qwen3/fdd_srkl/checkpoint-628/global_step628/mp_rank_00_model_states.pt +3 -0
  41. qwen3/fdd_srkl/checkpoint-628/latest +1 -0
  42. qwen3/fdd_srkl/checkpoint-628/rng_state_0.pth +3 -0
  43. qwen3/fdd_srkl/checkpoint-628/rng_state_1.pth +3 -0
  44. qwen3/fdd_srkl/checkpoint-628/scheduler.pt +3 -0
  45. qwen3/fdd_srkl/checkpoint-628/tokenizer.json +3 -0
  46. qwen3/fdd_srkl/checkpoint-628/tokenizer_config.json +31 -0
  47. qwen3/fdd_srkl/checkpoint-628/trainer_state.json +281 -0
  48. qwen3/fdd_srkl/checkpoint-628/training_args.bin +3 -0
  49. qwen3/fdd_srkl/checkpoint-628/zero_to_fp32.py +790 -0
  50. qwen3/fdd_srkl/checkpoint-942/README.md +208 -0
.gitattributes CHANGED
@@ -64,3 +64,20 @@ qwen3/fdd_sfkl/checkpoint-628/tokenizer.json filter=lfs diff=lfs merge=lfs -text
64
  qwen3/fdd_sfkl/checkpoint-942/tokenizer.json filter=lfs diff=lfs merge=lfs -text
65
  qwen3/fdd_sfkl/tokenizer.json filter=lfs diff=lfs merge=lfs -text
66
  qwen3/fdd_srkl/checkpoint-1256/tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  qwen3/fdd_sfkl/checkpoint-942/tokenizer.json filter=lfs diff=lfs merge=lfs -text
65
  qwen3/fdd_sfkl/tokenizer.json filter=lfs diff=lfs merge=lfs -text
66
  qwen3/fdd_srkl/checkpoint-1256/tokenizer.json filter=lfs diff=lfs merge=lfs -text
67
+ qwen3/fdd_srkl/checkpoint-1570/tokenizer.json filter=lfs diff=lfs merge=lfs -text
68
+ qwen3/fdd_srkl/checkpoint-314/tokenizer.json filter=lfs diff=lfs merge=lfs -text
69
+ qwen3/fdd_srkl/checkpoint-628/tokenizer.json filter=lfs diff=lfs merge=lfs -text
70
+ qwen3/fdd_srkl/checkpoint-942/tokenizer.json filter=lfs diff=lfs merge=lfs -text
71
+ qwen3/fdd_srkl/tokenizer.json filter=lfs diff=lfs merge=lfs -text
72
+ qwen3/fkl/checkpoint-1256/tokenizer.json filter=lfs diff=lfs merge=lfs -text
73
+ qwen3/fkl/checkpoint-1570/tokenizer.json filter=lfs diff=lfs merge=lfs -text
74
+ qwen3/fkl/checkpoint-314/tokenizer.json filter=lfs diff=lfs merge=lfs -text
75
+ qwen3/fkl/checkpoint-628/tokenizer.json filter=lfs diff=lfs merge=lfs -text
76
+ qwen3/fkl/checkpoint-942/tokenizer.json filter=lfs diff=lfs merge=lfs -text
77
+ qwen3/fkl/tokenizer.json filter=lfs diff=lfs merge=lfs -text
78
+ qwen3/hpd/checkpoint-1256/tokenizer.json filter=lfs diff=lfs merge=lfs -text
79
+ qwen3/hpd/checkpoint-1570/tokenizer.json filter=lfs diff=lfs merge=lfs -text
80
+ qwen3/hpd/checkpoint-314/tokenizer.json filter=lfs diff=lfs merge=lfs -text
81
+ qwen3/hpd/checkpoint-628/tokenizer.json filter=lfs diff=lfs merge=lfs -text
82
+ qwen3/hpd/checkpoint-942/tokenizer.json filter=lfs diff=lfs merge=lfs -text
83
+ qwen3/hpd/tokenizer.json filter=lfs diff=lfs merge=lfs -text
qwen3/fdd_srkl/checkpoint-1570/README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen3-0.6B
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:Qwen/Qwen3-0.6B
7
+ - llama-factory
8
+ - lora
9
+ - transformers
10
+ ---
11
+
12
+ # Model Card for Model ID
13
+
14
+ <!-- Provide a quick summary of what the model is/does. -->
15
+
16
+
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+
22
+ <!-- Provide a longer summary of what this model is. -->
23
+
24
+
25
+
26
+ - **Developed by:** [More Information Needed]
27
+ - **Funded by [optional]:** [More Information Needed]
28
+ - **Shared by [optional]:** [More Information Needed]
29
+ - **Model type:** [More Information Needed]
30
+ - **Language(s) (NLP):** [More Information Needed]
31
+ - **License:** [More Information Needed]
32
+ - **Finetuned from model [optional]:** [More Information Needed]
33
+
34
+ ### Model Sources [optional]
35
+
36
+ <!-- Provide the basic links for the model. -->
37
+
38
+ - **Repository:** [More Information Needed]
39
+ - **Paper [optional]:** [More Information Needed]
40
+ - **Demo [optional]:** [More Information Needed]
41
+
42
+ ## Uses
43
+
44
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
45
+
46
+ ### Direct Use
47
+
48
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Downstream Use [optional]
53
+
54
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
55
+
56
+ [More Information Needed]
57
+
58
+ ### Out-of-Scope Use
59
+
60
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ## Bias, Risks, and Limitations
65
+
66
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
67
+
68
+ [More Information Needed]
69
+
70
+ ### Recommendations
71
+
72
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
73
+
74
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
75
+
76
+ ## How to Get Started with the Model
77
+
78
+ Use the code below to get started with the model.
79
+
80
+ [More Information Needed]
81
+
82
+ ## Training Details
83
+
84
+ ### Training Data
85
+
86
+ <!-- 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. -->
87
+
88
+ [More Information Needed]
89
+
90
+ ### Training Procedure
91
+
92
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
93
+
94
+ #### Preprocessing [optional]
95
+
96
+ [More Information Needed]
97
+
98
+
99
+ #### Training Hyperparameters
100
+
101
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
102
+
103
+ #### Speeds, Sizes, Times [optional]
104
+
105
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
106
+
107
+ [More Information Needed]
108
+
109
+ ## Evaluation
110
+
111
+ <!-- This section describes the evaluation protocols and provides the results. -->
112
+
113
+ ### Testing Data, Factors & Metrics
114
+
115
+ #### Testing Data
116
+
117
+ <!-- This should link to a Dataset Card if possible. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Factors
122
+
123
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
124
+
125
+ [More Information Needed]
126
+
127
+ #### Metrics
128
+
129
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
130
+
131
+ [More Information Needed]
132
+
133
+ ### Results
134
+
135
+ [More Information Needed]
136
+
137
+ #### Summary
138
+
139
+
140
+
141
+ ## Model Examination [optional]
142
+
143
+ <!-- Relevant interpretability work for the model goes here -->
144
+
145
+ [More Information Needed]
146
+
147
+ ## Environmental Impact
148
+
149
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
150
+
151
+ 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).
152
+
153
+ - **Hardware Type:** [More Information Needed]
154
+ - **Hours used:** [More Information Needed]
155
+ - **Cloud Provider:** [More Information Needed]
156
+ - **Compute Region:** [More Information Needed]
157
+ - **Carbon Emitted:** [More Information Needed]
158
+
159
+ ## Technical Specifications [optional]
160
+
161
+ ### Model Architecture and Objective
162
+
163
+ [More Information Needed]
164
+
165
+ ### Compute Infrastructure
166
+
167
+ [More Information Needed]
168
+
169
+ #### Hardware
170
+
171
+ [More Information Needed]
172
+
173
+ #### Software
174
+
175
+ [More Information Needed]
176
+
177
+ ## Citation [optional]
178
+
179
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
180
+
181
+ **BibTeX:**
182
+
183
+ [More Information Needed]
184
+
185
+ **APA:**
186
+
187
+ [More Information Needed]
188
+
189
+ ## Glossary [optional]
190
+
191
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
192
+
193
+ [More Information Needed]
194
+
195
+ ## More Information [optional]
196
+
197
+ [More Information Needed]
198
+
199
+ ## Model Card Authors [optional]
200
+
201
+ [More Information Needed]
202
+
203
+ ## Model Card Contact
204
+
205
+ [More Information Needed]
206
+ ### Framework versions
207
+
208
+ - PEFT 0.18.1
qwen3/fdd_srkl/checkpoint-1570/adapter_config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen3-0.6B",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 64,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.1,
22
+ "megatron_config": null,
23
+ "megatron_core": "megatron.core",
24
+ "modules_to_save": null,
25
+ "peft_type": "LORA",
26
+ "peft_version": "0.18.1",
27
+ "qalora_group_size": 16,
28
+ "r": 32,
29
+ "rank_pattern": {},
30
+ "revision": null,
31
+ "target_modules": [
32
+ "k_proj",
33
+ "q_proj",
34
+ "v_proj",
35
+ "o_proj",
36
+ "up_proj",
37
+ "down_proj",
38
+ "gate_proj"
39
+ ],
40
+ "target_parameters": null,
41
+ "task_type": "CAUSAL_LM",
42
+ "trainable_token_indices": null,
43
+ "use_dora": false,
44
+ "use_qalora": false,
45
+ "use_rslora": false
46
+ }
qwen3/fdd_srkl/checkpoint-1570/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99fc0546ccfaf4ac4d14c8f45aee81602af1b5a2055a86913c4740cf4b7ef42c
3
+ size 40422560
qwen3/fdd_srkl/checkpoint-1570/chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# 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>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\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" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
qwen3/fdd_srkl/checkpoint-1570/global_step1570/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28a856061b9a2b9c3ec1266cf51ede9955d8cd358bca34cc9690f7d8c9571b13
3
+ size 121135557
qwen3/fdd_srkl/checkpoint-1570/global_step1570/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd3ed025c90f3c11c7cc82b06136ff01acb8b31680f7561a1025b3f92f4e09fe
3
+ size 121135749
qwen3/fdd_srkl/checkpoint-1570/global_step1570/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2da22aa2281ba02d5a68f3846200d692b6adf5f124f93cc2389e651bdfd59fca
3
+ size 351841765
qwen3/fdd_srkl/checkpoint-1570/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step1570
qwen3/fdd_srkl/checkpoint-1570/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3aecd1c085596d7db97dd4b4f44c436f9a4f4b006b7b4918ad4eff80706a73c3
3
+ size 14917
qwen3/fdd_srkl/checkpoint-1570/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5806b5397c5b16eef73bdab6d9dab79e97b62c7104e2b89e5d27d753bcd0057a
3
+ size 14917
qwen3/fdd_srkl/checkpoint-1570/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6332fac17ae99a07597512c705658da2fd8429d1c39bb776b30e107c2cb7aae
3
+ size 1465
qwen3/fdd_srkl/checkpoint-1570/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
qwen3/fdd_srkl/checkpoint-1570/tokenizer_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": false,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "padding_side": "right",
28
+ "split_special_tokens": false,
29
+ "tokenizer_class": "Qwen2Tokenizer",
30
+ "unk_token": null
31
+ }
qwen3/fdd_srkl/checkpoint-1570/trainer_state.json ADDED
@@ -0,0 +1,655 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 5.0,
6
+ "eval_steps": 500,
7
+ "global_step": 1570,
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.06382130035899482,
14
+ "grad_norm": 2.4362361431121826,
15
+ "learning_rate": 9.996390385474569e-05,
16
+ "loss": 1.4636783599853516,
17
+ "step": 20
18
+ },
19
+ {
20
+ "epoch": 0.12764260071798963,
21
+ "grad_norm": 2.9437320232391357,
22
+ "learning_rate": 9.984797509888031e-05,
23
+ "loss": 0.5306460380554199,
24
+ "step": 40
25
+ },
26
+ {
27
+ "epoch": 0.19146390107698444,
28
+ "grad_norm": 1.3007458448410034,
29
+ "learning_rate": 9.965229938050925e-05,
30
+ "loss": 0.34657702445983884,
31
+ "step": 60
32
+ },
33
+ {
34
+ "epoch": 0.25528520143597927,
35
+ "grad_norm": 1.569557547569275,
36
+ "learning_rate": 9.937719005663432e-05,
37
+ "loss": 0.25293736457824706,
38
+ "step": 80
39
+ },
40
+ {
41
+ "epoch": 0.3191065017949741,
42
+ "grad_norm": 0.8431988954544067,
43
+ "learning_rate": 9.902308769000724e-05,
44
+ "loss": 0.208502197265625,
45
+ "step": 100
46
+ },
47
+ {
48
+ "epoch": 0.3829278021539689,
49
+ "grad_norm": 2.0384669303894043,
50
+ "learning_rate": 9.859055934360789e-05,
51
+ "loss": 0.16615729331970214,
52
+ "step": 120
53
+ },
54
+ {
55
+ "epoch": 0.4467491025129637,
56
+ "grad_norm": 1.341955542564392,
57
+ "learning_rate": 9.808029767254437e-05,
58
+ "loss": 0.14722728729248047,
59
+ "step": 140
60
+ },
61
+ {
62
+ "epoch": 0.5105704028719585,
63
+ "grad_norm": 1.9276875257492065,
64
+ "learning_rate": 9.749311981482817e-05,
65
+ "loss": 0.14779376983642578,
66
+ "step": 160
67
+ },
68
+ {
69
+ "epoch": 0.5743917032309533,
70
+ "grad_norm": 1.3371649980545044,
71
+ "learning_rate": 9.682996608280154e-05,
72
+ "loss": 0.13147571086883544,
73
+ "step": 180
74
+ },
75
+ {
76
+ "epoch": 0.6382130035899481,
77
+ "grad_norm": 1.0184792280197144,
78
+ "learning_rate": 9.609189845731207e-05,
79
+ "loss": 0.14180898666381836,
80
+ "step": 200
81
+ },
82
+ {
83
+ "epoch": 0.702034303948943,
84
+ "grad_norm": 0.5344496369361877,
85
+ "learning_rate": 9.52800988870462e-05,
86
+ "loss": 0.12216286659240723,
87
+ "step": 220
88
+ },
89
+ {
90
+ "epoch": 0.7658556043079378,
91
+ "grad_norm": 3.0611512660980225,
92
+ "learning_rate": 9.439586739574513e-05,
93
+ "loss": 0.11602286100387574,
94
+ "step": 240
95
+ },
96
+ {
97
+ "epoch": 0.8296769046669326,
98
+ "grad_norm": 0.5453760027885437,
99
+ "learning_rate": 9.344062000033414e-05,
100
+ "loss": 0.11221114397048951,
101
+ "step": 260
102
+ },
103
+ {
104
+ "epoch": 0.8934982050259274,
105
+ "grad_norm": 0.4289671778678894,
106
+ "learning_rate": 9.241588644329919e-05,
107
+ "loss": 0.11079610586166382,
108
+ "step": 280
109
+ },
110
+ {
111
+ "epoch": 0.9573195053849222,
112
+ "grad_norm": 0.4820654094219208,
113
+ "learning_rate": 9.132330774294252e-05,
114
+ "loss": 0.10537848472595215,
115
+ "step": 300
116
+ },
117
+ {
118
+ "epoch": 1.0,
119
+ "eval_generator_count": 1712.0,
120
+ "eval_generator_exact_match": 87.9089,
121
+ "eval_generator_rouge1": 99.464,
122
+ "eval_generator_rouge2": 99.1899,
123
+ "eval_generator_rougeL": 99.0517,
124
+ "eval_loss": 0.009097261354327202,
125
+ "eval_runtime": 606.4571,
126
+ "eval_samples_per_second": 5.629,
127
+ "eval_selector_accuracy": 96.6706,
128
+ "eval_selector_count": 1712.0,
129
+ "eval_steps_per_second": 0.176,
130
+ "step": 314
131
+ },
132
+ {
133
+ "epoch": 1.0191463901076985,
134
+ "grad_norm": 3.0870883464813232,
135
+ "learning_rate": 9.01646335654399e-05,
136
+ "loss": 0.09972293376922607,
137
+ "step": 320
138
+ },
139
+ {
140
+ "epoch": 1.0829676904666932,
141
+ "grad_norm": 0.7636368870735168,
142
+ "learning_rate": 8.894171942290817e-05,
143
+ "loss": 0.08893377780914306,
144
+ "step": 340
145
+ },
146
+ {
147
+ "epoch": 1.146788990825688,
148
+ "grad_norm": 0.4203242063522339,
149
+ "learning_rate": 8.765652370197003e-05,
150
+ "loss": 0.08573378920555115,
151
+ "step": 360
152
+ },
153
+ {
154
+ "epoch": 1.210610291184683,
155
+ "grad_norm": 0.371820867061615,
156
+ "learning_rate": 8.631110452757467e-05,
157
+ "loss": 0.07898830771446227,
158
+ "step": 380
159
+ },
160
+ {
161
+ "epoch": 1.2744315915436777,
162
+ "grad_norm": 0.676804780960083,
163
+ "learning_rate": 8.490761646709642e-05,
164
+ "loss": 0.08897324800491332,
165
+ "step": 400
166
+ },
167
+ {
168
+ "epoch": 1.3382528919026724,
169
+ "grad_norm": 1.0131059885025024,
170
+ "learning_rate": 8.344830707998953e-05,
171
+ "loss": 0.08602790236473083,
172
+ "step": 420
173
+ },
174
+ {
175
+ "epoch": 1.4020741922616673,
176
+ "grad_norm": 0.4733346104621887,
177
+ "learning_rate": 8.193551331852458e-05,
178
+ "loss": 0.08213704824447632,
179
+ "step": 440
180
+ },
181
+ {
182
+ "epoch": 1.4658954926206622,
183
+ "grad_norm": 0.9082027673721313,
184
+ "learning_rate": 8.037165778537033e-05,
185
+ "loss": 0.0822598934173584,
186
+ "step": 460
187
+ },
188
+ {
189
+ "epoch": 1.5297167929796571,
190
+ "grad_norm": 0.3575717508792877,
191
+ "learning_rate": 7.875924485401427e-05,
192
+ "loss": 0.0718361496925354,
193
+ "step": 480
194
+ },
195
+ {
196
+ "epoch": 1.5935380933386518,
197
+ "grad_norm": 0.3527005612850189,
198
+ "learning_rate": 7.710085665823444e-05,
199
+ "loss": 0.07293112277984619,
200
+ "step": 500
201
+ },
202
+ {
203
+ "epoch": 1.6573593936976465,
204
+ "grad_norm": 0.3359999358654022,
205
+ "learning_rate": 7.539914895704521e-05,
206
+ "loss": 0.07311422824859619,
207
+ "step": 520
208
+ },
209
+ {
210
+ "epoch": 1.7211806940566414,
211
+ "grad_norm": 0.3345245122909546,
212
+ "learning_rate": 7.365684688173908e-05,
213
+ "loss": 0.07376066446304322,
214
+ "step": 540
215
+ },
216
+ {
217
+ "epoch": 1.7850019944156363,
218
+ "grad_norm": 0.3286590874195099,
219
+ "learning_rate": 7.18767405718347e-05,
220
+ "loss": 0.06656086444854736,
221
+ "step": 560
222
+ },
223
+ {
224
+ "epoch": 1.848823294774631,
225
+ "grad_norm": 0.41298067569732666,
226
+ "learning_rate": 7.006168070692036e-05,
227
+ "loss": 0.07345538735389709,
228
+ "step": 580
229
+ },
230
+ {
231
+ "epoch": 1.9126445951336257,
232
+ "grad_norm": 0.2776452600955963,
233
+ "learning_rate": 6.821457394154786e-05,
234
+ "loss": 0.06613650321960449,
235
+ "step": 600
236
+ },
237
+ {
238
+ "epoch": 1.9764658954926206,
239
+ "grad_norm": 0.27869823575019836,
240
+ "learning_rate": 6.633837825048768e-05,
241
+ "loss": 0.06492968797683715,
242
+ "step": 620
243
+ },
244
+ {
245
+ "epoch": 2.0,
246
+ "eval_generator_count": 1712.0,
247
+ "eval_generator_exact_match": 94.743,
248
+ "eval_generator_rouge1": 99.8867,
249
+ "eval_generator_rouge2": 99.7804,
250
+ "eval_generator_rougeL": 99.6736,
251
+ "eval_loss": 0.006523935589939356,
252
+ "eval_runtime": 602.2662,
253
+ "eval_samples_per_second": 5.669,
254
+ "eval_selector_accuracy": 97.3715,
255
+ "eval_selector_count": 1712.0,
256
+ "eval_steps_per_second": 0.178,
257
+ "step": 628
258
+ },
259
+ {
260
+ "epoch": 2.038292780215397,
261
+ "grad_norm": 0.5264983177185059,
262
+ "learning_rate": 6.443609819179926e-05,
263
+ "loss": 0.06454238891601563,
264
+ "step": 640
265
+ },
266
+ {
267
+ "epoch": 2.102114080574392,
268
+ "grad_norm": 0.7168541550636292,
269
+ "learning_rate": 6.251078009530256e-05,
270
+ "loss": 0.06528459787368775,
271
+ "step": 660
272
+ },
273
+ {
274
+ "epoch": 2.1659353809333863,
275
+ "grad_norm": 0.4798216223716736,
276
+ "learning_rate": 6.0565507184155677e-05,
277
+ "loss": 0.06159168481826782,
278
+ "step": 680
279
+ },
280
+ {
281
+ "epoch": 2.2297566812923812,
282
+ "grad_norm": 0.5430735349655151,
283
+ "learning_rate": 5.860339463735136e-05,
284
+ "loss": 0.06343585252761841,
285
+ "step": 700
286
+ },
287
+ {
288
+ "epoch": 2.293577981651376,
289
+ "grad_norm": 0.2429123818874359,
290
+ "learning_rate": 5.662758460103895e-05,
291
+ "loss": 0.06073571443557739,
292
+ "step": 720
293
+ },
294
+ {
295
+ "epoch": 2.357399282010371,
296
+ "grad_norm": 0.2920048236846924,
297
+ "learning_rate": 5.464124115666095e-05,
298
+ "loss": 0.05954910516738891,
299
+ "step": 740
300
+ },
301
+ {
302
+ "epoch": 2.421220582369366,
303
+ "grad_norm": 0.19888697564601898,
304
+ "learning_rate": 5.264754525396212e-05,
305
+ "loss": 0.05689072012901306,
306
+ "step": 760
307
+ },
308
+ {
309
+ "epoch": 2.4850418827283605,
310
+ "grad_norm": 0.3021155893802643,
311
+ "learning_rate": 5.06496896169857e-05,
312
+ "loss": 0.0560643196105957,
313
+ "step": 780
314
+ },
315
+ {
316
+ "epoch": 2.5488631830873554,
317
+ "grad_norm": 0.32512202858924866,
318
+ "learning_rate": 4.865087363121384e-05,
319
+ "loss": 0.0600568413734436,
320
+ "step": 800
321
+ },
322
+ {
323
+ "epoch": 2.6126844834463503,
324
+ "grad_norm": 0.53708815574646,
325
+ "learning_rate": 4.6654298220040673e-05,
326
+ "loss": 0.05846037864685059,
327
+ "step": 820
328
+ },
329
+ {
330
+ "epoch": 2.6765057838053448,
331
+ "grad_norm": 0.3181110620498657,
332
+ "learning_rate": 4.466316071878229e-05,
333
+ "loss": 0.05601181983947754,
334
+ "step": 840
335
+ },
336
+ {
337
+ "epoch": 2.74032708416434,
338
+ "grad_norm": 0.22879371047019958,
339
+ "learning_rate": 4.2680649754432913e-05,
340
+ "loss": 0.05564823150634766,
341
+ "step": 860
342
+ },
343
+ {
344
+ "epoch": 2.8041483845233346,
345
+ "grad_norm": 0.24975994229316711,
346
+ "learning_rate": 4.070994013936646e-05,
347
+ "loss": 0.05476831197738648,
348
+ "step": 880
349
+ },
350
+ {
351
+ "epoch": 2.8679696848823295,
352
+ "grad_norm": 0.3306073546409607,
353
+ "learning_rate": 3.8754187787161155e-05,
354
+ "loss": 0.05817422866821289,
355
+ "step": 900
356
+ },
357
+ {
358
+ "epoch": 2.9317909852413244,
359
+ "grad_norm": 0.1665683090686798,
360
+ "learning_rate": 3.681652465868875e-05,
361
+ "loss": 0.05767209529876709,
362
+ "step": 920
363
+ },
364
+ {
365
+ "epoch": 2.995612285600319,
366
+ "grad_norm": 0.3881584703922272,
367
+ "learning_rate": 3.490005374656184e-05,
368
+ "loss": 0.05669119954109192,
369
+ "step": 940
370
+ },
371
+ {
372
+ "epoch": 3.0,
373
+ "eval_generator_count": 1712.0,
374
+ "eval_generator_exact_match": 95.0935,
375
+ "eval_generator_rouge1": 99.8705,
376
+ "eval_generator_rouge2": 99.7886,
377
+ "eval_generator_rougeL": 99.6664,
378
+ "eval_loss": 0.005655109416693449,
379
+ "eval_runtime": 604.2347,
380
+ "eval_samples_per_second": 5.65,
381
+ "eval_selector_accuracy": 98.4813,
382
+ "eval_selector_count": 1712.0,
383
+ "eval_steps_per_second": 0.177,
384
+ "step": 942
385
+ },
386
+ {
387
+ "epoch": 3.057439170323095,
388
+ "grad_norm": 0.2090013325214386,
389
+ "learning_rate": 3.3007844105971336e-05,
390
+ "loss": 0.05627270340919495,
391
+ "step": 960
392
+ },
393
+ {
394
+ "epoch": 3.12126047068209,
395
+ "grad_norm": 0.2156447023153305,
396
+ "learning_rate": 3.114292593987149e-05,
397
+ "loss": 0.05334089994430542,
398
+ "step": 980
399
+ },
400
+ {
401
+ "epoch": 3.185081771041085,
402
+ "grad_norm": 0.1974238008260727,
403
+ "learning_rate": 2.9308285746383408e-05,
404
+ "loss": 0.051919639110565186,
405
+ "step": 1000
406
+ },
407
+ {
408
+ "epoch": 3.24890307140008,
409
+ "grad_norm": 0.18332256376743317,
410
+ "learning_rate": 2.7506861536187867e-05,
411
+ "loss": 0.05656099319458008,
412
+ "step": 1020
413
+ },
414
+ {
415
+ "epoch": 3.3127243717590744,
416
+ "grad_norm": 0.7237991094589233,
417
+ "learning_rate": 2.5741538127566396e-05,
418
+ "loss": 0.05259966850280762,
419
+ "step": 1040
420
+ },
421
+ {
422
+ "epoch": 3.3765456721180693,
423
+ "grad_norm": 0.2267737239599228,
424
+ "learning_rate": 2.4015142526625115e-05,
425
+ "loss": 0.05074975490570068,
426
+ "step": 1060
427
+ },
428
+ {
429
+ "epoch": 3.4403669724770642,
430
+ "grad_norm": 0.20692221820354462,
431
+ "learning_rate": 2.233043940009967e-05,
432
+ "loss": 0.054996371269226074,
433
+ "step": 1080
434
+ },
435
+ {
436
+ "epoch": 3.504188272836059,
437
+ "grad_norm": 0.15545181930065155,
438
+ "learning_rate": 2.0690126647990974e-05,
439
+ "loss": 0.05093409419059754,
440
+ "step": 1100
441
+ },
442
+ {
443
+ "epoch": 3.568009573195054,
444
+ "grad_norm": 0.1771135926246643,
445
+ "learning_rate": 1.9096831083121828e-05,
446
+ "loss": 0.05136837959289551,
447
+ "step": 1120
448
+ },
449
+ {
450
+ "epoch": 3.6318308735540485,
451
+ "grad_norm": 0.24874085187911987,
452
+ "learning_rate": 1.7553104224533324e-05,
453
+ "loss": 0.05098183155059814,
454
+ "step": 1140
455
+ },
456
+ {
457
+ "epoch": 3.6956521739130435,
458
+ "grad_norm": 0.17957162857055664,
459
+ "learning_rate": 1.606141821145735e-05,
460
+ "loss": 0.050333261489868164,
461
+ "step": 1160
462
+ },
463
+ {
464
+ "epoch": 3.7594734742720384,
465
+ "grad_norm": 0.1954505741596222,
466
+ "learning_rate": 1.4624161844408763e-05,
467
+ "loss": 0.05178115367889404,
468
+ "step": 1180
469
+ },
470
+ {
471
+ "epoch": 3.823294774631033,
472
+ "grad_norm": 0.19122923910617828,
473
+ "learning_rate": 1.324363675973698e-05,
474
+ "loss": 0.050999945402145384,
475
+ "step": 1200
476
+ },
477
+ {
478
+ "epoch": 3.8871160749900278,
479
+ "grad_norm": 0.26517826318740845,
480
+ "learning_rate": 1.1922053743763052e-05,
481
+ "loss": 0.0516182005405426,
482
+ "step": 1220
483
+ },
484
+ {
485
+ "epoch": 3.9509373753490227,
486
+ "grad_norm": 0.1767585426568985,
487
+ "learning_rate": 1.0661529192404973e-05,
488
+ "loss": 0.04989046454429626,
489
+ "step": 1240
490
+ },
491
+ {
492
+ "epoch": 4.0,
493
+ "eval_generator_count": 1712.0,
494
+ "eval_generator_exact_match": 96.3201,
495
+ "eval_generator_rouge1": 99.9029,
496
+ "eval_generator_rouge2": 99.8325,
497
+ "eval_generator_rougeL": 99.7566,
498
+ "eval_loss": 0.0041970605961978436,
499
+ "eval_runtime": 743.2973,
500
+ "eval_samples_per_second": 4.593,
501
+ "eval_selector_accuracy": 98.5397,
502
+ "eval_selector_count": 1712.0,
503
+ "eval_steps_per_second": 0.144,
504
+ "step": 1256
505
+ },
506
+ {
507
+ "epoch": 4.0127642600717985,
508
+ "grad_norm": 0.17936867475509644,
509
+ "learning_rate": 9.464081721960592e-06,
510
+ "loss": 0.05013519525527954,
511
+ "step": 1260
512
+ },
513
+ {
514
+ "epoch": 4.076585560430794,
515
+ "grad_norm": 0.323055237531662,
516
+ "learning_rate": 8.331628936475818e-06,
517
+ "loss": 0.04865485727787018,
518
+ "step": 1280
519
+ },
520
+ {
521
+ "epoch": 4.140406860789788,
522
+ "grad_norm": 0.16135305166244507,
523
+ "learning_rate": 7.2659843568748385e-06,
524
+ "loss": 0.04849388599395752,
525
+ "step": 1300
526
+ },
527
+ {
528
+ "epoch": 4.204228161148784,
529
+ "grad_norm": 0.17001892626285553,
530
+ "learning_rate": 6.268854516770008e-06,
531
+ "loss": 0.04871906638145447,
532
+ "step": 1320
533
+ },
534
+ {
535
+ "epoch": 4.268049461507778,
536
+ "grad_norm": 0.18477433919906616,
537
+ "learning_rate": 5.341836229602331e-06,
538
+ "loss": 0.048744958639144895,
539
+ "step": 1340
540
+ },
541
+ {
542
+ "epoch": 4.331870761866773,
543
+ "grad_norm": 0.1783062219619751,
544
+ "learning_rate": 4.4864140314888216e-06,
545
+ "loss": 0.04793646335601807,
546
+ "step": 1360
547
+ },
548
+ {
549
+ "epoch": 4.395692062225768,
550
+ "grad_norm": 0.17276793718338013,
551
+ "learning_rate": 3.703957803871932e-06,
552
+ "loss": 0.048929840326309204,
553
+ "step": 1380
554
+ },
555
+ {
556
+ "epoch": 4.4595133625847625,
557
+ "grad_norm": 0.1627519130706787,
558
+ "learning_rate": 2.9957205797780495e-06,
559
+ "loss": 0.04951263666152954,
560
+ "step": 1400
561
+ },
562
+ {
563
+ "epoch": 4.523334662943758,
564
+ "grad_norm": 0.28899943828582764,
565
+ "learning_rate": 2.362836537198199e-06,
566
+ "loss": 0.05062735080718994,
567
+ "step": 1420
568
+ },
569
+ {
570
+ "epoch": 4.587155963302752,
571
+ "grad_norm": 0.17383745312690735,
572
+ "learning_rate": 1.8063191828043703e-06,
573
+ "loss": 0.049233487248420714,
574
+ "step": 1440
575
+ },
576
+ {
577
+ "epoch": 4.650977263661747,
578
+ "grad_norm": 0.15494407713413239,
579
+ "learning_rate": 1.3270597289100437e-06,
580
+ "loss": 0.04810199737548828,
581
+ "step": 1460
582
+ },
583
+ {
584
+ "epoch": 4.714798564020742,
585
+ "grad_norm": 0.14835470914840698,
586
+ "learning_rate": 9.258256662741205e-07,
587
+ "loss": 0.04752459526062012,
588
+ "step": 1480
589
+ },
590
+ {
591
+ "epoch": 4.778619864379737,
592
+ "grad_norm": 0.17123174667358398,
593
+ "learning_rate": 6.032595350337341e-07,
594
+ "loss": 0.04880803823471069,
595
+ "step": 1500
596
+ },
597
+ {
598
+ "epoch": 4.842441164738732,
599
+ "grad_norm": 0.15825852751731873,
600
+ "learning_rate": 3.5987789573421356e-07,
601
+ "loss": 0.05428855419158936,
602
+ "step": 1520
603
+ },
604
+ {
605
+ "epoch": 4.9062624650977265,
606
+ "grad_norm": 1.0737415552139282,
607
+ "learning_rate": 1.9607050210401192e-07,
608
+ "loss": 0.0523545503616333,
609
+ "step": 1540
610
+ },
611
+ {
612
+ "epoch": 4.970083765456721,
613
+ "grad_norm": 0.18025070428848267,
614
+ "learning_rate": 1.1209967689925832e-07,
615
+ "loss": 0.049212086200714114,
616
+ "step": 1560
617
+ },
618
+ {
619
+ "epoch": 5.0,
620
+ "eval_generator_count": 1712.0,
621
+ "eval_generator_exact_match": 96.7874,
622
+ "eval_generator_rouge1": 99.9018,
623
+ "eval_generator_rouge2": 99.8253,
624
+ "eval_generator_rougeL": 99.7687,
625
+ "eval_loss": 0.0041342261247336864,
626
+ "eval_runtime": 612.0487,
627
+ "eval_samples_per_second": 5.578,
628
+ "eval_selector_accuracy": 98.8318,
629
+ "eval_selector_count": 1712.0,
630
+ "eval_steps_per_second": 0.175,
631
+ "step": 1570
632
+ }
633
+ ],
634
+ "logging_steps": 20,
635
+ "max_steps": 1570,
636
+ "num_input_tokens_seen": 0,
637
+ "num_train_epochs": 5,
638
+ "save_steps": 500,
639
+ "stateful_callbacks": {
640
+ "TrainerControl": {
641
+ "args": {
642
+ "should_epoch_stop": false,
643
+ "should_evaluate": false,
644
+ "should_log": false,
645
+ "should_save": true,
646
+ "should_training_stop": true
647
+ },
648
+ "attributes": {}
649
+ }
650
+ },
651
+ "total_flos": 5.871444840310374e+16,
652
+ "train_batch_size": 2,
653
+ "trial_name": null,
654
+ "trial_params": null
655
+ }
qwen3/fdd_srkl/checkpoint-1570/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb0e76106b10de1344a3493c5f04dde38b30a16fde01bc76445c98b578802418
3
+ size 7185
qwen3/fdd_srkl/checkpoint-1570/zero_to_fp32.py ADDED
@@ -0,0 +1,790 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, AUTOEP_LAYERS_KEY,
37
+ AUTOEP_LAYERS_KEY_LEGACY, AUTOEP_ZERO3_EXPERT_STATE_FORMAT_KEY,
38
+ AUTOEP_ZERO3_PARTITIONED_EXPERT_STATE_FORMAT)
39
+
40
+
41
+ @dataclass
42
+ class zero_model_state:
43
+ buffers: dict()
44
+ param_shapes: dict()
45
+ shared_params: list
46
+ ds_version: int
47
+ frozen_param_shapes: dict()
48
+ frozen_param_fragments: dict()
49
+
50
+
51
+ debug = 0
52
+
53
+ # load to cpu
54
+ device = torch.device('cpu')
55
+
56
+
57
+ def atoi(text):
58
+ return int(text) if text.isdigit() else text
59
+
60
+
61
+ def natural_keys(text):
62
+ '''
63
+ alist.sort(key=natural_keys) sorts in human order
64
+ http://nedbatchelder.com/blog/200712/human_sorting.html
65
+ (See Toothy's implementation in the comments)
66
+ '''
67
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
68
+
69
+
70
+ def get_model_state_file(checkpoint_dir, zero_stage):
71
+ if not os.path.isdir(checkpoint_dir):
72
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
73
+
74
+ # there should be only one file
75
+ if zero_stage <= 2:
76
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
77
+ elif zero_stage == 3:
78
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
79
+
80
+ if not os.path.exists(file):
81
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
82
+
83
+ return file
84
+
85
+
86
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
87
+ # XXX: need to test that this simple glob rule works for multi-node setup too
88
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
89
+
90
+ if len(ckpt_files) == 0:
91
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
92
+
93
+ return ckpt_files
94
+
95
+
96
+ def get_optim_files(checkpoint_dir):
97
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
98
+
99
+
100
+ def get_model_state_files(checkpoint_dir):
101
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
102
+
103
+
104
+ def _has_autoep_zero3_partitioned_metadata(state_dict):
105
+ autoep_layers = state_dict.get(AUTOEP_LAYERS_KEY)
106
+ if autoep_layers is None:
107
+ autoep_layers = state_dict.get(AUTOEP_LAYERS_KEY_LEGACY)
108
+ if not isinstance(autoep_layers, list):
109
+ return False
110
+ return any(
111
+ isinstance(entry, dict)
112
+ and entry.get(AUTOEP_ZERO3_EXPERT_STATE_FORMAT_KEY) == AUTOEP_ZERO3_PARTITIONED_EXPERT_STATE_FORMAT
113
+ for entry in autoep_layers)
114
+
115
+
116
+ def _raise_if_autoep_zero3_partitioned_state(state_dict):
117
+ if _has_autoep_zero3_partitioned_metadata(state_dict):
118
+ raise NotImplementedError("zero_to_fp32 does not support AutoEP ZeRO-3 partition-native checkpoints. "
119
+ "AutoEP expert parameters are partitioned over expert replica groups, so "
120
+ "global data-parallel consolidation would produce incomplete expert tensors. "
121
+ "Use ds_to_universal.py for expert-aware conversion.")
122
+
123
+
124
+ def _raise_if_autoep_zero3_partitioned_checkpoint(model_files):
125
+ for file in model_files:
126
+ state_dict = torch.load(file, map_location=device, weights_only=False)
127
+ _raise_if_autoep_zero3_partitioned_state(state_dict)
128
+
129
+
130
+ def parse_model_states(files):
131
+ zero_model_states = []
132
+ for file in files:
133
+ state_dict = torch.load(file, map_location=device, weights_only=False)
134
+ _raise_if_autoep_zero3_partitioned_state(state_dict)
135
+
136
+ if BUFFER_NAMES not in state_dict:
137
+ raise ValueError(f"{file} is not a model state checkpoint")
138
+ buffer_names = state_dict[BUFFER_NAMES]
139
+ if debug:
140
+ print("Found buffers:", buffer_names)
141
+
142
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
143
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
144
+ param_shapes = state_dict[PARAM_SHAPES]
145
+
146
+ # collect parameters that are included in param_shapes
147
+ param_names = []
148
+ for s in param_shapes:
149
+ for name in s.keys():
150
+ param_names.append(name)
151
+
152
+ # update with frozen parameters
153
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
154
+ if frozen_param_shapes is not None:
155
+ if debug:
156
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
157
+ param_names += list(frozen_param_shapes.keys())
158
+
159
+ # handle shared params
160
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
161
+
162
+ ds_version = state_dict.get(DS_VERSION, None)
163
+
164
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
165
+
166
+ z_model_state = zero_model_state(buffers=buffers,
167
+ param_shapes=param_shapes,
168
+ shared_params=shared_params,
169
+ ds_version=ds_version,
170
+ frozen_param_shapes=frozen_param_shapes,
171
+ frozen_param_fragments=frozen_param_fragments)
172
+ zero_model_states.append(z_model_state)
173
+
174
+ return zero_model_states
175
+
176
+
177
+ def parse_optim_states(files, ds_checkpoint_dir):
178
+ total_files = len(files)
179
+ state_dicts = []
180
+ for f in tqdm(files, desc='Loading checkpoint shards'):
181
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
182
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
183
+ # and also handle the case where it was already removed by another helper script
184
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
185
+ state_dicts.append(state_dict)
186
+
187
+ if ZERO_STAGE not in state_dicts[0][OPTIMIZER_STATE_DICT]:
188
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
189
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
190
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
191
+
192
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
193
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
194
+ # use the max of the partition_count to get the dp world_size.
195
+
196
+ if type(world_size) is list:
197
+ world_size = max(world_size)
198
+
199
+ if world_size != total_files:
200
+ raise ValueError(
201
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
202
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
203
+ )
204
+
205
+ # the groups are named differently in each stage
206
+ if zero_stage <= 2:
207
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
208
+ elif zero_stage == 3:
209
+ fp32_groups_key = FP32_FLAT_GROUPS
210
+ else:
211
+ raise ValueError(f"unknown zero stage {zero_stage}")
212
+
213
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
214
+ return zero_stage, world_size, fp32_flat_groups
215
+
216
+
217
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
218
+ """
219
+ Returns fp32 state_dict reconstructed from ds checkpoint
220
+
221
+ Args:
222
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
223
+
224
+ """
225
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
226
+
227
+ # parse_model_states rejects AutoEP ZeRO-3 partition-native checkpoints
228
+ # before the expensive optimizer-shard load below.
229
+ model_files = get_model_state_files(ds_checkpoint_dir)
230
+ zero_model_states = parse_model_states(model_files)
231
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
232
+
233
+ optim_files = get_optim_files(ds_checkpoint_dir)
234
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
235
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
236
+
237
+ if zero_stage <= 2:
238
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
239
+ exclude_frozen_parameters)
240
+ elif zero_stage == 3:
241
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
242
+ exclude_frozen_parameters)
243
+
244
+
245
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
246
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
247
+ return
248
+
249
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
250
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
251
+
252
+ if debug:
253
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
254
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
255
+
256
+ wanted_params = len(frozen_param_shapes)
257
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
258
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
259
+ print(f'Frozen params: Have {avail_numel} numels to process.')
260
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
261
+
262
+ total_params = 0
263
+ total_numel = 0
264
+ for name, shape in frozen_param_shapes.items():
265
+ total_params += 1
266
+ unpartitioned_numel = shape.numel()
267
+ total_numel += unpartitioned_numel
268
+
269
+ state_dict[name] = frozen_param_fragments[name]
270
+
271
+ if debug:
272
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
273
+
274
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
275
+
276
+
277
+ def _has_callable(obj, fn):
278
+ attr = getattr(obj, fn, None)
279
+ return callable(attr)
280
+
281
+
282
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
283
+ param_shapes = zero_model_states[0].param_shapes
284
+
285
+ # Reconstruction protocol:
286
+ #
287
+ # XXX: document this
288
+
289
+ if debug:
290
+ for i in range(world_size):
291
+ for j in range(len(fp32_flat_groups[0])):
292
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
293
+
294
+ # XXX: memory usage doubles here (zero2)
295
+ num_param_groups = len(fp32_flat_groups[0])
296
+ merged_single_partition_of_fp32_groups = []
297
+ for i in range(num_param_groups):
298
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
299
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
300
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
301
+ avail_numel = sum(
302
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
303
+
304
+ if debug:
305
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
306
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
307
+ # not asserting if there is a mismatch due to possible padding
308
+ print(f"Have {avail_numel} numels to process.")
309
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
310
+
311
+ # params
312
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
313
+ # out-of-core computing solution
314
+ total_numel = 0
315
+ total_params = 0
316
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
317
+ offset = 0
318
+ avail_numel = full_single_fp32_vector.numel()
319
+ for name, shape in shapes.items():
320
+
321
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
322
+ total_numel += unpartitioned_numel
323
+ total_params += 1
324
+
325
+ if debug:
326
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
327
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
328
+ offset += unpartitioned_numel
329
+
330
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
331
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
332
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
333
+ # live optimizer object, so we are checking that the numbers are within the right range
334
+ align_to = 2 * world_size
335
+
336
+ def zero2_align(x):
337
+ return align_to * math.ceil(x / align_to)
338
+
339
+ if debug:
340
+ print(f"original offset={offset}, avail_numel={avail_numel}")
341
+
342
+ offset = zero2_align(offset)
343
+ avail_numel = zero2_align(avail_numel)
344
+
345
+ if debug:
346
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
347
+
348
+ # Sanity check
349
+ if offset != avail_numel:
350
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
351
+
352
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
353
+
354
+
355
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
356
+ exclude_frozen_parameters):
357
+ state_dict = OrderedDict()
358
+
359
+ # buffers
360
+ buffers = zero_model_states[0].buffers
361
+ state_dict.update(buffers)
362
+ if debug:
363
+ print(f"added {len(buffers)} buffers")
364
+
365
+ if not exclude_frozen_parameters:
366
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
367
+
368
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
369
+
370
+ # recover shared parameters
371
+ for pair in zero_model_states[0].shared_params:
372
+ if pair[1] in state_dict:
373
+ state_dict[pair[0]] = state_dict[pair[1]]
374
+
375
+ return state_dict
376
+
377
+
378
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
379
+ remainder = unpartitioned_numel % world_size
380
+ padding_numel = (world_size - remainder) if remainder else 0
381
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
382
+ return partitioned_numel, padding_numel
383
+
384
+
385
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
386
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
387
+ return
388
+
389
+ if debug:
390
+ for i in range(world_size):
391
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
392
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
393
+
394
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
395
+ wanted_params = len(frozen_param_shapes)
396
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
397
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
398
+ print(f'Frozen params: Have {avail_numel} numels to process.')
399
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
400
+
401
+ total_params = 0
402
+ total_numel = 0
403
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
404
+ total_params += 1
405
+ unpartitioned_numel = shape.numel()
406
+ total_numel += unpartitioned_numel
407
+
408
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
409
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
410
+
411
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
412
+
413
+ if debug:
414
+ print(
415
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
416
+ )
417
+
418
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
419
+
420
+
421
+ class GatheredTensor:
422
+ """
423
+ A pseudo tensor that collects partitioned weights.
424
+ It is more memory efficient when there are multiple groups.
425
+ """
426
+
427
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
428
+ self.flat_groups = flat_groups
429
+ self.flat_groups_offset = flat_groups_offset
430
+ self.offset = offset
431
+ self.partitioned_numel = partitioned_numel
432
+ self.shape = shape
433
+ self.dtype = self.flat_groups[0][0].dtype
434
+
435
+ def contiguous(self):
436
+ """
437
+ Merge partitioned weights from flat_groups into a single tensor.
438
+ """
439
+ end_idx = self.offset + self.partitioned_numel
440
+ world_size = len(self.flat_groups)
441
+ pad_flat_param_chunks = []
442
+
443
+ for rank_i in range(world_size):
444
+ # for each rank, we need to collect weights from related group/groups
445
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
446
+ start_group_id = None
447
+ end_group_id = None
448
+ for group_id in range(len(self.flat_groups_offset)):
449
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
450
+ start_group_id = group_id
451
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
452
+ end_group_id = group_id
453
+ break
454
+ # collect weights from related group/groups
455
+ for group_id in range(start_group_id, end_group_id + 1):
456
+ flat_tensor = flat_groups_at_rank_i[group_id]
457
+ start_offset = self.offset - self.flat_groups_offset[group_id]
458
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
459
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
460
+
461
+ # collect weights from all ranks
462
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
463
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
464
+ return param
465
+
466
+
467
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
468
+ param_shapes = zero_model_states[0].param_shapes
469
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
470
+
471
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
472
+ # param, re-consolidating each param, while dealing with padding if any
473
+
474
+ # merge list of dicts, preserving order
475
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
476
+
477
+ if debug:
478
+ for i in range(world_size):
479
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
480
+
481
+ wanted_params = len(param_shapes)
482
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
483
+ # not asserting if there is a mismatch due to possible padding
484
+ avail_numel = fp32_flat_groups[0].numel() * world_size
485
+ print(f"Trainable params: Have {avail_numel} numels to process.")
486
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
487
+
488
+ # params
489
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
490
+ # out-of-core computing solution
491
+ offset = 0
492
+ total_numel = 0
493
+ total_params = 0
494
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
495
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
496
+ unpartitioned_numel = shape.numel()
497
+ total_numel += unpartitioned_numel
498
+ total_params += 1
499
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
500
+
501
+ if debug:
502
+ print(
503
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
504
+ )
505
+
506
+ # memory efficient tensor
507
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
508
+ state_dict[name] = tensor
509
+ offset += partitioned_numel
510
+
511
+ offset *= world_size
512
+
513
+ # Sanity check
514
+ if offset != avail_numel:
515
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
516
+
517
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
518
+
519
+
520
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
521
+ exclude_frozen_parameters):
522
+ state_dict = OrderedDict()
523
+
524
+ # buffers
525
+ buffers = zero_model_states[0].buffers
526
+ state_dict.update(buffers)
527
+ if debug:
528
+ print(f"added {len(buffers)} buffers")
529
+
530
+ if not exclude_frozen_parameters:
531
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
532
+
533
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
534
+
535
+ # recover shared parameters
536
+ for pair in zero_model_states[0].shared_params:
537
+ if pair[1] in state_dict:
538
+ state_dict[pair[0]] = state_dict[pair[1]]
539
+
540
+ return state_dict
541
+
542
+
543
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
544
+ """
545
+ Convert state_dict of GatheredTensor to torch tensor
546
+ """
547
+ torch_state_dict = {}
548
+ converted_tensors = {}
549
+ for name, tensor in state_dict.items():
550
+ tensor_id = id(tensor)
551
+ if tensor_id in converted_tensors: # shared tensors
552
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
553
+ torch_state_dict[name] = shared_tensor
554
+ else:
555
+ converted_tensors[tensor_id] = name
556
+ if return_empty_tensor:
557
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
558
+ else:
559
+ torch_state_dict[name] = tensor.contiguous()
560
+ return torch_state_dict
561
+
562
+
563
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
564
+ tag=None,
565
+ exclude_frozen_parameters=False,
566
+ lazy_mode=False):
567
+ """
568
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
569
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
570
+ via a model hub.
571
+
572
+ Args:
573
+ - ``checkpoint_dir``: path to the desired checkpoint folder
574
+ - ``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``
575
+ - ``exclude_frozen_parameters``: exclude frozen parameters
576
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
577
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
578
+
579
+ Returns:
580
+ - pytorch ``state_dict``
581
+
582
+ A typical usage might be ::
583
+
584
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
585
+ # do the training and checkpoint saving
586
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
587
+ model = model.cpu() # move to cpu
588
+ model.load_state_dict(state_dict)
589
+ # submit to model hub or save the model to share with others
590
+
591
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
592
+ application. i.e. you will need to re-initialize the deepspeed engine, since
593
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
594
+
595
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
596
+
597
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
598
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
599
+ the checkpoint. Or you can load state_dict in lazy mode ::
600
+
601
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
602
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
603
+ for name, lazy_tensor in state_dict.item():
604
+ tensor = lazy_tensor.contiguous() # to cpu
605
+ print(name, tensor)
606
+ # del tensor to release memory if it no longer in use
607
+ """
608
+ if tag is None:
609
+ latest_path = os.path.join(checkpoint_dir, 'latest')
610
+ if os.path.isfile(latest_path):
611
+ with open(latest_path, 'r') as fd:
612
+ tag = fd.read().strip()
613
+ else:
614
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
615
+
616
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
617
+
618
+ if not os.path.isdir(ds_checkpoint_dir):
619
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
620
+
621
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
622
+ if lazy_mode:
623
+ return state_dict
624
+ else:
625
+ return to_torch_tensor(state_dict)
626
+
627
+
628
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
629
+ output_dir,
630
+ max_shard_size="5GB",
631
+ safe_serialization=False,
632
+ tag=None,
633
+ exclude_frozen_parameters=False):
634
+ """
635
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
636
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
637
+
638
+ Args:
639
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
640
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
641
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
642
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
643
+ - ``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``
644
+ - ``exclude_frozen_parameters``: exclude frozen parameters
645
+ """
646
+
647
+ # Dependency pre-check
648
+ if safe_serialization:
649
+ try:
650
+ from safetensors.torch import save_file
651
+ except ImportError:
652
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
653
+ raise
654
+ if max_shard_size is not None:
655
+ try:
656
+ from huggingface_hub import split_torch_state_dict_into_shards
657
+ except ImportError:
658
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
659
+ raise
660
+
661
+ # Convert zero checkpoint to state_dict
662
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
663
+ tag,
664
+ exclude_frozen_parameters,
665
+ lazy_mode=True)
666
+
667
+ # Shard the model if it is too big.
668
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
669
+ if max_shard_size is not None:
670
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
671
+ # an memory-efficient approach for sharding
672
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
673
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
674
+ filename_pattern=filename_pattern,
675
+ max_shard_size=max_shard_size)
676
+ else:
677
+ from collections import namedtuple
678
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
679
+ state_dict_split = StateDictSplit(is_sharded=False,
680
+ filename_to_tensors={weights_name: list(state_dict.keys())})
681
+
682
+ # Save the model by shard
683
+ os.makedirs(output_dir, exist_ok=True)
684
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
685
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
686
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
687
+ shard_state_dict = to_torch_tensor(shard_state_dict)
688
+ output_path = os.path.join(output_dir, shard_file)
689
+ if safe_serialization:
690
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
691
+ else:
692
+ torch.save(shard_state_dict, output_path)
693
+ # release the memory of current shard
694
+ for tensor_name in list(shard_state_dict.keys()):
695
+ del state_dict[tensor_name]
696
+ del shard_state_dict[tensor_name]
697
+ del shard_state_dict
698
+ gc.collect()
699
+
700
+ # Save index if sharded
701
+ if state_dict_split.is_sharded:
702
+ index = {
703
+ "metadata": state_dict_split.metadata,
704
+ "weight_map": state_dict_split.tensor_to_filename,
705
+ }
706
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
707
+ save_index_file = os.path.join(output_dir, save_index_file)
708
+ with open(save_index_file, "w", encoding="utf-8") as f:
709
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
710
+ f.write(content)
711
+
712
+
713
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
714
+ """
715
+ 1. Put the provided model to cpu
716
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
717
+ 3. Load it into the provided model
718
+
719
+ Args:
720
+ - ``model``: the model object to update
721
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
722
+ - ``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``
723
+
724
+ Returns:
725
+ - ``model`: modified model
726
+
727
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
728
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
729
+ conveniently placed for you in the checkpoint folder.
730
+
731
+ A typical usage might be ::
732
+
733
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
734
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
735
+ # submit to model hub or save the model to share with others
736
+
737
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
738
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
739
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
740
+
741
+ """
742
+ logger.info("Extracting fp32 weights")
743
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
744
+
745
+ logger.info("Overwriting model with fp32 weights")
746
+ model = model.cpu()
747
+ model.load_state_dict(state_dict, strict=False)
748
+
749
+ return model
750
+
751
+
752
+ if __name__ == "__main__":
753
+ parser = argparse.ArgumentParser()
754
+ parser.add_argument("checkpoint_dir",
755
+ type=str,
756
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
757
+ parser.add_argument("output_dir",
758
+ type=str,
759
+ help="directory to the pytorch fp32 state_dict output files"
760
+ "(e.g. path/checkpoint-12-output/)")
761
+ parser.add_argument(
762
+ "--max_shard_size",
763
+ type=str,
764
+ default="5GB",
765
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
766
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
767
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
768
+ "without CPU OOM issues.")
769
+ parser.add_argument(
770
+ "--safe_serialization",
771
+ default=False,
772
+ action='store_true',
773
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
774
+ parser.add_argument("-t",
775
+ "--tag",
776
+ type=str,
777
+ default=None,
778
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
779
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
780
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
781
+ args = parser.parse_args()
782
+
783
+ debug = args.debug
784
+
785
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
786
+ args.output_dir,
787
+ max_shard_size=args.max_shard_size,
788
+ safe_serialization=args.safe_serialization,
789
+ tag=args.tag,
790
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
qwen3/fdd_srkl/checkpoint-314/README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen3-0.6B
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:Qwen/Qwen3-0.6B
7
+ - llama-factory
8
+ - lora
9
+ - transformers
10
+ ---
11
+
12
+ # Model Card for Model ID
13
+
14
+ <!-- Provide a quick summary of what the model is/does. -->
15
+
16
+
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+
22
+ <!-- Provide a longer summary of what this model is. -->
23
+
24
+
25
+
26
+ - **Developed by:** [More Information Needed]
27
+ - **Funded by [optional]:** [More Information Needed]
28
+ - **Shared by [optional]:** [More Information Needed]
29
+ - **Model type:** [More Information Needed]
30
+ - **Language(s) (NLP):** [More Information Needed]
31
+ - **License:** [More Information Needed]
32
+ - **Finetuned from model [optional]:** [More Information Needed]
33
+
34
+ ### Model Sources [optional]
35
+
36
+ <!-- Provide the basic links for the model. -->
37
+
38
+ - **Repository:** [More Information Needed]
39
+ - **Paper [optional]:** [More Information Needed]
40
+ - **Demo [optional]:** [More Information Needed]
41
+
42
+ ## Uses
43
+
44
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
45
+
46
+ ### Direct Use
47
+
48
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Downstream Use [optional]
53
+
54
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
55
+
56
+ [More Information Needed]
57
+
58
+ ### Out-of-Scope Use
59
+
60
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ## Bias, Risks, and Limitations
65
+
66
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
67
+
68
+ [More Information Needed]
69
+
70
+ ### Recommendations
71
+
72
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
73
+
74
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
75
+
76
+ ## How to Get Started with the Model
77
+
78
+ Use the code below to get started with the model.
79
+
80
+ [More Information Needed]
81
+
82
+ ## Training Details
83
+
84
+ ### Training Data
85
+
86
+ <!-- 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. -->
87
+
88
+ [More Information Needed]
89
+
90
+ ### Training Procedure
91
+
92
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
93
+
94
+ #### Preprocessing [optional]
95
+
96
+ [More Information Needed]
97
+
98
+
99
+ #### Training Hyperparameters
100
+
101
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
102
+
103
+ #### Speeds, Sizes, Times [optional]
104
+
105
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
106
+
107
+ [More Information Needed]
108
+
109
+ ## Evaluation
110
+
111
+ <!-- This section describes the evaluation protocols and provides the results. -->
112
+
113
+ ### Testing Data, Factors & Metrics
114
+
115
+ #### Testing Data
116
+
117
+ <!-- This should link to a Dataset Card if possible. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Factors
122
+
123
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
124
+
125
+ [More Information Needed]
126
+
127
+ #### Metrics
128
+
129
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
130
+
131
+ [More Information Needed]
132
+
133
+ ### Results
134
+
135
+ [More Information Needed]
136
+
137
+ #### Summary
138
+
139
+
140
+
141
+ ## Model Examination [optional]
142
+
143
+ <!-- Relevant interpretability work for the model goes here -->
144
+
145
+ [More Information Needed]
146
+
147
+ ## Environmental Impact
148
+
149
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
150
+
151
+ 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).
152
+
153
+ - **Hardware Type:** [More Information Needed]
154
+ - **Hours used:** [More Information Needed]
155
+ - **Cloud Provider:** [More Information Needed]
156
+ - **Compute Region:** [More Information Needed]
157
+ - **Carbon Emitted:** [More Information Needed]
158
+
159
+ ## Technical Specifications [optional]
160
+
161
+ ### Model Architecture and Objective
162
+
163
+ [More Information Needed]
164
+
165
+ ### Compute Infrastructure
166
+
167
+ [More Information Needed]
168
+
169
+ #### Hardware
170
+
171
+ [More Information Needed]
172
+
173
+ #### Software
174
+
175
+ [More Information Needed]
176
+
177
+ ## Citation [optional]
178
+
179
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
180
+
181
+ **BibTeX:**
182
+
183
+ [More Information Needed]
184
+
185
+ **APA:**
186
+
187
+ [More Information Needed]
188
+
189
+ ## Glossary [optional]
190
+
191
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
192
+
193
+ [More Information Needed]
194
+
195
+ ## More Information [optional]
196
+
197
+ [More Information Needed]
198
+
199
+ ## Model Card Authors [optional]
200
+
201
+ [More Information Needed]
202
+
203
+ ## Model Card Contact
204
+
205
+ [More Information Needed]
206
+ ### Framework versions
207
+
208
+ - PEFT 0.18.1
qwen3/fdd_srkl/checkpoint-314/adapter_config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen3-0.6B",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 64,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.1,
22
+ "megatron_config": null,
23
+ "megatron_core": "megatron.core",
24
+ "modules_to_save": null,
25
+ "peft_type": "LORA",
26
+ "peft_version": "0.18.1",
27
+ "qalora_group_size": 16,
28
+ "r": 32,
29
+ "rank_pattern": {},
30
+ "revision": null,
31
+ "target_modules": [
32
+ "k_proj",
33
+ "q_proj",
34
+ "v_proj",
35
+ "o_proj",
36
+ "up_proj",
37
+ "down_proj",
38
+ "gate_proj"
39
+ ],
40
+ "target_parameters": null,
41
+ "task_type": "CAUSAL_LM",
42
+ "trainable_token_indices": null,
43
+ "use_dora": false,
44
+ "use_qalora": false,
45
+ "use_rslora": false
46
+ }
qwen3/fdd_srkl/checkpoint-314/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0541597a8d58416bfd8df40ff0098eff9b6d1bd1dfd724a82bc5e004f4339abb
3
+ size 40422560
qwen3/fdd_srkl/checkpoint-314/chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# 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>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\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" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
qwen3/fdd_srkl/checkpoint-314/global_step314/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e62f46f4e76b52e92eb30268f602e719efb9844b7407144a2dee0ac86a35e121
3
+ size 121135557
qwen3/fdd_srkl/checkpoint-314/global_step314/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4798f49fd36837bdbcf0cedc60887464a3563bba6eea3ed356e2b487e185d668
3
+ size 121135749
qwen3/fdd_srkl/checkpoint-314/global_step314/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac2495f0251c136a218bc14d62f4a12ecec6f1b7406ef3ac3aef790c17e73f91
3
+ size 351841765
qwen3/fdd_srkl/checkpoint-314/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step314
qwen3/fdd_srkl/checkpoint-314/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c58fa50d0eb2b9d0c41c4c950a755054f17af94fbb60383eee5e46d96797b4cd
3
+ size 14917
qwen3/fdd_srkl/checkpoint-314/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e89a8da6898755602708e3be195153442a313c7b82548f2de733720343c1812e
3
+ size 14917
qwen3/fdd_srkl/checkpoint-314/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17e254b5642bb75983fd5105bec79b35376cfbc99d29702287668b8767d46149
3
+ size 1465
qwen3/fdd_srkl/checkpoint-314/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
qwen3/fdd_srkl/checkpoint-314/tokenizer_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": false,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "padding_side": "right",
28
+ "split_special_tokens": false,
29
+ "tokenizer_class": "Qwen2Tokenizer",
30
+ "unk_token": null
31
+ }
qwen3/fdd_srkl/checkpoint-314/trainer_state.json ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.0,
6
+ "eval_steps": 500,
7
+ "global_step": 314,
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.06382130035899482,
14
+ "grad_norm": 2.4362361431121826,
15
+ "learning_rate": 9.996390385474569e-05,
16
+ "loss": 1.4636783599853516,
17
+ "step": 20
18
+ },
19
+ {
20
+ "epoch": 0.12764260071798963,
21
+ "grad_norm": 2.9437320232391357,
22
+ "learning_rate": 9.984797509888031e-05,
23
+ "loss": 0.5306460380554199,
24
+ "step": 40
25
+ },
26
+ {
27
+ "epoch": 0.19146390107698444,
28
+ "grad_norm": 1.3007458448410034,
29
+ "learning_rate": 9.965229938050925e-05,
30
+ "loss": 0.34657702445983884,
31
+ "step": 60
32
+ },
33
+ {
34
+ "epoch": 0.25528520143597927,
35
+ "grad_norm": 1.569557547569275,
36
+ "learning_rate": 9.937719005663432e-05,
37
+ "loss": 0.25293736457824706,
38
+ "step": 80
39
+ },
40
+ {
41
+ "epoch": 0.3191065017949741,
42
+ "grad_norm": 0.8431988954544067,
43
+ "learning_rate": 9.902308769000724e-05,
44
+ "loss": 0.208502197265625,
45
+ "step": 100
46
+ },
47
+ {
48
+ "epoch": 0.3829278021539689,
49
+ "grad_norm": 2.0384669303894043,
50
+ "learning_rate": 9.859055934360789e-05,
51
+ "loss": 0.16615729331970214,
52
+ "step": 120
53
+ },
54
+ {
55
+ "epoch": 0.4467491025129637,
56
+ "grad_norm": 1.341955542564392,
57
+ "learning_rate": 9.808029767254437e-05,
58
+ "loss": 0.14722728729248047,
59
+ "step": 140
60
+ },
61
+ {
62
+ "epoch": 0.5105704028719585,
63
+ "grad_norm": 1.9276875257492065,
64
+ "learning_rate": 9.749311981482817e-05,
65
+ "loss": 0.14779376983642578,
66
+ "step": 160
67
+ },
68
+ {
69
+ "epoch": 0.5743917032309533,
70
+ "grad_norm": 1.3371649980545044,
71
+ "learning_rate": 9.682996608280154e-05,
72
+ "loss": 0.13147571086883544,
73
+ "step": 180
74
+ },
75
+ {
76
+ "epoch": 0.6382130035899481,
77
+ "grad_norm": 1.0184792280197144,
78
+ "learning_rate": 9.609189845731207e-05,
79
+ "loss": 0.14180898666381836,
80
+ "step": 200
81
+ },
82
+ {
83
+ "epoch": 0.702034303948943,
84
+ "grad_norm": 0.5344496369361877,
85
+ "learning_rate": 9.52800988870462e-05,
86
+ "loss": 0.12216286659240723,
87
+ "step": 220
88
+ },
89
+ {
90
+ "epoch": 0.7658556043079378,
91
+ "grad_norm": 3.0611512660980225,
92
+ "learning_rate": 9.439586739574513e-05,
93
+ "loss": 0.11602286100387574,
94
+ "step": 240
95
+ },
96
+ {
97
+ "epoch": 0.8296769046669326,
98
+ "grad_norm": 0.5453760027885437,
99
+ "learning_rate": 9.344062000033414e-05,
100
+ "loss": 0.11221114397048951,
101
+ "step": 260
102
+ },
103
+ {
104
+ "epoch": 0.8934982050259274,
105
+ "grad_norm": 0.4289671778678894,
106
+ "learning_rate": 9.241588644329919e-05,
107
+ "loss": 0.11079610586166382,
108
+ "step": 280
109
+ },
110
+ {
111
+ "epoch": 0.9573195053849222,
112
+ "grad_norm": 0.4820654094219208,
113
+ "learning_rate": 9.132330774294252e-05,
114
+ "loss": 0.10537848472595215,
115
+ "step": 300
116
+ },
117
+ {
118
+ "epoch": 1.0,
119
+ "eval_generator_count": 1712.0,
120
+ "eval_generator_exact_match": 87.9089,
121
+ "eval_generator_rouge1": 99.464,
122
+ "eval_generator_rouge2": 99.1899,
123
+ "eval_generator_rougeL": 99.0517,
124
+ "eval_loss": 0.009097261354327202,
125
+ "eval_runtime": 606.4571,
126
+ "eval_samples_per_second": 5.629,
127
+ "eval_selector_accuracy": 96.6706,
128
+ "eval_selector_count": 1712.0,
129
+ "eval_steps_per_second": 0.176,
130
+ "step": 314
131
+ }
132
+ ],
133
+ "logging_steps": 20,
134
+ "max_steps": 1570,
135
+ "num_input_tokens_seen": 0,
136
+ "num_train_epochs": 5,
137
+ "save_steps": 500,
138
+ "stateful_callbacks": {
139
+ "TrainerControl": {
140
+ "args": {
141
+ "should_epoch_stop": false,
142
+ "should_evaluate": false,
143
+ "should_log": false,
144
+ "should_save": true,
145
+ "should_training_stop": false
146
+ },
147
+ "attributes": {}
148
+ }
149
+ },
150
+ "total_flos": 1.172842003562496e+16,
151
+ "train_batch_size": 2,
152
+ "trial_name": null,
153
+ "trial_params": null
154
+ }
qwen3/fdd_srkl/checkpoint-314/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb0e76106b10de1344a3493c5f04dde38b30a16fde01bc76445c98b578802418
3
+ size 7185
qwen3/fdd_srkl/checkpoint-314/zero_to_fp32.py ADDED
@@ -0,0 +1,790 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, AUTOEP_LAYERS_KEY,
37
+ AUTOEP_LAYERS_KEY_LEGACY, AUTOEP_ZERO3_EXPERT_STATE_FORMAT_KEY,
38
+ AUTOEP_ZERO3_PARTITIONED_EXPERT_STATE_FORMAT)
39
+
40
+
41
+ @dataclass
42
+ class zero_model_state:
43
+ buffers: dict()
44
+ param_shapes: dict()
45
+ shared_params: list
46
+ ds_version: int
47
+ frozen_param_shapes: dict()
48
+ frozen_param_fragments: dict()
49
+
50
+
51
+ debug = 0
52
+
53
+ # load to cpu
54
+ device = torch.device('cpu')
55
+
56
+
57
+ def atoi(text):
58
+ return int(text) if text.isdigit() else text
59
+
60
+
61
+ def natural_keys(text):
62
+ '''
63
+ alist.sort(key=natural_keys) sorts in human order
64
+ http://nedbatchelder.com/blog/200712/human_sorting.html
65
+ (See Toothy's implementation in the comments)
66
+ '''
67
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
68
+
69
+
70
+ def get_model_state_file(checkpoint_dir, zero_stage):
71
+ if not os.path.isdir(checkpoint_dir):
72
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
73
+
74
+ # there should be only one file
75
+ if zero_stage <= 2:
76
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
77
+ elif zero_stage == 3:
78
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
79
+
80
+ if not os.path.exists(file):
81
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
82
+
83
+ return file
84
+
85
+
86
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
87
+ # XXX: need to test that this simple glob rule works for multi-node setup too
88
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
89
+
90
+ if len(ckpt_files) == 0:
91
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
92
+
93
+ return ckpt_files
94
+
95
+
96
+ def get_optim_files(checkpoint_dir):
97
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
98
+
99
+
100
+ def get_model_state_files(checkpoint_dir):
101
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
102
+
103
+
104
+ def _has_autoep_zero3_partitioned_metadata(state_dict):
105
+ autoep_layers = state_dict.get(AUTOEP_LAYERS_KEY)
106
+ if autoep_layers is None:
107
+ autoep_layers = state_dict.get(AUTOEP_LAYERS_KEY_LEGACY)
108
+ if not isinstance(autoep_layers, list):
109
+ return False
110
+ return any(
111
+ isinstance(entry, dict)
112
+ and entry.get(AUTOEP_ZERO3_EXPERT_STATE_FORMAT_KEY) == AUTOEP_ZERO3_PARTITIONED_EXPERT_STATE_FORMAT
113
+ for entry in autoep_layers)
114
+
115
+
116
+ def _raise_if_autoep_zero3_partitioned_state(state_dict):
117
+ if _has_autoep_zero3_partitioned_metadata(state_dict):
118
+ raise NotImplementedError("zero_to_fp32 does not support AutoEP ZeRO-3 partition-native checkpoints. "
119
+ "AutoEP expert parameters are partitioned over expert replica groups, so "
120
+ "global data-parallel consolidation would produce incomplete expert tensors. "
121
+ "Use ds_to_universal.py for expert-aware conversion.")
122
+
123
+
124
+ def _raise_if_autoep_zero3_partitioned_checkpoint(model_files):
125
+ for file in model_files:
126
+ state_dict = torch.load(file, map_location=device, weights_only=False)
127
+ _raise_if_autoep_zero3_partitioned_state(state_dict)
128
+
129
+
130
+ def parse_model_states(files):
131
+ zero_model_states = []
132
+ for file in files:
133
+ state_dict = torch.load(file, map_location=device, weights_only=False)
134
+ _raise_if_autoep_zero3_partitioned_state(state_dict)
135
+
136
+ if BUFFER_NAMES not in state_dict:
137
+ raise ValueError(f"{file} is not a model state checkpoint")
138
+ buffer_names = state_dict[BUFFER_NAMES]
139
+ if debug:
140
+ print("Found buffers:", buffer_names)
141
+
142
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
143
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
144
+ param_shapes = state_dict[PARAM_SHAPES]
145
+
146
+ # collect parameters that are included in param_shapes
147
+ param_names = []
148
+ for s in param_shapes:
149
+ for name in s.keys():
150
+ param_names.append(name)
151
+
152
+ # update with frozen parameters
153
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
154
+ if frozen_param_shapes is not None:
155
+ if debug:
156
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
157
+ param_names += list(frozen_param_shapes.keys())
158
+
159
+ # handle shared params
160
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
161
+
162
+ ds_version = state_dict.get(DS_VERSION, None)
163
+
164
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
165
+
166
+ z_model_state = zero_model_state(buffers=buffers,
167
+ param_shapes=param_shapes,
168
+ shared_params=shared_params,
169
+ ds_version=ds_version,
170
+ frozen_param_shapes=frozen_param_shapes,
171
+ frozen_param_fragments=frozen_param_fragments)
172
+ zero_model_states.append(z_model_state)
173
+
174
+ return zero_model_states
175
+
176
+
177
+ def parse_optim_states(files, ds_checkpoint_dir):
178
+ total_files = len(files)
179
+ state_dicts = []
180
+ for f in tqdm(files, desc='Loading checkpoint shards'):
181
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
182
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
183
+ # and also handle the case where it was already removed by another helper script
184
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
185
+ state_dicts.append(state_dict)
186
+
187
+ if ZERO_STAGE not in state_dicts[0][OPTIMIZER_STATE_DICT]:
188
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
189
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
190
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
191
+
192
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
193
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
194
+ # use the max of the partition_count to get the dp world_size.
195
+
196
+ if type(world_size) is list:
197
+ world_size = max(world_size)
198
+
199
+ if world_size != total_files:
200
+ raise ValueError(
201
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
202
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
203
+ )
204
+
205
+ # the groups are named differently in each stage
206
+ if zero_stage <= 2:
207
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
208
+ elif zero_stage == 3:
209
+ fp32_groups_key = FP32_FLAT_GROUPS
210
+ else:
211
+ raise ValueError(f"unknown zero stage {zero_stage}")
212
+
213
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
214
+ return zero_stage, world_size, fp32_flat_groups
215
+
216
+
217
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
218
+ """
219
+ Returns fp32 state_dict reconstructed from ds checkpoint
220
+
221
+ Args:
222
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
223
+
224
+ """
225
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
226
+
227
+ # parse_model_states rejects AutoEP ZeRO-3 partition-native checkpoints
228
+ # before the expensive optimizer-shard load below.
229
+ model_files = get_model_state_files(ds_checkpoint_dir)
230
+ zero_model_states = parse_model_states(model_files)
231
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
232
+
233
+ optim_files = get_optim_files(ds_checkpoint_dir)
234
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
235
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
236
+
237
+ if zero_stage <= 2:
238
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
239
+ exclude_frozen_parameters)
240
+ elif zero_stage == 3:
241
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
242
+ exclude_frozen_parameters)
243
+
244
+
245
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
246
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
247
+ return
248
+
249
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
250
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
251
+
252
+ if debug:
253
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
254
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
255
+
256
+ wanted_params = len(frozen_param_shapes)
257
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
258
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
259
+ print(f'Frozen params: Have {avail_numel} numels to process.')
260
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
261
+
262
+ total_params = 0
263
+ total_numel = 0
264
+ for name, shape in frozen_param_shapes.items():
265
+ total_params += 1
266
+ unpartitioned_numel = shape.numel()
267
+ total_numel += unpartitioned_numel
268
+
269
+ state_dict[name] = frozen_param_fragments[name]
270
+
271
+ if debug:
272
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
273
+
274
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
275
+
276
+
277
+ def _has_callable(obj, fn):
278
+ attr = getattr(obj, fn, None)
279
+ return callable(attr)
280
+
281
+
282
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
283
+ param_shapes = zero_model_states[0].param_shapes
284
+
285
+ # Reconstruction protocol:
286
+ #
287
+ # XXX: document this
288
+
289
+ if debug:
290
+ for i in range(world_size):
291
+ for j in range(len(fp32_flat_groups[0])):
292
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
293
+
294
+ # XXX: memory usage doubles here (zero2)
295
+ num_param_groups = len(fp32_flat_groups[0])
296
+ merged_single_partition_of_fp32_groups = []
297
+ for i in range(num_param_groups):
298
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
299
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
300
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
301
+ avail_numel = sum(
302
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
303
+
304
+ if debug:
305
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
306
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
307
+ # not asserting if there is a mismatch due to possible padding
308
+ print(f"Have {avail_numel} numels to process.")
309
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
310
+
311
+ # params
312
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
313
+ # out-of-core computing solution
314
+ total_numel = 0
315
+ total_params = 0
316
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
317
+ offset = 0
318
+ avail_numel = full_single_fp32_vector.numel()
319
+ for name, shape in shapes.items():
320
+
321
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
322
+ total_numel += unpartitioned_numel
323
+ total_params += 1
324
+
325
+ if debug:
326
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
327
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
328
+ offset += unpartitioned_numel
329
+
330
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
331
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
332
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
333
+ # live optimizer object, so we are checking that the numbers are within the right range
334
+ align_to = 2 * world_size
335
+
336
+ def zero2_align(x):
337
+ return align_to * math.ceil(x / align_to)
338
+
339
+ if debug:
340
+ print(f"original offset={offset}, avail_numel={avail_numel}")
341
+
342
+ offset = zero2_align(offset)
343
+ avail_numel = zero2_align(avail_numel)
344
+
345
+ if debug:
346
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
347
+
348
+ # Sanity check
349
+ if offset != avail_numel:
350
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
351
+
352
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
353
+
354
+
355
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
356
+ exclude_frozen_parameters):
357
+ state_dict = OrderedDict()
358
+
359
+ # buffers
360
+ buffers = zero_model_states[0].buffers
361
+ state_dict.update(buffers)
362
+ if debug:
363
+ print(f"added {len(buffers)} buffers")
364
+
365
+ if not exclude_frozen_parameters:
366
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
367
+
368
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
369
+
370
+ # recover shared parameters
371
+ for pair in zero_model_states[0].shared_params:
372
+ if pair[1] in state_dict:
373
+ state_dict[pair[0]] = state_dict[pair[1]]
374
+
375
+ return state_dict
376
+
377
+
378
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
379
+ remainder = unpartitioned_numel % world_size
380
+ padding_numel = (world_size - remainder) if remainder else 0
381
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
382
+ return partitioned_numel, padding_numel
383
+
384
+
385
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
386
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
387
+ return
388
+
389
+ if debug:
390
+ for i in range(world_size):
391
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
392
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
393
+
394
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
395
+ wanted_params = len(frozen_param_shapes)
396
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
397
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
398
+ print(f'Frozen params: Have {avail_numel} numels to process.')
399
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
400
+
401
+ total_params = 0
402
+ total_numel = 0
403
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
404
+ total_params += 1
405
+ unpartitioned_numel = shape.numel()
406
+ total_numel += unpartitioned_numel
407
+
408
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
409
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
410
+
411
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
412
+
413
+ if debug:
414
+ print(
415
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
416
+ )
417
+
418
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
419
+
420
+
421
+ class GatheredTensor:
422
+ """
423
+ A pseudo tensor that collects partitioned weights.
424
+ It is more memory efficient when there are multiple groups.
425
+ """
426
+
427
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
428
+ self.flat_groups = flat_groups
429
+ self.flat_groups_offset = flat_groups_offset
430
+ self.offset = offset
431
+ self.partitioned_numel = partitioned_numel
432
+ self.shape = shape
433
+ self.dtype = self.flat_groups[0][0].dtype
434
+
435
+ def contiguous(self):
436
+ """
437
+ Merge partitioned weights from flat_groups into a single tensor.
438
+ """
439
+ end_idx = self.offset + self.partitioned_numel
440
+ world_size = len(self.flat_groups)
441
+ pad_flat_param_chunks = []
442
+
443
+ for rank_i in range(world_size):
444
+ # for each rank, we need to collect weights from related group/groups
445
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
446
+ start_group_id = None
447
+ end_group_id = None
448
+ for group_id in range(len(self.flat_groups_offset)):
449
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
450
+ start_group_id = group_id
451
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
452
+ end_group_id = group_id
453
+ break
454
+ # collect weights from related group/groups
455
+ for group_id in range(start_group_id, end_group_id + 1):
456
+ flat_tensor = flat_groups_at_rank_i[group_id]
457
+ start_offset = self.offset - self.flat_groups_offset[group_id]
458
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
459
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
460
+
461
+ # collect weights from all ranks
462
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
463
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
464
+ return param
465
+
466
+
467
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
468
+ param_shapes = zero_model_states[0].param_shapes
469
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
470
+
471
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
472
+ # param, re-consolidating each param, while dealing with padding if any
473
+
474
+ # merge list of dicts, preserving order
475
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
476
+
477
+ if debug:
478
+ for i in range(world_size):
479
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
480
+
481
+ wanted_params = len(param_shapes)
482
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
483
+ # not asserting if there is a mismatch due to possible padding
484
+ avail_numel = fp32_flat_groups[0].numel() * world_size
485
+ print(f"Trainable params: Have {avail_numel} numels to process.")
486
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
487
+
488
+ # params
489
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
490
+ # out-of-core computing solution
491
+ offset = 0
492
+ total_numel = 0
493
+ total_params = 0
494
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
495
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
496
+ unpartitioned_numel = shape.numel()
497
+ total_numel += unpartitioned_numel
498
+ total_params += 1
499
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
500
+
501
+ if debug:
502
+ print(
503
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
504
+ )
505
+
506
+ # memory efficient tensor
507
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
508
+ state_dict[name] = tensor
509
+ offset += partitioned_numel
510
+
511
+ offset *= world_size
512
+
513
+ # Sanity check
514
+ if offset != avail_numel:
515
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
516
+
517
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
518
+
519
+
520
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
521
+ exclude_frozen_parameters):
522
+ state_dict = OrderedDict()
523
+
524
+ # buffers
525
+ buffers = zero_model_states[0].buffers
526
+ state_dict.update(buffers)
527
+ if debug:
528
+ print(f"added {len(buffers)} buffers")
529
+
530
+ if not exclude_frozen_parameters:
531
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
532
+
533
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
534
+
535
+ # recover shared parameters
536
+ for pair in zero_model_states[0].shared_params:
537
+ if pair[1] in state_dict:
538
+ state_dict[pair[0]] = state_dict[pair[1]]
539
+
540
+ return state_dict
541
+
542
+
543
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
544
+ """
545
+ Convert state_dict of GatheredTensor to torch tensor
546
+ """
547
+ torch_state_dict = {}
548
+ converted_tensors = {}
549
+ for name, tensor in state_dict.items():
550
+ tensor_id = id(tensor)
551
+ if tensor_id in converted_tensors: # shared tensors
552
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
553
+ torch_state_dict[name] = shared_tensor
554
+ else:
555
+ converted_tensors[tensor_id] = name
556
+ if return_empty_tensor:
557
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
558
+ else:
559
+ torch_state_dict[name] = tensor.contiguous()
560
+ return torch_state_dict
561
+
562
+
563
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
564
+ tag=None,
565
+ exclude_frozen_parameters=False,
566
+ lazy_mode=False):
567
+ """
568
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
569
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
570
+ via a model hub.
571
+
572
+ Args:
573
+ - ``checkpoint_dir``: path to the desired checkpoint folder
574
+ - ``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``
575
+ - ``exclude_frozen_parameters``: exclude frozen parameters
576
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
577
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
578
+
579
+ Returns:
580
+ - pytorch ``state_dict``
581
+
582
+ A typical usage might be ::
583
+
584
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
585
+ # do the training and checkpoint saving
586
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
587
+ model = model.cpu() # move to cpu
588
+ model.load_state_dict(state_dict)
589
+ # submit to model hub or save the model to share with others
590
+
591
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
592
+ application. i.e. you will need to re-initialize the deepspeed engine, since
593
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
594
+
595
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
596
+
597
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
598
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
599
+ the checkpoint. Or you can load state_dict in lazy mode ::
600
+
601
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
602
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
603
+ for name, lazy_tensor in state_dict.item():
604
+ tensor = lazy_tensor.contiguous() # to cpu
605
+ print(name, tensor)
606
+ # del tensor to release memory if it no longer in use
607
+ """
608
+ if tag is None:
609
+ latest_path = os.path.join(checkpoint_dir, 'latest')
610
+ if os.path.isfile(latest_path):
611
+ with open(latest_path, 'r') as fd:
612
+ tag = fd.read().strip()
613
+ else:
614
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
615
+
616
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
617
+
618
+ if not os.path.isdir(ds_checkpoint_dir):
619
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
620
+
621
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
622
+ if lazy_mode:
623
+ return state_dict
624
+ else:
625
+ return to_torch_tensor(state_dict)
626
+
627
+
628
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
629
+ output_dir,
630
+ max_shard_size="5GB",
631
+ safe_serialization=False,
632
+ tag=None,
633
+ exclude_frozen_parameters=False):
634
+ """
635
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
636
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
637
+
638
+ Args:
639
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
640
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
641
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
642
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
643
+ - ``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``
644
+ - ``exclude_frozen_parameters``: exclude frozen parameters
645
+ """
646
+
647
+ # Dependency pre-check
648
+ if safe_serialization:
649
+ try:
650
+ from safetensors.torch import save_file
651
+ except ImportError:
652
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
653
+ raise
654
+ if max_shard_size is not None:
655
+ try:
656
+ from huggingface_hub import split_torch_state_dict_into_shards
657
+ except ImportError:
658
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
659
+ raise
660
+
661
+ # Convert zero checkpoint to state_dict
662
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
663
+ tag,
664
+ exclude_frozen_parameters,
665
+ lazy_mode=True)
666
+
667
+ # Shard the model if it is too big.
668
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
669
+ if max_shard_size is not None:
670
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
671
+ # an memory-efficient approach for sharding
672
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
673
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
674
+ filename_pattern=filename_pattern,
675
+ max_shard_size=max_shard_size)
676
+ else:
677
+ from collections import namedtuple
678
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
679
+ state_dict_split = StateDictSplit(is_sharded=False,
680
+ filename_to_tensors={weights_name: list(state_dict.keys())})
681
+
682
+ # Save the model by shard
683
+ os.makedirs(output_dir, exist_ok=True)
684
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
685
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
686
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
687
+ shard_state_dict = to_torch_tensor(shard_state_dict)
688
+ output_path = os.path.join(output_dir, shard_file)
689
+ if safe_serialization:
690
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
691
+ else:
692
+ torch.save(shard_state_dict, output_path)
693
+ # release the memory of current shard
694
+ for tensor_name in list(shard_state_dict.keys()):
695
+ del state_dict[tensor_name]
696
+ del shard_state_dict[tensor_name]
697
+ del shard_state_dict
698
+ gc.collect()
699
+
700
+ # Save index if sharded
701
+ if state_dict_split.is_sharded:
702
+ index = {
703
+ "metadata": state_dict_split.metadata,
704
+ "weight_map": state_dict_split.tensor_to_filename,
705
+ }
706
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
707
+ save_index_file = os.path.join(output_dir, save_index_file)
708
+ with open(save_index_file, "w", encoding="utf-8") as f:
709
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
710
+ f.write(content)
711
+
712
+
713
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
714
+ """
715
+ 1. Put the provided model to cpu
716
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
717
+ 3. Load it into the provided model
718
+
719
+ Args:
720
+ - ``model``: the model object to update
721
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
722
+ - ``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``
723
+
724
+ Returns:
725
+ - ``model`: modified model
726
+
727
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
728
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
729
+ conveniently placed for you in the checkpoint folder.
730
+
731
+ A typical usage might be ::
732
+
733
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
734
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
735
+ # submit to model hub or save the model to share with others
736
+
737
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
738
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
739
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
740
+
741
+ """
742
+ logger.info("Extracting fp32 weights")
743
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
744
+
745
+ logger.info("Overwriting model with fp32 weights")
746
+ model = model.cpu()
747
+ model.load_state_dict(state_dict, strict=False)
748
+
749
+ return model
750
+
751
+
752
+ if __name__ == "__main__":
753
+ parser = argparse.ArgumentParser()
754
+ parser.add_argument("checkpoint_dir",
755
+ type=str,
756
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
757
+ parser.add_argument("output_dir",
758
+ type=str,
759
+ help="directory to the pytorch fp32 state_dict output files"
760
+ "(e.g. path/checkpoint-12-output/)")
761
+ parser.add_argument(
762
+ "--max_shard_size",
763
+ type=str,
764
+ default="5GB",
765
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
766
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
767
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
768
+ "without CPU OOM issues.")
769
+ parser.add_argument(
770
+ "--safe_serialization",
771
+ default=False,
772
+ action='store_true',
773
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
774
+ parser.add_argument("-t",
775
+ "--tag",
776
+ type=str,
777
+ default=None,
778
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
779
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
780
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
781
+ args = parser.parse_args()
782
+
783
+ debug = args.debug
784
+
785
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
786
+ args.output_dir,
787
+ max_shard_size=args.max_shard_size,
788
+ safe_serialization=args.safe_serialization,
789
+ tag=args.tag,
790
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
qwen3/fdd_srkl/checkpoint-628/README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen3-0.6B
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:Qwen/Qwen3-0.6B
7
+ - llama-factory
8
+ - lora
9
+ - transformers
10
+ ---
11
+
12
+ # Model Card for Model ID
13
+
14
+ <!-- Provide a quick summary of what the model is/does. -->
15
+
16
+
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+
22
+ <!-- Provide a longer summary of what this model is. -->
23
+
24
+
25
+
26
+ - **Developed by:** [More Information Needed]
27
+ - **Funded by [optional]:** [More Information Needed]
28
+ - **Shared by [optional]:** [More Information Needed]
29
+ - **Model type:** [More Information Needed]
30
+ - **Language(s) (NLP):** [More Information Needed]
31
+ - **License:** [More Information Needed]
32
+ - **Finetuned from model [optional]:** [More Information Needed]
33
+
34
+ ### Model Sources [optional]
35
+
36
+ <!-- Provide the basic links for the model. -->
37
+
38
+ - **Repository:** [More Information Needed]
39
+ - **Paper [optional]:** [More Information Needed]
40
+ - **Demo [optional]:** [More Information Needed]
41
+
42
+ ## Uses
43
+
44
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
45
+
46
+ ### Direct Use
47
+
48
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Downstream Use [optional]
53
+
54
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
55
+
56
+ [More Information Needed]
57
+
58
+ ### Out-of-Scope Use
59
+
60
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ## Bias, Risks, and Limitations
65
+
66
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
67
+
68
+ [More Information Needed]
69
+
70
+ ### Recommendations
71
+
72
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
73
+
74
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
75
+
76
+ ## How to Get Started with the Model
77
+
78
+ Use the code below to get started with the model.
79
+
80
+ [More Information Needed]
81
+
82
+ ## Training Details
83
+
84
+ ### Training Data
85
+
86
+ <!-- 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. -->
87
+
88
+ [More Information Needed]
89
+
90
+ ### Training Procedure
91
+
92
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
93
+
94
+ #### Preprocessing [optional]
95
+
96
+ [More Information Needed]
97
+
98
+
99
+ #### Training Hyperparameters
100
+
101
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
102
+
103
+ #### Speeds, Sizes, Times [optional]
104
+
105
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
106
+
107
+ [More Information Needed]
108
+
109
+ ## Evaluation
110
+
111
+ <!-- This section describes the evaluation protocols and provides the results. -->
112
+
113
+ ### Testing Data, Factors & Metrics
114
+
115
+ #### Testing Data
116
+
117
+ <!-- This should link to a Dataset Card if possible. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Factors
122
+
123
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
124
+
125
+ [More Information Needed]
126
+
127
+ #### Metrics
128
+
129
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
130
+
131
+ [More Information Needed]
132
+
133
+ ### Results
134
+
135
+ [More Information Needed]
136
+
137
+ #### Summary
138
+
139
+
140
+
141
+ ## Model Examination [optional]
142
+
143
+ <!-- Relevant interpretability work for the model goes here -->
144
+
145
+ [More Information Needed]
146
+
147
+ ## Environmental Impact
148
+
149
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
150
+
151
+ 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).
152
+
153
+ - **Hardware Type:** [More Information Needed]
154
+ - **Hours used:** [More Information Needed]
155
+ - **Cloud Provider:** [More Information Needed]
156
+ - **Compute Region:** [More Information Needed]
157
+ - **Carbon Emitted:** [More Information Needed]
158
+
159
+ ## Technical Specifications [optional]
160
+
161
+ ### Model Architecture and Objective
162
+
163
+ [More Information Needed]
164
+
165
+ ### Compute Infrastructure
166
+
167
+ [More Information Needed]
168
+
169
+ #### Hardware
170
+
171
+ [More Information Needed]
172
+
173
+ #### Software
174
+
175
+ [More Information Needed]
176
+
177
+ ## Citation [optional]
178
+
179
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
180
+
181
+ **BibTeX:**
182
+
183
+ [More Information Needed]
184
+
185
+ **APA:**
186
+
187
+ [More Information Needed]
188
+
189
+ ## Glossary [optional]
190
+
191
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
192
+
193
+ [More Information Needed]
194
+
195
+ ## More Information [optional]
196
+
197
+ [More Information Needed]
198
+
199
+ ## Model Card Authors [optional]
200
+
201
+ [More Information Needed]
202
+
203
+ ## Model Card Contact
204
+
205
+ [More Information Needed]
206
+ ### Framework versions
207
+
208
+ - PEFT 0.18.1
qwen3/fdd_srkl/checkpoint-628/adapter_config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen3-0.6B",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 64,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.1,
22
+ "megatron_config": null,
23
+ "megatron_core": "megatron.core",
24
+ "modules_to_save": null,
25
+ "peft_type": "LORA",
26
+ "peft_version": "0.18.1",
27
+ "qalora_group_size": 16,
28
+ "r": 32,
29
+ "rank_pattern": {},
30
+ "revision": null,
31
+ "target_modules": [
32
+ "k_proj",
33
+ "q_proj",
34
+ "v_proj",
35
+ "o_proj",
36
+ "up_proj",
37
+ "down_proj",
38
+ "gate_proj"
39
+ ],
40
+ "target_parameters": null,
41
+ "task_type": "CAUSAL_LM",
42
+ "trainable_token_indices": null,
43
+ "use_dora": false,
44
+ "use_qalora": false,
45
+ "use_rslora": false
46
+ }
qwen3/fdd_srkl/checkpoint-628/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c60a45c15516253317a55bd9d5a0cae46c3e4650e61ee00a1c7b18769d0724c
3
+ size 40422560
qwen3/fdd_srkl/checkpoint-628/chat_template.jinja ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {{- messages[0].content + '\n\n' }}
5
+ {%- endif %}
6
+ {{- "# 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>" }}
7
+ {%- for tool in tools %}
8
+ {{- "\n" }}
9
+ {{- tool | tojson }}
10
+ {%- endfor %}
11
+ {{- "\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" }}
12
+ {%- else %}
13
+ {%- if messages[0].role == 'system' %}
14
+ {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
15
+ {%- endif %}
16
+ {%- endif %}
17
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
18
+ {%- for message in messages[::-1] %}
19
+ {%- set index = (messages|length - 1) - loop.index0 %}
20
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
21
+ {%- set ns.multi_step_tool = false %}
22
+ {%- set ns.last_query_index = index %}
23
+ {%- endif %}
24
+ {%- endfor %}
25
+ {%- for message in messages %}
26
+ {%- if message.content is string %}
27
+ {%- set content = message.content %}
28
+ {%- else %}
29
+ {%- set content = '' %}
30
+ {%- endif %}
31
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
32
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
33
+ {%- elif message.role == "assistant" %}
34
+ {%- set reasoning_content = '' %}
35
+ {%- if message.reasoning_content is string %}
36
+ {%- set reasoning_content = message.reasoning_content %}
37
+ {%- else %}
38
+ {%- if '</think>' in content %}
39
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
40
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
41
+ {%- endif %}
42
+ {%- endif %}
43
+ {%- if loop.index0 > ns.last_query_index %}
44
+ {%- if loop.last or (not loop.last and reasoning_content) %}
45
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
46
+ {%- else %}
47
+ {{- '<|im_start|>' + message.role + '\n' + content }}
48
+ {%- endif %}
49
+ {%- else %}
50
+ {{- '<|im_start|>' + message.role + '\n' + content }}
51
+ {%- endif %}
52
+ {%- if message.tool_calls %}
53
+ {%- for tool_call in message.tool_calls %}
54
+ {%- if (loop.first and content) or (not loop.first) %}
55
+ {{- '\n' }}
56
+ {%- endif %}
57
+ {%- if tool_call.function %}
58
+ {%- set tool_call = tool_call.function %}
59
+ {%- endif %}
60
+ {{- '<tool_call>\n{"name": "' }}
61
+ {{- tool_call.name }}
62
+ {{- '", "arguments": ' }}
63
+ {%- if tool_call.arguments is string %}
64
+ {{- tool_call.arguments }}
65
+ {%- else %}
66
+ {{- tool_call.arguments | tojson }}
67
+ {%- endif %}
68
+ {{- '}\n</tool_call>' }}
69
+ {%- endfor %}
70
+ {%- endif %}
71
+ {{- '<|im_end|>\n' }}
72
+ {%- elif message.role == "tool" %}
73
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
74
+ {{- '<|im_start|>user' }}
75
+ {%- endif %}
76
+ {{- '\n<tool_response>\n' }}
77
+ {{- content }}
78
+ {{- '\n</tool_response>' }}
79
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
80
+ {{- '<|im_end|>\n' }}
81
+ {%- endif %}
82
+ {%- endif %}
83
+ {%- endfor %}
84
+ {%- if add_generation_prompt %}
85
+ {{- '<|im_start|>assistant\n' }}
86
+ {%- if enable_thinking is defined and enable_thinking is false %}
87
+ {{- '<think>\n\n</think>\n\n' }}
88
+ {%- endif %}
89
+ {%- endif %}
qwen3/fdd_srkl/checkpoint-628/global_step628/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b129c1b9f8ce13480079741c6f238ab6b9c3dde27f44d00f26215716830ea0ab
3
+ size 121135557
qwen3/fdd_srkl/checkpoint-628/global_step628/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21a8ae54bdf1cbe89e467069dc29bbb07b9efb6623c0534f7f37c34b04efd6a9
3
+ size 121135749
qwen3/fdd_srkl/checkpoint-628/global_step628/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da73dee48711c1760c1f3486c6990db7982d1b81e97c9012bbd162967a7a91ea
3
+ size 351841765
qwen3/fdd_srkl/checkpoint-628/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step628
qwen3/fdd_srkl/checkpoint-628/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0753776e10d2844af8605bc24a224af48189614693939c0c98ad8fef5a0e0b4
3
+ size 14917
qwen3/fdd_srkl/checkpoint-628/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4978b524e78ad211507c5eca2a017bd220e731f0ada7a2f3126361d8f9286ad
3
+ size 14917
qwen3/fdd_srkl/checkpoint-628/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb823a2c51d7fb42dfe3b693a7159784285dbf38c5a797e6e73292096123ab7a
3
+ size 1465
qwen3/fdd_srkl/checkpoint-628/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506
3
+ size 11422650
qwen3/fdd_srkl/checkpoint-628/tokenizer_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": false,
24
+ "local_files_only": false,
25
+ "model_max_length": 131072,
26
+ "pad_token": "<|endoftext|>",
27
+ "padding_side": "right",
28
+ "split_special_tokens": false,
29
+ "tokenizer_class": "Qwen2Tokenizer",
30
+ "unk_token": null
31
+ }
qwen3/fdd_srkl/checkpoint-628/trainer_state.json ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 2.0,
6
+ "eval_steps": 500,
7
+ "global_step": 628,
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.06382130035899482,
14
+ "grad_norm": 2.4362361431121826,
15
+ "learning_rate": 9.996390385474569e-05,
16
+ "loss": 1.4636783599853516,
17
+ "step": 20
18
+ },
19
+ {
20
+ "epoch": 0.12764260071798963,
21
+ "grad_norm": 2.9437320232391357,
22
+ "learning_rate": 9.984797509888031e-05,
23
+ "loss": 0.5306460380554199,
24
+ "step": 40
25
+ },
26
+ {
27
+ "epoch": 0.19146390107698444,
28
+ "grad_norm": 1.3007458448410034,
29
+ "learning_rate": 9.965229938050925e-05,
30
+ "loss": 0.34657702445983884,
31
+ "step": 60
32
+ },
33
+ {
34
+ "epoch": 0.25528520143597927,
35
+ "grad_norm": 1.569557547569275,
36
+ "learning_rate": 9.937719005663432e-05,
37
+ "loss": 0.25293736457824706,
38
+ "step": 80
39
+ },
40
+ {
41
+ "epoch": 0.3191065017949741,
42
+ "grad_norm": 0.8431988954544067,
43
+ "learning_rate": 9.902308769000724e-05,
44
+ "loss": 0.208502197265625,
45
+ "step": 100
46
+ },
47
+ {
48
+ "epoch": 0.3829278021539689,
49
+ "grad_norm": 2.0384669303894043,
50
+ "learning_rate": 9.859055934360789e-05,
51
+ "loss": 0.16615729331970214,
52
+ "step": 120
53
+ },
54
+ {
55
+ "epoch": 0.4467491025129637,
56
+ "grad_norm": 1.341955542564392,
57
+ "learning_rate": 9.808029767254437e-05,
58
+ "loss": 0.14722728729248047,
59
+ "step": 140
60
+ },
61
+ {
62
+ "epoch": 0.5105704028719585,
63
+ "grad_norm": 1.9276875257492065,
64
+ "learning_rate": 9.749311981482817e-05,
65
+ "loss": 0.14779376983642578,
66
+ "step": 160
67
+ },
68
+ {
69
+ "epoch": 0.5743917032309533,
70
+ "grad_norm": 1.3371649980545044,
71
+ "learning_rate": 9.682996608280154e-05,
72
+ "loss": 0.13147571086883544,
73
+ "step": 180
74
+ },
75
+ {
76
+ "epoch": 0.6382130035899481,
77
+ "grad_norm": 1.0184792280197144,
78
+ "learning_rate": 9.609189845731207e-05,
79
+ "loss": 0.14180898666381836,
80
+ "step": 200
81
+ },
82
+ {
83
+ "epoch": 0.702034303948943,
84
+ "grad_norm": 0.5344496369361877,
85
+ "learning_rate": 9.52800988870462e-05,
86
+ "loss": 0.12216286659240723,
87
+ "step": 220
88
+ },
89
+ {
90
+ "epoch": 0.7658556043079378,
91
+ "grad_norm": 3.0611512660980225,
92
+ "learning_rate": 9.439586739574513e-05,
93
+ "loss": 0.11602286100387574,
94
+ "step": 240
95
+ },
96
+ {
97
+ "epoch": 0.8296769046669326,
98
+ "grad_norm": 0.5453760027885437,
99
+ "learning_rate": 9.344062000033414e-05,
100
+ "loss": 0.11221114397048951,
101
+ "step": 260
102
+ },
103
+ {
104
+ "epoch": 0.8934982050259274,
105
+ "grad_norm": 0.4289671778678894,
106
+ "learning_rate": 9.241588644329919e-05,
107
+ "loss": 0.11079610586166382,
108
+ "step": 280
109
+ },
110
+ {
111
+ "epoch": 0.9573195053849222,
112
+ "grad_norm": 0.4820654094219208,
113
+ "learning_rate": 9.132330774294252e-05,
114
+ "loss": 0.10537848472595215,
115
+ "step": 300
116
+ },
117
+ {
118
+ "epoch": 1.0,
119
+ "eval_generator_count": 1712.0,
120
+ "eval_generator_exact_match": 87.9089,
121
+ "eval_generator_rouge1": 99.464,
122
+ "eval_generator_rouge2": 99.1899,
123
+ "eval_generator_rougeL": 99.0517,
124
+ "eval_loss": 0.009097261354327202,
125
+ "eval_runtime": 606.4571,
126
+ "eval_samples_per_second": 5.629,
127
+ "eval_selector_accuracy": 96.6706,
128
+ "eval_selector_count": 1712.0,
129
+ "eval_steps_per_second": 0.176,
130
+ "step": 314
131
+ },
132
+ {
133
+ "epoch": 1.0191463901076985,
134
+ "grad_norm": 3.0870883464813232,
135
+ "learning_rate": 9.01646335654399e-05,
136
+ "loss": 0.09972293376922607,
137
+ "step": 320
138
+ },
139
+ {
140
+ "epoch": 1.0829676904666932,
141
+ "grad_norm": 0.7636368870735168,
142
+ "learning_rate": 8.894171942290817e-05,
143
+ "loss": 0.08893377780914306,
144
+ "step": 340
145
+ },
146
+ {
147
+ "epoch": 1.146788990825688,
148
+ "grad_norm": 0.4203242063522339,
149
+ "learning_rate": 8.765652370197003e-05,
150
+ "loss": 0.08573378920555115,
151
+ "step": 360
152
+ },
153
+ {
154
+ "epoch": 1.210610291184683,
155
+ "grad_norm": 0.371820867061615,
156
+ "learning_rate": 8.631110452757467e-05,
157
+ "loss": 0.07898830771446227,
158
+ "step": 380
159
+ },
160
+ {
161
+ "epoch": 1.2744315915436777,
162
+ "grad_norm": 0.676804780960083,
163
+ "learning_rate": 8.490761646709642e-05,
164
+ "loss": 0.08897324800491332,
165
+ "step": 400
166
+ },
167
+ {
168
+ "epoch": 1.3382528919026724,
169
+ "grad_norm": 1.0131059885025024,
170
+ "learning_rate": 8.344830707998953e-05,
171
+ "loss": 0.08602790236473083,
172
+ "step": 420
173
+ },
174
+ {
175
+ "epoch": 1.4020741922616673,
176
+ "grad_norm": 0.4733346104621887,
177
+ "learning_rate": 8.193551331852458e-05,
178
+ "loss": 0.08213704824447632,
179
+ "step": 440
180
+ },
181
+ {
182
+ "epoch": 1.4658954926206622,
183
+ "grad_norm": 0.9082027673721313,
184
+ "learning_rate": 8.037165778537033e-05,
185
+ "loss": 0.0822598934173584,
186
+ "step": 460
187
+ },
188
+ {
189
+ "epoch": 1.5297167929796571,
190
+ "grad_norm": 0.3575717508792877,
191
+ "learning_rate": 7.875924485401427e-05,
192
+ "loss": 0.0718361496925354,
193
+ "step": 480
194
+ },
195
+ {
196
+ "epoch": 1.5935380933386518,
197
+ "grad_norm": 0.3527005612850189,
198
+ "learning_rate": 7.710085665823444e-05,
199
+ "loss": 0.07293112277984619,
200
+ "step": 500
201
+ },
202
+ {
203
+ "epoch": 1.6573593936976465,
204
+ "grad_norm": 0.3359999358654022,
205
+ "learning_rate": 7.539914895704521e-05,
206
+ "loss": 0.07311422824859619,
207
+ "step": 520
208
+ },
209
+ {
210
+ "epoch": 1.7211806940566414,
211
+ "grad_norm": 0.3345245122909546,
212
+ "learning_rate": 7.365684688173908e-05,
213
+ "loss": 0.07376066446304322,
214
+ "step": 540
215
+ },
216
+ {
217
+ "epoch": 1.7850019944156363,
218
+ "grad_norm": 0.3286590874195099,
219
+ "learning_rate": 7.18767405718347e-05,
220
+ "loss": 0.06656086444854736,
221
+ "step": 560
222
+ },
223
+ {
224
+ "epoch": 1.848823294774631,
225
+ "grad_norm": 0.41298067569732666,
226
+ "learning_rate": 7.006168070692036e-05,
227
+ "loss": 0.07345538735389709,
228
+ "step": 580
229
+ },
230
+ {
231
+ "epoch": 1.9126445951336257,
232
+ "grad_norm": 0.2776452600955963,
233
+ "learning_rate": 6.821457394154786e-05,
234
+ "loss": 0.06613650321960449,
235
+ "step": 600
236
+ },
237
+ {
238
+ "epoch": 1.9764658954926206,
239
+ "grad_norm": 0.27869823575019836,
240
+ "learning_rate": 6.633837825048768e-05,
241
+ "loss": 0.06492968797683715,
242
+ "step": 620
243
+ },
244
+ {
245
+ "epoch": 2.0,
246
+ "eval_generator_count": 1712.0,
247
+ "eval_generator_exact_match": 94.743,
248
+ "eval_generator_rouge1": 99.8867,
249
+ "eval_generator_rouge2": 99.7804,
250
+ "eval_generator_rougeL": 99.6736,
251
+ "eval_loss": 0.006523935589939356,
252
+ "eval_runtime": 602.2662,
253
+ "eval_samples_per_second": 5.669,
254
+ "eval_selector_accuracy": 97.3715,
255
+ "eval_selector_count": 1712.0,
256
+ "eval_steps_per_second": 0.178,
257
+ "step": 628
258
+ }
259
+ ],
260
+ "logging_steps": 20,
261
+ "max_steps": 1570,
262
+ "num_input_tokens_seen": 0,
263
+ "num_train_epochs": 5,
264
+ "save_steps": 500,
265
+ "stateful_callbacks": {
266
+ "TrainerControl": {
267
+ "args": {
268
+ "should_epoch_stop": false,
269
+ "should_evaluate": false,
270
+ "should_log": false,
271
+ "should_save": true,
272
+ "should_training_stop": false
273
+ },
274
+ "attributes": {}
275
+ }
276
+ },
277
+ "total_flos": 2.346351770520781e+16,
278
+ "train_batch_size": 2,
279
+ "trial_name": null,
280
+ "trial_params": null
281
+ }
qwen3/fdd_srkl/checkpoint-628/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb0e76106b10de1344a3493c5f04dde38b30a16fde01bc76445c98b578802418
3
+ size 7185
qwen3/fdd_srkl/checkpoint-628/zero_to_fp32.py ADDED
@@ -0,0 +1,790 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, AUTOEP_LAYERS_KEY,
37
+ AUTOEP_LAYERS_KEY_LEGACY, AUTOEP_ZERO3_EXPERT_STATE_FORMAT_KEY,
38
+ AUTOEP_ZERO3_PARTITIONED_EXPERT_STATE_FORMAT)
39
+
40
+
41
+ @dataclass
42
+ class zero_model_state:
43
+ buffers: dict()
44
+ param_shapes: dict()
45
+ shared_params: list
46
+ ds_version: int
47
+ frozen_param_shapes: dict()
48
+ frozen_param_fragments: dict()
49
+
50
+
51
+ debug = 0
52
+
53
+ # load to cpu
54
+ device = torch.device('cpu')
55
+
56
+
57
+ def atoi(text):
58
+ return int(text) if text.isdigit() else text
59
+
60
+
61
+ def natural_keys(text):
62
+ '''
63
+ alist.sort(key=natural_keys) sorts in human order
64
+ http://nedbatchelder.com/blog/200712/human_sorting.html
65
+ (See Toothy's implementation in the comments)
66
+ '''
67
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
68
+
69
+
70
+ def get_model_state_file(checkpoint_dir, zero_stage):
71
+ if not os.path.isdir(checkpoint_dir):
72
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
73
+
74
+ # there should be only one file
75
+ if zero_stage <= 2:
76
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
77
+ elif zero_stage == 3:
78
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
79
+
80
+ if not os.path.exists(file):
81
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
82
+
83
+ return file
84
+
85
+
86
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
87
+ # XXX: need to test that this simple glob rule works for multi-node setup too
88
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
89
+
90
+ if len(ckpt_files) == 0:
91
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
92
+
93
+ return ckpt_files
94
+
95
+
96
+ def get_optim_files(checkpoint_dir):
97
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
98
+
99
+
100
+ def get_model_state_files(checkpoint_dir):
101
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
102
+
103
+
104
+ def _has_autoep_zero3_partitioned_metadata(state_dict):
105
+ autoep_layers = state_dict.get(AUTOEP_LAYERS_KEY)
106
+ if autoep_layers is None:
107
+ autoep_layers = state_dict.get(AUTOEP_LAYERS_KEY_LEGACY)
108
+ if not isinstance(autoep_layers, list):
109
+ return False
110
+ return any(
111
+ isinstance(entry, dict)
112
+ and entry.get(AUTOEP_ZERO3_EXPERT_STATE_FORMAT_KEY) == AUTOEP_ZERO3_PARTITIONED_EXPERT_STATE_FORMAT
113
+ for entry in autoep_layers)
114
+
115
+
116
+ def _raise_if_autoep_zero3_partitioned_state(state_dict):
117
+ if _has_autoep_zero3_partitioned_metadata(state_dict):
118
+ raise NotImplementedError("zero_to_fp32 does not support AutoEP ZeRO-3 partition-native checkpoints. "
119
+ "AutoEP expert parameters are partitioned over expert replica groups, so "
120
+ "global data-parallel consolidation would produce incomplete expert tensors. "
121
+ "Use ds_to_universal.py for expert-aware conversion.")
122
+
123
+
124
+ def _raise_if_autoep_zero3_partitioned_checkpoint(model_files):
125
+ for file in model_files:
126
+ state_dict = torch.load(file, map_location=device, weights_only=False)
127
+ _raise_if_autoep_zero3_partitioned_state(state_dict)
128
+
129
+
130
+ def parse_model_states(files):
131
+ zero_model_states = []
132
+ for file in files:
133
+ state_dict = torch.load(file, map_location=device, weights_only=False)
134
+ _raise_if_autoep_zero3_partitioned_state(state_dict)
135
+
136
+ if BUFFER_NAMES not in state_dict:
137
+ raise ValueError(f"{file} is not a model state checkpoint")
138
+ buffer_names = state_dict[BUFFER_NAMES]
139
+ if debug:
140
+ print("Found buffers:", buffer_names)
141
+
142
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
143
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
144
+ param_shapes = state_dict[PARAM_SHAPES]
145
+
146
+ # collect parameters that are included in param_shapes
147
+ param_names = []
148
+ for s in param_shapes:
149
+ for name in s.keys():
150
+ param_names.append(name)
151
+
152
+ # update with frozen parameters
153
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
154
+ if frozen_param_shapes is not None:
155
+ if debug:
156
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
157
+ param_names += list(frozen_param_shapes.keys())
158
+
159
+ # handle shared params
160
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
161
+
162
+ ds_version = state_dict.get(DS_VERSION, None)
163
+
164
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
165
+
166
+ z_model_state = zero_model_state(buffers=buffers,
167
+ param_shapes=param_shapes,
168
+ shared_params=shared_params,
169
+ ds_version=ds_version,
170
+ frozen_param_shapes=frozen_param_shapes,
171
+ frozen_param_fragments=frozen_param_fragments)
172
+ zero_model_states.append(z_model_state)
173
+
174
+ return zero_model_states
175
+
176
+
177
+ def parse_optim_states(files, ds_checkpoint_dir):
178
+ total_files = len(files)
179
+ state_dicts = []
180
+ for f in tqdm(files, desc='Loading checkpoint shards'):
181
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
182
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
183
+ # and also handle the case where it was already removed by another helper script
184
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
185
+ state_dicts.append(state_dict)
186
+
187
+ if ZERO_STAGE not in state_dicts[0][OPTIMIZER_STATE_DICT]:
188
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
189
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
190
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
191
+
192
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
193
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
194
+ # use the max of the partition_count to get the dp world_size.
195
+
196
+ if type(world_size) is list:
197
+ world_size = max(world_size)
198
+
199
+ if world_size != total_files:
200
+ raise ValueError(
201
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
202
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
203
+ )
204
+
205
+ # the groups are named differently in each stage
206
+ if zero_stage <= 2:
207
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
208
+ elif zero_stage == 3:
209
+ fp32_groups_key = FP32_FLAT_GROUPS
210
+ else:
211
+ raise ValueError(f"unknown zero stage {zero_stage}")
212
+
213
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
214
+ return zero_stage, world_size, fp32_flat_groups
215
+
216
+
217
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
218
+ """
219
+ Returns fp32 state_dict reconstructed from ds checkpoint
220
+
221
+ Args:
222
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
223
+
224
+ """
225
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
226
+
227
+ # parse_model_states rejects AutoEP ZeRO-3 partition-native checkpoints
228
+ # before the expensive optimizer-shard load below.
229
+ model_files = get_model_state_files(ds_checkpoint_dir)
230
+ zero_model_states = parse_model_states(model_files)
231
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
232
+
233
+ optim_files = get_optim_files(ds_checkpoint_dir)
234
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
235
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
236
+
237
+ if zero_stage <= 2:
238
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
239
+ exclude_frozen_parameters)
240
+ elif zero_stage == 3:
241
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
242
+ exclude_frozen_parameters)
243
+
244
+
245
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
246
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
247
+ return
248
+
249
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
250
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
251
+
252
+ if debug:
253
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
254
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
255
+
256
+ wanted_params = len(frozen_param_shapes)
257
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
258
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
259
+ print(f'Frozen params: Have {avail_numel} numels to process.')
260
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
261
+
262
+ total_params = 0
263
+ total_numel = 0
264
+ for name, shape in frozen_param_shapes.items():
265
+ total_params += 1
266
+ unpartitioned_numel = shape.numel()
267
+ total_numel += unpartitioned_numel
268
+
269
+ state_dict[name] = frozen_param_fragments[name]
270
+
271
+ if debug:
272
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
273
+
274
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
275
+
276
+
277
+ def _has_callable(obj, fn):
278
+ attr = getattr(obj, fn, None)
279
+ return callable(attr)
280
+
281
+
282
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
283
+ param_shapes = zero_model_states[0].param_shapes
284
+
285
+ # Reconstruction protocol:
286
+ #
287
+ # XXX: document this
288
+
289
+ if debug:
290
+ for i in range(world_size):
291
+ for j in range(len(fp32_flat_groups[0])):
292
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
293
+
294
+ # XXX: memory usage doubles here (zero2)
295
+ num_param_groups = len(fp32_flat_groups[0])
296
+ merged_single_partition_of_fp32_groups = []
297
+ for i in range(num_param_groups):
298
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
299
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
300
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
301
+ avail_numel = sum(
302
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
303
+
304
+ if debug:
305
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
306
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
307
+ # not asserting if there is a mismatch due to possible padding
308
+ print(f"Have {avail_numel} numels to process.")
309
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
310
+
311
+ # params
312
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
313
+ # out-of-core computing solution
314
+ total_numel = 0
315
+ total_params = 0
316
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
317
+ offset = 0
318
+ avail_numel = full_single_fp32_vector.numel()
319
+ for name, shape in shapes.items():
320
+
321
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
322
+ total_numel += unpartitioned_numel
323
+ total_params += 1
324
+
325
+ if debug:
326
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
327
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
328
+ offset += unpartitioned_numel
329
+
330
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
331
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
332
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
333
+ # live optimizer object, so we are checking that the numbers are within the right range
334
+ align_to = 2 * world_size
335
+
336
+ def zero2_align(x):
337
+ return align_to * math.ceil(x / align_to)
338
+
339
+ if debug:
340
+ print(f"original offset={offset}, avail_numel={avail_numel}")
341
+
342
+ offset = zero2_align(offset)
343
+ avail_numel = zero2_align(avail_numel)
344
+
345
+ if debug:
346
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
347
+
348
+ # Sanity check
349
+ if offset != avail_numel:
350
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
351
+
352
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
353
+
354
+
355
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
356
+ exclude_frozen_parameters):
357
+ state_dict = OrderedDict()
358
+
359
+ # buffers
360
+ buffers = zero_model_states[0].buffers
361
+ state_dict.update(buffers)
362
+ if debug:
363
+ print(f"added {len(buffers)} buffers")
364
+
365
+ if not exclude_frozen_parameters:
366
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
367
+
368
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
369
+
370
+ # recover shared parameters
371
+ for pair in zero_model_states[0].shared_params:
372
+ if pair[1] in state_dict:
373
+ state_dict[pair[0]] = state_dict[pair[1]]
374
+
375
+ return state_dict
376
+
377
+
378
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
379
+ remainder = unpartitioned_numel % world_size
380
+ padding_numel = (world_size - remainder) if remainder else 0
381
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
382
+ return partitioned_numel, padding_numel
383
+
384
+
385
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
386
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
387
+ return
388
+
389
+ if debug:
390
+ for i in range(world_size):
391
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
392
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
393
+
394
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
395
+ wanted_params = len(frozen_param_shapes)
396
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
397
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
398
+ print(f'Frozen params: Have {avail_numel} numels to process.')
399
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
400
+
401
+ total_params = 0
402
+ total_numel = 0
403
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
404
+ total_params += 1
405
+ unpartitioned_numel = shape.numel()
406
+ total_numel += unpartitioned_numel
407
+
408
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
409
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
410
+
411
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
412
+
413
+ if debug:
414
+ print(
415
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
416
+ )
417
+
418
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
419
+
420
+
421
+ class GatheredTensor:
422
+ """
423
+ A pseudo tensor that collects partitioned weights.
424
+ It is more memory efficient when there are multiple groups.
425
+ """
426
+
427
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
428
+ self.flat_groups = flat_groups
429
+ self.flat_groups_offset = flat_groups_offset
430
+ self.offset = offset
431
+ self.partitioned_numel = partitioned_numel
432
+ self.shape = shape
433
+ self.dtype = self.flat_groups[0][0].dtype
434
+
435
+ def contiguous(self):
436
+ """
437
+ Merge partitioned weights from flat_groups into a single tensor.
438
+ """
439
+ end_idx = self.offset + self.partitioned_numel
440
+ world_size = len(self.flat_groups)
441
+ pad_flat_param_chunks = []
442
+
443
+ for rank_i in range(world_size):
444
+ # for each rank, we need to collect weights from related group/groups
445
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
446
+ start_group_id = None
447
+ end_group_id = None
448
+ for group_id in range(len(self.flat_groups_offset)):
449
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
450
+ start_group_id = group_id
451
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
452
+ end_group_id = group_id
453
+ break
454
+ # collect weights from related group/groups
455
+ for group_id in range(start_group_id, end_group_id + 1):
456
+ flat_tensor = flat_groups_at_rank_i[group_id]
457
+ start_offset = self.offset - self.flat_groups_offset[group_id]
458
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
459
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
460
+
461
+ # collect weights from all ranks
462
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
463
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
464
+ return param
465
+
466
+
467
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
468
+ param_shapes = zero_model_states[0].param_shapes
469
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
470
+
471
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
472
+ # param, re-consolidating each param, while dealing with padding if any
473
+
474
+ # merge list of dicts, preserving order
475
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
476
+
477
+ if debug:
478
+ for i in range(world_size):
479
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
480
+
481
+ wanted_params = len(param_shapes)
482
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
483
+ # not asserting if there is a mismatch due to possible padding
484
+ avail_numel = fp32_flat_groups[0].numel() * world_size
485
+ print(f"Trainable params: Have {avail_numel} numels to process.")
486
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
487
+
488
+ # params
489
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
490
+ # out-of-core computing solution
491
+ offset = 0
492
+ total_numel = 0
493
+ total_params = 0
494
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
495
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
496
+ unpartitioned_numel = shape.numel()
497
+ total_numel += unpartitioned_numel
498
+ total_params += 1
499
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
500
+
501
+ if debug:
502
+ print(
503
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
504
+ )
505
+
506
+ # memory efficient tensor
507
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
508
+ state_dict[name] = tensor
509
+ offset += partitioned_numel
510
+
511
+ offset *= world_size
512
+
513
+ # Sanity check
514
+ if offset != avail_numel:
515
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
516
+
517
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
518
+
519
+
520
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
521
+ exclude_frozen_parameters):
522
+ state_dict = OrderedDict()
523
+
524
+ # buffers
525
+ buffers = zero_model_states[0].buffers
526
+ state_dict.update(buffers)
527
+ if debug:
528
+ print(f"added {len(buffers)} buffers")
529
+
530
+ if not exclude_frozen_parameters:
531
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
532
+
533
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
534
+
535
+ # recover shared parameters
536
+ for pair in zero_model_states[0].shared_params:
537
+ if pair[1] in state_dict:
538
+ state_dict[pair[0]] = state_dict[pair[1]]
539
+
540
+ return state_dict
541
+
542
+
543
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
544
+ """
545
+ Convert state_dict of GatheredTensor to torch tensor
546
+ """
547
+ torch_state_dict = {}
548
+ converted_tensors = {}
549
+ for name, tensor in state_dict.items():
550
+ tensor_id = id(tensor)
551
+ if tensor_id in converted_tensors: # shared tensors
552
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
553
+ torch_state_dict[name] = shared_tensor
554
+ else:
555
+ converted_tensors[tensor_id] = name
556
+ if return_empty_tensor:
557
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
558
+ else:
559
+ torch_state_dict[name] = tensor.contiguous()
560
+ return torch_state_dict
561
+
562
+
563
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
564
+ tag=None,
565
+ exclude_frozen_parameters=False,
566
+ lazy_mode=False):
567
+ """
568
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
569
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
570
+ via a model hub.
571
+
572
+ Args:
573
+ - ``checkpoint_dir``: path to the desired checkpoint folder
574
+ - ``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``
575
+ - ``exclude_frozen_parameters``: exclude frozen parameters
576
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
577
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
578
+
579
+ Returns:
580
+ - pytorch ``state_dict``
581
+
582
+ A typical usage might be ::
583
+
584
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
585
+ # do the training and checkpoint saving
586
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
587
+ model = model.cpu() # move to cpu
588
+ model.load_state_dict(state_dict)
589
+ # submit to model hub or save the model to share with others
590
+
591
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
592
+ application. i.e. you will need to re-initialize the deepspeed engine, since
593
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
594
+
595
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
596
+
597
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
598
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
599
+ the checkpoint. Or you can load state_dict in lazy mode ::
600
+
601
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
602
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
603
+ for name, lazy_tensor in state_dict.item():
604
+ tensor = lazy_tensor.contiguous() # to cpu
605
+ print(name, tensor)
606
+ # del tensor to release memory if it no longer in use
607
+ """
608
+ if tag is None:
609
+ latest_path = os.path.join(checkpoint_dir, 'latest')
610
+ if os.path.isfile(latest_path):
611
+ with open(latest_path, 'r') as fd:
612
+ tag = fd.read().strip()
613
+ else:
614
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
615
+
616
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
617
+
618
+ if not os.path.isdir(ds_checkpoint_dir):
619
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
620
+
621
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
622
+ if lazy_mode:
623
+ return state_dict
624
+ else:
625
+ return to_torch_tensor(state_dict)
626
+
627
+
628
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
629
+ output_dir,
630
+ max_shard_size="5GB",
631
+ safe_serialization=False,
632
+ tag=None,
633
+ exclude_frozen_parameters=False):
634
+ """
635
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
636
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
637
+
638
+ Args:
639
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
640
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
641
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
642
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
643
+ - ``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``
644
+ - ``exclude_frozen_parameters``: exclude frozen parameters
645
+ """
646
+
647
+ # Dependency pre-check
648
+ if safe_serialization:
649
+ try:
650
+ from safetensors.torch import save_file
651
+ except ImportError:
652
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
653
+ raise
654
+ if max_shard_size is not None:
655
+ try:
656
+ from huggingface_hub import split_torch_state_dict_into_shards
657
+ except ImportError:
658
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
659
+ raise
660
+
661
+ # Convert zero checkpoint to state_dict
662
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
663
+ tag,
664
+ exclude_frozen_parameters,
665
+ lazy_mode=True)
666
+
667
+ # Shard the model if it is too big.
668
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
669
+ if max_shard_size is not None:
670
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
671
+ # an memory-efficient approach for sharding
672
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
673
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
674
+ filename_pattern=filename_pattern,
675
+ max_shard_size=max_shard_size)
676
+ else:
677
+ from collections import namedtuple
678
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
679
+ state_dict_split = StateDictSplit(is_sharded=False,
680
+ filename_to_tensors={weights_name: list(state_dict.keys())})
681
+
682
+ # Save the model by shard
683
+ os.makedirs(output_dir, exist_ok=True)
684
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
685
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
686
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
687
+ shard_state_dict = to_torch_tensor(shard_state_dict)
688
+ output_path = os.path.join(output_dir, shard_file)
689
+ if safe_serialization:
690
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
691
+ else:
692
+ torch.save(shard_state_dict, output_path)
693
+ # release the memory of current shard
694
+ for tensor_name in list(shard_state_dict.keys()):
695
+ del state_dict[tensor_name]
696
+ del shard_state_dict[tensor_name]
697
+ del shard_state_dict
698
+ gc.collect()
699
+
700
+ # Save index if sharded
701
+ if state_dict_split.is_sharded:
702
+ index = {
703
+ "metadata": state_dict_split.metadata,
704
+ "weight_map": state_dict_split.tensor_to_filename,
705
+ }
706
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
707
+ save_index_file = os.path.join(output_dir, save_index_file)
708
+ with open(save_index_file, "w", encoding="utf-8") as f:
709
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
710
+ f.write(content)
711
+
712
+
713
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
714
+ """
715
+ 1. Put the provided model to cpu
716
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
717
+ 3. Load it into the provided model
718
+
719
+ Args:
720
+ - ``model``: the model object to update
721
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
722
+ - ``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``
723
+
724
+ Returns:
725
+ - ``model`: modified model
726
+
727
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
728
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
729
+ conveniently placed for you in the checkpoint folder.
730
+
731
+ A typical usage might be ::
732
+
733
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
734
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
735
+ # submit to model hub or save the model to share with others
736
+
737
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
738
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
739
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
740
+
741
+ """
742
+ logger.info("Extracting fp32 weights")
743
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
744
+
745
+ logger.info("Overwriting model with fp32 weights")
746
+ model = model.cpu()
747
+ model.load_state_dict(state_dict, strict=False)
748
+
749
+ return model
750
+
751
+
752
+ if __name__ == "__main__":
753
+ parser = argparse.ArgumentParser()
754
+ parser.add_argument("checkpoint_dir",
755
+ type=str,
756
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
757
+ parser.add_argument("output_dir",
758
+ type=str,
759
+ help="directory to the pytorch fp32 state_dict output files"
760
+ "(e.g. path/checkpoint-12-output/)")
761
+ parser.add_argument(
762
+ "--max_shard_size",
763
+ type=str,
764
+ default="5GB",
765
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
766
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
767
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
768
+ "without CPU OOM issues.")
769
+ parser.add_argument(
770
+ "--safe_serialization",
771
+ default=False,
772
+ action='store_true',
773
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
774
+ parser.add_argument("-t",
775
+ "--tag",
776
+ type=str,
777
+ default=None,
778
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
779
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
780
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
781
+ args = parser.parse_args()
782
+
783
+ debug = args.debug
784
+
785
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
786
+ args.output_dir,
787
+ max_shard_size=args.max_shard_size,
788
+ safe_serialization=args.safe_serialization,
789
+ tag=args.tag,
790
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
qwen3/fdd_srkl/checkpoint-942/README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen3-0.6B
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:Qwen/Qwen3-0.6B
7
+ - llama-factory
8
+ - lora
9
+ - transformers
10
+ ---
11
+
12
+ # Model Card for Model ID
13
+
14
+ <!-- Provide a quick summary of what the model is/does. -->
15
+
16
+
17
+
18
+ ## Model Details
19
+
20
+ ### Model Description
21
+
22
+ <!-- Provide a longer summary of what this model is. -->
23
+
24
+
25
+
26
+ - **Developed by:** [More Information Needed]
27
+ - **Funded by [optional]:** [More Information Needed]
28
+ - **Shared by [optional]:** [More Information Needed]
29
+ - **Model type:** [More Information Needed]
30
+ - **Language(s) (NLP):** [More Information Needed]
31
+ - **License:** [More Information Needed]
32
+ - **Finetuned from model [optional]:** [More Information Needed]
33
+
34
+ ### Model Sources [optional]
35
+
36
+ <!-- Provide the basic links for the model. -->
37
+
38
+ - **Repository:** [More Information Needed]
39
+ - **Paper [optional]:** [More Information Needed]
40
+ - **Demo [optional]:** [More Information Needed]
41
+
42
+ ## Uses
43
+
44
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
45
+
46
+ ### Direct Use
47
+
48
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Downstream Use [optional]
53
+
54
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
55
+
56
+ [More Information Needed]
57
+
58
+ ### Out-of-Scope Use
59
+
60
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ## Bias, Risks, and Limitations
65
+
66
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
67
+
68
+ [More Information Needed]
69
+
70
+ ### Recommendations
71
+
72
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
73
+
74
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
75
+
76
+ ## How to Get Started with the Model
77
+
78
+ Use the code below to get started with the model.
79
+
80
+ [More Information Needed]
81
+
82
+ ## Training Details
83
+
84
+ ### Training Data
85
+
86
+ <!-- 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. -->
87
+
88
+ [More Information Needed]
89
+
90
+ ### Training Procedure
91
+
92
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
93
+
94
+ #### Preprocessing [optional]
95
+
96
+ [More Information Needed]
97
+
98
+
99
+ #### Training Hyperparameters
100
+
101
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
102
+
103
+ #### Speeds, Sizes, Times [optional]
104
+
105
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
106
+
107
+ [More Information Needed]
108
+
109
+ ## Evaluation
110
+
111
+ <!-- This section describes the evaluation protocols and provides the results. -->
112
+
113
+ ### Testing Data, Factors & Metrics
114
+
115
+ #### Testing Data
116
+
117
+ <!-- This should link to a Dataset Card if possible. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Factors
122
+
123
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
124
+
125
+ [More Information Needed]
126
+
127
+ #### Metrics
128
+
129
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
130
+
131
+ [More Information Needed]
132
+
133
+ ### Results
134
+
135
+ [More Information Needed]
136
+
137
+ #### Summary
138
+
139
+
140
+
141
+ ## Model Examination [optional]
142
+
143
+ <!-- Relevant interpretability work for the model goes here -->
144
+
145
+ [More Information Needed]
146
+
147
+ ## Environmental Impact
148
+
149
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
150
+
151
+ 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).
152
+
153
+ - **Hardware Type:** [More Information Needed]
154
+ - **Hours used:** [More Information Needed]
155
+ - **Cloud Provider:** [More Information Needed]
156
+ - **Compute Region:** [More Information Needed]
157
+ - **Carbon Emitted:** [More Information Needed]
158
+
159
+ ## Technical Specifications [optional]
160
+
161
+ ### Model Architecture and Objective
162
+
163
+ [More Information Needed]
164
+
165
+ ### Compute Infrastructure
166
+
167
+ [More Information Needed]
168
+
169
+ #### Hardware
170
+
171
+ [More Information Needed]
172
+
173
+ #### Software
174
+
175
+ [More Information Needed]
176
+
177
+ ## Citation [optional]
178
+
179
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
180
+
181
+ **BibTeX:**
182
+
183
+ [More Information Needed]
184
+
185
+ **APA:**
186
+
187
+ [More Information Needed]
188
+
189
+ ## Glossary [optional]
190
+
191
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
192
+
193
+ [More Information Needed]
194
+
195
+ ## More Information [optional]
196
+
197
+ [More Information Needed]
198
+
199
+ ## Model Card Authors [optional]
200
+
201
+ [More Information Needed]
202
+
203
+ ## Model Card Contact
204
+
205
+ [More Information Needed]
206
+ ### Framework versions
207
+
208
+ - PEFT 0.18.1