phphuc612 commited on
Commit
f9b9c88
·
verified ·
1 Parent(s): 03b019e

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -35,3 +35,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  train/run.log filter=lfs diff=lfs merge=lfs -text
37
  train/run_inference.log filter=lfs diff=lfs merge=lfs -text
 
 
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  train/run.log filter=lfs diff=lfs merge=lfs -text
37
  train/run_inference.log filter=lfs diff=lfs merge=lfs -text
38
+ train_no_diff/run.log filter=lfs diff=lfs merge=lfs -text
train_no_diff/.hydra/config.yaml ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data_wrapper:
2
+ dataset:
3
+ garment_tokenizer:
4
+ standardize:
5
+ rotations:
6
+ _target_: data.datasets.panel_configs.StatsConfig
7
+ scale:
8
+ - 1
9
+ - 1
10
+ - 1
11
+ - 1
12
+ shift:
13
+ - 0
14
+ - 0
15
+ - 0
16
+ - 0
17
+ translations:
18
+ _target_: data.datasets.panel_configs.StatsConfig
19
+ scale:
20
+ - 26.06867645
21
+ - 32.42920198
22
+ - 22.29905009
23
+ shift:
24
+ - -0.0125378371
25
+ - 113.507532
26
+ - 2.63046369
27
+ vertices:
28
+ _target_: data.datasets.panel_configs.StatsConfig
29
+ scale:
30
+ - 24.4920733
31
+ - 26.60402835
32
+ shift:
33
+ - 8.44428116
34
+ - 16.84081321
35
+ _target_: data.datasets.panel_configs.StandardizeConfig
36
+ _target_: data.garment_tokenizers.gcd_garment_tokenizer.GCDGarmentTokenizer
37
+ random_tag: true
38
+ num_tags: 108
39
+ _target_: data.datasets.gcd_mm_dataset.GCDMM
40
+ root_dir: datadir/GarmentCodeData_v2/GarmentCodeData_v2
41
+ editing_dir: datadir/GarmentCodeData_v2/GCD-MM/editing_dir/garmentcodedata_editing
42
+ caption_dir: datadir/GarmentCodeData_v2/GCD-MM/caption_dir/long-caption-processed
43
+ editing_flip_prob: 0.5
44
+ sampling_rate:
45
+ - 0.2
46
+ - 0.2
47
+ - 0.2
48
+ - 0.2
49
+ - 0.2
50
+ panel_classification: assets/data_configs/panel_classes_garmentcodedata.json
51
+ load_by_dataname: assets/data_configs/garmentcodedata_list.txt
52
+ image_size: 448
53
+ max_num_patches: 12
54
+ conv_template: internvl2_5
55
+ _target_: data.data_wrappers.data_wrapper.DataWrapper
56
+ _recursive_: false
57
+ collate_fn: data.data_wrappers.collate_fns.collate_fn
58
+ split_file: assets/data_configs/garmentcodedata_datasplit.json
59
+ trainer:
60
+ _target_: trainers.trainer.Trainer
61
+ lr: 1.0e-05
62
+ beta1: 0.9
63
+ beta2: 0.95
64
+ grad_accumulation_steps: 10
65
+ batch_size: 4
66
+ num_steps: 12750
67
+ save_freq: 1000
68
+ experiment:
69
+ wandb_info:
70
+ wandb_dir: wandb
71
+ wandb_cache_dir: wandb_cache
72
+ project_name: AIpparel
73
+ run_name: train
74
+ run_id: null
75
+ local_dir: null
76
+ model:
77
+ edge_loss_weight: 0.1
78
+ pos_embed: true
79
+ num_freq: 0
80
+ pos_embed_type: sinusoidal
81
+ verts_bounds:
82
+ - -4
83
+ - -4
84
+ - 4
85
+ - 4
86
+ transf_bounds:
87
+ - -4
88
+ - -4
89
+ - -4
90
+ - -1
91
+ - -1
92
+ - -1
93
+ - -1
94
+ - 4
95
+ - 4
96
+ - 4
97
+ - 1
98
+ - 1
99
+ - 1
100
+ - 1
101
+ denormalize_for_loss: false
102
+ num_regression_layers: 2
103
+ discretize: true
104
+ bin_num: 256
105
+ my_pretrained_path: null
106
+ llm_pretrained_path: cache/InternVL3-2B-Instruct
107
+ resume_path: null
108
+ sampling_type: default
109
+ pretrained_config: null
110
+ precision: bf16
111
+ evaluate: false
112
+ conv_type: internvl2_5
113
+ from_start: false
114
+ storage_dir: output/
train_no_diff/.hydra/hydra.yaml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ hydra:
2
+ run:
3
+ dir: output/train/
4
+ sweep:
5
+ dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S}
6
+ subdir: ${hydra.job.num}
7
+ launcher:
8
+ _target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher
9
+ sweeper:
10
+ _target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper
11
+ max_batch_size: null
12
+ params: null
13
+ help:
14
+ app_name: ${hydra.job.name}
15
+ header: '${hydra.help.app_name} is powered by Hydra.
16
+
17
+ '
18
+ footer: 'Powered by Hydra (https://hydra.cc)
19
+
20
+ Use --hydra-help to view Hydra specific help
21
+
22
+ '
23
+ template: '${hydra.help.header}
24
+
25
+ == Configuration groups ==
26
+
27
+ Compose your configuration from those groups (group=option)
28
+
29
+
30
+ $APP_CONFIG_GROUPS
31
+
32
+
33
+ == Config ==
34
+
35
+ Override anything in the config (foo.bar=value)
36
+
37
+
38
+ $CONFIG
39
+
40
+
41
+ ${hydra.help.footer}
42
+
43
+ '
44
+ hydra_help:
45
+ template: 'Hydra (${hydra.runtime.version})
46
+
47
+ See https://hydra.cc for more info.
48
+
49
+
50
+ == Flags ==
51
+
52
+ $FLAGS_HELP
53
+
54
+
55
+ == Configuration groups ==
56
+
57
+ Compose your configuration from those groups (For example, append hydra/job_logging=disabled
58
+ to command line)
59
+
60
+
61
+ $HYDRA_CONFIG_GROUPS
62
+
63
+
64
+ Use ''--cfg hydra'' to Show the Hydra config.
65
+
66
+ '
67
+ hydra_help: ???
68
+ hydra_logging:
69
+ version: 1
70
+ formatters:
71
+ simple:
72
+ format: '[%(asctime)s][HYDRA] %(message)s'
73
+ handlers:
74
+ console:
75
+ class: logging.StreamHandler
76
+ formatter: simple
77
+ stream: ext://sys.stdout
78
+ root:
79
+ level: INFO
80
+ handlers:
81
+ - console
82
+ loggers:
83
+ logging_example:
84
+ level: DEBUG
85
+ disable_existing_loggers: false
86
+ job_logging:
87
+ version: 1
88
+ formatters:
89
+ simple:
90
+ format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
91
+ handlers:
92
+ console:
93
+ class: logging.StreamHandler
94
+ formatter: simple
95
+ stream: ext://sys.stdout
96
+ file:
97
+ class: logging.FileHandler
98
+ formatter: simple
99
+ filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
100
+ root:
101
+ level: INFO
102
+ handlers:
103
+ - console
104
+ - file
105
+ disable_existing_loggers: false
106
+ env: {}
107
+ mode: RUN
108
+ searchpath: []
109
+ callbacks: {}
110
+ output_subdir: .hydra
111
+ overrides:
112
+ hydra:
113
+ - hydra.mode=RUN
114
+ task:
115
+ - experiment.project_name=AIpparel
116
+ - experiment.run_name=train
117
+ - evaluate=False
118
+ job:
119
+ name: diff_run
120
+ chdir: null
121
+ override_dirname: evaluate=False,experiment.project_name=AIpparel,experiment.run_name=train
122
+ id: ???
123
+ num: ???
124
+ config_name: aipparel_diff
125
+ env_set: {}
126
+ env_copy: []
127
+ config:
128
+ override_dirname:
129
+ kv_sep: '='
130
+ item_sep: ','
131
+ exclude_keys: []
132
+ runtime:
133
+ version: 1.3.2
134
+ version_base: '1.3'
135
+ cwd: /root/workspace/SwiftTailor3
136
+ config_sources:
137
+ - path: hydra.conf
138
+ schema: pkg
139
+ provider: hydra
140
+ - path: /root/workspace/SwiftTailor3/configs
141
+ schema: file
142
+ provider: main
143
+ - path: ''
144
+ schema: structured
145
+ provider: schema
146
+ output_dir: /root/workspace/SwiftTailor3/output/train
147
+ choices:
148
+ model: aipparel_model
149
+ experiment: experiment
150
+ experiment/wandb_info: wandb
151
+ trainer: trainer
152
+ data_wrapper: gcd_datawrapper
153
+ data_wrapper/dataset: gcd_mm
154
+ data_wrapper/dataset/garment_tokenizer: gcd_garment_tokenizer
155
+ data_wrapper/dataset/garment_tokenizer/standardize: gcd_stats
156
+ data_wrapper/dataset/garment_tokenizer/standardize/vertices: gcd_verts_stats
157
+ data_wrapper/dataset/garment_tokenizer/standardize/translations: gcd_transl_stats
158
+ data_wrapper/dataset/garment_tokenizer/standardize/rotations: gcd_rotation_stats
159
+ hydra/env: default
160
+ hydra/callbacks: null
161
+ hydra/job_logging: default
162
+ hydra/hydra_logging: default
163
+ hydra/hydra_help: default
164
+ hydra/help: default
165
+ hydra/sweeper: basic
166
+ hydra/launcher: basic
167
+ hydra/output: default
168
+ verbose: false
train_no_diff/.hydra/overrides.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ - experiment.project_name=AIpparel
2
+ - experiment.run_name=train
3
+ - evaluate=False
train_no_diff/ckpt_29000/global_step29001/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:14456252e1c47d363caab10d2cbf9d5337b9e81f2defd46ddcec14f68525eccb
3
+ size 5358433520
train_no_diff/ckpt_29000/global_step29001/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:f5b84e448135c7ca98225fef07fe659b8804e5ae93fab09fd4eaa51b8a9da931
3
+ size 5358437872
train_no_diff/ckpt_29000/global_step29001/bf16_zero_pp_rank_2_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f73962f98a9f47154957208420ed79362e9bb3d41e1cb70ce1d26bbfb02c0af1
3
+ size 5358438832
train_no_diff/ckpt_29000/global_step29001/bf16_zero_pp_rank_3_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f536d84489944f78c2c4d247ad90b74f7d3f3b3624062b07496b55c1eb0d5f71
3
+ size 5358432176
train_no_diff/ckpt_29000/global_step29001/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08191d11e0d4427b45565199e5d89b5955bbaf23c5bf3a091f6ac4e1669ac805
3
+ size 4823376020
train_no_diff/ckpt_29000/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step29001
train_no_diff/ckpt_29000/zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
train_no_diff/ckpt_29999/global_step30000/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:7a7b43d3497b5c861dd263826e96412a83e78acb163dec0fcaafc76252631a7b
3
+ size 5358433520
train_no_diff/ckpt_29999/global_step30000/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:53aed9ab192f6ee5e2b7fd684f8ebef51dbf5b0a605e20a2b176f9e303182cb0
3
+ size 5358437872
train_no_diff/ckpt_29999/global_step30000/bf16_zero_pp_rank_2_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0714536548f0e7e2afbd1f78eb701e9751824c485059c83823b88a17a5c940cb
3
+ size 5358438832
train_no_diff/ckpt_29999/global_step30000/bf16_zero_pp_rank_3_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4108f6d4f0e14368b8fe52f0c75f1deeaa9f78e4ec7b869e6c0ba423aa8f43e1
3
+ size 5358432176
train_no_diff/ckpt_29999/global_step30000/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bdc8d23e7b7be29859f048c1cb78fc40fbb30216c340b63d1c0efb497d75ee06
3
+ size 4823376020
train_no_diff/ckpt_29999/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step30000
train_no_diff/ckpt_29999/output_dir/config.json ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_commit_hash": null,
3
+ "_name_or_path": "/mnt/petrelfs/share_data/wangweiyun/share_internvl_preview/InternVL3-2B-Pretrain",
4
+ "architectures": [
5
+ "InternVLChatModel"
6
+ ],
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_internvl_chat.InternVLChatConfig",
9
+ "AutoModel": "modeling_internvl_chat.InternVLChatModel",
10
+ "AutoModelForCausalLM": "modeling_internvl_chat.InternVLChatModel"
11
+ },
12
+ "downsample_ratio": 0.5,
13
+ "dynamic_image_size": true,
14
+ "force_image_size": 448,
15
+ "image_fold": null,
16
+ "llm_config": {
17
+ "_name_or_path": "./pretrained/Qwen2.5-32B-Instruct",
18
+ "add_cross_attention": false,
19
+ "architectures": [
20
+ "Qwen2ForCausalLM"
21
+ ],
22
+ "attention_dropout": 0.0,
23
+ "bad_words_ids": null,
24
+ "begin_suppress_tokens": null,
25
+ "bos_token_id": 151643,
26
+ "chunk_size_feed_forward": 0,
27
+ "cross_attention_hidden_size": null,
28
+ "decoder_start_token_id": null,
29
+ "diversity_penalty": 0.0,
30
+ "do_sample": false,
31
+ "early_stopping": false,
32
+ "encoder_no_repeat_ngram_size": 0,
33
+ "eos_token_id": 151643,
34
+ "exponential_decay_length_penalty": null,
35
+ "finetuning_task": null,
36
+ "forced_bos_token_id": null,
37
+ "forced_eos_token_id": null,
38
+ "hidden_act": "silu",
39
+ "hidden_size": 1536,
40
+ "id2label": {
41
+ "0": "LABEL_0",
42
+ "1": "LABEL_1"
43
+ },
44
+ "initializer_range": 0.02,
45
+ "intermediate_size": 8960,
46
+ "is_decoder": false,
47
+ "is_encoder_decoder": false,
48
+ "label2id": {
49
+ "LABEL_0": 0,
50
+ "LABEL_1": 1
51
+ },
52
+ "length_penalty": 1.0,
53
+ "max_length": 20,
54
+ "max_position_embeddings": 32768,
55
+ "max_window_layers": 70,
56
+ "min_length": 0,
57
+ "model_type": "qwen2",
58
+ "moe_config": null,
59
+ "no_repeat_ngram_size": 0,
60
+ "num_attention_heads": 12,
61
+ "num_beam_groups": 1,
62
+ "num_beams": 1,
63
+ "num_hidden_layers": 28,
64
+ "num_key_value_heads": 2,
65
+ "num_return_sequences": 1,
66
+ "output_attentions": false,
67
+ "output_hidden_states": false,
68
+ "output_scores": false,
69
+ "pad_token_id": null,
70
+ "prefix": null,
71
+ "problem_type": null,
72
+ "pruned_heads": {},
73
+ "remove_invalid_values": false,
74
+ "repetition_penalty": 1.0,
75
+ "return_dict": true,
76
+ "return_dict_in_generate": false,
77
+ "rms_norm_eps": 1e-06,
78
+ "rope_scaling": {
79
+ "factor": 2.0,
80
+ "rope_type": "dynamic",
81
+ "type": "dynamic"
82
+ },
83
+ "rope_theta": 1000000.0,
84
+ "sep_token_id": null,
85
+ "sliding_window": null,
86
+ "suppress_tokens": null,
87
+ "task_specific_params": null,
88
+ "temperature": 1.0,
89
+ "tf_legacy_loss": false,
90
+ "tie_encoder_decoder": false,
91
+ "tie_word_embeddings": false,
92
+ "tokenizer_class": null,
93
+ "top_k": 50,
94
+ "top_p": 1.0,
95
+ "torch_dtype": "bfloat16",
96
+ "torchscript": false,
97
+ "transformers_version": "4.45.1",
98
+ "typical_p": 1.0,
99
+ "use_bfloat16": true,
100
+ "use_cache": true,
101
+ "use_sliding_window": false,
102
+ "vocab_size": 151796
103
+ },
104
+ "max_dynamic_patch": 12,
105
+ "min_dynamic_patch": 1,
106
+ "model_type": "internvl_chat",
107
+ "pad2square": false,
108
+ "ps_version": "v2",
109
+ "select_layer": -1,
110
+ "template": "internvl2_5",
111
+ "tie_word_embeddings": false,
112
+ "torch_dtype": "bfloat16",
113
+ "transformers_version": null,
114
+ "use_backbone_lora": 0,
115
+ "use_llm_lora": 0,
116
+ "use_thumbnail": true,
117
+ "vision_config": {
118
+ "_name_or_path": "OpenGVLab/InternViT-6B-448px-V1-5",
119
+ "add_cross_attention": false,
120
+ "architectures": [
121
+ "InternVisionModel"
122
+ ],
123
+ "attention_dropout": 0.0,
124
+ "auto_map": {
125
+ "AutoConfig": "configuration_intern_vit.InternVisionConfig",
126
+ "AutoModel": "modeling_intern_vit.InternVisionModel"
127
+ },
128
+ "bad_words_ids": null,
129
+ "begin_suppress_tokens": null,
130
+ "bos_token_id": null,
131
+ "capacity_factor": 1.2,
132
+ "chunk_size_feed_forward": 0,
133
+ "cross_attention_hidden_size": null,
134
+ "decoder_start_token_id": null,
135
+ "diversity_penalty": 0.0,
136
+ "do_sample": false,
137
+ "drop_path_rate": 0.0,
138
+ "dropout": 0.0,
139
+ "early_stopping": false,
140
+ "encoder_no_repeat_ngram_size": 0,
141
+ "eos_token_id": null,
142
+ "eval_capacity_factor": 1.4,
143
+ "exponential_decay_length_penalty": null,
144
+ "finetuning_task": null,
145
+ "forced_bos_token_id": null,
146
+ "forced_eos_token_id": null,
147
+ "hidden_act": "gelu",
148
+ "hidden_size": 1024,
149
+ "id2label": {
150
+ "0": "LABEL_0",
151
+ "1": "LABEL_1"
152
+ },
153
+ "image_size": 448,
154
+ "initializer_factor": 0.1,
155
+ "initializer_range": 1e-10,
156
+ "intermediate_size": 4096,
157
+ "is_decoder": false,
158
+ "is_encoder_decoder": false,
159
+ "label2id": {
160
+ "LABEL_0": 0,
161
+ "LABEL_1": 1
162
+ },
163
+ "laux_allreduce": "all_nodes",
164
+ "layer_norm_eps": 1e-06,
165
+ "length_penalty": 1.0,
166
+ "max_length": 20,
167
+ "min_length": 0,
168
+ "model_type": "intern_vit_6b",
169
+ "moe_coeff_ratio": 0.5,
170
+ "moe_intermediate_size": 768,
171
+ "moe_output_scale": 4.0,
172
+ "no_repeat_ngram_size": 0,
173
+ "noisy_gate_policy": "RSample_before",
174
+ "norm_type": "layer_norm",
175
+ "num_attention_heads": 16,
176
+ "num_beam_groups": 1,
177
+ "num_beams": 1,
178
+ "num_channels": 3,
179
+ "num_experts": 8,
180
+ "num_hidden_layers": 24,
181
+ "num_return_sequences": 1,
182
+ "num_routed_experts": 4,
183
+ "num_shared_experts": 4,
184
+ "output_attentions": false,
185
+ "output_hidden_states": false,
186
+ "output_scores": false,
187
+ "pad_token_id": null,
188
+ "patch_size": 14,
189
+ "prefix": null,
190
+ "problem_type": null,
191
+ "pruned_heads": {},
192
+ "qk_normalization": false,
193
+ "qkv_bias": true,
194
+ "remove_invalid_values": false,
195
+ "repetition_penalty": 1.0,
196
+ "return_dict": true,
197
+ "return_dict_in_generate": false,
198
+ "sep_token_id": null,
199
+ "shared_expert_intermediate_size": 3072,
200
+ "suppress_tokens": null,
201
+ "task_specific_params": null,
202
+ "temperature": 1.0,
203
+ "tf_legacy_loss": false,
204
+ "tie_encoder_decoder": false,
205
+ "tie_word_embeddings": true,
206
+ "tokenizer_class": null,
207
+ "top_k": 50,
208
+ "top_p": 1.0,
209
+ "torch_dtype": "bfloat16",
210
+ "torchscript": false,
211
+ "transformers_version": "4.45.1",
212
+ "typical_p": 1.0,
213
+ "use_bfloat16": true,
214
+ "use_flash_attn": true,
215
+ "use_moe": false,
216
+ "use_residual": true,
217
+ "use_rts": false,
218
+ "use_weighted_residual": false
219
+ }
220
+ }
train_no_diff/ckpt_29999/output_dir/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b0998b45d71a1b5de7cf1ba5c38be2a272260c1ab0d094733fda21ce7f27502
3
+ size 7770003116
train_no_diff/ckpt_29999/zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
train_no_diff/diff_run.log ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [2025-09-03 21:58:38,725][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
2
+ [2025-09-03 21:58:38,726][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
3
+ [2025-09-03 21:58:38,734][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
4
+ [2025-09-03 21:59:02,452][data.data_wrappers.data_wrapper][INFO] - Dataset split: 114869 / 6381 / 6381
5
+ [2025-09-03 21:59:02,453][__main__][INFO] - Dataset created.
6
+ [2025-09-03 21:59:02,752][__main__][INFO] - Added 122 tokens to the tokenizer.
7
+ [2025-09-03 21:59:02,766][__main__][INFO] - Token name to index dictionary: {'<pattern_cmd_MOVE>': 151674, '<pattern_cmd_LINE>': 151675, '<pattern_cmd_CLINE>': 151676, '<pattern_cmd_CURVE>': 151677, '<pattern_cmd_CCURVE>': 151678, '<pattern_cmd_CUBIC>': 151679, '<pattern_cmd_CCUBIC>': 151680, '<pattern_cmd_ARC>': 151681, '<pattern_cmd_CARC>': 151682, '<panel_start>': 151683, '<panel_end>': 151684, '<pattern_start>': 151685, '<pattern_end>': 151686, '<stitch_tag_0>': 151687, '<stitch_tag_1>': 151688, '<stitch_tag_2>': 151689, '<stitch_tag_3>': 151690, '<stitch_tag_4>': 151691, '<stitch_tag_5>': 151692, '<stitch_tag_6>': 151693, '<stitch_tag_7>': 151694, '<stitch_tag_8>': 151695, '<stitch_tag_9>': 151696, '<stitch_tag_10>': 151697, '<stitch_tag_11>': 151698, '<stitch_tag_12>': 151699, '<stitch_tag_13>': 151700, '<stitch_tag_14>': 151701, '<stitch_tag_15>': 151702, '<stitch_tag_16>': 151703, '<stitch_tag_17>': 151704, '<stitch_tag_18>': 151705, '<stitch_tag_19>': 151706, '<stitch_tag_20>': 151707, '<stitch_tag_21>': 151708, '<stitch_tag_22>': 151709, '<stitch_tag_23>': 151710, '<stitch_tag_24>': 151711, '<stitch_tag_25>': 151712, '<stitch_tag_26>': 151713, '<stitch_tag_27>': 151714, '<stitch_tag_28>': 151715, '<stitch_tag_29>': 151716, '<stitch_tag_30>': 151717, '<stitch_tag_31>': 151718, '<stitch_tag_32>': 151719, '<stitch_tag_33>': 151720, '<stitch_tag_34>': 151721, '<stitch_tag_35>': 151722, '<stitch_tag_36>': 151723, '<stitch_tag_37>': 151724, '<stitch_tag_38>': 151725, '<stitch_tag_39>': 151726, '<stitch_tag_40>': 151727, '<stitch_tag_41>': 151728, '<stitch_tag_42>': 151729, '<stitch_tag_43>': 151730, '<stitch_tag_44>': 151731, '<stitch_tag_45>': 151732, '<stitch_tag_46>': 151733, '<stitch_tag_47>': 151734, '<stitch_tag_48>': 151735, '<stitch_tag_49>': 151736, '<stitch_tag_50>': 151737, '<stitch_tag_51>': 151738, '<stitch_tag_52>': 151739, '<stitch_tag_53>': 151740, '<stitch_tag_54>': 151741, '<stitch_tag_55>': 151742, '<stitch_tag_56>': 151743, '<stitch_tag_57>': 151744, '<stitch_tag_58>': 151745, '<stitch_tag_59>': 151746, '<stitch_tag_60>': 151747, '<stitch_tag_61>': 151748, '<stitch_tag_62>': 151749, '<stitch_tag_63>': 151750, '<stitch_tag_64>': 151751, '<stitch_tag_65>': 151752, '<stitch_tag_66>': 151753, '<stitch_tag_67>': 151754, '<stitch_tag_68>': 151755, '<stitch_tag_69>': 151756, '<stitch_tag_70>': 151757, '<stitch_tag_71>': 151758, '<stitch_tag_72>': 151759, '<stitch_tag_73>': 151760, '<stitch_tag_74>': 151761, '<stitch_tag_75>': 151762, '<stitch_tag_76>': 151763, '<stitch_tag_77>': 151764, '<stitch_tag_78>': 151765, '<stitch_tag_79>': 151766, '<stitch_tag_80>': 151767, '<stitch_tag_81>': 151768, '<stitch_tag_82>': 151769, '<stitch_tag_83>': 151770, '<stitch_tag_84>': 151771, '<stitch_tag_85>': 151772, '<stitch_tag_86>': 151773, '<stitch_tag_87>': 151774, '<stitch_tag_88>': 151775, '<stitch_tag_89>': 151776, '<stitch_tag_90>': 151777, '<stitch_tag_91>': 151778, '<stitch_tag_92>': 151779, '<stitch_tag_93>': 151780, '<stitch_tag_94>': 151781, '<stitch_tag_95>': 151782, '<stitch_tag_96>': 151783, '<stitch_tag_97>': 151784, '<stitch_tag_98>': 151785, '<stitch_tag_99>': 151786, '<stitch_tag_100>': 151787, '<stitch_tag_101>': 151788, '<stitch_tag_102>': 151789, '<stitch_tag_103>': 151790, '<stitch_tag_104>': 151791, '<stitch_tag_105>': 151792, '<stitch_tag_106>': 151793, '<stitch_tag_107>': 151794, '<stitch_tag_null>': 151795}
8
+ [2025-09-03 21:59:02,768][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1
9
+ [2025-09-03 21:59:02,768][models.internvl.configuration_internvl_chat][INFO] - ps_version: v2
10
+ [2025-09-03 21:59:02,768][models.internvl.configuration_internvl_chat][INFO] - min_dynamic_patch: 1
11
+ [2025-09-03 21:59:02,768][models.internvl.configuration_internvl_chat][INFO] - max_dynamic_patch: 12
12
+ [2025-09-03 21:59:02,809][models.st_model_diff][INFO] - num_image_token: 256
13
+ [2025-09-03 21:59:02,810][models.st_model_diff][INFO] - ps_version: v2
14
+ [2025-09-03 21:59:24,668][trainers.trainer][INFO] - NN training Using device: cuda:0
15
+ [2025-09-03 21:59:24,751][trainers.trainer][INFO] - Start training from step 0
16
+ [2025-09-03 22:00:53,559][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
17
+ [2025-09-03 22:00:53,559][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
18
+ [2025-09-03 22:00:53,567][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
19
+ [2025-09-03 22:01:17,294][data.data_wrappers.data_wrapper][INFO] - Dataset split: 114869 / 6381 / 6381
20
+ [2025-09-03 22:01:17,296][__main__][INFO] - Dataset created.
21
+ [2025-09-03 22:01:17,569][__main__][INFO] - Added 122 tokens to the tokenizer.
22
+ [2025-09-03 22:01:17,579][__main__][INFO] - Token name to index dictionary: {'<pattern_cmd_MOVE>': 151674, '<pattern_cmd_LINE>': 151675, '<pattern_cmd_CLINE>': 151676, '<pattern_cmd_CURVE>': 151677, '<pattern_cmd_CCURVE>': 151678, '<pattern_cmd_CUBIC>': 151679, '<pattern_cmd_CCUBIC>': 151680, '<pattern_cmd_ARC>': 151681, '<pattern_cmd_CARC>': 151682, '<panel_start>': 151683, '<panel_end>': 151684, '<pattern_start>': 151685, '<pattern_end>': 151686, '<stitch_tag_0>': 151687, '<stitch_tag_1>': 151688, '<stitch_tag_2>': 151689, '<stitch_tag_3>': 151690, '<stitch_tag_4>': 151691, '<stitch_tag_5>': 151692, '<stitch_tag_6>': 151693, '<stitch_tag_7>': 151694, '<stitch_tag_8>': 151695, '<stitch_tag_9>': 151696, '<stitch_tag_10>': 151697, '<stitch_tag_11>': 151698, '<stitch_tag_12>': 151699, '<stitch_tag_13>': 151700, '<stitch_tag_14>': 151701, '<stitch_tag_15>': 151702, '<stitch_tag_16>': 151703, '<stitch_tag_17>': 151704, '<stitch_tag_18>': 151705, '<stitch_tag_19>': 151706, '<stitch_tag_20>': 151707, '<stitch_tag_21>': 151708, '<stitch_tag_22>': 151709, '<stitch_tag_23>': 151710, '<stitch_tag_24>': 151711, '<stitch_tag_25>': 151712, '<stitch_tag_26>': 151713, '<stitch_tag_27>': 151714, '<stitch_tag_28>': 151715, '<stitch_tag_29>': 151716, '<stitch_tag_30>': 151717, '<stitch_tag_31>': 151718, '<stitch_tag_32>': 151719, '<stitch_tag_33>': 151720, '<stitch_tag_34>': 151721, '<stitch_tag_35>': 151722, '<stitch_tag_36>': 151723, '<stitch_tag_37>': 151724, '<stitch_tag_38>': 151725, '<stitch_tag_39>': 151726, '<stitch_tag_40>': 151727, '<stitch_tag_41>': 151728, '<stitch_tag_42>': 151729, '<stitch_tag_43>': 151730, '<stitch_tag_44>': 151731, '<stitch_tag_45>': 151732, '<stitch_tag_46>': 151733, '<stitch_tag_47>': 151734, '<stitch_tag_48>': 151735, '<stitch_tag_49>': 151736, '<stitch_tag_50>': 151737, '<stitch_tag_51>': 151738, '<stitch_tag_52>': 151739, '<stitch_tag_53>': 151740, '<stitch_tag_54>': 151741, '<stitch_tag_55>': 151742, '<stitch_tag_56>': 151743, '<stitch_tag_57>': 151744, '<stitch_tag_58>': 151745, '<stitch_tag_59>': 151746, '<stitch_tag_60>': 151747, '<stitch_tag_61>': 151748, '<stitch_tag_62>': 151749, '<stitch_tag_63>': 151750, '<stitch_tag_64>': 151751, '<stitch_tag_65>': 151752, '<stitch_tag_66>': 151753, '<stitch_tag_67>': 151754, '<stitch_tag_68>': 151755, '<stitch_tag_69>': 151756, '<stitch_tag_70>': 151757, '<stitch_tag_71>': 151758, '<stitch_tag_72>': 151759, '<stitch_tag_73>': 151760, '<stitch_tag_74>': 151761, '<stitch_tag_75>': 151762, '<stitch_tag_76>': 151763, '<stitch_tag_77>': 151764, '<stitch_tag_78>': 151765, '<stitch_tag_79>': 151766, '<stitch_tag_80>': 151767, '<stitch_tag_81>': 151768, '<stitch_tag_82>': 151769, '<stitch_tag_83>': 151770, '<stitch_tag_84>': 151771, '<stitch_tag_85>': 151772, '<stitch_tag_86>': 151773, '<stitch_tag_87>': 151774, '<stitch_tag_88>': 151775, '<stitch_tag_89>': 151776, '<stitch_tag_90>': 151777, '<stitch_tag_91>': 151778, '<stitch_tag_92>': 151779, '<stitch_tag_93>': 151780, '<stitch_tag_94>': 151781, '<stitch_tag_95>': 151782, '<stitch_tag_96>': 151783, '<stitch_tag_97>': 151784, '<stitch_tag_98>': 151785, '<stitch_tag_99>': 151786, '<stitch_tag_100>': 151787, '<stitch_tag_101>': 151788, '<stitch_tag_102>': 151789, '<stitch_tag_103>': 151790, '<stitch_tag_104>': 151791, '<stitch_tag_105>': 151792, '<stitch_tag_106>': 151793, '<stitch_tag_107>': 151794, '<stitch_tag_null>': 151795}
23
+ [2025-09-03 22:01:17,581][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1
24
+ [2025-09-03 22:01:17,581][models.internvl.configuration_internvl_chat][INFO] - ps_version: v2
25
+ [2025-09-03 22:01:17,581][models.internvl.configuration_internvl_chat][INFO] - min_dynamic_patch: 1
26
+ [2025-09-03 22:01:17,581][models.internvl.configuration_internvl_chat][INFO] - max_dynamic_patch: 12
27
+ [2025-09-03 22:01:17,595][models.st_model_diff][INFO] - num_image_token: 256
28
+ [2025-09-03 22:01:17,595][models.st_model_diff][INFO] - ps_version: v2
29
+ [2025-09-03 22:01:36,641][trainers.trainer][INFO] - NN training Using device: cuda:0
30
+ [2025-09-03 22:01:36,770][trainers.trainer][INFO] - Start training from step 0
31
+ [2025-09-03 22:29:56,518][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
32
+ [2025-09-03 22:29:56,518][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
33
+ [2025-09-03 22:29:56,526][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
34
+ [2025-09-03 22:30:20,298][data.data_wrappers.data_wrapper][INFO] - Dataset split: 114869 / 6381 / 6381
35
+ [2025-09-03 22:30:20,300][__main__][INFO] - Dataset created.
36
+ [2025-09-03 22:30:20,573][__main__][INFO] - Added 122 tokens to the tokenizer.
37
+ [2025-09-03 22:30:20,582][__main__][INFO] - Token name to index dictionary: {'<pattern_cmd_MOVE>': 151674, '<pattern_cmd_LINE>': 151675, '<pattern_cmd_CLINE>': 151676, '<pattern_cmd_CURVE>': 151677, '<pattern_cmd_CCURVE>': 151678, '<pattern_cmd_CUBIC>': 151679, '<pattern_cmd_CCUBIC>': 151680, '<pattern_cmd_ARC>': 151681, '<pattern_cmd_CARC>': 151682, '<panel_start>': 151683, '<panel_end>': 151684, '<pattern_start>': 151685, '<pattern_end>': 151686, '<stitch_tag_0>': 151687, '<stitch_tag_1>': 151688, '<stitch_tag_2>': 151689, '<stitch_tag_3>': 151690, '<stitch_tag_4>': 151691, '<stitch_tag_5>': 151692, '<stitch_tag_6>': 151693, '<stitch_tag_7>': 151694, '<stitch_tag_8>': 151695, '<stitch_tag_9>': 151696, '<stitch_tag_10>': 151697, '<stitch_tag_11>': 151698, '<stitch_tag_12>': 151699, '<stitch_tag_13>': 151700, '<stitch_tag_14>': 151701, '<stitch_tag_15>': 151702, '<stitch_tag_16>': 151703, '<stitch_tag_17>': 151704, '<stitch_tag_18>': 151705, '<stitch_tag_19>': 151706, '<stitch_tag_20>': 151707, '<stitch_tag_21>': 151708, '<stitch_tag_22>': 151709, '<stitch_tag_23>': 151710, '<stitch_tag_24>': 151711, '<stitch_tag_25>': 151712, '<stitch_tag_26>': 151713, '<stitch_tag_27>': 151714, '<stitch_tag_28>': 151715, '<stitch_tag_29>': 151716, '<stitch_tag_30>': 151717, '<stitch_tag_31>': 151718, '<stitch_tag_32>': 151719, '<stitch_tag_33>': 151720, '<stitch_tag_34>': 151721, '<stitch_tag_35>': 151722, '<stitch_tag_36>': 151723, '<stitch_tag_37>': 151724, '<stitch_tag_38>': 151725, '<stitch_tag_39>': 151726, '<stitch_tag_40>': 151727, '<stitch_tag_41>': 151728, '<stitch_tag_42>': 151729, '<stitch_tag_43>': 151730, '<stitch_tag_44>': 151731, '<stitch_tag_45>': 151732, '<stitch_tag_46>': 151733, '<stitch_tag_47>': 151734, '<stitch_tag_48>': 151735, '<stitch_tag_49>': 151736, '<stitch_tag_50>': 151737, '<stitch_tag_51>': 151738, '<stitch_tag_52>': 151739, '<stitch_tag_53>': 151740, '<stitch_tag_54>': 151741, '<stitch_tag_55>': 151742, '<stitch_tag_56>': 151743, '<stitch_tag_57>': 151744, '<stitch_tag_58>': 151745, '<stitch_tag_59>': 151746, '<stitch_tag_60>': 151747, '<stitch_tag_61>': 151748, '<stitch_tag_62>': 151749, '<stitch_tag_63>': 151750, '<stitch_tag_64>': 151751, '<stitch_tag_65>': 151752, '<stitch_tag_66>': 151753, '<stitch_tag_67>': 151754, '<stitch_tag_68>': 151755, '<stitch_tag_69>': 151756, '<stitch_tag_70>': 151757, '<stitch_tag_71>': 151758, '<stitch_tag_72>': 151759, '<stitch_tag_73>': 151760, '<stitch_tag_74>': 151761, '<stitch_tag_75>': 151762, '<stitch_tag_76>': 151763, '<stitch_tag_77>': 151764, '<stitch_tag_78>': 151765, '<stitch_tag_79>': 151766, '<stitch_tag_80>': 151767, '<stitch_tag_81>': 151768, '<stitch_tag_82>': 151769, '<stitch_tag_83>': 151770, '<stitch_tag_84>': 151771, '<stitch_tag_85>': 151772, '<stitch_tag_86>': 151773, '<stitch_tag_87>': 151774, '<stitch_tag_88>': 151775, '<stitch_tag_89>': 151776, '<stitch_tag_90>': 151777, '<stitch_tag_91>': 151778, '<stitch_tag_92>': 151779, '<stitch_tag_93>': 151780, '<stitch_tag_94>': 151781, '<stitch_tag_95>': 151782, '<stitch_tag_96>': 151783, '<stitch_tag_97>': 151784, '<stitch_tag_98>': 151785, '<stitch_tag_99>': 151786, '<stitch_tag_100>': 151787, '<stitch_tag_101>': 151788, '<stitch_tag_102>': 151789, '<stitch_tag_103>': 151790, '<stitch_tag_104>': 151791, '<stitch_tag_105>': 151792, '<stitch_tag_106>': 151793, '<stitch_tag_107>': 151794, '<stitch_tag_null>': 151795}
38
+ [2025-09-03 22:30:20,584][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1
39
+ [2025-09-03 22:30:20,584][models.internvl.configuration_internvl_chat][INFO] - ps_version: v2
40
+ [2025-09-03 22:30:20,584][models.internvl.configuration_internvl_chat][INFO] - min_dynamic_patch: 1
41
+ [2025-09-03 22:30:20,584][models.internvl.configuration_internvl_chat][INFO] - max_dynamic_patch: 12
42
+ [2025-09-03 22:30:20,598][models.st_model_diff][INFO] - num_image_token: 256
43
+ [2025-09-03 22:30:20,598][models.st_model_diff][INFO] - ps_version: v2
44
+ [2025-09-03 22:30:39,345][trainers.trainer][INFO] - NN training Using device: cuda:0
45
+ [2025-09-03 22:30:39,463][trainers.trainer][INFO] - Start training from step 0
46
+ [2025-09-03 22:30:53,626][trainers.trainer][INFO] - Step: [1] Time 1.714 ( 1.406) Data 0.001 ( 0.069) Total Loss 18.1910 (22.1247) CE Loss 13.3750 (13.9187) Edge Loss 48.1604 (82.0597) LR 0.000000 (0.000000) <pattern_cmd_MOVE> Loss 3.8395 (4.5083) <pattern_cmd_LINE> Loss 7.9621 (17.1630) <pattern_cmd_CLINE> Loss 0.0000 (0.0000) <pattern_cmd_CURVE> Loss 6.2891 (18.7915) <pattern_cmd_CCURVE> Loss 2.1175 (7.6664) <pattern_cmd_CUBIC> Loss 7.5026 (16.7568) <pattern_cmd_CCUBIC> Loss 4.5007 (4.5007) <pattern_cmd_ARC> Loss 8.6430 (8.0111) <pattern_cmd_CARC> Loss 11.8064 (11.8491)
train_no_diff/run.log ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e76e9b16a075fc2bdba9dc69eda4b010abff19c6f7dbde89e347ba4dd3941986
3
+ size 69122454
train_no_diff/run_debug.log ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [2025-08-28 10:41:15,466][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
2
+ [2025-08-28 10:41:15,468][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
3
+ [2025-08-28 10:41:15,499][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
4
+ [2025-08-28 10:48:57,669][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
5
+ [2025-08-28 10:48:57,671][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
6
+ [2025-08-28 10:48:57,702][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
7
+ [2025-08-28 10:52:13,818][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
8
+ [2025-08-28 10:52:13,819][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
9
+ [2025-08-28 10:52:13,851][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
10
+ [2025-08-28 10:54:05,898][data.data_wrappers.data_wrapper][INFO] - Dataset split: 114869 / 6381 / 6381
11
+ [2025-08-28 10:54:05,899][__main__][INFO] - Dataset created.
12
+ [2025-08-28 10:54:06,241][__main__][INFO] - Added 122 tokens to the tokenizer.
13
+ [2025-08-28 10:54:06,270][__main__][INFO] - Token name to index dictionary: {'<pattern_cmd_MOVE>': 151674, '<pattern_cmd_LINE>': 151675, '<pattern_cmd_CLINE>': 151676, '<pattern_cmd_CURVE>': 151677, '<pattern_cmd_CCURVE>': 151678, '<pattern_cmd_CUBIC>': 151679, '<pattern_cmd_CCUBIC>': 151680, '<pattern_cmd_ARC>': 151681, '<pattern_cmd_CARC>': 151682, '<panel_start>': 151683, '<panel_end>': 151684, '<pattern_start>': 151685, '<pattern_end>': 151686, '<stitch_tag_0>': 151687, '<stitch_tag_1>': 151688, '<stitch_tag_2>': 151689, '<stitch_tag_3>': 151690, '<stitch_tag_4>': 151691, '<stitch_tag_5>': 151692, '<stitch_tag_6>': 151693, '<stitch_tag_7>': 151694, '<stitch_tag_8>': 151695, '<stitch_tag_9>': 151696, '<stitch_tag_10>': 151697, '<stitch_tag_11>': 151698, '<stitch_tag_12>': 151699, '<stitch_tag_13>': 151700, '<stitch_tag_14>': 151701, '<stitch_tag_15>': 151702, '<stitch_tag_16>': 151703, '<stitch_tag_17>': 151704, '<stitch_tag_18>': 151705, '<stitch_tag_19>': 151706, '<stitch_tag_20>': 151707, '<stitch_tag_21>': 151708, '<stitch_tag_22>': 151709, '<stitch_tag_23>': 151710, '<stitch_tag_24>': 151711, '<stitch_tag_25>': 151712, '<stitch_tag_26>': 151713, '<stitch_tag_27>': 151714, '<stitch_tag_28>': 151715, '<stitch_tag_29>': 151716, '<stitch_tag_30>': 151717, '<stitch_tag_31>': 151718, '<stitch_tag_32>': 151719, '<stitch_tag_33>': 151720, '<stitch_tag_34>': 151721, '<stitch_tag_35>': 151722, '<stitch_tag_36>': 151723, '<stitch_tag_37>': 151724, '<stitch_tag_38>': 151725, '<stitch_tag_39>': 151726, '<stitch_tag_40>': 151727, '<stitch_tag_41>': 151728, '<stitch_tag_42>': 151729, '<stitch_tag_43>': 151730, '<stitch_tag_44>': 151731, '<stitch_tag_45>': 151732, '<stitch_tag_46>': 151733, '<stitch_tag_47>': 151734, '<stitch_tag_48>': 151735, '<stitch_tag_49>': 151736, '<stitch_tag_50>': 151737, '<stitch_tag_51>': 151738, '<stitch_tag_52>': 151739, '<stitch_tag_53>': 151740, '<stitch_tag_54>': 151741, '<stitch_tag_55>': 151742, '<stitch_tag_56>': 151743, '<stitch_tag_57>': 151744, '<stitch_tag_58>': 151745, '<stitch_tag_59>': 151746, '<stitch_tag_60>': 151747, '<stitch_tag_61>': 151748, '<stitch_tag_62>': 151749, '<stitch_tag_63>': 151750, '<stitch_tag_64>': 151751, '<stitch_tag_65>': 151752, '<stitch_tag_66>': 151753, '<stitch_tag_67>': 151754, '<stitch_tag_68>': 151755, '<stitch_tag_69>': 151756, '<stitch_tag_70>': 151757, '<stitch_tag_71>': 151758, '<stitch_tag_72>': 151759, '<stitch_tag_73>': 151760, '<stitch_tag_74>': 151761, '<stitch_tag_75>': 151762, '<stitch_tag_76>': 151763, '<stitch_tag_77>': 151764, '<stitch_tag_78>': 151765, '<stitch_tag_79>': 151766, '<stitch_tag_80>': 151767, '<stitch_tag_81>': 151768, '<stitch_tag_82>': 151769, '<stitch_tag_83>': 151770, '<stitch_tag_84>': 151771, '<stitch_tag_85>': 151772, '<stitch_tag_86>': 151773, '<stitch_tag_87>': 151774, '<stitch_tag_88>': 151775, '<stitch_tag_89>': 151776, '<stitch_tag_90>': 151777, '<stitch_tag_91>': 151778, '<stitch_tag_92>': 151779, '<stitch_tag_93>': 151780, '<stitch_tag_94>': 151781, '<stitch_tag_95>': 151782, '<stitch_tag_96>': 151783, '<stitch_tag_97>': 151784, '<stitch_tag_98>': 151785, '<stitch_tag_99>': 151786, '<stitch_tag_100>': 151787, '<stitch_tag_101>': 151788, '<stitch_tag_102>': 151789, '<stitch_tag_103>': 151790, '<stitch_tag_104>': 151791, '<stitch_tag_105>': 151792, '<stitch_tag_106>': 151793, '<stitch_tag_107>': 151794, '<stitch_tag_null>': 151795}
14
+ [2025-08-28 10:54:06,275][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1
15
+ [2025-08-28 10:54:06,276][models.internvl.configuration_internvl_chat][INFO] - ps_version: v2
16
+ [2025-08-28 10:54:06,276][models.internvl.configuration_internvl_chat][INFO] - min_dynamic_patch: 1
17
+ [2025-08-28 10:54:06,276][models.internvl.configuration_internvl_chat][INFO] - max_dynamic_patch: 12
18
+ [2025-08-28 10:54:06,276][__main__][INFO] - Loading model from output/train/ckpt_29999/output_dir
19
+ [2025-08-28 10:54:06,321][models.st_model][INFO] - num_image_token: 256
20
+ [2025-08-28 10:54:06,321][models.st_model][INFO] - ps_version: v2
21
+ [2025-08-28 11:00:43,936][trainers.trainer][INFO] - Rank: 0, Progress: [0/6381]
22
+ [2025-08-28 11:00:52,549][trainers.trainer][INFO] - Rank: 0, Progress: [1/6381]
23
+ [2025-08-28 11:00:52,681][trainers.trainer][INFO] - Rank: 0, Progress: [2/6381]
24
+ [2025-08-28 11:00:52,801][trainers.trainer][INFO] - Rank: 0, Progress: [3/6381]
25
+ [2025-08-28 11:00:53,026][trainers.trainer][INFO] - Rank: 0, Progress: [4/6381]
26
+ [2025-08-28 11:00:53,173][trainers.trainer][INFO] - Rank: 0, Progress: [5/6381]
27
+ [2025-08-28 11:00:53,774][trainers.trainer][INFO] - Rank: 0, Progress: [6/6381]
28
+ [2025-08-28 11:00:53,878][trainers.trainer][INFO] - Rank: 0, Progress: [7/6381]
29
+ [2025-08-28 11:00:53,943][trainers.trainer][INFO] - Rank: 0, Progress: [8/6381]
30
+ [2025-08-28 11:00:54,044][trainers.trainer][INFO] - Rank: 0, Progress: [9/6381]
31
+ [2025-08-28 11:00:54,175][trainers.trainer][INFO] - Rank: 0, Progress: [10/6381]
32
+ [2025-08-28 11:00:54,296][trainers.trainer][INFO] - Rank: 0, Progress: [11/6381]
33
+ [2025-08-28 11:00:54,530][trainers.trainer][INFO] - Rank: 0, Progress: [12/6381]
34
+ [2025-08-28 11:00:54,602][trainers.trainer][INFO] - Rank: 0, Progress: [13/6381]
35
+ [2025-08-28 11:00:54,671][trainers.trainer][INFO] - Rank: 0, Progress: [14/6381]
36
+ [2025-08-28 11:00:54,743][trainers.trainer][INFO] - Rank: 0, Progress: [15/6381]
37
+ [2025-08-28 11:00:55,718][trainers.trainer][INFO] - Rank: 0, Progress: [16/6381]
38
+ [2025-08-28 11:00:55,799][trainers.trainer][INFO] - Rank: 0, Progress: [17/6381]
39
+ [2025-08-28 11:00:55,912][trainers.trainer][INFO] - Rank: 0, Progress: [18/6381]
40
+ [2025-08-28 11:00:55,983][trainers.trainer][INFO] - Rank: 0, Progress: [19/6381]
41
+ [2025-08-28 11:00:56,061][trainers.trainer][INFO] - Rank: 0, Progress: [20/6381]
42
+ [2025-08-28 11:00:56,191][trainers.trainer][INFO] - Rank: 0, Progress: [21/6381]
43
+ [2025-08-28 11:00:56,394][trainers.trainer][INFO] - Rank: 0, Progress: [22/6381]
44
+ [2025-08-28 11:00:56,502][trainers.trainer][INFO] - Rank: 0, Progress: [23/6381]
45
+ [2025-08-28 11:00:56,643][trainers.trainer][INFO] - Rank: 0, Progress: [24/6381]
46
+ [2025-08-28 11:00:56,757][trainers.trainer][INFO] - Rank: 0, Progress: [25/6381]
47
+ [2025-08-28 11:00:56,871][trainers.trainer][INFO] - Rank: 0, Progress: [26/6381]
48
+ [2025-08-28 11:00:56,964][trainers.trainer][INFO] - Rank: 0, Progress: [27/6381]
49
+ [2025-08-28 11:00:57,528][trainers.trainer][INFO] - Rank: 0, Progress: [28/6381]
50
+ [2025-08-28 11:00:57,630][trainers.trainer][INFO] - Rank: 0, Progress: [29/6381]
51
+ [2025-08-28 11:00:57,854][trainers.trainer][INFO] - Rank: 0, Progress: [30/6381]
52
+ [2025-08-28 11:00:57,967][trainers.trainer][INFO] - Rank: 0, Progress: [31/6381]
53
+ [2025-08-28 11:00:58,039][trainers.trainer][INFO] - Rank: 0, Progress: [32/6381]
54
+ [2025-08-28 11:00:58,159][trainers.trainer][INFO] - Rank: 0, Progress: [33/6381]
55
+ [2025-08-28 11:00:58,300][trainers.trainer][INFO] - Rank: 0, Progress: [34/6381]
56
+ [2025-08-28 11:00:58,448][trainers.trainer][INFO] - Rank: 0, Progress: [35/6381]
57
+ [2025-08-28 11:00:58,576][trainers.trainer][INFO] - Rank: 0, Progress: [36/6381]
58
+ [2025-08-28 11:00:58,718][trainers.trainer][INFO] - Rank: 0, Progress: [37/6381]
59
+ [2025-08-28 11:00:58,832][trainers.trainer][INFO] - Rank: 0, Progress: [38/6381]
60
+ [2025-08-28 11:00:58,999][trainers.trainer][INFO] - Rank: 0, Progress: [39/6381]
61
+ [2025-08-28 11:00:59,328][trainers.trainer][INFO] - Rank: 0, Progress: [40/6381]
62
+ [2025-08-28 11:00:59,412][trainers.trainer][INFO] - Rank: 0, Progress: [41/6381]
63
+ [2025-08-28 11:00:59,587][trainers.trainer][INFO] - Rank: 0, Progress: [42/6381]
64
+ [2025-08-28 11:00:59,672][trainers.trainer][INFO] - Rank: 0, Progress: [43/6381]
65
+ [2025-08-28 11:00:59,780][trainers.trainer][INFO] - Rank: 0, Progress: [44/6381]
66
+ [2025-08-28 11:00:59,900][trainers.trainer][INFO] - Rank: 0, Progress: [45/6381]
67
+ [2025-08-28 11:01:00,022][trainers.trainer][INFO] - Rank: 0, Progress: [46/6381]
68
+ [2025-08-28 11:01:00,132][trainers.trainer][INFO] - Rank: 0, Progress: [47/6381]
69
+ [2025-08-28 11:01:00,259][trainers.trainer][INFO] - Rank: 0, Progress: [48/6381]
70
+ [2025-08-28 11:01:00,415][trainers.trainer][INFO] - Rank: 0, Progress: [49/6381]
71
+ [2025-08-28 11:01:00,546][trainers.trainer][INFO] - Rank: 0, Progress: [50/6381]
72
+ [2025-08-28 11:01:00,637][trainers.trainer][INFO] - Rank: 0, Progress: [51/6381]
73
+ [2025-08-28 11:01:00,896][trainers.trainer][INFO] - Rank: 0, Progress: [52/6381]
74
+ [2025-08-28 11:01:01,047][trainers.trainer][INFO] - Rank: 0, Progress: [53/6381]
75
+ [2025-08-28 11:01:01,524][trainers.trainer][INFO] - Rank: 0, Progress: [54/6381]
76
+ [2025-08-28 11:01:01,611][trainers.trainer][INFO] - Rank: 0, Progress: [55/6381]
77
+ [2025-08-28 11:01:01,747][trainers.trainer][INFO] - Rank: 0, Progress: [56/6381]
78
+ [2025-08-28 11:01:01,824][trainers.trainer][INFO] - Rank: 0, Progress: [57/6381]
79
+ [2025-08-28 11:01:01,901][trainers.trainer][INFO] - Rank: 0, Progress: [58/6381]
80
+ [2025-08-28 11:01:02,018][trainers.trainer][INFO] - Rank: 0, Progress: [59/6381]
81
+ [2025-08-28 11:01:02,202][trainers.trainer][INFO] - Rank: 0, Progress: [60/6381]
82
+ [2025-08-28 11:01:02,333][trainers.trainer][INFO] - Rank: 0, Progress: [61/6381]
83
+ [2025-08-28 11:01:02,476][trainers.trainer][INFO] - Rank: 0, Progress: [62/6381]
84
+ [2025-08-28 11:01:02,585][trainers.trainer][INFO] - Rank: 0, Progress: [63/6381]
85
+ [2025-08-28 11:01:02,882][trainers.trainer][INFO] - Rank: 0, Progress: [64/6381]
86
+ [2025-08-28 11:01:03,042][trainers.trainer][INFO] - Rank: 0, Progress: [65/6381]
87
+ [2025-08-28 11:01:03,297][trainers.trainer][INFO] - Rank: 0, Progress: [66/6381]
88
+ [2025-08-28 11:01:03,383][trainers.trainer][INFO] - Rank: 0, Progress: [67/6381]
89
+ [2025-08-28 11:01:03,497][trainers.trainer][INFO] - Rank: 0, Progress: [68/6381]
90
+ [2025-08-28 11:01:03,581][trainers.trainer][INFO] - Rank: 0, Progress: [69/6381]
91
+ [2025-08-28 11:01:03,670][trainers.trainer][INFO] - Rank: 0, Progress: [70/6381]
92
+ [2025-08-28 11:01:03,766][trainers.trainer][INFO] - Rank: 0, Progress: [71/6381]
93
+ [2025-08-28 11:01:03,940][trainers.trainer][INFO] - Rank: 0, Progress: [72/6381]
94
+ [2025-08-28 11:01:04,066][trainers.trainer][INFO] - Rank: 0, Progress: [73/6381]
95
+ [2025-08-28 11:01:04,192][trainers.trainer][INFO] - Rank: 0, Progress: [74/6381]
96
+ [2025-08-28 11:01:04,340][trainers.trainer][INFO] - Rank: 0, Progress: [75/6381]
97
+ [2025-08-28 11:01:04,699][trainers.trainer][INFO] - Rank: 0, Progress: [76/6381]
98
+ [2025-08-28 11:01:04,816][trainers.trainer][INFO] - Rank: 0, Progress: [77/6381]
99
+ [2025-08-28 11:01:05,033][trainers.trainer][INFO] - Rank: 0, Progress: [78/6381]
100
+ [2025-08-28 11:01:05,112][trainers.trainer][INFO] - Rank: 0, Progress: [79/6381]
101
+ [2025-08-28 11:01:05,211][trainers.trainer][INFO] - Rank: 0, Progress: [80/6381]
102
+ [2025-08-28 11:01:05,330][trainers.trainer][INFO] - Rank: 0, Progress: [81/6381]
103
+ [2025-08-28 11:01:05,446][trainers.trainer][INFO] - Rank: 0, Progress: [82/6381]
104
+ [2025-08-28 11:01:05,592][trainers.trainer][INFO] - Rank: 0, Progress: [83/6381]
105
+ [2025-08-28 11:01:05,781][trainers.trainer][INFO] - Rank: 0, Progress: [84/6381]
106
+ [2025-08-28 11:01:05,960][trainers.trainer][INFO] - Rank: 0, Progress: [85/6381]
107
+ [2025-08-28 11:01:06,067][trainers.trainer][INFO] - Rank: 0, Progress: [86/6381]
108
+ [2025-08-28 11:01:06,281][trainers.trainer][INFO] - Rank: 0, Progress: [87/6381]
109
+ [2025-08-28 11:01:06,664][trainers.trainer][INFO] - Rank: 0, Progress: [88/6381]
110
+ [2025-08-28 11:01:06,742][trainers.trainer][INFO] - Rank: 0, Progress: [89/6381]
111
+ [2025-08-28 11:01:06,898][trainers.trainer][INFO] - Rank: 0, Progress: [90/6381]
112
+ [2025-08-28 11:01:07,003][trainers.trainer][INFO] - Rank: 0, Progress: [91/6381]
113
+ [2025-08-28 11:01:07,129][trainers.trainer][INFO] - Rank: 0, Progress: [92/6381]
114
+ [2025-08-28 11:01:07,226][trainers.trainer][INFO] - Rank: 0, Progress: [93/6381]
115
+ [2025-08-28 11:01:07,388][trainers.trainer][INFO] - Rank: 0, Progress: [94/6381]
116
+ [2025-08-28 11:01:07,897][trainers.trainer][INFO] - Rank: 0, Progress: [95/6381]
117
+ [2025-08-28 11:01:08,101][trainers.trainer][INFO] - Rank: 0, Progress: [96/6381]
118
+ [2025-08-28 11:01:08,313][trainers.trainer][INFO] - Rank: 0, Progress: [97/6381]
119
+ [2025-08-28 11:01:08,563][trainers.trainer][INFO] - Rank: 0, Progress: [98/6381]
120
+ [2025-08-28 11:01:08,704][trainers.trainer][INFO] - Rank: 0, Progress: [99/6381]
121
+ [2025-08-28 11:01:08,900][trainers.trainer][INFO] - Rank: 0, Progress: [100/6381]
122
+ [2025-08-28 11:01:09,006][trainers.trainer][INFO] - Rank: 0, Progress: [101/6381]
123
+ [2025-08-28 11:01:09,179][trainers.trainer][INFO] - Rank: 0, Progress: [102/6381]
124
+ [2025-08-28 11:01:09,324][trainers.trainer][INFO] - Rank: 0, Progress: [103/6381]
125
+ [2025-08-28 11:01:09,423][trainers.trainer][INFO] - Rank: 0, Progress: [104/6381]
126
+ [2025-08-28 11:01:09,554][trainers.trainer][INFO] - Rank: 0, Progress: [105/6381]
127
+ [2025-08-28 11:01:09,736][trainers.trainer][INFO] - Rank: 0, Progress: [106/6381]
128
+ [2025-08-28 11:01:09,873][trainers.trainer][INFO] - Rank: 0, Progress: [107/6381]
129
+ [2025-08-28 11:01:10,035][trainers.trainer][INFO] - Rank: 0, Progress: [108/6381]
130
+ [2025-08-28 11:01:10,136][trainers.trainer][INFO] - Rank: 0, Progress: [109/6381]
131
+ [2025-08-28 11:01:10,263][trainers.trainer][INFO] - Rank: 0, Progress: [110/6381]
132
+ [2025-08-28 11:01:10,435][trainers.trainer][INFO] - Rank: 0, Progress: [111/6381]
133
+ [2025-08-28 11:01:10,654][trainers.trainer][INFO] - Rank: 0, Progress: [112/6381]
134
+ [2025-08-28 11:01:10,924][trainers.trainer][INFO] - Rank: 0, Progress: [113/6381]
135
+ [2025-08-28 11:01:11,288][trainers.trainer][INFO] - Rank: 0, Progress: [114/6381]
136
+ [2025-08-28 11:01:11,386][trainers.trainer][INFO] - Rank: 0, Progress: [115/6381]
137
+ [2025-08-28 11:01:11,497][trainers.trainer][INFO] - Rank: 0, Progress: [116/6381]
138
+ [2025-08-28 11:01:11,579][trainers.trainer][INFO] - Rank: 0, Progress: [117/6381]
139
+ [2025-08-28 11:01:11,784][trainers.trainer][INFO] - Rank: 0, Progress: [118/6381]
140
+ [2025-08-28 11:01:11,884][trainers.trainer][INFO] - Rank: 0, Progress: [119/6381]
141
+ [2025-08-28 11:01:12,018][trainers.trainer][INFO] - Rank: 0, Progress: [120/6381]
142
+ [2025-08-28 11:01:12,099][trainers.trainer][INFO] - Rank: 0, Progress: [121/6381]
143
+ [2025-08-28 11:01:12,217][trainers.trainer][INFO] - Rank: 0, Progress: [122/6381]
144
+ [2025-08-28 11:01:12,349][trainers.trainer][INFO] - Rank: 0, Progress: [123/6381]
145
+ [2025-08-28 11:01:12,549][trainers.trainer][INFO] - Rank: 0, Progress: [124/6381]
146
+ [2025-08-28 11:01:12,652][trainers.trainer][INFO] - Rank: 0, Progress: [125/6381]
147
+ [2025-08-28 11:01:12,952][trainers.trainer][INFO] - Rank: 0, Progress: [126/6381]
148
+ [2025-08-28 11:01:13,056][trainers.trainer][INFO] - Rank: 0, Progress: [127/6381]
149
+ [2025-08-28 11:01:13,130][trainers.trainer][INFO] - Rank: 0, Progress: [128/6381]
150
+ [2025-08-28 11:01:13,267][trainers.trainer][INFO] - Rank: 0, Progress: [129/6381]
151
+ [2025-08-28 11:01:13,350][trainers.trainer][INFO] - Rank: 0, Progress: [130/6381]
152
+ [2025-08-28 11:01:13,536][trainers.trainer][INFO] - Rank: 0, Progress: [131/6381]
153
+ [2025-08-28 11:01:13,678][trainers.trainer][INFO] - Rank: 0, Progress: [132/6381]
154
+ [2025-08-28 11:01:13,765][trainers.trainer][INFO] - Rank: 0, Progress: [133/6381]
155
+ [2025-08-28 11:01:13,940][trainers.trainer][INFO] - Rank: 0, Progress: [134/6381]
156
+ [2025-08-28 11:01:14,051][trainers.trainer][INFO] - Rank: 0, Progress: [135/6381]
157
+ [2025-08-28 11:01:14,290][trainers.trainer][INFO] - Rank: 0, Progress: [136/6381]
158
+ [2025-08-28 11:01:14,449][trainers.trainer][INFO] - Rank: 0, Progress: [137/6381]
159
+ [2025-08-28 11:01:14,614][trainers.trainer][INFO] - Rank: 0, Progress: [138/6381]
160
+ [2025-08-28 11:01:14,747][trainers.trainer][INFO] - Rank: 0, Progress: [139/6381]
161
+ [2025-08-28 11:01:14,964][trainers.trainer][INFO] - Rank: 0, Progress: [140/6381]
162
+ [2025-08-28 11:01:15,053][trainers.trainer][INFO] - Rank: 0, Progress: [141/6381]
163
+ [2025-08-28 11:01:15,159][trainers.trainer][INFO] - Rank: 0, Progress: [142/6381]
164
+ [2025-08-28 11:01:15,271][trainers.trainer][INFO] - Rank: 0, Progress: [143/6381]
165
+ [2025-08-28 11:01:15,468][trainers.trainer][INFO] - Rank: 0, Progress: [144/6381]
166
+ [2025-08-28 11:01:15,657][trainers.trainer][INFO] - Rank: 0, Progress: [145/6381]
167
+ [2025-08-28 11:01:15,756][trainers.trainer][INFO] - Rank: 0, Progress: [146/6381]
168
+ [2025-08-28 11:01:15,828][trainers.trainer][INFO] - Rank: 0, Progress: [147/6381]
169
+ [2025-08-28 11:01:15,990][trainers.trainer][INFO] - Rank: 0, Progress: [148/6381]
170
+ [2025-08-28 11:01:16,097][trainers.trainer][INFO] - Rank: 0, Progress: [149/6381]
171
+ [2025-08-28 11:01:16,417][trainers.trainer][INFO] - Rank: 0, Progress: [150/6381]
172
+ [2025-08-28 11:01:16,501][trainers.trainer][INFO] - Rank: 0, Progress: [151/6381]
173
+ [2025-08-28 11:01:16,574][trainers.trainer][INFO] - Rank: 0, Progress: [152/6381]
174
+ [2025-08-28 11:01:16,687][trainers.trainer][INFO] - Rank: 0, Progress: [153/6381]
175
+ [2025-08-28 11:01:16,783][trainers.trainer][INFO] - Rank: 0, Progress: [154/6381]
176
+ [2025-08-28 11:01:16,905][trainers.trainer][INFO] - Rank: 0, Progress: [155/6381]
177
+ [2025-08-28 11:01:17,066][trainers.trainer][INFO] - Rank: 0, Progress: [156/6381]
178
+ [2025-08-28 11:01:17,214][trainers.trainer][INFO] - Rank: 0, Progress: [157/6381]
179
+ [2025-08-28 11:01:17,529][trainers.trainer][INFO] - Rank: 0, Progress: [158/6381]
180
+ [2025-08-28 11:01:17,632][trainers.trainer][INFO] - Rank: 0, Progress: [159/6381]
181
+ [2025-08-28 11:01:17,797][trainers.trainer][INFO] - Rank: 0, Progress: [160/6381]
182
+ [2025-08-28 11:01:17,910][trainers.trainer][INFO] - Rank: 0, Progress: [161/6381]
183
+ [2025-08-28 11:01:18,093][trainers.trainer][INFO] - Rank: 0, Progress: [162/6381]
184
+ [2025-08-28 11:01:18,375][trainers.trainer][INFO] - Rank: 0, Progress: [163/6381]
185
+ [2025-08-28 11:01:18,544][trainers.trainer][INFO] - Rank: 0, Progress: [164/6381]
186
+ [2025-08-28 11:01:18,626][trainers.trainer][INFO] - Rank: 0, Progress: [165/6381]
187
+ [2025-08-28 11:01:18,725][trainers.trainer][INFO] - Rank: 0, Progress: [166/6381]
188
+ [2025-08-28 11:01:18,843][trainers.trainer][INFO] - Rank: 0, Progress: [167/6381]
189
+ [2025-08-28 11:01:19,164][trainers.trainer][INFO] - Rank: 0, Progress: [168/6381]
190
+ [2025-08-28 11:01:19,316][trainers.trainer][INFO] - Rank: 0, Progress: [169/6381]
191
+ [2025-08-28 11:01:19,439][trainers.trainer][INFO] - Rank: 0, Progress: [170/6381]
192
+ [2025-08-28 11:01:19,582][trainers.trainer][INFO] - Rank: 0, Progress: [171/6381]
193
+ [2025-08-28 11:01:19,799][trainers.trainer][INFO] - Rank: 0, Progress: [172/6381]
194
+ [2025-08-28 11:01:19,908][trainers.trainer][INFO] - Rank: 0, Progress: [173/6381]
195
+ [2025-08-28 11:01:20,085][trainers.trainer][INFO] - Rank: 0, Progress: [174/6381]
196
+ [2025-08-28 11:01:20,342][trainers.trainer][INFO] - Rank: 0, Progress: [175/6381]
197
+ [2025-08-28 11:01:20,492][trainers.trainer][INFO] - Rank: 0, Progress: [176/6381]
198
+ [2025-08-28 11:01:20,622][trainers.trainer][INFO] - Rank: 0, Progress: [177/6381]
199
+ [2025-08-28 11:01:20,725][trainers.trainer][INFO] - Rank: 0, Progress: [178/6381]
200
+ [2025-08-28 11:01:20,845][trainers.trainer][INFO] - Rank: 0, Progress: [179/6381]
201
+ [2025-08-28 11:01:21,085][trainers.trainer][INFO] - Rank: 0, Progress: [180/6381]
202
+ [2025-08-28 11:01:21,197][trainers.trainer][INFO] - Rank: 0, Progress: [181/6381]
203
+ [2025-08-28 11:01:21,335][trainers.trainer][INFO] - Rank: 0, Progress: [182/6381]
204
+ [2025-08-28 11:01:21,594][trainers.trainer][INFO] - Rank: 0, Progress: [183/6381]
205
+ [2025-08-28 11:01:21,744][trainers.trainer][INFO] - Rank: 0, Progress: [184/6381]
206
+ [2025-08-28 11:01:21,825][trainers.trainer][INFO] - Rank: 0, Progress: [185/6381]
207
+ [2025-08-28 11:01:21,964][trainers.trainer][INFO] - Rank: 0, Progress: [186/6381]
208
+ [2025-08-28 11:01:22,039][trainers.trainer][INFO] - Rank: 0, Progress: [187/6381]
209
+ [2025-08-28 11:01:22,107][trainers.trainer][INFO] - Rank: 0, Progress: [188/6381]
210
+ [2025-08-28 11:01:22,201][trainers.trainer][INFO] - Rank: 0, Progress: [189/6381]
211
+ [2025-08-28 11:01:22,300][trainers.trainer][INFO] - Rank: 0, Progress: [190/6381]
212
+ [2025-08-28 11:01:22,452][trainers.trainer][INFO] - Rank: 0, Progress: [191/6381]
213
+ [2025-08-28 11:01:22,696][trainers.trainer][INFO] - Rank: 0, Progress: [192/6381]
214
+ [2025-08-28 11:01:22,808][trainers.trainer][INFO] - Rank: 0, Progress: [193/6381]
215
+ [2025-08-28 11:01:22,942][trainers.trainer][INFO] - Rank: 0, Progress: [194/6381]
216
+ [2025-08-28 11:01:23,059][trainers.trainer][INFO] - Rank: 0, Progress: [195/6381]
217
+ [2025-08-28 11:01:23,266][trainers.trainer][INFO] - Rank: 0, Progress: [196/6381]
218
+ [2025-08-28 11:01:23,386][trainers.trainer][INFO] - Rank: 0, Progress: [197/6381]
219
+ [2025-08-28 11:01:23,577][trainers.trainer][INFO] - Rank: 0, Progress: [198/6381]
220
+ [2025-08-28 11:01:23,770][trainers.trainer][INFO] - Rank: 0, Progress: [199/6381]
221
+ [2025-08-28 11:01:23,873][trainers.trainer][INFO] - Rank: 0, Progress: [200/6381]
222
+ [2025-08-28 11:01:23,979][trainers.trainer][INFO] - Rank: 0, Progress: [201/6381]
223
+ [2025-08-28 11:01:24,121][trainers.trainer][INFO] - Rank: 0, Progress: [202/6381]
224
+ [2025-08-28 11:01:24,250][trainers.trainer][INFO] - Rank: 0, Progress: [203/6381]
225
+ [2025-08-28 11:01:24,463][trainers.trainer][INFO] - Rank: 0, Progress: [204/6381]
226
+ [2025-08-28 11:01:24,592][trainers.trainer][INFO] - Rank: 0, Progress: [205/6381]
227
+ [2025-08-28 11:01:24,922][trainers.trainer][INFO] - Rank: 0, Progress: [206/6381]
228
+ [2025-08-28 11:01:25,125][trainers.trainer][INFO] - Rank: 0, Progress: [207/6381]
229
+ [2025-08-28 11:01:25,248][trainers.trainer][INFO] - Rank: 0, Progress: [208/6381]
230
+ [2025-08-28 11:01:25,456][trainers.trainer][INFO] - Rank: 0, Progress: [209/6381]
231
+ [2025-08-28 11:01:25,587][trainers.trainer][INFO] - Rank: 0, Progress: [210/6381]
232
+ [2025-08-28 11:01:25,845][trainers.trainer][INFO] - Rank: 0, Progress: [211/6381]
233
+ [2025-08-28 11:01:25,951][trainers.trainer][INFO] - Rank: 0, Progress: [212/6381]
234
+ [2025-08-28 11:01:26,036][trainers.trainer][INFO] - Rank: 0, Progress: [213/6381]
235
+ [2025-08-28 11:01:26,185][trainers.trainer][INFO] - Rank: 0, Progress: [214/6381]
236
+ [2025-08-28 11:01:26,324][trainers.trainer][INFO] - Rank: 0, Progress: [215/6381]
237
+ [2025-08-28 11:01:26,536][trainers.trainer][INFO] - Rank: 0, Progress: [216/6381]
238
+ [2025-08-28 11:01:26,676][trainers.trainer][INFO] - Rank: 0, Progress: [217/6381]
239
+ [2025-08-28 11:01:26,757][trainers.trainer][INFO] - Rank: 0, Progress: [218/6381]
240
+ [2025-08-28 11:01:26,838][trainers.trainer][INFO] - Rank: 0, Progress: [219/6381]
241
+ [2025-08-28 11:01:26,951][trainers.trainer][INFO] - Rank: 0, Progress: [220/6381]
242
+ [2025-08-28 11:01:27,082][trainers.trainer][INFO] - Rank: 0, Progress: [221/6381]
243
+ [2025-08-28 11:01:27,256][trainers.trainer][INFO] - Rank: 0, Progress: [222/6381]
244
+ [2025-08-28 11:01:27,460][trainers.trainer][INFO] - Rank: 0, Progress: [223/6381]
245
+ [2025-08-28 11:01:27,596][trainers.trainer][INFO] - Rank: 0, Progress: [224/6381]
246
+ [2025-08-28 11:01:27,739][trainers.trainer][INFO] - Rank: 0, Progress: [225/6381]
247
+ [2025-08-28 11:01:27,855][trainers.trainer][INFO] - Rank: 0, Progress: [226/6381]
248
+ [2025-08-28 11:01:27,936][trainers.trainer][INFO] - Rank: 0, Progress: [227/6381]
249
+ [2025-08-28 11:01:28,132][trainers.trainer][INFO] - Rank: 0, Progress: [228/6381]
250
+ [2025-08-28 11:01:28,203][trainers.trainer][INFO] - Rank: 0, Progress: [229/6381]
251
+ [2025-08-28 11:01:28,310][trainers.trainer][INFO] - Rank: 0, Progress: [230/6381]
252
+ [2025-08-28 11:01:28,688][trainers.trainer][INFO] - Rank: 0, Progress: [231/6381]
253
+ [2025-08-28 11:01:28,797][trainers.trainer][INFO] - Rank: 0, Progress: [232/6381]
254
+ [2025-08-28 11:01:28,928][trainers.trainer][INFO] - Rank: 0, Progress: [233/6381]
255
+ [2025-08-28 11:01:29,144][trainers.trainer][INFO] - Rank: 0, Progress: [234/6381]
256
+ [2025-08-28 11:01:29,262][trainers.trainer][INFO] - Rank: 0, Progress: [235/6381]
257
+ [2025-08-28 11:01:29,352][trainers.trainer][INFO] - Rank: 0, Progress: [236/6381]
258
+ [2025-08-28 11:01:29,435][trainers.trainer][INFO] - Rank: 0, Progress: [237/6381]
259
+ [2025-08-28 11:01:29,550][trainers.trainer][INFO] - Rank: 0, Progress: [238/6381]
260
+ [2025-08-28 11:01:29,701][trainers.trainer][INFO] - Rank: 0, Progress: [239/6381]
261
+ [2025-08-28 11:01:29,869][trainers.trainer][INFO] - Rank: 0, Progress: [240/6381]
262
+ [2025-08-28 11:01:29,984][trainers.trainer][INFO] - Rank: 0, Progress: [241/6381]
263
+ [2025-08-28 11:01:30,257][trainers.trainer][INFO] - Rank: 0, Progress: [242/6381]
264
+ [2025-08-28 11:01:30,467][trainers.trainer][INFO] - Rank: 0, Progress: [243/6381]
265
+ [2025-08-28 11:01:30,679][trainers.trainer][INFO] - Rank: 0, Progress: [244/6381]
266
+ [2025-08-28 11:01:30,889][trainers.trainer][INFO] - Rank: 0, Progress: [245/6381]
267
+ [2025-08-28 11:01:31,327][trainers.trainer][INFO] - Rank: 0, Progress: [246/6381]
268
+ [2025-08-28 11:01:31,411][trainers.trainer][INFO] - Rank: 0, Progress: [247/6381]
269
+ [2025-08-28 11:01:31,610][trainers.trainer][INFO] - Rank: 0, Progress: [248/6381]
270
+ [2025-08-28 11:01:31,693][trainers.trainer][INFO] - Rank: 0, Progress: [249/6381]
271
+ [2025-08-28 11:01:31,816][trainers.trainer][INFO] - Rank: 0, Progress: [250/6381]
272
+ [2025-08-28 11:01:31,915][trainers.trainer][INFO] - Rank: 0, Progress: [251/6381]
273
+ [2025-08-28 11:01:32,077][trainers.trainer][INFO] - Rank: 0, Progress: [252/6381]
274
+ [2025-08-28 11:01:32,169][trainers.trainer][INFO] - Rank: 0, Progress: [253/6381]
275
+ [2025-08-28 11:01:32,242][trainers.trainer][INFO] - Rank: 0, Progress: [254/6381]
276
+ [2025-08-28 11:01:32,325][trainers.trainer][INFO] - Rank: 0, Progress: [255/6381]
277
+ [2025-08-28 11:01:32,510][trainers.trainer][INFO] - Rank: 0, Progress: [256/6381]
278
+ [2025-08-28 11:01:32,633][trainers.trainer][INFO] - Rank: 0, Progress: [257/6381]
279
+ [2025-08-28 11:01:33,043][trainers.trainer][INFO] - Rank: 0, Progress: [258/6381]
280
+ [2025-08-28 11:01:33,157][trainers.trainer][INFO] - Rank: 0, Progress: [259/6381]
281
+ [2025-08-28 11:01:33,262][trainers.trainer][INFO] - Rank: 0, Progress: [260/6381]
282
+ [2025-08-28 11:01:33,385][trainers.trainer][INFO] - Rank: 0, Progress: [261/6381]
283
+ [2025-08-28 11:01:33,506][trainers.trainer][INFO] - Rank: 0, Progress: [262/6381]
284
+ [2025-08-28 11:01:33,626][trainers.trainer][INFO] - Rank: 0, Progress: [263/6381]
285
+ [2025-08-28 11:01:33,836][trainers.trainer][INFO] - Rank: 0, Progress: [264/6381]
286
+ [2025-08-28 11:01:33,942][trainers.trainer][INFO] - Rank: 0, Progress: [265/6381]
287
+ [2025-08-28 11:01:34,035][trainers.trainer][INFO] - Rank: 0, Progress: [266/6381]
288
+ [2025-08-28 11:01:34,114][trainers.trainer][INFO] - Rank: 0, Progress: [267/6381]
289
+ [2025-08-28 11:01:34,236][trainers.trainer][INFO] - Rank: 0, Progress: [268/6381]
290
+ [2025-08-28 11:01:34,391][trainers.trainer][INFO] - Rank: 0, Progress: [269/6381]
291
+ [2025-08-28 11:01:34,614][trainers.trainer][INFO] - Rank: 0, Progress: [270/6381]
292
+ [2025-08-28 11:01:34,688][trainers.trainer][INFO] - Rank: 0, Progress: [271/6381]
293
+ [2025-08-28 11:01:34,797][trainers.trainer][INFO] - Rank: 0, Progress: [272/6381]
294
+ [2025-08-28 11:01:34,919][trainers.trainer][INFO] - Rank: 0, Progress: [273/6381]
295
+ [2025-08-28 11:01:35,027][trainers.trainer][INFO] - Rank: 0, Progress: [274/6381]
296
+ [2025-08-28 11:01:35,226][trainers.trainer][INFO] - Rank: 0, Progress: [275/6381]
297
+ [2025-08-28 11:01:35,477][trainers.trainer][INFO] - Rank: 0, Progress: [276/6381]
298
+ [2025-08-28 11:01:35,608][trainers.trainer][INFO] - Rank: 0, Progress: [277/6381]
299
+ [2025-08-28 11:01:35,684][trainers.trainer][INFO] - Rank: 0, Progress: [278/6381]
300
+ [2025-08-28 11:01:35,781][trainers.trainer][INFO] - Rank: 0, Progress: [279/6381]
301
+ [2025-08-28 11:01:35,878][trainers.trainer][INFO] - Rank: 0, Progress: [280/6381]
302
+ [2025-08-28 11:01:35,985][trainers.trainer][INFO] - Rank: 0, Progress: [281/6381]
303
+ [2025-08-28 11:01:36,196][trainers.trainer][INFO] - Rank: 0, Progress: [282/6381]
304
+ [2025-08-28 11:01:36,305][trainers.trainer][INFO] - Rank: 0, Progress: [283/6381]
305
+ [2025-08-28 11:01:36,374][trainers.trainer][INFO] - Rank: 0, Progress: [284/6381]
306
+ [2025-08-28 11:01:36,457][trainers.trainer][INFO] - Rank: 0, Progress: [285/6381]
307
+ [2025-08-28 11:01:36,557][trainers.trainer][INFO] - Rank: 0, Progress: [286/6381]
308
+ [2025-08-28 11:01:36,727][trainers.trainer][INFO] - Rank: 0, Progress: [287/6381]
309
+ [2025-08-28 11:01:36,906][trainers.trainer][INFO] - Rank: 0, Progress: [288/6381]
310
+ [2025-08-28 11:01:37,056][trainers.trainer][INFO] - Rank: 0, Progress: [289/6381]
311
+ [2025-08-28 11:01:37,214][trainers.trainer][INFO] - Rank: 0, Progress: [290/6381]
312
+ [2025-08-28 11:01:37,297][trainers.trainer][INFO] - Rank: 0, Progress: [291/6381]
313
+ [2025-08-28 11:01:37,425][trainers.trainer][INFO] - Rank: 0, Progress: [292/6381]
314
+ [2025-08-28 11:01:37,589][trainers.trainer][INFO] - Rank: 0, Progress: [293/6381]
315
+ [2025-08-28 11:01:37,865][trainers.trainer][INFO] - Rank: 0, Progress: [294/6381]
316
+ [2025-08-28 11:01:38,063][trainers.trainer][INFO] - Rank: 0, Progress: [295/6381]
317
+ [2025-08-28 11:01:38,161][trainers.trainer][INFO] - Rank: 0, Progress: [296/6381]
318
+ [2025-08-28 11:01:38,286][trainers.trainer][INFO] - Rank: 0, Progress: [297/6381]
319
+ [2025-08-28 11:01:38,373][trainers.trainer][INFO] - Rank: 0, Progress: [298/6381]
320
+ [2025-08-28 11:01:38,509][trainers.trainer][INFO] - Rank: 0, Progress: [299/6381]
321
+ [2025-08-28 11:01:38,755][trainers.trainer][INFO] - Rank: 0, Progress: [300/6381]
322
+ [2025-08-28 11:01:38,845][trainers.trainer][INFO] - Rank: 0, Progress: [301/6381]
323
+ [2025-08-28 11:01:38,961][trainers.trainer][INFO] - Rank: 0, Progress: [302/6381]
324
+ [2025-08-28 11:01:39,090][trainers.trainer][INFO] - Rank: 0, Progress: [303/6381]
325
+ [2025-08-28 11:01:39,206][trainers.trainer][INFO] - Rank: 0, Progress: [304/6381]
326
+ [2025-08-28 11:01:39,313][trainers.trainer][INFO] - Rank: 0, Progress: [305/6381]
327
+ [2025-08-28 11:01:39,469][trainers.trainer][INFO] - Rank: 0, Progress: [306/6381]
328
+ [2025-08-28 11:01:39,545][trainers.trainer][INFO] - Rank: 0, Progress: [307/6381]
329
+ [2025-08-28 11:01:39,630][trainers.trainer][INFO] - Rank: 0, Progress: [308/6381]
330
+ [2025-08-28 11:01:39,747][trainers.trainer][INFO] - Rank: 0, Progress: [309/6381]
331
+ [2025-08-28 11:01:39,898][trainers.trainer][INFO] - Rank: 0, Progress: [310/6381]
332
+ [2025-08-28 11:01:39,989][trainers.trainer][INFO] - Rank: 0, Progress: [311/6381]
333
+ [2025-08-28 11:01:40,199][trainers.trainer][INFO] - Rank: 0, Progress: [312/6381]
334
+ [2025-08-28 11:01:40,497][trainers.trainer][INFO] - Rank: 0, Progress: [313/6381]
335
+ [2025-08-28 11:01:40,684][trainers.trainer][INFO] - Rank: 0, Progress: [314/6381]
336
+ [2025-08-28 11:01:40,937][trainers.trainer][INFO] - Rank: 0, Progress: [315/6381]
337
+ [2025-08-28 11:01:41,072][trainers.trainer][INFO] - Rank: 0, Progress: [316/6381]
338
+ [2025-08-28 11:01:41,218][trainers.trainer][INFO] - Rank: 0, Progress: [317/6381]
339
+ [2025-08-28 11:01:41,363][trainers.trainer][INFO] - Rank: 0, Progress: [318/6381]
340
+ [2025-08-28 11:01:41,445][trainers.trainer][INFO] - Rank: 0, Progress: [319/6381]
341
+ [2025-08-28 11:01:41,566][trainers.trainer][INFO] - Rank: 0, Progress: [320/6381]
342
+ [2025-08-28 11:01:41,716][trainers.trainer][INFO] - Rank: 0, Progress: [321/6381]
343
+ [2025-08-28 11:01:41,851][trainers.trainer][INFO] - Rank: 0, Progress: [322/6381]
344
+ [2025-08-28 11:01:41,954][trainers.trainer][INFO] - Rank: 0, Progress: [323/6381]
345
+ [2025-08-28 11:01:42,136][trainers.trainer][INFO] - Rank: 0, Progress: [324/6381]
346
+ [2025-08-28 11:01:42,212][trainers.trainer][INFO] - Rank: 0, Progress: [325/6381]
347
+ [2025-08-28 11:01:42,304][trainers.trainer][INFO] - Rank: 0, Progress: [326/6381]
348
+ [2025-08-28 11:01:42,517][trainers.trainer][INFO] - Rank: 0, Progress: [327/6381]
349
+ [2025-08-28 11:01:42,636][trainers.trainer][INFO] - Rank: 0, Progress: [328/6381]
350
+ [2025-08-28 11:01:42,758][trainers.trainer][INFO] - Rank: 0, Progress: [329/6381]
351
+ [2025-08-28 11:01:42,958][trainers.trainer][INFO] - Rank: 0, Progress: [330/6381]
352
+ [2025-08-28 11:01:43,056][trainers.trainer][INFO] - Rank: 0, Progress: [331/6381]
353
+ [2025-08-28 11:01:43,177][trainers.trainer][INFO] - Rank: 0, Progress: [332/6381]
354
+ [2025-08-28 11:01:43,293][trainers.trainer][INFO] - Rank: 0, Progress: [333/6381]
355
+ [2025-08-28 11:01:43,412][trainers.trainer][INFO] - Rank: 0, Progress: [334/6381]
356
+ [2025-08-28 11:01:43,552][trainers.trainer][INFO] - Rank: 0, Progress: [335/6381]
357
+ [2025-08-28 11:01:43,734][trainers.trainer][INFO] - Rank: 0, Progress: [336/6381]
358
+ [2025-08-28 11:01:43,876][trainers.trainer][INFO] - Rank: 0, Progress: [337/6381]
359
+ [2025-08-28 11:01:44,006][trainers.trainer][INFO] - Rank: 0, Progress: [338/6381]
360
+ [2025-08-28 11:01:44,128][trainers.trainer][INFO] - Rank: 0, Progress: [339/6381]
361
+ [2025-08-28 11:01:44,204][trainers.trainer][INFO] - Rank: 0, Progress: [340/6381]
362
+ [2025-08-28 11:01:44,340][trainers.trainer][INFO] - Rank: 0, Progress: [341/6381]
363
+ [2025-08-28 11:01:44,493][trainers.trainer][INFO] - Rank: 0, Progress: [342/6381]
364
+ [2025-08-28 11:01:44,773][trainers.trainer][INFO] - Rank: 0, Progress: [343/6381]
365
+ [2025-08-28 11:01:44,909][trainers.trainer][INFO] - Rank: 0, Progress: [344/6381]
366
+ [2025-08-28 11:01:45,042][trainers.trainer][INFO] - Rank: 0, Progress: [345/6381]
367
+ [2025-08-28 11:01:45,252][trainers.trainer][INFO] - Rank: 0, Progress: [346/6381]
368
+ [2025-08-28 11:01:45,389][trainers.trainer][INFO] - Rank: 0, Progress: [347/6381]
369
+ [2025-08-28 11:01:45,597][trainers.trainer][INFO] - Rank: 0, Progress: [348/6381]
370
+ [2025-08-28 11:01:45,762][trainers.trainer][INFO] - Rank: 0, Progress: [349/6381]
371
+ [2025-08-28 11:01:45,878][trainers.trainer][INFO] - Rank: 0, Progress: [350/6381]
372
+ [2025-08-28 11:01:46,035][trainers.trainer][INFO] - Rank: 0, Progress: [351/6381]
373
+ [2025-08-28 11:01:46,153][trainers.trainer][INFO] - Rank: 0, Progress: [352/6381]
374
+ [2025-08-28 11:01:46,307][trainers.trainer][INFO] - Rank: 0, Progress: [353/6381]
375
+ [2025-08-28 11:01:46,666][trainers.trainer][INFO] - Rank: 0, Progress: [354/6381]
376
+ [2025-08-28 11:01:46,814][trainers.trainer][INFO] - Rank: 0, Progress: [355/6381]
377
+ [2025-08-28 11:01:46,961][trainers.trainer][INFO] - Rank: 0, Progress: [356/6381]
378
+ [2025-08-28 11:01:47,086][trainers.trainer][INFO] - Rank: 0, Progress: [357/6381]
379
+ [2025-08-28 11:01:47,206][trainers.trainer][INFO] - Rank: 0, Progress: [358/6381]
380
+ [2025-08-28 11:01:47,349][trainers.trainer][INFO] - Rank: 0, Progress: [359/6381]
381
+ [2025-08-28 11:01:47,566][trainers.trainer][INFO] - Rank: 0, Progress: [360/6381]
382
+ [2025-08-28 11:01:47,727][trainers.trainer][INFO] - Rank: 0, Progress: [361/6381]
383
+ [2025-08-28 11:01:47,940][trainers.trainer][INFO] - Rank: 0, Progress: [362/6381]
384
+ [2025-08-28 11:01:48,059][trainers.trainer][INFO] - Rank: 0, Progress: [363/6381]
385
+ [2025-08-28 11:01:48,215][trainers.trainer][INFO] - Rank: 0, Progress: [364/6381]
386
+ [2025-08-28 11:01:48,285][trainers.trainer][INFO] - Rank: 0, Progress: [365/6381]
387
+ [2025-08-28 11:01:48,555][trainers.trainer][INFO] - Rank: 0, Progress: [366/6381]
388
+ [2025-08-28 11:01:48,794][trainers.trainer][INFO] - Rank: 0, Progress: [367/6381]
389
+ [2025-08-28 11:01:49,134][trainers.trainer][INFO] - Rank: 0, Progress: [368/6381]
390
+ [2025-08-28 11:01:49,275][trainers.trainer][INFO] - Rank: 0, Progress: [369/6381]
391
+ [2025-08-28 11:01:49,364][trainers.trainer][INFO] - Rank: 0, Progress: [370/6381]
392
+ [2025-08-28 11:01:49,457][trainers.trainer][INFO] - Rank: 0, Progress: [371/6381]
393
+ [2025-08-28 11:01:49,692][trainers.trainer][INFO] - Rank: 0, Progress: [372/6381]
394
+ [2025-08-28 11:01:49,784][trainers.trainer][INFO] - Rank: 0, Progress: [373/6381]
395
+ [2025-08-28 11:01:49,957][trainers.trainer][INFO] - Rank: 0, Progress: [374/6381]
396
+ [2025-08-28 11:01:50,106][trainers.trainer][INFO] - Rank: 0, Progress: [375/6381]
397
+ [2025-08-28 11:01:50,190][trainers.trainer][INFO] - Rank: 0, Progress: [376/6381]
398
+ [2025-08-28 11:01:50,276][trainers.trainer][INFO] - Rank: 0, Progress: [377/6381]
399
+ [2025-08-28 11:01:50,457][trainers.trainer][INFO] - Rank: 0, Progress: [378/6381]
400
+ [2025-08-28 11:01:50,571][trainers.trainer][INFO] - Rank: 0, Progress: [379/6381]
401
+ [2025-08-28 11:01:50,756][trainers.trainer][INFO] - Rank: 0, Progress: [380/6381]
402
+ [2025-08-28 11:01:50,931][trainers.trainer][INFO] - Rank: 0, Progress: [381/6381]
403
+ [2025-08-28 11:01:51,080][trainers.trainer][INFO] - Rank: 0, Progress: [382/6381]
404
+ [2025-08-28 11:01:51,228][trainers.trainer][INFO] - Rank: 0, Progress: [383/6381]
405
+ [2025-08-28 11:01:51,444][trainers.trainer][INFO] - Rank: 0, Progress: [384/6381]
406
+ [2025-08-28 11:01:51,523][trainers.trainer][INFO] - Rank: 0, Progress: [385/6381]
407
+ [2025-08-28 11:01:51,629][trainers.trainer][INFO] - Rank: 0, Progress: [386/6381]
408
+ [2025-08-28 11:01:51,858][trainers.trainer][INFO] - Rank: 0, Progress: [387/6381]
409
+ [2025-08-28 11:01:52,092][trainers.trainer][INFO] - Rank: 0, Progress: [388/6381]
410
+ [2025-08-28 11:01:52,242][trainers.trainer][INFO] - Rank: 0, Progress: [389/6381]
411
+ [2025-08-28 11:01:52,374][trainers.trainer][INFO] - Rank: 0, Progress: [390/6381]
412
+ [2025-08-28 11:01:52,446][trainers.trainer][INFO] - Rank: 0, Progress: [391/6381]
413
+ [2025-08-28 11:01:52,582][trainers.trainer][INFO] - Rank: 0, Progress: [392/6381]
414
+ [2025-08-28 11:01:52,772][trainers.trainer][INFO] - Rank: 0, Progress: [393/6381]
415
+ [2025-08-28 11:01:52,909][trainers.trainer][INFO] - Rank: 0, Progress: [394/6381]
416
+ [2025-08-28 11:01:53,004][trainers.trainer][INFO] - Rank: 0, Progress: [395/6381]
417
+ [2025-08-28 11:01:53,237][trainers.trainer][INFO] - Rank: 0, Progress: [396/6381]
418
+ [2025-08-28 11:01:53,369][trainers.trainer][INFO] - Rank: 0, Progress: [397/6381]
419
+ [2025-08-28 11:01:53,442][trainers.trainer][INFO] - Rank: 0, Progress: [398/6381]
420
+ [2025-08-28 11:01:53,528][trainers.trainer][INFO] - Rank: 0, Progress: [399/6381]
421
+ [2025-08-28 11:01:53,715][trainers.trainer][INFO] - Rank: 0, Progress: [400/6381]
422
+ [2025-08-28 11:01:53,930][trainers.trainer][INFO] - Rank: 0, Progress: [401/6381]
423
+ [2025-08-28 11:01:54,060][trainers.trainer][INFO] - Rank: 0, Progress: [402/6381]
424
+ [2025-08-28 11:01:54,206][trainers.trainer][INFO] - Rank: 0, Progress: [403/6381]
425
+ [2025-08-28 11:01:54,314][trainers.trainer][INFO] - Rank: 0, Progress: [404/6381]
426
+ [2025-08-28 11:01:54,492][trainers.trainer][INFO] - Rank: 0, Progress: [405/6381]
427
+ [2025-08-28 11:01:54,573][trainers.trainer][INFO] - Rank: 0, Progress: [406/6381]
428
+ [2025-08-28 11:01:54,701][trainers.trainer][INFO] - Rank: 0, Progress: [407/6381]
429
+ [2025-08-28 11:01:55,002][trainers.trainer][INFO] - Rank: 0, Progress: [408/6381]
430
+ [2025-08-28 11:01:55,082][trainers.trainer][INFO] - Rank: 0, Progress: [409/6381]
431
+ [2025-08-28 11:01:55,231][trainers.trainer][INFO] - Rank: 0, Progress: [410/6381]
432
+ [2025-08-28 11:01:55,378][trainers.trainer][INFO] - Rank: 0, Progress: [411/6381]
433
+ [2025-08-28 11:01:55,455][trainers.trainer][INFO] - Rank: 0, Progress: [412/6381]
434
+ [2025-08-28 11:01:55,623][trainers.trainer][INFO] - Rank: 0, Progress: [413/6381]
435
+ [2025-08-28 11:02:52,106][__main__][INFO] - Working directory : /root/workspace/SwiftTailor3
436
+ [2025-08-28 11:02:52,106][__main__][INFO] - Output directory : /root/workspace/SwiftTailor3/output/train
437
+ [2025-08-28 11:02:52,114][data.data_wrappers.data_wrapper][INFO] - Loading data split from assets/data_configs/garmentcodedata_datasplit.json
438
+ [2025-08-28 11:03:16,792][data.data_wrappers.data_wrapper][INFO] - Dataset split: 114869 / 6381 / 6381
439
+ [2025-08-28 11:03:16,801][__main__][INFO] - Dataset created.
440
+ [2025-08-28 11:03:17,090][__main__][INFO] - Added 122 tokens to the tokenizer.
441
+ [2025-08-28 11:03:17,111][__main__][INFO] - Token name to index dictionary: {'<pattern_cmd_MOVE>': 151674, '<pattern_cmd_LINE>': 151675, '<pattern_cmd_CLINE>': 151676, '<pattern_cmd_CURVE>': 151677, '<pattern_cmd_CCURVE>': 151678, '<pattern_cmd_CUBIC>': 151679, '<pattern_cmd_CCUBIC>': 151680, '<pattern_cmd_ARC>': 151681, '<pattern_cmd_CARC>': 151682, '<panel_start>': 151683, '<panel_end>': 151684, '<pattern_start>': 151685, '<pattern_end>': 151686, '<stitch_tag_0>': 151687, '<stitch_tag_1>': 151688, '<stitch_tag_2>': 151689, '<stitch_tag_3>': 151690, '<stitch_tag_4>': 151691, '<stitch_tag_5>': 151692, '<stitch_tag_6>': 151693, '<stitch_tag_7>': 151694, '<stitch_tag_8>': 151695, '<stitch_tag_9>': 151696, '<stitch_tag_10>': 151697, '<stitch_tag_11>': 151698, '<stitch_tag_12>': 151699, '<stitch_tag_13>': 151700, '<stitch_tag_14>': 151701, '<stitch_tag_15>': 151702, '<stitch_tag_16>': 151703, '<stitch_tag_17>': 151704, '<stitch_tag_18>': 151705, '<stitch_tag_19>': 151706, '<stitch_tag_20>': 151707, '<stitch_tag_21>': 151708, '<stitch_tag_22>': 151709, '<stitch_tag_23>': 151710, '<stitch_tag_24>': 151711, '<stitch_tag_25>': 151712, '<stitch_tag_26>': 151713, '<stitch_tag_27>': 151714, '<stitch_tag_28>': 151715, '<stitch_tag_29>': 151716, '<stitch_tag_30>': 151717, '<stitch_tag_31>': 151718, '<stitch_tag_32>': 151719, '<stitch_tag_33>': 151720, '<stitch_tag_34>': 151721, '<stitch_tag_35>': 151722, '<stitch_tag_36>': 151723, '<stitch_tag_37>': 151724, '<stitch_tag_38>': 151725, '<stitch_tag_39>': 151726, '<stitch_tag_40>': 151727, '<stitch_tag_41>': 151728, '<stitch_tag_42>': 151729, '<stitch_tag_43>': 151730, '<stitch_tag_44>': 151731, '<stitch_tag_45>': 151732, '<stitch_tag_46>': 151733, '<stitch_tag_47>': 151734, '<stitch_tag_48>': 151735, '<stitch_tag_49>': 151736, '<stitch_tag_50>': 151737, '<stitch_tag_51>': 151738, '<stitch_tag_52>': 151739, '<stitch_tag_53>': 151740, '<stitch_tag_54>': 151741, '<stitch_tag_55>': 151742, '<stitch_tag_56>': 151743, '<stitch_tag_57>': 151744, '<stitch_tag_58>': 151745, '<stitch_tag_59>': 151746, '<stitch_tag_60>': 151747, '<stitch_tag_61>': 151748, '<stitch_tag_62>': 151749, '<stitch_tag_63>': 151750, '<stitch_tag_64>': 151751, '<stitch_tag_65>': 151752, '<stitch_tag_66>': 151753, '<stitch_tag_67>': 151754, '<stitch_tag_68>': 151755, '<stitch_tag_69>': 151756, '<stitch_tag_70>': 151757, '<stitch_tag_71>': 151758, '<stitch_tag_72>': 151759, '<stitch_tag_73>': 151760, '<stitch_tag_74>': 151761, '<stitch_tag_75>': 151762, '<stitch_tag_76>': 151763, '<stitch_tag_77>': 151764, '<stitch_tag_78>': 151765, '<stitch_tag_79>': 151766, '<stitch_tag_80>': 151767, '<stitch_tag_81>': 151768, '<stitch_tag_82>': 151769, '<stitch_tag_83>': 151770, '<stitch_tag_84>': 151771, '<stitch_tag_85>': 151772, '<stitch_tag_86>': 151773, '<stitch_tag_87>': 151774, '<stitch_tag_88>': 151775, '<stitch_tag_89>': 151776, '<stitch_tag_90>': 151777, '<stitch_tag_91>': 151778, '<stitch_tag_92>': 151779, '<stitch_tag_93>': 151780, '<stitch_tag_94>': 151781, '<stitch_tag_95>': 151782, '<stitch_tag_96>': 151783, '<stitch_tag_97>': 151784, '<stitch_tag_98>': 151785, '<stitch_tag_99>': 151786, '<stitch_tag_100>': 151787, '<stitch_tag_101>': 151788, '<stitch_tag_102>': 151789, '<stitch_tag_103>': 151790, '<stitch_tag_104>': 151791, '<stitch_tag_105>': 151792, '<stitch_tag_106>': 151793, '<stitch_tag_107>': 151794, '<stitch_tag_null>': 151795}
442
+ [2025-08-28 11:03:17,114][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1
443
+ [2025-08-28 11:03:17,114][models.internvl.configuration_internvl_chat][INFO] - ps_version: v2
444
+ [2025-08-28 11:03:17,115][models.internvl.configuration_internvl_chat][INFO] - min_dynamic_patch: 1
445
+ [2025-08-28 11:03:17,115][models.internvl.configuration_internvl_chat][INFO] - max_dynamic_patch: 12
446
+ [2025-08-28 11:03:17,115][__main__][INFO] - Loading model from output/train/ckpt_29999/output_dir
447
+ [2025-08-28 11:03:17,129][models.st_model][INFO] - num_image_token: 256
448
+ [2025-08-28 11:03:17,129][models.st_model][INFO] - ps_version: v2
449
+ [2025-08-28 11:04:11,409][models.internvl.configuration_internvl_chat][INFO] - vision_config is None. Initializing the InternVisionConfig with default values.
450
+ [2025-08-28 11:04:11,410][models.internvl.configuration_internvl_chat][INFO] - llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).
451
+ [2025-08-28 11:04:11,411][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1
452
+ [2025-08-28 11:04:11,411][models.internvl.configuration_internvl_chat][INFO] - ps_version: v1
453
+ [2025-08-28 11:04:11,411][models.internvl.configuration_internvl_chat][INFO] - min_dynamic_patch: 1
454
+ [2025-08-28 11:04:11,411][models.internvl.configuration_internvl_chat][INFO] - max_dynamic_patch: 6
455
+ [2025-08-28 11:18:45,123][trainers.trainer][INFO] - Rank: 0, Progress: [0/6381]
456
+ [2025-08-28 11:18:45,141][models.internvl.configuration_internvl_chat][INFO] - vision_config is None. Initializing the InternVisionConfig with default values.
457
+ [2025-08-28 11:18:45,141][models.internvl.configuration_internvl_chat][INFO] - llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).
458
+ [2025-08-28 11:18:45,143][models.internvl.configuration_internvl_chat][INFO] - vision_select_layer: -1