跳转至

D3DHOI batched-loss speedup

Objective

Keep the canonical d3dhoi_default optimization mathematically equivalent while removing per-frame and per-candidate Python/GPU synchronization from joint search and HOI alignment.

Implemented

  • Joint-search candidates use batched FK, rendering, and loss evaluation.
  • Sampled HOI mask, center, contact, grasp, keypoint, joint-limit, and smoothness losses are batched over frames.
  • Object-local spatial and temporal contact losses use padded label-by-frame tensors with no runtime Python loop.
  • Object-only refinement computes fixed human geometry and grasp geometry once; human-only refinement recomputes trainable human geometry each iteration.
  • Result export loads and transforms immutable motion/camera data once for all stage writes.
  • Every active contact label receives a reference observation, including sequences that switch hands after the stable reference window.
  • Required joint_parameterization.mode is explicit in both canonical HOI phases.
  • Stage timing reports only synchronized elapsed time.

Verification

  • Optimization tests: 26 passed.
  • Real sanity: b001-0010_cad12561, 120 frames, one iteration per phase; final losses is float32[120] and finite.
  • Sanity timing: object-only 0.236 s; human-only 0.288 s.
  • Debug/non-debug real-case comparison: all 47 fields and tensor shapes match; maximum tensor difference is 4.88e-4 and passes the numerical tolerance.
  • Joint-search 41-candidate microbenchmark: 102.286 -> 3.526 ms (29.01x), maximum loss difference 4.77e-7.
  • Sampled 32-frame mask/center/contact forward-backward microbenchmark: 206.336 -> 3.726 ms (55.37x), identical loss and maximum gradient difference 9.31e-10.
  • Spatial contact microbenchmark: 13.521 -> 2.414 ms (5.60x), identical loss.
  • Temporal contact microbenchmark: 47.111 -> 6.071 ms (7.76x), loss difference about 3e-8.
  • Fixed-human grasp microbenchmark: 10.550 -> 7.952 ms (1.33x), identical loss.
  • Final canonical run: 20/20 cases completed on eight GPUs. All results share 47 persisted fields, all floating tensors are finite, all time-major shapes match their sequences, and no final log contains an exception.
  • Across 20 cases, synchronized median phase time is 15.313 s for object-only and 21.852 s for human-only.
  • End-to-end recon from existing preprocess through final result takes 141-235 s per case, with median 160.5 s and mean 163.8 s. The two HOI phases account for a median 37.148 s; object-pose reconstruction, joint search, loading, and result writing account for the remaining median 122.2 s.
  • The complete 20-case eight-GPU run took 521 s (8 min 41 s) wall time.

Logs and raw benchmark JSON are under output/runs/bench_d3dhoi_batched_loss/.

Contact-density repeats

Each case ran three full 200-iteration repeats. Times below are synchronized medians.

  • Low b004-0033_cad7221 (80/125): object-only 16.097 s, human-only 22.513 s.
  • Median b005-0024_cad10900 (168/201): object-only 13.604 s, human-only 20.127 s.
  • High b004-0017_cad7221 (125/125): object-only 17.125 s, human-only 23.985 s.