hmkang commited on
Commit
331bdc2
·
verified ·
1 Parent(s): 1d2e50c

stage-1 ctxcomp encspatial @ step 25000 (weights only)

Browse files
encspatial/config.json ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "",
3
+ "action_dit_size": "DiT-B",
4
+ "action_head_model_type": "dit",
5
+ "action_horizon": 16,
6
+ "action_loss_weight": 1.0,
7
+ "action_text_kv": false,
8
+ "add_cross_attention": false,
9
+ "add_pos_embed": true,
10
+ "apply_sincos_state_encoding": false,
11
+ "architectures": [
12
+ "WAMDiT4DiT"
13
+ ],
14
+ "attn_dropout": 0.2,
15
+ "backbone_embedding_dim": 3072,
16
+ "backbone_trainable_params_fp32": true,
17
+ "backbone_type": "wan22_diffusers",
18
+ "bad_words_ids": null,
19
+ "begin_suppress_tokens": null,
20
+ "bos_token_id": null,
21
+ "chunk_size_feed_forward": 0,
22
+ "color_jitter_params": null,
23
+ "conditional_frame_timestep": 0.0001,
24
+ "cosmos_model_path": "nvidia/Cosmos-Predict2.5-2B",
25
+ "cosmos_model_revision": "diffusers/base/pre-trained",
26
+ "crop_fraction": 0.95,
27
+ "cross_attention_hidden_size": null,
28
+ "decoder_start_token_id": null,
29
+ "diffusion_model_cfg": {
30
+ "attention_head_dim": 64,
31
+ "dropout": 0.2,
32
+ "final_dropout": true,
33
+ "interleave_self_attention": true,
34
+ "norm_type": "ada_norm",
35
+ "num_attention_heads": 12,
36
+ "num_layers": 16,
37
+ "output_dim": 2560,
38
+ "positional_embeddings": null
39
+ },
40
+ "diversity_penalty": 0.0,
41
+ "do_sample": false,
42
+ "dtype": "bfloat16",
43
+ "early_stopping": false,
44
+ "encoder_no_repeat_ngram_size": 0,
45
+ "eos_token_id": null,
46
+ "exponential_decay_length_penalty": null,
47
+ "fadistill_target_tau": 1.0,
48
+ "fadistill_teacher_nstep": 0,
49
+ "fadistill_teacher_traj": false,
50
+ "feature_extraction_aggregate_all": false,
51
+ "feature_extraction_aggregate_layer_window": 0,
52
+ "feature_extraction_layer": 18,
53
+ "finetuning_task": null,
54
+ "fm_high_sigma_min": 0.98,
55
+ "fm_high_sigma_ratio": null,
56
+ "fm_loss_weight": 1.0,
57
+ "fm_time_distribution": "uniform",
58
+ "forced_bos_token_id": null,
59
+ "forced_eos_token_id": null,
60
+ "formalize_language": true,
61
+ "frame_downsample_factor": 2,
62
+ "freeze_modules_pattern": "text_encoder,vae,transformer",
63
+ "freeze_step_weight_predictor": false,
64
+ "freeze_whole_backbone": false,
65
+ "future_loss_type": "flow_matching",
66
+ "future_num_inference_steps": 1,
67
+ "hidden_size": 2560,
68
+ "history_num_clean_frames": 1,
69
+ "history_obs_noise_timestep": 0.0,
70
+ "id2label": {
71
+ "0": "LABEL_0",
72
+ "1": "LABEL_1"
73
+ },
74
+ "image_crop_size": null,
75
+ "image_resize_backend": "cv2_linear",
76
+ "image_target_size": null,
77
+ "input_embedding_dim": 768,
78
+ "is_decoder": false,
79
+ "is_encoder_decoder": false,
80
+ "label2id": {
81
+ "LABEL_0": 0,
82
+ "LABEL_1": 1
83
+ },
84
+ "length_penalty": 1.0,
85
+ "load_bf16": true,
86
+ "max_action_dim": 32,
87
+ "max_length": 20,
88
+ "max_num_embodiments": 36,
89
+ "max_seq_len": 1024,
90
+ "max_state_dim": 64,
91
+ "meta_queries_mode": "meta_only",
92
+ "min_length": 0,
93
+ "model_dtype": "bfloat16",
94
+ "model_type": "WAM_DIT4DIT",
95
+ "multiview_layout": "tmosaic",
96
+ "n_meta_queries": 8,
97
+ "n_tune_layers_below_feature_extraction": 0,
98
+ "new_embodiment_train_ratio": 0,
99
+ "no_repeat_ngram_size": 0,
100
+ "noise_beta_alpha": 1.5,
101
+ "noise_beta_beta": 1.0,
102
+ "noise_s": 0.999,
103
+ "nstep_agg": false,
104
+ "nstep_agg_layers": 4,
105
+ "nstep_base_residual": false,
106
+ "nstep_base_residual_gate": "layerscale",
107
+ "nstep_certainty_arch": "mlp",
108
+ "nstep_certainty_ckpt": "",
109
+ "nstep_certainty_decalib": false,
110
+ "nstep_certainty_drop_cond": false,
111
+ "nstep_certainty_fusion": false,
112
+ "nstep_certainty_hidden": 1024,
113
+ "nstep_certainty_layers": 2,
114
+ "nstep_certainty_step_bias": false,
115
+ "nstep_certainty_tau": 1.0,
116
+ "nstep_compress_k": 64,
117
+ "nstep_compress_n_frame": 3,
118
+ "nstep_compress_query": false,
119
+ "nstep_latent_cond": false,
120
+ "nstep_n": 2,
121
+ "nstep_noise_ensemble": false,
122
+ "nstep_per_step_gated": false,
123
+ "nstep_query_len": 588,
124
+ "nstep_readout_exclude_step0": false,
125
+ "nstep_residual_warmup": false,
126
+ "nstep_residual_warmup_full": 20000,
127
+ "nstep_residual_warmup_start": 10000,
128
+ "nstep_step_dropout": false,
129
+ "nstep_step_embed": true,
130
+ "nstep_train_integration": false,
131
+ "num_beam_groups": 1,
132
+ "num_beams": 1,
133
+ "num_frames_in": 25,
134
+ "num_frames_out": 25,
135
+ "num_inference_timesteps": 4,
136
+ "num_past_action_steps": 24,
137
+ "num_return_sequences": 1,
138
+ "num_timestep_buckets": 1000,
139
+ "output_attentions": false,
140
+ "output_hidden_states": false,
141
+ "output_scores": false,
142
+ "pad_token_id": null,
143
+ "prefix": null,
144
+ "problem_type": null,
145
+ "pruned_heads": {},
146
+ "random_rotation_angle": null,
147
+ "remove_invalid_values": false,
148
+ "repeated_diffusion_steps": 4,
149
+ "repetition_penalty": 1.0,
150
+ "reproject_vision": false,
151
+ "return_dict": true,
152
+ "return_dict_in_generate": false,
153
+ "selfflow_ema_decay": 0.9999,
154
+ "selfflow_mask_ratio": 0.1,
155
+ "selfflow_rep": false,
156
+ "selfflow_rep_layer": -1,
157
+ "selfflow_rep_layer_student": -1,
158
+ "selfflow_rep_layer_teacher": -1,
159
+ "selfflow_rep_weight": 0.8,
160
+ "selfflow_teacher_noise": 0.0,
161
+ "sep_token_id": null,
162
+ "shortest_image_edge": null,
163
+ "state_additive_noise_scale": 0.0,
164
+ "state_dropout_prob": 0.0,
165
+ "step_weight_exclude_current_tokens": false,
166
+ "step_weight_predictor_ckpt": "",
167
+ "step_weight_predictor_heads": 16,
168
+ "step_weight_predictor_layers": 4,
169
+ "step_weight_sigmas": "0.995,0.9631,0.594,0.0099",
170
+ "step_weight_target_tau": 0.7,
171
+ "suppress_tokens": null,
172
+ "task_specific_params": null,
173
+ "temperature": 1.0,
174
+ "tf_legacy_loss": false,
175
+ "tie_encoder_decoder": false,
176
+ "tie_word_embeddings": true,
177
+ "tokenizer_class": null,
178
+ "top_k": 50,
179
+ "top_p": 1.0,
180
+ "torchscript": false,
181
+ "training_mode": "ctxcomp",
182
+ "transformers_version": "4.57.0",
183
+ "truncate_above_feature_extraction": false,
184
+ "tune_crossattn_proj": false,
185
+ "tune_diffusion_model": true,
186
+ "tune_layers_above_feature_extraction": true,
187
+ "tune_llm": false,
188
+ "tune_patch_embed": false,
189
+ "tune_projector": true,
190
+ "tune_time_embed": false,
191
+ "tune_top_llm_layers": 4,
192
+ "tune_vgln": true,
193
+ "tune_visual": false,
194
+ "typical_p": 1.0,
195
+ "use_albumentations_transforms": true,
196
+ "use_bfloat16": false,
197
+ "use_meta_queries": false,
198
+ "use_meta_queries_in_fm": false,
199
+ "use_noise_frames_in_extraction": true,
200
+ "use_relative_action": true,
201
+ "use_step_weight_fusion": false,
202
+ "use_vgln": false,
203
+ "use_vlm_meta": false,
204
+ "video_resolution": 256,
205
+ "video_train_crop": false,
206
+ "vl_adapter_num_layers": 0,
207
+ "wan21_model_path": "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers",
208
+ "wan_diffusers_model_path": "Wan-AI/Wan2.2-TI2V-5B-Diffusers",
209
+ "wan_fadistill_action_from_teacher": false,
210
+ "wan_fadistill_align_weight": 0.01,
211
+ "wan_fadistill_single_step_index": -1,
212
+ "wan_fadistill_teacher_shift": 5.0,
213
+ "wan_fadistill_teacher_stepper": "euler",
214
+ "wan_feature_extraction_layer": 18,
215
+ "wan_fm_train_shift": 1.0,
216
+ "wan_model_path": "Wan-AI/Wan2.2-TI2V-5B",
217
+ "wan_text_pad_zero": false,
218
+ "wan_tokenizer_model_id": "Wan-AI/Wan2.1-T2V-1.3B"
219
+ }
encspatial/embodiment_id.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "new_embodiment": 0,
3
+ "fractal20220817_data": 1,
4
+ "kuka": 2,
5
+ "bridge_orig": 3,
6
+ "taco_play": 4,
7
+ "jaco_play": 5,
8
+ "berkeley_cable_routing": 6,
9
+ "roboturk": 7,
10
+ "viola": 8,
11
+ "berkeley_autolab_ur5": 9,
12
+ "toto": 10,
13
+ "language_table": 11,
14
+ "stanford_hydra_dataset_converted_externally_to_rlds": 12,
15
+ "austin_buds_dataset_converted_externally_to_rlds": 13,
16
+ "nyu_franka_play_dataset_converted_externally_to_rlds": 14,
17
+ "furniture_bench_dataset_converted_externally_to_rlds": 15,
18
+ "ucsd_kitchen_dataset_converted_externally_to_rlds": 16,
19
+ "austin_sailor_dataset_converted_externally_to_rlds": 17,
20
+ "austin_sirius_dataset_converted_externally_to_rlds": 18,
21
+ "dlr_edan_shared_control_converted_externally_to_rlds": 19,
22
+ "iamlab_cmu_pickup_insert_converted_externally_to_rlds": 20,
23
+ "utaustin_mutex": 21,
24
+ "berkeley_fanuc_manipulation": 22,
25
+ "cmu_stretch": 23,
26
+ "bc_z": 24,
27
+ "fmb_dataset": 25,
28
+ "dobbe": 26,
29
+ "droid": 27,
30
+ "agibot_dexhand": 28,
31
+ "agibot_gripper": 29,
32
+ "galaxea": 30,
33
+ "humanoid_everyday_g1": 31,
34
+ "humanoid_everyday_h1": 32,
35
+ "action_net": 33,
36
+ "neural_gr1": 34,
37
+ "simulation_gr1": 35,
38
+ "libero_panda": 2
39
+ }
encspatial/experiment_cfg/conf.yaml ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data:
2
+ datasets:
3
+ - dataset_paths:
4
+ - /data/shared_dataset/robocasa_mg_gr00t_300
5
+ embodiment_tag: new_embodiment
6
+ mix_ratio: 1.0
7
+ dataset_type: physical_embodiment
8
+ val_dataset_path: null
9
+ modality_configs:
10
+ new_embodiment:
11
+ video:
12
+ delta_indices:
13
+ - -24
14
+ - -22
15
+ - -20
16
+ - -18
17
+ - -16
18
+ - -14
19
+ - -12
20
+ - -10
21
+ - -8
22
+ - -6
23
+ - -4
24
+ - -2
25
+ - 0
26
+ modality_keys:
27
+ - left_view
28
+ - right_view
29
+ - wrist_view
30
+ sin_cos_embedding_keys: null
31
+ mean_std_embedding_keys: null
32
+ action_configs: null
33
+ state:
34
+ delta_indices:
35
+ - 0
36
+ modality_keys:
37
+ - end_effector_position_relative
38
+ - end_effector_rotation_relative
39
+ - gripper_qpos
40
+ - base_position
41
+ - base_rotation
42
+ sin_cos_embedding_keys: null
43
+ mean_std_embedding_keys: null
44
+ action_configs: null
45
+ action:
46
+ delta_indices:
47
+ - -24
48
+ - -23
49
+ - -22
50
+ - -21
51
+ - -20
52
+ - -19
53
+ - -18
54
+ - -17
55
+ - -16
56
+ - -15
57
+ - -14
58
+ - -13
59
+ - -12
60
+ - -11
61
+ - -10
62
+ - -9
63
+ - -8
64
+ - -7
65
+ - -6
66
+ - -5
67
+ - -4
68
+ - -3
69
+ - -2
70
+ - -1
71
+ - 0
72
+ - 1
73
+ - 2
74
+ - 3
75
+ - 4
76
+ - 5
77
+ - 6
78
+ - 7
79
+ - 8
80
+ - 9
81
+ - 10
82
+ - 11
83
+ - 12
84
+ - 13
85
+ - 14
86
+ - 15
87
+ modality_keys:
88
+ - end_effector_position
89
+ - end_effector_rotation
90
+ - gripper_close
91
+ - base_motion
92
+ - control_mode
93
+ sin_cos_embedding_keys: null
94
+ mean_std_embedding_keys: null
95
+ action_configs:
96
+ - rep: DELTA
97
+ type: EEF
98
+ format: DEFAULT
99
+ state_key: null
100
+ - rep: DELTA
101
+ type: EEF
102
+ format: DEFAULT
103
+ state_key: null
104
+ - rep: ABSOLUTE
105
+ type: NON_EEF
106
+ format: DEFAULT
107
+ state_key: null
108
+ - rep: DELTA
109
+ type: NON_EEF
110
+ format: DEFAULT
111
+ state_key: null
112
+ - rep: ABSOLUTE
113
+ type: NON_EEF
114
+ format: DEFAULT
115
+ state_key: null
116
+ language:
117
+ delta_indices:
118
+ - 0
119
+ modality_keys:
120
+ - annotation.human.action.task_description
121
+ sin_cos_embedding_keys: null
122
+ mean_std_embedding_keys: null
123
+ action_configs: null
124
+ dataset_mode: sharded
125
+ download_cache: false
126
+ shard_size: 1024
127
+ episode_sampling_rate: 0.1
128
+ num_shards_per_epoch: 100000
129
+ override_pretraining_statistics: false
130
+ mode: single_turn
131
+ random_chop: 0.0
132
+ mock_dataset_mode: false
133
+ shuffle: true
134
+ seed: 42
135
+ multiprocessing_context: fork
136
+ allow_padding: true
137
+ subsample_ratio: 1.0
138
+ image_crop_size:
139
+ - 244
140
+ - 244
141
+ image_target_size:
142
+ - 224
143
+ - 224
144
+ video_backend: ffmpeg
145
+ load_config_path: null
146
+ model:
147
+ model_type: WAM_DIT4DIT
148
+ model_dtype: bfloat16
149
+ backbone_type: wan22_diffusers
150
+ wan_model_path: Wan-AI/Wan2.2-TI2V-5B
151
+ wan_diffusers_model_path: Wan-AI/Wan2.2-TI2V-5B-Diffusers
152
+ wan21_model_path: Wan-AI/Wan2.1-I2V-14B-480P-Diffusers
153
+ wan_tokenizer_model_id: Wan-AI/Wan2.1-T2V-1.3B
154
+ wan_feature_extraction_layer: 18
155
+ cosmos_model_path: nvidia/Cosmos-Predict2.5-2B
156
+ cosmos_model_revision: diffusers/base/pre-trained
157
+ backbone_embedding_dim: 2048
158
+ num_frames_in: 25
159
+ num_frames_out: 25
160
+ frame_downsample_factor: 2
161
+ video_resolution: 256
162
+ feature_extraction_layer: 18
163
+ feature_extraction_aggregate_all: false
164
+ feature_extraction_aggregate_layer_window: 0
165
+ truncate_above_feature_extraction: false
166
+ vl_adapter_num_layers: 0
167
+ tune_layers_above_feature_extraction: true
168
+ n_tune_layers_below_feature_extraction: 0
169
+ tune_patch_embed: false
170
+ tune_time_embed: false
171
+ tune_crossattn_proj: false
172
+ freeze_modules_pattern: text_encoder,vae,transformer
173
+ freeze_whole_backbone: false
174
+ fm_loss_weight: 1.0
175
+ action_loss_weight: 1.0
176
+ conditional_frame_timestep: 0.0001
177
+ history_obs_noise_timestep: 0.0
178
+ history_num_clean_frames: 1
179
+ selfflow_rep: false
180
+ selfflow_rep_layer: -1
181
+ selfflow_rep_layer_student: -1
182
+ selfflow_rep_layer_teacher: -1
183
+ selfflow_mask_ratio: 0.1
184
+ selfflow_ema_decay: 0.9999
185
+ selfflow_rep_weight: 0.8
186
+ selfflow_teacher_noise: 0.0
187
+ fadistill_teacher_traj: false
188
+ fadistill_target_tau: 1.0
189
+ fadistill_teacher_nstep: 0
190
+ wan_fadistill_teacher_shift: 5.0
191
+ wan_fadistill_single_step_index: -1
192
+ wan_fadistill_align_weight: 0.01
193
+ wan_fadistill_teacher_stepper: euler
194
+ wan_fadistill_action_from_teacher: false
195
+ wan_fm_train_shift: 1.0
196
+ wan_text_pad_zero: false
197
+ nstep_agg: false
198
+ nstep_n: 2
199
+ nstep_query_len: 588
200
+ nstep_step_embed: true
201
+ nstep_agg_layers: 4
202
+ nstep_train_integration: false
203
+ nstep_noise_ensemble: false
204
+ nstep_base_residual: false
205
+ nstep_base_residual_gate: layerscale
206
+ nstep_compress_query: false
207
+ nstep_compress_k: 64
208
+ nstep_compress_n_frame: 3
209
+ nstep_readout_exclude_step0: false
210
+ nstep_per_step_gated: false
211
+ nstep_step_dropout: false
212
+ nstep_residual_warmup: false
213
+ nstep_residual_warmup_start: 10000
214
+ nstep_residual_warmup_full: 20000
215
+ nstep_certainty_fusion: false
216
+ nstep_certainty_ckpt: ''
217
+ nstep_certainty_tau: 1.0
218
+ nstep_certainty_drop_cond: false
219
+ nstep_certainty_arch: mlp
220
+ nstep_certainty_hidden: 1024
221
+ nstep_certainty_layers: 2
222
+ nstep_certainty_decalib: false
223
+ nstep_certainty_step_bias: false
224
+ nstep_latent_cond: false
225
+ use_step_weight_fusion: false
226
+ step_weight_target_tau: 0.7
227
+ step_weight_sigmas: 0.995,0.9631,0.594,0.0099
228
+ step_weight_predictor_layers: 4
229
+ step_weight_predictor_heads: 16
230
+ step_weight_predictor_ckpt: ''
231
+ freeze_step_weight_predictor: false
232
+ step_weight_exclude_current_tokens: false
233
+ multiview_layout: tmosaic
234
+ fm_time_distribution: uniform
235
+ fm_high_sigma_ratio: null
236
+ fm_high_sigma_min: 0.98
237
+ future_loss_type: flow_matching
238
+ future_num_inference_steps: 1
239
+ use_noise_frames_in_extraction: true
240
+ use_meta_queries: false
241
+ n_meta_queries: 8
242
+ meta_queries_mode: meta_only
243
+ use_meta_queries_in_fm: false
244
+ use_vlm_meta: false
245
+ use_vgln: false
246
+ tune_vgln: true
247
+ action_text_kv: false
248
+ state_dropout_prob: 0.0
249
+ state_additive_noise_scale: 0.0
250
+ training_mode: ctxcomp
251
+ action_head_model_type: dit
252
+ max_state_dim: 64
253
+ apply_sincos_state_encoding: false
254
+ video_train_crop: false
255
+ image_resize_backend: cv2_linear
256
+ max_action_dim: 32
257
+ action_horizon: 16
258
+ num_past_action_steps: 24
259
+ hidden_size: 2560
260
+ input_embedding_dim: 768
261
+ repeated_diffusion_steps: 4
262
+ add_pos_embed: true
263
+ max_seq_len: 1024
264
+ attn_dropout: 0.2
265
+ action_dit_size: DiT-B
266
+ diffusion_model_cfg:
267
+ attention_head_dim: 64
268
+ dropout: 0.2
269
+ final_dropout: true
270
+ interleave_self_attention: true
271
+ norm_type: ada_norm
272
+ num_attention_heads: 12
273
+ num_layers: 16
274
+ output_dim: 2560
275
+ positional_embeddings: null
276
+ num_inference_timesteps: 4
277
+ noise_beta_alpha: 1.5
278
+ noise_beta_beta: 1.0
279
+ noise_s: 0.999
280
+ num_timestep_buckets: 1000
281
+ tune_projector: true
282
+ tune_diffusion_model: true
283
+ formalize_language: true
284
+ use_albumentations_transforms: true
285
+ crop_fraction: 0.95
286
+ random_rotation_angle: null
287
+ color_jitter_params: null
288
+ image_crop_size: null
289
+ image_target_size: null
290
+ shortest_image_edge: null
291
+ max_num_embodiments: 36
292
+ new_embodiment_train_ratio: 0.0
293
+ training:
294
+ output_dir: /data/rlwrld-unified-checkpoints/hyeonmo/checkpoints/ctxcomp_stage1_encspatial
295
+ experiment_name: ctxcomp_s1_encspatial_T4_mdim192_attn
296
+ max_steps: 25000
297
+ global_batch_size: 16
298
+ batch_size: null
299
+ gradient_accumulation_steps: 1
300
+ learning_rate: 0.0003
301
+ lr_scheduler_type: cosine_with_min_lr
302
+ min_lr: 5.0e-07
303
+ weight_decay: 0.0
304
+ warmup_ratio: 0.0
305
+ warmup_steps: 1500
306
+ max_grad_norm: 1.0
307
+ new_param_warmup_steps: 0
308
+ reset_stage2_lr_scheduler: false
309
+ adam_beta1: 0.9
310
+ adam_beta2: 0.95
311
+ adam_epsilon: 1.0e-08
312
+ lr_per_module_enabled: false
313
+ lr_base: 3.0e-05
314
+ lr_backbone: 1.0e-05
315
+ lr_action_head: 0.0001
316
+ optim: adamw_torch
317
+ start_from_checkpoint: /data/hyeonmo/hf_ckpt/hwabl_4latin/checkpoint-100000
318
+ tf32: true
319
+ fp16: false
320
+ bf16: true
321
+ eval_bf16: true
322
+ logging_steps: 10
323
+ save_steps: 5000
324
+ save_total_limit: 6
325
+ save_vl_model: false
326
+ upload_checkpoints: false
327
+ upload_every: 1000
328
+ upload_last_n_checkpoints: 5
329
+ max_concurrent_uploads: 2
330
+ eval_strategy: 'no'
331
+ eval_steps: 500
332
+ eval_set_split_ratio: 0.1
333
+ eval_num_shards_per_epoch: 8
334
+ eval_batch_size: 2
335
+ save_best_eval_metric_name: ''
336
+ save_best_eval_metric_greater_is_better: true
337
+ deepspeed_stage: 2
338
+ deepspeed_config_path: null
339
+ gradient_checkpointing: false
340
+ resume_from_checkpoint: false
341
+ transformers_trust_remote_code: true
342
+ transformers_local_files_only: false
343
+ transformers_cache_dir: null
344
+ transformers_access_token: null
345
+ use_ddp: false
346
+ ddp_bucket_cap_mb: 100
347
+ num_gpus: 2
348
+ dataloader_num_workers: 4
349
+ remove_unused_columns: false
350
+ use_wandb: true
351
+ wandb_project: wam-dit4dit-robocasa-ctxcomp-stage1
352
+ enable_profiling: false
353
+ max_retries: 3
354
+ assert_loss_less_than: null
355
+ add_rl_callback: false
356
+ enable_open_loop_eval: false
357
+ open_loop_eval_traj_ids:
358
+ - 0
359
+ open_loop_eval_steps_per_traj: 100
360
+ open_loop_eval_plot_indices: null
361
+ max_steps: 25000
362
+ save_steps: 5000
encspatial/experiment_cfg/config.yaml ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !!python/object:gr00t.configs.base_config.Config
2
+ data: !!python/object:gr00t.configs.data.data_config.DataConfig
3
+ allow_padding: true
4
+ dataset_mode: sharded
5
+ datasets:
6
+ - !!python/object:gr00t.configs.data.data_config.SingleDatasetConfig
7
+ dataset_paths:
8
+ - /data/shared_dataset/robocasa_mg_gr00t_300
9
+ dataset_type: physical_embodiment
10
+ embodiment_tag: new_embodiment
11
+ mix_ratio: 1.0
12
+ val_dataset_path: null
13
+ download_cache: false
14
+ episode_sampling_rate: 0.1
15
+ image_crop_size:
16
+ - 244
17
+ - 244
18
+ image_target_size:
19
+ - 224
20
+ - 224
21
+ mock_dataset_mode: false
22
+ modality_configs:
23
+ new_embodiment:
24
+ action: !!python/object:gr00t.data.types.ModalityConfig
25
+ action_configs:
26
+ - !!python/object:gr00t.data.types.ActionConfig
27
+ format: &id001 !!python/object/apply:gr00t.data.types.ActionFormat
28
+ - default
29
+ rep: &id002 !!python/object/apply:gr00t.data.types.ActionRepresentation
30
+ - delta
31
+ state_key: null
32
+ type: &id003 !!python/object/apply:gr00t.data.types.ActionType
33
+ - eef
34
+ - !!python/object:gr00t.data.types.ActionConfig
35
+ format: *id001
36
+ rep: *id002
37
+ state_key: null
38
+ type: *id003
39
+ - !!python/object:gr00t.data.types.ActionConfig
40
+ format: *id001
41
+ rep: &id005 !!python/object/apply:gr00t.data.types.ActionRepresentation
42
+ - absolute
43
+ state_key: null
44
+ type: &id004 !!python/object/apply:gr00t.data.types.ActionType
45
+ - non_eef
46
+ - !!python/object:gr00t.data.types.ActionConfig
47
+ format: *id001
48
+ rep: *id002
49
+ state_key: null
50
+ type: *id004
51
+ - !!python/object:gr00t.data.types.ActionConfig
52
+ format: *id001
53
+ rep: *id005
54
+ state_key: null
55
+ type: *id004
56
+ delta_indices:
57
+ - -24
58
+ - -23
59
+ - -22
60
+ - -21
61
+ - -20
62
+ - -19
63
+ - -18
64
+ - -17
65
+ - -16
66
+ - -15
67
+ - -14
68
+ - -13
69
+ - -12
70
+ - -11
71
+ - -10
72
+ - -9
73
+ - -8
74
+ - -7
75
+ - -6
76
+ - -5
77
+ - -4
78
+ - -3
79
+ - -2
80
+ - -1
81
+ - 0
82
+ - 1
83
+ - 2
84
+ - 3
85
+ - 4
86
+ - 5
87
+ - 6
88
+ - 7
89
+ - 8
90
+ - 9
91
+ - 10
92
+ - 11
93
+ - 12
94
+ - 13
95
+ - 14
96
+ - 15
97
+ mean_std_embedding_keys: null
98
+ modality_keys:
99
+ - end_effector_position
100
+ - end_effector_rotation
101
+ - gripper_close
102
+ - base_motion
103
+ - control_mode
104
+ sin_cos_embedding_keys: null
105
+ language: !!python/object:gr00t.data.types.ModalityConfig
106
+ action_configs: null
107
+ delta_indices:
108
+ - 0
109
+ mean_std_embedding_keys: null
110
+ modality_keys:
111
+ - annotation.human.action.task_description
112
+ sin_cos_embedding_keys: null
113
+ state: !!python/object:gr00t.data.types.ModalityConfig
114
+ action_configs: null
115
+ delta_indices:
116
+ - 0
117
+ mean_std_embedding_keys: null
118
+ modality_keys:
119
+ - end_effector_position_relative
120
+ - end_effector_rotation_relative
121
+ - gripper_qpos
122
+ - base_position
123
+ - base_rotation
124
+ sin_cos_embedding_keys: null
125
+ video: !!python/object:gr00t.data.types.ModalityConfig
126
+ action_configs: null
127
+ delta_indices:
128
+ - -24
129
+ - -22
130
+ - -20
131
+ - -18
132
+ - -16
133
+ - -14
134
+ - -12
135
+ - -10
136
+ - -8
137
+ - -6
138
+ - -4
139
+ - -2
140
+ - 0
141
+ mean_std_embedding_keys: null
142
+ modality_keys:
143
+ - left_view
144
+ - right_view
145
+ - wrist_view
146
+ sin_cos_embedding_keys: null
147
+ mode: single_turn
148
+ multiprocessing_context: fork
149
+ num_shards_per_epoch: 100000
150
+ override_pretraining_statistics: false
151
+ random_chop: 0.0
152
+ seed: 42
153
+ shard_size: 1024
154
+ shuffle: true
155
+ subsample_ratio: 1.0
156
+ video_backend: ffmpeg
157
+ load_config_path: null
158
+ model: !!python/object:gr00t.configs.model.wam_dit4dit.WAMDiT4DiTConfig
159
+ _attn_implementation_internal: null
160
+ _commit_hash: null
161
+ _name_or_path: ''
162
+ _output_attentions: false
163
+ _wam_sparse_checkpoint_config: false
164
+ action_dit_size: DiT-B
165
+ action_head_model_type: dit
166
+ action_text_kv: false
167
+ add_cross_attention: false
168
+ apply_sincos_state_encoding: false
169
+ architectures: null
170
+ backbone_trainable_params_fp32: true
171
+ backbone_type: wan22_diffusers
172
+ bad_words_ids: null
173
+ begin_suppress_tokens: null
174
+ bos_token_id: null
175
+ chunk_size_feed_forward: 0
176
+ color_jitter_params: null
177
+ conditional_frame_timestep: 0.0001
178
+ cross_attention_hidden_size: null
179
+ decoder_start_token_id: null
180
+ diffusion_model_cfg:
181
+ attention_head_dim: 64
182
+ dropout: 0.2
183
+ final_dropout: true
184
+ interleave_self_attention: true
185
+ norm_type: ada_norm
186
+ num_attention_heads: 12
187
+ num_layers: 16
188
+ output_dim: 2560
189
+ positional_embeddings: null
190
+ diversity_penalty: 0.0
191
+ do_sample: false
192
+ dtype: null
193
+ early_stopping: false
194
+ encoder_no_repeat_ngram_size: 0
195
+ eos_token_id: null
196
+ exponential_decay_length_penalty: null
197
+ fadistill_target_tau: 1.0
198
+ fadistill_teacher_nstep: 0
199
+ fadistill_teacher_traj: false
200
+ feature_extraction_aggregate_all: false
201
+ feature_extraction_aggregate_layer_window: 0
202
+ feature_extraction_layer: 18
203
+ finetuning_task: null
204
+ forced_bos_token_id: null
205
+ forced_eos_token_id: null
206
+ frame_downsample_factor: 2
207
+ freeze_modules_pattern: text_encoder,vae,transformer
208
+ freeze_step_weight_predictor: false
209
+ freeze_whole_backbone: false
210
+ history_num_clean_frames: 1
211
+ history_obs_noise_timestep: 0.0
212
+ id2label:
213
+ 0: LABEL_0
214
+ 1: LABEL_1
215
+ image_resize_backend: cv2_linear
216
+ input_embedding_dim: 768
217
+ is_decoder: false
218
+ is_encoder_decoder: false
219
+ label2id:
220
+ LABEL_0: 0
221
+ LABEL_1: 1
222
+ length_penalty: 1.0
223
+ load_bf16: true
224
+ max_length: 20
225
+ min_length: 0
226
+ model_type: WAM_DIT4DIT
227
+ multiview_layout: tmosaic
228
+ new_embodiment_train_ratio: 0
229
+ no_repeat_ngram_size: 0
230
+ nstep_agg: false
231
+ nstep_agg_layers: 4
232
+ nstep_base_residual: false
233
+ nstep_base_residual_gate: layerscale
234
+ nstep_certainty_arch: mlp
235
+ nstep_certainty_ckpt: ''
236
+ nstep_certainty_decalib: false
237
+ nstep_certainty_drop_cond: false
238
+ nstep_certainty_fusion: false
239
+ nstep_certainty_hidden: 1024
240
+ nstep_certainty_layers: 2
241
+ nstep_certainty_step_bias: false
242
+ nstep_certainty_tau: 1.0
243
+ nstep_compress_k: 64
244
+ nstep_compress_n_frame: 3
245
+ nstep_compress_query: false
246
+ nstep_latent_cond: false
247
+ nstep_n: 2
248
+ nstep_noise_ensemble: false
249
+ nstep_per_step_gated: false
250
+ nstep_query_len: 588
251
+ nstep_readout_exclude_step0: false
252
+ nstep_residual_warmup: false
253
+ nstep_residual_warmup_full: 20000
254
+ nstep_residual_warmup_start: 10000
255
+ nstep_step_dropout: false
256
+ nstep_step_embed: true
257
+ nstep_train_integration: false
258
+ num_beam_groups: 1
259
+ num_beams: 1
260
+ num_frames_in: 25
261
+ num_frames_out: 25
262
+ num_past_action_steps: 24
263
+ num_return_sequences: 1
264
+ output_hidden_states: false
265
+ output_scores: false
266
+ pad_token_id: null
267
+ prefix: null
268
+ problem_type: null
269
+ pruned_heads: {}
270
+ random_rotation_angle: null
271
+ remove_invalid_values: false
272
+ repeated_diffusion_steps: 4
273
+ repetition_penalty: 1.0
274
+ reproject_vision: false
275
+ return_dict: true
276
+ return_dict_in_generate: false
277
+ selfflow_ema_decay: 0.9999
278
+ selfflow_mask_ratio: 0.1
279
+ selfflow_rep: false
280
+ selfflow_rep_layer: -1
281
+ selfflow_rep_layer_student: -1
282
+ selfflow_rep_layer_teacher: -1
283
+ selfflow_rep_weight: 0.8
284
+ selfflow_teacher_noise: 0.0
285
+ sep_token_id: null
286
+ state_dropout_prob: 0.0
287
+ step_weight_exclude_current_tokens: false
288
+ step_weight_predictor_ckpt: ''
289
+ step_weight_predictor_heads: 16
290
+ step_weight_predictor_layers: 4
291
+ step_weight_sigmas: 0.995,0.9631,0.594,0.0099
292
+ step_weight_target_tau: 0.7
293
+ suppress_tokens: null
294
+ task_specific_params: null
295
+ temperature: 1.0
296
+ tf_legacy_loss: false
297
+ tie_encoder_decoder: false
298
+ tie_word_embeddings: true
299
+ tokenizer_class: null
300
+ top_k: 50
301
+ top_p: 1.0
302
+ torchscript: false
303
+ training_mode: ctxcomp
304
+ transformers_version: null
305
+ truncate_above_feature_extraction: false
306
+ tune_crossattn_proj: false
307
+ tune_diffusion_model: true
308
+ tune_layers_above_feature_extraction: true
309
+ tune_llm: false
310
+ tune_patch_embed: false
311
+ tune_projector: true
312
+ tune_time_embed: false
313
+ tune_top_llm_layers: 4
314
+ tune_vgln: true
315
+ tune_visual: false
316
+ typical_p: 1.0
317
+ use_bfloat16: false
318
+ use_meta_queries: false
319
+ use_meta_queries_in_fm: false
320
+ use_noise_frames_in_extraction: true
321
+ use_relative_action: true
322
+ use_step_weight_fusion: false
323
+ use_vgln: false
324
+ use_vlm_meta: false
325
+ video_resolution: 256
326
+ video_train_crop: false
327
+ vl_adapter_num_layers: 0
328
+ wan_fadistill_action_from_teacher: false
329
+ wan_fadistill_align_weight: 0.01
330
+ wan_fadistill_single_step_index: -1
331
+ wan_fadistill_teacher_shift: 5.0
332
+ wan_fadistill_teacher_stepper: euler
333
+ wan_feature_extraction_layer: 18
334
+ wan_fm_train_shift: 1.0
335
+ wan_model_path: Wan-AI/Wan2.2-TI2V-5B
336
+ wan_text_pad_zero: false
337
+ training: !!python/object:gr00t.configs.training.training_config.TrainingConfig
338
+ adam_beta1: 0.9
339
+ adam_beta2: 0.95
340
+ adam_epsilon: 1.0e-08
341
+ add_rl_callback: false
342
+ assert_loss_less_than: null
343
+ batch_size: null
344
+ bf16: true
345
+ dataloader_num_workers: 4
346
+ ddp_bucket_cap_mb: 100
347
+ deepspeed_config_path: null
348
+ deepspeed_stage: 2
349
+ enable_open_loop_eval: false
350
+ enable_profiling: false
351
+ eval_batch_size: 2
352
+ eval_bf16: true
353
+ eval_num_shards_per_epoch: 8
354
+ eval_set_split_ratio: 0.1
355
+ eval_steps: 500
356
+ eval_strategy: 'no'
357
+ experiment_name: ctxcomp_s1_encspatial_T4_mdim192_attn
358
+ fp16: false
359
+ global_batch_size: 16
360
+ gradient_accumulation_steps: 1
361
+ gradient_checkpointing: false
362
+ learning_rate: 0.0003
363
+ logging_steps: 10
364
+ lr_action_head: 0.0001
365
+ lr_backbone: 1.0e-05
366
+ lr_base: 3.0e-05
367
+ lr_per_module_enabled: false
368
+ lr_scheduler_type: cosine_with_min_lr
369
+ max_concurrent_uploads: 2
370
+ max_grad_norm: 1.0
371
+ max_retries: 3
372
+ max_steps: 25000
373
+ min_lr: 5.0e-07
374
+ new_param_warmup_steps: 0
375
+ num_gpus: 2
376
+ open_loop_eval_plot_indices: null
377
+ open_loop_eval_steps_per_traj: 100
378
+ open_loop_eval_traj_ids:
379
+ - 0
380
+ optim: adamw_torch
381
+ output_dir: /data/rlwrld-unified-checkpoints/hyeonmo/checkpoints/ctxcomp_stage1_encspatial
382
+ remove_unused_columns: false
383
+ reset_stage2_lr_scheduler: false
384
+ resume_from_checkpoint: false
385
+ save_best_eval_metric_greater_is_better: true
386
+ save_best_eval_metric_name: ''
387
+ save_steps: 5000
388
+ save_total_limit: 6
389
+ save_vl_model: false
390
+ start_from_checkpoint: /data/hyeonmo/hf_ckpt/hwabl_4latin/checkpoint-100000
391
+ tf32: true
392
+ transformers_access_token: null
393
+ transformers_cache_dir: null
394
+ transformers_local_files_only: false
395
+ transformers_trust_remote_code: true
396
+ upload_checkpoints: false
397
+ upload_every: 1000
398
+ upload_last_n_checkpoints: 5
399
+ use_ddp: false
400
+ use_wandb: true
401
+ wandb_project: wam-dit4dit-robocasa-ctxcomp-stage1
402
+ warmup_ratio: 0.0
403
+ warmup_steps: 1500
404
+ weight_decay: 0.0
encspatial/experiment_cfg/dataset_statistics.json ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "new_embodiment": {
3
+ "state": {
4
+ "end_effector_position_relative": {
5
+ "min": [
6
+ -0.46594083309173584,
7
+ -0.8278615474700928,
8
+ 0.011948669329285622
9
+ ],
10
+ "max": [
11
+ 0.8734620809555054,
12
+ 0.8441421985626221,
13
+ 1.1348456144332886
14
+ ],
15
+ "mean": [
16
+ 0.266306072473526,
17
+ -0.04002884030342102,
18
+ 0.5537278652191162
19
+ ],
20
+ "std": [
21
+ 0.19139817357063293,
22
+ 0.2582354247570038,
23
+ 0.2461009919643402
24
+ ],
25
+ "q01": [
26
+ -0.251964715719223,
27
+ -0.6177875232696534,
28
+ 0.07541620314121246
29
+ ],
30
+ "q99": [
31
+ 0.736240336894989,
32
+ 0.6068667078018188,
33
+ 0.9772176861763
34
+ ]
35
+ },
36
+ "end_effector_rotation_relative": {
37
+ "min": [
38
+ -0.9999996423721313,
39
+ -0.9910850524902344,
40
+ -0.9571061134338379,
41
+ 6.351022108219695e-08
42
+ ],
43
+ "max": [
44
+ 0.9999980926513672,
45
+ 0.990567147731781,
46
+ 0.964046835899353,
47
+ 0.9740113019943237
48
+ ],
49
+ "mean": [
50
+ -0.14963096380233765,
51
+ 0.1248803362250328,
52
+ 0.0027880165725946426,
53
+ 0.2082664668560028
54
+ ],
55
+ "std": [
56
+ 0.7683019042015076,
57
+ 0.36296239495277405,
58
+ 0.37635329365730286,
59
+ 0.2322801947593689
60
+ ],
61
+ "q01": [
62
+ -0.9973158955574035,
63
+ -0.6837371301651001,
64
+ -0.7814695286750794,
65
+ 0.0013687612861394884
66
+ ],
67
+ "q99": [
68
+ 0.9957762026786804,
69
+ 0.8491807365417481,
70
+ 0.7687161755561829,
71
+ 0.802422981262207
72
+ ]
73
+ },
74
+ "gripper_qpos": {
75
+ "min": [
76
+ -0.027591193094849586,
77
+ -0.05319468677043915
78
+ ],
79
+ "max": [
80
+ 0.07896614819765091,
81
+ 0.10181591659784317
82
+ ],
83
+ "mean": [
84
+ 0.030854083597660065,
85
+ -0.03072655387222767
86
+ ],
87
+ "std": [
88
+ 0.013360796496272087,
89
+ 0.013391095213592052
90
+ ],
91
+ "q01": [
92
+ -4.0135159069905056e-05,
93
+ -0.04032127052545548
94
+ ],
95
+ "q99": [
96
+ 0.04066328033804893,
97
+ -0.00040660659200511887
98
+ ]
99
+ },
100
+ "base_position": {
101
+ "min": [
102
+ 0.31250813603401184,
103
+ -5.100343704223633,
104
+ 0.6963803172111511
105
+ ],
106
+ "max": [
107
+ 5.601607322692871,
108
+ -0.4872598946094513,
109
+ 0.7495372295379639
110
+ ],
111
+ "mean": [
112
+ 2.5315651893615723,
113
+ -1.5020122528076172,
114
+ 0.7073471546173096
115
+ ],
116
+ "std": [
117
+ 1.4670116901397705,
118
+ 0.8559004664421082,
119
+ 0.006971539929508914
120
+ ],
121
+ "q01": [
122
+ 0.5000457167625427,
123
+ -4.100119590759277,
124
+ 0.6999446749687195
125
+ ],
126
+ "q99": [
127
+ 5.5999836921691895,
128
+ -0.778001925945282,
129
+ 0.7071865797042847
130
+ ]
131
+ },
132
+ "base_rotation": {
133
+ "min": [
134
+ 0.0,
135
+ 0.0,
136
+ -1.0,
137
+ 0.0
138
+ ],
139
+ "max": [
140
+ 0.0,
141
+ 0.0,
142
+ 1.0,
143
+ 1.0
144
+ ],
145
+ "mean": [
146
+ 0.0,
147
+ 0.0,
148
+ 0.2765239179134369,
149
+ 0.6414101719856262
150
+ ],
151
+ "std": [
152
+ 0.0,
153
+ 0.0,
154
+ 0.6192871332168579,
155
+ 0.35383468866348267
156
+ ],
157
+ "q01": [
158
+ 0.0,
159
+ 0.0,
160
+ -1.0,
161
+ 5.569559434661642e-06
162
+ ],
163
+ "q99": [
164
+ 0.0,
165
+ 0.0,
166
+ 1.0,
167
+ 1.0
168
+ ]
169
+ }
170
+ },
171
+ "action": {
172
+ "end_effector_position": {
173
+ "min": [
174
+ -1.0,
175
+ -1.0,
176
+ -1.0
177
+ ],
178
+ "max": [
179
+ 1.0,
180
+ 1.0,
181
+ 1.0
182
+ ],
183
+ "mean": [
184
+ 0.029150759801268578,
185
+ 0.007607606239616871,
186
+ -0.037477411329746246
187
+ ],
188
+ "std": [
189
+ 0.4175023138523102,
190
+ 0.41343387961387634,
191
+ 0.36864909529685974
192
+ ],
193
+ "q01": [
194
+ -1.0,
195
+ -1.0,
196
+ -1.0
197
+ ],
198
+ "q99": [
199
+ 1.0,
200
+ 1.0,
201
+ 1.0
202
+ ]
203
+ },
204
+ "end_effector_rotation": {
205
+ "min": [
206
+ -1.0,
207
+ -1.0,
208
+ -1.0
209
+ ],
210
+ "max": [
211
+ 1.0,
212
+ 1.0,
213
+ 1.0
214
+ ],
215
+ "mean": [
216
+ 0.007235987111926079,
217
+ -0.023321982473134995,
218
+ -0.0024119403678923845
219
+ ],
220
+ "std": [
221
+ 0.147710919380188,
222
+ 0.15399158000946045,
223
+ 0.13929523527622223
224
+ ],
225
+ "q01": [
226
+ -0.42321433901786804,
227
+ -0.5219977021217346,
228
+ -0.4101182746887207
229
+ ],
230
+ "q99": [
231
+ 0.47503985762596074,
232
+ 0.38744416117668146,
233
+ 0.4242807936668394
234
+ ]
235
+ },
236
+ "gripper_close": {
237
+ "min": [
238
+ 0.0
239
+ ],
240
+ "max": [
241
+ 1.0
242
+ ],
243
+ "mean": [
244
+ 0.34521719813346863
245
+ ],
246
+ "std": [
247
+ 0.47949448227882385
248
+ ],
249
+ "q01": [
250
+ 0.0
251
+ ],
252
+ "q99": [
253
+ 1.0
254
+ ]
255
+ },
256
+ "base_motion": {
257
+ "min": [
258
+ 0.0,
259
+ 0.0,
260
+ 0.0,
261
+ 0.0
262
+ ],
263
+ "max": [
264
+ 0.0,
265
+ 0.0,
266
+ 0.0,
267
+ 0.0
268
+ ],
269
+ "mean": [
270
+ 0.0,
271
+ 0.0,
272
+ 0.0,
273
+ 0.0
274
+ ],
275
+ "std": [
276
+ 0.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0
280
+ ],
281
+ "q01": [
282
+ 0.0,
283
+ 0.0,
284
+ 0.0,
285
+ 0.0
286
+ ],
287
+ "q99": [
288
+ 0.0,
289
+ 0.0,
290
+ 0.0,
291
+ 0.0
292
+ ]
293
+ },
294
+ "control_mode": {
295
+ "min": [
296
+ 0.0
297
+ ],
298
+ "max": [
299
+ 0.0
300
+ ],
301
+ "mean": [
302
+ 0.0
303
+ ],
304
+ "std": [
305
+ 0.0
306
+ ],
307
+ "q01": [
308
+ 0.0
309
+ ],
310
+ "q99": [
311
+ 0.0
312
+ ]
313
+ }
314
+ },
315
+ "relative_action": {}
316
+ }
317
+ }
encspatial/experiment_cfg/final_model_config.json ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "WAM_DIT4DIT",
3
+ "model_dtype": "bfloat16",
4
+ "backbone_type": "wan22_diffusers",
5
+ "wan_model_path": "Wan-AI/Wan2.2-TI2V-5B",
6
+ "wan_diffusers_model_path": "Wan-AI/Wan2.2-TI2V-5B-Diffusers",
7
+ "wan21_model_path": "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers",
8
+ "wan_tokenizer_model_id": "Wan-AI/Wan2.1-T2V-1.3B",
9
+ "wan_feature_extraction_layer": 18,
10
+ "cosmos_model_path": "nvidia/Cosmos-Predict2.5-2B",
11
+ "cosmos_model_revision": "diffusers/base/pre-trained",
12
+ "backbone_embedding_dim": 3072,
13
+ "num_frames_in": 25,
14
+ "num_frames_out": 25,
15
+ "frame_downsample_factor": 2,
16
+ "video_resolution": 256,
17
+ "feature_extraction_layer": 18,
18
+ "feature_extraction_aggregate_all": false,
19
+ "feature_extraction_aggregate_layer_window": 0,
20
+ "truncate_above_feature_extraction": false,
21
+ "vl_adapter_num_layers": 0,
22
+ "tune_layers_above_feature_extraction": true,
23
+ "n_tune_layers_below_feature_extraction": 0,
24
+ "tune_patch_embed": false,
25
+ "tune_time_embed": false,
26
+ "tune_crossattn_proj": false,
27
+ "freeze_modules_pattern": "text_encoder,vae,transformer",
28
+ "freeze_whole_backbone": false,
29
+ "fm_loss_weight": 1.0,
30
+ "action_loss_weight": 1.0,
31
+ "conditional_frame_timestep": 0.0001,
32
+ "history_obs_noise_timestep": 0.0,
33
+ "history_num_clean_frames": 1,
34
+ "selfflow_rep": false,
35
+ "selfflow_rep_layer": -1,
36
+ "selfflow_rep_layer_student": -1,
37
+ "selfflow_rep_layer_teacher": -1,
38
+ "selfflow_mask_ratio": 0.1,
39
+ "selfflow_ema_decay": 0.9999,
40
+ "selfflow_rep_weight": 0.8,
41
+ "selfflow_teacher_noise": 0.0,
42
+ "fadistill_teacher_traj": false,
43
+ "fadistill_target_tau": 1.0,
44
+ "fadistill_teacher_nstep": 0,
45
+ "wan_fadistill_teacher_shift": 5.0,
46
+ "wan_fadistill_single_step_index": -1,
47
+ "wan_fadistill_align_weight": 0.01,
48
+ "wan_fadistill_teacher_stepper": "euler",
49
+ "wan_fadistill_action_from_teacher": false,
50
+ "wan_fm_train_shift": 1.0,
51
+ "wan_text_pad_zero": false,
52
+ "nstep_agg": false,
53
+ "nstep_n": 2,
54
+ "nstep_query_len": 588,
55
+ "nstep_step_embed": true,
56
+ "nstep_agg_layers": 4,
57
+ "nstep_train_integration": false,
58
+ "nstep_noise_ensemble": false,
59
+ "nstep_base_residual": false,
60
+ "nstep_base_residual_gate": "layerscale",
61
+ "nstep_compress_query": false,
62
+ "nstep_compress_k": 64,
63
+ "nstep_compress_n_frame": 3,
64
+ "nstep_readout_exclude_step0": false,
65
+ "nstep_per_step_gated": false,
66
+ "nstep_step_dropout": false,
67
+ "nstep_residual_warmup": false,
68
+ "nstep_residual_warmup_start": 10000,
69
+ "nstep_residual_warmup_full": 20000,
70
+ "nstep_certainty_fusion": false,
71
+ "nstep_certainty_ckpt": "",
72
+ "nstep_certainty_tau": 1.0,
73
+ "nstep_certainty_drop_cond": false,
74
+ "nstep_certainty_arch": "mlp",
75
+ "nstep_certainty_hidden": 1024,
76
+ "nstep_certainty_layers": 2,
77
+ "nstep_certainty_decalib": false,
78
+ "nstep_certainty_step_bias": false,
79
+ "nstep_latent_cond": false,
80
+ "use_step_weight_fusion": false,
81
+ "step_weight_target_tau": 0.7,
82
+ "step_weight_sigmas": "0.995,0.9631,0.594,0.0099",
83
+ "step_weight_predictor_layers": 4,
84
+ "step_weight_predictor_heads": 16,
85
+ "step_weight_predictor_ckpt": "",
86
+ "freeze_step_weight_predictor": false,
87
+ "step_weight_exclude_current_tokens": false,
88
+ "multiview_layout": "tmosaic",
89
+ "fm_time_distribution": "uniform",
90
+ "fm_high_sigma_ratio": null,
91
+ "fm_high_sigma_min": 0.98,
92
+ "future_loss_type": "flow_matching",
93
+ "future_num_inference_steps": 1,
94
+ "use_noise_frames_in_extraction": true,
95
+ "use_meta_queries": false,
96
+ "n_meta_queries": 8,
97
+ "meta_queries_mode": "meta_only",
98
+ "use_meta_queries_in_fm": false,
99
+ "use_vlm_meta": false,
100
+ "use_vgln": false,
101
+ "tune_vgln": true,
102
+ "action_text_kv": false,
103
+ "state_dropout_prob": 0.0,
104
+ "state_additive_noise_scale": 0.0,
105
+ "training_mode": "ctxcomp",
106
+ "action_head_model_type": "dit",
107
+ "max_state_dim": 64,
108
+ "apply_sincos_state_encoding": false,
109
+ "video_train_crop": false,
110
+ "image_resize_backend": "cv2_linear",
111
+ "max_action_dim": 32,
112
+ "action_horizon": 16,
113
+ "num_past_action_steps": 24,
114
+ "hidden_size": 2560,
115
+ "input_embedding_dim": 768,
116
+ "repeated_diffusion_steps": 4,
117
+ "add_pos_embed": true,
118
+ "max_seq_len": 1024,
119
+ "attn_dropout": 0.2,
120
+ "action_dit_size": "DiT-B",
121
+ "diffusion_model_cfg": {
122
+ "attention_head_dim": 64,
123
+ "dropout": 0.2,
124
+ "final_dropout": true,
125
+ "interleave_self_attention": true,
126
+ "norm_type": "ada_norm",
127
+ "num_attention_heads": 12,
128
+ "num_layers": 16,
129
+ "output_dim": 2560,
130
+ "positional_embeddings": null
131
+ },
132
+ "num_inference_timesteps": 4,
133
+ "noise_beta_alpha": 1.5,
134
+ "noise_beta_beta": 1.0,
135
+ "noise_s": 0.999,
136
+ "num_timestep_buckets": 1000,
137
+ "tune_projector": true,
138
+ "tune_diffusion_model": true,
139
+ "max_num_embodiments": 36,
140
+ "new_embodiment_train_ratio": 0
141
+ }
encspatial/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c005114e5980ed52dfa97955e302b2dd210b4bc9f54d9ec1711542de4a34b0b
3
+ size 934210216
encspatial/processor_config.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "processor_class": "WAMDiT4DiTProcessor",
3
+ "downsampled_num_frames_in": 13,
4
+ "downsampled_num_frames_out": 13,
5
+ "emit_future_video": false,
6
+ "frame_downsample_factor": 2,
7
+ "max_state_dim": 64,
8
+ "max_action_dim": 32,
9
+ "max_action_horizon": 16,
10
+ "num_past_action_steps": 24,
11
+ "formalize_language": true,
12
+ "new_embodiment_train_ratio": 0,
13
+ "use_percentiles": false,
14
+ "clip_outliers": true,
15
+ "apply_sincos_state_encoding": false,
16
+ "video_train_crop": false,
17
+ "image_resize_backend": "cv2_linear",
18
+ "multiview_layout": "tmosaic",
19
+ "video_resolution": 256,
20
+ "use_relative_action": false,
21
+ "embodiment_id_mapping": {
22
+ "new_embodiment": 0,
23
+ "fractal20220817_data": 1,
24
+ "kuka": 2,
25
+ "bridge_orig": 3,
26
+ "taco_play": 4,
27
+ "jaco_play": 5,
28
+ "berkeley_cable_routing": 6,
29
+ "roboturk": 7,
30
+ "viola": 8,
31
+ "berkeley_autolab_ur5": 9,
32
+ "toto": 10,
33
+ "language_table": 11,
34
+ "stanford_hydra_dataset_converted_externally_to_rlds": 12,
35
+ "austin_buds_dataset_converted_externally_to_rlds": 13,
36
+ "nyu_franka_play_dataset_converted_externally_to_rlds": 14,
37
+ "furniture_bench_dataset_converted_externally_to_rlds": 15,
38
+ "ucsd_kitchen_dataset_converted_externally_to_rlds": 16,
39
+ "austin_sailor_dataset_converted_externally_to_rlds": 17,
40
+ "austin_sirius_dataset_converted_externally_to_rlds": 18,
41
+ "dlr_edan_shared_control_converted_externally_to_rlds": 19,
42
+ "iamlab_cmu_pickup_insert_converted_externally_to_rlds": 20,
43
+ "utaustin_mutex": 21,
44
+ "berkeley_fanuc_manipulation": 22,
45
+ "cmu_stretch": 23,
46
+ "bc_z": 24,
47
+ "fmb_dataset": 25,
48
+ "dobbe": 26,
49
+ "droid": 27,
50
+ "agibot_dexhand": 28,
51
+ "agibot_gripper": 29,
52
+ "galaxea": 30,
53
+ "humanoid_everyday_g1": 31,
54
+ "humanoid_everyday_h1": 32,
55
+ "action_net": 33,
56
+ "neural_gr1": 34,
57
+ "simulation_gr1": 35,
58
+ "libero_panda": 2
59
+ },
60
+ "use_vlm_meta": false,
61
+ "vlm_model_name": "huiwon/alinvlm_v1_3",
62
+ "vlm_backbone_model_type": "qwen3_vl",
63
+ "conversation_image_first": false,
64
+ "image_aug": true,
65
+ "image_aug_stronger": false
66
+ }
encspatial/statistics.json ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "new_embodiment": {
3
+ "state": {
4
+ "end_effector_position_relative": {
5
+ "min": [
6
+ -0.46594083309173584,
7
+ -0.8278615474700928,
8
+ 0.011948669329285622
9
+ ],
10
+ "max": [
11
+ 0.8734620809555054,
12
+ 0.8441421985626221,
13
+ 1.1348456144332886
14
+ ],
15
+ "mean": [
16
+ 0.266306072473526,
17
+ -0.04002884030342102,
18
+ 0.5537278652191162
19
+ ],
20
+ "std": [
21
+ 0.19139817357063293,
22
+ 0.2582354247570038,
23
+ 0.2461009919643402
24
+ ],
25
+ "q01": [
26
+ -0.251964715719223,
27
+ -0.6177875232696534,
28
+ 0.07541620314121246
29
+ ],
30
+ "q99": [
31
+ 0.736240336894989,
32
+ 0.6068667078018188,
33
+ 0.9772176861763
34
+ ]
35
+ },
36
+ "end_effector_rotation_relative": {
37
+ "min": [
38
+ -0.9999996423721313,
39
+ -0.9910850524902344,
40
+ -0.9571061134338379,
41
+ 6.351022108219695e-08
42
+ ],
43
+ "max": [
44
+ 0.9999980926513672,
45
+ 0.990567147731781,
46
+ 0.964046835899353,
47
+ 0.9740113019943237
48
+ ],
49
+ "mean": [
50
+ -0.14963096380233765,
51
+ 0.1248803362250328,
52
+ 0.0027880165725946426,
53
+ 0.2082664668560028
54
+ ],
55
+ "std": [
56
+ 0.7683019042015076,
57
+ 0.36296239495277405,
58
+ 0.37635329365730286,
59
+ 0.2322801947593689
60
+ ],
61
+ "q01": [
62
+ -0.9973158955574035,
63
+ -0.6837371301651001,
64
+ -0.7814695286750794,
65
+ 0.0013687612861394884
66
+ ],
67
+ "q99": [
68
+ 0.9957762026786804,
69
+ 0.8491807365417481,
70
+ 0.7687161755561829,
71
+ 0.802422981262207
72
+ ]
73
+ },
74
+ "gripper_qpos": {
75
+ "min": [
76
+ -0.027591193094849586,
77
+ -0.05319468677043915
78
+ ],
79
+ "max": [
80
+ 0.07896614819765091,
81
+ 0.10181591659784317
82
+ ],
83
+ "mean": [
84
+ 0.030854083597660065,
85
+ -0.03072655387222767
86
+ ],
87
+ "std": [
88
+ 0.013360796496272087,
89
+ 0.013391095213592052
90
+ ],
91
+ "q01": [
92
+ -4.0135159069905056e-05,
93
+ -0.04032127052545548
94
+ ],
95
+ "q99": [
96
+ 0.04066328033804893,
97
+ -0.00040660659200511887
98
+ ]
99
+ },
100
+ "base_position": {
101
+ "min": [
102
+ 0.31250813603401184,
103
+ -5.100343704223633,
104
+ 0.6963803172111511
105
+ ],
106
+ "max": [
107
+ 5.601607322692871,
108
+ -0.4872598946094513,
109
+ 0.7495372295379639
110
+ ],
111
+ "mean": [
112
+ 2.5315651893615723,
113
+ -1.5020122528076172,
114
+ 0.7073471546173096
115
+ ],
116
+ "std": [
117
+ 1.4670116901397705,
118
+ 0.8559004664421082,
119
+ 0.006971539929508914
120
+ ],
121
+ "q01": [
122
+ 0.5000457167625427,
123
+ -4.100119590759277,
124
+ 0.6999446749687195
125
+ ],
126
+ "q99": [
127
+ 5.5999836921691895,
128
+ -0.778001925945282,
129
+ 0.7071865797042847
130
+ ]
131
+ },
132
+ "base_rotation": {
133
+ "min": [
134
+ 0.0,
135
+ 0.0,
136
+ -1.0,
137
+ 0.0
138
+ ],
139
+ "max": [
140
+ 0.0,
141
+ 0.0,
142
+ 1.0,
143
+ 1.0
144
+ ],
145
+ "mean": [
146
+ 0.0,
147
+ 0.0,
148
+ 0.2765239179134369,
149
+ 0.6414101719856262
150
+ ],
151
+ "std": [
152
+ 0.0,
153
+ 0.0,
154
+ 0.6192871332168579,
155
+ 0.35383468866348267
156
+ ],
157
+ "q01": [
158
+ 0.0,
159
+ 0.0,
160
+ -1.0,
161
+ 5.569559434661642e-06
162
+ ],
163
+ "q99": [
164
+ 0.0,
165
+ 0.0,
166
+ 1.0,
167
+ 1.0
168
+ ]
169
+ }
170
+ },
171
+ "action": {
172
+ "end_effector_position": {
173
+ "min": [
174
+ -1.0,
175
+ -1.0,
176
+ -1.0
177
+ ],
178
+ "max": [
179
+ 1.0,
180
+ 1.0,
181
+ 1.0
182
+ ],
183
+ "mean": [
184
+ 0.029150759801268578,
185
+ 0.007607606239616871,
186
+ -0.037477411329746246
187
+ ],
188
+ "std": [
189
+ 0.4175023138523102,
190
+ 0.41343387961387634,
191
+ 0.36864909529685974
192
+ ],
193
+ "q01": [
194
+ -1.0,
195
+ -1.0,
196
+ -1.0
197
+ ],
198
+ "q99": [
199
+ 1.0,
200
+ 1.0,
201
+ 1.0
202
+ ]
203
+ },
204
+ "end_effector_rotation": {
205
+ "min": [
206
+ -1.0,
207
+ -1.0,
208
+ -1.0
209
+ ],
210
+ "max": [
211
+ 1.0,
212
+ 1.0,
213
+ 1.0
214
+ ],
215
+ "mean": [
216
+ 0.007235987111926079,
217
+ -0.023321982473134995,
218
+ -0.0024119403678923845
219
+ ],
220
+ "std": [
221
+ 0.147710919380188,
222
+ 0.15399158000946045,
223
+ 0.13929523527622223
224
+ ],
225
+ "q01": [
226
+ -0.42321433901786804,
227
+ -0.5219977021217346,
228
+ -0.4101182746887207
229
+ ],
230
+ "q99": [
231
+ 0.47503985762596074,
232
+ 0.38744416117668146,
233
+ 0.4242807936668394
234
+ ]
235
+ },
236
+ "gripper_close": {
237
+ "min": [
238
+ 0.0
239
+ ],
240
+ "max": [
241
+ 1.0
242
+ ],
243
+ "mean": [
244
+ 0.34521719813346863
245
+ ],
246
+ "std": [
247
+ 0.47949448227882385
248
+ ],
249
+ "q01": [
250
+ 0.0
251
+ ],
252
+ "q99": [
253
+ 1.0
254
+ ]
255
+ },
256
+ "base_motion": {
257
+ "min": [
258
+ 0.0,
259
+ 0.0,
260
+ 0.0,
261
+ 0.0
262
+ ],
263
+ "max": [
264
+ 0.0,
265
+ 0.0,
266
+ 0.0,
267
+ 0.0
268
+ ],
269
+ "mean": [
270
+ 0.0,
271
+ 0.0,
272
+ 0.0,
273
+ 0.0
274
+ ],
275
+ "std": [
276
+ 0.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0
280
+ ],
281
+ "q01": [
282
+ 0.0,
283
+ 0.0,
284
+ 0.0,
285
+ 0.0
286
+ ],
287
+ "q99": [
288
+ 0.0,
289
+ 0.0,
290
+ 0.0,
291
+ 0.0
292
+ ]
293
+ },
294
+ "control_mode": {
295
+ "min": [
296
+ 0.0
297
+ ],
298
+ "max": [
299
+ 0.0
300
+ ],
301
+ "mean": [
302
+ 0.0
303
+ ],
304
+ "std": [
305
+ 0.0
306
+ ],
307
+ "q01": [
308
+ 0.0
309
+ ],
310
+ "q99": [
311
+ 0.0
312
+ ]
313
+ }
314
+ },
315
+ "relative_action": {}
316
+ }
317
+ }
encspatial/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
encspatial/wandb_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"project": "wam-dit4dit-robocasa-ctxcomp-stage1", "run_id": "ctxcomp_s1_encspatial_T4_mdim192_attn"}
encspatial/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 ZERO_STAGE not in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info("Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info("Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)