ASLP-lab commited on
Commit
f79bcad
·
verified ·
1 Parent(s): ee09a40

Remove nested MultiDialect-ASR folder

Browse files
MultiDialect-ASR/added_tokens.json DELETED
@@ -1,64 +0,0 @@
1
- {
2
- "</think>": 151668,
3
- "</tool_call>": 151658,
4
- "</tool_response>": 151666,
5
- "<asr_text>": 151704,
6
- "<blank10>": 151686,
7
- "<blank11>": 151687,
8
- "<blank12>": 151688,
9
- "<blank13>": 151689,
10
- "<blank14>": 151690,
11
- "<blank15>": 151691,
12
- "<blank16>": 151692,
13
- "<blank17>": 151693,
14
- "<blank18>": 151694,
15
- "<blank19>": 151695,
16
- "<blank1>": 151677,
17
- "<blank20>": 151696,
18
- "<blank21>": 151697,
19
- "<blank22>": 151698,
20
- "<blank23>": 151699,
21
- "<blank24>": 151700,
22
- "<blank25>": 151701,
23
- "<blank26>": 151702,
24
- "<blank27>": 151703,
25
- "<blank2>": 151678,
26
- "<blank3>": 151679,
27
- "<blank4>": 151680,
28
- "<blank5>": 151681,
29
- "<blank6>": 151682,
30
- "<blank7>": 151683,
31
- "<blank8>": 151684,
32
- "<blank9>": 151685,
33
- "<non_speech>": 151675,
34
- "<think>": 151667,
35
- "<tool_call>": 151657,
36
- "<tool_response>": 151665,
37
- "<tts_pad>": 151671,
38
- "<tts_text_bos>": 151672,
39
- "<tts_text_bos_single>": 151674,
40
- "<tts_text_eod>": 151673,
41
- "<|audio_end|>": 151670,
42
- "<|audio_pad|>": 151676,
43
- "<|audio_start|>": 151669,
44
- "<|box_end|>": 151649,
45
- "<|box_start|>": 151648,
46
- "<|endoftext|>": 151643,
47
- "<|file_sep|>": 151664,
48
- "<|fim_middle|>": 151660,
49
- "<|fim_pad|>": 151662,
50
- "<|fim_prefix|>": 151659,
51
- "<|fim_suffix|>": 151661,
52
- "<|im_end|>": 151645,
53
- "<|im_start|>": 151644,
54
- "<|image_pad|>": 151655,
55
- "<|object_ref_end|>": 151647,
56
- "<|object_ref_start|>": 151646,
57
- "<|quad_end|>": 151651,
58
- "<|quad_start|>": 151650,
59
- "<|repo_name|>": 151663,
60
- "<|video_pad|>": 151656,
61
- "<|vision_end|>": 151653,
62
- "<|vision_pad|>": 151654,
63
- "<|vision_start|>": 151652
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/args.json DELETED
@@ -1,404 +0,0 @@
1
- {
2
- "output_dir": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v7-20260708-235534",
3
- "overwrite_output_dir": false,
4
- "do_train": false,
5
- "do_eval": false,
6
- "do_predict": false,
7
- "eval_strategy": "steps",
8
- "prediction_loss_only": false,
9
- "per_device_train_batch_size": 96,
10
- "per_device_eval_batch_size": 96,
11
- "per_gpu_train_batch_size": null,
12
- "per_gpu_eval_batch_size": null,
13
- "gradient_accumulation_steps": 2,
14
- "eval_accumulation_steps": null,
15
- "eval_delay": 0,
16
- "torch_empty_cache_steps": null,
17
- "learning_rate": 1e-05,
18
- "weight_decay": 0.1,
19
- "adam_beta1": 0.9,
20
- "adam_beta2": 0.95,
21
- "adam_epsilon": 1e-08,
22
- "max_grad_norm": 1.0,
23
- "num_train_epochs": 1.0,
24
- "max_steps": -1,
25
- "lr_scheduler_type": "cosine",
26
- "lr_scheduler_kwargs": null,
27
- "warmup_ratio": 0.05,
28
- "warmup_steps": 0,
29
- "log_level": "passive",
30
- "log_level_replica": "warning",
31
- "log_on_each_node": true,
32
- "logging_dir": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v7-20260708-235534/runs",
33
- "logging_strategy": "steps",
34
- "logging_first_step": true,
35
- "logging_steps": 5,
36
- "logging_nan_inf_filter": true,
37
- "save_strategy": "steps",
38
- "save_steps": 500.0,
39
- "save_total_limit": null,
40
- "save_safetensors": true,
41
- "save_on_each_node": false,
42
- "save_only_model": false,
43
- "restore_callback_states_from_checkpoint": false,
44
- "no_cuda": false,
45
- "use_cpu": false,
46
- "use_mps_device": false,
47
- "seed": 42,
48
- "data_seed": 42,
49
- "jit_mode_eval": false,
50
- "bf16": true,
51
- "fp16": false,
52
- "fp16_opt_level": "O1",
53
- "half_precision_backend": "auto",
54
- "bf16_full_eval": false,
55
- "fp16_full_eval": false,
56
- "tf32": null,
57
- "local_rank": 0,
58
- "ddp_backend": null,
59
- "tpu_num_cores": null,
60
- "tpu_metrics_debug": false,
61
- "debug": null,
62
- "dataloader_drop_last": false,
63
- "eval_steps": 500.0,
64
- "dataloader_num_workers": 16,
65
- "dataloader_prefetch_factor": null,
66
- "past_index": -1,
67
- "run_name": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v7-20260708-235534",
68
- "disable_tqdm": null,
69
- "remove_unused_columns": true,
70
- "label_names": null,
71
- "load_best_model_at_end": false,
72
- "metric_for_best_model": "loss",
73
- "greater_is_better": false,
74
- "ignore_data_skip": false,
75
- "fsdp": [],
76
- "fsdp_min_num_params": 0,
77
- "fsdp_config": null,
78
- "fsdp_transformer_layer_cls_to_wrap": null,
79
- "accelerator_config": {
80
- "dispatch_batches": false
81
- },
82
- "parallelism_config": null,
83
- "deepspeed": {
84
- "fp16": {
85
- "enabled": "auto",
86
- "loss_scale": 0,
87
- "loss_scale_window": 1000,
88
- "initial_scale_power": 16,
89
- "hysteresis": 2,
90
- "min_loss_scale": 1
91
- },
92
- "bf16": {
93
- "enabled": "auto"
94
- },
95
- "zero_optimization": {
96
- "stage": 2,
97
- "offload_optimizer": {
98
- "device": "none",
99
- "pin_memory": true
100
- },
101
- "allgather_partitions": true,
102
- "allgather_bucket_size": 200000000.0,
103
- "overlap_comm": false,
104
- "reduce_scatter": true,
105
- "reduce_bucket_size": 200000000.0,
106
- "contiguous_gradients": true
107
- },
108
- "gradient_accumulation_steps": "auto",
109
- "gradient_clipping": "auto",
110
- "steps_per_print": 2000,
111
- "train_batch_size": "auto",
112
- "train_micro_batch_size_per_gpu": "auto",
113
- "wall_clock_breakdown": false
114
- },
115
- "label_smoothing_factor": 0.0,
116
- "optim": "adamw_torch_fused",
117
- "optim_args": null,
118
- "adafactor": false,
119
- "group_by_length": false,
120
- "length_column_name": "length",
121
- "report_to": [
122
- "tensorboard"
123
- ],
124
- "project": "huggingface",
125
- "trackio_space_id": "trackio",
126
- "ddp_find_unused_parameters": null,
127
- "ddp_bucket_cap_mb": null,
128
- "ddp_broadcast_buffers": null,
129
- "dataloader_pin_memory": true,
130
- "dataloader_persistent_workers": false,
131
- "skip_memory_metrics": true,
132
- "use_legacy_prediction_loop": false,
133
- "push_to_hub": false,
134
- "resume_from_checkpoint": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v6-20260707-132425/checkpoint-8500",
135
- "hub_model_id": null,
136
- "hub_strategy": "every_save",
137
- "hub_token": null,
138
- "hub_private_repo": null,
139
- "hub_always_push": false,
140
- "hub_revision": null,
141
- "gradient_checkpointing": true,
142
- "gradient_checkpointing_kwargs": "{\"use_reentrant\": false}",
143
- "include_inputs_for_metrics": false,
144
- "include_for_metrics": [],
145
- "eval_do_concat_batches": true,
146
- "fp16_backend": "auto",
147
- "push_to_hub_model_id": null,
148
- "push_to_hub_organization": null,
149
- "push_to_hub_token": null,
150
- "mp_parameters": "",
151
- "auto_find_batch_size": false,
152
- "full_determinism": false,
153
- "torchdynamo": null,
154
- "ray_scope": "last",
155
- "ddp_timeout": 18000000,
156
- "torch_compile": false,
157
- "torch_compile_backend": null,
158
- "torch_compile_mode": null,
159
- "include_tokens_per_second": false,
160
- "include_num_input_tokens_seen": false,
161
- "neftune_noise_alpha": null,
162
- "optim_target_modules": null,
163
- "batch_eval_metrics": false,
164
- "eval_on_start": false,
165
- "use_liger_kernel": false,
166
- "liger_kernel_config": null,
167
- "eval_use_gather_object": false,
168
- "average_tokens_across_devices": true,
169
- "sortish_sampler": false,
170
- "predict_with_generate": false,
171
- "generation_max_length": null,
172
- "generation_num_beams": null,
173
- "generation_config": null,
174
- "tuner_backend": "peft",
175
- "vit_gradient_checkpointing": true,
176
- "router_aux_loss_coef": 0.0,
177
- "enable_dft_loss": false,
178
- "enable_channel_loss": false,
179
- "safe_serialization": true,
180
- "max_shard_size": "5GB",
181
- "check_model": false,
182
- "acc_strategy": "token",
183
- "train_dataloader_shuffle": true,
184
- "max_epochs": null,
185
- "aligner_lr": null,
186
- "vit_lr": null,
187
- "use_logits_to_keep": null,
188
- "ds3_gather_for_generation": true,
189
- "resume_only_model": false,
190
- "optimizer": null,
191
- "loss_type": null,
192
- "eval_metric": null,
193
- "callbacks": [],
194
- "early_stop_interval": null,
195
- "eval_use_evalscope": false,
196
- "eval_dataset": [],
197
- "eval_dataset_args": null,
198
- "eval_limit": null,
199
- "eval_generation_config": null,
200
- "extra_eval_args": null,
201
- "tuner_type": "full",
202
- "use_galore": false,
203
- "galore_target_modules": null,
204
- "galore_rank": 128,
205
- "galore_update_proj_gap": 50,
206
- "galore_scale": 1.0,
207
- "galore_proj_type": "std",
208
- "galore_optim_per_parameter": false,
209
- "galore_with_embedding": false,
210
- "galore_quantization": false,
211
- "galore_proj_quant": false,
212
- "galore_proj_bits": 4,
213
- "galore_proj_group_size": 256,
214
- "galore_cos_threshold": 0.4,
215
- "galore_gamma_proj": 2,
216
- "galore_queue_size": 5,
217
- "lisa_activated_layers": 0,
218
- "lisa_step_interval": 20,
219
- "use_flash_ckpt": false,
220
- "use_ray": false,
221
- "ray_exp_name": null,
222
- "device_groups": null,
223
- "model": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en_lora/v2-20260629-195144/checkpoint-10000-merged",
224
- "model_type": "qwen3_asr",
225
- "model_revision": null,
226
- "task_type": "causal_lm",
227
- "torch_dtype": "bfloat16",
228
- "attn_impl": "flash_attention_2",
229
- "experts_impl": null,
230
- "new_special_tokens": [],
231
- "num_labels": null,
232
- "problem_type": null,
233
- "rope_scaling": null,
234
- "device_map": null,
235
- "max_memory": {},
236
- "max_model_len": null,
237
- "local_repo_path": null,
238
- "init_strategy": null,
239
- "template": "qwen3_asr",
240
- "system": null,
241
- "max_length": 1024,
242
- "truncation_strategy": "delete",
243
- "max_pixels": null,
244
- "agent_template": null,
245
- "norm_bbox": null,
246
- "use_chat_template": true,
247
- "padding_side": "right",
248
- "padding_free": true,
249
- "loss_scale": "default",
250
- "sequence_parallel_size": 1,
251
- "is_binary_loss_scale": null,
252
- "template_backend": "swift",
253
- "response_prefix": null,
254
- "enable_thinking": null,
255
- "preserve_thinking": null,
256
- "add_non_thinking_prefix": true,
257
- "disable_ignore_empty_think": false,
258
- "dataset": [
259
- "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/data/train_v8_processed/train_new.jsonl"
260
- ],
261
- "val_dataset": [
262
- "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/data/train_v8_processed/dev.jsonl"
263
- ],
264
- "cached_dataset": [],
265
- "cached_val_dataset": [],
266
- "split_dataset_ratio": 0.0,
267
- "dataset_num_proc": 8,
268
- "load_from_cache_file": true,
269
- "dataset_shuffle": true,
270
- "val_dataset_shuffle": false,
271
- "streaming": false,
272
- "interleave_prob": null,
273
- "stopping_strategy": "first_exhausted",
274
- "shuffle_buffer_size": 1000,
275
- "download_mode": "reuse_dataset_if_exists",
276
- "columns": {},
277
- "strict": false,
278
- "disable_auto_column_mapping": false,
279
- "model_name": null,
280
- "model_author": null,
281
- "custom_dataset_info": [],
282
- "quant_method": null,
283
- "quant_bits": null,
284
- "hqq_axis": null,
285
- "bnb_4bit_compute_dtype": "bfloat16",
286
- "bnb_4bit_quant_type": "nf4",
287
- "bnb_4bit_use_double_quant": true,
288
- "bnb_4bit_quant_storage": null,
289
- "max_new_tokens": 64,
290
- "temperature": 0.0,
291
- "top_k": null,
292
- "top_p": null,
293
- "repetition_penalty": null,
294
- "num_beams": 1,
295
- "stream": false,
296
- "stop_words": [],
297
- "logprobs": false,
298
- "top_logprobs": null,
299
- "structured_outputs_regex": null,
300
- "adapters": [],
301
- "external_plugins": [],
302
- "custom_register_path": [],
303
- "model_kwargs": {},
304
- "enable_npu_model_patch": true,
305
- "load_args": false,
306
- "load_data_args": false,
307
- "packing": false,
308
- "packing_length": null,
309
- "packing_num_proc": 1,
310
- "lazy_tokenize": true,
311
- "use_hf": false,
312
- "ignore_args_error": false,
313
- "use_swift_lora": false,
314
- "freeze_parameters": [],
315
- "freeze_parameters_regex": null,
316
- "freeze_parameters_ratio": 0.0,
317
- "trainable_parameters": [
318
- "thinker.audio_tower.proj1",
319
- "thinker.audio_tower.proj2"
320
- ],
321
- "trainable_parameters_regex": null,
322
- "freeze_llm": false,
323
- "freeze_vit": false,
324
- "freeze_aligner": false,
325
- "target_modules": [
326
- "all-linear"
327
- ],
328
- "target_regex": null,
329
- "target_parameters": null,
330
- "modules_to_save": [],
331
- "lora_rank": 8,
332
- "lora_alpha": 32,
333
- "lora_dropout": 0.05,
334
- "lora_bias": "none",
335
- "lora_dtype": null,
336
- "lorap_lr_ratio": null,
337
- "use_rslora": false,
338
- "use_dora": false,
339
- "lora_ga_batch_size": 2,
340
- "lora_ga_iters": 2,
341
- "lora_ga_max_length": 1024,
342
- "lora_ga_direction": "ArB2r",
343
- "lora_ga_scale": "stable",
344
- "lora_ga_stable_gamma": 16,
345
- "init_weights": true,
346
- "fourier_n_frequency": 2000,
347
- "fourier_scaling": 300.0,
348
- "boft_block_size": 4,
349
- "boft_block_num": 0,
350
- "boft_n_butterfly_factor": 1,
351
- "boft_dropout": 0.0,
352
- "vera_rank": 256,
353
- "vera_projection_prng_key": 0,
354
- "vera_dropout": 0.0,
355
- "vera_d_initial": 0.1,
356
- "adapter_act": "gelu",
357
- "adapter_length": 128,
358
- "adalora_target_r": 8,
359
- "adalora_init_r": 12,
360
- "adalora_tinit": 0,
361
- "adalora_tfinal": 0,
362
- "adalora_deltaT": 1,
363
- "adalora_beta1": 0.85,
364
- "adalora_beta2": 0.85,
365
- "adalora_orth_reg_weight": 0.5,
366
- "llamapro_num_new_blocks": 4,
367
- "llamapro_num_groups": null,
368
- "reft_layer_key": null,
369
- "reft_layers": null,
370
- "reft_rank": 4,
371
- "reft_intervention_type": "LoreftIntervention",
372
- "reft_args": null,
373
- "swanlab_token": null,
374
- "swanlab_project": "ms-swift",
375
- "swanlab_workspace": null,
376
- "swanlab_exp_name": null,
377
- "swanlab_notification_method": null,
378
- "swanlab_webhook_url": null,
379
- "swanlab_secret": null,
380
- "swanlab_sender_email": null,
381
- "swanlab_receiver_email": null,
382
- "swanlab_smtp_server": null,
383
- "swanlab_smtp_port": null,
384
- "swanlab_email_language": "zh",
385
- "swanlab_mode": "cloud",
386
- "add_version": true,
387
- "create_checkpoint_symlink": false,
388
- "zero_hpz_partition_size": null,
389
- "deepspeed_autotp_size": null,
390
- "swift_version": "4.3.1",
391
- "ckpt_dir": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en_lora/v2-20260629-195144/checkpoint-10000-merged",
392
- "rank": 0,
393
- "global_world_size": 8,
394
- "local_world_size": 8,
395
- "model_suffix": "checkpoint-10000-merged",
396
- "model_info": "ModelInfo(model_type='qwen3_asr', model_dir='/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en_lora/v2-20260629-195144/checkpoint-10000-merged', torch_dtype=torch.bfloat16, max_model_len=65536, quant_method=None, quant_bits=None, rope_scaling={'interleaved': True, 'mrope_interleaved': True, 'mrope_section': [24, 20, 20], 'rope_type': 'default', 'type': 'default'}, is_moe_model=False, is_multimodal=True, config=None, task_type='causal_lm', num_labels=None)",
397
- "model_meta": "ModelMeta(model_type='qwen3_asr', model_groups=[ModelGroup(models=[Model(ms_model_id='Qwen/Qwen3-ASR-1.7B', hf_model_id='Qwen/Qwen3-ASR-1.7B', model_path=None, ms_revision=None, hf_revision=None), Model(ms_model_id='Qwen/Qwen3-ASR-0.6B', hf_model_id='Qwen/Qwen3-ASR-0.6B', model_path=None, ms_revision=None, hf_revision=None)], template='qwen3_asr', ignore_patterns=None, requires=None, tags=[])], loader=<class 'swift.model.models.qwen.Qwen3ASRLoader'>, template=None, model_arch=MultiModelKeys(arch_name='qwen3_asr', embedding=None, module_list=None, lm_head=None, q_proj=None, k_proj=None, v_proj=None, o_proj=None, attention=None, mlp=None, down_proj=None, qkv_proj=None, qk_proj=None, qa_proj=None, qb_proj=None, kv_proj=None, kva_proj=None, kvb_proj=None, language_model=['thinker.model', 'thinker.lm_head'], aligner=['thinker.audio_tower.proj1', 'thinker.audio_tower.proj2'], vision_tower=['thinker.audio_tower'], generator=[]), mcore_model_type=None, architectures=['Qwen3ASRForConditionalGeneration'], additional_saved_files=[], torch_dtype=None, is_multimodal=True, is_reward=False, task_type=None, ignore_patterns=None, requires=['qwen-asr', 'transformers==4.57.6'], tags=['audio'])",
398
- "model_dir": "/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en_lora/v2-20260629-195144/checkpoint-10000-merged",
399
- "template_meta": "QwenTemplateMeta(template_type='qwen3_asr', prefix=['<|im_start|>system\\n<|im_end|>\\n'], prompt=['<|im_start|>user\\n{{QUERY}}<|im_end|>\\n<|im_start|>assistant\\n'], chat_sep=['<|im_end|>\\n'], suffix=['<|im_end|>\\n'], template_cls=<class 'swift.template.templates.qwen.Qwen3ASRTemplate'>, system_prefix=['<|im_start|>system\\n{{SYSTEM}}<|im_end|>\\n'], default_system=None, auto_add_bos=False, stop_words=['<|endoftext|>'], agent_template='hermes', is_thinking=False, thinking_prefix='', non_thinking_prefix='', history_thinking_prefix='')",
400
- "_val_dataset_exists": true,
401
- "hub": "<class 'swift.hub.hub.MSHub'>",
402
- "evaluation_strategy": "steps",
403
- "training_args": "Seq2SeqTrainingArguments(output_dir='/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v7-20260708-235534', overwrite_output_dir=False, do_train=False, do_eval=True, do_predict=False, eval_strategy=<IntervalStrategy.STEPS: 'steps'>, prediction_loss_only=False, per_device_train_batch_size=96, per_device_eval_batch_size=96, per_gpu_train_batch_size=None, per_gpu_eval_batch_size=None, gradient_accumulation_steps=2, eval_accumulation_steps=None, eval_delay=0, torch_empty_cache_steps=None, learning_rate=1e-05, weight_decay=0.1, adam_beta1=0.9, adam_beta2=0.95, adam_epsilon=1e-08, max_grad_norm=1.0, num_train_epochs=1.0, max_steps=-1, lr_scheduler_type=<SchedulerType.COSINE: 'cosine'>, lr_scheduler_kwargs=None, warmup_ratio=0.05, warmup_steps=0, log_level='passive', log_level_replica='warning', log_on_each_node=True, logging_dir='/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v7-20260708-235534/runs', logging_strategy=<IntervalStrategy.STEPS: 'steps'>, logging_first_step=True, logging_steps=5, logging_nan_inf_filter=True, save_strategy=<SaveStrategy.STEPS: 'steps'>, save_steps=500, save_total_limit=None, save_safetensors=True, save_on_each_node=False, save_only_model=False, restore_callback_states_from_checkpoint=False, no_cuda=False, use_cpu=False, use_mps_device=False, seed=42, data_seed=42, jit_mode_eval=False, bf16=True, fp16=False, fp16_opt_level='O1', half_precision_backend='auto', bf16_full_eval=False, fp16_full_eval=False, tf32=None, local_rank=0, ddp_backend=None, tpu_num_cores=None, tpu_metrics_debug=False, debug=[], dataloader_drop_last=False, eval_steps=500, dataloader_num_workers=16, dataloader_prefetch_factor=2, past_index=-1, run_name='/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v7-20260708-235534', disable_tqdm=False, remove_unused_columns=False, label_names=None, load_best_model_at_end=False, metric_for_best_model='loss', greater_is_better=False, ignore_data_skip=False, fsdp=[], fsdp_min_num_params=0, fsdp_config={'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}, fsdp_transformer_layer_cls_to_wrap=None, accelerator_config=AcceleratorConfig(split_batches=False, dispatch_batches=False, even_batches=True, use_seedable_sampler=True, non_blocking=False, gradient_accumulation_kwargs=None, use_configured_state=False), parallelism_config=None, deepspeed={'fp16': {'enabled': 'auto', 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'bf16': {'enabled': 'auto'}, 'zero_optimization': {'stage': 2, 'offload_optimizer': {'device': 'none', 'pin_memory': True}, 'allgather_partitions': True, 'allgather_bucket_size': 200000000.0, 'overlap_comm': False, 'reduce_scatter': True, 'reduce_bucket_size': 200000000.0, 'contiguous_gradients': True}, 'gradient_accumulation_steps': 'auto', 'gradient_clipping': 'auto', 'steps_per_print': 2000, 'train_batch_size': 'auto', 'train_micro_batch_size_per_gpu': 'auto', 'wall_clock_breakdown': False}, label_smoothing_factor=0.0, optim=<OptimizerNames.ADAMW_TORCH_FUSED: 'adamw_torch_fused'>, optim_args=None, adafactor=False, group_by_length=False, length_column_name='length', report_to=['tensorboard'], project='huggingface', trackio_space_id='trackio', ddp_find_unused_parameters=None, ddp_bucket_cap_mb=None, ddp_broadcast_buffers=None, dataloader_pin_memory=True, dataloader_persistent_workers=False, skip_memory_metrics=True, use_legacy_prediction_loop=False, push_to_hub=False, resume_from_checkpoint='/home/work_nfs23/sywang/code/ms-swift/examples/qwen3asr/exp3/exp_stage6_zh_en/v6-20260707-132425/checkpoint-8500', hub_model_id=None, hub_strategy=<HubStrategy.EVERY_SAVE: 'every_save'>, hub_token=None, hub_private_repo=None, hub_always_push=False, hub_revision=None, gradient_checkpointing=True, gradient_checkpointing_kwargs={'use_reentrant': False}, include_inputs_for_metrics=False, include_for_metrics=[], eval_do_concat_batches=True, fp16_backend='auto', push_to_hub_model_id=None, push_to_hub_organization=None, push_to_hub_token=None, mp_parameters='', auto_find_batch_size=False, full_determinism=False, torchdynamo=None, ray_scope='last', ddp_timeout=18000000, torch_compile=False, torch_compile_backend=None, torch_compile_mode=None, include_tokens_per_second=None, include_num_input_tokens_seen=None, neftune_noise_alpha=None, optim_target_modules=None, batch_eval_metrics=False, eval_on_start=False, use_liger_kernel=False, liger_kernel_config=None, eval_use_gather_object=False, average_tokens_across_devices=None, sortish_sampler=False, predict_with_generate=False, generation_max_length=None, generation_num_beams=None, generation_config=None, tuner_backend='peft', vit_gradient_checkpointing=True, router_aux_loss_coef=0.0, enable_dft_loss=False, enable_channel_loss=False, safe_serialization=True, max_shard_size='5GB', check_model=False, acc_strategy='token', train_dataloader_shuffle=True, max_epochs=None, aligner_lr=None, vit_lr=None, use_logits_to_keep=None, ds3_gather_for_generation=True, resume_only_model=False, optimizer=None, loss_type=None, eval_metric=None, callbacks=[], early_stop_interval=None, eval_use_evalscope=False, eval_dataset=[], eval_dataset_args=None, eval_limit=None, eval_generation_config=None, extra_eval_args=None, tuner_type='full', use_galore=False, galore_target_modules=None, galore_rank=128, galore_update_proj_gap=50, galore_scale=1.0, galore_proj_type='std', galore_optim_per_parameter=False, galore_with_embedding=False, galore_quantization=False, galore_proj_quant=False, galore_proj_bits=4, galore_proj_group_size=256, galore_cos_threshold=0.4, galore_gamma_proj=2, galore_queue_size=5, lisa_activated_layers=0, lisa_step_interval=20, use_flash_ckpt=False)"
404
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/chat_template.jinja DELETED
@@ -1,31 +0,0 @@
1
- {%- set ns = namespace(system_text="") -%}
2
- {%- for m in messages -%}
3
- {%- if m.role == 'system' -%}
4
- {%- if m.content is string -%}
5
- {%- set ns.system_text = ns.system_text + m.content -%}
6
- {%- else -%}
7
- {%- for c in m.content -%}
8
- {%- if c.type == 'text' and (c.text is defined) -%}
9
- {%- set ns.system_text = ns.system_text + c.text -%}
10
- {%- endif -%}
11
- {%- endfor -%}
12
- {%- endif -%}
13
- {%- endif -%}
14
- {%- endfor -%}
15
-
16
- {%- set ns2 = namespace(audio_tokens="") -%}
17
- {%- for m in messages -%}
18
- {%- if m.content is not string -%}
19
- {%- for c in m.content -%}
20
- {%- if c.type == 'audio' or ('audio' in c) or ('audio_url' in c) -%}
21
- {%- set ns2.audio_tokens = ns2.audio_tokens + "<|audio_start|><|audio_pad|><|audio_end|>" -%}
22
- {%- endif -%}
23
- {%- endfor -%}
24
- {%- endif -%}
25
- {%- endfor -%}
26
-
27
- {{- '<|im_start|>system\n' + (ns.system_text if ns.system_text is string else '') + '<|im_end|>\n' -}}
28
- {{- '<|im_start|>user\n' + ns2.audio_tokens + '<|im_end|>\n' -}}
29
- {%- if add_generation_prompt -%}
30
- {{- '<|im_start|>assistant\n' -}}
31
- {%- endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/config.json DELETED
@@ -1,228 +0,0 @@
1
- {
2
- "architectures": [
3
- "Qwen3ASRForConditionalGeneration"
4
- ],
5
- "dtype": "bfloat16",
6
- "eos_token_id": 151645,
7
- "hidden_size": 2048,
8
- "keys_to_ignore_at_inference": [
9
- "past_key_values"
10
- ],
11
- "model_type": "qwen3_asr",
12
- "pad_token_id": 151643,
13
- "support_languages": [
14
- "Chinese",
15
- "English",
16
- "Cantonese",
17
- "Arabic",
18
- "German",
19
- "French",
20
- "Spanish",
21
- "Portuguese",
22
- "Indonesian",
23
- "Italian",
24
- "Korean",
25
- "Russian",
26
- "Thai",
27
- "Vietnamese",
28
- "Japanese",
29
- "Turkish",
30
- "Hindi",
31
- "Malay",
32
- "Dutch",
33
- "Swedish",
34
- "Danish",
35
- "Finnish",
36
- "Polish",
37
- "Czech",
38
- "Filipino",
39
- "Persian",
40
- "Greek",
41
- "Romanian",
42
- "Hungarian",
43
- "Macedonian"
44
- ],
45
- "thinker_config": {
46
- "architectures": [
47
- "Qwen3ASRForConditionalGeneration"
48
- ],
49
- "audio_config": {
50
- "_name_or_path": "",
51
- "activation_dropout": 0,
52
- "activation_function": "gelu",
53
- "add_cross_attention": false,
54
- "architectures": null,
55
- "attention_dropout": 0,
56
- "bad_words_ids": null,
57
- "begin_suppress_tokens": null,
58
- "bos_token_id": null,
59
- "chunk_size_feed_forward": 0,
60
- "conv_chunksize": 500,
61
- "cross_attention_hidden_size": null,
62
- "d_model": 1024,
63
- "decoder_start_token_id": null,
64
- "diversity_penalty": 0.0,
65
- "do_sample": false,
66
- "downsample_hidden_size": 480,
67
- "dropout": 0,
68
- "dtype": "bfloat16",
69
- "early_stopping": false,
70
- "encoder_attention_heads": 16,
71
- "encoder_ffn_dim": 4096,
72
- "encoder_layers": 24,
73
- "encoder_no_repeat_ngram_size": 0,
74
- "eos_token_id": null,
75
- "exponential_decay_length_penalty": null,
76
- "finetuning_task": null,
77
- "forced_bos_token_id": null,
78
- "forced_eos_token_id": null,
79
- "id2label": {
80
- "0": "LABEL_0",
81
- "1": "LABEL_1"
82
- },
83
- "initializer_range": 0.02,
84
- "is_decoder": false,
85
- "is_encoder_decoder": false,
86
- "label2id": {
87
- "LABEL_0": 0,
88
- "LABEL_1": 1
89
- },
90
- "length_penalty": 1.0,
91
- "max_length": 20,
92
- "max_source_positions": 1500,
93
- "min_length": 0,
94
- "model_type": "qwen3_asr_audio_encoder",
95
- "n_window": 50,
96
- "n_window_infer": 800,
97
- "no_repeat_ngram_size": 0,
98
- "num_beam_groups": 1,
99
- "num_beams": 1,
100
- "num_hidden_layers": 24,
101
- "num_mel_bins": 128,
102
- "num_return_sequences": 1,
103
- "output_attentions": false,
104
- "output_dim": 2048,
105
- "output_hidden_states": false,
106
- "output_scores": false,
107
- "pad_token_id": null,
108
- "prefix": null,
109
- "problem_type": null,
110
- "pruned_heads": {},
111
- "remove_invalid_values": false,
112
- "repetition_penalty": 1.0,
113
- "return_dict": true,
114
- "return_dict_in_generate": false,
115
- "scale_embedding": false,
116
- "sep_token_id": null,
117
- "suppress_tokens": null,
118
- "task_specific_params": null,
119
- "temperature": 1.0,
120
- "tf_legacy_loss": false,
121
- "tie_encoder_decoder": false,
122
- "tie_word_embeddings": true,
123
- "tokenizer_class": null,
124
- "top_k": 50,
125
- "top_p": 1.0,
126
- "torchscript": false,
127
- "typical_p": 1.0,
128
- "use_bfloat16": false
129
- },
130
- "audio_end_token_id": 151670,
131
- "audio_start_token_id": 151669,
132
- "audio_token_id": 151676,
133
- "dtype": "bfloat16",
134
- "initializer_range": 0.02,
135
- "model_type": "qwen3_asr_thinker",
136
- "text_config": {
137
- "_name_or_path": "",
138
- "add_cross_attention": false,
139
- "architectures": null,
140
- "attention_bias": false,
141
- "attention_dropout": 0.0,
142
- "bad_words_ids": null,
143
- "begin_suppress_tokens": null,
144
- "bos_token_id": null,
145
- "chunk_size_feed_forward": 0,
146
- "cross_attention_hidden_size": null,
147
- "decoder_start_token_id": null,
148
- "diversity_penalty": 0.0,
149
- "do_sample": false,
150
- "dtype": "bfloat16",
151
- "early_stopping": false,
152
- "encoder_no_repeat_ngram_size": 0,
153
- "eos_token_id": null,
154
- "exponential_decay_length_penalty": null,
155
- "finetuning_task": null,
156
- "forced_bos_token_id": null,
157
- "forced_eos_token_id": null,
158
- "head_dim": 128,
159
- "hidden_act": "silu",
160
- "hidden_size": 2048,
161
- "id2label": {
162
- "0": "LABEL_0",
163
- "1": "LABEL_1"
164
- },
165
- "initializer_range": 0.02,
166
- "intermediate_size": 6144,
167
- "is_decoder": false,
168
- "is_encoder_decoder": false,
169
- "label2id": {
170
- "LABEL_0": 0,
171
- "LABEL_1": 1
172
- },
173
- "length_penalty": 1.0,
174
- "max_length": 20,
175
- "max_position_embeddings": 65536,
176
- "min_length": 0,
177
- "model_type": "qwen3_asr_text",
178
- "no_repeat_ngram_size": 0,
179
- "num_attention_heads": 16,
180
- "num_beam_groups": 1,
181
- "num_beams": 1,
182
- "num_hidden_layers": 28,
183
- "num_key_value_heads": 8,
184
- "num_return_sequences": 1,
185
- "output_attentions": false,
186
- "output_hidden_states": false,
187
- "output_scores": false,
188
- "pad_token_id": 151643,
189
- "prefix": null,
190
- "problem_type": null,
191
- "pruned_heads": {},
192
- "remove_invalid_values": false,
193
- "repetition_penalty": 1.0,
194
- "return_dict": true,
195
- "return_dict_in_generate": false,
196
- "rms_norm_eps": 1e-06,
197
- "rope_scaling": {
198
- "interleaved": true,
199
- "mrope_interleaved": true,
200
- "mrope_section": [
201
- 24,
202
- 20,
203
- 20
204
- ],
205
- "rope_type": "default",
206
- "type": "default"
207
- },
208
- "rope_theta": 1000000,
209
- "sep_token_id": null,
210
- "suppress_tokens": null,
211
- "task_specific_params": null,
212
- "temperature": 1.0,
213
- "tf_legacy_loss": false,
214
- "tie_encoder_decoder": false,
215
- "tie_word_embeddings": true,
216
- "tokenizer_class": null,
217
- "top_k": 50,
218
- "top_p": 1.0,
219
- "torchscript": false,
220
- "typical_p": 1.0,
221
- "use_bfloat16": false,
222
- "use_cache": false,
223
- "vocab_size": 151936
224
- },
225
- "user_token_id": 872
226
- },
227
- "transformers_version": "4.57.6"
228
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/generation_config.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "_from_model_config": true,
3
- "eos_token_id": [
4
- 151645,
5
- 151643
6
- ],
7
- "transformers_version": "4.57.6"
8
- }
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/latest DELETED
@@ -1 +0,0 @@
1
- global_step16000
 
 
MultiDialect-ASR/merges.txt DELETED
The diff for this file is too large to render. See raw diff
 
MultiDialect-ASR/model.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:dc75555d5558ebcdf84a6f4121bf7613e22d251d1d0110b35fbdc5054643bc0a
3
- size 4698521600
 
 
 
 
MultiDialect-ASR/preprocessor_config.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "chunk_length": 30,
3
- "dither": 0.0,
4
- "feature_extractor_type": "WhisperFeatureExtractor",
5
- "feature_size": 128,
6
- "hop_length": 160,
7
- "n_fft": 400,
8
- "n_samples": 480000,
9
- "nb_max_frames": 3000,
10
- "padding_side": "right",
11
- "padding_value": 0.0,
12
- "processor_class": "Qwen3ASRProcessor",
13
- "return_attention_mask": true
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/special_tokens_map.json DELETED
@@ -1,44 +0,0 @@
1
- {
2
- "additional_special_tokens": [
3
- "<|im_start|>",
4
- "<|im_end|>",
5
- "<|object_ref_start|>",
6
- "<|object_ref_end|>",
7
- "<|box_start|>",
8
- "<|box_end|>",
9
- "<|quad_start|>",
10
- "<|quad_end|>",
11
- "<|vision_start|>",
12
- "<|vision_end|>",
13
- "<|vision_pad|>",
14
- "<|image_pad|>",
15
- "<|video_pad|>",
16
- "<|audio_start|>",
17
- "<|audio_end|>",
18
- "<tts_pad>",
19
- "<tts_text_bos>",
20
- "<tts_text_bos_single>",
21
- "<|audio_pad|>"
22
- ],
23
- "audio_bos_token": "<|audio_start|>",
24
- "audio_eos_token": "<|audio_end|>",
25
- "audio_token": "<|audio_pad|>",
26
- "eos_token": {
27
- "content": "<|im_end|>",
28
- "lstrip": false,
29
- "normalized": false,
30
- "rstrip": false,
31
- "single_word": false
32
- },
33
- "image_token": "<|image_pad|>",
34
- "pad_token": {
35
- "content": "<|endoftext|>",
36
- "lstrip": false,
37
- "normalized": false,
38
- "rstrip": false,
39
- "single_word": false
40
- },
41
- "video_token": "<|video_pad|>",
42
- "vision_bos_token": "<|vision_start|>",
43
- "vision_eos_token": "<|vision_end|>"
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/tokenizer.json DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bd2a97b55c8f7f9c328c73ee9b9178771037e9f566dfca8e238a063d41cbac92
3
- size 11429377
 
 
 
 
MultiDialect-ASR/tokenizer_config.json DELETED
@@ -1,549 +0,0 @@
1
- {
2
- "add_bos_token": false,
3
- "add_prefix_space": false,
4
- "added_tokens_decoder": {
5
- "151643": {
6
- "content": "<|endoftext|>",
7
- "lstrip": false,
8
- "normalized": false,
9
- "rstrip": false,
10
- "single_word": false,
11
- "special": true
12
- },
13
- "151644": {
14
- "content": "<|im_start|>",
15
- "lstrip": false,
16
- "normalized": false,
17
- "rstrip": false,
18
- "single_word": false,
19
- "special": true
20
- },
21
- "151645": {
22
- "content": "<|im_end|>",
23
- "lstrip": false,
24
- "normalized": false,
25
- "rstrip": false,
26
- "single_word": false,
27
- "special": true
28
- },
29
- "151646": {
30
- "content": "<|object_ref_start|>",
31
- "lstrip": false,
32
- "normalized": false,
33
- "rstrip": false,
34
- "single_word": false,
35
- "special": true
36
- },
37
- "151647": {
38
- "content": "<|object_ref_end|>",
39
- "lstrip": false,
40
- "normalized": false,
41
- "rstrip": false,
42
- "single_word": false,
43
- "special": true
44
- },
45
- "151648": {
46
- "content": "<|box_start|>",
47
- "lstrip": false,
48
- "normalized": false,
49
- "rstrip": false,
50
- "single_word": false,
51
- "special": true
52
- },
53
- "151649": {
54
- "content": "<|box_end|>",
55
- "lstrip": false,
56
- "normalized": false,
57
- "rstrip": false,
58
- "single_word": false,
59
- "special": true
60
- },
61
- "151650": {
62
- "content": "<|quad_start|>",
63
- "lstrip": false,
64
- "normalized": false,
65
- "rstrip": false,
66
- "single_word": false,
67
- "special": true
68
- },
69
- "151651": {
70
- "content": "<|quad_end|>",
71
- "lstrip": false,
72
- "normalized": false,
73
- "rstrip": false,
74
- "single_word": false,
75
- "special": true
76
- },
77
- "151652": {
78
- "content": "<|vision_start|>",
79
- "lstrip": false,
80
- "normalized": false,
81
- "rstrip": false,
82
- "single_word": false,
83
- "special": true
84
- },
85
- "151653": {
86
- "content": "<|vision_end|>",
87
- "lstrip": false,
88
- "normalized": false,
89
- "rstrip": false,
90
- "single_word": false,
91
- "special": true
92
- },
93
- "151654": {
94
- "content": "<|vision_pad|>",
95
- "lstrip": false,
96
- "normalized": false,
97
- "rstrip": false,
98
- "single_word": false,
99
- "special": true
100
- },
101
- "151655": {
102
- "content": "<|image_pad|>",
103
- "lstrip": false,
104
- "normalized": false,
105
- "rstrip": false,
106
- "single_word": false,
107
- "special": true
108
- },
109
- "151656": {
110
- "content": "<|video_pad|>",
111
- "lstrip": false,
112
- "normalized": false,
113
- "rstrip": false,
114
- "single_word": false,
115
- "special": true
116
- },
117
- "151657": {
118
- "content": "<tool_call>",
119
- "lstrip": false,
120
- "normalized": false,
121
- "rstrip": false,
122
- "single_word": false,
123
- "special": false
124
- },
125
- "151658": {
126
- "content": "</tool_call>",
127
- "lstrip": false,
128
- "normalized": false,
129
- "rstrip": false,
130
- "single_word": false,
131
- "special": false
132
- },
133
- "151659": {
134
- "content": "<|fim_prefix|>",
135
- "lstrip": false,
136
- "normalized": false,
137
- "rstrip": false,
138
- "single_word": false,
139
- "special": false
140
- },
141
- "151660": {
142
- "content": "<|fim_middle|>",
143
- "lstrip": false,
144
- "normalized": false,
145
- "rstrip": false,
146
- "single_word": false,
147
- "special": false
148
- },
149
- "151661": {
150
- "content": "<|fim_suffix|>",
151
- "lstrip": false,
152
- "normalized": false,
153
- "rstrip": false,
154
- "single_word": false,
155
- "special": false
156
- },
157
- "151662": {
158
- "content": "<|fim_pad|>",
159
- "lstrip": false,
160
- "normalized": false,
161
- "rstrip": false,
162
- "single_word": false,
163
- "special": false
164
- },
165
- "151663": {
166
- "content": "<|repo_name|>",
167
- "lstrip": false,
168
- "normalized": false,
169
- "rstrip": false,
170
- "single_word": false,
171
- "special": false
172
- },
173
- "151664": {
174
- "content": "<|file_sep|>",
175
- "lstrip": false,
176
- "normalized": false,
177
- "rstrip": false,
178
- "single_word": false,
179
- "special": false
180
- },
181
- "151665": {
182
- "content": "<tool_response>",
183
- "lstrip": false,
184
- "normalized": false,
185
- "rstrip": false,
186
- "single_word": false,
187
- "special": false
188
- },
189
- "151666": {
190
- "content": "</tool_response>",
191
- "lstrip": false,
192
- "normalized": false,
193
- "rstrip": false,
194
- "single_word": false,
195
- "special": false
196
- },
197
- "151667": {
198
- "content": "<think>",
199
- "lstrip": false,
200
- "normalized": false,
201
- "rstrip": false,
202
- "single_word": false,
203
- "special": false
204
- },
205
- "151668": {
206
- "content": "</think>",
207
- "lstrip": false,
208
- "normalized": false,
209
- "rstrip": false,
210
- "single_word": false,
211
- "special": false
212
- },
213
- "151669": {
214
- "content": "<|audio_start|>",
215
- "lstrip": false,
216
- "normalized": false,
217
- "rstrip": false,
218
- "single_word": false,
219
- "special": true
220
- },
221
- "151670": {
222
- "content": "<|audio_end|>",
223
- "lstrip": false,
224
- "normalized": false,
225
- "rstrip": false,
226
- "single_word": false,
227
- "special": true
228
- },
229
- "151671": {
230
- "content": "<tts_pad>",
231
- "lstrip": false,
232
- "normalized": false,
233
- "rstrip": false,
234
- "single_word": false,
235
- "special": true
236
- },
237
- "151672": {
238
- "content": "<tts_text_bos>",
239
- "lstrip": false,
240
- "normalized": false,
241
- "rstrip": false,
242
- "single_word": false,
243
- "special": true
244
- },
245
- "151673": {
246
- "content": "<tts_text_eod>",
247
- "lstrip": false,
248
- "normalized": false,
249
- "rstrip": false,
250
- "single_word": false,
251
- "special": true
252
- },
253
- "151674": {
254
- "content": "<tts_text_bos_single>",
255
- "lstrip": false,
256
- "normalized": false,
257
- "rstrip": false,
258
- "single_word": false,
259
- "special": true
260
- },
261
- "151675": {
262
- "content": "<non_speech>",
263
- "lstrip": false,
264
- "normalized": false,
265
- "rstrip": false,
266
- "single_word": false,
267
- "special": false
268
- },
269
- "151676": {
270
- "content": "<|audio_pad|>",
271
- "lstrip": false,
272
- "normalized": false,
273
- "rstrip": false,
274
- "single_word": false,
275
- "special": true
276
- },
277
- "151677": {
278
- "content": "<blank1>",
279
- "lstrip": false,
280
- "normalized": false,
281
- "rstrip": false,
282
- "single_word": false,
283
- "special": true
284
- },
285
- "151678": {
286
- "content": "<blank2>",
287
- "lstrip": false,
288
- "normalized": false,
289
- "rstrip": false,
290
- "single_word": false,
291
- "special": true
292
- },
293
- "151679": {
294
- "content": "<blank3>",
295
- "lstrip": false,
296
- "normalized": false,
297
- "rstrip": false,
298
- "single_word": false,
299
- "special": true
300
- },
301
- "151680": {
302
- "content": "<blank4>",
303
- "lstrip": false,
304
- "normalized": false,
305
- "rstrip": false,
306
- "single_word": false,
307
- "special": true
308
- },
309
- "151681": {
310
- "content": "<blank5>",
311
- "lstrip": false,
312
- "normalized": false,
313
- "rstrip": false,
314
- "single_word": false,
315
- "special": true
316
- },
317
- "151682": {
318
- "content": "<blank6>",
319
- "lstrip": false,
320
- "normalized": false,
321
- "rstrip": false,
322
- "single_word": false,
323
- "special": true
324
- },
325
- "151683": {
326
- "content": "<blank7>",
327
- "lstrip": false,
328
- "normalized": false,
329
- "rstrip": false,
330
- "single_word": false,
331
- "special": true
332
- },
333
- "151684": {
334
- "content": "<blank8>",
335
- "lstrip": false,
336
- "normalized": false,
337
- "rstrip": false,
338
- "single_word": false,
339
- "special": true
340
- },
341
- "151685": {
342
- "content": "<blank9>",
343
- "lstrip": false,
344
- "normalized": false,
345
- "rstrip": false,
346
- "single_word": false,
347
- "special": true
348
- },
349
- "151686": {
350
- "content": "<blank10>",
351
- "lstrip": false,
352
- "normalized": false,
353
- "rstrip": false,
354
- "single_word": false,
355
- "special": true
356
- },
357
- "151687": {
358
- "content": "<blank11>",
359
- "lstrip": false,
360
- "normalized": false,
361
- "rstrip": false,
362
- "single_word": false,
363
- "special": true
364
- },
365
- "151688": {
366
- "content": "<blank12>",
367
- "lstrip": false,
368
- "normalized": false,
369
- "rstrip": false,
370
- "single_word": false,
371
- "special": true
372
- },
373
- "151689": {
374
- "content": "<blank13>",
375
- "lstrip": false,
376
- "normalized": false,
377
- "rstrip": false,
378
- "single_word": false,
379
- "special": true
380
- },
381
- "151690": {
382
- "content": "<blank14>",
383
- "lstrip": false,
384
- "normalized": false,
385
- "rstrip": false,
386
- "single_word": false,
387
- "special": true
388
- },
389
- "151691": {
390
- "content": "<blank15>",
391
- "lstrip": false,
392
- "normalized": false,
393
- "rstrip": false,
394
- "single_word": false,
395
- "special": true
396
- },
397
- "151692": {
398
- "content": "<blank16>",
399
- "lstrip": false,
400
- "normalized": false,
401
- "rstrip": false,
402
- "single_word": false,
403
- "special": true
404
- },
405
- "151693": {
406
- "content": "<blank17>",
407
- "lstrip": false,
408
- "normalized": false,
409
- "rstrip": false,
410
- "single_word": false,
411
- "special": true
412
- },
413
- "151694": {
414
- "content": "<blank18>",
415
- "lstrip": false,
416
- "normalized": false,
417
- "rstrip": false,
418
- "single_word": false,
419
- "special": true
420
- },
421
- "151695": {
422
- "content": "<blank19>",
423
- "lstrip": false,
424
- "normalized": false,
425
- "rstrip": false,
426
- "single_word": false,
427
- "special": true
428
- },
429
- "151696": {
430
- "content": "<blank20>",
431
- "lstrip": false,
432
- "normalized": false,
433
- "rstrip": false,
434
- "single_word": false,
435
- "special": true
436
- },
437
- "151697": {
438
- "content": "<blank21>",
439
- "lstrip": false,
440
- "normalized": false,
441
- "rstrip": false,
442
- "single_word": false,
443
- "special": true
444
- },
445
- "151698": {
446
- "content": "<blank22>",
447
- "lstrip": false,
448
- "normalized": false,
449
- "rstrip": false,
450
- "single_word": false,
451
- "special": true
452
- },
453
- "151699": {
454
- "content": "<blank23>",
455
- "lstrip": false,
456
- "normalized": false,
457
- "rstrip": false,
458
- "single_word": false,
459
- "special": true
460
- },
461
- "151700": {
462
- "content": "<blank24>",
463
- "lstrip": false,
464
- "normalized": false,
465
- "rstrip": false,
466
- "single_word": false,
467
- "special": true
468
- },
469
- "151701": {
470
- "content": "<blank25>",
471
- "lstrip": false,
472
- "normalized": false,
473
- "rstrip": false,
474
- "single_word": false,
475
- "special": true
476
- },
477
- "151702": {
478
- "content": "<blank26>",
479
- "lstrip": false,
480
- "normalized": false,
481
- "rstrip": false,
482
- "single_word": false,
483
- "special": true
484
- },
485
- "151703": {
486
- "content": "<blank27>",
487
- "lstrip": false,
488
- "normalized": false,
489
- "rstrip": false,
490
- "single_word": false,
491
- "special": true
492
- },
493
- "151704": {
494
- "content": "<asr_text>",
495
- "lstrip": false,
496
- "normalized": false,
497
- "rstrip": false,
498
- "single_word": false,
499
- "special": false
500
- }
501
- },
502
- "additional_special_tokens": [
503
- "<|im_start|>",
504
- "<|im_end|>",
505
- "<|object_ref_start|>",
506
- "<|object_ref_end|>",
507
- "<|box_start|>",
508
- "<|box_end|>",
509
- "<|quad_start|>",
510
- "<|quad_end|>",
511
- "<|vision_start|>",
512
- "<|vision_end|>",
513
- "<|vision_pad|>",
514
- "<|image_pad|>",
515
- "<|video_pad|>",
516
- "<|audio_start|>",
517
- "<|audio_end|>",
518
- "<tts_pad>",
519
- "<tts_text_bos>",
520
- "<tts_text_bos_single>",
521
- "<|audio_pad|>"
522
- ],
523
- "audio_bos_token": "<|audio_start|>",
524
- "audio_eos_token": "<|audio_end|>",
525
- "audio_token": "<|audio_pad|>",
526
- "bos_token": null,
527
- "clean_up_tokenization_spaces": false,
528
- "eos_token": "<|im_end|>",
529
- "errors": "replace",
530
- "extra_special_tokens": {
531
- "audio_bos_token": "<|audio_start|>",
532
- "audio_eos_token": "<|audio_end|>",
533
- "audio_token": "<|audio_pad|>",
534
- "image_token": "<|image_pad|>",
535
- "video_token": "<|video_pad|>",
536
- "vision_bos_token": "<|vision_start|>",
537
- "vision_eos_token": "<|vision_end|>"
538
- },
539
- "image_token": "<|image_pad|>",
540
- "model_max_length": 131072,
541
- "pad_token": "<|endoftext|>",
542
- "processor_class": "Qwen3ASRProcessor",
543
- "split_special_tokens": false,
544
- "tokenizer_class": "Qwen2Tokenizer",
545
- "unk_token": null,
546
- "video_token": "<|video_pad|>",
547
- "vision_bos_token": "<|vision_start|>",
548
- "vision_eos_token": "<|vision_end|>"
549
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
MultiDialect-ASR/trainer_state.json DELETED
The diff for this file is too large to render. See raw diff
 
MultiDialect-ASR/training_args.bin DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c6ab0e00f239679378219e95b7e3a48b66077abb2ecc2eb61cbe4ca0a1b7c83e
3
- size 9489
 
 
 
 
MultiDialect-ASR/vocab.json DELETED
The diff for this file is too large to render. See raw diff
 
MultiDialect-ASR/zero_to_fp32.py DELETED
@@ -1,760 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- # Copyright (c) Microsoft Corporation.
4
- # SPDX-License-Identifier: Apache-2.0
5
-
6
- # DeepSpeed Team
7
-
8
- # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
- # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
- # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
- # application.
12
- #
13
- # example:
14
- # python zero_to_fp32.py . output_dir/
15
- # or
16
- # python zero_to_fp32.py . output_dir/ --safe_serialization
17
-
18
- import argparse
19
- import torch
20
- import glob
21
- import math
22
- import os
23
- import re
24
- import gc
25
- import json
26
- import numpy as np
27
- from tqdm import tqdm
28
- from collections import OrderedDict
29
- from dataclasses import dataclass
30
-
31
- # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
- # DeepSpeed data structures it has to be available in the current python environment.
33
- from deepspeed.utils import logger
34
- from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
- FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
- FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
-
38
-
39
- @dataclass
40
- class zero_model_state:
41
- buffers: dict()
42
- param_shapes: dict()
43
- shared_params: list
44
- ds_version: int
45
- frozen_param_shapes: dict()
46
- frozen_param_fragments: dict()
47
-
48
-
49
- debug = 0
50
-
51
- # load to cpu
52
- device = torch.device('cpu')
53
-
54
-
55
- def atoi(text):
56
- return int(text) if text.isdigit() else text
57
-
58
-
59
- def natural_keys(text):
60
- '''
61
- alist.sort(key=natural_keys) sorts in human order
62
- http://nedbatchelder.com/blog/200712/human_sorting.html
63
- (See Toothy's implementation in the comments)
64
- '''
65
- return [atoi(c) for c in re.split(r'(\d+)', text)]
66
-
67
-
68
- def get_model_state_file(checkpoint_dir, zero_stage):
69
- if not os.path.isdir(checkpoint_dir):
70
- raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
-
72
- # there should be only one file
73
- if zero_stage <= 2:
74
- file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
- elif zero_stage == 3:
76
- file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
-
78
- if not os.path.exists(file):
79
- raise FileNotFoundError(f"can't find model states file at '{file}'")
80
-
81
- return file
82
-
83
-
84
- def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
- # XXX: need to test that this simple glob rule works for multi-node setup too
86
- ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
-
88
- if len(ckpt_files) == 0:
89
- raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
-
91
- return ckpt_files
92
-
93
-
94
- def get_optim_files(checkpoint_dir):
95
- return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
-
97
-
98
- def get_model_state_files(checkpoint_dir):
99
- return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
-
101
-
102
- def parse_model_states(files):
103
- zero_model_states = []
104
- for file in files:
105
- state_dict = torch.load(file, map_location=device, weights_only=False)
106
-
107
- if BUFFER_NAMES not in state_dict:
108
- raise ValueError(f"{file} is not a model state checkpoint")
109
- buffer_names = state_dict[BUFFER_NAMES]
110
- if debug:
111
- print("Found buffers:", buffer_names)
112
-
113
- # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
- buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
- param_shapes = state_dict[PARAM_SHAPES]
116
-
117
- # collect parameters that are included in param_shapes
118
- param_names = []
119
- for s in param_shapes:
120
- for name in s.keys():
121
- param_names.append(name)
122
-
123
- # update with frozen parameters
124
- frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
- if frozen_param_shapes is not None:
126
- if debug:
127
- print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
- param_names += list(frozen_param_shapes.keys())
129
-
130
- # handle shared params
131
- shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
-
133
- ds_version = state_dict.get(DS_VERSION, None)
134
-
135
- frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
-
137
- z_model_state = zero_model_state(buffers=buffers,
138
- param_shapes=param_shapes,
139
- shared_params=shared_params,
140
- ds_version=ds_version,
141
- frozen_param_shapes=frozen_param_shapes,
142
- frozen_param_fragments=frozen_param_fragments)
143
- zero_model_states.append(z_model_state)
144
-
145
- return zero_model_states
146
-
147
-
148
- def parse_optim_states(files, ds_checkpoint_dir):
149
- total_files = len(files)
150
- state_dicts = []
151
- for f in tqdm(files, desc='Loading checkpoint shards'):
152
- state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
- # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
- # and also handle the case where it was already removed by another helper script
155
- state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
- state_dicts.append(state_dict)
157
-
158
- if ZERO_STAGE not in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
- raise ValueError(f"{files[0]} is not a zero checkpoint")
160
- zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
- world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
-
163
- # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
- # parameters can be different from data parallelism for non-expert parameters. So we can just
165
- # use the max of the partition_count to get the dp world_size.
166
-
167
- if type(world_size) is list:
168
- world_size = max(world_size)
169
-
170
- if world_size != total_files:
171
- raise ValueError(
172
- f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
- "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
- )
175
-
176
- # the groups are named differently in each stage
177
- if zero_stage <= 2:
178
- fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
- elif zero_stage == 3:
180
- fp32_groups_key = FP32_FLAT_GROUPS
181
- else:
182
- raise ValueError(f"unknown zero stage {zero_stage}")
183
-
184
- fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
- return zero_stage, world_size, fp32_flat_groups
186
-
187
-
188
- def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
- """
190
- Returns fp32 state_dict reconstructed from ds checkpoint
191
-
192
- Args:
193
- - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
-
195
- """
196
- print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
-
198
- optim_files = get_optim_files(ds_checkpoint_dir)
199
- zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
- print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
-
202
- model_files = get_model_state_files(ds_checkpoint_dir)
203
-
204
- zero_model_states = parse_model_states(model_files)
205
- print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
-
207
- if zero_stage <= 2:
208
- return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
- exclude_frozen_parameters)
210
- elif zero_stage == 3:
211
- return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
- exclude_frozen_parameters)
213
-
214
-
215
- def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
- if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
- return
218
-
219
- frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
- frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
-
222
- if debug:
223
- num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
- print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
-
226
- wanted_params = len(frozen_param_shapes)
227
- wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
- avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
- print(f'Frozen params: Have {avail_numel} numels to process.')
230
- print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
-
232
- total_params = 0
233
- total_numel = 0
234
- for name, shape in frozen_param_shapes.items():
235
- total_params += 1
236
- unpartitioned_numel = shape.numel()
237
- total_numel += unpartitioned_numel
238
-
239
- state_dict[name] = frozen_param_fragments[name]
240
-
241
- if debug:
242
- print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
-
244
- print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
-
246
-
247
- def _has_callable(obj, fn):
248
- attr = getattr(obj, fn, None)
249
- return callable(attr)
250
-
251
-
252
- def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
- param_shapes = zero_model_states[0].param_shapes
254
-
255
- # Reconstruction protocol:
256
- #
257
- # XXX: document this
258
-
259
- if debug:
260
- for i in range(world_size):
261
- for j in range(len(fp32_flat_groups[0])):
262
- print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
-
264
- # XXX: memory usage doubles here (zero2)
265
- num_param_groups = len(fp32_flat_groups[0])
266
- merged_single_partition_of_fp32_groups = []
267
- for i in range(num_param_groups):
268
- merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
- full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
- merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
- avail_numel = sum(
272
- [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
-
274
- if debug:
275
- wanted_params = sum([len(shapes) for shapes in param_shapes])
276
- wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
- # not asserting if there is a mismatch due to possible padding
278
- print(f"Have {avail_numel} numels to process.")
279
- print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
-
281
- # params
282
- # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
- # out-of-core computing solution
284
- total_numel = 0
285
- total_params = 0
286
- for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
- offset = 0
288
- avail_numel = full_single_fp32_vector.numel()
289
- for name, shape in shapes.items():
290
-
291
- unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
- total_numel += unpartitioned_numel
293
- total_params += 1
294
-
295
- if debug:
296
- print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
- state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
- offset += unpartitioned_numel
299
-
300
- # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
- # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
- # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
- # live optimizer object, so we are checking that the numbers are within the right range
304
- align_to = 2 * world_size
305
-
306
- def zero2_align(x):
307
- return align_to * math.ceil(x / align_to)
308
-
309
- if debug:
310
- print(f"original offset={offset}, avail_numel={avail_numel}")
311
-
312
- offset = zero2_align(offset)
313
- avail_numel = zero2_align(avail_numel)
314
-
315
- if debug:
316
- print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
-
318
- # Sanity check
319
- if offset != avail_numel:
320
- raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
-
322
- print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
-
324
-
325
- def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
- exclude_frozen_parameters):
327
- state_dict = OrderedDict()
328
-
329
- # buffers
330
- buffers = zero_model_states[0].buffers
331
- state_dict.update(buffers)
332
- if debug:
333
- print(f"added {len(buffers)} buffers")
334
-
335
- if not exclude_frozen_parameters:
336
- _zero2_merge_frozen_params(state_dict, zero_model_states)
337
-
338
- _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
-
340
- # recover shared parameters
341
- for pair in zero_model_states[0].shared_params:
342
- if pair[1] in state_dict:
343
- state_dict[pair[0]] = state_dict[pair[1]]
344
-
345
- return state_dict
346
-
347
-
348
- def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
- remainder = unpartitioned_numel % world_size
350
- padding_numel = (world_size - remainder) if remainder else 0
351
- partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
- return partitioned_numel, padding_numel
353
-
354
-
355
- def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
- if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
- return
358
-
359
- if debug:
360
- for i in range(world_size):
361
- num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
- print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
-
364
- frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
- wanted_params = len(frozen_param_shapes)
366
- wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
- avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
- print(f'Frozen params: Have {avail_numel} numels to process.')
369
- print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
-
371
- total_params = 0
372
- total_numel = 0
373
- for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
- total_params += 1
375
- unpartitioned_numel = shape.numel()
376
- total_numel += unpartitioned_numel
377
-
378
- param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
- state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
-
381
- partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
-
383
- if debug:
384
- print(
385
- f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
- )
387
-
388
- print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
-
390
-
391
- class GatheredTensor:
392
- """
393
- A pseudo tensor that collects partitioned weights.
394
- It is more memory efficient when there are multiple groups.
395
- """
396
-
397
- def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
- self.flat_groups = flat_groups
399
- self.flat_groups_offset = flat_groups_offset
400
- self.offset = offset
401
- self.partitioned_numel = partitioned_numel
402
- self.shape = shape
403
- self.dtype = self.flat_groups[0][0].dtype
404
-
405
- def contiguous(self):
406
- """
407
- Merge partitioned weights from flat_groups into a single tensor.
408
- """
409
- end_idx = self.offset + self.partitioned_numel
410
- world_size = len(self.flat_groups)
411
- pad_flat_param_chunks = []
412
-
413
- for rank_i in range(world_size):
414
- # for each rank, we need to collect weights from related group/groups
415
- flat_groups_at_rank_i = self.flat_groups[rank_i]
416
- start_group_id = None
417
- end_group_id = None
418
- for group_id in range(len(self.flat_groups_offset)):
419
- if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
- start_group_id = group_id
421
- if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
- end_group_id = group_id
423
- break
424
- # collect weights from related group/groups
425
- for group_id in range(start_group_id, end_group_id + 1):
426
- flat_tensor = flat_groups_at_rank_i[group_id]
427
- start_offset = self.offset - self.flat_groups_offset[group_id]
428
- end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
- pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
-
431
- # collect weights from all ranks
432
- pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
- param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
- return param
435
-
436
-
437
- def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
- param_shapes = zero_model_states[0].param_shapes
439
- avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
-
441
- # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
- # param, re-consolidating each param, while dealing with padding if any
443
-
444
- # merge list of dicts, preserving order
445
- param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
-
447
- if debug:
448
- for i in range(world_size):
449
- print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
-
451
- wanted_params = len(param_shapes)
452
- wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
- # not asserting if there is a mismatch due to possible padding
454
- avail_numel = fp32_flat_groups[0].numel() * world_size
455
- print(f"Trainable params: Have {avail_numel} numels to process.")
456
- print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
-
458
- # params
459
- # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
- # out-of-core computing solution
461
- offset = 0
462
- total_numel = 0
463
- total_params = 0
464
- flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
- for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
- unpartitioned_numel = shape.numel()
467
- total_numel += unpartitioned_numel
468
- total_params += 1
469
- partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
-
471
- if debug:
472
- print(
473
- f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
- )
475
-
476
- # memory efficient tensor
477
- tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
- state_dict[name] = tensor
479
- offset += partitioned_numel
480
-
481
- offset *= world_size
482
-
483
- # Sanity check
484
- if offset != avail_numel:
485
- raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
-
487
- print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
-
489
-
490
- def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
- exclude_frozen_parameters):
492
- state_dict = OrderedDict()
493
-
494
- # buffers
495
- buffers = zero_model_states[0].buffers
496
- state_dict.update(buffers)
497
- if debug:
498
- print(f"added {len(buffers)} buffers")
499
-
500
- if not exclude_frozen_parameters:
501
- _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
-
503
- _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
-
505
- # recover shared parameters
506
- for pair in zero_model_states[0].shared_params:
507
- if pair[1] in state_dict:
508
- state_dict[pair[0]] = state_dict[pair[1]]
509
-
510
- return state_dict
511
-
512
-
513
- def to_torch_tensor(state_dict, return_empty_tensor=False):
514
- """
515
- Convert state_dict of GatheredTensor to torch tensor
516
- """
517
- torch_state_dict = {}
518
- converted_tensors = {}
519
- for name, tensor in state_dict.items():
520
- tensor_id = id(tensor)
521
- if tensor_id in converted_tensors: # shared tensors
522
- shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
- torch_state_dict[name] = shared_tensor
524
- else:
525
- converted_tensors[tensor_id] = name
526
- if return_empty_tensor:
527
- torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
- else:
529
- torch_state_dict[name] = tensor.contiguous()
530
- return torch_state_dict
531
-
532
-
533
- def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
- tag=None,
535
- exclude_frozen_parameters=False,
536
- lazy_mode=False):
537
- """
538
- Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
- ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
- via a model hub.
541
-
542
- Args:
543
- - ``checkpoint_dir``: path to the desired checkpoint folder
544
- - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
- - ``exclude_frozen_parameters``: exclude frozen parameters
546
- - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
- Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
-
549
- Returns:
550
- - pytorch ``state_dict``
551
-
552
- A typical usage might be ::
553
-
554
- from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
- # do the training and checkpoint saving
556
- state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
- model = model.cpu() # move to cpu
558
- model.load_state_dict(state_dict)
559
- # submit to model hub or save the model to share with others
560
-
561
- In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
- application. i.e. you will need to re-initialize the deepspeed engine, since
563
- ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
-
565
- If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
-
567
- Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
- You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
- the checkpoint. Or you can load state_dict in lazy mode ::
570
-
571
- from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
- state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
- for name, lazy_tensor in state_dict.item():
574
- tensor = lazy_tensor.contiguous() # to cpu
575
- print(name, tensor)
576
- # del tensor to release memory if it no longer in use
577
- """
578
- if tag is None:
579
- latest_path = os.path.join(checkpoint_dir, 'latest')
580
- if os.path.isfile(latest_path):
581
- with open(latest_path, 'r') as fd:
582
- tag = fd.read().strip()
583
- else:
584
- raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
-
586
- ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
-
588
- if not os.path.isdir(ds_checkpoint_dir):
589
- raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
-
591
- state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
- if lazy_mode:
593
- return state_dict
594
- else:
595
- return to_torch_tensor(state_dict)
596
-
597
-
598
- def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
- output_dir,
600
- max_shard_size="5GB",
601
- safe_serialization=False,
602
- tag=None,
603
- exclude_frozen_parameters=False):
604
- """
605
- Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
- loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
-
608
- Args:
609
- - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
- - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
- - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
- - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
- - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
- - ``exclude_frozen_parameters``: exclude frozen parameters
615
- """
616
-
617
- # Dependency pre-check
618
- if safe_serialization:
619
- try:
620
- from safetensors.torch import save_file
621
- except ImportError:
622
- print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
- raise
624
- if max_shard_size is not None:
625
- try:
626
- from huggingface_hub import split_torch_state_dict_into_shards
627
- except ImportError:
628
- print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
- raise
630
-
631
- # Convert zero checkpoint to state_dict
632
- state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
- tag,
634
- exclude_frozen_parameters,
635
- lazy_mode=True)
636
-
637
- # Shard the model if it is too big.
638
- weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
- if max_shard_size is not None:
640
- filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
- # an memory-efficient approach for sharding
642
- empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
- state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
- filename_pattern=filename_pattern,
645
- max_shard_size=max_shard_size)
646
- else:
647
- from collections import namedtuple
648
- StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
- state_dict_split = StateDictSplit(is_sharded=False,
650
- filename_to_tensors={weights_name: list(state_dict.keys())})
651
-
652
- # Save the model by shard
653
- os.makedirs(output_dir, exist_ok=True)
654
- filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
- for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
- shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
- shard_state_dict = to_torch_tensor(shard_state_dict)
658
- output_path = os.path.join(output_dir, shard_file)
659
- if safe_serialization:
660
- save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
- else:
662
- torch.save(shard_state_dict, output_path)
663
- # release the memory of current shard
664
- for tensor_name in list(shard_state_dict.keys()):
665
- del state_dict[tensor_name]
666
- del shard_state_dict[tensor_name]
667
- del shard_state_dict
668
- gc.collect()
669
-
670
- # Save index if sharded
671
- if state_dict_split.is_sharded:
672
- index = {
673
- "metadata": state_dict_split.metadata,
674
- "weight_map": state_dict_split.tensor_to_filename,
675
- }
676
- save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
- save_index_file = os.path.join(output_dir, save_index_file)
678
- with open(save_index_file, "w", encoding="utf-8") as f:
679
- content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
- f.write(content)
681
-
682
-
683
- def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
- """
685
- 1. Put the provided model to cpu
686
- 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
- 3. Load it into the provided model
688
-
689
- Args:
690
- - ``model``: the model object to update
691
- - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
- - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
-
694
- Returns:
695
- - ``model`: modified model
696
-
697
- Make sure you have plenty of CPU memory available before you call this function. If you don't
698
- have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
- conveniently placed for you in the checkpoint folder.
700
-
701
- A typical usage might be ::
702
-
703
- from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
- model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
- # submit to model hub or save the model to share with others
706
-
707
- Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
- of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
- ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
-
711
- """
712
- logger.info("Extracting fp32 weights")
713
- state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
-
715
- logger.info("Overwriting model with fp32 weights")
716
- model = model.cpu()
717
- model.load_state_dict(state_dict, strict=False)
718
-
719
- return model
720
-
721
-
722
- if __name__ == "__main__":
723
- parser = argparse.ArgumentParser()
724
- parser.add_argument("checkpoint_dir",
725
- type=str,
726
- help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
- parser.add_argument("output_dir",
728
- type=str,
729
- help="directory to the pytorch fp32 state_dict output files"
730
- "(e.g. path/checkpoint-12-output/)")
731
- parser.add_argument(
732
- "--max_shard_size",
733
- type=str,
734
- default="5GB",
735
- help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
- "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
- "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
- "without CPU OOM issues.")
739
- parser.add_argument(
740
- "--safe_serialization",
741
- default=False,
742
- action='store_true',
743
- help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
- parser.add_argument("-t",
745
- "--tag",
746
- type=str,
747
- default=None,
748
- help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
- parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
- parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
- args = parser.parse_args()
752
-
753
- debug = args.debug
754
-
755
- convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
- args.output_dir,
757
- max_shard_size=args.max_shard_size,
758
- safe_serialization=args.safe_serialization,
759
- tag=args.tag,
760
- exclude_frozen_parameters=args.exclude_frozen_parameters)