Index
2026-05-09 — Engineering

RGB / PT / FF 3-way Latent Cache Split + 병렬 빌드

EgoX v2 (exp3) | Phase C — cache 분리 설계 구현

TL;DR

3
Cache 슬롯
16자
PT meta hash
~2×
병렬 빌드 속도 향상
0
HCPT 회귀

1 배경 / 목적

기존 모놀리식 cache는 use_pointmap on/off 모드별로 별도 디렉토리가 나뉘었고, RGB + PT를 합친 단일 텐서로 저장했다.

기존 구조의 문제 세 가지:
1. PT extractor 재실행(norm.json 갱신) 시 RGB latent까지 통째로 재인코딩 — 비용 낭비.
2. 학습 entry를 거쳐야만 cache를 채울 수 있어 사전 빌드가 불가.
3. RGB-only와 HCPT run의 cache 디렉토리가 달라 RGB latent 재사용 불가.

I2V A14B 마이그레이션(Phase B) 완료 직후 적용. backward compat는 신경 쓰지 않기로 명시적으로 결정(새 데이터로 학습 예정)해서 스키마를 깔끔하게 재설계.

2 작업 내용

Cache 디렉토리 구조 (신규)

<cache_root>/cache/video_latent/robocasa_hdf5/ <F>x<H>x<W>_rgb/ ← RGB row latent, use_pointmap 무관 reuse <key>_s<start>.safetensors <F>x<H>x<W>_pt__<hash16>/ ← PT row latent, PT extractor 변경 시 hash 변경 <key>_s<start>.safetensors <F>x<H>x<W>_ff[__<hash16>]/ ← first_frame latent <key>_s<start>.safetensors episodes/ ← 변경 없음 prompt_embeddings/ ← 변경 없음

PT meta hash (_pt_meta_hash())

입력: 모든 pt_norm_path(resolved_path, size, mtime_ns) + pt_norm_mean/std + pt_cache_root. 출력: sha256 16자. PT extractor 재실행 → norm.json mtime 변경 → hash 변경 → 새 _pt__<new_hash>/ dir 분기. RANK 0에서 first call 시 episode당 1 stat() (memoize 이후 무비용).

핵심 구현 변경 (robocasa_hdf5.py)

Standalone builder (scripts/build_robocasa_latent_cache.py)

accelerate launch --config_file configs_acc/4gpu.yaml \ scripts/build_robocasa_latent_cache.py \ --config configs/robocasa_i2v.yaml \ --mode {rgb|pt|ff|all} # --mode rgb: _rgb/ 만 빌드, PT/FF dir 미생성 # --mode pt: _pt__<hash>/ 만 빌드, RGB strict 의존 없음 # --mode all: 기존 lazy fill과 동일 (학습 startup 흐름)

Trainer 변경

trainer.py의 pre-filter 로직: monolithic vid_dir lookup 제거 → dataset.is_sample_cached(ep, s=0) 위임. trainer가 cache 기하구조(dir suffix, hash)를 직접 모르도록 결합도 감소.

3 결과

테스트ConfigModeGPU결과
Sanity모든 confignoneArgs.build_only_slot default None, 잘못된 값 raise 확인
RGB 전용 빌드smoke_rgbonlyrgb0_rgb/ 만 생성 (10 files). PT/FF dir 미생성
PT 전용 빌드smoke_hcptpt1_pt__651647b2b3b86f03/ 만 생성 (10 files)
병렬성 검증위 두 job 동시0+1timestamps 14s window 내 완전 overlap, 충돌 0
HCPT smoke 회귀smoke_hcptall0RGB+PT+FF 3 dirs 정상. 4 step + validation 통과. loss = 모놀리식과 동일
병렬 빌드 효과: 30K demo 기준 4-GPU multi-GPU sharding (~10h) → 4+4 GPU RGB||PT 병렬 (~5h) — 본격 데이터셋 cache 빌드 시간 ~2× 단축 가능.

본격 데이터셋 병렬 빌드 명령 (Next 단계)

# RGB와 PT를 동시 제출 (disjoint GPU 세트) sbm "accelerate launch --config_file configs_acc/4gpu.yaml \ scripts/build_robocasa_latent_cache.py \ --config configs/robocasa_i2v.yaml --mode rgb" \ --gres=gpu:4 -c 56 --mem 800GB --qos=share sbm "accelerate launch --config_file configs_acc/4gpu.yaml \ scripts/build_robocasa_latent_cache.py \ --config configs/robocasa_i2v.yaml --mode pt" \ --gres=gpu:4 -c 56 --mem 800GB --qos=share # PT 빌드 완료 후 FF 별도 (PT hash 일관성 위해) sbm "accelerate launch --config_file configs_acc/4gpu.yaml \ scripts/build_robocasa_latent_cache.py \ --config configs/robocasa_i2v.yaml --mode ff" \ --gres=gpu:4 -c 56 --mem 800GB --qos=share

수정된 파일 요약

파일변경 내용
core/finetune/datasets/robocasa_hdf5.py_RGB/PT/FF_SUFFIX 상수, _cache_dirs override, _pt_meta_hash, _build_rgb_row/_build_pt_row, _build_single_slot, _getitem_t2v 3-way split, build_only bypass
core/finetune/trainer.pyprepare_dataset kwargs forward, pre-filter is_sample_cached 위임
core/finetune/schemas/args.pystrict_rgb/pt/ff_must_exist, skip_ff, build_only_slot 필드 + CLI flags
scripts/build_robocasa_latent_cache.py신규 standalone builder, --mode {rgb,pt,ff,all}, sys.path 보정

4 Takeaway

의미

PT extractor 재실행 시 RGB 재인코딩 비용이 완전히 제거됐다. PT 데이터 품질 개선(view2 outlier fix 등)을 반복해도 RGB encoding을 다시 돌릴 필요가 없다. PT meta hash 메커니즘이 들어온 덕분에 PT extractor 수정 후 hash 자동 갱신으로 stale cache 참조 위험도 없다.

RGB || PT 진짜 병렬 빌드가 검증됐다. 30K demo 기준 4+4 GPU 동시 빌드로 10h → ~5h 단축. trainer.py의 cache 기하구조 직접 참조를 is_sample_cached로 위임해서 결합도도 낮아졌다.

5 Next Steps

본격 4-GPU LoRA 학습 sbm 제출

cache 사전 빌드 후 또는 lazy fill 방식으로 즉시 제출 가능. configs/robocasa_i2v.yaml (rank=64, boundary_ratio=0.875, use_pointmap=true).

PT view2 outlier fix (별도 plan)

view2 depth invalid pixel이 norm.json 통계를 오염시켜 pred PT cluster가 GT 기준 수백 m 밖에 위치하는 버그. PT meta hash 자동 invalidate 메커니즘이 들어왔으니 PT extractor 수정 후 hash 자동 갱신으로 안전하게 적용 가능.

Cosmetic: 빈 _rgb/ dir

build_only 모드(--mode pt/ff)에서도 RGB dir을 무조건 mkdir. 0 byte라 무해지만, _cache_dirs()의 RGB mkdir을 lazy(첫 RGB write 직전)로 미룰 수 있음. 우선순위 낮음.