spatialencoder_full / README.md
qicq1c's picture
Fix Hyperism shard extraction target
f642c0e verified
|
Raw
History Blame Contribute Delete
8.02 kB
# spatialencoder_full
Full SpatialEncoder training dataset prepared on 2026-05-25.
The original relative file layout under the local data root is preserved. Manifests and preparation stats are stored under `metadata/spatialencoder_full_20260525/`.
Training items:
- CA-1M: 2966
- hyperism: 560
- ADT: 64
- Manifest entries: 391760
- Logical size excluding directory entries: 2044.28 GiB
- Directory entries: 64
## Goal
This dataset is intended to become the `BOX_DATA_PATH` / `BOX_DATA_VAL_PATH` input tree used by SpatialEncoder training.
After preparation, the training code should see:
```text
${BOX_DATA_PATH}/
├── CA-1M/
│ ├── train/
│ │ └── ca1m-train-<video_id>.tar
│ ├── val/
│ │ └── ca1m-val-<video_id>.tar
│ └── val-unzip/
├── hyperism/
│ └── hyperism/
├── aria_digital_twin/
│ └── ADT/
├── pickle/
│ └── CA-1M/
│ └── *train*.pkl
├── BoxFromMotion/
│ └── dataset/
│ ├── CA-1M.json
│ ├── hyperism.json
│ └── ADT.json
├── json_wo_pose/
└── val-json/
```
Use:
```bash
export BOX_DATA_PATH=/path/to/spatialencoder_full
export BOX_DATA_VAL_PATH=/path/to/spatialencoder_full/BoxFromMotion/dataset
```
## 1. Download
Install the Hugging Face CLI if needed:
```bash
pip install -U "huggingface_hub[cli]"
```
Download the dataset while preserving repository paths. The expanded ADT and Hyperism frame trees are not stored directly in the repository; download the archive shards and restore them locally.
- ADT archives: `aria_digital_twin/ADT_tars/*.tar`
- Hyperism archives: `hyperism_required_shards/*.tar`
```bash
DATA_ROOT=/mnt/nvme6/jieneng/data/spatialencoder_full
mkdir -p "$DATA_ROOT"
hf download qicq1c/spatialencoder_full \
--type dataset \
--local-dir "$DATA_ROOT" \
--exclude "aria_digital_twin/ADT/**" \
--exclude "hyperism/hyperism/unzip/**"
```
The ADT tar archives are about 405 GiB. After extraction, `aria_digital_twin/ADT/` is about 406 GiB. The Hyperism tar shards are about 35.6 GiB. Keep the archives and expanded trees if you want the download to be resumable and reproducible.
## 2. Restore ADT From Tar Archives
Restore the ADT frame tree from the downloaded tar archives:
```bash
cd "$DATA_ROOT"
mkdir -p aria_digital_twin/ADT
for tar_file in aria_digital_twin/ADT_tars/*.tar; do
tar --skip-old-files -xf "$tar_file" -C aria_digital_twin/ADT
done
```
This recreates paths such as:
```text
aria_digital_twin/ADT/Apartment_release_clean_seq131_M1292/depth_frames/...
aria_digital_twin/ADT/Apartment_release_clean_seq131_M1292/rgb_frames/...
```
## 3. Restore Hyperism From Tar Shards
Restore the Hyperism frame tree from the downloaded tar shards:
```bash
cd "$DATA_ROOT"
mkdir -p hyperism
for shard in hyperism_required_shards/*.tar; do
tar --skip-old-files -xf "$shard" -C hyperism
done
```
This recreates paths such as:
```text
hyperism/hyperism/unzip/ai_001_001/...
hyperism/hyperism/unzip/ai_001_002/...
```
## 4. Expand Packed Add-Ons If Present
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:
```bash
cd "$DATA_ROOT"
for z in pickle.zip hyperism-train-json.zip hyperism-val-json.zip; do
if [ -f "$z" ]; then
unzip -o "$z" -d "$DATA_ROOT"
fi
done
```
Skip this step for files that are already expanded in the final tree.
## 5. Check Required Files
Run these checks before training:
```bash
export BOX_DATA_PATH="$DATA_ROOT"
export BOX_DATA_VAL_PATH="$DATA_ROOT/BoxFromMotion/dataset"
test -d "$BOX_DATA_PATH/CA-1M/train"
test -d "$BOX_DATA_PATH/CA-1M/val"
test -d "$BOX_DATA_PATH/pickle/CA-1M"
test -d "$BOX_DATA_PATH/hyperism/hyperism"
test -d "$BOX_DATA_PATH/aria_digital_twin/ADT"
test -f "$BOX_DATA_VAL_PATH/CA-1M.json"
test -f "$BOX_DATA_VAL_PATH/hyperism.json"
test -f "$BOX_DATA_VAL_PATH/ADT.json"
find "$BOX_DATA_PATH/CA-1M/train" -name 'ca1m-train-*.tar' | wc -l
find "$BOX_DATA_PATH/pickle/CA-1M" -name '*train*.pkl' | wc -l
```
Expected minimum result:
- `CA-1M/train` contains many `ca1m-train-*.tar` files.
- `pickle/CA-1M` contains CA-1M iterable training metadata.
- `BoxFromMotion/dataset/{CA-1M,hyperism,ADT}.json` exist.
- Hyperism and ADT frame paths referenced by the json files exist under `BOX_DATA_PATH`.
## 6. Set Training Environment
From the SpatialEncoder code checkout:
```bash
cd /path/to/SpatialEncoder
export BOX_DATA_PATH=/path/to/spatialencoder_full
export BOX_DATA_VAL_PATH=/path/to/spatialencoder_full/BoxFromMotion/dataset
export BOX_WEIGHTS_PATH=/path/to/training_output
export SAM3_CHECKPOINT=$BOX_WEIGHTS_PATH/sam3.1_multiplex.pt
export PYTORCH_ALLOC_CONF=expandable_segments:True
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
export NCCL_DEBUG=WARN
export TORCH_NCCL_BLOCKING_WAIT=1
```
Download the SAM 3.1 checkpoint separately into `BOX_WEIGHTS_PATH`:
```bash
wget -P "$BOX_WEIGHTS_PATH" \
--header="Authorization: Bearer YOUR_HF_TOKEN" \
https://huggingface.co/facebook/sam3.1/resolve/main/sam3.1_multiplex.pt
```
## 7. Dataset Smoke Tests
The merged training config samples datasets according to:
```text
trainer.data.train.dataset.weights = [CA-1M, hyperism, ADT]
```
Before starting a long run, verify each dataset can print loss:
```bash
# CA-1M only
trainer.data.train.dataset.weights='[1,0,0]'
# Hyperism only
trainer.data.train.dataset.weights='[0,1,0]'
# ADT only
trainer.data.train.dataset.weights='[0,0,1]'
```
Example 8-GPU smoke command:
```bash
RUN_NAME=SpatialEncoder_smoke_$(date +%Y%m%d_%H%M%S)
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 env -u LD_LIBRARY_PATH python sam3/train/train.py \
-c configs/depth/train_merged_iterable_da3_best_memory_extras_lowmem_actckpt_fa3.yaml \
--use-cluster 0 \
--num-gpus 8 \
paths.experiment_log_dir="$BOX_WEIGHTS_PATH/Exps/$RUN_NAME" \
trainer.model.use_fa3=true \
trainer.distributed.gradient_as_bucket_view=false \
trainer.data.train.dataset.weights='[0,1,0]' \
trainer.logging.log_freq=1 \
trainer.logging.log_scalar_frequency=1
```
It is ready if the log reaches lines like:
```text
Train Epoch: [0][ 0/...] ... Losses/train_all_loss: ...
```
The first batch can be slow because workers are filling caches. Later steps should have near-zero `Data Time`.
## 8. Mixed Training
Once all three single-dataset smoke tests print loss, launch the mixed run:
```bash
RUN_NAME=SpatialEncoder_mixed_8gpu_$(date +%Y%m%d_%H%M%S)
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 env -u LD_LIBRARY_PATH python sam3/train/train.py \
-c configs/depth/train_merged_iterable_da3_best_memory_extras_lowmem_actckpt_fa3.yaml \
--use-cluster 0 \
--num-gpus 8 \
paths.experiment_log_dir="$BOX_WEIGHTS_PATH/Exps/$RUN_NAME" \
trainer.model.use_fa3=true \
trainer.distributed.gradient_as_bucket_view=false \
trainer.data.train.dataset.weights='[0.4,0.2,0.4]' \
trainer.logging.log_freq=1 \
trainer.logging.log_scalar_frequency=1
```
For quick debugging on slow storage, temporarily add:
```bash
scratch.num_train_workers=2
```
For the default full setting, omit that override; the config uses `scratch.num_train_workers=16`.
## Troubleshooting
- 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.
- If only one dataset fails, rerun with the corresponding one-hot weight to isolate missing files.
- 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.
- If a run is interrupted, kill the whole process group and confirm GPUs are free with:
```bash
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader,nounits
```