qicq1c commited on
Commit
c53b397
·
verified ·
1 Parent(s): c865295

Update training-ready data preparation steps

Browse files
Files changed (1) hide show
  1. README.md +230 -0
README.md CHANGED
@@ -12,3 +12,233 @@ Training items:
12
  - Manifest entries: 391760
13
  - Logical size excluding directory entries: 2044.28 GiB
14
  - Directory entries: 64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  - Manifest entries: 391760
13
  - Logical size excluding directory entries: 2044.28 GiB
14
  - Directory entries: 64
15
+
16
+ ## Goal
17
+
18
+ This dataset is intended to become the `BOX_DATA_PATH` / `BOX_DATA_VAL_PATH` input tree used by SpatialEncoder training.
19
+
20
+ After preparation, the training code should see:
21
+
22
+ ```text
23
+ ${BOX_DATA_PATH}/
24
+ ├── CA-1M/
25
+ │ ├── train/
26
+ │ │ └── ca1m-train-<video_id>.tar
27
+ │ ├── val/
28
+ │ │ └── ca1m-val-<video_id>.tar
29
+ │ └── val-unzip/
30
+ ├── hyperism/
31
+ │ └── hyperism/
32
+ ├── aria_digital_twin/
33
+ │ └── ADT/
34
+ ├── pickle/
35
+ │ └── CA-1M/
36
+ │ └── *train*.pkl
37
+ ├── BoxFromMotion/
38
+ │ └── dataset/
39
+ │ ├── CA-1M.json
40
+ │ ├── hyperism.json
41
+ │ └── ADT.json
42
+ ├── json_wo_pose/
43
+ └── val-json/
44
+ ```
45
+
46
+ Use:
47
+
48
+ ```bash
49
+ export BOX_DATA_PATH=/path/to/spatialencoder_full
50
+ export BOX_DATA_VAL_PATH=/path/to/spatialencoder_full/BoxFromMotion/dataset
51
+ ```
52
+
53
+ ## 1. Download
54
+
55
+ Install the Hugging Face CLI if needed:
56
+
57
+ ```bash
58
+ pip install -U "huggingface_hub[cli]"
59
+ ```
60
+
61
+ Download the dataset while preserving repository paths:
62
+
63
+ ```bash
64
+ DATA_ROOT=/mnt/nvme6/jieneng/data/spatialencoder_full
65
+ mkdir -p "$DATA_ROOT"
66
+
67
+ huggingface-cli download qicq1c/spatialencoder_full \
68
+ --repo-type dataset \
69
+ --local-dir "$DATA_ROOT" \
70
+ --local-dir-use-symlinks False
71
+ ```
72
+
73
+ The full dataset is about 2 TiB, so make sure the target filesystem has enough space before starting.
74
+
75
+ ## 2. Expand Packed Add-Ons If Present
76
+
77
+ If the download contains archive files such as `pickle.zip`, `hyperism-train-json.zip`, or `hyperism-val-json.zip`, unzip them at the data root:
78
+
79
+ ```bash
80
+ cd "$DATA_ROOT"
81
+
82
+ for z in pickle.zip hyperism-train-json.zip hyperism-val-json.zip; do
83
+ if [ -f "$z" ]; then
84
+ unzip -o "$z" -d "$DATA_ROOT"
85
+ fi
86
+ done
87
+ ```
88
+
89
+ If the download contains `hyperism_required_shards/*.tar`, expand those shards into the Hyperism frame directory:
90
+
91
+ ```bash
92
+ mkdir -p "$DATA_ROOT/hyperism/hyperism/unzip"
93
+
94
+ if [ -d "$DATA_ROOT/hyperism_required_shards" ]; then
95
+ for shard in "$DATA_ROOT"/hyperism_required_shards/*.tar; do
96
+ tar -xf "$shard" -C "$DATA_ROOT/hyperism/hyperism/unzip"
97
+ done
98
+ fi
99
+ ```
100
+
101
+ Skip this step for files that are already expanded in the final tree.
102
+
103
+ ## 3. Check Required Files
104
+
105
+ Run these checks before training:
106
+
107
+ ```bash
108
+ export BOX_DATA_PATH="$DATA_ROOT"
109
+ export BOX_DATA_VAL_PATH="$DATA_ROOT/BoxFromMotion/dataset"
110
+
111
+ test -d "$BOX_DATA_PATH/CA-1M/train"
112
+ test -d "$BOX_DATA_PATH/CA-1M/val"
113
+ test -d "$BOX_DATA_PATH/pickle/CA-1M"
114
+ test -d "$BOX_DATA_PATH/hyperism/hyperism"
115
+ test -d "$BOX_DATA_PATH/aria_digital_twin/ADT"
116
+
117
+ test -f "$BOX_DATA_VAL_PATH/CA-1M.json"
118
+ test -f "$BOX_DATA_VAL_PATH/hyperism.json"
119
+ test -f "$BOX_DATA_VAL_PATH/ADT.json"
120
+
121
+ find "$BOX_DATA_PATH/CA-1M/train" -name 'ca1m-train-*.tar' | wc -l
122
+ find "$BOX_DATA_PATH/pickle/CA-1M" -name '*train*.pkl' | wc -l
123
+ ```
124
+
125
+ Expected minimum result:
126
+
127
+ - `CA-1M/train` contains many `ca1m-train-*.tar` files.
128
+ - `pickle/CA-1M` contains CA-1M iterable training metadata.
129
+ - `BoxFromMotion/dataset/{CA-1M,hyperism,ADT}.json` exist.
130
+ - Hyperism and ADT frame paths referenced by the json files exist under `BOX_DATA_PATH`.
131
+
132
+ ## 4. Set Training Environment
133
+
134
+ From the SpatialEncoder code checkout:
135
+
136
+ ```bash
137
+ cd /path/to/SpatialEncoder
138
+
139
+ export BOX_DATA_PATH=/path/to/spatialencoder_full
140
+ export BOX_DATA_VAL_PATH=/path/to/spatialencoder_full/BoxFromMotion/dataset
141
+ export BOX_WEIGHTS_PATH=/path/to/training_output
142
+ export SAM3_CHECKPOINT=$BOX_WEIGHTS_PATH/sam3.1_multiplex.pt
143
+
144
+ export PYTORCH_ALLOC_CONF=expandable_segments:True
145
+ export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
146
+ export OMP_NUM_THREADS=1
147
+ export MKL_NUM_THREADS=1
148
+ export OPENBLAS_NUM_THREADS=1
149
+ export NUMEXPR_NUM_THREADS=1
150
+ export NCCL_DEBUG=WARN
151
+ export TORCH_NCCL_BLOCKING_WAIT=1
152
+ ```
153
+
154
+ Download the SAM 3.1 checkpoint separately into `BOX_WEIGHTS_PATH`:
155
+
156
+ ```bash
157
+ wget -P "$BOX_WEIGHTS_PATH" \
158
+ --header="Authorization: Bearer YOUR_HF_TOKEN" \
159
+ https://huggingface.co/facebook/sam3.1/resolve/main/sam3.1_multiplex.pt
160
+ ```
161
+
162
+ ## 5. Dataset Smoke Tests
163
+
164
+ The merged training config samples datasets according to:
165
+
166
+ ```text
167
+ trainer.data.train.dataset.weights = [CA-1M, hyperism, ADT]
168
+ ```
169
+
170
+ Before starting a long run, verify each dataset can print loss:
171
+
172
+ ```bash
173
+ # CA-1M only
174
+ trainer.data.train.dataset.weights='[1,0,0]'
175
+
176
+ # Hyperism only
177
+ trainer.data.train.dataset.weights='[0,1,0]'
178
+
179
+ # ADT only
180
+ trainer.data.train.dataset.weights='[0,0,1]'
181
+ ```
182
+
183
+ Example 8-GPU smoke command:
184
+
185
+ ```bash
186
+ RUN_NAME=SpatialEncoder_smoke_$(date +%Y%m%d_%H%M%S)
187
+
188
+ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 env -u LD_LIBRARY_PATH python sam3/train/train.py \
189
+ -c configs/depth/train_merged_iterable_da3_best_memory_extras_lowmem_actckpt_fa3.yaml \
190
+ --use-cluster 0 \
191
+ --num-gpus 8 \
192
+ paths.experiment_log_dir="$BOX_WEIGHTS_PATH/Exps/$RUN_NAME" \
193
+ trainer.model.use_fa3=true \
194
+ trainer.distributed.gradient_as_bucket_view=false \
195
+ trainer.data.train.dataset.weights='[0,1,0]' \
196
+ trainer.logging.log_freq=1 \
197
+ trainer.logging.log_scalar_frequency=1
198
+ ```
199
+
200
+ It is ready if the log reaches lines like:
201
+
202
+ ```text
203
+ Train Epoch: [0][ 0/...] ... Losses/train_all_loss: ...
204
+ ```
205
+
206
+ The first batch can be slow because workers are filling caches. Later steps should have near-zero `Data Time`.
207
+
208
+ ## 6. Mixed Training
209
+
210
+ Once all three single-dataset smoke tests print loss, launch the mixed run:
211
+
212
+ ```bash
213
+ RUN_NAME=SpatialEncoder_mixed_8gpu_$(date +%Y%m%d_%H%M%S)
214
+
215
+ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 env -u LD_LIBRARY_PATH python sam3/train/train.py \
216
+ -c configs/depth/train_merged_iterable_da3_best_memory_extras_lowmem_actckpt_fa3.yaml \
217
+ --use-cluster 0 \
218
+ --num-gpus 8 \
219
+ paths.experiment_log_dir="$BOX_WEIGHTS_PATH/Exps/$RUN_NAME" \
220
+ trainer.model.use_fa3=true \
221
+ trainer.distributed.gradient_as_bucket_view=false \
222
+ trainer.data.train.dataset.weights='[0.4,0.2,0.4]' \
223
+ trainer.logging.log_freq=1 \
224
+ trainer.logging.log_scalar_frequency=1
225
+ ```
226
+
227
+ For quick debugging on slow storage, temporarily add:
228
+
229
+ ```bash
230
+ scratch.num_train_workers=2
231
+ ```
232
+
233
+ For the default full setting, omit that override; the config uses `scratch.num_train_workers=16`.
234
+
235
+ ## Troubleshooting
236
+
237
+ - If training appears stuck before the first loss, check whether dataloader workers are still starting. With `num_train_workers=16`, the first batch can take around 1-2 minutes on large mixed data.
238
+ - If only one dataset fails, rerun with the corresponding one-hot weight to isolate missing files.
239
+ - If `use_fa3=true` fails at import or CUDA runtime, retry with `trainer.model.use_fa3=false` to separate data issues from FA3 compatibility issues.
240
+ - If a run is interrupted, kill the whole process group and confirm GPUs are free with:
241
+
242
+ ```bash
243
+ nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader,nounits
244
+ ```