dagger / code /1028_run /README.md
yqi19's picture
add 1031 yu_parts tasks: plug1ramp / battery2 / eraser1 (collectors + assets in 1027_sim_tasks, yp_task_1031.sh + jobs in code/1028_run, sample videos)
9213391 verified
|
Raw History Blame Contribute Delete
8.9 kB

UR5 Sim2Real: Data Collection & Diffusion Policy Training

This repo contains the scripts used to collect simulation demonstrations and train Diffusion Policy (DP) checkpoints for 6 robot manipulation tasks on NVIDIA L40s cluster nodes, as part of the UR5 sim2real pipeline.

Overview

Task Demos DP Checkpoint Notes
battery_v1 50 1027_sim_ckpt/battery_v1/latest.ckpt βœ…
ring_v1 50 1027_sim_ckpt/ring_v1/latest.ckpt βœ…
package_d5_v1 50 1027_sim_ckpt/package_d5_v1/latest.ckpt βœ…
ringpeg_dart_v1 100 1027_sim_ckpt/ringpeg_dart_v1/latest.ckpt βœ…
blb_v1 47 1027_sim_ckpt/blb_v1/latest.ckpt βœ… (47 due to GPU crash)
plug_v1 50 1027_sim_ckpt/plug_v1/latest.ckpt βœ…
toaster_lever β€” β€” ❌ Skipped: USD crashes Isaac Sim 5
plug1ramp_v1 50 (to collect) β€” πŸ†• 2026-10-31, yp_task_1031.sh
battery2_v1 50 (to collect) β€” πŸ†• 2026-10-31, yp_task_1031.sh
eraser1_v1 50 (to collect) β€” πŸ†• 2026-10-31, yp_task_1031.sh

Demo zarr + collect_meta are in 1027_sim_demo/<task>/ on HuggingFace yqi19/dagger.


Repository Layout

1027_run/                   # Original run (2x parallel collection)
  tasks/
    yp_task.sh              # battery / ring / plug collect + train
    package_d5.sh           # package_d5 collect + train
    bread_lever_bowl.sh     # bread_lever_bowl collect + train
    ringpeg.sh              # ringpeg collect + train
    yp_train_only.sh        # train-only (after manual merge)
    package_d5_train.sh     # package_d5 train-only
  jobs/                     # Slurm sbatch wrappers
  merge_shards.py           # merge N shard dirs into one output dir
  upload_results.sh         # HuggingFace upload script

1028_run/                   # Speedup run (4x parallel collection + AMP training)
  tasks/
    yp_task.sh              # battery / ring / plug β€” 4x parallel
    yp_task_1031.sh         # plug1ramp / battery2 / eraser1 β€” 4x parallel (2026-10-31)
    package_d5.sh
    bread_lever_bowl.sh
    ringpeg.sh
  jobs/                     # Slurm sbatch wrappers
  merge_shards.py

Code lives at:

/lustre/fsw/portfolios/nvr/users/jtremblay/yu/1027_sim_tasks/share_v5_sim2real_20260929/code/
  ur5_lab_code/             # DP training (Hydra/PyTorch)
  ur5_import/               # sim collect utils, build_scene, pack_zarr
  sim_data/                 # symlinks to per-task data dirs
  train_runs/               # training output dirs (checkpoints)

Environment

Two conda envs on Lustre (/lustre/fsw/portfolios/nvr/users/jtremblay/yu/miniconda3/):

Env Purpose
simfoundry Isaac Sim 5 + OmniGibson (data collection)
ur5dp PyTorch + Diffusion Policy (training)

Container: robolab-isaacsim5.sqsh (Isaac Sim 5, CUDA 12.8).

Key env vars for collection

OMNIGIBSON_HEADLESS=1
OMNI_KIT_ACCEPT_EULA=YES
OMNIGIBSON_RENDER_VIEWER_CAMERA=0
OMNIGIBSON_DATA_PATH=.../BEHAVIOR-1K/datasets
OMNIGIBSON_GPU_ID=<0|1|2|3>   # physical GPU index (do NOT set CUDA_VISIBLE_DEVICES)
TORCH_COMPILE_DISABLE=1
TORCHDYNAMO_DISABLE=1

Data Collection

Camera quality

Cameras render at native resolution from ur5_import/cfg/scene_real.yaml:

  • cam0 (RealSense D455): 1280Γ—720, 10 fps
  • cam1 (FLIR Blackfly): 1440Γ—1080, 10 fps

Videos encoded with libx264 yuv420p via imageio/ffmpeg. Training crops both to 224Γ—224.

4x parallel collection does not affect render quality: each process gets its own Isaac Sim instance on a dedicated physical GPU (OMNIGIBSON_GPU_ID=0/1/2/3). Vulkan renderer + PhysX are both pinned to the same physical GPU.

Per-task collect scripts

All tasks follow the same pattern: N parallel Isaac Sim processes β†’ merge shards β†’ pack zarr β†’ train.

sbatch 1028_run/jobs/battery_job.sh
sbatch 1028_run/jobs/ring_job.sh
sbatch 1028_run/jobs/plug_job.sh
sbatch 1028_run/jobs/package_d5_job.sh
sbatch 1028_run/jobs/bread_lever_bowl_job.sh
sbatch 1028_run/jobs/ringpeg_job.sh
sbatch 1028_run/jobs/plug1ramp_job.sh     # 2026-10-31 tasks, see below
sbatch 1028_run/jobs/battery2_job.sh
sbatch 1028_run/jobs/eraser1_job.sh

2026-10-31 tasks (yp_task_1031.sh)

Same pipeline and settings as yp_task.sh (4 shards on GPU 0-3, seeds 200-599, max-kept 15/15/15/20, --dart --start-offset, merge -> pack_zarr -> AMP training, 130 epochs). Only the collector script differs:

TASK= Script Task Smoke test (yu_workstation, no video) Time per demo (with video, RTX 4090)
plug1ramp yp_plugrack.py --task plug1ramp white plug from the grey ramp -> rotate wrist 45Β° -> into the outlet 12/12 ~200 s
battery2 yp_battery2.py black battery -> grey holder, then white battery -> white holder 12/12 ~320 s
eraser1 yp_eraser.py pick the eraser, wipe two black marker lines and fine stains off the fixed whiteboard (3 lanes), put the eraser back 12/12 ~350 s

Setup (once): extract 1027_sim_tasks/tasks/yu_parts_tasks_1031.tar.gz into $TASKS (= .../yu/1027_sim_tasks). It only adds files to yu_parts_tasks/ (the shared scripts are byte-identical to the 10-27 package) and brings the new objects in yu_parts_tasks/object_assets/objects/ (grey_plug_ramp_test, white_plug_ramp_test, white_board, blue_eraser); yp_task_1031.sh links them into yu-assets and stops with an error if they are missing. Train-only reruns: jobs/<task>_train_job.sh (uses train_only.sh, NAME=<task>_v1).

The eraser1 stains are a dynamic texture on the board face material (omni.ui.DynamicTextureProvider); the extra npz key ink_left is the stain fraction left per step. Details for all three tasks: README_1031.md inside the package. Example episodes (seed 0, cam0 | cam1): 1027_smoke_video/1031/.

Shard merge

python3 merge_shards.py shard_a/ shard_b/ shard_c/ shard_d/ final_dir/ 50

Merges episode npz + videos, renumbers indices, writes collect_meta.json.


Training

Config

  • Config: train_baseline_diffusion_unet + task=sim_baseline
  • Policy: DiffusionUnetBaselineAugPolicy
  • 130 epochs, checkpoint_every=129 β†’ saves latest.ckpt at end
  • Cam augmentation: cam1 dropout 0.1, aug_p 0.5, erase_p 0.3, cam0 aug_p 0.3

Speed comparison

Setting it/s Batches/epoch Time for 130 epochs
1027_run: batch=64, workers=4, FP32 ~1.1 324 ~10h
1028_run: batch=256, workers=16, AMP (FP16) ~2.5 39 ~78 min

Measured speedup: 7.7Γ— on training (tested on battery_v1, L40s GPU).

Speedup sources:

  1. batch_size 64β†’256: 4Γ— fewer batches per epoch
  2. AMP mixed precision (+training.use_amp=True): FP16 forward/backward via torch.cuda.amp.GradScaler + autocast, ~2Γ— throughput on L40s tensor cores
  3. num_workers 4β†’16: parallel zarr.zip cache loading

AMP is patched into train_equi_workspace.py. Disable with +training.use_amp=False.

Collection speedup

Setting Total collect time (50 demos)
1027_run: 2x parallel (GPU 0+2) ~5–8h
1028_run: 4x parallel (GPU 0/1/2/3) ~2.5h

Measured: battery_v1 50 demos in 2h 26min (4x parallel, 15+15+15+20 shards).

270s per demo Γ— 50 demos / 4 GPUs = ~56 min minimum. With Isaac Sim init overhead (3 min/proc Γ— 4 staggered) total ~2.5h.


Known Issues

Isaac Sim GPU crash (RenderGraph Error)

After ~3–4h / ~18 demos per process, Isaac Sim hits GPU memory leak. Solution: collect in short shards (max-kept=15–20), then merge.

toaster_lever skipped

black_toaster_lever USD crashes add_reference_to_stage at the C++ layer in Isaac Sim 5. Not fixable without USD rebuild.

OmniGibson vision_sensor patch

vision_sensor.py _remove_modality_from_backend raises TypeError during multi-episode teardown. Fix: wrap detach() in try/except (TypeError, AttributeError).

OMNIGIBSON_GPU_ID vs CUDA_VISIBLE_DEVICES

Isaac Sim uses OMNIGIBSON_GPU_ID for both Vulkan rendering (active_gpu) and PhysX CUDA (physics_gpu). Do not combine with CUDA_VISIBLE_DEVICES β€” it causes PhysX to request an invalid device ordinal.


HuggingFace Upload

Dataset: yqi19/dagger

1027_sim_demo/<task>/collect_meta.json
1027_sim_demo/<task>/replay_buffer.zarr/
1027_sim_ckpt/<task>/latest.ckpt

Upload script: 1027_run/upload_results.sh


Cluster

  • Account: nvr_lpr_rvp, QOS: normal, Partition: batch_long
  • Node spec: L40s Γ— 4 GPUs per node, 56 CPUs, 48GB VRAM per GPU
  • --comment=fact_off on all jobs
  • Container mounts: /lustre/fsw/portfolios/nvr/users/jtremblay:/lustre/fsw/portfolios/nvr/users/jtremblay